diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp index 53a7f4c3b5..2242882d26 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp @@ -465,4 +465,14 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept } unreachable("Wrong type"); } + +D3D12_RECT get_scissor(u32 horizontal, u32 vertical) noexcept +{ + return{ + horizontal & 0xFFFF, + vertical & 0xFFFF, + (horizontal & 0xFFFF) + (horizontal >> 16), + (vertical & 0xFFFF) + (vertical >> 16) + }; +} #endif diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h index 37fd9f6aee..45fdac4114 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h @@ -97,3 +97,8 @@ DXGI_FORMAT get_index_type(u8 index_type) noexcept; * Convert vertex attribute format and size to DXGI_FORMAT */ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept; + +/** + * Convert scissor register value to D3D12_RECT + */ +D3D12_RECT get_scissor(u32 horizontal, u32 vertical) noexcept; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index 66c8c0fed6..3a135b9953 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -351,14 +351,7 @@ void D3D12GSRender::end() }; getCurrentResourceStorage().command_list->RSSetViewports(1, &viewport); - D3D12_RECT box = - { - 0, - 0, - (LONG)clip_w, - (LONG)clip_h, - }; - getCurrentResourceStorage().command_list->RSSetScissorRects(1, &box); + getCurrentResourceStorage().command_list->RSSetScissorRects(1, &get_scissor(rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL], rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL])); getCurrentResourceStorage().command_list->IASetPrimitiveTopology(get_primitive_topology(draw_mode)); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index e899983e74..066b73a1d4 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -86,12 +86,13 @@ void D3D12GSRender::clear_surface(u32 arg) { u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8; u32 max_depth_value = m_surface.depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff; - getCurrentResourceStorage().command_list->ClearDepthStencilView(handle, D3D12_CLEAR_FLAG_DEPTH, clear_depth / (float)max_depth_value, 0, 0, nullptr); + getCurrentResourceStorage().command_list->ClearDepthStencilView(handle, D3D12_CLEAR_FLAG_DEPTH, clear_depth / (float)max_depth_value, 0, + 1, &get_scissor(rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL], rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL])); } if (arg & 0x2) - getCurrentResourceStorage().command_list->ClearDepthStencilView(handle, D3D12_CLEAR_FLAG_STENCIL, 0.f, - get_clear_stencil(rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE]), 0, nullptr); + getCurrentResourceStorage().command_list->ClearDepthStencilView(handle, D3D12_CLEAR_FLAG_STENCIL, 0.f, get_clear_stencil(rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE]), + 1, &get_scissor(rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL], rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL])); } if (arg & 0xF0) @@ -101,8 +102,8 @@ void D3D12GSRender::clear_surface(u32 arg) size_t rtt_index = m_rtts.bind_render_targets(m_device.Get(), m_surface.color_format, handle); getCurrentResourceStorage().render_targets_descriptors_heap_index += rtt_index; for (unsigned i = 0; i < rtt_index; i++) - getCurrentResourceStorage().command_list->ClearRenderTargetView(handle.Offset(i, g_descriptorStrideRTV), - get_clear_color(rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE]).data(), 0, nullptr); + getCurrentResourceStorage().command_list->ClearRenderTargetView(handle.Offset(i, g_descriptorStrideRTV), get_clear_color(rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE]).data(), + 1, &get_scissor(rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL], rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL])); } std::chrono::time_point end_duration = std::chrono::system_clock::now();