Add state caching for stencil test.

This commit is contained in:
Henrik Rydgard committed 2013-01-12 17:19:01 +01:00
1 parent 9df584067e
commit de36ea9f34
2 files changed
+30 -1

No files matched your search

+4 -1
View File
@@ -35,6 +35,10 @@ void OpenGLState::Restore() {
colorMask.restore(); count++;
viewport.restore(); count++;
stencilTest.restore(); count++;
stencilOp.restore(); count++;
stencilFunc.restore(); count++;
assert(count == state_count && "OpenGLState::Restore is missing some states");
}
@@ -53,4 +57,3 @@ void CheckGLExtensions() {
gl_extensions.OES_depth_texture = strstr(extString, "GL_OES_depth_texture") != 0;
gl_extensions.EXT_discard_framebuffer = strstr(extString, "GL_EXT_discard_framebuffer") != 0;
}
+26
View File
@@ -86,6 +86,28 @@ private:
} \
}
#define STATE3(func, p1type, p2type, p3type, p1def, p2def, p3def) \
class SavedState3_##func { \
p1type p1; \
p2type p2; \
p3type p3; \
public: \
SavedState3_##func() : p1(p1def), p2(p2def), p3(p3def) { \
OpenGLState::state_count++; \
}; \
inline void set(p1type newp1, p2type newp2, p3type newp3) { \
if(newp1 != p1 || newp2 != p2 || newp3 != p3) { \
p1 = newp1; \
p2 = newp2; \
p3 = newp3; \
func(p1, p2, p3); \
} \
} \
inline void restore() { \
func(p1, p2, p3); \
} \
}
#define STATE4(func, p1type, p2type, p3type, p4type, p1def, p2def, p3def, p4def) \
class SavedState4_##func { \
p1type p1; \
@@ -161,6 +183,10 @@ public:
STATE4(glColorMask, bool, bool, bool, bool, true, true, true, true) colorMask;
STATE4(glViewport, GLint, GLint, GLsizei, GLsizei, 0, 0, 128, 128) viewport;
BoolState<GL_STENCIL_TEST, false> stencilTest;
STATE3(glStencilOp, GLenum, GLenum, GLenum, GL_KEEP, GL_KEEP, GL_KEEP) stencilOp;
STATE3(glStencilFunc, GLenum, GLint, GLuint, GL_ALWAYS, 0, 0xFF) stencilFunc;
};
#undef STATE1