Mesa (master): texture_builtins.py: Refactor coordinate dimension calculations.
Kenneth Graunke
kwg at kemper.freedesktop.org
Mon Jan 31 19:53:19 UTC 2011
Module: Mesa
Branch: master
Commit: 99f36486ebf3d5a6edfd6329e882d6409a085582
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=99f36486ebf3d5a6edfd6329e882d6409a085582
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Mon Dec 27 02:50:42 2010 -0800
texture_builtins.py: Refactor coordinate dimension calculations.
For offsets, we'll want the straight sampler dimensionality, without the
+1 for array types. Create a new function to do that; refactor.
---
src/glsl/builtins/tools/texture_builtins.py | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py
index d7ac4d3..63401ea 100755
--- a/src/glsl/builtins/tools/texture_builtins.py
+++ b/src/glsl/builtins/tools/texture_builtins.py
@@ -12,16 +12,20 @@ def vec_type(g, size):
return "float"
return g + "vec" + str(size)
-# Get the base dimension - i.e. sampler3D gives 3
-# Array samplers also get +1 here since the layer is really an extra coordinate
-def get_coord_dim(sampler_type):
+# Get the sampler dimension - i.e. sampler3D gives 3
+def get_sampler_dim(sampler_type):
if sampler_type[0].isdigit():
- coord_dim = int(sampler_type[0])
+ sampler_dim = int(sampler_type[0])
elif sampler_type.startswith("Cube"):
- coord_dim = 3
+ sampler_dim = 3
else:
assert False ("coord_dim: invalid sampler_type: " + sampler_type)
+ return sampler_dim
+# Get the coordinate dimension for a given sampler type.
+# Array samplers also get +1 here since the layer is really an extra coordinate
+def get_coord_dim(sampler_type):
+ coord_dim = get_sampler_dim(sampler_type)
if sampler_type.find("Array") != -1:
coord_dim += 1
return coord_dim
More information about the mesa-commit
mailing list