From 14523145a272a84a57e1fb2593e04f8643680d2e Mon Sep 17 00:00:00 2001 From: Triang3l Date: Thu, 16 Aug 2018 15:53:55 +0300 Subject: [PATCH] [D3D12] ps_param_gen in HLSL --- src/xenia/gpu/hlsl_shader_translator.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/xenia/gpu/hlsl_shader_translator.cc b/src/xenia/gpu/hlsl_shader_translator.cc index 8ed4afd56..b45ea2ef4 100644 --- a/src/xenia/gpu/hlsl_shader_translator.cc +++ b/src/xenia/gpu/hlsl_shader_translator.cc @@ -277,7 +277,6 @@ std::vector HlslShaderTranslator::CompleteTranslation() { for (uint32_t i = 0; i < kMaxInterpolators; ++i) { source.AppendFormat(" xe_output.interpolators[%u] = (0.0).xxxx;\n", i); } - // TODO(Triang3l): Reset interpolators to zero if really needed. } else if (is_pixel_shader()) { // Pixel shader inputs, outputs and prologue. // If the shader writes to depth, it needs to define @@ -313,7 +312,15 @@ std::vector HlslShaderTranslator::CompleteTranslation() { for (uint32_t i = 0; i < interpolator_register_count; ++i) { source.AppendFormat(" xe_r[%u] = xe_input.interpolators[%u];\n", i, i); } - // TODO(Triang3l): ps_param_gen. + // Write pixel position to the register specified by ps_param_gen. + source.AppendFormat( + " [branch] if (xe_pixel_pos_reg < %uu) {\n" + " float4 xe_pixel_pos = xe_input.position;\n" + " xe_pixel_pos.xy = xe_pixel_pos.xy * xe_ssaa_inv_scale +\n" + " xe_pixel_half_pixel_offset;\n" + " xe_r[xe_pixel_pos_reg] = xe_pixel_pos;\n" + " }\n", + register_count()); } // Common main function variables and prologue. @@ -407,7 +414,7 @@ std::vector HlslShaderTranslator::CompleteTranslation() { " xe_output.colors[2] = xe_color_output[xe_color_output_map.b];\n" " xe_output.colors[3] = xe_color_output[xe_color_output_map.a];\n"); } - // TODO(Triang3l): Half pixel offset, alpha test, gamma. + // TODO(Triang3l): Gamma if needed. source.Append( " return xe_output;\n" "}\n");