Add support for GL_OES_EGL_image_external_essl3

This commit is contained in:
David Srbecký 2017-09-04 17:33:04 +01:00 committed by David Srbecky
parent 3a21c88050
commit 2c5b3d64af
10 changed files with 487 additions and 4 deletions

View File

@ -0,0 +1,41 @@
#version 100
#extension GL_OES_EGL_image_external : enable
uniform samplerExternalOES sExt;
precision mediump samplerExternalOES;
uniform samplerExternalOES mediumExt;
uniform highp samplerExternalOES highExt;
void main()
{
texture2D(sExt, vec2(0.2));
texture2D(mediumExt, vec2(0.2));
texture2D(highExt, vec2(0.2));
texture2DProj(sExt, vec3(0.3));
texture2DProj(sExt, vec4(0.3));
int lod = 0;
highp float bias = 0.01;
textureSize(sExt, lod); // ERROR
texture(sExt, vec2(0.2)); // ERROR
texture(sExt, vec2(0.2), bias); // ERROR
textureProj(sExt, vec3(0.2)); // ERROR
textureProj(sExt, vec3(0.2), bias); // ERROR
textureProj(sExt, vec4(0.2)); // ERROR
textureProj(sExt, vec4(0.2), bias); // ERROR
texelFetch(sExt, ivec2(4), lod); // ERROR
texture3D(sExt, vec3(0.3)); // ERROR
texture2DProjLod(sExt, vec3(0.3), 0.3); // ERROR
texture(sExt, vec3(0.3)); // ERROR
textureProjLod(sExt, vec3(0.3), 0.3); // ERROR
}
#extension GL_OES_EGL_image_external : disable
#extension GL_OES_EGL_image_external_essl3 : enable
uniform samplerExternalOES badExt; // ERROR
#extension GL_OES_EGL_image_external_essl3 : disable
uniform samplerExternalOES badExt; // ERROR

View File

@ -0,0 +1,41 @@
#version 300 es
#extension GL_OES_EGL_image_external_essl3 : enable
uniform samplerExternalOES sExt;
precision mediump samplerExternalOES;
uniform samplerExternalOES mediumExt;
uniform highp samplerExternalOES highExt;
void main()
{
texture2D(sExt, vec2(0.2)); // ERROR
texture2D(mediumExt, vec2(0.2)); // ERROR
texture2D(highExt, vec2(0.2)); // ERROR
texture2DProj(sExt, vec3(0.3)); // ERROR
texture2DProj(sExt, vec4(0.3)); // ERROR
int lod = 0;
highp float bias = 0.01;
textureSize(sExt, lod);
texture(sExt, vec2(0.2));
texture(sExt, vec2(0.2), bias);
textureProj(sExt, vec3(0.2));
textureProj(sExt, vec3(0.2), bias);
textureProj(sExt, vec4(0.2));
textureProj(sExt, vec4(0.2), bias);
texelFetch(sExt, ivec2(4), lod);
texture3D(sExt, vec3(0.3)); // ERROR
texture2DProjLod(sExt, vec3(0.3), 0.3); // ERROR
texture(sExt, vec3(0.3)); // ERROR
textureProjLod(sExt, vec3(0.3), 0.3); // ERROR
}
#extension GL_OES_EGL_image_external_essl3 : disable
#extension GL_OES_EGL_image_external : enable
uniform samplerExternalOES badExt; // ERROR
#extension GL_OES_EGL_image_external : disable
uniform samplerExternalOES badExt; // ERROR

View File

