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

Handle multiple PhysicalStorageBuffer in same struct #232

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

spencer-lunarg
Copy link
Contributor

closes #230
closes #231

@muraj and @danginsburg if you want to make sure this works for both your use cases that would be helpful

spirv_reflect.c Outdated
@@ -2448,6 +2477,18 @@ static SpvReflectResult ParseDescriptorBlockVariable(
}
}
if (!found_recursion) {
uint32_t struct_id = FindType(p_module, p_member_type->id)
->struct_type_description->id;
p_parser
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chaoticbob I'm going to just make a PR to run clang-format with more than 80 lines as this starts to just become unnecessarily hard to read

@@ -320,398 +320,3 @@ all_type_descriptions:
members:
- *td13
- *td16
- &td18
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked, these were duplicates (these tests do recursion looping) so this is actually good it was removed

@muraj
Copy link

muraj commented Nov 3, 2023

Sure, I'll give it a try tonight, thank you very much for such a fast response!

@muraj
Copy link

muraj commented Nov 3, 2023

Yup, this change is working for me, thanks again!

@danginsburg
Copy link
Contributor

danginsburg commented Nov 6, 2023

I tested this change, it does seem to not assert anymore, but I'm not getting any information about which members of a buffer_reference are statically referenced, I just see this in the output:

`Push constant blocks: 1

0:
  spirv id : 1649
  name     : g_GlobalsBDAPushConstant_0 (_S2)
      // size = 96, padded size = 96
      struct _S2 {

          // abs offset = 0, rel offset = 0, size = 96, padded size = 96, array stride = 16
          ref struct BufferPointer_BDAGlobals_t_0_1 {
          } g_GlobalsBDAPerStage_0[6];

      } g_GlobalsBDAPushConstant_0;`

My understanding from @greg-lunarg is that it should be reporting which members are statically referenced.

The shader in #231 demonstrates this problem. You can now reflect the buffer_reference, but shouldn't it show that only g_GlobalsBDAPerStage_0[6]._data.g_vTest is referenced?

@danginsburg
Copy link
Contributor

danginsburg commented Nov 7, 2023

Hi @spencer-lunarg - I am trying to look at this change some more. When I run your change on tests\glsl\buffer_pointer.spv I see:

D:\Users\Dan\src\SPIRV-Reflect\tests\glsl>..\..\bin\Debug\spirv-reflect.exe -v 2 buffer_pointer.spv
generator       : Khronos Glslang Reference Front End
source lang     : GLSL
source lang ver : 460
source file     : buffer_pointer.glsl
entry point     : main (stage=PS)


  Output variables: 1

    0:
      spirv id  : 26
      location  : 0
      type      : float4
      semantic  :
      name      : Color
      qualifier :


  Push constant blocks: 1

    0:
      spirv id : 14
      name     : push (PushData)
          // size = 16, padded size = 16
          struct PushData {

              // abs offset = 0, rel offset = 0, size = 8, padded size = 16
              ref struct Data {
              } data_ptr;

          } push;

In @greg-lunarg original PR (https://github.com/KhronosGroup/SPIRV-Reflect/pull/180/files) both in the spirv-reflect output and yaml it would report on the referenced variables g0/g1/g2, i.e.:

      name     : push (PushData)
          // size = 16, padded size = 16
          struct PushData {

              // abs offset = 0, rel offset = 0, size = 8, padded size = 16
              ref struct Data {
                  float g0; // abs offset = 0, rel offset = 0, size = 4, padded
size = 4 UNUSED
                  float g1; // abs offset = 4, rel offset = 4, size = 4, padded
size = 4
                  float g2; // abs offset = 8, rel offset = 8, size = 4, padded
size = 8 UNUSED
              } data_ptr;

          } push;

I am trying also to use the API and I am not seeing how I can reflect out which members pointed to by the buffer_ref's in the push_constant are active. So it seems this change isn't fully working?

@spencer-lunarg
Copy link
Contributor Author

spencer-lunarg commented Nov 8, 2023

@danginsburg looking into fixing the print-out logic now

I am not seeing how I can reflect out which members pointed to by the buffer_ref's in the push_constant are active

this is an orthogonal issue of spirv-reflect as the accessed flag is only in the DescriptorBinding and not currently found at a push constant level (that will require adding logic to mark accesses at a more fine granularity)

@danginsburg
Copy link
Contributor

Is this ready for me to test again or are you still working on the PR?

@spencer-lunarg
Copy link
Contributor Author

ready to be tested, now convinced I fixed the issues, added another test as well

@danginsburg
Copy link
Contributor

From my testing so far, this PR now does seem to correctly fill in the SPV_REFLECT_VARIABLE_FLAGS_UNUSED flag for the unused BDA fields.

@spencer-lunarg spencer-lunarg force-pushed the spencer-lunarg-230 branch 2 times, most recently from 712509e to c1cc754 Compare December 20, 2023 08:36
@spencer-lunarg spencer-lunarg force-pushed the spencer-lunarg-230 branch 2 times, most recently from 4f4a25c to 6663324 Compare December 20, 2023 08:55
Copy link
Contributor

@chaoticbob chaoticbob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit

spirv_reflect.c Outdated Show resolved Hide resolved
@spencer-lunarg spencer-lunarg merged commit 4aedb50 into KhronosGroup:main Dec 21, 2023
5 checks passed
@spencer-lunarg spencer-lunarg deleted the spencer-lunarg-230 branch December 21, 2023 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants