--- /dev/null
+#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);
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;
# 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
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"
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))",
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
if (extensions->ARB_texture_multisample)
add_builtin_define(parser, "GL_ARB_texture_multisample", 1);
+
+ if (extensions->ARB_texture_query_lod)
+ add_builtin_define(parser, "GL_ARB_texture_query_lod", 1);
}
}
EXT(ARB_texture_cube_map_array, true, false, true, true, false, ARB_texture_cube_map_array),
EXT(ARB_shading_language_packing, true, false, true, true, false, ARB_shading_language_packing),
EXT(ARB_texture_multisample, true, false, true, true, false, ARB_texture_multisample),
+ EXT(ARB_texture_query_lod, false, false, true, true, false, ARB_texture_query_lod),
};
#undef EXT
bool ARB_shading_language_packing_warn;
bool ARB_texture_multisample_enable;
bool ARB_texture_multisample_warn;
+ bool ARB_texture_query_lod_enable;
+ bool ARB_texture_query_lod_warn;
/*@}*/
/** Extensions supported by the OpenGL implementation. */
}
-static const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf", "txf_ms", "txs" };
+static const char *tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf", "txf_ms", "txs", "lod" };
const char *ir_texture::opcode_string()
{
if (this->op == ir_txs) {
assert(type->base_type == GLSL_TYPE_INT);
+ } else if (this->op == ir_lod) {
+ assert(type->vector_elements == 2);
+ assert(type->base_type == GLSL_TYPE_FLOAT);
} else {
assert(sampler->type->sampler_type == (int) type->base_type);
if (sampler->type->sampler_shadow)
ir_txd, /**< Texture look-up with partial derivatvies */
ir_txf, /**< Texel fetch with explicit LOD */
ir_txf_ms, /**< Multisample texture fetch */
- ir_txs /**< Texture size */
+ ir_txs, /**< Texture size */
+ ir_lod /**< Texture lod query */
};
* (txf_ms
* <type> <sampler> <coordinate> <sample_index>)
* (txs <type> <sampler> <lod>)
+ * (lod <type> <sampler> <coordinate>)
*/
class ir_texture : public ir_rvalue {
public:
switch (this->op) {
case ir_tex:
+ case ir_lod:
break;
case ir_txb:
new_tex->lod_info.bias = this->lod_info.bias->clone(mem_ctx, ht);
switch (this->op) {
case ir_tex:
+ case ir_lod:
break;
case ir_txb:
s = this->lod_info.bias->accept(v);
switch (ir->op)
{
case ir_tex:
+ case ir_lod:
break;
case ir_txb:
ir->lod_info.bias->accept(this);
s_pattern tex_pattern[] =
{ "tex", s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow };
+ s_pattern lod_pattern[] =
+ { "lod", s_type, s_sampler, s_coord };
s_pattern txf_pattern[] =
{ "txf", s_type, s_sampler, s_coord, s_offset, s_lod };
s_pattern txf_ms_pattern[] =
s_pattern other_pattern[] =
{ tag, s_type, s_sampler, s_coord, s_offset, s_proj, s_shadow, s_lod };
- if (MATCH(expr, tex_pattern)) {
+ if (MATCH(expr, lod_pattern)) {
+ op = ir_lod;
+ } else if (MATCH(expr, tex_pattern)) {
op = ir_tex;
} else if (MATCH(expr, txf_pattern)) {
op = ir_txf;
if (op == -1)
return NULL;
} else {
- ir_read_error(NULL, "unexpected texture pattern");
+ ir_read_error(NULL, "unexpected texture pattern %s", tag->value());
return NULL;
}
return NULL;
}
- if (op != ir_txf_ms) {
+ if (op != ir_txf_ms && op != ir_lod) {
// Read texel offset - either 0 or an rvalue.
s_int *si_offset = SX_AS_INT(s_offset);
if (si_offset == NULL || si_offset->value() != 0) {
}
}
- if (op != ir_txf && op != ir_txf_ms && op != ir_txs) {
+ if (op != ir_txf && op != ir_txf_ms && op != ir_txs && op != ir_lod) {
s_int *proj_as_int = SX_AS_INT(s_proj);
if (proj_as_int && proj_as_int->value() == 1) {
tex->projector = NULL;
break;
}
default:
- // tex doesn't have any extra parameters.
+ // tex and lod don't have any extra parameters.
break;
};
return tex;
switch (ir->op) {
case ir_tex:
+ case ir_lod:
break;
case ir_txb:
handle_rvalue(&ir->lod_info.bias);
switch (ir->op) {
case ir_tex:
+ case ir_lod:
break;
case ir_txb:
if (do_graft(&ir->lod_info.bias))
ctx->Extensions.OES_standard_derivatives = true;
ctx->Extensions.ARB_texture_cube_map_array = true;
ctx->Extensions.ARB_texture_multisample = true;
+ ctx->Extensions.ARB_texture_query_lod = true;
ctx->Const.GLSLVersion = 120;
{ "GL_ARB_texture_mirrored_repeat", o(dummy_true), GLL, 2001 },
{ "GL_ARB_texture_multisample", o(ARB_texture_multisample), GL, 2009 },
{ "GL_ARB_texture_non_power_of_two", o(ARB_texture_non_power_of_two), GL, 2003 },
+ { "GL_ARB_texture_query_lod", o(ARB_texture_query_lod), GL, 2009 },
{ "GL_ARB_texture_rectangle", o(NV_texture_rectangle), GL, 2004 },
{ "GL_ARB_texture_rgb10_a2ui", o(ARB_texture_rgb10_a2ui), GL, 2009 },
{ "GL_ARB_texture_rg", o(ARB_texture_rg), GL, 2008 },
GLboolean ARB_texture_float;
GLboolean ARB_texture_multisample;
GLboolean ARB_texture_non_power_of_two;
+ GLboolean ARB_texture_query_lod;
GLboolean ARB_texture_rg;
GLboolean ARB_texture_rgb10_a2ui;
GLboolean ARB_texture_storage;
case ir_txf_ms:
assert(!"Unexpected ir_txf_ms opcode");
break;
+ case ir_lod:
+ assert(!"Unexpected ir_lod opcode");
+ break;
}
const glsl_type *sampler_type = ir->sampler->type;