Add basic HS/DS implementation.

This obsoletes WIP PR #704, which was built on the pre entry point wrapping master.  New version
here uses entry point wrapping.

This is a limited implementation of tessellation shaders.  In particular, the following are not functional,
and will be added as separate stages to reduce the size of each PR.

* patchconstantfunctions accepting per-control-point input values, such as
  const OutputPatch <hs_out_t, 3> cpv are not implemented.

* patchconstantfunctions whose signature requires an aggregate input type such as
  a structure containing builtin variables.  Code to synthesize such calls is not
  yet present.

These restrictions will be relaxed as soon as possible.  Simple cases can compile now: see for example
Test/hulsl.hull.1.tesc - e.g, writing to inner and outer tessellation factors.

PCF invocation is synthesized as an entry point epilogue protected behind a barrier and a test on
invocation ID == 0.  If there is an existing invocation ID variable it will be used, otherwise one is
added to the linkage.  The PCF and the shader EP interfaces are unioned and builtins appearing in
the PCF but not the EP are also added to the linkage and synthesized as shader inputs.
Parameter matching to (eventually arbitrary) PCF signatures is by builtin variable type.  Any user
variables in the PCF signature will result in an error.  Overloaded PCF functions will also result in
an error.

[domain()], [partitioning()], [outputtopology()], [outputcontrolpoints()], and [patchconstantfunction()]
attributes to the shader entry point are in place, with the exception of the Pow2 partitioning mode.
This commit is contained in:
steve-lunarg
2017-01-07 08:54:10 -07:00
parent 8e711b84bd
commit 858c928ac7
18 changed files with 1562 additions and 11 deletions

View File

@@ -869,6 +869,67 @@ bool HlslGrammar::acceptOutputPrimitiveGeometry(TLayoutGeometry& geometry)
return true;
}
// tessellation_decl_type
// : INPUTPATCH
// | OUTPUTPATCH
//
bool HlslGrammar::acceptTessellationDeclType()
{
// read geometry type
const EHlslTokenClass tessType = peek();
switch (tessType) {
case EHTokInputPatch: break;
case EHTokOutputPatch: break;
default:
return false; // not a tessellation decl
}
advanceToken(); // consume the keyword
return true;
}
// tessellation_patch_template_type
// : tessellation_decl_type LEFT_ANGLE type comma integer_literal RIGHT_ANGLE
//
bool HlslGrammar::acceptTessellationPatchTemplateType(TType& type)
{
if (! acceptTessellationDeclType())
return false;
if (! acceptTokenClass(EHTokLeftAngle))
return false;
if (! acceptType(type)) {
expected("tessellation patch type");
return false;
}
if (! acceptTokenClass(EHTokComma))
return false;
// integer size
if (! peekTokenClass(EHTokIntConstant)) {
expected("literal integer");
return false;
}
TIntermTyped* size;
if (! acceptLiteral(size))
return false;
TArraySizes* arraySizes = new TArraySizes;
arraySizes->addInnerSize(size->getAsConstantUnion()->getConstArray()[0].getIConst());
type.newArraySizes(*arraySizes);
if (! acceptTokenClass(EHTokRightAngle)) {
expected("right angle bracket");
return false;
}
return true;
}
// stream_out_template_type
// : output_primitive_geometry_type LEFT_ANGLE type RIGHT_ANGLE
//
@@ -1147,6 +1208,15 @@ bool HlslGrammar::acceptType(TType& type)
return true;
}
case EHTokInputPatch: // fall through
case EHTokOutputPatch: // ...
{
if (! acceptTessellationPatchTemplateType(type))
return false;
return true;
}
case EHTokSampler: // fall through
case EHTokSampler1d: // ...
case EHTokSampler2d: // ...
@@ -2522,7 +2592,7 @@ bool HlslGrammar::acceptLiteral(TIntermTyped*& node)
node = intermediate.addConstantUnion(token.b, token.loc, true);
break;
case EHTokStringConstant:
node = nullptr;
node = intermediate.addConstantUnion(token.string, token.loc, true);
break;
default: