diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 8c3ab48ad..504c97e1d 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -53,7 +53,6 @@ void GPU::SoftReset() m_drawing_area.Set(0, 0, 0, 0); m_drawing_area_changed = true; m_drawing_offset = {}; - m_drawing_offset_changed = true; std::memset(&m_crtc_state, 0, sizeof(m_crtc_state)); m_crtc_state.regs.display_address_start = 0; m_crtc_state.regs.horizontal_display_range = 0xC60260; @@ -148,7 +147,6 @@ bool GPU::DoState(StateWrapper& sw) m_draw_mode.texture_page_changed = true; m_draw_mode.texture_window_changed = true; m_drawing_area_changed = true; - m_drawing_offset_changed = true; UpdateDMARequest(); } diff --git a/src/core/gpu.h b/src/core/gpu.h index 713cfe219..eab1de2aa 100644 --- a/src/core/gpu.h +++ b/src/core/gpu.h @@ -508,7 +508,6 @@ protected: bool m_set_texture_disable_mask = false; bool m_drawing_area_changed = false; - bool m_drawing_offset_changed = false; bool m_force_progressive_scan = false; struct CRTCState diff --git a/src/core/gpu_commands.cpp b/src/core/gpu_commands.cpp index 599667403..5a00bb288 100644 --- a/src/core/gpu_commands.cpp +++ b/src/core/gpu_commands.cpp @@ -195,7 +195,6 @@ bool GPU::HandleSetDrawingOffsetCommand(const u32*& command_ptr, u32 command_siz m_drawing_offset.x = x; m_drawing_offset.y = y; - m_drawing_offset_changed = true; } EndCommand(); diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index a0bd8a9d7..cef7202a6 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -118,7 +118,7 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices, const u32* command const VertexPosition vp{command_ptr[buffer_pos++]}; const u16 packed_texcoord = textured ? Truncate16(command_ptr[buffer_pos++]) : 0; - vertices[i].Set(vp.x, vp.y, color, texpage, packed_texcoord); + vertices[i].Set(m_drawing_offset.x + vp.x, m_drawing_offset.y + vp.y, color, texpage, packed_texcoord); } // Cull polygons which are too large. @@ -150,7 +150,7 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices, const u32* command const VertexPosition vp{command_ptr[buffer_pos++]}; const u16 packed_texcoord = textured ? Truncate16(command_ptr[buffer_pos++]) : 0; - vertices[3].Set(vp.x, vp.y, color, texpage, packed_texcoord); + vertices[3].Set(m_drawing_offset.x + vp.x, m_drawing_offset.y + vp.y, color, texpage, packed_texcoord); // Cull polygons which are too large. if (std::abs(vertices[3].x - vertices[2].x) >= MAX_PRIMITIVE_WIDTH || @@ -183,8 +183,8 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices, const u32* command u32 buffer_pos = 1; const u32 color = rc.color_for_first_vertex; const VertexPosition vp{command_ptr[buffer_pos++]}; - const s32 pos_x = vp.x; - const s32 pos_y = vp.y; + const s32 pos_x = m_drawing_offset.x + vp.x; + const s32 pos_y = m_drawing_offset.y + vp.y; const auto [texcoord_x, texcoord_y] = UnpackTexcoord(rc.texture_enable ? Truncate16(command_ptr[buffer_pos++]) : 0); @@ -278,7 +278,7 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices, const u32* command const VertexPosition vp{command_ptr[buffer_pos++]}; BatchVertex vertex; - vertex.Set(vp.x, vp.y, color, 0, 0); + vertex.Set(m_drawing_offset.x + vp.x, m_drawing_offset.y + vp.y, color, 0, 0); if (i > 0) { @@ -312,16 +312,10 @@ void GPU_HW::LoadVertices(RenderCommand rc, u32 num_vertices, const u32* command if (min_x <= max_x) { const Common::Rectangle area_covered( - std::clamp(m_drawing_offset.x + min_x, static_cast(m_drawing_area.left), - static_cast(m_drawing_area.right)), - std::clamp(m_drawing_offset.y + min_y, static_cast(m_drawing_area.top), - static_cast(m_drawing_area.bottom)), - std::clamp(m_drawing_offset.x + max_x, static_cast(m_drawing_area.left), - static_cast(m_drawing_area.right)) + - 1, - std::clamp(m_drawing_offset.y + max_y, static_cast(m_drawing_area.top), - static_cast(m_drawing_area.bottom)) + - 1); + std::clamp(min_x, static_cast(m_drawing_area.left), static_cast(m_drawing_area.right)), + std::clamp(min_y, static_cast(m_drawing_area.top), static_cast(m_drawing_area.bottom)), + std::clamp(max_x, static_cast(m_drawing_area.left), static_cast(m_drawing_area.right)) + 1, + std::clamp(max_y, static_cast(m_drawing_area.top), static_cast(m_drawing_area.bottom)) + 1); m_vram_dirty_rect.Include(area_covered); } } @@ -447,7 +441,7 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 { if (m_batch.texture_mode != texture_mode || m_batch.transparency_mode != transparency_mode || m_batch.primitive != rc_primitive || dithering_enable != m_batch.dithering || m_drawing_area_changed || - m_drawing_offset_changed || m_draw_mode.IsTextureWindowChanged()) + m_draw_mode.IsTextureWindowChanged()) { FlushRender(); } @@ -471,14 +465,6 @@ void GPU_HW::DispatchRenderCommand(RenderCommand rc, u32 num_vertices, const u32 m_batch_ubo_dirty = true; } - if (m_drawing_offset_changed) - { - m_drawing_offset_changed = false; - m_batch_ubo_data.u_pos_offset[0] = m_drawing_offset.x; - m_batch_ubo_data.u_pos_offset[1] = m_drawing_offset.y; - m_batch_ubo_dirty = true; - } - // update state m_batch.primitive = rc_primitive; m_batch.texture_mode = texture_mode; diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index c3eb3db28..b8c3b130e 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -95,13 +95,12 @@ protected: struct BatchUBOData { - s32 u_pos_offset[2]; u32 u_texture_window_mask[2]; u32 u_texture_window_offset[2]; float u_src_alpha_factor; float u_dst_alpha_factor; u32 u_set_mask_while_drawing; - u32 padding[3]; + u32 padding[1]; }; struct RendererStats diff --git a/src/core/gpu_hw_opengl_es.cpp b/src/core/gpu_hw_opengl_es.cpp index dfbf9e847..5c96be05d 100644 --- a/src/core/gpu_hw_opengl_es.cpp +++ b/src/core/gpu_hw_opengl_es.cpp @@ -218,7 +218,6 @@ bool GPU_HW_OpenGL_ES::CompilePrograms() prog.Bind(); - prog.RegisterUniform("u_pos_offset"); prog.RegisterUniform("u_texture_window_mask"); prog.RegisterUniform("u_texture_window_offset"); prog.RegisterUniform("u_src_alpha_factor"); @@ -311,12 +310,11 @@ void GPU_HW_OpenGL_ES::SetDrawState(BatchRenderMode render_mode) if (m_batch_ubo_dirty) { - prog.Uniform2iv(0, m_batch_ubo_data.u_pos_offset); - prog.Uniform2uiv(1, m_batch_ubo_data.u_texture_window_mask); - prog.Uniform2uiv(2, m_batch_ubo_data.u_texture_window_offset); - prog.Uniform1f(3, m_batch_ubo_data.u_src_alpha_factor); - prog.Uniform1f(4, m_batch_ubo_data.u_dst_alpha_factor); - prog.Uniform1i(5, static_cast(m_batch_ubo_data.u_set_mask_while_drawing)); + prog.Uniform2uiv(0, m_batch_ubo_data.u_texture_window_mask); + prog.Uniform2uiv(1, m_batch_ubo_data.u_texture_window_offset); + prog.Uniform1f(2, m_batch_ubo_data.u_src_alpha_factor); + prog.Uniform1f(3, m_batch_ubo_data.u_dst_alpha_factor); + prog.Uniform1i(4, static_cast(m_batch_ubo_data.u_set_mask_while_drawing)); m_batch_ubo_dirty = false; } } diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 55e70ee2e..3bf86d29c 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -344,8 +344,8 @@ void GPU_HW_ShaderGen::DeclareFragmentEntryPoint(std::stringstream& ss, u32 num_ void GPU_HW_ShaderGen::WriteBatchUniformBuffer(std::stringstream& ss) { - DeclareUniformBuffer(ss, {"int2 u_pos_offset", "uint2 u_texture_window_mask", "uint2 u_texture_window_offset", - "float u_src_alpha_factor", "float u_dst_alpha_factor", "bool u_set_mask_while_drawing"}); + DeclareUniformBuffer(ss, {"uint2 u_texture_window_mask", "uint2 u_texture_window_offset", "float u_src_alpha_factor", + "float u_dst_alpha_factor", "bool u_set_mask_while_drawing"}); } std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured) @@ -370,8 +370,8 @@ std::string GPU_HW_ShaderGen::GenerateBatchVertexShader(bool textured) ss << R"( { // 0..+1023 -> -1..1 - float pos_x = (float(a_pos.x + u_pos_offset.x) / 512.0) - 1.0; - float pos_y = (float(a_pos.y + u_pos_offset.y) / -256.0) + 1.0; + float pos_x = (float(a_pos.x) / 512.0) - 1.0; + float pos_y = (float(a_pos.y) / -256.0) + 1.0; v_pos = float4(pos_x, pos_y, 0.0, 1.0); v_col0 = a_col0;