You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[vulkan] Add a buffer index offset during codegen to allow arbitrary crop offsets (#8954)
* Add an index offset during codegen to allow arbitrary offsets when accessing buffers to avoid restrictive alignment constraints.
CodeGen now adds one int32 buffer offset param for each buffer after all other scalar args
The runtime packs these params into the uniform buffer for each storage buffer
Crop device now computes an index offset (instead of a byte offset
Copy to/from device recomputes a byte offset from this index offset
* Refactor cleanup to remove unused MemoryRegion.range.
Adjusted relative offsets to use indexing for buffer copies.
Added RegionAllocation and RegionIndexing to clarify mapping.
Updated all affected interfaces.
* Clang formatting pass
Copy file name to clipboardExpand all lines: src/CodeGen_Vulkan_Dev.cpp
+85-5Lines changed: 85 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -147,6 +147,8 @@ class CodeGen_Vulkan_Dev : public CodeGen_GPU_Dev {
147
147
voidstore_at_scalar_index(const Store *op, SpvId index_id, SpvId variable_id, Type value_type, Type storage_type, SpvStorageClass storage_class, SpvId value_id);
148
148
voidstore_at_vector_index(const Store *op, SpvId variable_id, Type value_type, Type storage_type, SpvStorageClass storage_class, SpvId value_id);
Copy file name to clipboardExpand all lines: src/runtime/internal/memory_resources.h
+9-7Lines changed: 9 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -69,18 +69,20 @@ struct MemoryBlock {
69
69
MemoryProperties properties; //< properties for the allocated block
70
70
};
71
71
72
-
// Client-facing struct for specifying a range of a memory region (eg for crops)
73
-
structMemoryRange {
74
-
size_t head_offset = 0; //< byte offset from start of region
75
-
size_t tail_offset = 0; //< byte offset from end of region
72
+
structRegionAllocation {
73
+
size_t offset = 0; //< offset from base address in block (in bytes)
74
+
size_t size = 0; //< allocated size in block (in bytes)
75
+
};
76
+
77
+
structRegionIndexing {
78
+
int32_t offset = 0; //< indexing offset from start of region (used to adjust indices in compute shader to avoid alignment constraints for arbitrary crops)
76
79
};
77
80
78
81
// Client-facing struct for exchanging memory region allocation requests
79
82
structMemoryRegion {
80
83
void *handle = nullptr; //< client data storing native handle (managed by alloc_block_region/free_block_region) or a pointer to region owning allocation
81
-
size_t offset = 0; //< offset from base address in block (in bytes)
82
-
size_t size = 0; //< allocated size (in bytes)
83
-
MemoryRange range; //< optional range (e.g. for handling crops, etc)
84
+
RegionAllocation allocation; //< allocation in parent block for region
85
+
RegionIndexing indexing; //< indexing adjustments for controlling access
84
86
bool dedicated = false; //< flag indicating whether allocation is one dedicated resource (or split/shared into other resources)
85
87
bool is_owner = true; //< flag indicating whether allocation is owned by this region, in which case handle is a native handle. Otherwise handle points to owning region of alloction.
86
88
MemoryProperties properties; //< properties for the allocated region
0 commit comments