|
|
|
@ -61,26 +61,27 @@ struct DrawParams { |
|
|
|
|
|
|
|
VkViewport GetViewportState(const Device& device, const Maxwell& regs, size_t index, float scale) { |
|
|
|
const auto& src = regs.viewport_transform[index]; |
|
|
|
auto conv = [scale](float value) { |
|
|
|
const auto conv = [scale](float value) { |
|
|
|
float new_value = value * scale; |
|
|
|
if (scale < 1.0f) { |
|
|
|
bool sign = std::signbit(value); |
|
|
|
const bool sign = std::signbit(value); |
|
|
|
new_value = std::round(std::abs(new_value)); |
|
|
|
new_value = sign ? -new_value : new_value; |
|
|
|
} |
|
|
|
return new_value; |
|
|
|
}; |
|
|
|
float x = conv(src.translate_x - src.scale_x); |
|
|
|
const float x = conv(src.translate_x - src.scale_x); |
|
|
|
float width = conv(src.scale_x * 2.0f); |
|
|
|
float y = conv(src.translate_y - src.scale_y); |
|
|
|
float height = conv(src.scale_y * 2.0f); |
|
|
|
bool lower_left = regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft; |
|
|
|
bool is_main_framebuffer = (width == conv(static_cast<float>(regs.surface_clip.width)) && height == conv(static_cast<float>(regs.surface_clip.height))); |
|
|
|
if (is_main_framebuffer && lower_left) { |
|
|
|
if (regs.window_origin.mode == Maxwell::WindowOrigin::LowerLeft) { |
|
|
|
y = conv(static_cast<float>(regs.surface_clip.height)) - y - height; |
|
|
|
} |
|
|
|
if (!device.IsNvViewportSwizzleSupported() && src.swizzle.y == Maxwell::ViewportSwizzle::NegativeY) { |
|
|
|
y += height; |
|
|
|
height = -height; |
|
|
|
} |
|
|
|
float reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne ? 1.0f : 0.0f; |
|
|
|
const float reduce_z = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne ? 1.0f : 0.0f; |
|
|
|
VkViewport viewport{ |
|
|
|
.x = x, |
|
|
|
.y = y, |
|
|
|
|