mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
metal: fix automatic depth/stencil with setCanvas.
This commit is contained in:
@@ -201,7 +201,7 @@ private:
|
||||
love::graphics::ShaderStage *newShaderStageInternal(ShaderStageType stage, const std::string &cachekey, const std::string &source, bool gles) override;
|
||||
love::graphics::Shader *newShaderInternal(StrongRef<love::graphics::ShaderStage> stages[SHADERSTAGE_MAX_ENUM]) override;
|
||||
love::graphics::StreamBuffer *newStreamBuffer(BufferUsage usage, size_t size) override;
|
||||
void setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBcanvas) override;
|
||||
void setRenderTargetsInternal(const RenderTargets &rts, int pixelw, int pixelh, bool hasSRGBcanvas) override;
|
||||
void initCapabilities() override;
|
||||
void getAPIStats(int &shaderswitches) const override;
|
||||
|
||||
@@ -226,6 +226,7 @@ private:
|
||||
uint32 dirtyRenderState;
|
||||
CullMode lastCullMode;
|
||||
VertexAttributes lastVertexAttributes;
|
||||
PixelFormat activeDepthStencilFormat;
|
||||
bool windowHasStencil;
|
||||
int shaderSwitches;
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@ Graphics::Graphics()
|
||||
, passDesc(nil)
|
||||
, dirtyRenderState(STATEBIT_ALL)
|
||||
, lastCullMode(CULL_MAX_ENUM)
|
||||
, activeDepthStencilFormat(PIXELFORMAT_UNKNOWN)
|
||||
, windowHasStencil(false)
|
||||
, shaderSwitches(0)
|
||||
, requestedBackbufferMSAA(0)
|
||||
@@ -920,9 +921,9 @@ void Graphics::applyRenderState(id<MTLRenderCommandEncoder> encoder, const Verte
|
||||
for (size_t i = 0; i < rts.size(); i++)
|
||||
key.colorRenderTargetFormats |= (rts[i].texture->getPixelFormat()) << (8 * i);
|
||||
|
||||
// TODO: automatic depth/stencil (state doesn't store it).
|
||||
if (state.renderTargets.depthStencil.texture.get())
|
||||
key.depthStencilFormat = state.renderTargets.depthStencil.texture->getPixelFormat();
|
||||
// Don't query the current RTs because they don't include
|
||||
// automatic depth/stencil.
|
||||
key.depthStencilFormat = activeDepthStencilFormat;
|
||||
|
||||
key.msaa = (uint8) firsttarget.texture->getMSAA();
|
||||
}
|
||||
@@ -1321,7 +1322,7 @@ bool Graphics::dispatch(int x, int y, int z)
|
||||
return true;
|
||||
}}
|
||||
|
||||
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int /*w*/, int /*h*/, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
|
||||
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
|
||||
{ @autoreleasepool {
|
||||
endPass();
|
||||
|
||||
@@ -1346,18 +1347,21 @@ void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int /*w*/, int
|
||||
if (isbackbuffer && ds == nullptr)
|
||||
ds = backbufferDepthStencil;
|
||||
|
||||
PixelFormat dsformat = PIXELFORMAT_UNKNOWN;
|
||||
if (ds != nullptr)
|
||||
{
|
||||
RenderTarget rt = rts.depthStencil;
|
||||
rt.texture = ds;
|
||||
dsformat = ds->getPixelFormat();
|
||||
|
||||
if (isPixelFormatDepth(ds->getPixelFormat()))
|
||||
if (isPixelFormatDepth(dsformat))
|
||||
setAttachment(rt, passDesc.depthAttachment, attachmentStoreActions.depth);
|
||||
|
||||
if (isPixelFormatStencil(ds->getPixelFormat()))
|
||||
if (isPixelFormatStencil(dsformat))
|
||||
setAttachment(rt, passDesc.stencilAttachment, attachmentStoreActions.stencil);
|
||||
}
|
||||
|
||||
activeDepthStencilFormat = dsformat;
|
||||
dirtyRenderState = STATEBIT_ALL;
|
||||
lastVertexAttributes = VertexAttributes();
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user