diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-06-27 16:53:48 -0400 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-06-27 13:53:47 -0700 |
| commit | 22033f06573f900dc030c487b2c30feddf3d8f16 (patch) | |
| tree | 34770637a5985328478eda0b7b31cc91ee87c0f8 /tests | |
| parent | 4bbd0e70a246290ce5c0e0a80b951fec504b6844 (diff) | |
Support for Tessellation (#607)
* Fix typo OuptutTopologyAttribute -> OutputTopologyAttribute
First pass support for handing tesselation shaders - domain and hull.
* Added attribute PatchConstantFuncAttribute
* Added visitHLSLPatchType(HLSLPatchType* type) such that the patch type template parameters are handled
* Added IRNotePatchConstantFunc - such that the patch constant function is referenced within IR
* Added support for outputing typical tesselation attributes (although minimal validation is performed)
* Added findFunctionDeclByName
* Small improvements to diagnostic.
* Improved diagnostics and checking for geometry shader attributes.
* Added diagnostic if patchconstantfunc is not found
Handle assert failure when outputing a domain shader alone and therefore attr->patchConstantFuncDecl is not set.
* Simple script tess.hlsl to test out domain/hull shaders.
* Added url for where hull shader attributes are defined.
* Fix unsigned/signed comparison warning.
* Restore removal of fix in "Improve generic argument inference for builtins (#598)"
* Update tessellation test case to compare against fxc
The test was previously comparing against fixed expected DXBC output, but this caused problems when the test runner tried to execute the test on Linux (where there is no fxc to invoke...), and would also be a potential source of problems down the road if different users run using different builds of fxc.
The simple solution here is to convert the test to compare against fxc output generated on the fly. That test type is already filtered out on non-Windows builds, so it eliminates the portability issue (in a crude way).
I also changed the test to compile both entry points in one compiler invocation, just to streamline things into fewer distinct tests.
* Eliminate unnecessary call to `lowerFuncDecl`
In a very obscure case this could cause a bug, if the patch-constant function had somehow already been lowered (because it was called somewhere else in the code).
The call should not be needed because `ensureDecl` will lower a declaration on-demand if required, so eliminating it causes no problems for code that wouldn't be in that extreme corner case.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/render/tess.hlsl | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/render/tess.hlsl b/tests/render/tess.hlsl new file mode 100644 index 000000000..1cd01ef33 --- /dev/null +++ b/tests/render/tess.hlsl @@ -0,0 +1,78 @@ +//TEST:COMPARE_HLSL: -target dxbc-assembly -profile hs_5_1 -entry HS -profile ds_5_1 -entry DS + +// tests/render/tess.hlsl + +// -profile vs_5_1 -o my-shader.vs.dxbc -entry VS -profile ps_5_1 -o my-shader.ps.dxbc -entry PS + +struct IA_OUTPUT +{ + float3 cpoint : CPOINT; +}; + +struct VS_OUTPUT +{ + float3 cpoint : CPOINT; +}; + +struct HS_CONSTANT_OUTPUT +{ + float edges[2] : SV_TessFactor; +}; + +struct HS_OUTPUT +{ + float3 cpoint : CPOINT; +}; + +struct DS_OUTPUT +{ + float4 position : SV_Position; +}; + +VS_OUTPUT VS(IA_OUTPUT input) +{ + VS_OUTPUT output; + output.cpoint = input.cpoint; + return output; +} + +HS_CONSTANT_OUTPUT HSConst() +{ + HS_CONSTANT_OUTPUT output; + + output.edges[0] = 1.0f; // Detail factor + output.edges[1] = 64.0f; // Density factor + + return output; +} + +[domain("isoline")] +[partitioning("integer")] +[outputtopology("line")] +[outputcontrolpoints(4)] +[patchconstantfunc("HSConst")] +HS_OUTPUT HS(InputPatch<VS_OUTPUT, 4> ip, uint id : SV_OutputControlPointID) +{ + HS_OUTPUT output; + output.cpoint = ip[id].cpoint; + return output; +} + +[domain("isoline")] +DS_OUTPUT DS(HS_CONSTANT_OUTPUT input, OutputPatch<HS_OUTPUT, 4> op, float2 uv : SV_DomainLocation) +{ + DS_OUTPUT output; + + float t = uv.x; + + float3 pos = pow(1.0f - t, 3.0f) * op[0].cpoint + 3.0f * pow(1.0f - t, 2.0f) * t * op[1].cpoint + 3.0f * (1.0f - t) * pow(t, 2.0f) * op[2].cpoint + pow(t, 3.0f) * op[3].cpoint; + + output.position = float4(pos, 1.0f); + + return output; +} + +float4 PS(DS_OUTPUT input) : SV_Target0 +{ + return float4(0.0f, 0.0f, 0.0f, 1.0f); +}
\ No newline at end of file |
