Compute Shader Texture Precision in GLSL

I am trying to access a regular RGBA32 texture in a compute shader, and wondering if there is a way to get the data as 4 bytes. I tried used “fixed4” in the compute shader, but it doesn’t seem to recognize the keyword.

If I declare the texture as

RWTexture2DArray<float4> colorTexture;

it will compile to

writeonly layout(binding=0, rgba32f) highp uniform image2DArray colorTexture;

And if I declare it as:

RWTexture2DArray<half4> colorTexture;

it will compile to

writeonly layout(binding=0, rgba16f) mediump uniform image2DArray colorTexture;

However, if I declare it as:

RWTexture2DArray<fixed4> colorTexture;

then I simply get a compile error.

I would ideally like it to be defined in the glsl compute shader code as “rgba8” or “rgba8_snorm” because I am worried about extra bandwidth or conversion costs of defining it as a higher precision.

I haven’t been able to find any examples or documentation about whether this is possible, or whether it is something I shouldn’t be concerned about.

Thanks!

RWTexture2DArray<unorm float4> colorTexture; should do the trick :slight_smile:

2 Likes

Thanks a lot! That did the trick :slight_smile:

1 Like