slang
slang copied to clipboard
Use ExplicitLod instructions for texture sampling in vertex shader
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".
//TEST:SIMPLE:-target spirv-asm -stage vertex -entry main -allow-glsl
#version 450 core
layout(location = 0) in highp vec4 a_position;
layout(location = 4) in highp vec4 a_in0;
layout(location = 0) out mediump vec4 v_color;
layout(set = 0, binding = 0) uniform highp sampler2D u_sampler;
layout(set = 0, binding = 1) uniform buf0 { highp vec4 u_scale; };
layout(set = 0, binding = 2) uniform buf1 { highp vec4 u_bias; };
out gl_PerVertex {
vec4 gl_Position;
};
void main()
{
gl_Position = a_position;
v_color = vec4(textureProj(u_sampler, a_in0))*u_scale + u_bias;
}
When ran, the following validation error message is observed,
error: line 60: OpEntryPoint Entry Point <id> '2[%main]'s callgraph contains function <id> '2[%main]', which cannot be used with the current execution model:
ImplicitLod instructions require Fragment or GLCompute execution model: ImageSampleProjImplicitLod