Open jkwak-work opened 5 months ago
Supporting this is not trivial and require infrastructural work.
For the intrinsic definition, we should be able to use __target_switch
to switch to different implementation based on stage
:
float4 texture(...)
{
__target_switch
{
case spirv:
__target_switch
{
case vertex:
// use explicit lod
case fragment:
// use implicit lod
...
}
}
}
The tricky part is when handling modules that has both vertex and fragment shaders:
[shader("vertex")]
func vert() { texture(...); }
[shader("fragment")]
func frag() { texture(...); }
When compiling this file to spirv, we need to create two specializations of texture
and then specialize them differently based on which stage they are for.
Right now our target switch specialization pass assumes there is no need to use the call graph to decide what capabilities are available, so a __target_switch on stage isn't supported. To make this work, we need to extend our target switch specilaization pass to do the following:
I thought that a simple __target_switch would do the job and I didn't think about the case where a module has more than one stages.
I think I should still make the __target_switch change for now and put this issue to the backlog.
Instead of inventing the whole stage-specialization mechanism, we should just mark this function as fragment only.
Problem Description Because there is no way to implicitly calculate LOD for texture sampling in the vertex shader, it causes a validation error when "ImplicitLod" variants of the texture instructions are used in vertex shader.
Goal We should use "ExplicitLod" variants in vertex shader with LOD value zero.
Repro steps The following shader code is from CTS test, "dEQP-VK.glsl.texture_functions.textureproj.sampler2d_vec4_fixed_vertex".
When ran, the following validation error message is observed,