Flatten uniform arrays
This checkin adds a --flatten-uniform-arrays option which can break uniform arrays of samplers, textures, or UBOs up into individual scalars named (e.g) myarray[0], myarray[1], etc. These appear as individual linkage objects. Code notes: - shouldFlatten internally calls shouldFlattenIO, and shouldFlattenUniform, but is the only flattening query directly called. - flattenVariable will handle structs or arrays (but not yet arrayed structs; this is tested an an error is generated). - There's some error checking around unhandled situations. E.g, flattening uniform arrays with initializer lists is not implemented. - This piggybacks on as much of the existing mechanism for struct flattening as it can. E.g, it uses the same flattenMap, and the same flattenAccess() method. - handleAssign() has been generalized to cope with either structs or arrays. - Extended test infrastructure to test flattening ability.
This commit is contained in:
parent
6714bcc2ca
commit
e0b9debda2
11 changed files with 872 additions and 46 deletions
|
|
@ -424,6 +424,11 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
// opaque types can be passed to functions
|
||||
if (op == EOpFunction)
|
||||
break;
|
||||
|
||||
// HLSL can assign samplers directly (no constructor)
|
||||
if (source == EShSourceHlsl && node->getBasicType() == EbtSampler)
|
||||
break;
|
||||
|
||||
// samplers can get assigned via a sampler constructor
|
||||
// (well, not yet, but code in the rest of this function is ready for it)
|
||||
if (node->getBasicType() == EbtSampler && op == EOpAssign &&
|
||||
|
|
|
|||
|
|
@ -1493,6 +1493,8 @@ void TShader::setShiftSamplerBinding(unsigned int base) { intermediate->setShift
|
|||
void TShader::setShiftTextureBinding(unsigned int base) { intermediate->setShiftTextureBinding(base); }
|
||||
void TShader::setShiftUboBinding(unsigned int base) { intermediate->setShiftUboBinding(base); }
|
||||
void TShader::setAutoMapBindings(bool map) { intermediate->setAutoMapBindings(map); }
|
||||
void TShader::setFlattenUniformArrays(bool flatten) { intermediate->setFlattenUniformArrays(flatten); }
|
||||
|
||||
//
|
||||
// Turn the shader strings into a parse tree in the TIntermediate.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -145,7 +145,8 @@ public:
|
|||
shiftSamplerBinding(0),
|
||||
shiftTextureBinding(0),
|
||||
shiftUboBinding(0),
|
||||
autoMapBindings(false)
|
||||
autoMapBindings(false),
|
||||
flattenUniformArrays(false)
|
||||
{
|
||||
localSize[0] = 1;
|
||||
localSize[1] = 1;
|
||||
|
|
@ -176,6 +177,8 @@ public:
|
|||
unsigned int getShiftUboBinding() const { return shiftUboBinding; }
|
||||
void setAutoMapBindings(bool map) { autoMapBindings = map; }
|
||||
bool getAutoMapBindings() const { return autoMapBindings; }
|
||||
void setFlattenUniformArrays(bool flatten) { flattenUniformArrays = flatten; }
|
||||
bool getFlattenUniformArrays() const { return flattenUniformArrays; }
|
||||
|
||||
void setVersion(int v) { version = v; }
|
||||
int getVersion() const { return version; }
|
||||
|
|
@ -385,6 +388,7 @@ protected:
|
|||
unsigned int shiftTextureBinding;
|
||||
unsigned int shiftUboBinding;
|
||||
bool autoMapBindings;
|
||||
bool flattenUniformArrays;
|
||||
|
||||
EProfile profile;
|
||||
int version;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue