Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding additional word offsets to SpvReflectBlockVariable #158

Open
alister-chowdhury opened this issue Sep 18, 2022 · 2 comments
Open

Adding additional word offsets to SpvReflectBlockVariable #158

alister-chowdhury opened this issue Sep 18, 2022 · 2 comments

Comments

@alister-chowdhury
Copy link
Contributor

alister-chowdhury commented Sep 18, 2022

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.

--- 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;
@chaoticbob
Copy link
Contributor

Hi apologies for the late reply. Definitely not against it if it's useful to you - so definitely would love a PR. Just a couple of things:

  1. Looking at SpvReflectBlockVariable - it seems like embedded struct isn't necessary, so a member called word_offset should be sufficient. I don't have a strong opinion on this.
  2. Can you add it to the end of the struct?

Thanks!

@alister-chowdhury
Copy link
Contributor Author

That sounds fine, will put something together hopefully sooner rather than later.
The word offset part was just to match the existing convention (since I suppose, it might be desirable in the future to have the word offsets of other things such as alignment and whatknot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants