glsl: add support for GL_OES_EGL_image_external
This extension introduces a new sampler type: samplerExternalOES. texture2D (and texture2DProj) can be used to do a texture look up in an external texture. Reviewed-by: Brian Paul <brianp@vmware.com> Acked-by: Jakob Bornecrantz <jakob@vmware.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
@@ -437,6 +437,7 @@ enum ast_types {
|
|||||||
ast_sampler2drect,
|
ast_sampler2drect,
|
||||||
ast_sampler3d,
|
ast_sampler3d,
|
||||||
ast_samplercube,
|
ast_samplercube,
|
||||||
|
ast_samplerexternaloes,
|
||||||
ast_sampler1dshadow,
|
ast_sampler1dshadow,
|
||||||
ast_sampler2dshadow,
|
ast_sampler2dshadow,
|
||||||
ast_sampler2drectshadow,
|
ast_sampler2drectshadow,
|
||||||
|
@@ -83,6 +83,7 @@ ast_type_specifier::ast_type_specifier(int specifier)
|
|||||||
"sampler2DRect",
|
"sampler2DRect",
|
||||||
"sampler3D",
|
"sampler3D",
|
||||||
"samplerCube",
|
"samplerCube",
|
||||||
|
"samplerExternalOES",
|
||||||
"sampler1DShadow",
|
"sampler1DShadow",
|
||||||
"sampler2DShadow",
|
"sampler2DShadow",
|
||||||
"sampler2DRectShadow",
|
"sampler2DRectShadow",
|
||||||
|
@@ -300,3 +300,13 @@ const glsl_type glsl_type::builtin_EXT_texture_buffer_object_types[] = {
|
|||||||
GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"),
|
GLSL_SAMPLER_DIM_BUF, 0, 0, GLSL_TYPE_UINT, "usamplerBuffer"),
|
||||||
};
|
};
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
/** \name Sampler types added by GL_OES_EGL_image_external
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
const glsl_type glsl_type::builtin_OES_EGL_image_external_types[] = {
|
||||||
|
glsl_type(GL_SAMPLER_EXTERNAL_OES,
|
||||||
|
GLSL_SAMPLER_DIM_EXTERNAL, 0, 0, GLSL_TYPE_FLOAT, "samplerExternalOES"),
|
||||||
|
};
|
||||||
|
/*@}*/
|
||||||
|
6
src/glsl/builtins/profiles/OES_EGL_image_external.frag
Normal file
6
src/glsl/builtins/profiles/OES_EGL_image_external.frag
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#version 100
|
||||||
|
#extension GL_OES_EGL_image_external : enable
|
||||||
|
|
||||||
|
vec4 texture2D(samplerExternalOES sampler, vec2 coord);
|
||||||
|
vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);
|
||||||
|
vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);
|
6
src/glsl/builtins/profiles/OES_EGL_image_external.vert
Normal file
6
src/glsl/builtins/profiles/OES_EGL_image_external.vert
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#version 100
|
||||||
|
#extension GL_OES_EGL_image_external : enable
|
||||||
|
|
||||||
|
vec4 texture2D(samplerExternalOES sampler, vec2 coord);
|
||||||
|
vec4 texture2DProj(samplerExternalOES sampler, vec3 coord);
|
||||||
|
vec4 texture2DProj(samplerExternalOES sampler, vec4 coord);
|
@@ -164,6 +164,7 @@ read_builtins(GLenum target, const char *protos, const char **functions, unsigne
|
|||||||
st->symbols->language_version = 130;
|
st->symbols->language_version = 130;
|
||||||
st->ARB_texture_rectangle_enable = true;
|
st->ARB_texture_rectangle_enable = true;
|
||||||
st->EXT_texture_array_enable = true;
|
st->EXT_texture_array_enable = true;
|
||||||
|
st->OES_EGL_image_external_enable = true;
|
||||||
_mesa_glsl_initialize_types(st);
|
_mesa_glsl_initialize_types(st);
|
||||||
|
|
||||||
sh->ir = new(sh) exec_list;
|
sh->ir = new(sh) exec_list;
|
||||||
|
@@ -23,6 +23,8 @@ def get_sampler_dim(sampler_type):
|
|||||||
sampler_dim = int(sampler_type[0])
|
sampler_dim = int(sampler_type[0])
|
||||||
elif sampler_type.startswith("Cube"):
|
elif sampler_type.startswith("Cube"):
|
||||||
sampler_dim = 3
|
sampler_dim = 3
|
||||||
|
elif sampler_type == "ExternalOES":
|
||||||
|
sampler_dim = 2
|
||||||
else:
|
else:
|
||||||
assert False ("coord_dim: invalid sampler_type: " + sampler_type)
|
assert False ("coord_dim: invalid sampler_type: " + sampler_type)
|
||||||
return sampler_dim
|
return sampler_dim
|
||||||
@@ -480,6 +482,8 @@ def generate_texture_functions(fs):
|
|||||||
start_function("texture2D")
|
start_function("texture2D")
|
||||||
generate_sigs("", "tex", "2D")
|
generate_sigs("", "tex", "2D")
|
||||||
generate_sigs("", "txb", "2D")
|
generate_sigs("", "txb", "2D")
|
||||||
|
# OES_EGL_image_external
|
||||||
|
generate_sigs("", "tex", "ExternalOES")
|
||||||
end_function(fs, "texture2D")
|
end_function(fs, "texture2D")
|
||||||
|
|
||||||
start_function("texture2DLod")
|
start_function("texture2DLod")
|
||||||
@@ -491,6 +495,9 @@ def generate_texture_functions(fs):
|
|||||||
generate_sigs("", "tex", "2D", Proj, 1)
|
generate_sigs("", "tex", "2D", Proj, 1)
|
||||||
generate_sigs("", "txb", "2D", Proj)
|
generate_sigs("", "txb", "2D", Proj)
|
||||||
generate_sigs("", "txb", "2D", Proj, 1)
|
generate_sigs("", "txb", "2D", Proj, 1)
|
||||||
|
# OES_EGL_image_external
|
||||||
|
generate_sigs("", "tex", "ExternalOES", Proj)
|
||||||
|
generate_sigs("", "tex", "ExternalOES", Proj, 1)
|
||||||
end_function(fs, "texture2DProj")
|
end_function(fs, "texture2DProj")
|
||||||
|
|
||||||
start_function("texture2DProjLod")
|
start_function("texture2DProjLod")
|
||||||
|
@@ -1136,6 +1136,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
|
|||||||
add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
|
add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
|
||||||
add_builtin_define(parser, "GL_ARB_conservative_depth", 1);
|
add_builtin_define(parser, "GL_ARB_conservative_depth", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extensions->OES_EGL_image_external)
|
||||||
|
add_builtin_define(parser, "GL_OES_EGL_image_external", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
language_version = 110;
|
language_version = 110;
|
||||||
|
@@ -296,6 +296,13 @@ usamplerCube KEYWORD(130, 130, USAMPLERCUBE);
|
|||||||
usampler1DArray KEYWORD(130, 130, USAMPLER1DARRAY);
|
usampler1DArray KEYWORD(130, 130, USAMPLER1DARRAY);
|
||||||
usampler2DArray KEYWORD(130, 130, USAMPLER2DARRAY);
|
usampler2DArray KEYWORD(130, 130, USAMPLER2DARRAY);
|
||||||
|
|
||||||
|
samplerExternalOES {
|
||||||
|
if (yyextra->OES_EGL_image_external_enable)
|
||||||
|
return SAMPLEREXTERNALOES;
|
||||||
|
else
|
||||||
|
return IDENTIFIER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct return STRUCT;
|
struct return STRUCT;
|
||||||
void return VOID_TOK;
|
void return VOID_TOK;
|
||||||
|
@@ -92,6 +92,7 @@
|
|||||||
%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
|
%token SAMPLER2DARRAYSHADOW ISAMPLER1D ISAMPLER2D ISAMPLER3D ISAMPLERCUBE
|
||||||
%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D
|
%token ISAMPLER1DARRAY ISAMPLER2DARRAY USAMPLER1D USAMPLER2D USAMPLER3D
|
||||||
%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY
|
%token USAMPLERCUBE USAMPLER1DARRAY USAMPLER2DARRAY
|
||||||
|
%token SAMPLEREXTERNALOES
|
||||||
%token STRUCT VOID_TOK WHILE
|
%token STRUCT VOID_TOK WHILE
|
||||||
%token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
|
%token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
|
||||||
%type <identifier> any_identifier
|
%type <identifier> any_identifier
|
||||||
@@ -1368,6 +1369,7 @@ basic_type_specifier_nonarray:
|
|||||||
| SAMPLER2DRECT { $$ = ast_sampler2drect; }
|
| SAMPLER2DRECT { $$ = ast_sampler2drect; }
|
||||||
| SAMPLER3D { $$ = ast_sampler3d; }
|
| SAMPLER3D { $$ = ast_sampler3d; }
|
||||||
| SAMPLERCUBE { $$ = ast_samplercube; }
|
| SAMPLERCUBE { $$ = ast_samplercube; }
|
||||||
|
| SAMPLEREXTERNALOES { $$ = ast_samplerexternaloes; }
|
||||||
| SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; }
|
| SAMPLER1DSHADOW { $$ = ast_sampler1dshadow; }
|
||||||
| SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; }
|
| SAMPLER2DSHADOW { $$ = ast_sampler2dshadow; }
|
||||||
| SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; }
|
| SAMPLER2DRECTSHADOW { $$ = ast_sampler2drectshadow; }
|
||||||
|
@@ -267,6 +267,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
|
|||||||
EXT(AMD_conservative_depth, true, false, true, true, false, AMD_conservative_depth),
|
EXT(AMD_conservative_depth, true, false, true, true, false, AMD_conservative_depth),
|
||||||
EXT(AMD_shader_stencil_export, false, false, true, true, false, ARB_shader_stencil_export),
|
EXT(AMD_shader_stencil_export, false, false, true, true, false, ARB_shader_stencil_export),
|
||||||
EXT(OES_texture_3D, true, false, true, false, true, EXT_texture3D),
|
EXT(OES_texture_3D, true, false, true, false, true, EXT_texture3D),
|
||||||
|
EXT(OES_EGL_image_external, true, false, true, false, true, OES_EGL_image_external),
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef EXT
|
#undef EXT
|
||||||
|
@@ -186,6 +186,8 @@ struct _mesa_glsl_parse_state {
|
|||||||
bool AMD_shader_stencil_export_warn;
|
bool AMD_shader_stencil_export_warn;
|
||||||
bool OES_texture_3D_enable;
|
bool OES_texture_3D_enable;
|
||||||
bool OES_texture_3D_warn;
|
bool OES_texture_3D_warn;
|
||||||
|
bool OES_EGL_image_external_enable;
|
||||||
|
bool OES_EGL_image_external_warn;
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/** Extensions supported by the OpenGL implementation. */
|
/** Extensions supported by the OpenGL implementation. */
|
||||||
|
@@ -202,6 +202,15 @@ glsl_type::generate_OES_texture_3D_types(glsl_symbol_table *symtab, bool warn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
glsl_type::generate_OES_EGL_image_external_types(glsl_symbol_table *symtab,
|
||||||
|
bool warn)
|
||||||
|
{
|
||||||
|
add_types_to_symbol_table(symtab, builtin_OES_EGL_image_external_types,
|
||||||
|
Elements(builtin_OES_EGL_image_external_types),
|
||||||
|
warn);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
|
_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
|
||||||
{
|
{
|
||||||
@@ -238,6 +247,15 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
|
|||||||
glsl_type::generate_EXT_texture_array_types(state->symbols,
|
glsl_type::generate_EXT_texture_array_types(state->symbols,
|
||||||
state->EXT_texture_array_warn);
|
state->EXT_texture_array_warn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We cannot check for language_version == 100 here because we need the
|
||||||
|
* types to support fixed-function program generation. But this is fine
|
||||||
|
* since the extension is never enabled for OpenGL contexts.
|
||||||
|
*/
|
||||||
|
if (state->OES_EGL_image_external_enable) {
|
||||||
|
glsl_type::generate_OES_EGL_image_external_types(state->symbols,
|
||||||
|
state->OES_EGL_image_external_warn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -62,7 +62,8 @@ enum glsl_sampler_dim {
|
|||||||
GLSL_SAMPLER_DIM_3D,
|
GLSL_SAMPLER_DIM_3D,
|
||||||
GLSL_SAMPLER_DIM_CUBE,
|
GLSL_SAMPLER_DIM_CUBE,
|
||||||
GLSL_SAMPLER_DIM_RECT,
|
GLSL_SAMPLER_DIM_RECT,
|
||||||
GLSL_SAMPLER_DIM_BUF
|
GLSL_SAMPLER_DIM_BUF,
|
||||||
|
GLSL_SAMPLER_DIM_EXTERNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -489,6 +490,7 @@ private:
|
|||||||
static const glsl_type builtin_ARB_texture_rectangle_types[];
|
static const glsl_type builtin_ARB_texture_rectangle_types[];
|
||||||
static const glsl_type builtin_EXT_texture_array_types[];
|
static const glsl_type builtin_EXT_texture_array_types[];
|
||||||
static const glsl_type builtin_EXT_texture_buffer_object_types[];
|
static const glsl_type builtin_EXT_texture_buffer_object_types[];
|
||||||
|
static const glsl_type builtin_OES_EGL_image_external_types[];
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -507,6 +509,7 @@ private:
|
|||||||
static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool);
|
static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool);
|
||||||
static void generate_EXT_texture_array_types(glsl_symbol_table *, bool);
|
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_texture_3D_types(glsl_symbol_table *, bool);
|
||||||
|
static void generate_OES_EGL_image_external_types(glsl_symbol_table *, bool);
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -72,6 +72,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
|
|||||||
ctx->Extensions.EXT_texture_array = true;
|
ctx->Extensions.EXT_texture_array = true;
|
||||||
ctx->Extensions.NV_texture_rectangle = true;
|
ctx->Extensions.NV_texture_rectangle = true;
|
||||||
ctx->Extensions.EXT_texture3D = true;
|
ctx->Extensions.EXT_texture3D = true;
|
||||||
|
ctx->Extensions.OES_EGL_image_external = true;
|
||||||
|
|
||||||
ctx->Const.GLSLVersion = 120;
|
ctx->Const.GLSLVersion = 120;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user