Implement GL_OES_shader_image_atomic.

This commit is contained in:
John Kessenich 2015-08-16 23:40:15 -06:00
parent 556ab3ac96
commit fb5ba510ca
9 changed files with 705 additions and 23 deletions

View file

@ -2,5 +2,5 @@
// 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).
#define GLSLANG_REVISION "2.3.719"
#define GLSLANG_REVISION "2.3.720"
#define GLSLANG_DATE "16-Aug-2015"

View file

@ -1990,7 +1990,8 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
commonBuiltins.append(prefixes[sampler.type]);
commonBuiltins.append("vec4);\n");
if (profile != EEsProfile) {
if ( profile != EEsProfile ||
(profile == EEsProfile && version >= 310)) {
if (sampler.type == EbtInt || sampler.type == EbtUint) {
const char* dataType = sampler.type == EbtInt ? "int" : "uint";
@ -2027,7 +2028,8 @@ void TBuiltIns::addImageFunctions(TSampler sampler, TString& typeName, int versi
// not int or uint
// 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?
if (version >= 450) {
if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 310)) {
commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
commonBuiltins.append(imageParams);
commonBuiltins.append(", float);\n");
@ -2852,6 +2854,17 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
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
case EShLangTessControl:
@ -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_PrimitiveID", 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;
case EShLangCompute:

View file

@ -1428,8 +1428,12 @@ void TParseContext::nonOpBuiltInCheck(const TSourceLoc& loc, const TFunction& fn
if (imageType.getSampler().type == EbtInt || imageType.getSampler().type == EbtUint) {
if (imageType.getQualifier().layoutFormat != ElfR32i && imageType.getQualifier().layoutFormat != ElfR32ui)
error(loc, "only supported on image with format r32i or r32ui", fnCandidate.getName().c_str(), "");
} else if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") != 0)
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");
} else {
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(), "");
}
}
}

View file

@ -182,7 +182,7 @@ void TParseContext::initializeExtensionBehavior()
extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisablePartial;
extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisablePartial;
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_texture_storage_multisample_2d_array] = EBhDisable;
extensionBehavior[E_GL_EXT_geometry_shader] = EBhDisable;