From e8bce4d45a0d801b8ed3eb3c38dbd14a1b176f3b Mon Sep 17 00:00:00 2001 From: Ricardo Garcia Date: Mon, 28 Oct 2024 17:24:00 +0100 Subject: [PATCH] Add support for GL_EXT_texture_offset_non_const --- .../textureoffset_non_const.vert.out | 357 ++++++++++++++++++ Test/textureoffset_non_const.vert | 31 ++ glslang/MachineIndependent/ParseHelper.cpp | 13 +- glslang/MachineIndependent/Versions.cpp | 6 + glslang/MachineIndependent/Versions.h | 2 + gtests/AST.FromFile.cpp | 1 + 6 files changed, 406 insertions(+), 4 deletions(-) create mode 100644 Test/baseResults/textureoffset_non_const.vert.out create mode 100644 Test/textureoffset_non_const.vert diff --git a/Test/baseResults/textureoffset_non_const.vert.out b/Test/baseResults/textureoffset_non_const.vert.out new file mode 100644 index 0000000000..7b5d136abb --- /dev/null +++ b/Test/baseResults/textureoffset_non_const.vert.out @@ -0,0 +1,357 @@ +textureoffset_non_const.vert +Shader version: 450 +Requested GL_EXT_texture_offset_non_const +0:? Sequence +0:21 Function Definition: main( ( global void) +0:21 Function Parameters: +0:23 Sequence +0:23 move second child to first child ( temp 4-component vector of float) +0:23 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:23 'anon@2' ( out block{ gl_Position 4-component vector of float Position gl_Position}) +0:23 Constant: +0:23 0 (const uint) +0:23 'a_position' (layout( location=0) in 4-component vector of float) +0:24 move second child to first child ( temp 4-component vector of float) +0:24 'v_color0' (layout( location=0) smooth out 4-component vector of float) +0:24 add ( temp 4-component vector of float) +0:24 component-wise multiply ( temp 4-component vector of float) +0:24 Construct vec4 ( temp 4-component vector of float) +0:24 textureOffset ( global 4-component vector of float) +0:24 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:24 'a_in0' (layout( location=4) in 2-component vector of float) +0:24 'offsetValue' (layout( location=10) in 2-component vector of int) +0:24 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:24 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:24 Constant: +0:24 0 (const uint) +0:24 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:24 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:24 Constant: +0:24 0 (const uint) +0:25 move second child to first child ( temp 4-component vector of float) +0:25 'v_color1' (layout( location=1) smooth out 4-component vector of float) +0:25 add ( temp 4-component vector of float) +0:25 component-wise multiply ( temp 4-component vector of float) +0:25 Construct vec4 ( temp 4-component vector of float) +0:25 textureFetchOffset ( global 4-component vector of float) +0:25 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:25 Convert float to int ( temp 2-component vector of int) +0:25 'a_in0' (layout( location=4) in 2-component vector of float) +0:25 Convert float to int ( temp int) +0:25 'a_in1' (layout( location=5) in float) +0:25 'offsetValue' (layout( location=10) in 2-component vector of int) +0:25 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:25 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:25 Constant: +0:25 0 (const uint) +0:25 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:25 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:25 Constant: +0:25 0 (const uint) +0:26 move second child to first child ( temp 4-component vector of float) +0:26 'v_color2' (layout( location=2) smooth out 4-component vector of float) +0:26 add ( temp 4-component vector of float) +0:26 component-wise multiply ( temp 4-component vector of float) +0:26 Construct vec4 ( temp 4-component vector of float) +0:26 textureProjOffset ( global 4-component vector of float) +0:26 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:26 Construct vec3 ( temp 3-component vector of float) +0:26 'a_in0' (layout( location=4) in 2-component vector of float) +0:26 Constant: +0:26 1.000000 +0:26 'offsetValue' (layout( location=10) in 2-component vector of int) +0:26 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:26 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:26 Constant: +0:26 0 (const uint) +0:26 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:26 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:26 Constant: +0:26 0 (const uint) +0:27 move second child to first child ( temp 4-component vector of float) +0:27 'v_color3' (layout( location=3) smooth out 4-component vector of float) +0:27 add ( temp 4-component vector of float) +0:27 component-wise multiply ( temp 4-component vector of float) +0:27 Construct vec4 ( temp 4-component vector of float) +0:27 textureLodOffset ( global 4-component vector of float) +0:27 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:27 'a_in0' (layout( location=4) in 2-component vector of float) +0:27 'a_in1' (layout( location=5) in float) +0:27 'offsetValue' (layout( location=10) in 2-component vector of int) +0:27 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:27 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:27 Constant: +0:27 0 (const uint) +0:27 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:27 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:27 Constant: +0:27 0 (const uint) +0:28 move second child to first child ( temp 4-component vector of float) +0:28 'v_color4' (layout( location=4) smooth out 4-component vector of float) +0:28 add ( temp 4-component vector of float) +0:28 component-wise multiply ( temp 4-component vector of float) +0:28 Construct vec4 ( temp 4-component vector of float) +0:28 textureProjLodOffset ( global 4-component vector of float) +0:28 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:28 Construct vec3 ( temp 3-component vector of float) +0:28 'a_in0' (layout( location=4) in 2-component vector of float) +0:28 Constant: +0:28 1.000000 +0:28 'a_in1' (layout( location=5) in float) +0:28 'offsetValue' (layout( location=10) in 2-component vector of int) +0:28 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:28 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:28 Constant: +0:28 0 (const uint) +0:28 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:28 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:28 Constant: +0:28 0 (const uint) +0:29 move second child to first child ( temp 4-component vector of float) +0:29 'v_color5' (layout( location=5) smooth out 4-component vector of float) +0:29 add ( temp 4-component vector of float) +0:29 component-wise multiply ( temp 4-component vector of float) +0:29 Construct vec4 ( temp 4-component vector of float) +0:29 textureGradOffset ( global 4-component vector of float) +0:29 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:29 'a_in0' (layout( location=4) in 2-component vector of float) +0:29 Construct vec2 ( temp 2-component vector of float) +0:29 'a_in1' (layout( location=5) in float) +0:29 'a_in1' (layout( location=5) in float) +0:29 Construct vec2 ( temp 2-component vector of float) +0:29 'a_in1' (layout( location=5) in float) +0:29 'a_in1' (layout( location=5) in float) +0:29 'offsetValue' (layout( location=10) in 2-component vector of int) +0:29 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:29 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:29 Constant: +0:29 0 (const uint) +0:29 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:29 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:29 Constant: +0:29 0 (const uint) +0:30 move second child to first child ( temp 4-component vector of float) +0:30 'v_color6' (layout( location=6) smooth out 4-component vector of float) +0:30 add ( temp 4-component vector of float) +0:30 component-wise multiply ( temp 4-component vector of float) +0:30 Construct vec4 ( temp 4-component vector of float) +0:30 textureProjGradOffset ( global 4-component vector of float) +0:30 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:30 Construct vec3 ( temp 3-component vector of float) +0:30 'a_in0' (layout( location=4) in 2-component vector of float) +0:30 Constant: +0:30 1.000000 +0:30 Construct vec2 ( temp 2-component vector of float) +0:30 'a_in1' (layout( location=5) in float) +0:30 'a_in1' (layout( location=5) in float) +0:30 Construct vec2 ( temp 2-component vector of float) +0:30 'a_in1' (layout( location=5) in float) +0:30 'a_in1' (layout( location=5) in float) +0:30 'offsetValue' (layout( location=10) in 2-component vector of int) +0:30 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:30 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:30 Constant: +0:30 0 (const uint) +0:30 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:30 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:30 Constant: +0:30 0 (const uint) +0:? Linker Objects +0:? 'a_position' (layout( location=0) in 4-component vector of float) +0:? 'a_in0' (layout( location=4) in 2-component vector of float) +0:? 'a_in1' (layout( location=5) in float) +0:? 'offsetValue' (layout( location=10) in 2-component vector of int) +0:? 'v_color0' (layout( location=0) smooth out 4-component vector of float) +0:? 'v_color1' (layout( location=1) smooth out 4-component vector of float) +0:? 'v_color2' (layout( location=2) smooth out 4-component vector of float) +0:? 'v_color3' (layout( location=3) smooth out 4-component vector of float) +0:? 'v_color4' (layout( location=4) smooth out 4-component vector of float) +0:? 'v_color5' (layout( location=5) smooth out 4-component vector of float) +0:? 'v_color6' (layout( location=6) smooth out 4-component vector of float) +0:? 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:? 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:? 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:? 'anon@2' ( out block{ gl_Position 4-component vector of float Position gl_Position}) +0:? 'gl_VertexID' ( gl_VertexId int VertexId) +0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) + + +Linked vertex stage: + + +Shader version: 450 +Requested GL_EXT_texture_offset_non_const +0:? Sequence +0:21 Function Definition: main( ( global void) +0:21 Function Parameters: +0:23 Sequence +0:23 move second child to first child ( temp 4-component vector of float) +0:23 gl_Position: direct index for structure ( gl_Position 4-component vector of float Position) +0:23 'anon@2' ( out block{ gl_Position 4-component vector of float Position gl_Position}) +0:23 Constant: +0:23 0 (const uint) +0:23 'a_position' (layout( location=0) in 4-component vector of float) +0:24 move second child to first child ( temp 4-component vector of float) +0:24 'v_color0' (layout( location=0) smooth out 4-component vector of float) +0:24 add ( temp 4-component vector of float) +0:24 component-wise multiply ( temp 4-component vector of float) +0:24 Construct vec4 ( temp 4-component vector of float) +0:24 textureOffset ( global 4-component vector of float) +0:24 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:24 'a_in0' (layout( location=4) in 2-component vector of float) +0:24 'offsetValue' (layout( location=10) in 2-component vector of int) +0:24 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:24 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:24 Constant: +0:24 0 (const uint) +0:24 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:24 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:24 Constant: +0:24 0 (const uint) +0:25 move second child to first child ( temp 4-component vector of float) +0:25 'v_color1' (layout( location=1) smooth out 4-component vector of float) +0:25 add ( temp 4-component vector of float) +0:25 component-wise multiply ( temp 4-component vector of float) +0:25 Construct vec4 ( temp 4-component vector of float) +0:25 textureFetchOffset ( global 4-component vector of float) +0:25 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:25 Convert float to int ( temp 2-component vector of int) +0:25 'a_in0' (layout( location=4) in 2-component vector of float) +0:25 Convert float to int ( temp int) +0:25 'a_in1' (layout( location=5) in float) +0:25 'offsetValue' (layout( location=10) in 2-component vector of int) +0:25 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:25 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:25 Constant: +0:25 0 (const uint) +0:25 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:25 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:25 Constant: +0:25 0 (const uint) +0:26 move second child to first child ( temp 4-component vector of float) +0:26 'v_color2' (layout( location=2) smooth out 4-component vector of float) +0:26 add ( temp 4-component vector of float) +0:26 component-wise multiply ( temp 4-component vector of float) +0:26 Construct vec4 ( temp 4-component vector of float) +0:26 textureProjOffset ( global 4-component vector of float) +0:26 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:26 Construct vec3 ( temp 3-component vector of float) +0:26 'a_in0' (layout( location=4) in 2-component vector of float) +0:26 Constant: +0:26 1.000000 +0:26 'offsetValue' (layout( location=10) in 2-component vector of int) +0:26 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:26 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:26 Constant: +0:26 0 (const uint) +0:26 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:26 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:26 Constant: +0:26 0 (const uint) +0:27 move second child to first child ( temp 4-component vector of float) +0:27 'v_color3' (layout( location=3) smooth out 4-component vector of float) +0:27 add ( temp 4-component vector of float) +0:27 component-wise multiply ( temp 4-component vector of float) +0:27 Construct vec4 ( temp 4-component vector of float) +0:27 textureLodOffset ( global 4-component vector of float) +0:27 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:27 'a_in0' (layout( location=4) in 2-component vector of float) +0:27 'a_in1' (layout( location=5) in float) +0:27 'offsetValue' (layout( location=10) in 2-component vector of int) +0:27 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:27 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:27 Constant: +0:27 0 (const uint) +0:27 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:27 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:27 Constant: +0:27 0 (const uint) +0:28 move second child to first child ( temp 4-component vector of float) +0:28 'v_color4' (layout( location=4) smooth out 4-component vector of float) +0:28 add ( temp 4-component vector of float) +0:28 component-wise multiply ( temp 4-component vector of float) +0:28 Construct vec4 ( temp 4-component vector of float) +0:28 textureProjLodOffset ( global 4-component vector of float) +0:28 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:28 Construct vec3 ( temp 3-component vector of float) +0:28 'a_in0' (layout( location=4) in 2-component vector of float) +0:28 Constant: +0:28 1.000000 +0:28 'a_in1' (layout( location=5) in float) +0:28 'offsetValue' (layout( location=10) in 2-component vector of int) +0:28 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:28 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:28 Constant: +0:28 0 (const uint) +0:28 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:28 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:28 Constant: +0:28 0 (const uint) +0:29 move second child to first child ( temp 4-component vector of float) +0:29 'v_color5' (layout( location=5) smooth out 4-component vector of float) +0:29 add ( temp 4-component vector of float) +0:29 component-wise multiply ( temp 4-component vector of float) +0:29 Construct vec4 ( temp 4-component vector of float) +0:29 textureGradOffset ( global 4-component vector of float) +0:29 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:29 'a_in0' (layout( location=4) in 2-component vector of float) +0:29 Construct vec2 ( temp 2-component vector of float) +0:29 'a_in1' (layout( location=5) in float) +0:29 'a_in1' (layout( location=5) in float) +0:29 Construct vec2 ( temp 2-component vector of float) +0:29 'a_in1' (layout( location=5) in float) +0:29 'a_in1' (layout( location=5) in float) +0:29 'offsetValue' (layout( location=10) in 2-component vector of int) +0:29 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:29 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:29 Constant: +0:29 0 (const uint) +0:29 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:29 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:29 Constant: +0:29 0 (const uint) +0:30 move second child to first child ( temp 4-component vector of float) +0:30 'v_color6' (layout( location=6) smooth out 4-component vector of float) +0:30 add ( temp 4-component vector of float) +0:30 component-wise multiply ( temp 4-component vector of float) +0:30 Construct vec4 ( temp 4-component vector of float) +0:30 textureProjGradOffset ( global 4-component vector of float) +0:30 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:30 Construct vec3 ( temp 3-component vector of float) +0:30 'a_in0' (layout( location=4) in 2-component vector of float) +0:30 Constant: +0:30 1.000000 +0:30 Construct vec2 ( temp 2-component vector of float) +0:30 'a_in1' (layout( location=5) in float) +0:30 'a_in1' (layout( location=5) in float) +0:30 Construct vec2 ( temp 2-component vector of float) +0:30 'a_in1' (layout( location=5) in float) +0:30 'a_in1' (layout( location=5) in float) +0:30 'offsetValue' (layout( location=10) in 2-component vector of int) +0:30 u_scale: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:30 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:30 Constant: +0:30 0 (const uint) +0:30 u_bias: direct index for structure (layout( column_major shared) uniform 4-component vector of float) +0:30 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:30 Constant: +0:30 0 (const uint) +0:? Linker Objects +0:? 'a_position' (layout( location=0) in 4-component vector of float) +0:? 'a_in0' (layout( location=4) in 2-component vector of float) +0:? 'a_in1' (layout( location=5) in float) +0:? 'offsetValue' (layout( location=10) in 2-component vector of int) +0:? 'v_color0' (layout( location=0) smooth out 4-component vector of float) +0:? 'v_color1' (layout( location=1) smooth out 4-component vector of float) +0:? 'v_color2' (layout( location=2) smooth out 4-component vector of float) +0:? 'v_color3' (layout( location=3) smooth out 4-component vector of float) +0:? 'v_color4' (layout( location=4) smooth out 4-component vector of float) +0:? 'v_color5' (layout( location=5) smooth out 4-component vector of float) +0:? 'v_color6' (layout( location=6) smooth out 4-component vector of float) +0:? 'u_sampler' (layout( set=0 binding=0) uniform sampler2D) +0:? 'anon@0' (layout( set=0 binding=1 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_scale}) +0:? 'anon@1' (layout( set=0 binding=2 column_major shared) uniform block{layout( column_major shared) uniform 4-component vector of float u_bias}) +0:? 'anon@2' ( out block{ gl_Position 4-component vector of float Position gl_Position}) +0:? 'gl_VertexID' ( gl_VertexId int VertexId) +0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId) + diff --git a/Test/textureoffset_non_const.vert b/Test/textureoffset_non_const.vert new file mode 100644 index 0000000000..482e6dd0e7 --- /dev/null +++ b/Test/textureoffset_non_const.vert @@ -0,0 +1,31 @@ +#version 450 core +#extension GL_EXT_texture_offset_non_const : enable +layout(location = 0) in highp vec4 a_position; +layout(location = 4) in highp vec2 a_in0; +layout(location = 5) in highp float a_in1; +layout(location = 10) in highp ivec2 offsetValue; +layout(location = 0) out mediump vec4 v_color0; +layout(location = 1) out mediump vec4 v_color1; +layout(location = 2) out mediump vec4 v_color2; +layout(location = 3) out mediump vec4 v_color3; +layout(location = 4) out mediump vec4 v_color4; +layout(location = 5) out mediump vec4 v_color5; +layout(location = 6) out mediump vec4 v_color6; +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_color0 = vec4(textureOffset(u_sampler, a_in0, offsetValue))*u_scale + u_bias; + v_color1 = vec4(texelFetchOffset(u_sampler, ivec2(a_in0), int(a_in1), offsetValue))*u_scale + u_bias; + v_color2 = vec4(textureProjOffset(u_sampler, vec3(a_in0, 1.0), offsetValue))*u_scale + u_bias; + v_color3 = vec4(textureLodOffset(u_sampler, a_in0, a_in1, offsetValue))*u_scale + u_bias; + v_color4 = vec4(textureProjLodOffset(u_sampler, vec3(a_in0, 1.0), a_in1, offsetValue))*u_scale + u_bias; + v_color5 = vec4(textureGradOffset(u_sampler, a_in0, vec2(a_in1, a_in1), vec2(a_in1, a_in1), offsetValue))*u_scale + u_bias; + v_color6 = vec4(textureProjGradOffset(u_sampler, vec3(a_in0, 1.0), vec2(a_in1, a_in1), vec2(a_in1, a_in1), offsetValue))*u_scale + u_bias; +} diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 215ccd9918..a92d1634d2 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -44,6 +44,7 @@ #include +#include "Versions.h" #include "preprocessor/PpContext.h" extern int yyparse(glslang::TParseContext*); @@ -2332,8 +2333,10 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan arg0->getType().getSampler().shadow; if (f16ShadowCompare) ++arg; - if (! (*argp)[arg]->getAsTyped()->getQualifier().isConstant()) - error(loc, "argument must be compile-time constant", "texel offset", ""); + if (! (*argp)[arg]->getAsTyped()->getQualifier().isConstant()) { + if (!extensionTurnedOn(E_GL_EXT_texture_offset_non_const)) + error(loc, "argument must be compile-time constant", "texel offset", ""); + } else if ((*argp)[arg]->getAsConstantUnion()) { const TType& type = (*argp)[arg]->getAsTyped()->getType(); for (int c = 0; c < type.getVectorSize(); ++c) { @@ -2926,8 +2929,10 @@ void TParseContext::nonOpBuiltInCheck(const TSourceLoc& loc, const TFunction& fn arg = 4; if (arg > 0) { - if (! callNode.getSequence()[arg]->getAsConstantUnion()) - error(loc, "argument must be compile-time constant", "texel offset", ""); + if (! callNode.getSequence()[arg]->getAsConstantUnion()) { + if (!extensionTurnedOn(E_GL_EXT_texture_offset_non_const)) + error(loc, "argument must be compile-time constant", "texel offset", ""); + } else { const TType& type = callNode.getSequence()[arg]->getAsTyped()->getType(); for (int c = 0; c < type.getVectorSize(); ++c) { diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp index 0262c54dcb..ee89d825e2 100644 --- a/glslang/MachineIndependent/Versions.cpp +++ b/glslang/MachineIndependent/Versions.cpp @@ -371,6 +371,7 @@ void TParseVersions::initializeExtensionBehavior() extensionBehavior[E_GL_EXT_texture_shadow_lod] = EBhDisable; extensionBehavior[E_GL_EXT_draw_instanced] = EBhDisable; extensionBehavior[E_GL_EXT_texture_array] = EBhDisable; + extensionBehavior[E_GL_EXT_texture_offset_non_const] = EBhDisable; // OVR extensions extensionBehavior[E_GL_OVR_multiview] = EBhDisable; @@ -632,6 +633,11 @@ void TParseVersions::getPreamble(std::string& preamble) ; } + if ((!isEsProfile() && version >= 130) || + (isEsProfile() && version >= 300)) { + preamble += "#define GL_EXT_texture_offset_non_const 1\n"; + } + if (version >= 300 /* both ES and non-ES */) { preamble += "#define GL_OVR_multiview 1\n" diff --git a/glslang/MachineIndependent/Versions.h b/glslang/MachineIndependent/Versions.h index 75a823774e..be0bd2d37a 100644 --- a/glslang/MachineIndependent/Versions.h +++ b/glslang/MachineIndependent/Versions.h @@ -4,6 +4,7 @@ // Copyright (C) 2017, 2022-2024 Arm Limited. // Copyright (C) 2015-2018 Google, Inc. // Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved. +// Modifications Copyright (C) 2024 Valve Corporation. // // All rights reserved. // @@ -223,6 +224,7 @@ const char* const E_GL_EXT_maximal_reconvergence = "GL_EXT_maximal_re const char* const E_GL_EXT_expect_assume = "GL_EXT_expect_assume"; const char* const E_GL_EXT_control_flow_attributes2 = "GL_EXT_control_flow_attributes2"; const char* const E_GL_EXT_spec_constant_composites = "GL_EXT_spec_constant_composites"; +const char* const E_GL_EXT_texture_offset_non_const = "GL_EXT_texture_offset_non_const"; // Arrays of extensions for the above viewportEXTs duplications diff --git a/gtests/AST.FromFile.cpp b/gtests/AST.FromFile.cpp index cc433fe70e..e3259a10b9 100644 --- a/gtests/AST.FromFile.cpp +++ b/gtests/AST.FromFile.cpp @@ -317,6 +317,7 @@ INSTANTIATE_TEST_SUITE_P( "ps_uint_int.frag", "ps_sample.frag", "tes_patch.tese", + "textureoffset_non_const.vert", })), FileNameAsCustomTestSuffix );