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

spirv-opt: VK_EXT_scalar_block_layout is not supported properly #3153

Open
tomilov opened this issue Jan 24, 2020 · 4 comments
Open

spirv-opt: VK_EXT_scalar_block_layout is not supported properly #3153

tomilov opened this issue Jan 24, 2020 · 4 comments

Comments

@tomilov
Copy link

tomilov commented Jan 24, 2020

The following shader pathtrace.rchit.glsl

#extension GL_EXT_scalar_block_layout : require

layout(scalar, set=DSRender, binding=BindingRdSeqBuffer) uniform UBO {
  uint rd_seq[1056];
} ubo;

void main() {
  if (ubo.rd_seq[1] != 2447445414u) {
    return;
  }
  if (ubo.rd_seq[1055] != 2159022709u) {
    return;
  }
}

compiled by glslangValidator -g -V pathtrace.rchit.glsl -o pathtrace.rchit.debug.spv. Output is to be optimized as spirv-opt -O pathtrace.rchit.debug.spv -o pathtrace.rchit.spv, but the following error is occured:

/home/user/Projects/render/shaders/pathtrace.rchit.glsl
error: line 1046: Structure id 2601 decorated as Block for variable in Uniform storage class must follow standard uniform buffer layout rules: member 0 contains an array with stride 4 not satisfying alignment to 16
  %UBO = OpTypeStruct %_arr_uint_uint_1056

As I can see --scalar-block-layout is the option of spirv-val, not spirv-opt. So I can't tell to spirv-opt that extension is enabled.

@tomilov
Copy link
Author

tomilov commented Jan 24, 2020

My workaround is to replace spirv-opt invocation to spirv-opt --skip-validation then spirv-val --scalar-block-layout.
But now I see noisy warning from validation layers:

vkDebug: Validation: 0:  [ UNASSIGNED-CoreValidation-Shader-InconsistentSpirv ] Object: VK_NULL_HANDLE (Type = 0) | SPIR-V module not valid: Structure id 2601 decorated as Block for variable in Uniform storage class must follow relaxed uniform buffer layout rules: member 0 contains an array with stride 4 not satisfying alignment to 16
  %_struct_2601 = OpTypeStruct %_arr_uint_uint_1056

@sfricke-samsung
Copy link
Contributor

I was looking into the --scalar-block-layout stuff right now, my question is why can't the core SPIR-V tools just detect the present of #extension GL_EXT_scalar_block_layout and enabled it then, why is there even a need for a flag as other extensions don't need to be opt'ed in like this

@fu5ha
Copy link

fu5ha commented May 21, 2021

I was looking into the --scalar-block-layout stuff right now, my question is why can't the core SPIR-V tools just detect the present of #extension GL_EXT_scalar_block_layout and enabled it then, why is there even a need for a flag as other extensions don't need to be opt'ed in like this

AFAICT, it's because this extension doesn't make any modification to the spir-v itself, the limitation being lifted is within the vulkan implementation. Sure would be nice to have an extension flag to set in the spirv to indicate that we want to make use of that though.

@khyperia
Copy link
Contributor

I believe this issue was fixed by #3314, which added the --scalar-block-layout flag to spirv-opt

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

No branches or pull requests

5 participants