1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

LibGL+LibSoftGPU: Implement the stencil buffer

This implements an 8-bit front stencil buffer. Stencil operations are
SIMD optimized. LibGL changes include:

* New `glStencilMask` and `glStencilMaskSeparate` functions
* New context parameter `GL_STENCIL_CLEAR_VALUE`
This commit is contained in:
Jelle Raaijmakers 2022-01-16 22:48:46 +01:00 committed by Andreas Kling
parent 6386671944
commit 11c807ebd1
13 changed files with 430 additions and 77 deletions

View file

@ -128,6 +128,7 @@ public:
virtual void gl_pixel_storei(GLenum pname, GLint param) override;
virtual void gl_scissor(GLint x, GLint y, GLsizei width, GLsizei height) override;
virtual void gl_stencil_func_separate(GLenum face, GLenum func, GLint ref, GLuint mask) override;
virtual void gl_stencil_mask_separate(GLenum face, GLuint mask) override;
virtual void gl_stencil_op_separate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) override;
virtual void gl_normal(GLfloat nx, GLfloat ny, GLfloat nz) override;
virtual void gl_normal_pointer(GLenum type, GLsizei stride, void const* pointer) override;
@ -154,6 +155,7 @@ private:
void sync_device_sampler_config();
void sync_device_texcoord_config();
void sync_light_state();
void sync_stencil_configuration();
template<typename T>
T* store_in_listing(T value)
@ -195,7 +197,7 @@ private:
FloatVector4 m_clear_color { 0.0f, 0.0f, 0.0f, 0.0f };
double m_clear_depth { 1.0 };
GLint m_clear_stencil { 0 };
u8 m_clear_stencil { 0 };
FloatVector4 m_current_vertex_color = { 1.0f, 1.0f, 1.0f, 1.0f };
FloatVector4 m_current_vertex_tex_coord = { 0.0f, 0.0f, 0.0f, 1.0f };
@ -225,6 +227,7 @@ private:
// Stencil configuration
bool m_stencil_test_enabled { false };
bool m_stencil_configuration_dirty { true };
struct StencilFunctionOptions {
GLenum func { GL_ALWAYS };
@ -237,6 +240,7 @@ private:
GLenum op_fail { GL_KEEP };
GLenum op_depth_fail { GL_KEEP };
GLenum op_pass { GL_KEEP };
GLuint write_mask { NumericLimits<GLuint>::max() };
};
Array<StencilOperationOptions, 2u> m_stencil_operation;
@ -360,6 +364,7 @@ private:
decltype(&SoftwareGLContext::gl_polygon_offset),
decltype(&SoftwareGLContext::gl_scissor),
decltype(&SoftwareGLContext::gl_stencil_func_separate),
decltype(&SoftwareGLContext::gl_stencil_mask_separate),
decltype(&SoftwareGLContext::gl_stencil_op_separate),
decltype(&SoftwareGLContext::gl_normal),
decltype(&SoftwareGLContext::gl_raster_pos),