Skip to content

Commit 401a0ba

Browse files
committed
GPUTexture: Don't assemble vector in GetSizeVec()
Use a load/extend instead. Turns into movd+pmovzxwd.
1 parent c5fdea1 commit 401a0ba

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/util/gpu_device.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ size_t GPUFramebufferManagerBase::KeyHash::operator()(const Key& key) const
236236

237237
GPUSwapChain::GPUSwapChain(const WindowInfo& wi, GPUVSyncMode vsync_mode) : m_window_info(wi), m_vsync_mode(vsync_mode)
238238
{
239+
// Needed for the GetSizeVec() function to work.
240+
static_assert(OFFSETOF(GPUSwapChain, m_window_info.surface_height) ==
241+
OFFSETOF(GPUSwapChain, m_window_info.surface_width) + sizeof(u16));
239242
}
240243

241244
GPUSwapChain::~GPUSwapChain() = default;

src/util/gpu_device.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,7 @@ class GPUSwapChain
471471
ALWAYS_INLINE void SetRefreshRate(float refresh_rate) { m_window_info.surface_refresh_rate = refresh_rate; }
472472
ALWAYS_INLINE WindowInfoPrerotation GetPreRotation() const { return m_window_info.surface_prerotation; }
473473
ALWAYS_INLINE GPUTextureFormat GetFormat() const { return m_window_info.surface_format; }
474-
ALWAYS_INLINE GSVector2i GetSizeVec() const
475-
{
476-
return GSVector2i(m_window_info.surface_width, m_window_info.surface_height);
477-
}
474+
ALWAYS_INLINE GSVector2i GetSizeVec() const { return GSVector2i::load32(&m_window_info.surface_width).u16to32(); }
478475
ALWAYS_INLINE GSVector2i GetPostRotatedSizeVec() const
479476
{
480477
return GSVector2i(m_window_info.GetPostRotatedWidth(), m_window_info.GetPostRotatedHeight());

src/util/gpu_texture.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ GPUTexture::GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples,
1616
: m_width(width), m_height(height), m_layers(layers), m_levels(levels), m_samples(samples), m_type(type),
1717
m_format(format), m_flags(flags)
1818
{
19+
// Needed for the GPUTexture::GetSizeVec() and GPUTexture::GetRect() functions to work correctly.
20+
static_assert(OFFSETOF(GPUTexture, m_height) == OFFSETOF(GPUTexture, m_width) + sizeof(u16));
1921
GPUDevice::s_total_vram_usage += GetVRAMUsage();
2022
}
2123

src/util/gpu_texture.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ class GPUTexture
9292
ALWAYS_INLINE GPUTextureFormat GetFormat() const { return m_format; }
9393
ALWAYS_INLINE Flags GetFlags() const { return m_flags; }
9494
ALWAYS_INLINE bool HasFlag(Flags flag) const { return ((static_cast<u8>(m_flags) & static_cast<u8>(flag)) != 0); }
95-
ALWAYS_INLINE GSVector2i GetSizeVec() const { return GSVector2i(m_width, m_height); }
96-
ALWAYS_INLINE GSVector4i GetRect() const
97-
{
98-
return GSVector4i(0, 0, static_cast<s32>(m_width), static_cast<s32>(m_height));
99-
}
95+
ALWAYS_INLINE GSVector2i GetSizeVec() const { return GSVector2i::load32(&m_width).u16to32(); }
96+
ALWAYS_INLINE GSVector4i GetRect() const { return GSVector4i::loadh(GetSizeVec()); }
10097

10198
ALWAYS_INLINE bool IsTextureArray() const { return m_layers > 1; }
10299
ALWAYS_INLINE bool IsMultisampled() const { return m_samples > 1; }

0 commit comments

Comments
 (0)