mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
LibGL+LibSoftGPU: Implement GL_POLYGON_OFFSET_FILL
capability
This commit is contained in:
parent
991cbc56a2
commit
453f62c935
4 changed files with 17 additions and 2 deletions
|
@ -168,6 +168,8 @@ Optional<ContextParameter> SoftwareGLContext::get_context_parameter(GLenum name)
|
||||||
return ContextParameter { .type = GL_INT, .value = { .integer_value = 0 } };
|
return ContextParameter { .type = GL_INT, .value = { .integer_value = 0 } };
|
||||||
case GL_PACK_SWAP_BYTES:
|
case GL_PACK_SWAP_BYTES:
|
||||||
return ContextParameter { .type = GL_BOOL, .value = { .boolean_value = false } };
|
return ContextParameter { .type = GL_BOOL, .value = { .boolean_value = false } };
|
||||||
|
case GL_POLYGON_OFFSET_FILL:
|
||||||
|
return ContextParameter { .type = GL_BOOL, .is_capability = true, .value = { .boolean_value = m_depth_offset_enabled } };
|
||||||
case GL_RED_BITS:
|
case GL_RED_BITS:
|
||||||
return ContextParameter { .type = GL_INT, .value = { .integer_value = sizeof(float) * 8 } };
|
return ContextParameter { .type = GL_INT, .value = { .integer_value = sizeof(float) * 8 } };
|
||||||
case GL_SCISSOR_BOX: {
|
case GL_SCISSOR_BOX: {
|
||||||
|
@ -723,6 +725,11 @@ void SoftwareGLContext::gl_enable(GLenum capability)
|
||||||
rasterizer_options.normalization_enabled = true;
|
rasterizer_options.normalization_enabled = true;
|
||||||
update_rasterizer_options = true;
|
update_rasterizer_options = true;
|
||||||
break;
|
break;
|
||||||
|
case GL_POLYGON_OFFSET_FILL:
|
||||||
|
m_depth_offset_enabled = true;
|
||||||
|
rasterizer_options.depth_offset_enabled = true;
|
||||||
|
update_rasterizer_options = true;
|
||||||
|
break;
|
||||||
case GL_SCISSOR_TEST:
|
case GL_SCISSOR_TEST:
|
||||||
rasterizer_options.scissor_enabled = true;
|
rasterizer_options.scissor_enabled = true;
|
||||||
update_rasterizer_options = true;
|
update_rasterizer_options = true;
|
||||||
|
@ -836,6 +843,11 @@ void SoftwareGLContext::gl_disable(GLenum capability)
|
||||||
rasterizer_options.normalization_enabled = false;
|
rasterizer_options.normalization_enabled = false;
|
||||||
update_rasterizer_options = true;
|
update_rasterizer_options = true;
|
||||||
break;
|
break;
|
||||||
|
case GL_POLYGON_OFFSET_FILL:
|
||||||
|
m_depth_offset_enabled = false;
|
||||||
|
rasterizer_options.depth_offset_enabled = false;
|
||||||
|
update_rasterizer_options = true;
|
||||||
|
break;
|
||||||
case GL_SCISSOR_TEST:
|
case GL_SCISSOR_TEST:
|
||||||
rasterizer_options.scissor_enabled = false;
|
rasterizer_options.scissor_enabled = false;
|
||||||
update_rasterizer_options = true;
|
update_rasterizer_options = true;
|
||||||
|
|
|
@ -212,7 +212,8 @@ private:
|
||||||
GLenum m_error = GL_NO_ERROR;
|
GLenum m_error = GL_NO_ERROR;
|
||||||
bool m_in_draw_state = false;
|
bool m_in_draw_state = false;
|
||||||
|
|
||||||
bool m_depth_test_enabled = false;
|
bool m_depth_test_enabled { false };
|
||||||
|
bool m_depth_offset_enabled { false };
|
||||||
|
|
||||||
bool m_cull_faces = false;
|
bool m_cull_faces = false;
|
||||||
GLenum m_front_face = GL_CCW;
|
GLenum m_front_face = GL_CCW;
|
||||||
|
|
|
@ -413,7 +413,8 @@ void Device::rasterize_triangle(const Triangle& triangle)
|
||||||
|
|
||||||
quad.depth = interpolate(vertex0.window_coordinates.z(), vertex1.window_coordinates.z(), vertex2.window_coordinates.z(), quad.barycentrics);
|
quad.depth = interpolate(vertex0.window_coordinates.z(), vertex1.window_coordinates.z(), vertex2.window_coordinates.z(), quad.barycentrics);
|
||||||
// FIXME: Also apply depth_offset_factor which depends on the depth gradient
|
// FIXME: Also apply depth_offset_factor which depends on the depth gradient
|
||||||
quad.depth += m_options.depth_offset_constant * NumericLimits<float>::epsilon();
|
if (m_options.depth_offset_enabled)
|
||||||
|
quad.depth += m_options.depth_offset_constant * NumericLimits<float>::epsilon();
|
||||||
|
|
||||||
i32x4 depth_test_passed;
|
i32x4 depth_test_passed;
|
||||||
switch (m_options.depth_func) {
|
switch (m_options.depth_func) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ struct RasterizerOptions {
|
||||||
bool enable_color_write { true };
|
bool enable_color_write { true };
|
||||||
float depth_offset_factor { 0 };
|
float depth_offset_factor { 0 };
|
||||||
float depth_offset_constant { 0 };
|
float depth_offset_constant { 0 };
|
||||||
|
bool depth_offset_enabled { false };
|
||||||
bool enable_culling { false };
|
bool enable_culling { false };
|
||||||
WindingOrder front_face { WindingOrder::CounterClockwise };
|
WindingOrder front_face { WindingOrder::CounterClockwise };
|
||||||
bool cull_back { true };
|
bool cull_back { true };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue