summaryrefslogtreecommitdiffstats
path: root/src/glsl/builtins
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/builtins')
-rw-r--r--src/glsl/builtins/profiles/ARB_texture_query_lod.frag38
-rwxr-xr-xsrc/glsl/builtins/tools/generate_builtins.py1
-rwxr-xr-xsrc/glsl/builtins/tools/texture_builtins.py40
3 files changed, 68 insertions, 11 deletions
diff --git a/src/glsl/builtins/profiles/ARB_texture_query_lod.frag b/src/glsl/builtins/profiles/ARB_texture_query_lod.frag
new file mode 100644
index 00000000000..5d76127040a
--- /dev/null
+++ b/src/glsl/builtins/profiles/ARB_texture_query_lod.frag
@@ -0,0 +1,38 @@
+#version 130
+#extension GL_ARB_texture_query_lod : enable
+#extension GL_ARB_texture_cube_map_array : enable
+
+vec2 textureQueryLOD( sampler1D sampler, float coord);
+vec2 textureQueryLOD(isampler1D sampler, float coord);
+vec2 textureQueryLOD(usampler1D sampler, float coord);
+
+vec2 textureQueryLOD( sampler2D sampler, vec2 coord);
+vec2 textureQueryLOD(isampler2D sampler, vec2 coord);
+vec2 textureQueryLOD(usampler2D sampler, vec2 coord);
+
+vec2 textureQueryLOD( sampler3D sampler, vec3 coord);
+vec2 textureQueryLOD(isampler3D sampler, vec3 coord);
+vec2 textureQueryLOD(usampler3D sampler, vec3 coord);
+
+vec2 textureQueryLOD( samplerCube sampler, vec3 coord);
+vec2 textureQueryLOD(isamplerCube sampler, vec3 coord);
+vec2 textureQueryLOD(usamplerCube sampler, vec3 coord);
+
+vec2 textureQueryLOD( sampler1DArray sampler, float coord);
+vec2 textureQueryLOD(isampler1DArray sampler, float coord);
+vec2 textureQueryLOD(usampler1DArray sampler, float coord);
+
+vec2 textureQueryLOD( sampler2DArray sampler, vec2 coord);
+vec2 textureQueryLOD(isampler2DArray sampler, vec2 coord);
+vec2 textureQueryLOD(usampler2DArray sampler, vec2 coord);
+
+vec2 textureQueryLOD( samplerCubeArray sampler, vec3 coord);
+vec2 textureQueryLOD(isamplerCubeArray sampler, vec3 coord);
+vec2 textureQueryLOD(usamplerCubeArray sampler, vec3 coord);
+
+vec2 textureQueryLOD(sampler1DShadow sampler, float coord);
+vec2 textureQueryLOD(sampler2DShadow sampler, vec2 coord);
+vec2 textureQueryLOD(samplerCubeShadow sampler, vec3 coord);
+vec2 textureQueryLOD(sampler1DArrayShadow sampler, float coord);
+vec2 textureQueryLOD(sampler2DArrayShadow sampler, vec2 coord);
+vec2 textureQueryLOD(samplerCubeArrayShadow sampler, vec3 coord);
diff --git a/src/glsl/builtins/tools/generate_builtins.py b/src/glsl/builtins/tools/generate_builtins.py
index 748a689fe3a..75d3c21f43b 100755
--- a/src/glsl/builtins/tools/generate_builtins.py
+++ b/src/glsl/builtins/tools/generate_builtins.py
@@ -191,6 +191,7 @@ read_builtins(GLenum target, const char *protos, const char **functions, unsigne
st->ARB_texture_cube_map_array_enable = true;
st->ARB_shading_language_packing_enable = true;
st->ARB_texture_multisample_enable = true;
+ st->ARB_texture_query_lod_enable = true;
_mesa_glsl_initialize_types(st);
sh->ir = new(sh) exec_list;
diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py
index f32391de9ea..6ef20d5561b 100755
--- a/src/glsl/builtins/tools/texture_builtins.py
+++ b/src/glsl/builtins/tools/texture_builtins.py
@@ -33,29 +33,29 @@ def get_sampler_dim(sampler_type):
# 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):
+def get_coord_dim(sampler_type, tex_inst):
coord_dim = get_sampler_dim(sampler_type)
- if sampler_type.find("Array") != -1:
+ if sampler_type.find("Array") != -1 and tex_inst != "lod":
coord_dim += 1
return coord_dim
# Get the number of extra vector components (i.e. shadow comparitor)
-def get_extra_dim(sampler_type, use_proj, unused_fields):
+def get_extra_dim(sampler_type, use_proj, unused_fields, tex_inst):
extra_dim = unused_fields
if sampler_type == "CubeArrayShadow":
return 0
- if sampler_type.find("Shadow") != -1:
+ if sampler_type.find("Shadow") != -1 and tex_inst != "lod":
extra_dim += 1
if use_proj:
extra_dim += 1
return extra_dim
-def get_txs_dim(sampler_type):
+def get_txs_dim(sampler_type, tex_inst):
if sampler_type.startswith("CubeArray"):
return 3
if sampler_type.startswith("Cube"):
return 2
- return get_coord_dim(sampler_type)
+ return get_coord_dim(sampler_type, tex_inst)
def has_lod(sampler_type):
if 'Buffer' in sampler_type: return False
@@ -64,14 +64,16 @@ def has_lod(sampler_type):
return True
def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
- coord_dim = get_coord_dim(sampler_type)
- extra_dim = get_extra_dim(sampler_type, variant & Proj, unused_fields)
+ coord_dim = get_coord_dim(sampler_type, tex_inst)
+ extra_dim = get_extra_dim(sampler_type, variant & Proj, unused_fields, tex_inst)
sampler_dim = get_sampler_dim(sampler_type)
if variant & Single:
return_type = "float"
elif tex_inst == "txs":
- return_type = vec_type("i", get_txs_dim(sampler_type))
+ return_type = vec_type("i", get_txs_dim(sampler_type, tex_inst))
+ elif tex_inst == "lod":
+ return_type = "vec2"
else:
return_type = g + "vec4"
@@ -108,14 +110,14 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
else:
print "(var_ref P)",
- if tex_inst not in ['txf_ms', 'txs']:
+ if tex_inst not in ['txf_ms', 'txs', 'lod']:
# Coordinate offset
if variant & Offset:
print "(var_ref offset)",
else:
print "0",
- if tex_inst not in ['txf', 'txf_ms', 'txs']:
+ if tex_inst not in ['txf', 'txf_ms', 'txs', 'lod']:
# Projective divisor
if variant & Proj:
print "(swiz " + "xyzw"[coord_dim + extra_dim-1] + " (var_ref P))",
@@ -635,6 +637,22 @@ def generate_texture_functions(fs):
generate_sigs("", "txl", "2DShadow", Proj)
end_function(fs, "shadow2DProjLod")
+ start_function("textureQueryLOD")
+ generate_fiu_sigs("lod", "1D")
+ generate_fiu_sigs("lod", "2D")
+ generate_fiu_sigs("lod", "3D")
+ generate_fiu_sigs("lod", "Cube")
+ generate_fiu_sigs("lod", "1DArray")
+ generate_fiu_sigs("lod", "2DArray")
+ generate_fiu_sigs("lod", "CubeArray")
+ generate_sigs("", "lod", "1DShadow")
+ generate_sigs("", "lod", "2DShadow")
+ generate_sigs("", "lod", "CubeShadow")
+ generate_sigs("", "lod", "1DArrayShadow")
+ generate_sigs("", "lod", "2DArrayShadow")
+ generate_sigs("", "lod", "CubeArrayShadow")
+ end_function(fs, "textureQueryLOD")
+
sys.stdout = sys.__stdout__
return fs