mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
metal: implement depth/stencil state
This commit is contained in:
@@ -1119,7 +1119,8 @@ void Graphics::setScissor()
|
||||
|
||||
void Graphics::drawToStencilBuffer(StencilAction action, int value)
|
||||
{
|
||||
const auto &rts = states.back().renderTargets;
|
||||
DisplayState &state = states.back();
|
||||
const auto &rts = state.renderTargets;
|
||||
love::graphics::Texture *dstexture = rts.depthStencil.texture.get();
|
||||
|
||||
if (!isRenderTargetActive() && !windowHasStencil)
|
||||
@@ -1129,7 +1130,8 @@ void Graphics::drawToStencilBuffer(StencilAction action, int value)
|
||||
|
||||
flushBatchedDraws();
|
||||
|
||||
writingToStencil = true;
|
||||
state.stencil.action = action;
|
||||
state.stencil.value = value;
|
||||
|
||||
// Disable color writes but don't save the state for it.
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
@@ -1169,33 +1171,33 @@ void Graphics::drawToStencilBuffer(StencilAction action, int value)
|
||||
|
||||
void Graphics::stopDrawToStencilBuffer()
|
||||
{
|
||||
if (!writingToStencil)
|
||||
DisplayState &state = states.back();
|
||||
|
||||
if (state.stencil.action == STENCIL_KEEP)
|
||||
return;
|
||||
|
||||
flushBatchedDraws();
|
||||
|
||||
writingToStencil = false;
|
||||
|
||||
const DisplayState &state = states.back();
|
||||
state.stencil.action = STENCIL_KEEP;
|
||||
|
||||
// Revert the color write mask.
|
||||
setColorMask(state.colorMask);
|
||||
|
||||
// Use the user-set stencil test state when writes are disabled.
|
||||
setStencilTest(state.stencilCompare, state.stencilTestValue);
|
||||
setStencilTest(state.stencil.compare, state.stencil.value);
|
||||
}
|
||||
|
||||
void Graphics::setStencilTest(CompareMode compare, int value)
|
||||
{
|
||||
DisplayState &state = states.back();
|
||||
|
||||
if (state.stencilCompare != compare || state.stencilTestValue != value)
|
||||
if (state.stencil.compare != compare || state.stencil.value != value)
|
||||
flushBatchedDraws();
|
||||
|
||||
state.stencilCompare = compare;
|
||||
state.stencilTestValue = value;
|
||||
state.stencil.compare = compare;
|
||||
state.stencil.value = value;
|
||||
|
||||
if (writingToStencil)
|
||||
if (state.stencil.action != STENCIL_KEEP)
|
||||
return;
|
||||
|
||||
if (compare == COMPARE_ALWAYS)
|
||||
|
||||
@@ -42,7 +42,6 @@ Shader::Shader(love::graphics::ShaderStage *vertex, love::graphics::ShaderStage
|
||||
, program(0)
|
||||
, builtinUniforms()
|
||||
, builtinUniformInfo()
|
||||
, builtinAttributes()
|
||||
, lastPointSize(0.0f)
|
||||
{
|
||||
// load shader source and create program object
|
||||
@@ -343,15 +342,6 @@ bool Shader::loadVolatile()
|
||||
// Get all active uniform variables in this shader from OpenGL.
|
||||
mapActiveUniforms();
|
||||
|
||||
for (int i = 0; i < int(ATTRIB_MAX_ENUM); i++)
|
||||
{
|
||||
const char *name = nullptr;
|
||||
if (vertex::getConstant(BuiltinVertexAttribute(i), name))
|
||||
builtinAttributes[i] = glGetAttribLocation(program, name);
|
||||
else
|
||||
builtinAttributes[i] = -1;
|
||||
}
|
||||
|
||||
if (current == this)
|
||||
{
|
||||
// make sure glUseProgram gets called.
|
||||
|
||||
@@ -102,9 +102,6 @@ private:
|
||||
GLint builtinUniforms[BUILTIN_MAX_ENUM];
|
||||
UniformInfo *builtinUniformInfo[BUILTIN_MAX_ENUM];
|
||||
|
||||
// Location values for any generic vertex attribute variables.
|
||||
GLint builtinAttributes[ATTRIB_MAX_ENUM];
|
||||
|
||||
std::map<std::string, GLint> attributes;
|
||||
|
||||
// Uniform location buffer map
|
||||
|
||||
Reference in New Issue
Block a user