[D3D12] Move interpolators above position because it's more important for pixel shaders

This commit is contained in:
Triang3l 2018-08-18 18:47:13 +03:00
parent bd868ae6cc
commit 7ba2526fa8
2 changed files with 18 additions and 18 deletions

View File

@ -1,6 +1,6 @@
struct XeVertex {
float4 position : SV_Position;
float4 interpolators[16] : TEXCOORD;
float4 position : SV_Position;
float point_size : PSIZE;
};
@ -8,16 +8,16 @@ struct XeVertex {
void main(triangle XeVertex xe_in[3], inout TriangleStream<XeVertex> xe_stream) {
XeVertex xe_out;
xe_out.position = xe_in[0].position;
xe_out.interpolators = xe_in[0].interpolators;
xe_out.position = xe_in[0].position;
xe_out.point_size = xe_in[0].point_size;
xe_stream.Append(xe_out);
xe_out.position = xe_in[1].position;
xe_out.interpolators = xe_in[1].interpolators;
xe_out.position = xe_in[1].position;
xe_out.point_size = xe_in[1].point_size;
xe_stream.Append(xe_out);
xe_out.position = xe_in[2].position;
xe_out.interpolators = xe_in[2].interpolators;
xe_out.position = xe_in[2].position;
xe_out.point_size = xe_in[2].point_size;
xe_stream.Append(xe_out);
xe_stream.RestartStrip();
@ -38,46 +38,46 @@ void main(triangle XeVertex xe_in[3], inout TriangleStream<XeVertex> xe_stream)
// | // | 2: 1,-1
// | - | 3: [ 1, 1 ]
// 1 ------[3]
xe_out.position = xe_in[2].position;
xe_out.interpolators = xe_in[2].interpolators;
xe_out.position = xe_in[2].position;
xe_out.point_size = xe_in[2].point_size;
xe_stream.Append(xe_out);
xe_out.position = xe_in[1].position;
xe_out.interpolators = xe_in[1].interpolators;
xe_out.position = xe_in[1].position;
xe_out.point_size = xe_in[1].point_size;
xe_stream.Append(xe_out);
xe_out.position = float4(xe_in[1].position.xy -
xe_in[0].position.xy +
xe_in[2].position.xy,
xe_in[2].position.zw);
[unroll] for (int i = 0; i < 16; ++i) {
xe_out.interpolators[i] = xe_in[1].interpolators[i] -
xe_in[0].interpolators[i] +
xe_in[2].interpolators[i];
}
xe_out.position = float4(xe_in[1].position.xy -
xe_in[0].position.xy +
xe_in[2].position.xy,
xe_in[2].position.zw);
} else {
// 0 ------ 1 0: -1,-1
// | - | 1: 1,-1
// | \\ | 2: 1, 1
// | - | 3: [-1, 1 ]
// [3] ----- 2
xe_out.position = xe_in[0].position;
xe_out.interpolators = xe_in[0].interpolators;
xe_out.position = xe_in[0].position;
xe_out.point_size = xe_in[0].point_size;
xe_stream.Append(xe_out);
xe_out.position = xe_in[2].position;
xe_out.interpolators = xe_in[2].interpolators;
xe_out.position = xe_in[2].position;
xe_out.point_size = xe_in[2].point_size;
xe_stream.Append(xe_out);
xe_out.position = float4(xe_in[0].position.xy -
xe_in[1].position.xy +
xe_in[2].position.xy,
xe_in[2].position.zw);
[unroll] for (int i = 0; i < 16; ++i) {
xe_out.interpolators[i] = xe_in[0].interpolators[i] -
xe_in[1].interpolators[i] +
xe_in[2].interpolators[i];
}
xe_out.position = float4(xe_in[0].position.xy -
xe_in[1].position.xy +
xe_in[2].position.xy,
xe_in[2].position.zw);
}
xe_out.point_size = xe_in[2].point_size;
xe_stream.Append(xe_out);

View File

@ -258,8 +258,8 @@ std::vector<uint8_t> HlslShaderTranslator::CompleteTranslation() {
"XE_BYTE_SWAP_OVERLOAD(uint4)\n"
"\n"
"struct XeVertexShaderOutput {\n"
" float4 position : SV_Position;\n"
" float4 interpolators[%u] : TEXCOORD;\n"
" float4 position : SV_Position;\n"
" float point_size : PSIZE;\n"
"};\n"
"\n"
@ -283,8 +283,8 @@ std::vector<uint8_t> HlslShaderTranslator::CompleteTranslation() {
// XE_PIXEL_SHADER_WRITES_DEPTH in the beginning of the final output.
source.AppendFormat(
"struct XePixelShaderInput {\n"
" float4 position : SV_Position;\n"
" float4 interpolators[%u] : TEXCOORD;\n"
" float4 position : SV_Position;\n"
"};\n"
"\n"
"struct XePixelShaderOutput {\n"