mirror of https://github.com/PCSX2/pcsx2.git
GS/Metal: Align texture upload pitch to 32 bytes
This commit is contained in:
parent
98c611e404
commit
b219ee9049
|
@ -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<id<MTLBuffer>> buffer, u32 width, u32 height, GSTexture::Format format);
|
||||
|
||||
GSDeviceMTL* m_dev;
|
||||
|
|
|
@ -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<id<MTLTexture>> 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<u8*>(buffer);
|
||||
|
|
Loading…
Reference in New Issue