glsl: add ARB_texture_cube_map_array support (v2)
This adds all the new builtins + the new sampler types, and hooks them up if the extension is supported. v2: fix missing signatures for grad/lod fix missing textureSize clarifications fix compare vs starts with usage Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -327,3 +327,18 @@ const glsl_type glsl_type::builtin_OES_EGL_image_external_types[] = {
|
||||
GLSL_SAMPLER_DIM_EXTERNAL, 0, 0, GLSL_TYPE_FLOAT, "samplerExternalOES"),
|
||||
};
|
||||
/*@}*/
|
||||
|
||||
/** \name Sampler types added by GL_ARB_texture_cube_map_array
|
||||
*/
|
||||
/*@{*/
|
||||
const glsl_type glsl_type::builtin_ARB_texture_cube_map_array_types[] = {
|
||||
glsl_type(GL_SAMPLER_CUBE_MAP_ARRAY,
|
||||
GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_FLOAT, "samplerCubeArray"),
|
||||
glsl_type(GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW,
|
||||
GLSL_SAMPLER_DIM_CUBE, 1, 1, GLSL_TYPE_FLOAT, "samplerCubeArrayShadow"),
|
||||
glsl_type(GL_INT_SAMPLER_CUBE_MAP_ARRAY,
|
||||
GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_INT, "isamplerCubeArray"),
|
||||
glsl_type(GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY,
|
||||
GLSL_SAMPLER_DIM_CUBE, 0, 1, GLSL_TYPE_UINT, "usamplerCubeArray"),
|
||||
};
|
||||
/*@}*/
|
||||
|
19
src/glsl/builtins/profiles/ARB_texture_cube_map_array.glsl
Normal file
19
src/glsl/builtins/profiles/ARB_texture_cube_map_array.glsl
Normal file
@@ -0,0 +1,19 @@
|
||||
#version 130
|
||||
#extension GL_ARB_texture_cube_map_array : enable
|
||||
|
||||
ivec3 textureSize(samplerCubeArray sampler, int lod);
|
||||
ivec3 textureSize(isamplerCubeArray sampler, int lod);
|
||||
ivec3 textureSize(usamplerCubeArray sampler, int lod);
|
||||
ivec3 textureSize(samplerCubeArrayShadow sampler, int lod);
|
||||
|
||||
vec4 texture( samplerCubeArray sampler, vec4 coord);
|
||||
vec4 texture( samplerCubeArray sampler, vec4 coord, float bias);
|
||||
float texture( samplerCubeArrayShadow sampler, vec4 P, float compare);
|
||||
|
||||
vec4 textureGrad( samplerCubeArray sampler, vec4 P, vec3 dPdx, vec3 dPdy);
|
||||
ivec4 textureGrad( isamplerCubeArray sampler, vec4 P, vec3 dPdx, vec3 dPdy);
|
||||
uvec4 textureGrad( usamplerCubeArray sampler, vec4 P, vec3 dPdx, vec3 dPdy);
|
||||
|
||||
vec4 textureLod( samplerCubeArray sampler, vec4 P, float lod);
|
||||
ivec4 textureLod( isamplerCubeArray sampler, vec4 P, float lod);
|
||||
uvec4 textureLod( usamplerCubeArray sampler, vec4 P, float lod);
|
@@ -187,6 +187,7 @@ read_builtins(GLenum target, const char *protos, const char **functions, unsigne
|
||||
st->EXT_texture_array_enable = true;
|
||||
st->OES_EGL_image_external_enable = true;
|
||||
st->ARB_shader_bit_encoding_enable = true;
|
||||
st->ARB_texture_cube_map_array_enable = true;
|
||||
_mesa_glsl_initialize_types(st);
|
||||
|
||||
sh->ir = new(sh) exec_list;
|
||||
|
@@ -42,6 +42,8 @@ def get_coord_dim(sampler_type):
|
||||
# Get the number of extra vector components (i.e. shadow comparitor)
|
||||
def get_extra_dim(sampler_type, use_proj, unused_fields):
|
||||
extra_dim = unused_fields
|
||||
if sampler_type == "CubeArrayShadow":
|
||||
return 0
|
||||
if sampler_type.find("Shadow") != -1:
|
||||
extra_dim += 1
|
||||
if use_proj:
|
||||
@@ -49,6 +51,8 @@ def get_extra_dim(sampler_type, use_proj, unused_fields):
|
||||
return extra_dim
|
||||
|
||||
def get_txs_dim(sampler_type):
|
||||
if sampler_type.startswith("CubeArray"):
|
||||
return 3
|
||||
if sampler_type.startswith("Cube"):
|
||||
return 2
|
||||
return get_coord_dim(sampler_type)
|
||||
@@ -79,6 +83,8 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
|
||||
grad_type = vec_type("", sampler_dim)
|
||||
print "\n (declare (in) " + grad_type + " dPdx)",
|
||||
print "\n (declare (in) " + grad_type + " dPdy)",
|
||||
if sampler_type == "CubeArrayShadow" and tex_inst == "tex":
|
||||
print "\n (declare (in) float compare)",
|
||||
|
||||
if variant & Offset:
|
||||
print "\n (declare (const_in) " + vec_type("i", sampler_dim) + " offset)",
|
||||
@@ -107,7 +113,9 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
|
||||
print "1",
|
||||
|
||||
# Shadow comparitor
|
||||
if sampler_type == "2DArrayShadow" or sampler_type == "CubeShadow": # a special case:
|
||||
if sampler_type == "CubeArrayShadow": # a special case
|
||||
print "(var_ref compare)",
|
||||
elif sampler_type == "2DArrayShadow" or sampler_type == "CubeShadow": # a special case:
|
||||
print "(swiz w (var_ref P))", # ...array layer is z; shadow is w
|
||||
elif sampler_type.endswith("Shadow"):
|
||||
print "(swiz z (var_ref P))",
|
||||
@@ -163,6 +171,8 @@ def generate_texture_functions(fs):
|
||||
generate_fiu_sigs("txs", "2DRect")
|
||||
generate_sigs("", "txs", "2DRectShadow")
|
||||
generate_fiu_sigs("txs", "Buffer")
|
||||
generate_fiu_sigs("txs", "CubeArray")
|
||||
generate_sigs("", "txs", "CubeArrayShadow")
|
||||
end_function(fs, "textureSize")
|
||||
|
||||
start_function("texture")
|
||||
@@ -179,6 +189,9 @@ def generate_texture_functions(fs):
|
||||
generate_sigs("", "tex", "2DArrayShadow", Single);
|
||||
generate_fiu_sigs("tex", "2DRect")
|
||||
generate_sigs("", "tex", "2DRectShadow", Single);
|
||||
# ARB_texture_cube_map_array extension
|
||||
generate_fiu_sigs("tex", "CubeArray")
|
||||
generate_sigs("", "tex", "CubeArrayShadow", Single);
|
||||
|
||||
generate_fiu_sigs("txb", "1D")
|
||||
generate_fiu_sigs("txb", "2D")
|
||||
@@ -186,6 +199,7 @@ def generate_texture_functions(fs):
|
||||
generate_fiu_sigs("txb", "Cube")
|
||||
generate_fiu_sigs("txb", "1DArray")
|
||||
generate_fiu_sigs("txb", "2DArray")
|
||||
generate_fiu_sigs("txb", "CubeArray")
|
||||
generate_sigs("", "txb", "1DShadow", Single, 1);
|
||||
generate_sigs("", "txb", "2DShadow", Single);
|
||||
generate_sigs("", "txb", "CubeShadow", Single);
|
||||
@@ -224,6 +238,8 @@ def generate_texture_functions(fs):
|
||||
generate_sigs("", "txl", "1DShadow", Single, 1);
|
||||
generate_sigs("", "txl", "2DShadow", Single);
|
||||
generate_sigs("", "txl", "1DArrayShadow", Single);
|
||||
# ARB_texture_cube_map_array extension
|
||||
generate_fiu_sigs("txl", "CubeArray")
|
||||
end_function(fs, "textureLod")
|
||||
|
||||
start_function("textureLodOffset")
|
||||
@@ -333,6 +349,8 @@ def generate_texture_functions(fs):
|
||||
generate_sigs("", "txd", "CubeShadow", Single);
|
||||
generate_sigs("", "txd", "1DArrayShadow", Single);
|
||||
generate_sigs("", "txd", "2DArrayShadow", Single);
|
||||
# ARB_texture_cube_map_array extension
|
||||
generate_fiu_sigs("txd", "CubeArray")
|
||||
end_function(fs, "textureGrad")
|
||||
|
||||
start_function("textureGradOffset")
|
||||
|
@@ -1187,6 +1187,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
|
||||
|
||||
if (extensions->ARB_uniform_buffer_object)
|
||||
add_builtin_define(parser, "GL_ARB_uniform_buffer_object", 1);
|
||||
|
||||
if (extensions->ARB_texture_cube_map_array)
|
||||
add_builtin_define(parser, "GL_ARB_texture_cube_map_array", 1);
|
||||
}
|
||||
|
||||
language_version = 110;
|
||||
|
@@ -296,12 +296,37 @@ usamplerCube KEYWORD(130, 130, USAMPLERCUBE);
|
||||
usampler1DArray KEYWORD(130, 130, USAMPLER1DARRAY);
|
||||
usampler2DArray KEYWORD(130, 130, USAMPLER2DARRAY);
|
||||
|
||||
samplerExternalOES {
|
||||
samplerCubeArray {
|
||||
if (yyextra->ARB_texture_cube_map_array_enable)
|
||||
return SAMPLERCUBEARRAY;
|
||||
else
|
||||
return IDENTIFIER;
|
||||
}
|
||||
isamplerCubeArray {
|
||||
if (yyextra->ARB_texture_cube_map_array_enable)
|
||||
return ISAMPLERCUBEARRAY;
|
||||
else
|
||||
return IDENTIFIER;
|
||||
}
|
||||
usamplerCubeArray {
|
||||
if (yyextra->ARB_texture_cube_map_array_enable)
|
||||
return USAMPLERCUBEARRAY;
|
||||
else
|
||||
return IDENTIFIER;
|
||||
}
|
||||
samplerCubeArrayShadow {
|
||||
if (yyextra->ARB_texture_cube_map_array_enable)
|
||||
return SAMPLERCUBEARRAYSHADOW;
|
||||
else
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
samplerExternalOES {
|
||||
if (yyextra->OES_EGL_image_external_enable)
|
||||
return SAMPLEREXTERNALOES;
|
||||
else
|
||||
return IDENTIFIER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct return STRUCT;
|
||||
|
@@ -101,9 +101,11 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)
|
||||
%token MAT4X2 MAT4X3 MAT4X4
|
||||
%token SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW
|
||||
%token SAMPLERCUBESHADOW SAMPLER1DARRAY SAMPLER2DARRAY SAMPLER1DARRAYSHADOW
|
||||
%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
|
||||
%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D
|
||||
%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY
|
||||
%token SAMPLER2DARRAYSHADOW SAMPLERCUBEARRAY SAMPLERCUBEARRAYSHADOW
|
||||
%token ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
|
||||
%token ISAMPLER1DARRAY ISAMPLER2DARRAY ISAMPLERCUBEARRAY
|
||||
%token USAMPLER1D USAMPLER2D USAMPLER3D USAMPLERCUBE USAMPLER1DARRAY
|
||||
%token USAMPLER2DARRAY USAMPLERCUBEARRAY
|
||||
%token SAMPLER2DRECT ISAMPLER2DRECT USAMPLER2DRECT SAMPLER2DRECTSHADOW
|
||||
%token SAMPLERBUFFER ISAMPLERBUFFER USAMPLERBUFFER
|
||||
%token SAMPLEREXTERNALOES
|
||||
@@ -1467,6 +1469,8 @@ basic_type_specifier_nonarray:
|
||||
| SAMPLER1DARRAYSHADOW { $$ = "sampler1DArrayShadow"; }
|
||||
| SAMPLER2DARRAYSHADOW { $$ = "sampler2DArrayShadow"; }
|
||||
| SAMPLERBUFFER { $$ = "samplerBuffer"; }
|
||||
| SAMPLERCUBEARRAY { $$ = "samplerCubeArray"; }
|
||||
| SAMPLERCUBEARRAYSHADOW { $$ = "samplerCubeArrayShadow"; }
|
||||
| ISAMPLER1D { $$ = "isampler1D"; }
|
||||
| ISAMPLER2D { $$ = "isampler2D"; }
|
||||
| ISAMPLER2DRECT { $$ = "isampler2DRect"; }
|
||||
@@ -1475,6 +1479,7 @@ basic_type_specifier_nonarray:
|
||||
| ISAMPLER1DARRAY { $$ = "isampler1DArray"; }
|
||||
| ISAMPLER2DARRAY { $$ = "isampler2DArray"; }
|
||||
| ISAMPLERBUFFER { $$ = "isamplerBuffer"; }
|
||||
| ISAMPLERCUBEARRAY { $$ = "isamplerCubeArray"; }
|
||||
| USAMPLER1D { $$ = "usampler1D"; }
|
||||
| USAMPLER2D { $$ = "usampler2D"; }
|
||||
| USAMPLER2DRECT { $$ = "usampler2DRect"; }
|
||||
@@ -1483,6 +1488,7 @@ basic_type_specifier_nonarray:
|
||||
| USAMPLER1DARRAY { $$ = "usampler1DArray"; }
|
||||
| USAMPLER2DARRAY { $$ = "usampler2DArray"; }
|
||||
| USAMPLERBUFFER { $$ = "usamplerBuffer"; }
|
||||
| USAMPLERCUBEARRAY { $$ = "usamplerCubeArray"; }
|
||||
;
|
||||
|
||||
precision_qualifier:
|
||||
|
@@ -289,6 +289,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
|
||||
EXT(ARB_shader_bit_encoding, true, true, true, true, false, ARB_shader_bit_encoding),
|
||||
EXT(ARB_uniform_buffer_object, true, false, true, true, false, ARB_uniform_buffer_object),
|
||||
EXT(OES_standard_derivatives, false, false, true, false, true, OES_standard_derivatives),
|
||||
EXT(ARB_texture_cube_map_array, true, false, true, true, false, ARB_texture_cube_map_array),
|
||||
};
|
||||
|
||||
#undef EXT
|
||||
|
@@ -205,6 +205,8 @@ struct _mesa_glsl_parse_state {
|
||||
bool ARB_uniform_buffer_object_warn;
|
||||
bool OES_standard_derivatives_enable;
|
||||
bool OES_standard_derivatives_warn;
|
||||
bool ARB_texture_cube_map_array_enable;
|
||||
bool ARB_texture_cube_map_array_warn;
|
||||
/*@}*/
|
||||
|
||||
/** Extensions supported by the OpenGL implementation. */
|
||||
|
@@ -142,7 +142,7 @@ glsl_type::sampler_index() const
|
||||
case GLSL_SAMPLER_DIM_3D:
|
||||
return TEXTURE_3D_INDEX;
|
||||
case GLSL_SAMPLER_DIM_CUBE:
|
||||
return TEXTURE_CUBE_INDEX;
|
||||
return (t->sampler_array) ? TEXTURE_CUBE_ARRAY_INDEX : TEXTURE_CUBE_INDEX;
|
||||
case GLSL_SAMPLER_DIM_RECT:
|
||||
return TEXTURE_RECT_INDEX;
|
||||
case GLSL_SAMPLER_DIM_BUF:
|
||||
@@ -255,6 +255,15 @@ glsl_type::generate_OES_EGL_image_external_types(glsl_symbol_table *symtab,
|
||||
warn);
|
||||
}
|
||||
|
||||
void
|
||||
glsl_type::generate_ARB_texture_cube_map_array_types(glsl_symbol_table *symtab,
|
||||
bool warn)
|
||||
{
|
||||
add_types_to_symbol_table(symtab, builtin_ARB_texture_cube_map_array_types,
|
||||
Elements(builtin_ARB_texture_cube_map_array_types),
|
||||
warn);
|
||||
}
|
||||
|
||||
void
|
||||
_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
|
||||
{
|
||||
@@ -304,6 +313,11 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
|
||||
glsl_type::generate_OES_EGL_image_external_types(state->symbols,
|
||||
state->OES_EGL_image_external_warn);
|
||||
}
|
||||
|
||||
if (state->ARB_texture_cube_map_array_enable) {
|
||||
glsl_type::generate_ARB_texture_cube_map_array_types(state->symbols,
|
||||
state->ARB_texture_cube_map_array_warn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -521,6 +521,7 @@ private:
|
||||
static const glsl_type builtin_EXT_texture_array_types[];
|
||||
static const glsl_type builtin_EXT_texture_buffer_object_types[];
|
||||
static const glsl_type builtin_OES_EGL_image_external_types[];
|
||||
static const glsl_type builtin_ARB_texture_cube_map_array_types[];
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
@@ -541,6 +542,7 @@ private:
|
||||
static void generate_EXT_texture_array_types(glsl_symbol_table *, bool);
|
||||
static void generate_OES_texture_3D_types(glsl_symbol_table *, bool);
|
||||
static void generate_OES_EGL_image_external_types(glsl_symbol_table *, bool);
|
||||
static void generate_ARB_texture_cube_map_array_types(glsl_symbol_table *, bool);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
|
@@ -81,6 +81,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
|
||||
ctx->Extensions.OES_EGL_image_external = true;
|
||||
ctx->Extensions.ARB_shader_bit_encoding = true;
|
||||
ctx->Extensions.OES_standard_derivatives = true;
|
||||
ctx->Extensions.ARB_texture_cube_map_array = true;
|
||||
|
||||
ctx->Const.GLSLVersion = 120;
|
||||
|
||||
|
Reference in New Issue
Block a user