GPU/HW: Slight re-shuffling of field offsets

Free up some bits in the middle.
This commit is contained in:
Stenzek 2025-01-07 17:18:25 +10:00
parent 116bc83d09
commit fda87de7e7
No known key found for this signature in database
3 changed files with 19 additions and 25 deletions

View File

@ -172,10 +172,11 @@ protected:
void DestroyDeinterlaceTextures(); void DestroyDeinterlaceTextures();
bool ApplyChromaSmoothing(); bool ApplyChromaSmoothing();
GSVector4i m_clamped_drawing_area = {};
s32 m_display_width = 0; s32 m_display_width = 0;
s32 m_display_height = 0; s32 m_display_height = 0;
GSVector4i m_clamped_drawing_area = {};
s32 m_display_origin_left = 0; s32 m_display_origin_left = 0;
s32 m_display_origin_top = 0; s32 m_display_origin_top = 0;
s32 m_display_vram_width = 0; s32 m_display_vram_width = 0;

View File

@ -3059,10 +3059,9 @@ ALWAYS_INLINE_RELEASE void GPU_HW::CheckForTexPageOverlap(const GPUBackendDrawCo
if (m_texpage_dirty & TEXPAGE_DIRTY_PAGE_RECT) if (m_texpage_dirty & TEXPAGE_DIRTY_PAGE_RECT)
{ {
DebugAssert(!(m_texpage_dirty & (TEXPAGE_DIRTY_DRAWN_RECT | TEXPAGE_DIRTY_WRITTEN_RECT))); DebugAssert(!(m_texpage_dirty & (TEXPAGE_DIRTY_DRAWN_RECT | TEXPAGE_DIRTY_WRITTEN_RECT)));
DebugAssert(m_batch.texture_mode == BatchTextureMode::PageTexture && DebugAssert(m_batch.texture_mode == BatchTextureMode::PageTexture && m_texture_cache_key.page < NUM_VRAM_PAGES);
m_batch.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 // UVs intersect with drawn area, can't use TC
if (m_batch_index_count > 0) if (m_batch_index_count > 0)
@ -3072,7 +3071,7 @@ ALWAYS_INLINE_RELEASE void GPU_HW::CheckForTexPageOverlap(const GPUBackendDrawCo
} }
// We need to swap the dirty tracking over to drawn/written. // 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_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_vram_dirty_write_rect.rintersects(page_rect) ? TEXPAGE_DIRTY_WRITTEN_RECT : 0);
m_compute_uv_range = (ShouldCheckForTexPageOverlap() || m_clamp_uvs); m_compute_uv_range = (ShouldCheckForTexPageOverlap() || m_clamp_uvs);
@ -3605,7 +3604,7 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd)
{ {
// TODO: avoid all this for vertex loading, only do when the type of draw changes // 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; 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) if (cmd->texture_enable)
{ {
// texture page changed - check that the new page doesn't intersect the drawing area // texture page changed - check that the new page doesn't intersect the drawing area
@ -3713,9 +3712,9 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd)
{ {
if (texture_mode != m_batch.texture_mode || transparency_mode != m_batch.transparency_mode || if (texture_mode != m_batch.texture_mode || transparency_mode != m_batch.transparency_mode ||
(transparency_mode == GPUTransparencyMode::BackgroundMinusForeground && !m_allow_shader_blend) || (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) || 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(); FlushRender();
} }
@ -3762,13 +3761,13 @@ void GPU_HW::PrepareDraw(const GPUBackendDrawCommand* cmd)
m_batch.texture_mode = texture_mode; m_batch.texture_mode = texture_mode;
m_batch.transparency_mode = transparency_mode; m_batch.transparency_mode = transparency_mode;
m_batch.dithering = dithering_enable; 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}}); m_texture_window_active = (cmd->window != GPUTextureWindow{{0xFF, 0xFF, 0x00, 0x00}});
GSVector4i::store<true>(&m_batch_ubo_data.u_texture_window[0], GSVector4i::load32(&cmd->window).u8to32()); GSVector4i::store<false>(&m_batch_ubo_data.u_texture_window[0], GSVector4i::load32(&cmd->window).u8to32());
m_batch_ubo_dirty = true; m_batch_ubo_dirty = true;
} }
@ -3812,7 +3811,7 @@ void GPU_HW::FlushRender()
const GPUTextureCache::Source* texture = nullptr; const GPUTextureCache::Source* texture = nullptr;
if (m_batch.texture_mode == BatchTextureMode::PageTexture) 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 ? m_batch.transparency_mode != GPUTransparencyMode::Disabled ?
GPUTextureCache::PaletteRecordFlags::HasSemiTransparentDraws : GPUTextureCache::PaletteRecordFlags::HasSemiTransparentDraws :
GPUTextureCache::PaletteRecordFlags::None); GPUTextureCache::PaletteRecordFlags::None);

View File

@ -15,12 +15,6 @@
#include <tuple> #include <tuple>
#include <utility> #include <utility>
class Error;
class GPU_SW_Backend;
struct GPUBackendCommand;
struct GPUBackendDrawCommand;
// TODO: Move to cpp // TODO: Move to cpp
// TODO: Rename to GPUHWBackend, preserved to avoid conflicts. // TODO: Rename to GPUHWBackend, preserved to avoid conflicts.
class GPU_HW final : public GPUBackend class GPU_HW final : public GPUBackend
@ -147,7 +141,7 @@ private:
void SetUVLimits(u32 min_u, u32 max_u, u32 min_v, u32 max_v); 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; BatchTextureMode texture_mode = BatchTextureMode::Disabled;
GPUTransparencyMode transparency_mode = GPUTransparencyMode::Disabled; GPUTransparencyMode transparency_mode = GPUTransparencyMode::Disabled;
@ -158,13 +152,11 @@ private:
bool use_depth_buffer = false; bool use_depth_buffer = false;
bool sprite_mode = false; bool sprite_mode = false;
GPUTextureCache::SourceKey texture_cache_key = {};
// Returns the render mode for this batch. // Returns the render mode for this batch.
BatchRenderMode GetRenderMode() const; BatchRenderMode GetRenderMode() const;
}; };
struct alignas(VECTOR_ALIGNMENT) BatchUBOData struct BatchUBOData
{ {
u32 u_texture_window[4]; // and_x, and_y, or_x, or_y u32 u_texture_window[4]; // and_x, and_y, or_x, or_y
float u_src_alpha_factor; float u_src_alpha_factor;
@ -174,7 +166,6 @@ private:
float u_resolution_scale; float u_resolution_scale;
float u_rcp_resolution_scale; float u_rcp_resolution_scale;
float u_resolution_scale_minus_one; float u_resolution_scale_minus_one;
GPUTextureWindow u_texture_window_bits; // not actually used on GPU
}; };
struct RendererStats struct RendererStats
@ -339,6 +330,7 @@ private:
// Changed state // Changed state
BatchUBOData m_batch_ubo_data = {}; BatchUBOData m_batch_ubo_data = {};
GPUTextureCache::SourceKey m_texture_cache_key = {};
// Bounding box of VRAM area that the GPU has drawn into. // Bounding box of VRAM area that the GPU has drawn into.
GSVector4i m_vram_dirty_draw_rect = INVALID_RECT; GSVector4i m_vram_dirty_draw_rect = INVALID_RECT;
@ -359,6 +351,8 @@ private:
u32 bits = INVALID_DRAW_MODE_BITS; u32 bits = INVALID_DRAW_MODE_BITS;
} m_draw_mode = {}; } m_draw_mode = {};
GPUTextureWindow m_texture_window_bits;
std::unique_ptr<GPUPipeline> m_wireframe_pipeline; std::unique_ptr<GPUPipeline> m_wireframe_pipeline;
// [wrapped][interlaced] // [wrapped][interlaced]