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

Assertion in dead member elimination with spec constants #3282

Closed
godlikepanos opened this issue Apr 7, 2020 · 2 comments · Fixed by #3289
Closed

Assertion in dead member elimination with spec constants #3282

godlikepanos opened this issue Apr 7, 2020 · 2 comments · Fixed by #3289
Assignees

Comments

@godlikepanos
Copy link

Hi,

I have this compute shader:

#version 450 core

layout(constant_id = 0) const int c_0 = 1;

layout(local_size_x_id = 1, local_size_y = 1, local_size_z = 1) in;

void main()
{
}

Compiling it with glslang without opts will give this:

              OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint GLCompute %main "main"
               OpExecutionMode %main LocalSize 1 1 1
               OpSource GLSL 450
               OpName %main "main"
               OpName %c_0 "c_0"
               OpDecorate %c_0 SpecId 0
               OpDecorate %9 SpecId 1
               OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
        %int = OpTypeInt 32 1
        %c_0 = OpSpecConstant %int 1
       %uint = OpTypeInt 32 0
          %9 = OpSpecConstant %uint 1
     %uint_1 = OpConstant %uint 1
     %v3uint = OpTypeVector %uint 3
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %9 %uint_1 %uint_1
       %main = OpFunction %void None %3
          %5 = OpLabel
               OpReturn
               OpFunctionEnd

Using spirv-opt with -Os throws this assertion:

spirv-opt: /xxx/source/opt/eliminate_dead_members_pass.cpp:397: bool spvtools::opt::EliminateDeadMembersPass::UpdateConstantComposite(spvtools::opt::Instruction*): Assertion `inst->opcode() == SpvOpConstantComposite || inst->opcode() == SpvOpCompositeConstruct' failed.

Any idea what might be wrong?

@greg-lunarg
Copy link
Contributor

May want to change title to:

Assertion in dead member elimination with spec constants

@godlikepanos godlikepanos changed the title Assertion in dead pass elimination with spec constants Assertion in dead member elimination with spec constants Apr 7, 2020
@godlikepanos
Copy link
Author

May want to change title to:

Assertion in dead member elimination with spec constants

Done. Thanks

@s-perron s-perron self-assigned this Apr 9, 2020
s-perron added a commit that referenced this issue Apr 9, 2020
* Handle more cases in dead member elim

- Rewrite composite insert and extract operations on SpecConstnatOp.
- Leaves assert for Access chain instructions, which are only allowed
for kernels.
- Other operations do not require any extra code will no longer cause an
assert.

Fixes #3284.
Fixes #3282.
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

Successfully merging a pull request may close this issue.

3 participants