Correct textureGather*() extension support:
- add extension behavior and warning message for partial extension support - add partial support for gpu_shader5 for textureGather* - add interactions between texture rectangle and textureGather* - add checks to distinguish between gpu_shader5 and texture_gather extension feature differences git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24183 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
5b9f98854c
commit
d6bef9186b
11 changed files with 347 additions and 140 deletions
|
|
@ -1498,8 +1498,6 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
|
|||
|
||||
if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
|
||||
continue;
|
||||
if (dim == EsdRect && version < 140)
|
||||
continue;
|
||||
if (dim != Esd2D && ms)
|
||||
continue;
|
||||
if ((dim == Esd3D || dim == EsdRect) && arrayed)
|
||||
|
|
@ -1518,6 +1516,9 @@ void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
|
|||
if (shadow && bType > 0)
|
||||
continue;
|
||||
|
||||
if (dim == EsdRect && version < 140 && bType > 0)
|
||||
continue;
|
||||
|
||||
//
|
||||
// Now, make all the function prototypes for the type we just built...
|
||||
//
|
||||
|
|
@ -1800,6 +1801,9 @@ void TBuiltIns::addGatherFunctions(TSampler sampler, TString& typeName, int vers
|
|||
if (sampler.ms)
|
||||
return;
|
||||
|
||||
if (version < 140 && sampler.dim == EsdRect && sampler.type != EbtFloat)
|
||||
return;
|
||||
|
||||
// make one string per stage to contain all functions of the passed-in type for that stage
|
||||
TString functions[EShLangCount];
|
||||
|
||||
|
|
|
|||
|
|
@ -982,18 +982,45 @@ void TParseContext::nonOpBuiltInCheck(TSourceLoc loc, const TFunction& fnCandida
|
|||
|
||||
if (fnCandidate.getName().compare(0, 7, "texture") == 0) {
|
||||
if (fnCandidate.getName().compare(0, 13, "textureGather") == 0) {
|
||||
const char* feature = "texture gather function";
|
||||
TString featureString = fnCandidate.getName() + "(...)";
|
||||
const char* feature = featureString.c_str();
|
||||
requireProfile(loc, ~EEsProfile, feature);
|
||||
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature); // TODO: GL_ARB_gpu_shader5
|
||||
int lastArgIndex = fnCandidate.getParamCount() - 1;
|
||||
if (fnCandidate[lastArgIndex].type->getBasicType() == EbtInt && fnCandidate[lastArgIndex].type->isScalar()) {
|
||||
// the last integral argument to a texture gather must be a constant int between 0 and 3
|
||||
if (callNode.getSequence()[lastArgIndex]->getAsConstantUnion()) {
|
||||
int value = callNode.getSequence()[lastArgIndex]->getAsConstantUnion()->getConstArray()[0].getIConst();
|
||||
if (value < 0 || value > 3)
|
||||
error(loc, "must be 0, 1, 2, or 3", "texture gather component", "");
|
||||
|
||||
int compArg = -1; // track which argument, if any, is the constant component argument
|
||||
if (fnCandidate.getName().compare("textureGatherOffset") == 0) {
|
||||
// GL_ARB_texture_gather is good enough for 2D non-shadow textures with no component argument
|
||||
if (fnCandidate[0].type->getSampler().dim == Esd2D && ! fnCandidate[0].type->getSampler().shadow && fnCandidate.getParamCount() == 3)
|
||||
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature);
|
||||
else
|
||||
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
|
||||
if (! fnCandidate[0].type->getSampler().shadow)
|
||||
compArg = 3;
|
||||
} else if (fnCandidate.getName().compare("textureGatherOffsets") == 0) {
|
||||
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
|
||||
if (! fnCandidate[0].type->getSampler().shadow)
|
||||
compArg = 3;
|
||||
// check for constant offsets
|
||||
int offsetArg = fnCandidate[0].type->getSampler().shadow ? 3 : 2;
|
||||
if (! callNode.getSequence()[offsetArg]->getAsConstantUnion())
|
||||
error(loc, "must be a compile-time constant:", feature, "offsets argument");
|
||||
} else if (fnCandidate.getName().compare("textureGather") == 0) {
|
||||
// More than two arguments needs gpu_shader5, and rectangular or shadow needs gpu_shader5,
|
||||
// otherwise, need GL_ARB_texture_gather.
|
||||
if (fnCandidate.getParamCount() > 2 || fnCandidate[0].type->getSampler().dim == EsdRect || fnCandidate[0].type->getSampler().shadow) {
|
||||
profileRequires(loc, ~EEsProfile, 400, GL_ARB_gpu_shader5, feature);
|
||||
if (! fnCandidate[0].type->getSampler().shadow)
|
||||
compArg = 2;
|
||||
} else
|
||||
error(loc, "must be a constant", "texture gather component", "");
|
||||
profileRequires(loc, ~EEsProfile, 400, GL_ARB_texture_gather, feature);
|
||||
}
|
||||
|
||||
if (compArg > 0 && compArg < fnCandidate.getParamCount()) {
|
||||
if (callNode.getSequence()[compArg]->getAsConstantUnion()) {
|
||||
int value = callNode.getSequence()[compArg]->getAsConstantUnion()->getConstArray()[0].getIConst();
|
||||
if (value < 0 || value > 3)
|
||||
error(loc, "must be 0, 1, 2, or 3:", feature, "component argument");
|
||||
} else
|
||||
error(loc, "must be a compile-time constant:", feature, "component argument");
|
||||
}
|
||||
} else {
|
||||
// this is only for functions not starting "textureGather"...
|
||||
|
|
|
|||
|
|
@ -798,8 +798,9 @@ int TScanContext::tokenizeIdentifier()
|
|||
case SAMPLER2DRECT:
|
||||
case SAMPLER2DRECTSHADOW:
|
||||
afterType = true;
|
||||
if (parseContext.profile == EEsProfile ||
|
||||
(parseContext.profile != EEsProfile && parseContext.version < 140))
|
||||
if (parseContext.profile == EEsProfile)
|
||||
reservedWord();
|
||||
else if (parseContext.version < 140 && ! parseContext.symbolTable.atBuiltInLevel() && ! parseContext.extensionsTurnedOn(1, &GL_ARB_texture_rectangle))
|
||||
reservedWord();
|
||||
return keyword;
|
||||
|
||||
|
|
|
|||
|
|
@ -157,8 +157,9 @@ void TParseContext::initializeExtensionBehavior()
|
|||
|
||||
extensionBehavior[GL_ARB_texture_rectangle] = EBhDisable;
|
||||
extensionBehavior[GL_3DL_array_objects] = EBhDisable;
|
||||
extensionBehavior[GL_ARB_shading_language_420pack] = EBhDisable;
|
||||
extensionBehavior[GL_ARB_shading_language_420pack] = EBhDisablePartial;
|
||||
extensionBehavior[GL_ARB_texture_gather] = EBhDisable;
|
||||
extensionBehavior[GL_ARB_gpu_shader5] = EBhDisablePartial;
|
||||
extensionBehavior[GL_ARB_separate_shader_objects] = EBhDisable;
|
||||
}
|
||||
|
||||
|
|
@ -180,6 +181,7 @@ const char* TParseContext::getPreamble()
|
|||
"#define GL_ARB_texture_rectangle 1\n"
|
||||
"#define GL_ARB_shading_language_420pack 1\n"
|
||||
"#define GL_ARB_texture_gather 1\n"
|
||||
"#define GL_ARB_gpu_shader5 1\n"
|
||||
"#define GL_ARB_separate_shader_objects 1\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -435,8 +437,11 @@ void TParseContext::updateExtensionBehavior(const char* extension, const char* b
|
|||
}
|
||||
|
||||
return;
|
||||
} else
|
||||
} else {
|
||||
if (iter->second == EBhDisablePartial)
|
||||
warn(getCurrentLoc(), "extension is only partially supported:", "#extension", extension);
|
||||
iter->second = behavior;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ typedef enum {
|
|||
EBhRequire,
|
||||
EBhEnable,
|
||||
EBhWarn,
|
||||
EBhDisable
|
||||
EBhDisable,
|
||||
EBhDisablePartial // use as initial state of an extension that is only partially implemented
|
||||
} TExtensionBehavior;
|
||||
|
||||
//
|
||||
|
|
@ -82,6 +83,7 @@ const char* const GL_ARB_texture_rectangle = "GL_ARB_texture_rectangle";
|
|||
const char* const GL_3DL_array_objects = "GL_3DL_array_objects";
|
||||
const char* const GL_ARB_shading_language_420pack = "GL_ARB_shading_language_420pack";
|
||||
const char* const GL_ARB_texture_gather = "GL_ARB_texture_gather";
|
||||
const char* const GL_ARB_gpu_shader5 = "GL_ARB_gpu_shader5";
|
||||
const char* const GL_ARB_separate_shader_objects = "GL_ARB_separate_shader_objects";
|
||||
|
||||
} // end namespace glslang
|
||||
|
|
|
|||
|
|
@ -1717,29 +1717,21 @@ type_specifier_nonarray
|
|||
$$.sampler.set(EbtUint, EsdCube, true);
|
||||
}
|
||||
| SAMPLER2DRECT {
|
||||
parseContext.profileRequires($1.loc, ENoProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
|
||||
|
||||
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
|
||||
$$.basicType = EbtSampler;
|
||||
$$.sampler.set(EbtFloat, EsdRect);
|
||||
}
|
||||
| SAMPLER2DRECTSHADOW {
|
||||
parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
|
||||
|
||||
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
|
||||
$$.basicType = EbtSampler;
|
||||
$$.sampler.set(EbtFloat, EsdRect, false, true);
|
||||
}
|
||||
| ISAMPLER2DRECT {
|
||||
parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
|
||||
|
||||
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
|
||||
$$.basicType = EbtSampler;
|
||||
$$.sampler.set(EbtInt, EsdRect);
|
||||
}
|
||||
| USAMPLER2DRECT {
|
||||
parseContext.profileRequires($1.loc, ECoreProfile, 140, GL_ARB_texture_rectangle, "rectangle texture");
|
||||
|
||||
$$.init($1.loc, parseContext.symbolTable.atGlobalLevel());
|
||||
$$.basicType = EbtSampler;
|
||||
$$.sampler.set(EbtUint, EsdRect);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue