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

OpCapability StorageImageRead/WriteWithoutFormat is added to spirv in spirv_1_3 profile when it's not required by the shader #5969

Closed
jjiangweilan opened this issue Dec 31, 2024 · 3 comments

Comments

@jjiangweilan
Copy link

If I compile the following code with Vulkan 1.1 with profile spirv_1_3. The Vulkan validation layer will throw an error because OpCapability StorageImageReadWithoutFormat and OpCapability StorageImageWriteWithoutFormat are added while it's not necessary

[ VUID-VkShaderModuleCreateInfo-pCode-08740 ] | MessageID = 0x6e224e9 | vkCreateShaderModule():  SPIR-V Capability StorageImageReadWithoutFormat was declared, but one of the following requirements is required (VkPhysicalDeviceFeatures::shaderStorageImageReadWithoutFormat OR VK_VERSION_1_3 OR VK_KHR_format_feature_flags2). The Vulkan spec states: If pCode is a pointer to SPIR-V code, and pCode declares any of the capabilities listed in the SPIR-V Environment appendix, one of the corresponding requirements must be satisfied (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-08740)
struct PerMaterial
{
RWTexture2D<float4> outputTex;
}

ParameterBlock<PerMaterial> perMaterial;

[shader("compute")]
[numthreads(8,8,1)]
void FragmentMain(uint3 id : SV_DispatchThreadID)
{
    perMaterial.outputTex[id.xy] = float4(0.5);
}
@csyonghe
Copy link
Collaborator

I believe these two capabilities are required because the texture does not specify its storage format. You will need to mark your texture declaration with [format("rgba8")] attribute to remove the requirement.

@fairywreath
Copy link
Contributor

@csyonghe These caps are enabled by this code in slang-emit-spirv.cpp:

// TODO: It may not be necessary to have both of these
// depending on if we read or write
requireSPIRVCapability(SpvCapabilityStorageImageReadWithoutFormat);
requireSPIRVCapability(SpvCapabilityStorageImageWriteWithoutFormat);

when checking texture type, in this case RWTexture2D.

We should be able to do something like moving these from being enabled here to during load/store and subscript set/get calls so we can enable them individually. although this would require some work. In the example above only SpvCapabilityStorageImageWriteWithoutFormat should be enabled.

@jjiangweilan
Copy link
Author

jjiangweilan commented Dec 31, 2024

I believe these two capabilities are required because the texture does not specify its storage format. You will need to mark your texture declaration with [format("rgba8")] attribute to remove the requirement.

thank you for the reply. It's indeed my lack of understanding.

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

3 participants