Skip to content

Conversation

@pobrn
Copy link

@pobrn pobrn commented Sep 30, 2025

The first commit adds a diagnostic when local_size_*_id is used when targeting < SPIR-V 1.2. I think it would be nice to get a diagnostic if the qualifier will be ignored in the end; I was surprised by this behaviour.

The second commit essentially applies #3351 to mesh and task shaders (#3739).

The third commit, I'm not entirely sure about, but according to https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpExecutionModeId local_size_*_id should be available when targeting at least SPIR-V 1.2, so that commit lowers the required versions.

The fourth is a trivial cleanup.

Related:

`OpExecutionModeId` and the `LocalSizeId` execution mode are missing before
SPIR-V 1.2[0], and currently when targeting an earlier version, it is ignored
and the work group sizes are set to 1 instead without any diagnostic.

So to prevent surprises, reject `local_size_*_id` layout qualifiers when
targeting a SPIR-V version before 1.2.

[0]: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpExecutionModeId
Only use `LocalSizeId` when necessary, same changes as KhronosGroup#3351
but applied to mesh and task shaders.

Fixes KhronosGroup#3739
`OpExecutionModeId` and the `LocalSizeId` execution mode were added in
SPIR-V 1.2[0]. So use them when targeting at least 1.2.

[0]: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpExecutionModeId

See KhronosGroup#3510
Changing the value of `needSizeId` in the loop will have no
effect because it is not checked after that anywhere.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

}
}
if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_6 && needSizeId) {
if (glslangIntermediate->getSpv().spv >= glslang::EShTargetSpv_1_2 && needSizeId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please add a test for this? The one in #3510 seems fine. Also, please split it into its own PR for clarity.

Copy link
Author

Choose a reason for hiding this comment

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

I suppose I should add it to Spv.FromFile.cpp? And I imagine I can just add two new test suites CompileToSpirv11Test and CompileToSpirv12Test, and then use the same input file for both?

@pobrn
Copy link
Author

pobrn commented Oct 7, 2025

I have somehow missed the test suite, sorry. These changes generate 11 failures:

[----------] Global test environment tear-down
[==========] 1782 tests from 71 test suites ran. (61587 ms total)
[  PASSED  ] 1771 tests.
[  FAILED  ] 11 tests, listed below:
[  FAILED  ] Glsl/LinkTestVulkan.FromFile/9, where GetParam() = { "link.vk.multiUnitLayout.0.comp", "link.vk.multiUnitLayout.1.comp" }
[  FAILED  ] Glsl/LinkTestVulkan.FromFile/10, where GetParam() = { "link.vk.multiUnitLayout.2.comp", "link.vk.multiUnitLayout.0.comp" }
[  FAILED  ] Glsl/CompileVulkanToSpirvTest.FromFile/spv_noWorkgroup_comp, where GetParam() = "spv.noWorkgroup.comp"
[  FAILED  ] Glsl/CompileVulkanToSpirvTest.FromFile/spv_specConstant_comp, where GetParam() = "spv.specConstant.comp"
[  FAILED  ] Glsl/CompileVulkanToSpirvTest.FromFile/spv_tensorARM_params_comp, where GetParam() = "spv.tensorARM.params.comp"
[  FAILED  ] Glsl/CompileVulkan1_1ToSpirvTest.FromFile/spv_atomicAdd_bufferReference_comp, where GetParam() = "spv.atomicAdd.bufferReference.comp"
[  FAILED  ] Glsl/VulkanSemantics.FromFile/vulkan_comp, where GetParam() = "vulkan.comp"
[  FAILED  ] Glsl/CompileVulkanToSpirv13TestQCOM.FromFile/spv_qcom_coopmatConversion_1_comp, where GetParam() = "spv.qcom.coopmatConversion.1.comp"
[  FAILED  ] Glsl/CompileVulkanToSpirv13TestQCOM.FromFile/spv_qcom_coopmatConversion_2_comp, where GetParam() = "spv.qcom.coopmatConversion.2.comp"
[  FAILED  ] Glsl/CompileVulkanToSpirvTestNV.FromFile/spv_computeShaderDerivativesSpec_comp, where GetParam() = "spv.computeShaderDerivativesSpec.comp"
[  FAILED  ] Glsl/CompileVulkanToSpirvTestNV.FromFile/spv_computeShaderDerivativesSpec2_comp, where GetParam() = "spv.computeShaderDerivativesSpec2.comp"

11 FAILED TESTS

Mostly due to to new "requires SPIR-V 1.2" error message.

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 this pull request may close these issues.

3 participants