mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-10 04:20:06 +00:00
HLSL: Remove support for having GLSL versions of HLSL intrinsics.
Related to PR #2265.
This commit is contained in:
parent
ebf55a0711
commit
a58978ac9a
@ -56,8 +56,6 @@
|
||||
|
||||
namespace { // anonymous namespace functions
|
||||
|
||||
const bool UseHlslTypes = true;
|
||||
|
||||
const char* BaseTypeName(const char argOrder, const char* scalarName, const char* vecName, const char* matName)
|
||||
{
|
||||
switch (argOrder) {
|
||||
@ -216,8 +214,7 @@ int FixedVecSize(const char* arg)
|
||||
return 0; // none found.
|
||||
}
|
||||
|
||||
// Create and return a type name. This is done in GLSL, not HLSL conventions, until such
|
||||
// time as builtins are parsed using the HLSL parser.
|
||||
// Create and return a type name, using HLSL type conventions.
|
||||
//
|
||||
// order: S = scalar, V = vector, M = matrix
|
||||
// argType: F = float, D = double, I = int, U = uint, B = bool, S = sampler
|
||||
@ -252,63 +249,35 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons
|
||||
|
||||
char order = *argOrder;
|
||||
|
||||
if (UseHlslTypes) {
|
||||
switch (type) {
|
||||
case '-': s += "void"; break;
|
||||
case 'F': s += "float"; break;
|
||||
case 'D': s += "double"; break;
|
||||
case 'I': s += "int"; break;
|
||||
case 'U': s += "uint"; break;
|
||||
case 'L': s += "int64_t"; break;
|
||||
case 'M': s += "uint64_t"; break;
|
||||
case 'B': s += "bool"; break;
|
||||
case 'S': s += "sampler"; break;
|
||||
case 's': s += "SamplerComparisonState"; break;
|
||||
case 'T': s += ((isBuffer && isImage) ? "RWBuffer" :
|
||||
isSubpass ? "SubpassInput" :
|
||||
isBuffer ? "Buffer" :
|
||||
isImage ? "RWTexture" : "Texture"); break;
|
||||
case 'i': s += ((isBuffer && isImage) ? "RWBuffer" :
|
||||
isSubpass ? "SubpassInput" :
|
||||
isBuffer ? "Buffer" :
|
||||
isImage ? "RWTexture" : "Texture"); break;
|
||||
case 'u': s += ((isBuffer && isImage) ? "RWBuffer" :
|
||||
isSubpass ? "SubpassInput" :
|
||||
isBuffer ? "Buffer" :
|
||||
isImage ? "RWTexture" : "Texture"); break;
|
||||
default: s += "UNKNOWN_TYPE"; break;
|
||||
}
|
||||
|
||||
if (isSubpass && isMS)
|
||||
s += "MS";
|
||||
|
||||
} else {
|
||||
switch (type) {
|
||||
case '-': s += "void"; break;
|
||||
case 'F': s += BaseTypeName(order, "float", "vec", "mat"); break;
|
||||
case 'D': s += BaseTypeName(order, "double", "dvec", "dmat"); break;
|
||||
case 'I': s += BaseTypeName(order, "int", "ivec", "imat"); break;
|
||||
case 'U': s += BaseTypeName(order, "uint", "uvec", "umat"); break;
|
||||
case 'B': s += BaseTypeName(order, "bool", "bvec", "bmat"); break;
|
||||
case 'S': s += "sampler"; break;
|
||||
case 's': s += "samplerShadow"; break;
|
||||
case 'T': // fall through
|
||||
case 'i': // ...
|
||||
case 'u': // ...
|
||||
if (type != 'T') // create itexture, utexture, etc
|
||||
s += type;
|
||||
|
||||
s += ((isImage && isBuffer) ? "imageBuffer" :
|
||||
isSubpass ? "subpassInput" :
|
||||
isImage ? "image" :
|
||||
isBuffer ? "samplerBuffer" :
|
||||
"texture");
|
||||
break;
|
||||
|
||||
default: s += "UNKNOWN_TYPE"; break;
|
||||
}
|
||||
switch (type) {
|
||||
case '-': s += "void"; break;
|
||||
case 'F': s += "float"; break;
|
||||
case 'D': s += "double"; break;
|
||||
case 'I': s += "int"; break;
|
||||
case 'U': s += "uint"; break;
|
||||
case 'L': s += "int64_t"; break;
|
||||
case 'M': s += "uint64_t"; break;
|
||||
case 'B': s += "bool"; break;
|
||||
case 'S': s += "sampler"; break;
|
||||
case 's': s += "SamplerComparisonState"; break;
|
||||
case 'T': s += ((isBuffer && isImage) ? "RWBuffer" :
|
||||
isSubpass ? "SubpassInput" :
|
||||
isBuffer ? "Buffer" :
|
||||
isImage ? "RWTexture" : "Texture"); break;
|
||||
case 'i': s += ((isBuffer && isImage) ? "RWBuffer" :
|
||||
isSubpass ? "SubpassInput" :
|
||||
isBuffer ? "Buffer" :
|
||||
isImage ? "RWTexture" : "Texture"); break;
|
||||
case 'u': s += ((isBuffer && isImage) ? "RWBuffer" :
|
||||
isSubpass ? "SubpassInput" :
|
||||
isBuffer ? "Buffer" :
|
||||
isImage ? "RWTexture" : "Texture"); break;
|
||||
default: s += "UNKNOWN_TYPE"; break;
|
||||
}
|
||||
|
||||
if (isSubpass && isMS)
|
||||
s += "MS";
|
||||
|
||||
// handle fixed vector sizes, such as float3, and only ever 3.
|
||||
const int fixedVecSize = FixedVecSize(argOrder);
|
||||
if (fixedVecSize != 0)
|
||||
@ -357,22 +326,21 @@ glslang::TString& AppendTypeName(glslang::TString& s, const char* argOrder, cons
|
||||
if (isArrayed)
|
||||
s += "Array";
|
||||
|
||||
// For HLSL, append return type for texture types
|
||||
if (UseHlslTypes) {
|
||||
switch (type) {
|
||||
case 'i': s += "<int"; s += dim0Char; s += ">"; break;
|
||||
case 'u': s += "<uint"; s += dim0Char; s += ">"; break;
|
||||
case 'T': s += "<float"; s += dim0Char; s += ">"; break;
|
||||
default: break;
|
||||
}
|
||||
switch (type) {
|
||||
case 'i': s += "<int"; s += dim0Char; s += ">"; break;
|
||||
case 'u': s += "<uint"; s += dim0Char; s += ">"; break;
|
||||
case 'T': s += "<float"; s += dim0Char; s += ">"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// The GLSL parser can be used to parse a subset of HLSL prototypes. However, many valid HLSL prototypes
|
||||
// are not valid GLSL prototypes. This rejects the invalid ones. Thus, there is a single switch below
|
||||
// to enable creation of the entire HLSL space.
|
||||
// This rejects prototypes not normally valid for GLSL and it's way of finding
|
||||
// overloaded built-ins under implicit type conversion.
|
||||
//
|
||||
// It is possible that this is not needed, but that would require some tweaking
|
||||
// of other rules to get the same results.
|
||||
inline bool IsValid(const char* cname, char retOrder, char retType, char argOrder, char argType, int dim0, int dim1)
|
||||
{
|
||||
const bool isVec = (argOrder == 'V');
|
||||
@ -387,26 +355,6 @@ inline bool IsValid(const char* cname, char retOrder, char retType, char argOrde
|
||||
if (!IsTextureType(argOrder) && (isVec && dim0 == 1)) // avoid vec1
|
||||
return false;
|
||||
|
||||
if (UseHlslTypes) {
|
||||
// NO further restrictions for HLSL
|
||||
} else {
|
||||
// GLSL parser restrictions
|
||||
if ((isMat && (argType == 'I' || argType == 'U' || argType == 'B')) ||
|
||||
(retOrder == 'M' && (retType == 'I' || retType == 'U' || retType == 'B')))
|
||||
return false;
|
||||
|
||||
if (isMat && dim0 == 1 && dim1 == 1) // avoid mat1x1
|
||||
return false;
|
||||
|
||||
if (isMat && dim1 == 1) // TODO: avoid mat Nx1 until we find the right GLSL profile
|
||||
return false;
|
||||
|
||||
if (name == "GetRenderTargetSamplePosition" ||
|
||||
name == "tex1D" ||
|
||||
name == "tex1Dgrad")
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -461,12 +409,10 @@ void TBuiltInParseablesHlsl::createMatTimesMat()
|
||||
{
|
||||
TString& s = commonBuiltins;
|
||||
|
||||
const int first = (UseHlslTypes ? 1 : 2);
|
||||
|
||||
for (int xRows = first; xRows <=4; xRows++) {
|
||||
for (int xCols = first; xCols <=4; xCols++) {
|
||||
for (int xRows = 1; xRows <=4; xRows++) {
|
||||
for (int xCols = 1; xCols <=4; xCols++) {
|
||||
const int yRows = xCols;
|
||||
for (int yCols = first; yCols <=4; yCols++) {
|
||||
for (int yCols = 1; yCols <=4; yCols++) {
|
||||
const int retRows = xRows;
|
||||
const int retCols = yCols;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user