@ -0,0 +1,172 @@
100samplerExternal.frag
ERROR: 0:20: 'textureSize' : no matching overloaded function found
ERROR: 0:21: 'texture' : no matching overloaded function found
ERROR: 0:22: 'texture' : no matching overloaded function found
ERROR: 0:23: 'textureProj' : no matching overloaded function found
ERROR: 0:24: 'textureProj' : no matching overloaded function found
ERROR: 0:25: 'textureProj' : no matching overloaded function found
ERROR: 0:26: 'textureProj' : no matching overloaded function found
ERROR: 0:27: 'texelFetch' : no matching overloaded function found
ERROR: 0:29: 'texture3D' : no matching overloaded function found
ERROR: 0:30: 'texture2DProjLod' : no matching overloaded function found
ERROR: 0:31: 'texture' : no matching overloaded function found
ERROR: 0:32: 'textureProjLod' : no matching overloaded function found
ERROR: 0:38: 'samplerExternalOES' : required extension not requested: GL_OES_EGL_image_external
ERROR: 0:41: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
ERROR: 14 compilation errors. No code generated.
Shader version: 100
Requested GL_OES_EGL_image_external
Requested GL_OES_EGL_image_external_essl3
ERROR: node is still EOpNull!
0:10 Function Definition: main( ( global void)
0:10 Function Parameters:
0:12 Sequence
0:12 texture ( global lowp 4-component vector of float)
0:12 'sExt' ( uniform lowp samplerExternalOES)
0:12 Constant:
0:12 0.200000
0:12 0.200000
0:13 texture ( global mediump 4-component vector of float)
0:13 'mediumExt' ( uniform mediump samplerExternalOES)
0:13 Constant:
0:13 0.200000
0:13 0.200000
0:14 texture ( global highp 4-component vector of float)
0:14 'highExt' ( uniform highp samplerExternalOES)
0:14 Constant:
0:14 0.200000
0:14 0.200000
0:15 textureProj ( global lowp 4-component vector of float)
0:15 'sExt' ( uniform lowp samplerExternalOES)
0:15 Constant:
0:15 0.300000
0:15 0.300000
0:15 0.300000
0:16 textureProj ( global lowp 4-component vector of float)
0:16 'sExt' ( uniform lowp samplerExternalOES)
0:16 Constant:
0:16 0.300000
0:16 0.300000
0:16 0.300000
0:16 0.300000
0:18 Sequence
0:18 move second child to first child ( temp mediump int)
0:18 'lod' ( temp mediump int)
0:18 Constant:
0:18 0 (const int)
0:19 Sequence
0:19 move second child to first child ( temp highp float)
0:19 'bias' ( temp highp float)
0:19 Constant:
0:19 0.010000
0:20 Constant:
0:20 0.000000
0:21 Constant:
0:21 0.000000
0:22 Constant:
0:22 0.000000
0:23 Constant:
0:23 0.000000
0:24 Constant:
0:24 0.000000
0:25 Constant:
0:25 0.000000
0:26 Constant:
0:26 0.000000
0:27 Constant:
0:27 0.000000
0:29 Constant:
0:29 0.000000
0:30 Constant:
0:30 0.000000
0:31 Constant:
0:31 0.000000
0:32 Constant:
0:32 0.000000
0:? Linker Objects
0:? 'sExt' ( uniform lowp samplerExternalOES)
0:? 'mediumExt' ( uniform mediump samplerExternalOES)
0:? 'highExt' ( uniform highp samplerExternalOES)
0:? 'badExt' ( uniform mediump samplerExternalOES)
Linked fragment stage:
Shader version: 100
Requested GL_OES_EGL_image_external
Requested GL_OES_EGL_image_external_essl3
ERROR: node is still EOpNull!
0:10 Function Definition: main( ( global void)
0:10 Function Parameters:
0:12 Sequence
0:12 texture ( global lowp 4-component vector of float)
0:12 'sExt' ( uniform lowp samplerExternalOES)
0:12 Constant:
0:12 0.200000
0:12 0.200000
0:13 texture ( global mediump 4-component vector of float)
0:13 'mediumExt' ( uniform mediump samplerExternalOES)
0:13 Constant:
0:13 0.200000
0:13 0.200000
0:14 texture ( global highp 4-component vector of float)
0:14 'highExt' ( uniform highp samplerExternalOES)
0:14 Constant:
0:14 0.200000
0:14 0.200000
0:15 textureProj ( global lowp 4-component vector of float)
0:15 'sExt' ( uniform lowp samplerExternalOES)
0:15 Constant:
0:15 0.300000
0:15 0.300000
0:15 0.300000
0:16 textureProj ( global lowp 4-component vector of float)
0:16 'sExt' ( uniform lowp samplerExternalOES)
0:16 Constant:
0:16 0.300000
0:16 0.300000
0:16 0.300000
0:16 0.300000
0:18 Sequence
0:18 move second child to first child ( temp mediump int)
0:18 'lod' ( temp mediump int)
0:18 Constant:
0:18 0 (const int)
0:19 Sequence
0:19 move second child to first child ( temp highp float)
0:19 'bias' ( temp highp float)
0:19 Constant:
0:19 0.010000
0:20 Constant:
0:20 0.000000
0:21 Constant:
0:21 0.000000
0:22 Constant:
0:22 0.000000
0:23 Constant:
0:23 0.000000
0:24 Constant:
0:24 0.000000
0:25 Constant:
0:25 0.000000
0:26 Constant:
0:26 0.000000
0:27 Constant:
0:27 0.000000
0:29 Constant:
0:29 0.000000
0:30 Constant:
0:30 0.000000
0:31 Constant:
0:31 0.000000
0:32 Constant:
0:32 0.000000
0:? Linker Objects
0:? 'sExt' ( uniform lowp samplerExternalOES)
0:? 'mediumExt' ( uniform mediump samplerExternalOES)
0:? 'highExt' ( uniform highp samplerExternalOES)
0:? 'badExt' ( uniform mediump samplerExternalOES)

View File

@ -0,0 +1,197 @@
300samplerExternal.frag
ERROR: 0:12: 'texture2D' : no matching overloaded function found
ERROR: 0:13: 'texture2D' : no matching overloaded function found
ERROR: 0:14: 'texture2D' : no matching overloaded function found
ERROR: 0:15: 'texture2DProj' : no matching overloaded function found
ERROR: 0:16: 'texture2DProj' : no matching overloaded function found
ERROR: 0:29: 'texture3D' : no matching overloaded function found
ERROR: 0:30: 'texture2DProjLod' : no matching overloaded function found
ERROR: 0:31: 'texture' : no matching overloaded function found
ERROR: 0:32: 'textureProjLod' : no matching overloaded function found
ERROR: 0:38: 'samplerExternalOES' : required extension not requested: GL_OES_EGL_image_external_essl3
ERROR: 0:41: '' : syntax error, unexpected IDENTIFIER, expecting LEFT_BRACE or COMMA or SEMICOLON
ERROR: 11 compilation errors. No code generated.
Shader version: 300
Requested GL_OES_EGL_image_external
Requested GL_OES_EGL_image_external_essl3
ERROR: node is still EOpNull!
0:10 Function Definition: main( ( global void)
0:10 Function Parameters:
0:12 Sequence
0:12 Constant:
0:12 0.000000
0:13 Constant:
0:13 0.000000
0:14 Constant:
0:14 0.000000
0:15 Constant:
0:15 0.000000
0:16 Constant:
0:16 0.000000
0:18 Sequence
0:18 move second child to first child ( temp mediump int)
0:18 'lod' ( temp mediump int)
0:18 Constant:
0:18 0 (const int)
0:19 Sequence
0:19 move second child to first child ( temp highp float)
0:19 'bias' ( temp highp float)
0:19 Constant:
0:19 0.010000
0:20 textureSize ( global highp 2-component vector of int, operation at mediump)
0:20 'sExt' ( uniform lowp samplerExternalOES)
0:20 'lod' ( temp mediump int)
0:21 texture ( global lowp 4-component vector of float)
0:21 'sExt' ( uniform lowp samplerExternalOES)
0:21 Constant:
0:21 0.200000
0:21 0.200000
0:22 texture ( global lowp 4-component vector of float, operation at highp)
0:22 'sExt' ( uniform lowp samplerExternalOES)
0:22 Constant:
0:22 0.200000
0:22 0.200000
0:22 'bias' ( temp highp float)
0:23 textureProj ( global lowp 4-component vector of float)
0:23 'sExt' ( uniform lowp samplerExternalOES)
0:23 Constant:
0:23 0.200000
0:23 0.200000
0:23 0.200000
0:24 textureProj ( global lowp 4-component vector of float, operation at highp)
0:24 'sExt' ( uniform lowp samplerExternalOES)
0:24 Constant:
0:24 0.200000
0:24 0.200000
0:24 0.200000
0:24 'bias' ( temp highp float)
0:25 textureProj ( global lowp 4-component vector of float)
0:25 'sExt' ( uniform lowp samplerExternalOES)
0:25 Constant:
0:25 0.200000
0:25 0.200000
0:25 0.200000
0:25 0.200000
0:26 textureProj ( global lowp 4-component vector of float, operation at highp)
0:26 'sExt' ( uniform lowp samplerExternalOES)
0:26 Constant:
0:26 0.200000
0:26 0.200000
0:26 0.200000
0:26 0.200000
0:26 'bias' ( temp highp float)
0:27 textureFetch ( global lowp 4-component vector of float, operation at mediump)
0:27 'sExt' ( uniform lowp samplerExternalOES)
0:27 Constant:
0:27 4 (const int)
0:27 4 (const int)
0:27 'lod' ( temp mediump int)
0:29 Constant:
0:29 0.000000
0:30 Constant:
0:30 0.000000
0:31 Constant:
0:31 0.000000
0:32 Constant:
0:32 0.000000
0:? Linker Objects
0:? 'sExt' ( uniform lowp samplerExternalOES)
0:? 'mediumExt' ( uniform mediump samplerExternalOES)
0:? 'highExt' ( uniform highp samplerExternalOES)
0:? 'badExt' ( uniform mediump samplerExternalOES)
Linked fragment stage:
Shader version: 300
Requested GL_OES_EGL_image_external
Requested GL_OES_EGL_image_external_essl3
ERROR: node is still EOpNull!
0:10 Function Definition: main( ( global void)
0:10 Function Parameters:
0:12 Sequence
0:12 Constant:
0:12 0.000000
0:13 Constant:
0:13 0.000000
0:14 Constant:
0:14 0.000000
0:15 Constant:
0:15 0.000000
0:16 Constant:
0:16 0.000000
0:18 Sequence
0:18 move second child to first child ( temp mediump int)
0:18 'lod' ( temp mediump int)
0:18 Constant:
0:18 0 (const int)
0:19 Sequence
0:19 move second child to first child ( temp highp float)
0:19 'bias' ( temp highp float)
0:19 Constant:
0:19 0.010000
0:20 textureSize ( global highp 2-component vector of int, operation at mediump)
0:20 'sExt' ( uniform lowp samplerExternalOES)
0:20 'lod' ( temp mediump int)
0:21 texture ( global lowp 4-component vector of float)
0:21 'sExt' ( uniform lowp samplerExternalOES)
0:21 Constant:
0:21 0.200000
0:21 0.200000
0:22 texture ( global lowp 4-component vector of float, operation at highp)
0:22 'sExt' ( uniform lowp samplerExternalOES)
0:22 Constant:
0:22 0.200000
0:22 0.200000
0:22 'bias' ( temp highp float)
0:23 textureProj ( global lowp 4-component vector of float)
0:23 'sExt' ( uniform lowp samplerExternalOES)
0:23 Constant:
0:23 0.200000
0:23 0.200000
0:23 0.200000
0:24 textureProj ( global lowp 4-component vector of float, operation at highp)
0:24 'sExt' ( uniform lowp samplerExternalOES)
0:24 Constant:
0:24 0.200000
0:24 0.200000
0:24 0.200000
0:24 'bias' ( temp highp float)
0:25 textureProj ( global lowp 4-component vector of float)
0:25 'sExt' ( uniform lowp samplerExternalOES)
0:25 Constant:
0:25 0.200000
0:25 0.200000
0:25 0.200000
0:25 0.200000
0:26 textureProj ( global lowp 4-component vector of float, operation at highp)
0:26 'sExt' ( uniform lowp samplerExternalOES)
0:26 Constant:
0:26 0.200000
0:26 0.200000
0:26 0.200000
0:26 0.200000
0:26 'bias' ( temp highp float)
0:27 textureFetch ( global lowp 4-component vector of float, operation at mediump)
0:27 'sExt' ( uniform lowp samplerExternalOES)
0:27 Constant:
0:27 4 (const int)
0:27 4 (const int)
0:27 'lod' ( temp mediump int)
0:29 Constant:
0:29 0.000000
0:30 Constant:
0:30 0.000000
0:31 Constant:
0:31 0.000000
0:32 Constant:
0:32 0.000000
0:? Linker Objects
0:? 'sExt' ( uniform lowp samplerExternalOES)
0:? 'mediumExt' ( uniform mediump samplerExternalOES)
0:? 'highExt' ( uniform highp samplerExternalOES)
0:? 'badExt' ( uniform mediump samplerExternalOES)

View File

@ -1324,10 +1324,25 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
if (profile == EEsProfile) {
if (spvVersion.spv == 0) {
if (version < 300) {
commonBuiltins.append(
"vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external
"vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external
"vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external
"\n");
} else {
commonBuiltins.append(
"highp ivec2 textureSize(samplerExternalOES, int lod);" // GL_OES_EGL_image_external_essl3
"vec4 texture(samplerExternalOES, vec2);" // GL_OES_EGL_image_external_essl3
"vec4 texture(samplerExternalOES, vec2, float bias);" // GL_OES_EGL_image_external_essl3
"vec4 textureProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external_essl3
"vec4 textureProj(samplerExternalOES, vec3, float bias);" // GL_OES_EGL_image_external_essl3
"vec4 textureProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external_essl3
"vec4 textureProj(samplerExternalOES, vec4, float bias);" // GL_OES_EGL_image_external_essl3
"vec4 texelFetch(samplerExternalOES, ivec2, int lod);" // GL_OES_EGL_image_external_essl3
"\n");
}
commonBuiltins.append(
"vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external, caught by keyword check
"vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external, caught by keyword check
"vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external, caught by keyword check
"vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);" // GL_EXT_shader_texture_lod
"vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);" // GL_EXT_shader_texture_lod
"vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);" // GL_EXT_shader_texture_lod

View File

@ -2457,6 +2457,16 @@ void TParseContext::boolCheck(const TSourceLoc& loc, const TPublicType& pType)
void TParseContext::samplerCheck(const TSourceLoc& loc, const TType& type, const TString& identifier, TIntermTyped* /*initializer*/)
{
// Check that the appropriate extension is enabled if external sampler is used.
// There are two extensions. The correct one must be used based on GLSL version.
if (type.getBasicType() == EbtSampler && type.getSampler().external) {
if (version < 300) {
requireExtensions(loc, 1, &E_GL_OES_EGL_image_external, "samplerExternalOES");
} else {
requireExtensions(loc, 1, &E_GL_OES_EGL_image_external_essl3, "samplerExternalOES");
}
}
if (type.getQualifier().storage == EvqUniform)
return;

View File

@ -1152,7 +1152,9 @@ int TScanContext::tokenizeIdentifier()
case SAMPLEREXTERNALOES:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external))
if (parseContext.symbolTable.atBuiltInLevel() ||
parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external) ||
parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external_essl3))
return keyword;
return identifierOrType();

View File

@ -154,6 +154,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_OES_standard_derivatives] = EBhDisable;
extensionBehavior[E_GL_EXT_frag_depth] = EBhDisable;
extensionBehavior[E_GL_OES_EGL_image_external] = EBhDisable;
extensionBehavior[E_GL_OES_EGL_image_external_essl3] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_texture_lod] = EBhDisable;
extensionBehavior[E_GL_EXT_shadow_samplers] = EBhDisable;
extensionBehavior[E_GL_ARB_texture_rectangle] = EBhDisable;
@ -260,6 +261,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_OES_standard_derivatives 1\n"
"#define GL_EXT_frag_depth 1\n"
"#define GL_OES_EGL_image_external 1\n"
"#define GL_OES_EGL_image_external_essl3 1\n"
"#define GL_EXT_shader_texture_lod 1\n"
"#define GL_EXT_shadow_samplers 1\n"

View File

@ -107,6 +107,7 @@ const char* const E_GL_OES_texture_3D = "GL_OES_texture_3D";
const char* const E_GL_OES_standard_derivatives = "GL_OES_standard_derivatives";
const char* const E_GL_EXT_frag_depth = "GL_EXT_frag_depth";
const char* const E_GL_OES_EGL_image_external = "GL_OES_EGL_image_external";
const char* const E_GL_OES_EGL_image_external_essl3 = "GL_OES_EGL_image_external_essl3";
const char* const E_GL_EXT_shader_texture_lod = "GL_EXT_shader_texture_lod";
const char* const E_GL_EXT_shadow_samplers = "GL_EXT_shadow_samplers";

View File

@ -62,6 +62,7 @@ INSTANTIATE_TEST_CASE_P(
"versionsErrors.frag",
"versionsErrors.vert",
"100.frag",
"100samplerExternal.frag",
"120.vert",
"120.frag",
"130.vert",
@ -93,6 +94,7 @@ INSTANTIATE_TEST_CASE_P(
"300layout.frag",
"300operations.frag",
"300block.frag",
"300samplerExternal.frag",
"310.comp",
"310.vert",
"310.geom",