diff --git a/src/xenia/gpu/spirv_shader_translator.cc b/src/xenia/gpu/spirv_shader_translator.cc index ec19f76c0..51d989cfe 100644 --- a/src/xenia/gpu/spirv_shader_translator.cc +++ b/src/xenia/gpu/spirv_shader_translator.cc @@ -269,7 +269,11 @@ std::vector SpirvShaderTranslator::CompleteTranslation() { auto vtx_fmt_ptr = b.createAccessChain( spv::StorageClass::StorageClassPushConstant, push_consts_, std::vector({b.makeUintConstant(1)})); + auto window_scale_ptr = b.createAccessChain( + spv::StorageClass::StorageClassPushConstant, push_consts_, + std::vector({b.makeUintConstant(0)})); auto vtx_fmt = b.createLoad(vtx_fmt_ptr); + auto window_scale = b.createLoad(window_scale_ptr); auto p = b.createLoad(pos_); auto c = b.createBinOp(spv::Op::OpFOrdNotEqual, vec4_bool_type_, vtx_fmt, @@ -291,6 +295,16 @@ std::vector SpirvShaderTranslator::CompleteTranslation() { // Reinsert w p = b.createCompositeInsert(p_w, p, vec4_float_type_, 3); + // Apply window scaling + // pos.xy *= window_scale.xy + auto p_scaled = b.createUnaryOp(spv::Op::OpCopyObject, vec4_float_type_, p); + p_scaled = b.createBinOp(spv::Op::OpFMul, vec4_float_type_, p_scaled, + window_scale); + + std::vector operands({p, p_scaled}); + p = b.createOp(spv::Op::OpVectorShuffle, vec4_float_type_, + {p, p_scaled, 4, 5, 2, 3}); + b.createStore(p, pos_); }