KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
3.02k stars 833 forks source link

Set RelaxedPrecision sampler using HLSL #1945

Open Programiao opened 4 years ago

Programiao commented 4 years ago

I'm currently writing HLSL that compiles to Spir-V and then to GLSL using Spirv-Cross. I'm trying to output some of the samplers to mediump and other samplers remain highp in GLSL. I tried to use min16float as Texture type. But seems like glslang will ignore it.

SamplerState DiffuseMapSampler: register(s0); 
Texture2D<min16float> DiffuseMapTexture: register(t0);

Setting default precision to spirv_cross::CompilerGLSL::Options will change all samplers uniformly which doesn't work neither.

Is there a way to mark a texture sampler as relaxed precision or not in hlsl?

johnkslang commented 4 years ago

I don't know that HLSL has a feature for doing this. We could probably do it with glslang using the attribute [[...]] syntax, if that's considered portable enough.

Programiao commented 4 years ago

That would be handy.

g-exp commented 1 year ago

could u elaborate more how to do it? Not sure if attribute [[...]] means some additional glslang options or not. Thx

g-exp commented 1 year ago

Searched online but found nothing related with precision in hlsl attribute [[...]]. Appreciate any help

arcady-lunarg commented 1 year ago

@g-exp I think the discussion is about implementing this feature in glslang using the attribute syntax. I don't believe it has been implemented yet.

g-exp commented 1 year ago

Got it thanks for the info, and wonder any other way to set relaxed precision sampler BTW, sorry just a newbie here, do setting mediump sampler and setting mediump datatype in Texture have the same effect here, in compiler such as glslang and spirvcross?