Commit fb5ba510 by John Kessenich

Implement GL_OES_shader_image_atomic.

parent 556ab3ac
...@@ -274,3 +274,70 @@ void goodSample() ...@@ -274,3 +274,70 @@ void goodSample()
mediump int n1 = gl_MaxSamples; mediump int n1 = gl_MaxSamples;
mediump int n2 = gl_NumSamples; mediump int n2 = gl_NumSamples;
} }
uniform layout(r32f) highp image2D im2Df;
uniform layout(r32ui) highp uimage2D im2Du;
uniform layout(r32i) highp iimage2D im2Di;
uniform ivec2 P;
void badImageAtom()
{
float datf;
int dati;
uint datu;
imageAtomicAdd( im2Di, P, dati); // ERROR, need extension
imageAtomicAdd( im2Du, P, datu); // ERROR, need extension
imageAtomicMin( im2Di, P, dati); // ERROR, need extension
imageAtomicMin( im2Du, P, datu); // ERROR, need extension
imageAtomicMax( im2Di, P, dati); // ERROR, need extension
imageAtomicMax( im2Du, P, datu); // ERROR, need extension
imageAtomicAnd( im2Di, P, dati); // ERROR, need extension
imageAtomicAnd( im2Du, P, datu); // ERROR, need extension
imageAtomicOr( im2Di, P, dati); // ERROR, need extension
imageAtomicOr( im2Du, P, datu); // ERROR, need extension
imageAtomicXor( im2Di, P, dati); // ERROR, need extension
imageAtomicXor( im2Du, P, datu); // ERROR, need extension
imageAtomicExchange(im2Di, P, dati); // ERROR, need extension
imageAtomicExchange(im2Du, P, datu); // ERROR, need extension
imageAtomicExchange(im2Df, P, datf); // ERROR, need extension
imageAtomicCompSwap(im2Di, P, 3, dati); // ERROR, need extension
imageAtomicCompSwap(im2Du, P, 5u, datu); // ERROR, need extension
}
#ifdef GL_OES_shader_image_atomic
#extension GL_OES_shader_image_atomic : enable
#endif
uniform layout(rgba32f) highp image2D badIm2Df; // ERROR, needs readonly or writeonly
uniform layout(rgba8ui) highp uimage2D badIm2Du; // ERROR, needs readonly or writeonly
uniform layout(rgba16i) highp iimage2D badIm2Di; // ERROR, needs readonly or writeonly
void goodImageAtom()
{
float datf;
int dati;
uint datu;
imageAtomicAdd( im2Di, P, dati);
imageAtomicAdd( im2Du, P, datu);
imageAtomicMin( im2Di, P, dati);
imageAtomicMin( im2Du, P, datu);
imageAtomicMax( im2Di, P, dati);
imageAtomicMax( im2Du, P, datu);
imageAtomicAnd( im2Di, P, dati);
imageAtomicAnd( im2Du, P, datu);
imageAtomicOr( im2Di, P, dati);
imageAtomicOr( im2Du, P, datu);
imageAtomicXor( im2Di, P, dati);
imageAtomicXor( im2Du, P, datu);
imageAtomicExchange(im2Di, P, dati);
imageAtomicExchange(im2Du, P, datu);
imageAtomicExchange(im2Df, P, datf);
imageAtomicCompSwap(im2Di, P, 3, dati);
imageAtomicCompSwap(im2Du, P, 5u, datu);
imageAtomicMax(badIm2Di, P, dati); // ERROR, not an allowed layout() on the image
imageAtomicMax(badIm2Du, P, datu); // ERROR, not an allowed layout() on the image
imageAtomicExchange(badIm2Df, P, datf); // ERROR, not an allowed layout() on the image
}
...@@ -339,3 +339,37 @@ void MSA() ...@@ -339,3 +339,37 @@ void MSA()
ivec3 tfsb = textureSize(samp2DMSAi, 4); // ERROR, no lod ivec3 tfsb = textureSize(samp2DMSAi, 4); // ERROR, no lod
ivec3 tfsu = textureSize(samp2DMSAu); ivec3 tfsu = textureSize(samp2DMSAu);
} }
#ifdef GL_OES_shader_image_atomic
#extension GL_OES_shader_image_atomic : enable
#endif
uniform layout(r32f) highp image2D im2Df;
uniform layout(r32ui) highp uimage2D im2Du;
uniform layout(r32i) highp iimage2D im2Di;
uniform ivec2 P;
void goodImageAtom()
{
float datf;
int dati;
uint datu;
imageAtomicAdd( im2Di, P, dati);
imageAtomicAdd( im2Du, P, datu);
imageAtomicMin( im2Di, P, dati);
imageAtomicMin( im2Du, P, datu);
imageAtomicMax( im2Di, P, dati);
imageAtomicMax( im2Du, P, datu);
imageAtomicAnd( im2Di, P, dati);
imageAtomicAnd( im2Du, P, datu);
imageAtomicOr( im2Di, P, dati);
imageAtomicOr( im2Du, P, datu);
imageAtomicXor( im2Di, P, dati);
imageAtomicXor( im2Du, P, datu);
imageAtomicExchange(im2Di, P, dati);
imageAtomicExchange(im2Du, P, datu);
imageAtomicExchange(im2Df, P, datf);
imageAtomicCompSwap(im2Di, P, 3, dati);
imageAtomicCompSwap(im2Du, P, 5u, datu);
}
...@@ -17,9 +17,11 @@ ERROR: 0:61: 'assign' : l-value required "ro" (can't modify a readonly buffer) ...@@ -17,9 +17,11 @@ ERROR: 0:61: 'assign' : l-value required "ro" (can't modify a readonly buffer)
ERROR: 0:66: 'buffer' : buffers can be declared only as blocks ERROR: 0:66: 'buffer' : buffers can be declared only as blocks
ERROR: 0:68: 'sampler/image' : type requires declaration of default precision qualifier ERROR: 0:68: 'sampler/image' : type requires declaration of default precision qualifier
ERROR: 0:76: '' : image variables not declared 'writeonly' must have a format layout qualifier ERROR: 0:76: '' : image variables not declared 'writeonly' must have a format layout qualifier
ERROR: 0:87: 'imageAtomicCompSwap' : no matching overloaded function found ERROR: 0:87: 'imageAtomicCompSwap' : required extension not requested: GL_OES_shader_image_atomic
ERROR: 0:88: 'imageAtomicAdd' : no matching overloaded function found ERROR: 0:88: 'imageAtomicAdd' : required extension not requested: GL_OES_shader_image_atomic
ERROR: 0:89: 'imageAtomicMin' : no matching overloaded function found ERROR: 0:89: 'imageAtomicMin' : required extension not requested: GL_OES_shader_image_atomic
ERROR: 0:89: 'readonly' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 0:89: 'imageAtomicMin' : only supported on image with format r32i or r32ui
ERROR: 0:90: 'imageAtomicMax' : no matching overloaded function found ERROR: 0:90: 'imageAtomicMax' : no matching overloaded function found
ERROR: 0:94: 'writeonly' : argument cannot drop memory qualifier when passed to formal parameter ERROR: 0:94: 'writeonly' : argument cannot drop memory qualifier when passed to formal parameter
ERROR: 0:97: '' : memory qualifiers cannot be used on this type ERROR: 0:97: '' : memory qualifiers cannot be used on this type
...@@ -76,7 +78,7 @@ ERROR: 0:227: 'input block' : not supported in this stage: compute ...@@ -76,7 +78,7 @@ ERROR: 0:227: 'input block' : not supported in this stage: compute
ERROR: 0:231: 'output block' : not supported in this stage: compute ERROR: 0:231: 'output block' : not supported in this stage: compute
WARNING: 0:235: 't__' : identifiers containing consecutive underscores ("__") are reserved WARNING: 0:235: 't__' : identifiers containing consecutive underscores ("__") are reserved
WARNING: 0:238: '#define' : names containing consecutive underscores are reserved: __D WARNING: 0:238: '#define' : names containing consecutive underscores are reserved: __D
ERROR: 74 compilation errors. No code generated. ERROR: 76 compilation errors. No code generated.
Shader version: 310 Shader version: 310
...@@ -132,12 +134,26 @@ ERROR: node is still EOpNull! ...@@ -132,12 +134,26 @@ ERROR: node is still EOpNull!
0:86 'i' (temp highp int) 0:86 'i' (temp highp int)
0:86 Constant: 0:86 Constant:
0:86 4 (const int) 0:86 4 (const int)
0:87 Constant: 0:87 Function Call: imageAtomicCompSwap(iI21;vi2;i1;i1; (global highp int)
0:87 0.000000 0:87 'iimg2D' (layout(r32i ) uniform highp iimage2D)
0:88 Constant: 0:87 Construct ivec2 (temp 2-component vector of int)
0:88 0.000000 0:87 'i' (temp highp int)
0:89 Constant: 0:87 'i' (temp highp int)
0:89 0.000000 0:87 'i' (temp highp int)
0:87 'i' (temp highp int)
0:88 Function Call: imageAtomicAdd(uI21;vi2;u1; (global highp uint)
0:88 'uimg2D' (layout(r32ui ) uniform highp uimage2D)
0:88 Construct ivec2 (temp 2-component vector of int)
0:88 'i' (temp highp int)
0:88 'i' (temp highp int)
0:88 Convert int to uint (temp uint)
0:88 'i' (temp highp int)
0:89 Function Call: imageAtomicMin(iI21;vi2;i1; (global highp int)
0:89 'iimg2Drgba' (layout(rgba32i ) readonly uniform highp iimage2D)
0:89 Construct ivec2 (temp 2-component vector of int)
0:89 'i' (temp highp int)
0:89 'i' (temp highp int)
0:89 'i' (temp highp int)
0:90 Constant: 0:90 Constant:
0:90 0.000000 0:90 0.000000
0:91 Sequence 0:91 Sequence
...@@ -544,12 +560,26 @@ ERROR: node is still EOpNull! ...@@ -544,12 +560,26 @@ ERROR: node is still EOpNull!
0:86 'i' (temp highp int) 0:86 'i' (temp highp int)
0:86 Constant: 0:86 Constant:
0:86 4 (const int) 0:86 4 (const int)
0:87 Constant: 0:87 Function Call: imageAtomicCompSwap(iI21;vi2;i1;i1; (global highp int)
0:87 0.000000 0:87 'iimg2D' (layout(r32i ) uniform highp iimage2D)
0:88 Constant: 0:87 Construct ivec2 (temp 2-component vector of int)
0:88 0.000000 0:87 'i' (temp highp int)
0:89 Constant: 0:87 'i' (temp highp int)
0:89 0.000000 0:87 'i' (temp highp int)
0:87 'i' (temp highp int)
0:88 Function Call: imageAtomicAdd(uI21;vi2;u1; (global highp uint)
0:88 'uimg2D' (layout(r32ui ) uniform highp uimage2D)
0:88 Construct ivec2 (temp 2-component vector of int)
0:88 'i' (temp highp int)
0:88 'i' (temp highp int)
0:88 Convert int to uint (temp uint)
0:88 'i' (temp highp int)
0:89 Function Call: imageAtomicMin(iI21;vi2;i1; (global highp int)
0:89 'iimg2Drgba' (layout(rgba32i ) readonly uniform highp iimage2D)
0:89 Construct ivec2 (temp 2-component vector of int)
0:89 'i' (temp highp int)
0:89 'i' (temp highp int)
0:89 'i' (temp highp int)
0:90 Constant: 0:90 Constant:
0:90 0.000000 0:90 0.000000
0:91 Sequence 0:91 Sequence
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits. // For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run). // For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "2.3.719" #define GLSLANG_REVISION "2.3.720"
#define GLSLANG_DATE "16-Aug-2015" #define GLSLANG_DATE "16-Aug-2015"
...@@ -1990,7 +1990,8 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi ...@@ -1990,7 +1990,8 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
commonBuiltins.append(prefixes[sampler.type]); commonBuiltins.append(prefixes[sampler.type]);
commonBuiltins.append("vec4);\n"); commonBuiltins.append("vec4);\n");
if (profile != EEsProfile) { if ( profile != EEsProfile ||
(profile == EEsProfile && version >= 310)) {
if (sampler.type == EbtInt || sampler.type == EbtUint) { if (sampler.type == EbtInt || sampler.type == EbtUint) {
const char* dataType = sampler.type == EbtInt ? "int" : "uint"; const char* dataType = sampler.type == EbtInt ? "int" : "uint";
...@@ -2027,7 +2028,8 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi ...@@ -2027,7 +2028,8 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
// not int or uint // not int or uint
// GL_ARB_ES3_1_compatibility // GL_ARB_ES3_1_compatibility
// TODO: spec issue: are there restrictions on the kind of layout() that can be used? what about dropping memory qualifiers? // TODO: spec issue: are there restrictions on the kind of layout() that can be used? what about dropping memory qualifiers?
if (version >= 450) { if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 310)) {
commonBuiltins.append("float imageAtomicExchange(volatile coherent "); commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
commonBuiltins.append(imageParams); commonBuiltins.append(imageParams);
commonBuiltins.append(", float);\n"); commonBuiltins.append(", float);\n");
...@@ -2852,6 +2854,17 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb ...@@ -2852,6 +2854,17 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5); symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
} }
if (profile == EEsProfile) {
symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
}
// Fall through // Fall through
case EShLangTessControl: case EShLangTessControl:
...@@ -3053,6 +3066,17 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb ...@@ -3053,6 +3066,17 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth); symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader); symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader);
symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader); symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader);
if (profile == EEsProfile) {
symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
}
break; break;
case EShLangCompute: case EShLangCompute:
......
...@@ -1428,8 +1428,12 @@ void TParseContext::nonOpBuiltInCheck(const TSourceLoc& loc, const TFunction& fn ...@@ -1428,8 +1428,12 @@ void TParseContext::nonOpBuiltInCheck(const TSourceLoc& loc, const TFunction& fn
if (imageType.getSampler().type == EbtInt || imageType.getSampler().type == EbtUint) { if (imageType.getSampler().type == EbtInt || imageType.getSampler().type == EbtUint) {
if (imageType.getQualifier().layoutFormat != ElfR32i && imageType.getQualifier().layoutFormat != ElfR32ui) if (imageType.getQualifier().layoutFormat != ElfR32i && imageType.getQualifier().layoutFormat != ElfR32ui)
error(loc, "only supported on image with format r32i or r32ui", fnCandidate.getName().c_str(), ""); error(loc, "only supported on image with format r32i or r32ui", fnCandidate.getName().c_str(), "");
} else if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0) } else {
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), ""); if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
else if (imageType.getQualifier().layoutFormat != ElfR32f && profile == EEsProfile)
error(loc, "only supported on image with format r32f", fnCandidate.getName().c_str(), "");
}
} }
} }
......
...@@ -182,7 +182,7 @@ void TParseContext::initializeExtensionBehavior() ...@@ -182,7 +182,7 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisablePartial; extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisablePartial;
extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisablePartial; extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisablePartial;
extensionBehavior[E_GL_OES_sample_variables] = EBhDisable; extensionBehavior[E_GL_OES_sample_variables] = EBhDisable;
extensionBehavior[E_GL_OES_shader_image_atomic] = EBhDisablePartial; extensionBehavior[E_GL_OES_shader_image_atomic] = EBhDisable;
extensionBehavior[E_GL_OES_shader_multisample_interpolation] = EBhDisablePartial; extensionBehavior[E_GL_OES_shader_multisample_interpolation] = EBhDisablePartial;
extensionBehavior[E_GL_OES_texture_storage_multisample_2d_array] = EBhDisable; extensionBehavior[E_GL_OES_texture_storage_multisample_2d_array] = EBhDisable;
extensionBehavior[E_GL_EXT_geometry_shader] = EBhDisable; extensionBehavior[E_GL_EXT_geometry_shader] = EBhDisable;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment