# beratdizdar/cd3d11 architecture

> Architecture diagram of the GitHub repository beratdizdar/cd3d11, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/beratdizdar/cd3d11
- Repository: https://github.com/beratdizdar/cd3d11

## Overview

cd3d11 is a small C wrapper around Direct3D 11, intended to simplify C-side API use and COM object lifetime management. The principal workflow is to open and select a device instance, create resources and shaders, configure the pipeline, then draw, clear, and present; timestamp queries are a separate capability. The README describes the usability goals but not call sequencing, so actor-to-entry links are dashed. Runtime behavior is evidenced by the sampled implementation; no separate application code is present.

Main entry points: [`d11_internal.c`](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c) (Shader creation), [`d11_open.c`](https://github.com/beratdizdar/cd3d11/blob/main/d11_open.c) (Open and close), [`d11_object.c`](https://github.com/beratdizdar/cd3d11/blob/main/d11_object.c) (Resource creation), [`d11.h`](https://github.com/beratdizdar/cd3d11/blob/main/d11.h) (Public API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Device lifecycle"]
  node_instance["Device state<br/>[d11_internal.h]"]
  node_device_lifecycle["Open and close<br/>[d11_open.c]"]
  node_com_helpers["COM and result helpers<br/>[d11_internal.c]"]
end

subgraph group_resources["GPU resources"]
  node_resource_creation["Resource creation<br/>[d11_object.c]"]
  node_memory_update["Mapped updates<br/>[d11_internal.c]"]
end

subgraph group_rendering["Rendering"]
  node_shader_creation["Shader creation<br/>[d11_internal.c]"]
  node_pipeline["Pipeline selection<br/>[d11_internal.c]"]
  node_draw_present["Draw and present<br/>[d11_internal.c]"]
end

subgraph group_timing["Timing and diagnostics"]
  node_timestamps["Timestamp queries<br/>[d11_internal.c]"]
end

node_caller(("C application"))
node_api["Public API<br/>[d11.h]"]

node_caller -.->|"uses"| node_api
node_api -.->|"opens instance"| node_device_lifecycle
node_device_lifecycle -->|"creates state"| node_instance
node_caller -.->|"creates resources"| node_resource_creation
node_caller -.->|"updates buffers"| node_memory_update
node_caller -.->|"creates shaders"| node_shader_creation
node_shader_creation -->|"checks results"| node_com_helpers
node_shader_creation -->|"loads file shaders"| node_shader_creation
node_caller -.->|"sets pipeline"| node_pipeline
node_caller -.->|"executes rendering"| node_draw_present
node_caller -.->|"measures time"| node_timestamps
node_device_lifecycle -->|"releases objects"| node_com_helpers
node_resource_creation -->|"releases slots"| node_com_helpers

click node_api "https://github.com/beratdizdar/cd3d11/blob/main/d11.h"
click node_instance "https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.h"
click node_device_lifecycle "https://github.com/beratdizdar/cd3d11/blob/main/d11_open.c"
click node_resource_creation "https://github.com/beratdizdar/cd3d11/blob/main/d11_object.c"
click node_memory_update "https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c"
click node_shader_creation "https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c"
click node_pipeline "https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c"
click node_draw_present "https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c"
click node_timestamps "https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c"
click node_com_helpers "https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_instance,node_device_lifecycle,node_com_helpers toneBlue
class node_resource_creation,node_memory_update toneAmber
class node_shader_creation,node_pipeline,node_draw_present,node_api toneMint
class node_timestamps toneRose
class node_caller toneIndigo
```

## Components

### Device lifecycle

- [Device state](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.h): `d11_internal.h`
- [Open and close](https://github.com/beratdizdar/cd3d11/blob/main/d11_open.c): `d11_open.c`
- [COM and result helpers](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c): `d11_internal.c`

### GPU resources

- [Resource creation](https://github.com/beratdizdar/cd3d11/blob/main/d11_object.c): `d11_object.c`
- [Mapped updates](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c): `d11_internal.c`

### Rendering

- [Shader creation](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c): `d11_internal.c`
- [Pipeline selection](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c): `d11_internal.c`
- [Draw and present](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c): `d11_internal.c`

### Timing and diagnostics

- [Timestamp queries](https://github.com/beratdizdar/cd3d11/blob/main/d11_internal.c): `d11_internal.c`

### Other components

- **C application**
- [Public API](https://github.com/beratdizdar/cd3d11/blob/main/d11.h): `d11.h`

## Connections

- C application → Public API: uses (evidence: `readme.md`)
- Public API → Open and close: opens instance (evidence: `d11.h`)
- Open and close → Device state: creates state (evidence: `d11_open.c`)
- C application → Resource creation: creates resources
- C application → Mapped updates: updates buffers
- C application → Shader creation: creates shaders
- Shader creation → COM and result helpers: checks results (evidence: `d11_internal.c`)
- Shader creation → Shader creation: loads file shaders (evidence: `d11_internal.c`)
- C application → Pipeline selection: sets pipeline
- C application → Draw and present: executes rendering
- C application → Timestamp queries: measures time
- Open and close → COM and result helpers: releases objects (evidence: `d11_open.c`)
- Resource creation → COM and result helpers: releases slots (evidence: `d11_object.c`)
