5eacc974c7
The caveat being having to manually create HLSL versions of the hull, domain, and geometry shaders in parallel with the Vulkan GLSL ones, while keeping the interfaces intact (stage inputs and outputs, cbuffer layouts, binding points/registers). This is not always trivial but typically doable in not very complicated case after inspecting the SPIRV-Cross-generated vertex/fragment code in the .qsb files. Once written, the HLSL files can be injected into a .qsb file with qsb -r. or the corresponding CMake syntax. Conceptually this is no different from how samplerExternalOES support is implemented for Multimedia. (there the problem is that the shaders cannot be compiled to SPIR-V to begin with, here it is that we cannot translate from SPIR-V, but in the end the workaround for both problems is effectively the same) The manual tests demonstrate this, both the tessellation and geometry apps work now with D3D out of the box. On the bright side, the implementation here in the the D3D backend of QRhi does not need to know about how the shaders got there in the QShader. So none of the implementation is dependent on this manual process. If some day qsb would start translating to these kind of shaders as well, it would all still work as-is. Change-Id: I32d9ab94e00174e4bd5b59ac814dfedef9f93ad1 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
41 lines
852 B
HLSL
41 lines
852 B
HLSL
struct Input
|
|
{
|
|
float3 color : TEXCOORD0;
|
|
float4 position : SV_Position;
|
|
};
|
|
|
|
struct Output
|
|
{
|
|
float3 position : POSITION;
|
|
float3 color : COLOR;
|
|
};
|
|
|
|
struct ConstantData
|
|
{
|
|
float edges[3] : SV_TessFactor;
|
|
float inside : SV_InsideTessFactor;
|
|
};
|
|
|
|
ConstantData patchConstFunc(InputPatch<Input, 3> ip, uint PatchID : SV_PrimitiveID )
|
|
{
|
|
ConstantData d;
|
|
d.edges[0] = 4.0;
|
|
d.edges[1] = 4.0;
|
|
d.edges[2] = 4.0;
|
|
d.inside = 4.0;
|
|
return d;
|
|
}
|
|
|
|
[domain("tri")]
|
|
[partitioning("integer")]
|
|
[outputtopology("triangle_cw")]
|
|
[outputcontrolpoints(3)]
|
|
[patchconstantfunc("patchConstFunc")]
|
|
Output main(InputPatch<Input, 3> patch, uint pointId : SV_OutputControlPointID, uint patchId : SV_PrimitiveID)
|
|
{
|
|
Output output;
|
|
output.position = patch[pointId].position;
|
|
output.color = patch[pointId].color;
|
|
return output;
|
|
}
|