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

[SPIRV] Can't use Buffer<half> in shader #4372

Closed
gongminmin opened this issue Apr 1, 2022 · 1 comment · Fixed by #6242
Closed

[SPIRV] Can't use Buffer<half> in shader #4372

gongminmin opened this issue Apr 1, 2022 · 1 comment · Fixed by #6242
Labels
spirv Work related to SPIR-V

Comments

@gongminmin
Copy link
Contributor

A simple HLSL:

Buffer<half> buffer;
float4 HalfBufferPS(uint coord : TEXCOORD0) : SV_Target0
{
	return float4(buffer[coord], 0.0f, 0.0f, 1.0f);
}

compiled with ps_6_2 -enable-16bit-types and -spirv. It returns an error message:

error: cannot translate resource type parameter 'half' to proper image format
Buffer<half> buffer;

StructuredBuffer is OK, but Buffer doesn't. It's related to #1672.

@jaebaek jaebaek added the spirv Work related to SPIR-V label Apr 4, 2022
@gongminmin
Copy link
Contributor Author

gongminmin commented Apr 6, 2022

Texture<half4> and RWTexture<half4> those kinds of data types also don't work in SPIR-V back-end.

sudonatalie added a commit to sudonatalie/DirectXShaderCompiler that referenced this issue Feb 5, 2024
According to the Vulkan spec:
OpTypeImage must declare a scalar 32-bit float, 64-bit integer, or 32-bit integer type for the “Sampled Type” (RelaxedPrecision can be applied to a sampling instruction and to the variable holding the result of a sampling instruction)

We want to avoid translating a true HLSL 16-bit floating point texture
object to a 32-bit texture object with relaxed precision, as this will
break backwards compatibility if Vulkan does support 16-bit texture
types in the future.

This change adds an error message in cases where the code generated
would otherwise fail validation for the above reasons.

Closes microsoft#4372
sudonatalie added a commit that referenced this issue Feb 6, 2024
According to the Vulkan spec:
OpTypeImage must declare a scalar 32-bit float, 64-bit integer, or
32-bit integer type for the “Sampled Type” (RelaxedPrecision can be
applied to a sampling instruction and to the variable holding the result
of a sampling instruction)

We want to avoid translating a true HLSL 16-bit floating point texture
object to a 32-bit texture object with relaxed precision, as this will
break backwards compatibility if Vulkan does support 16-bit texture
types in the future.

This change adds an error message in cases where the code generated
would otherwise fail validation for the above reasons.

Closes #4372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spirv Work related to SPIR-V
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants