summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan/vk_rasterizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/renderer_vulkan/vk_rasterizer.cpp')
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp85
1 files changed, 46 insertions, 39 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 74f9f099e..8ba50a834 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -125,11 +125,23 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3
return value < 0 ? std::min<s32>(converted_value - acumm, -1)
: std::max<s32>(converted_value + acumm, 1);
};
+
+ const bool lower_left = regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft;
+ const s32 clip_height = regs.surface_clip.height;
+
+ // Flip coordinates if lower left
+ s32 min_y = lower_left ? (clip_height - src.max_y) : src.min_y.Value();
+ s32 max_y = lower_left ? (clip_height - src.min_y) : src.max_y.Value();
+
+ // Bound to render area
+ min_y = std::max(min_y, 0);
+ max_y = std::max(max_y, 0);
+
if (src.enable) {
- scissor.offset.x = scale_up(static_cast<s32>(src.min_x));
- scissor.offset.y = scale_up(static_cast<s32>(src.min_y));
+ scissor.offset.x = scale_up(src.min_x);
+ scissor.offset.y = scale_up(min_y);
scissor.extent.width = scale_up(src.max_x - src.min_x);
- scissor.extent.height = scale_up(src.max_y - src.min_y);
+ scissor.extent.height = scale_up(max_y - min_y);
} else {
scissor.offset.x = 0;
scissor.offset.y = 0;
@@ -308,17 +320,33 @@ void RasterizerVulkan::DrawTexture() {
const auto& draw_texture_state = maxwell3d->draw_manager->GetDrawTextureState();
const auto& sampler = texture_cache.GetGraphicsSampler(draw_texture_state.src_sampler);
const auto& texture = texture_cache.GetImageView(draw_texture_state.src_texture);
- Region2D dst_region = {Offset2D{.x = static_cast<s32>(draw_texture_state.dst_x0),
- .y = static_cast<s32>(draw_texture_state.dst_y0)},
- Offset2D{.x = static_cast<s32>(draw_texture_state.dst_x1),
- .y = static_cast<s32>(draw_texture_state.dst_y1)}};
- Region2D src_region = {Offset2D{.x = static_cast<s32>(draw_texture_state.src_x0),
- .y = static_cast<s32>(draw_texture_state.src_y0)},
- Offset2D{.x = static_cast<s32>(draw_texture_state.src_x1),
- .y = static_cast<s32>(draw_texture_state.src_y1)}};
- blit_image.BlitColor(texture_cache.GetFramebuffer(), texture.RenderTarget(),
- texture.ImageHandle(), sampler->Handle(), dst_region, src_region,
- texture.size);
+ const auto* framebuffer = texture_cache.GetFramebuffer();
+
+ const bool src_rescaling = texture_cache.IsRescaling() && texture.IsRescaled();
+ const bool dst_rescaling = texture_cache.IsRescaling() && framebuffer->IsRescaled();
+
+ const auto ScaleSrc = [&](auto dim_f) -> s32 {
+ auto dim = static_cast<s32>(dim_f);
+ return src_rescaling ? Settings::values.resolution_info.ScaleUp(dim) : dim;
+ };
+
+ const auto ScaleDst = [&](auto dim_f) -> s32 {
+ auto dim = static_cast<s32>(dim_f);
+ return dst_rescaling ? Settings::values.resolution_info.ScaleUp(dim) : dim;
+ };
+
+ Region2D dst_region = {Offset2D{.x = ScaleDst(draw_texture_state.dst_x0),
+ .y = ScaleDst(draw_texture_state.dst_y0)},
+ Offset2D{.x = ScaleDst(draw_texture_state.dst_x1),
+ .y = ScaleDst(draw_texture_state.dst_y1)}};
+ Region2D src_region = {Offset2D{.x = ScaleSrc(draw_texture_state.src_x0),
+ .y = ScaleSrc(draw_texture_state.src_y0)},
+ Offset2D{.x = ScaleSrc(draw_texture_state.src_x1),
+ .y = ScaleSrc(draw_texture_state.src_y1)}};
+ Extent3D src_size = {static_cast<u32>(ScaleSrc(texture.size.width)),
+ static_cast<u32>(ScaleSrc(texture.size.height)), texture.size.depth};
+ blit_image.BlitColor(framebuffer, texture.RenderTarget(), texture.ImageHandle(),
+ sampler->Handle(), dst_region, src_region, src_size);
}
void RasterizerVulkan::Clear(u32 layer_count) {
@@ -1054,37 +1082,16 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) {
regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM ||
regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM ||
regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM;
- bool force_unorm = ([&] {
- if (!is_d24 || device.SupportsD24DepthBuffer()) {
- return false;
- }
- if (device.IsExtDepthBiasControlSupported()) {
- return true;
- }
- if (!Settings::values.renderer_amdvlk_depth_bias_workaround) {
- return false;
- }
+ if (is_d24 && !device.SupportsD24DepthBuffer() && program_id == 0x1006A800016E000ULL) {
+ // Only activate this in Super Smash Brothers Ultimate
// the base formulas can be obtained from here:
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias
const double rescale_factor =
static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127));
units = static_cast<float>(static_cast<double>(units) * rescale_factor);
- return false;
- })();
+ }
scheduler.Record([constant = units, clamp = regs.depth_bias_clamp,
- factor = regs.slope_scale_depth_bias, force_unorm,
- precise = device.HasExactDepthBiasControl()](vk::CommandBuffer cmdbuf) {
- if (force_unorm) {
- VkDepthBiasRepresentationInfoEXT info{
- .sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT,
- .pNext = nullptr,
- .depthBiasRepresentation =
- VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT,
- .depthBiasExact = precise ? VK_TRUE : VK_FALSE,
- };
- cmdbuf.SetDepthBias(constant, clamp, factor, &info);
- return;
- }
+ factor = regs.slope_scale_depth_bias](vk::CommandBuffer cmdbuf) {
cmdbuf.SetDepthBias(constant, clamp, factor);
});
}