[Mesa-dev] [PATCH 9/9] glsl: Add GLSL 1.40 textureSize() implementations for sampler2DRect.

Eric Anholt eric at anholt.net
Mon Mar 12 18:08:22 PDT 2012


By setting lod to 0 in the builtin function implementation, we avoid
needing to update all the visitors to ignore LOD in this case, when
the hardware drivers actually want to ask for LOD 0 for rectangular
textures.

Fixes piglit spec/GLSL-1.40/textureSize-*Rect.
---
 src/glsl/builtins/profiles/140.frag         |    5 +++++
 src/glsl/builtins/profiles/140.vert         |    5 +++++
 src/glsl/builtins/tools/texture_builtins.py |   11 +++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/glsl/builtins/profiles/140.frag b/src/glsl/builtins/profiles/140.frag
index 1bf6c75..da28473 100644
--- a/src/glsl/builtins/profiles/140.frag
+++ b/src/glsl/builtins/profiles/140.frag
@@ -499,6 +499,11 @@ ivec3 textureSize(usampler2DArray sampler, int lod);
 ivec2 textureSize(sampler1DArrayShadow sampler, int lod);
 ivec3 textureSize(sampler2DArrayShadow sampler, int lod);
 
+ivec2 textureSize(sampler2DRect sampler);
+ivec2 textureSize(isampler2DRect sampler);
+ivec2 textureSize(usampler2DRect sampler);
+ivec2 textureSize(sampler2DRectShadow sampler);
+
 /* texture - no bias */
  vec4 texture( sampler1D sampler, float P);
 ivec4 texture(isampler1D sampler, float P);
diff --git a/src/glsl/builtins/profiles/140.vert b/src/glsl/builtins/profiles/140.vert
index 0fad767..bfef4ed 100644
--- a/src/glsl/builtins/profiles/140.vert
+++ b/src/glsl/builtins/profiles/140.vert
@@ -499,6 +499,11 @@ ivec3 textureSize(usampler2DArray sampler, int lod);
 ivec2 textureSize(sampler1DArrayShadow sampler, int lod);
 ivec3 textureSize(sampler2DArrayShadow sampler, int lod);
 
+ivec2 textureSize(sampler2DRect sampler);
+ivec2 textureSize(isampler2DRect sampler);
+ivec2 textureSize(usampler2DRect sampler);
+ivec2 textureSize(sampler2DRectShadow sampler);
+
 /* texture */
  vec4 texture( sampler1D sampler, float P);
 ivec4 texture(isampler1D sampler, float P);
diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py
index 07d0a1b..35571e8 100755
--- a/src/glsl/builtins/tools/texture_builtins.py
+++ b/src/glsl/builtins/tools/texture_builtins.py
@@ -71,7 +71,7 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
         print "\n       (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)",
     if tex_inst == "txl":
         print "\n       (declare (in) float lod)",
-    elif tex_inst == "txf" or tex_inst == "txs":
+    elif tex_inst == "txf" or (tex_inst == "txs" and sampler_type.find("Rect") == -1):
         print "\n       (declare (in) int lod)",
     elif tex_inst == "txd":
         grad_type = vec_type("", coord_dim)
@@ -115,7 +115,12 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
     # Bias/explicit LOD/gradient:
     if tex_inst == "txb":
         print "(var_ref bias)",
-    elif tex_inst == "txl" or tex_inst == "txf" or tex_inst == "txs":
+    elif tex_inst == "txs":
+        if sampler_type.find("Rect") == -1:
+            print "(var_ref lod)",
+        else:
+            print "(constant int (0))"
+    elif tex_inst == "txl" or tex_inst == "txf":
         print "(var_ref lod)",
     elif tex_inst == "txd":
         print "((var_ref dPdx) (var_ref dPdy))",
@@ -153,6 +158,8 @@ def generate_texture_functions(fs):
     generate_sigs("", "txs", "CubeShadow")
     generate_sigs("", "txs", "1DArrayShadow")
     generate_sigs("", "txs", "2DArrayShadow")
+    generate_fiu_sigs("txs", "2DRect")
+    generate_sigs("", "txs", "2DRectShadow")
     end_function(fs, "textureSize")
 
     start_function("texture")
-- 
1.7.9.1



More information about the mesa-dev mailing list