mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
metal: more work on MSAA textures
This commit is contained in:
@@ -45,7 +45,7 @@ public:
|
||||
void setSamplerState(const SamplerState &s) override;
|
||||
|
||||
ptrdiff_t getHandle() const override { return (ptrdiff_t) texture; }
|
||||
ptrdiff_t getRenderTargetHandle() const override { return (ptrdiff_t) texture; /* TODO */ }
|
||||
ptrdiff_t getRenderTargetHandle() const override { return msaaTexture != nil ? (ptrdiff_t) msaaTexture : (ptrdiff_t) texture; }
|
||||
int getMSAA() const override { return 1 /* TODO*/; }
|
||||
|
||||
private:
|
||||
@@ -53,6 +53,7 @@ private:
|
||||
void uploadByteData(PixelFormat pixelformat, const void *data, size_t size, int level, int slice, const Rect &r, love::image::ImageDataBase *imgd = nullptr) override;
|
||||
|
||||
id<MTLTexture> texture;
|
||||
id<MTLTexture> msaaTexture;
|
||||
id<MTLSamplerState> sampler;
|
||||
|
||||
}; // Texture
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace metal
|
||||
Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *data)
|
||||
: love::graphics::Texture(settings, data)
|
||||
, texture(nil)
|
||||
, msaaTexture(nil)
|
||||
, sampler(nil)
|
||||
{ @autoreleasepool {
|
||||
MTLTextureDescriptor *desc = [MTLTextureDescriptor new];
|
||||
@@ -38,15 +39,12 @@ Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *d
|
||||
int w = pixelWidth;
|
||||
int h = pixelHeight;
|
||||
|
||||
// TODO: sampleCount validation
|
||||
desc.sampleCount = getRequestedMSAA();
|
||||
|
||||
desc.width = w;
|
||||
desc.height = h;
|
||||
desc.depth = depth;
|
||||
desc.arrayLength = layers;
|
||||
desc.mipmapLevelCount = mipmapCount;
|
||||
desc.textureType = Metal::getTextureType(texType, (int)desc.sampleCount);
|
||||
desc.textureType = Metal::getTextureType(texType, 1);
|
||||
desc.pixelFormat = Metal::convertPixelFormat(format, sRGB);
|
||||
desc.storageMode = MTLStorageModePrivate;
|
||||
|
||||
@@ -60,6 +58,22 @@ Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *d
|
||||
if (texture == nil)
|
||||
throw love::Exception("Out of graphics memory.");
|
||||
|
||||
if (getRequestedMSAA() > 1)
|
||||
{
|
||||
// TODO: sampleCount validation
|
||||
desc.sampleCount = getRequestedMSAA();
|
||||
desc.textureType = Metal::getTextureType(texType, (int)desc.sampleCount);
|
||||
desc.usage &= ~MTLTextureUsageShaderRead;
|
||||
|
||||
// TODO: This needs to be cleared, etc.
|
||||
msaaTexture = [device newTextureWithDescriptor:desc];
|
||||
if (msaaTexture == nil)
|
||||
{
|
||||
texture = nil;
|
||||
throw love::Exception("Out of graphics memory.");
|
||||
}
|
||||
}
|
||||
|
||||
int mipcount = getMipmapCount();
|
||||
|
||||
int slicecount = 1;
|
||||
@@ -105,6 +119,7 @@ Texture::Texture(id<MTLDevice> device, const Settings &settings, const Slices *d
|
||||
Texture::~Texture()
|
||||
{ @autoreleasepool {
|
||||
texture = nil;
|
||||
msaaTexture = nil;
|
||||
sampler = nil;
|
||||
}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user