KhronosGroup / KhronosGroup/SPIRV-Reflect
Adding additional word offsets to `SpvReflectBlockVariable`
- Dominant language
- C
- Stars
- 871
- Forks
- 188
- Avg merge
- 19m
- Merged PRs (30d)
- 1
Description
Hey there,
It would be useful to be able to reflect the word offset of `offset` in UBOs, this allows you to reorder and compact structs.
(This is mostly for dealing with floating hlsl `$Globals`)
This was a very trivial patch for me to implement locally, if it's something you wouldn't be against I can quickly put together a PR.
```diff
--- aspirv_reflect/spirv_reflect.c
+++ bspirv_reflect/spirv_reflect.c
@@ -2272,6 +2272,8 @@ static SpvReflectResult ParseDescriptorBlockVariable(
ApplyArrayTraits(p_member_type, &p_member_var->array);
}
+ p_member_var->word_offset.offset = p_type_node->member_decorations[member_index].offset.word_offset;
+
p_member_var->type_description = p_member_type;
}
}
--- aspirv_reflect/spirv_reflect.h
+++ bspirv_reflect/spirv_reflect.h
@@ -378,6 +378,10 @@ typedef struct SpvReflectBlockVariable {
uint32_t member_count;
struct SpvReflectBlockVariable* members;
+ struct {
+ uint32_t offset;
+ } word_offset;
+
SpvReflectTypeDescription* type_description;
} SpvReflectBlockVariable;
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in aspirv_reflect.h at SpvReflectBlockVariable and in aspirv_reflect.c at ParseDescriptorBlockVariable, following the proposed diff. Confirm how member decorations expose the offset word value and ensure the reflected block variable makes it available for UBO members; done means the requested offset is exposed through the reflection API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100