HLSL: Type sanitization: create non-IO types for var decl and fn param/ret
This introduces parallel types for IO-type containing aggregates used as non-entry point function parameters or return types, or declared as variables. Further uses of the same original type will share the same sanitized deep structure. This is intended to be used with the wrap-entry-point branch.
This commit is contained in:
parent
0fe106afd2
commit
5d3023af03
5 changed files with 282 additions and 229 deletions
|
|
@ -401,7 +401,20 @@ public:
|
|||
// drop qualifiers that don't belong in a temporary variable
|
||||
void makeTemporary()
|
||||
{
|
||||
makeNonIo();
|
||||
storage = EvqTemporary;
|
||||
specConstant = false;
|
||||
coherent = false;
|
||||
volatil = false;
|
||||
restrict = false;
|
||||
readonly = false;
|
||||
writeonly = false;
|
||||
}
|
||||
|
||||
// Remove IO related data from qualifier.
|
||||
void makeNonIo()
|
||||
{
|
||||
// This preserves the storage type
|
||||
builtIn = EbvNone;
|
||||
centroid = false;
|
||||
smooth = false;
|
||||
|
|
@ -412,15 +425,18 @@ public:
|
|||
#endif
|
||||
patch = false;
|
||||
sample = false;
|
||||
coherent = false;
|
||||
volatil = false;
|
||||
restrict = false;
|
||||
readonly = false;
|
||||
writeonly = false;
|
||||
specConstant = false;
|
||||
clearLayout();
|
||||
}
|
||||
|
||||
// Return true if there is data which would be scrubbed by makeNonIo
|
||||
bool hasIoData() const
|
||||
{
|
||||
return builtIn != EbvNone ||
|
||||
hasLayout() ||
|
||||
isInterpolation() ||
|
||||
isAuxiliary();
|
||||
}
|
||||
|
||||
// Drop just the storage qualification, which perhaps should
|
||||
// never be done, as it is fundamentally inconsistent, but need to
|
||||
// explore what downstream consumers need.
|
||||
|
|
@ -1209,6 +1225,30 @@ public:
|
|||
deepCopy(copyOf, copied);
|
||||
}
|
||||
|
||||
// Return true if type (recursively) contains IO data.
|
||||
bool hasIoData() const
|
||||
{
|
||||
if (getQualifier().hasIoData())
|
||||
return true;
|
||||
|
||||
if (isStruct())
|
||||
for (unsigned int i = 0; i < structure->size(); ++i)
|
||||
if ((*structure)[i].type->hasIoData())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove IO related data from type
|
||||
void makeNonIo()
|
||||
{
|
||||
getQualifier().makeNonIo();
|
||||
|
||||
if (isStruct())
|
||||
for (unsigned int i = 0; i < structure->size(); ++i)
|
||||
(*structure)[i].type->makeNonIo();
|
||||
}
|
||||
|
||||
// Recursively make temporary
|
||||
void makeTemporary()
|
||||
{
|
||||
|
|
@ -1701,6 +1741,7 @@ public:
|
|||
const char* getBuiltInVariableString() const { return GetBuiltInVariableString(qualifier.builtIn); }
|
||||
const char* getPrecisionQualifierString() const { return GetPrecisionQualifierString(qualifier.precision); }
|
||||
const TTypeList* getStruct() const { return structure; }
|
||||
void setStruct(TTypeList* s) { structure = s; }
|
||||
TTypeList* getWritableStruct() const { return structure; } // This should only be used when known to not be sharing with other threads
|
||||
|
||||
int computeNumComponents() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue