Nothing enables the extension yet, but the values are now available.
The spec calls for it to only be exposed for GL 3.3+, which is core-only
in mesa. Instead we allow any driver to enable it, including in a compat
context for any GL version.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
}
static void
-nouveau_polygon_offset(struct gl_context *ctx, GLfloat factor, GLfloat units)
+nouveau_polygon_offset(struct gl_context *ctx, GLfloat factor, GLfloat units, GLfloat clamp)
{
context_dirty(ctx, POLYGON_OFFSET);
}
*/
static void r200PolygonOffset( struct gl_context *ctx,
- GLfloat factor, GLfloat units )
+ GLfloat factor, GLfloat units, GLfloat clamp )
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
*/
static void radeonPolygonOffset( struct gl_context *ctx,
- GLfloat factor, GLfloat units )
+ GLfloat factor, GLfloat units, GLfloat clamp )
{
r100ContextPtr rmesa = R100_CONTEXT(ctx);
const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
_mesa_FrontFace(polygon->FrontFace);
_mesa_PolygonMode(GL_FRONT, polygon->FrontMode);
_mesa_PolygonMode(GL_BACK, polygon->BackMode);
- _mesa_PolygonOffset(polygon->OffsetFactor,
- polygon->OffsetUnits);
+ _mesa_polygon_offset_clamp(ctx,
+ polygon->OffsetFactor,
+ polygon->OffsetUnits,
+ polygon->OffsetClamp);
_mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag);
_mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag);
_mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag);
/** Select a polygon rasterization mode */
void (*PolygonMode)(struct gl_context *ctx, GLenum face, GLenum mode);
/** Set the scale and units used to calculate depth values */
- void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units);
+ void (*PolygonOffset)(struct gl_context *ctx, GLfloat factor, GLfloat units, GLfloat clamp);
/** Set the polygon stippling pattern */
void (*PolygonStipple)(struct gl_context *ctx, const GLubyte *mask );
/* Specifies the current buffer for reading */
/* ARB_uniform_buffer_object */
OPCODE_UNIFORM_BLOCK_BINDING,
+ /* EXT_polygon_offset_clamp */
+ OPCODE_POLYGON_OFFSET_CLAMP,
+
/* The following three are meta instructions */
OPCODE_ERROR, /* raise compiled-in error */
OPCODE_CONTINUE,
save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias);
}
+static void GLAPIENTRY
+save_PolygonOffsetClampEXT(GLfloat factor, GLfloat units, GLfloat clamp)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = alloc_instruction(ctx, OPCODE_POLYGON_OFFSET_CLAMP, 3);
+ if (n) {
+ n[1].f = factor;
+ n[2].f = units;
+ n[3].f = clamp;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PolygonOffsetClampEXT(ctx->Exec, (factor, units, clamp));
+ }
+}
static void GLAPIENTRY
save_PopAttrib(void)
case OPCODE_POLYGON_OFFSET:
CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
break;
+ case OPCODE_POLYGON_OFFSET_CLAMP:
+ CALL_PolygonOffsetClampEXT(ctx->Exec, (n[1].f, n[2].f, n[3].f));
+ break;
case OPCODE_POP_ATTRIB:
CALL_PopAttrib(ctx->Exec, ());
break;
SET_ProgramUniformMatrix4x2fv(table, save_ProgramUniformMatrix4x2fv);
SET_ProgramUniformMatrix3x4fv(table, save_ProgramUniformMatrix3x4fv);
SET_ProgramUniformMatrix4x3fv(table, save_ProgramUniformMatrix4x3fv);
+
+ /* GL_EXT_polygon_offset_clamp */
+ SET_PolygonOffsetClampEXT(table, save_PolygonOffsetClampEXT);
}
{ "GL_EXT_pixel_buffer_object", o(EXT_pixel_buffer_object), GL, 2004 },
{ "GL_EXT_point_parameters", o(EXT_point_parameters), GLL, 1997 },
{ "GL_EXT_polygon_offset", o(dummy_true), GLL, 1995 },
+ { "GL_EXT_polygon_offset_clamp", o(EXT_polygon_offset_clamp), GL, 2014 },
{ "GL_EXT_provoking_vertex", o(EXT_provoking_vertex), GL, 2009 },
{ "GL_EXT_rescale_normal", o(dummy_true), GLL, 1997 },
{ "GL_EXT_secondary_color", o(dummy_true), GLL, 1999 },
EXTRA_EXT(INTEL_performance_query);
EXTRA_EXT(ARB_explicit_uniform_location);
EXTRA_EXT(ARB_clip_control);
+EXTRA_EXT(EXT_polygon_offset_clamp);
static const int
extra_ARB_color_buffer_float_or_glcore[] = {
[ "VIEWPORT_BOUNDS_RANGE", "CONTEXT_FLOAT2(Const.ViewportBounds), extra_ARB_viewport_array" ],
[ "LAYER_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ],
[ "VIEWPORT_INDEX_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ],
+
+# GL_EXT_polygon_offset_clamp
+ [ "POLYGON_OFFSET_CLAMP_EXT", "CONTEXT_FLOAT(Polygon.OffsetClamp), extra_EXT_polygon_offset_clamp" ],
]}
]
GLenum CullFaceMode; /**< Culling mode GL_FRONT or GL_BACK */
GLfloat OffsetFactor; /**< Polygon offset factor, from user */
GLfloat OffsetUnits; /**< Polygon offset units, from user */
+ GLfloat OffsetClamp; /**< Polygon offset clamp, from user */
GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
GLboolean OffsetLine; /**< Offset in GL_LINE mode */
GLboolean OffsetFill; /**< Offset in GL_FILL mode */
GLboolean EXT_packed_float;
GLboolean EXT_pixel_buffer_object;
GLboolean EXT_point_parameters;
+ GLboolean EXT_polygon_offset_clamp;
GLboolean EXT_provoking_vertex;
GLboolean EXT_shader_integer_mix;
GLboolean EXT_stencil_two_side;
_mesa_GetnPolygonStippleARB(INT_MAX, dest);
}
-
-void GLAPIENTRY
-_mesa_PolygonOffset( GLfloat factor, GLfloat units )
+void
+_mesa_polygon_offset_clamp(struct gl_context *ctx,
+ GLfloat factor, GLfloat units, GLfloat clamp)
{
- GET_CURRENT_CONTEXT(ctx);
-
- if (MESA_VERBOSE&VERBOSE_API)
- _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units);
-
if (ctx->Polygon.OffsetFactor == factor &&
- ctx->Polygon.OffsetUnits == units)
+ ctx->Polygon.OffsetUnits == units &&
+ ctx->Polygon.OffsetClamp == clamp)
return;
FLUSH_VERTICES(ctx, _NEW_POLYGON);
ctx->Polygon.OffsetFactor = factor;
ctx->Polygon.OffsetUnits = units;
+ ctx->Polygon.OffsetClamp = clamp;
if (ctx->Driver.PolygonOffset)
- ctx->Driver.PolygonOffset( ctx, factor, units );
+ ctx->Driver.PolygonOffset( ctx, factor, units, clamp );
+}
+
+void GLAPIENTRY
+_mesa_PolygonOffset( GLfloat factor, GLfloat units )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units);
+
+ _mesa_polygon_offset_clamp(ctx, factor, units, 0.0);
}
void GLAPIENTRY
_mesa_PolygonOffsetClampEXT( GLfloat factor, GLfloat units, GLfloat clamp )
{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.EXT_polygon_offset_clamp) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "unsupported function (glPolygonOffsetClampEXT) called");
+ return;
+ }
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glPolygonOffsetClampEXT %f %f %f\n", factor, units, clamp);
+ _mesa_polygon_offset_clamp(ctx, factor, units, clamp);
}
ctx->Polygon.StippleFlag = GL_FALSE;
ctx->Polygon.OffsetFactor = 0.0F;
ctx->Polygon.OffsetUnits = 0.0F;
+ ctx->Polygon.OffsetClamp = 0.0F;
ctx->Polygon.OffsetPoint = GL_FALSE;
ctx->Polygon.OffsetLine = GL_FALSE;
ctx->Polygon.OffsetFill = GL_FALSE;
extern void GLAPIENTRY
_mesa_GetPolygonStipple( GLubyte *mask );
+extern void
+_mesa_polygon_offset_clamp(struct gl_context *ctx,
+ GLfloat factor, GLfloat units, GLfloat clamp);
extern void
_mesa_init_polygon( struct gl_context * ctx );