Initial implementation of layout qualifiers. More to come after uniform blocks are in place.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@21078 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
3ed2db58f1
commit
e9942d26f5
8 changed files with 215 additions and 17 deletions
|
|
@ -64,7 +64,8 @@ enum TStorageQualifier {
|
|||
EvqConst, // User defined constants and non-output parameters in functions
|
||||
EvqVaryingIn, // pipeline input, read only
|
||||
EvqVaryingOut, // pipeline ouput, read/write
|
||||
EvqUniform, // Readonly, vertex and fragment
|
||||
EvqUniform, // read only, shader with app
|
||||
EVqBuffer, // read only, shader with app
|
||||
|
||||
// parameters
|
||||
EvqIn,
|
||||
|
|
@ -102,8 +103,8 @@ __inline const char* getStorageQualifierString(TStorageQualifier q)
|
|||
case EvqGlobal: return "global"; break;
|
||||
case EvqConst: return "const"; break;
|
||||
case EvqConstReadOnly: return "const (read only)"; break;
|
||||
case EvqVaryingIn: return "shader in"; break;
|
||||
case EvqVaryingOut: return "shader out"; break;
|
||||
case EvqVaryingIn: return "in"; break;
|
||||
case EvqVaryingOut: return "out"; break;
|
||||
case EvqUniform: return "uniform"; break;
|
||||
case EvqIn: return "in"; break;
|
||||
case EvqOut: return "out"; break;
|
||||
|
|
@ -116,7 +117,7 @@ __inline const char* getStorageQualifierString(TStorageQualifier q)
|
|||
case EvqFace: return "gl_FrontFacing"; break;
|
||||
case EvqFragCoord: return "gl_FragCoord"; break;
|
||||
case EvqPointCoord: return "gl_PointCoord"; break;
|
||||
case EvqFragColor: return "fragment out"; break;
|
||||
case EvqFragColor: return "fragColor"; break;
|
||||
case EvqFragDepth: return "gl_FragDepth"; break;
|
||||
default: return "unknown qualifier";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,8 @@ inline TArraySizes NewPoolTArraySizes()
|
|||
}
|
||||
|
||||
//
|
||||
// TPublicType is a workaround for a problem with the yacc stack, It can't have
|
||||
// TPublicType (coming up after some dependent declarations)
|
||||
// is a workaround for a problem with the yacc stack, It can't have
|
||||
// types that it thinks have non-trivial constructors. It should
|
||||
// just be used while recognizing the grammar, not anything else. Pointers
|
||||
// could be used, but also trying to avoid lots of memory management overhead.
|
||||
|
|
@ -180,13 +181,26 @@ inline TArraySizes NewPoolTArraySizes()
|
|||
// match up or are named the same or anything like that.
|
||||
//
|
||||
|
||||
enum TLayoutPacking {
|
||||
ElpNone,
|
||||
ElpShared, // default, but different than saying nothing
|
||||
ElpStd140,
|
||||
ElpStd430,
|
||||
ElpPacked // see bitfield width below
|
||||
};
|
||||
|
||||
enum TLayoutMatrix {
|
||||
ElmNone,
|
||||
ElmRowMajor,
|
||||
ElmColumnMajor // default, but different than saying nothing
|
||||
}; // see bitfield width below
|
||||
|
||||
class TQualifier {
|
||||
public:
|
||||
void clear()
|
||||
{
|
||||
storage = EvqTemporary;
|
||||
precision = EpqNone;
|
||||
buffer = false;
|
||||
invariant = false;
|
||||
centroid = false;
|
||||
smooth = false;
|
||||
|
|
@ -200,10 +214,10 @@ public:
|
|||
restrict = false;
|
||||
readonly = false;
|
||||
writeonly = false;
|
||||
clearLayout();
|
||||
}
|
||||
TStorageQualifier storage : 7;
|
||||
TStorageQualifier storage : 6;
|
||||
TPrecisionQualifier precision : 3;
|
||||
bool buffer : 1;
|
||||
bool invariant : 1;
|
||||
bool centroid : 1;
|
||||
bool smooth : 1;
|
||||
|
|
@ -217,6 +231,7 @@ public:
|
|||
bool restrict : 1;
|
||||
bool readonly : 1;
|
||||
bool writeonly : 1;
|
||||
|
||||
bool isMemory()
|
||||
{
|
||||
return coherent || volatil || restrict || readonly || writeonly;
|
||||
|
|
@ -229,6 +244,46 @@ public:
|
|||
{
|
||||
return centroid || patch || sample;
|
||||
}
|
||||
|
||||
// Implementing an embedded layout-qualifier class here, since C++ can't have a real class bitfield
|
||||
void clearLayout()
|
||||
{
|
||||
layoutMatrix = ElmNone;
|
||||
layoutPacking = ElpNone;
|
||||
layoutSlotLocation = layoutLocationEnd;
|
||||
}
|
||||
bool hasLayout() const
|
||||
{
|
||||
return layoutMatrix != ElmNone ||
|
||||
layoutPacking != ElpNone ||
|
||||
layoutSlotLocation != layoutLocationEnd;
|
||||
}
|
||||
TLayoutMatrix layoutMatrix : 3;
|
||||
TLayoutPacking layoutPacking : 4;
|
||||
unsigned int layoutSlotLocation : 7; // ins/outs should have small numbers, buffer offsets could be large
|
||||
static const unsigned int layoutLocationEnd = 0x3F;
|
||||
bool hasLocation() const
|
||||
{
|
||||
return layoutSlotLocation != layoutLocationEnd;
|
||||
}
|
||||
static const char* getLayoutPackingString(TLayoutPacking packing)
|
||||
{
|
||||
switch (packing) {
|
||||
case ElpPacked: return "packed";
|
||||
case ElpShared: return "shared";
|
||||
case ElpStd140: return "std140";
|
||||
case ElpStd430: return "std430";
|
||||
default: return "none";
|
||||
}
|
||||
}
|
||||
static const char* getLayoutMatrixString(TLayoutMatrix m)
|
||||
{
|
||||
switch (m) {
|
||||
case ElmColumnMajor: return "column_major";
|
||||
case ElmRowMajor: return "row_major";
|
||||
default: return "none";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class TPublicType {
|
||||
|
|
@ -479,8 +534,17 @@ public:
|
|||
char *p = &buf[0];
|
||||
char *end = &buf[maxSize];
|
||||
|
||||
if (qualifier.buffer)
|
||||
p += snprintf(p, end - p, "buffer ");
|
||||
if (qualifier.hasLayout()) {
|
||||
p += snprintf(p, end - p, "layout(");
|
||||
if (qualifier.hasLocation())
|
||||
p += snprintf(p, end - p, "location=%d ", qualifier.layoutSlotLocation);
|
||||
if (qualifier.layoutMatrix != ElmNone)
|
||||
p += snprintf(p, end - p, "%s ", TQualifier::getLayoutMatrixString(qualifier.layoutMatrix));
|
||||
if (qualifier.layoutPacking != ElpNone)
|
||||
p += snprintf(p, end - p, "%s ", TQualifier::getLayoutPackingString(qualifier.layoutPacking));
|
||||
p += snprintf(p, end - p, ") ");
|
||||
}
|
||||
|
||||
if (qualifier.invariant)
|
||||
p += snprintf(p, end - p, "invariant ");
|
||||
if (qualifier.centroid)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue