mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-25 23:25:41 +00:00
GPU: Remove redundant fields
This commit is contained in:
parent
23d5b20da6
commit
98a96db1bd
|
@ -193,12 +193,16 @@ bool GPU::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_displ
|
||||||
sw.Do(&m_GPUSTAT.bits);
|
sw.Do(&m_GPUSTAT.bits);
|
||||||
|
|
||||||
sw.Do(&m_draw_mode.mode_reg.bits);
|
sw.Do(&m_draw_mode.mode_reg.bits);
|
||||||
sw.Do(&m_draw_mode.palette_reg);
|
sw.Do(&m_draw_mode.palette_reg.bits);
|
||||||
sw.Do(&m_draw_mode.texture_window_value);
|
sw.Do(&m_draw_mode.texture_window_value);
|
||||||
sw.Do(&m_draw_mode.texture_page_x);
|
|
||||||
sw.Do(&m_draw_mode.texture_page_y);
|
if (sw.GetVersion() < 62)
|
||||||
sw.Do(&m_draw_mode.texture_palette_x);
|
{
|
||||||
sw.Do(&m_draw_mode.texture_palette_y);
|
// texture_page_x, texture_page_y, texture_palette_x, texture_palette_y
|
||||||
|
DebugAssert(sw.IsReading());
|
||||||
|
sw.SkipBytes(sizeof(u32) * 4);
|
||||||
|
}
|
||||||
|
|
||||||
sw.Do(&m_draw_mode.texture_window.and_x);
|
sw.Do(&m_draw_mode.texture_window.and_x);
|
||||||
sw.Do(&m_draw_mode.texture_window.and_y);
|
sw.Do(&m_draw_mode.texture_window.and_y);
|
||||||
sw.Do(&m_draw_mode.texture_window.or_x);
|
sw.Do(&m_draw_mode.texture_window.or_x);
|
||||||
|
@ -1514,14 +1518,8 @@ void GPU::SetDrawMode(u16 value)
|
||||||
if (new_mode_reg.bits == m_draw_mode.mode_reg.bits)
|
if (new_mode_reg.bits == m_draw_mode.mode_reg.bits)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((new_mode_reg.bits & GPUDrawModeReg::TEXTURE_PAGE_MASK) !=
|
m_draw_mode.texture_page_changed |= ((new_mode_reg.bits & GPUDrawModeReg::TEXTURE_PAGE_MASK) !=
|
||||||
(m_draw_mode.mode_reg.bits & GPUDrawModeReg::TEXTURE_PAGE_MASK))
|
(m_draw_mode.mode_reg.bits & GPUDrawModeReg::TEXTURE_PAGE_MASK));
|
||||||
{
|
|
||||||
m_draw_mode.texture_page_x = new_mode_reg.GetTexturePageBaseX();
|
|
||||||
m_draw_mode.texture_page_y = new_mode_reg.GetTexturePageBaseY();
|
|
||||||
m_draw_mode.texture_page_changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_draw_mode.mode_reg.bits = new_mode_reg.bits;
|
m_draw_mode.mode_reg.bits = new_mode_reg.bits;
|
||||||
|
|
||||||
if (m_GPUSTAT.draw_to_displayed_field != new_mode_reg.draw_to_displayed_field)
|
if (m_GPUSTAT.draw_to_displayed_field != new_mode_reg.draw_to_displayed_field)
|
||||||
|
@ -1536,12 +1534,10 @@ void GPU::SetDrawMode(u16 value)
|
||||||
void GPU::SetTexturePalette(u16 value)
|
void GPU::SetTexturePalette(u16 value)
|
||||||
{
|
{
|
||||||
value &= DrawMode::PALETTE_MASK;
|
value &= DrawMode::PALETTE_MASK;
|
||||||
if (m_draw_mode.palette_reg == value)
|
if (m_draw_mode.palette_reg.bits == value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_draw_mode.texture_palette_x = ZeroExtend32(value & 0x3F) * 16;
|
m_draw_mode.palette_reg.bits = value;
|
||||||
m_draw_mode.texture_palette_y = ZeroExtend32(value >> 6);
|
|
||||||
m_draw_mode.palette_reg = value;
|
|
||||||
m_draw_mode.texture_page_changed = true;
|
m_draw_mode.texture_page_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -422,28 +422,16 @@ protected:
|
||||||
|
|
||||||
// original values
|
// original values
|
||||||
GPUDrawModeReg mode_reg;
|
GPUDrawModeReg mode_reg;
|
||||||
u16 palette_reg; // from vertex
|
GPUTexturePaletteReg palette_reg; // from vertex
|
||||||
u32 texture_window_value;
|
u32 texture_window_value;
|
||||||
|
|
||||||
// decoded values
|
// decoded values
|
||||||
u32 texture_page_x;
|
|
||||||
u32 texture_page_y;
|
|
||||||
u32 texture_palette_x;
|
|
||||||
u32 texture_palette_y;
|
|
||||||
GPUTextureWindow texture_window;
|
GPUTextureWindow texture_window;
|
||||||
bool texture_x_flip;
|
bool texture_x_flip;
|
||||||
bool texture_y_flip;
|
bool texture_y_flip;
|
||||||
bool texture_page_changed;
|
bool texture_page_changed;
|
||||||
bool texture_window_changed;
|
bool texture_window_changed;
|
||||||
|
|
||||||
/// Returns a rectangle comprising the texture palette area.
|
|
||||||
ALWAYS_INLINE_RELEASE Common::Rectangle<u32> GetTexturePaletteRectangle() const
|
|
||||||
{
|
|
||||||
static constexpr std::array<u32, 4> palette_widths = {{16, 256, 0, 0}};
|
|
||||||
return Common::Rectangle<u32>::FromExtents(texture_palette_x, texture_palette_y,
|
|
||||||
palette_widths[static_cast<u8>(mode_reg.texture_mode.GetValue())], 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ALWAYS_INLINE bool IsTexturePageChanged() const { return texture_page_changed; }
|
ALWAYS_INLINE bool IsTexturePageChanged() const { return texture_page_changed; }
|
||||||
ALWAYS_INLINE void SetTexturePageChanged() { texture_page_changed = true; }
|
ALWAYS_INLINE void SetTexturePageChanged() { texture_page_changed = true; }
|
||||||
ALWAYS_INLINE void ClearTexturePageChangedFlag() { texture_page_changed = false; }
|
ALWAYS_INLINE void ClearTexturePageChangedFlag() { texture_page_changed = false; }
|
||||||
|
|
|
@ -1623,7 +1623,7 @@ void GPU_HW::LoadVertices()
|
||||||
m_current_depth++;
|
m_current_depth++;
|
||||||
|
|
||||||
const GPURenderCommand rc{m_render_command.bits};
|
const GPURenderCommand rc{m_render_command.bits};
|
||||||
const u32 texpage = ZeroExtend32(m_draw_mode.mode_reg.bits) | (ZeroExtend32(m_draw_mode.palette_reg) << 16);
|
const u32 texpage = ZeroExtend32(m_draw_mode.mode_reg.bits) | (ZeroExtend32(m_draw_mode.palette_reg.bits) << 16);
|
||||||
const float depth = GetCurrentNormalizedVertexDepth();
|
const float depth = GetCurrentNormalizedVertexDepth();
|
||||||
|
|
||||||
switch (rc.primitive)
|
switch (rc.primitive)
|
||||||
|
@ -2067,7 +2067,8 @@ void GPU_HW::IncludeVRAMDirtyRectangle(Common::Rectangle<u32>& rect, const Commo
|
||||||
// shadow texture is updated
|
// shadow texture is updated
|
||||||
if (!m_draw_mode.IsTexturePageChanged() &&
|
if (!m_draw_mode.IsTexturePageChanged() &&
|
||||||
(m_draw_mode.mode_reg.GetTexturePageRectangle().Intersects(new_rect) ||
|
(m_draw_mode.mode_reg.GetTexturePageRectangle().Intersects(new_rect) ||
|
||||||
(m_draw_mode.mode_reg.IsUsingPalette() && m_draw_mode.GetTexturePaletteRectangle().Intersects(new_rect))))
|
(m_draw_mode.mode_reg.IsUsingPalette() &&
|
||||||
|
m_draw_mode.palette_reg.GetRectangle(m_draw_mode.mode_reg.texture_mode).Intersects(new_rect))))
|
||||||
{
|
{
|
||||||
m_draw_mode.SetTexturePageChanged();
|
m_draw_mode.SetTexturePageChanged();
|
||||||
}
|
}
|
||||||
|
@ -2300,7 +2301,7 @@ void GPU_HW::FillDrawCommand(GPUBackendDrawCommand* cmd, GPURenderCommand rc) co
|
||||||
FillBackendCommandParameters(cmd);
|
FillBackendCommandParameters(cmd);
|
||||||
cmd->rc.bits = rc.bits;
|
cmd->rc.bits = rc.bits;
|
||||||
cmd->draw_mode.bits = m_draw_mode.mode_reg.bits;
|
cmd->draw_mode.bits = m_draw_mode.mode_reg.bits;
|
||||||
cmd->palette.bits = m_draw_mode.palette_reg;
|
cmd->palette.bits = m_draw_mode.palette_reg.bits;
|
||||||
cmd->window = m_draw_mode.texture_window;
|
cmd->window = m_draw_mode.texture_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2604,7 +2605,8 @@ void GPU_HW::DispatchRenderCommand()
|
||||||
|
|
||||||
if (m_draw_mode.mode_reg.IsUsingPalette())
|
if (m_draw_mode.mode_reg.IsUsingPalette())
|
||||||
{
|
{
|
||||||
const Common::Rectangle<u32> palette_rect = m_draw_mode.GetTexturePaletteRectangle();
|
const Common::Rectangle<u32> palette_rect =
|
||||||
|
m_draw_mode.palette_reg.GetRectangle(m_draw_mode.mode_reg.texture_mode);
|
||||||
const bool update_drawn = palette_rect.Intersects(m_vram_dirty_draw_rect);
|
const bool update_drawn = palette_rect.Intersects(m_vram_dirty_draw_rect);
|
||||||
const bool update_written = palette_rect.Intersects(m_vram_dirty_write_rect);
|
const bool update_written = palette_rect.Intersects(m_vram_dirty_write_rect);
|
||||||
if (update_drawn || update_written)
|
if (update_drawn || update_written)
|
||||||
|
|
|
@ -554,7 +554,7 @@ void GPU_SW::FillDrawCommand(GPUBackendDrawCommand* cmd, GPURenderCommand rc) co
|
||||||
FillBackendCommandParameters(cmd);
|
FillBackendCommandParameters(cmd);
|
||||||
cmd->rc.bits = rc.bits;
|
cmd->rc.bits = rc.bits;
|
||||||
cmd->draw_mode.bits = m_draw_mode.mode_reg.bits;
|
cmd->draw_mode.bits = m_draw_mode.mode_reg.bits;
|
||||||
cmd->palette.bits = m_draw_mode.palette_reg;
|
cmd->palette.bits = m_draw_mode.palette_reg.bits;
|
||||||
cmd->window = m_draw_mode.texture_window;
|
cmd->window = m_draw_mode.texture_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,13 @@ union GPUTexturePaletteReg
|
||||||
|
|
||||||
ALWAYS_INLINE u32 GetXBase() const { return static_cast<u32>(x) * 16u; }
|
ALWAYS_INLINE u32 GetXBase() const { return static_cast<u32>(x) * 16u; }
|
||||||
ALWAYS_INLINE u32 GetYBase() const { return static_cast<u32>(y); }
|
ALWAYS_INLINE u32 GetYBase() const { return static_cast<u32>(y); }
|
||||||
|
|
||||||
|
/// Returns a rectangle comprising the texture palette area.
|
||||||
|
ALWAYS_INLINE_RELEASE Common::Rectangle<u32> GetRectangle(GPUTextureMode mode) const
|
||||||
|
{
|
||||||
|
static constexpr std::array<u32, 4> palette_widths = {{16, 256, 0, 0}};
|
||||||
|
return Common::Rectangle<u32>::FromExtents(GetXBase(), GetYBase(), palette_widths[static_cast<u8>(mode)], 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GPUTextureWindow
|
struct GPUTextureWindow
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
static constexpr u32 SAVE_STATE_MAGIC = 0x43435544;
|
static constexpr u32 SAVE_STATE_MAGIC = 0x43435544;
|
||||||
static constexpr u32 SAVE_STATE_VERSION = 61;
|
static constexpr u32 SAVE_STATE_VERSION = 62;
|
||||||
static constexpr u32 SAVE_STATE_MINIMUM_VERSION = 42;
|
static constexpr u32 SAVE_STATE_MINIMUM_VERSION = 42;
|
||||||
|
|
||||||
static_assert(SAVE_STATE_VERSION >= SAVE_STATE_MINIMUM_VERSION);
|
static_assert(SAVE_STATE_VERSION >= SAVE_STATE_MINIMUM_VERSION);
|
||||||
|
|
Loading…
Reference in a new issue