diff --git a/pcsx2/GS/Renderers/Metal/GSTextureMTL.h b/pcsx2/GS/Renderers/Metal/GSTextureMTL.h index b79826fded..9574e938bb 100644 --- a/pcsx2/GS/Renderers/Metal/GSTextureMTL.h +++ b/pcsx2/GS/Renderers/Metal/GSTextureMTL.h @@ -93,9 +93,6 @@ public: void Flush() override; private: - // TODO: Is there an optimal transfer pitch alignment for Metal? - static constexpr u32 PITCH_ALIGNMENT = 32; - GSDownloadTextureMTL(GSDeviceMTL* dev, MRCOwned> buffer, u32 width, u32 height, GSTexture::Format format); GSDeviceMTL* m_dev; diff --git a/pcsx2/GS/Renderers/Metal/GSTextureMTL.mm b/pcsx2/GS/Renderers/Metal/GSTextureMTL.mm index 7c84dc0943..66882ceb09 100644 --- a/pcsx2/GS/Renderers/Metal/GSTextureMTL.mm +++ b/pcsx2/GS/Renderers/Metal/GSTextureMTL.mm @@ -17,10 +17,14 @@ #include "GS/Renderers/Metal/GSTextureMTL.h" #include "GS/Renderers/Metal/GSDeviceMTL.h" #include "GS/GSPerfMon.h" +#include "common/Align.h" #include "common/Console.h" #ifdef __APPLE__ +// Uploads/downloads need 32-byte alignment for AVX2. +static constexpr u32 PITCH_ALIGNMENT = 32; + GSTextureMTL::GSTextureMTL(GSDeviceMTL* dev, MRCOwned> texture, Type type, Format format) : m_dev(dev) , m_texture(std::move(texture)) @@ -119,7 +123,7 @@ bool GSTextureMTL::Map(GSMap& m, const GSVector4i* _r, int layer) GSVector4i r = _r ? *_r : GSVector4i(0, 0, m_size.x, m_size.y); u32 block_size = GetCompressedBlockSize(); u32 blocks_wide = (r.width() + block_size - 1) / block_size; - m.pitch = blocks_wide * GetCompressedBytesPerBlock(); + m.pitch = Common::AlignUpPow2(blocks_wide * GetCompressedBytesPerBlock(), PITCH_ALIGNMENT); if (void* buffer = MapWithPitch(r, m.pitch, layer)) { m.bits = static_cast(buffer);