metal: improve canvas creation performance.

Prefer initializing textures by using a render target clear rather than a blank data upload, when possible.
This commit is contained in:
Sasha Szpakowski
2026-07-01 14:03:20 -03:00
parent fc98c7d2e1
commit fc0cb61c6c
+9 -9
View File
@@ -147,15 +147,6 @@ Texture::Texture(love::graphics::Graphics *gfxbase, id<MTLDevice> device, const
shouldgeneratemips = true;
continue;
}
else if (getMSAA() <= 1 && !isPixelFormatDepthStencil(format) && !isPixelFormatCompressed(format))
{
// Initialize to transparent black.
if (emptydata.empty())
emptydata.resize(getPixelFormatSliceSize(format, w, h));
Rect r = {0, 0, getPixelWidth(mip), getPixelHeight(mip)};
uploadByteData(emptydata.data(), emptydata.size(), mip, slice, r);
}
else if (isRenderTarget())
{
// Clear to transparent black.
@@ -201,6 +192,15 @@ Texture::Texture(love::graphics::Graphics *gfxbase, id<MTLDevice> device, const
id<MTLRenderCommandEncoder> encoder = [cmd renderCommandEncoderWithDescriptor:passdesc];
[encoder endEncoding];
}
else if (getMSAA() <= 1 && !isPixelFormatDepthStencil(format) && !isPixelFormatCompressed(format))
{
// Initialize to transparent black.
if (emptydata.empty())
emptydata.resize(getPixelFormatSliceSize(format, w, h));
Rect r = {0, 0, getPixelWidth(mip), getPixelHeight(mip)};
uploadByteData(emptydata.data(), emptydata.size(), mip, slice, r);
}
else
{
// Shouldn't be possible to get here.