diff --git a/src/core/gpu_backend.h b/src/core/gpu_backend.h index 53f79fb8b..9ed39bdd3 100644 --- a/src/core/gpu_backend.h +++ b/src/core/gpu_backend.h @@ -191,10 +191,11 @@ protected: void DestroyDeinterlaceTextures(); bool ApplyChromaSmoothing(); - GSVector4i m_clamped_drawing_area = {}; - s32 m_display_width = 0; s32 m_display_height = 0; + + GSVector4i m_clamped_drawing_area = {}; + s32 m_display_origin_left = 0; s32 m_display_origin_top = 0; s32 m_display_vram_width = 0; diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index c9176eee1..401f522a0 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -3050,10 +3050,9 @@ ALWAYS_INLINE_RELEASE void GPU_HW::CheckForTexPageOverlap(const GPUBackendDrawCo if (m_texpage_dirty & TEXPAGE_DIRTY_PAGE_RECT) { DebugAssert(!(m_texpage_dirty & (TEXPAGE_DIRTY_DRAWN_RECT | TEXPAGE_DIRTY_WRITTEN_RECT))); - DebugAssert(m_batch.texture_mode == BatchTextureMode::PageTexture && - m_batch.texture_cache_key.page < NUM_VRAM_PAGES); + DebugAssert(m_batch.texture_mode == BatchTextureMode::PageTexture && m_texture_cache_key.page < NUM_VRAM_PAGES); - if (GPUTextureCache::AreSourcePagesDrawn(m_batch.texture_cache_key, m_current_uv_rect)) + if (GPUTextureCache::AreSourcePagesDrawn(m_texture_cache_key, m_current_uv_rect)) { // UVs intersect with drawn area, can't use TC if (m_batch_index_count > 0) @@ -3063,7 +3062,7 @@ ALWAYS_INLINE_RELEASE void GPU_HW::CheckForTexPageOverlap(const GPUBackendDrawCo } // We need to swap the dirty tracking over to drawn/written. - const GSVector4i page_rect = GetTextureRect(m_batch.texture_cache_key.page, m_batch.texture_cache_key.mode); + const GSVector4i page_rect = GetTextureRect(m_texture_cache_key.page, m_texture_cache_key.mode); m_texpage_dirty = (m_vram_dirty_draw_rect.rintersects(page_rect) ? TEXPAGE_DIRTY_DRAWN_RECT : 0) | (m_vram_dirty_write_rect.rintersects(page_rect) ? TEXPAGE_DIRTY_WRITTEN_RECT : 0); m_compute_uv_range = (ShouldCheckForTexPageOverlap() || m_clamp_uvs); @@ -3572,7 +3571,7 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd) { // TODO: avoid all this for vertex loading, only do when the type of draw changes BatchTextureMode texture_mode = cmd->texture_enable ? m_batch.texture_mode : BatchTextureMode::Disabled; - GPUTextureCache::SourceKey texture_cache_key = m_batch.texture_cache_key; + GPUTextureCache::SourceKey texture_cache_key = m_texture_cache_key; if (cmd->texture_enable) { // texture page changed - check that the new page doesn't intersect the drawing area @@ -3680,9 +3679,9 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd) { if (texture_mode != m_batch.texture_mode || transparency_mode != m_batch.transparency_mode || (transparency_mode == GPUTransparencyMode::BackgroundMinusForeground && !m_allow_shader_blend) || - dithering_enable != m_batch.dithering || m_batch_ubo_data.u_texture_window_bits != cmd->window || + dithering_enable != m_batch.dithering || m_texture_window_bits != cmd->window || m_batch_ubo_data.u_set_mask_while_drawing != BoolToUInt32(cmd->set_mask_while_drawing) || - (texture_mode == BatchTextureMode::PageTexture && m_batch.texture_cache_key != texture_cache_key)) + (texture_mode == BatchTextureMode::PageTexture && m_texture_cache_key != texture_cache_key)) { FlushRender(); } @@ -3729,13 +3728,13 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd) m_batch.texture_mode = texture_mode; m_batch.transparency_mode = transparency_mode; m_batch.dithering = dithering_enable; - m_batch.texture_cache_key = texture_cache_key; + m_texture_cache_key = texture_cache_key; - if (m_batch_ubo_data.u_texture_window_bits != cmd->window) + if (m_texture_window_bits != cmd->window) { - m_batch_ubo_data.u_texture_window_bits = cmd->window; + m_texture_window_bits = cmd->window; m_texture_window_active = (cmd->window != GPUTextureWindow{{0xFF, 0xFF, 0x00, 0x00}}); - GSVector4i::store(&m_batch_ubo_data.u_texture_window[0], GSVector4i::load32(&cmd->window).u8to32()); + GSVector4i::store(&m_batch_ubo_data.u_texture_window[0], GSVector4i::load32(&cmd->window).u8to32()); m_batch_ubo_dirty = true; } @@ -3779,7 +3778,7 @@ void GPU_HW::FlushRender() const GPUTextureCache::Source* texture = nullptr; if (m_batch.texture_mode == BatchTextureMode::PageTexture) { - texture = LookupSource(m_batch.texture_cache_key, m_current_uv_rect, + texture = LookupSource(m_texture_cache_key, m_current_uv_rect, m_batch.transparency_mode != GPUTransparencyMode::Disabled ? GPUTextureCache::PaletteRecordFlags::HasSemiTransparentDraws : GPUTextureCache::PaletteRecordFlags::None); diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index 1cfbb0e62..fd909a995 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -15,12 +15,6 @@ #include #include -class Error; - -class GPU_SW_Backend; -struct GPUBackendCommand; -struct GPUBackendDrawCommand; - // TODO: Move to cpp // TODO: Rename to GPUHWBackend, preserved to avoid conflicts. class GPU_HW final : public GPUBackend @@ -139,7 +133,7 @@ private: void SetUVLimits(u32 min_u, u32 max_u, u32 min_v, u32 max_v); }; - struct alignas(4) BatchConfig + struct BatchConfig { BatchTextureMode texture_mode = BatchTextureMode::Disabled; GPUTransparencyMode transparency_mode = GPUTransparencyMode::Disabled; @@ -150,13 +144,11 @@ private: bool use_depth_buffer = false; bool sprite_mode = false; - GPUTextureCache::SourceKey texture_cache_key = {}; - // Returns the render mode for this batch. BatchRenderMode GetRenderMode() const; }; - struct alignas(VECTOR_ALIGNMENT) BatchUBOData + struct BatchUBOData { u32 u_texture_window[4]; // and_x, and_y, or_x, or_y float u_src_alpha_factor; @@ -166,7 +158,6 @@ private: float u_resolution_scale; float u_rcp_resolution_scale; float u_resolution_scale_minus_one; - GPUTextureWindow u_texture_window_bits; // not actually used on GPU }; struct RendererStats @@ -327,6 +318,7 @@ private: bool m_batch_ubo_dirty = true; bool m_drawing_area_changed = true; BatchConfig m_batch; + GPUTextureCache::SourceKey m_texture_cache_key = {}; // Changed state BatchUBOData m_batch_ubo_data = {}; @@ -350,6 +342,8 @@ private: u32 bits = INVALID_DRAW_MODE_BITS; } m_draw_mode = {}; + GPUTextureWindow m_texture_window_bits; + std::unique_ptr m_wireframe_pipeline; // [wrapped][interlaced]