RHI vulkan updates
This commit is contained in:
@@ -36,6 +36,16 @@ All code follows the patterns established in `src/wapp/`. The project prefix is
|
||||
|
||||
- **Tabs for indentation**, 8-column tab width.
|
||||
- **Braces** on the same line as control statements (Attach style).
|
||||
- **Braces on single-line if statements**: Always use braces, even for single-line bodies:
|
||||
```c
|
||||
// correct
|
||||
if (!buffer) { return; }
|
||||
if (!texture) { _abort("alloc failed"); }
|
||||
|
||||
// wrong
|
||||
if (!buffer) return;
|
||||
if (!texture) _abort("alloc failed");
|
||||
```
|
||||
- **Pointers**: `*` against the name, not the type (`PrRhiBuffer *buf`, not `PrRhiBuffer* buf`).
|
||||
- **Line width**: 120 columns.
|
||||
- **Continuation lines** align to the opening parenthesis.
|
||||
@@ -117,6 +127,24 @@ prefer SoA layouts, batch processing, and minimise pointer chasing. Keep
|
||||
the DAG in contiguous arrays (e.g. adjacency lists packed in flat buffers)
|
||||
rather than individually allocated linked structures.
|
||||
|
||||
### Frame-by-frame command batching
|
||||
|
||||
Commands that execute every frame must avoid arena allocation. Use stack
|
||||
arrays with a while-loop to batch operations in fixed-size chunks:
|
||||
|
||||
```c
|
||||
while (count > 0) {
|
||||
VkTypeArray batch = wpArrayWithCapacity(VkType, 16, WP_ARRAY_INIT_FILLED);
|
||||
u32 batch_size = count < wpArrayCapacity(batch) ? count : (u32)wpArrayCapacity(batch);
|
||||
// ... process batch ...
|
||||
vkCmd*(cb->handle, ...);
|
||||
count -= batch_size;
|
||||
first += batch_size;
|
||||
}
|
||||
```
|
||||
|
||||
This avoids per-frame arena churn while handling arbitrarily large inputs.
|
||||
|
||||
### Graph / adjacency lists
|
||||
|
||||
Adjacency list nodes must be **separately allocated from the vertex array**.
|
||||
|
||||
Reference in New Issue
Block a user