diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index d28fa949..10d96810 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -1773,8 +1773,15 @@ void GPU_HW_D3D11::UpdateDisplay() const uint32_t reinterpret_field_offset = (interlaced != InterlacedRenderMode::None) ? GetInterlacedDisplayField() : 0; const uint32_t reinterpret_start_x = m_crtc_state.regs.X * resolution_scale; const uint32_t reinterpret_crop_left = (m_crtc_state.display_vram_left - m_crtc_state.regs.X) * resolution_scale; - const uint32_t uniforms[4] = {reinterpret_start_x, scaled_vram_offset_y + reinterpret_field_offset, - reinterpret_crop_left, reinterpret_field_offset}; + // 6 DWORDs to match the post-RESOLUTION_SCALE-refactor display_ps + // cbuffer (u_vram_offset.xy, u_crop_left, u_field_offset, + // u_resolution_scale, u_pad0). m_resolution_scale is pushed, + // NOT the local resolution_scale (which is forced to 1 in + // 24-bit mode for coord scaling) - the shader's RESOLUTION_SCALE + // macro has always been the session m_resolution_scale. + const uint32_t uniforms[6] = {reinterpret_start_x, scaled_vram_offset_y + reinterpret_field_offset, + reinterpret_crop_left, reinterpret_field_offset, + m_resolution_scale, 0u /* u_pad0 */}; ID3D11PixelShader* display_pixel_shader = m_display_pixel_shaders[static_cast(m_GPUSTAT.display_area_color_depth_24)][static_cast(interlaced)].Get(); diff --git a/src/core/gpu_hw_d3d12.cpp b/src/core/gpu_hw_d3d12.cpp index 01d6fd08..4a137876 100644 --- a/src/core/gpu_hw_d3d12.cpp +++ b/src/core/gpu_hw_d3d12.cpp @@ -2067,8 +2067,15 @@ void GPU_HW_D3D12::UpdateDisplay() const uint32_t reinterpret_field_offset = (interlaced != InterlacedRenderMode::None) ? GetInterlacedDisplayField() : 0; const uint32_t reinterpret_start_x = m_crtc_state.regs.X * resolution_scale; const uint32_t reinterpret_crop_left = (m_crtc_state.display_vram_left - m_crtc_state.regs.X) * resolution_scale; - const uint32_t uniforms[4] = {reinterpret_start_x, scaled_vram_offset_y + reinterpret_field_offset, - reinterpret_crop_left, reinterpret_field_offset}; + // 6 DWORDs to match the post-RESOLUTION_SCALE-refactor display_ps + // cbuffer (u_vram_offset.xy, u_crop_left, u_field_offset, + // u_resolution_scale, u_pad0). m_resolution_scale is pushed, + // NOT the local resolution_scale (which is forced to 1 in + // 24-bit mode for coord scaling) - the shader's RESOLUTION_SCALE + // macro has always been the session m_resolution_scale. + const uint32_t uniforms[6] = {reinterpret_start_x, scaled_vram_offset_y + reinterpret_field_offset, + reinterpret_crop_left, reinterpret_field_offset, + m_resolution_scale, 0u /* u_pad0 */}; ID3D12GraphicsCommandList* cmdlist = g_d3d12_context->GetCommandList(); m_display_texture.TransitionToState(D3D12_RESOURCE_STATE_RENDER_TARGET); diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 4c00c97d..ef6a1976 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -1756,8 +1756,15 @@ void GPU_HW_OpenGL::UpdateDisplay() reinterpret_field_offset - (scaled_display_height >> height_div2); const uint32_t reinterpret_start_x = m_crtc_state.regs.X * resolution_scale; const uint32_t reinterpret_crop_left = (m_crtc_state.display_vram_left - m_crtc_state.regs.X) * resolution_scale; - const uint32_t uniforms[4] = {reinterpret_start_x, scaled_flipped_vram_offset_y, reinterpret_crop_left, - reinterpret_field_offset}; + // 6 DWORDs to match the post-RESOLUTION_SCALE-refactor display_ps + // cbuffer (u_vram_offset.xy, u_crop_left, u_field_offset, + // u_resolution_scale, u_pad0). m_resolution_scale is pushed, + // NOT the local resolution_scale (forced to 1 in 24-bit mode) + // since the shader's RESOLUTION_SCALE has always been the + // session m_resolution_scale. scaled_flipped_vram_offset_y + // preserves OpenGL's lower-left origin y-flip. + const uint32_t uniforms[6] = {reinterpret_start_x, scaled_flipped_vram_offset_y, reinterpret_crop_left, + reinterpret_field_offset, m_resolution_scale, 0u /* u_pad0 */}; UploadUniformBuffer(uniforms, sizeof(uniforms)); m_batch_ubo_dirty = true; diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 0c48a0dd..a4ba82d8 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -1070,8 +1070,28 @@ std::string GPU_HW_ShaderGen::GenerateDisplayFragmentShader(bool depth_24bit, DefineMacro(ss, "INTERLEAVED", interlace_mode == GPU_HW::InterlacedRenderMode::InterleavedFields); DefineMacro(ss, "SMOOTH_CHROMA", smooth_chroma); - WriteCommonFunctions(ss); - DeclareUniformBuffer(ss, {"uint2 u_vram_offset", "uint u_crop_left", "uint u_field_offset"}, true); + // u_resolution_scale appended; u_pad0 keeps the cbuffer 16-byte- + // aligned. The 4 callers (D3D11 / D3D12 / OpenGL / Vulkan + // GPU_HW_*::UpdateDisplay) must push uniforms in this exact + // order: u_vram_offset.x, u_vram_offset.y, u_crop_left, + // u_field_offset, u_resolution_scale, u_pad0. + DeclareUniformBuffer(ss, + {"uint2 u_vram_offset", "uint u_crop_left", "uint u_field_offset", "uint u_resolution_scale", + "uint u_pad0"}, + true); + + // Route RESOLUTION_SCALE / VRAM_SIZE / RCP_VRAM_SIZE through the + // cbuffer above. Same pattern as e56d4d4 / 9d2b49d / 2980961. + // display_ps body uses RESOLUTION_SCALE in SampleVRAM24 (24-bit + // colour mode coord scaling) and VRAM_SIZE in the 16-bit path's + // modulo wrap. The 24-bit path is hit during FMV playback and any + // game that uses true-colour mode for the framebuffer; the 16-bit + // path is the common case (every game's standard framebuffer + // present). Both expand to the same #define aliases as + // u_resolution_scale-derived arithmetic. + WriteCBufferResolutionScaleAliases(ss); + WriteCommonFunctions(ss, true); + DeclareTexture(ss, "samp0", 0, UsingMSAA()); ss << R"( diff --git a/src/core/gpu_hw_vulkan.cpp b/src/core/gpu_hw_vulkan.cpp index ab11d5fb..7df82154 100644 --- a/src/core/gpu_hw_vulkan.cpp +++ b/src/core/gpu_hw_vulkan.cpp @@ -3128,8 +3128,15 @@ void GPU_HW_Vulkan::UpdateDisplay() const uint32_t reinterpret_field_offset = (interlaced != InterlacedRenderMode::None) ? GetInterlacedDisplayField() : 0; const uint32_t reinterpret_start_x = m_crtc_state.regs.X * resolution_scale; const uint32_t reinterpret_crop_left = (m_crtc_state.display_vram_left - m_crtc_state.regs.X) * resolution_scale; - const uint32_t uniforms[4] = {reinterpret_start_x, scaled_vram_offset_y + reinterpret_field_offset, - reinterpret_crop_left, reinterpret_field_offset}; + // 6 DWORDs to match the post-RESOLUTION_SCALE-refactor display_ps + // cbuffer (u_vram_offset.xy, u_crop_left, u_field_offset, + // u_resolution_scale, u_pad0). m_resolution_scale is pushed, + // NOT the local resolution_scale (which is forced to 1 in + // 24-bit mode for coord scaling) - the shader's RESOLUTION_SCALE + // macro has always been the session m_resolution_scale. + const uint32_t uniforms[6] = {reinterpret_start_x, scaled_vram_offset_y + reinterpret_field_offset, + reinterpret_crop_left, reinterpret_field_offset, + m_resolution_scale, 0u /* u_pad0 */}; m_display_texture.TransitionToLayout(cmdbuf, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); m_vram_texture.TransitionToLayout(cmdbuf, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);