mirror of
https://github.com/love2d/love.git
synced 2026-08-12 00:20:52 +02:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user