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

Compute shaders compiling to spir-v version 1.6 generates Vulkan validation error due to OpExecutionMode #1414

Open
Wlammm opened this issue May 1, 2024 · 1 comment

Comments

@Wlammm
Copy link

Wlammm commented May 1, 2024

Compiling this shader (TestShader.comp):

#version 450

layout (local_size_x = 256) in;

void main() {
// Compute shader code
}

using this code:

shaderc::Compiler compiler;
shaderc::CompileOptions options;
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_3);
options.SetWarningsAsErrors();
options.SetGenerateDebugInfo();
options.SetTargetSpirv(shaderc_spirv_version_1_6);
options.SetOptimizationLevel(shaderc_optimization_level_performance);
shaderc::SpvCompilationResult result = compiler.CompileGlslToSpv(shaderSource, shaderc_compute_shader, inputFileName, options);

generates this validation error when running vkCreateShaderModule:

{ Validation } Validation Error: [ VUID-RuntimeSpirv-LocalSizeId-06434 ] | MessageID = 0xf95e08b7 | vkCreateShaderModule(): SPIR-V OpExecutionMode LocalSizeId is used but maintenance4 feature was not enabled. The Vulkan spec states: If Execution Mode LocalSizeId is used, maintenance4 must be enabled

This does not happen if I change the target spir-v version to shaderc_spirv_version_1_5.
This does not happen if I compile it directly with glslc.exe -c TestShader.comp.

Tested on Vulkan version 1.3 with Vulkan SDK version 1.3.280.0 and whatever shaderc version is included there.

@Wlammm Wlammm changed the title Compute shaders compiling to version spir-v version 1.6 generates Vulkan validation error due to OpExecutionMode Compute shaders compiling to spir-v version 1.6 generates Vulkan validation error due to OpExecutionMode May 1, 2024
@felix-ri
Copy link

felix-ri commented Sep 23, 2024

I have a similar issue with compiling this simple MeshShader with this commandline glslc --target-env=vulkan1.3 --target-spv=spv1.6 .\MeshShader.glsl:

#version 450
#extension GL_EXT_mesh_shader : enable
#pragma shader_stage(mesh)

layout(local_size_x = 128, local_size_y = 1, local_size_z = 1) in;

layout(triangles) out;
layout(max_vertices = 256, max_primitives = 256) out;

void main()
{
}

This results in OpExecutionModeId LocalSizeId 128 1 1, which seems wrong to me, as the 128 should not specify any Id, but the literal Workgroup Size.

Compiling it with --target-spv=spv1.5 results in OpExecutionMode LocalSize 128 1 1, which seems to be correct to me.

Compiling it with --target-spv=spv1.6 results in OpExecutionModeId LocalSizeId 128 1 1, which is wrong.

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