[Vulkan] Halve the viewport dimensions when viewport scaling is disabled (10240 -> 5120)

The negative part of the viewport is unused, so hijack the 2 unused parameters of the window scale to use as an offset
This commit is contained in:
DrChat
2018-04-16 12:54:50 -05:00
parent 25f93a171c
commit b90465e2e5
2 changed files with 19 additions and 7 deletions

View File

@@ -532,8 +532,16 @@ std::vector<uint8_t> SpirvShaderTranslator::CompleteTranslation() {
// pos.xy *= window_scale.xy
auto p_scaled =
b.createBinOp(spv::Op::OpFMul, vec4_float_type_, p, window_scale);
// Apply window offset
// pos.xy += window_scale.zw
auto window_offset = b.createOp(spv::Op::OpVectorShuffle, vec4_float_type_,
{window_scale, window_scale, 2, 3, 0, 1});
auto p_offset = b.createBinOp(spv::Op::OpFAdd, vec4_float_type_, p_scaled,
window_offset);
p = b.createOp(spv::Op::OpVectorShuffle, vec4_float_type_,
{p, p_scaled, 4, 5, 2, 3});
{p, p_offset, 4, 5, 2, 3});
b.createStore(p, pos_);
} else {