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

OpUConvert for specialization constant should not generate spirv-opt error. #3506

Open
castano opened this issue Feb 12, 2024 · 3 comments
Open

Comments

@castano
Copy link

castano commented Feb 12, 2024

When I compile the following program:

#version 450
#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require

layout (constant_id = 0) const uint local_size_x = 8;
layout (constant_id = 1) const uint local_size_y = 8;
layout (local_size_x_id = 0, local_size_y_id = 1, local_size_z = 1) in;

void main() {
    u16vec2 tid = u16vec2(gl_LocalInvocationID.xy);
    uint16_t idx = tid.y * uint16_t(gl_WorkGroupSize.x) + tid.x;
}

As follows:

glslangValidator.exe -V100 -e main repro.comp.glsl -o spirv/repro.comp.spv
spirv-opt.exe -O spirv/repro.comp.spv -o spirv/repro.comp.opt.spv

spirv-opt produces the following error:

error: line 38: Prior to SPIR-V 1.4, specialization constant operation UConvert requires Kernel capability or extension SPV_AMD_gpu_shader_int16
  %28 = OpSpecConstantOp %ushort UConvert %27

According to #848 the spec has been updated to include OpUConvert in the list of permitted opcodes. Is this a spirv-opt error?

I'm using the most recent builds that are publicly available:

$ glslangValidator.exe --version
Glslang Version: 11:14.0.0
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 14.0.0
GLSL Version: 4.60 glslang Khronos. 14.0.0
SPIR-V Version 0x00010600, Revision 1
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 11
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

$ spirv-opt.exe --version
SPIRV-Tools v2023.6 v2023.6.rc1-0-gf0cc85ef
@castano castano closed this as completed Feb 12, 2024
@castano
Copy link
Author

castano commented Feb 12, 2024

Sorry, reported to wrong repository.

@castano
Copy link
Author

castano commented Feb 12, 2024

Reposted here: KhronosGroup/SPIRV-Tools#5571

@arcady-lunarg
Copy link
Contributor

This is technically a glslang error I think, SPIR-V 1.0 does indeed have the restriction you mention and so glslang should not be generating this code because you explicitly requested SPIR-V 1.0.

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