gallium: implement clamping controls (ARB_color_buffer_float)
BTW this changes the gallium interface. Some rather cosmetic changes by Marek. Squashed commit of the following: commit 513b37d484f0318311e84bb86ed4c93cdff71f13 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Thu Aug 26 18:17:54 2010 +0200 mesa/st: respect fragment clamping in st_DrawPixels commit 546a31e42cad459d7a7a10ebf77fc5ffcf89e9b8 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Thu Aug 26 18:17:28 2010 +0200 mesa/st: support fragment and vertex color clamping commit c406514a1fbee6891da4cf9ac3eebe4e4407ec13 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Tue Aug 24 21:56:37 2010 +0200 mesa/st: expose ARB_color_buffer_float if unclamping is supported commit d0c5ea11b6f75f3da2f4ca989115f150ebc7cf8d Author: Luca Barbieri <luca@luca-barbieri.com> Date: Thu Aug 26 17:53:41 2010 +0200 mesa/st: use unclamped colors This assumes that Gallium is to be interpreted as given drivers the responsibility to clamp these colors if necessary. commit aef5c3c6be6edd076e955e37c80905bc447f8a82 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Thu Aug 26 18:12:34 2010 +0200 mesa, mesa/st: handle read color clamping properly We set IMAGE_CLAMP_BIT in the caller based on _ClampReadColor, where the operation mandates it. (see the removed XXX comment. -Marek) TODO: did I get the set of operations mandating it right? commit 76bdfcfe3ff4145a1818e6cb6e227b730a5f12d8 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Thu Aug 26 18:18:25 2010 +0200 gallium: add color clamping to the interface
This commit is contained in:

committed by
Marek Olšák

parent
e5c6a92a12
commit
47e3896dfd
@@ -7,6 +7,30 @@ The rasterizer state controls the rendering of points, lines and triangles.
|
||||
Attributes include polygon culling state, line width, line stipple,
|
||||
multisample state, scissoring and flat/smooth shading.
|
||||
|
||||
Linkage
|
||||
|
||||
clamp_vertex_color
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
If set, TGSI_SEMANTIC_COLOR registers are clamped to the [0, 1] range after
|
||||
the execution of the vertex shader, before being passed to the geometry
|
||||
shader or fragment shader.
|
||||
|
||||
OpenGL: glClampColor(GL_CLAMP_VERTEX_COLOR) in GL 3.0 or GL_ARB_color_buffer_float
|
||||
|
||||
D3D11: seems always disabled
|
||||
|
||||
clamp_fragment_color
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Controls whether TGSI_SEMANTIC_COLOR outputs of the fragment shader
|
||||
are clamped to [0, 1].
|
||||
|
||||
OpenGL: glClampColor(GL_CLAMP_FRAGMENT_COLOR) in GL 3.0 or ARB_color_buffer_float
|
||||
|
||||
D3D11: seems always disabled
|
||||
|
||||
|
||||
Shading
|
||||
-------
|
||||
|
||||
|
@@ -463,6 +463,8 @@ enum pipe_cap {
|
||||
PIPE_CAP_SHADER_STENCIL_EXPORT,
|
||||
PIPE_CAP_TGSI_INSTANCEID,
|
||||
PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR,
|
||||
PIPE_CAP_VERTEX_COLOR_CLAMP_CONTROL,
|
||||
PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL
|
||||
};
|
||||
|
||||
/* Shader caps not specific to any single stage */
|
||||
|
@@ -81,6 +81,8 @@ struct pipe_rasterizer_state
|
||||
{
|
||||
unsigned flatshade:1;
|
||||
unsigned light_twoside:1;
|
||||
unsigned clamp_vertex_color:1;
|
||||
unsigned clamp_fragment_color:1;
|
||||
unsigned front_ccw:1;
|
||||
unsigned cull_face:2; /**< PIPE_FACE_x */
|
||||
unsigned fill_front:2; /**< PIPE_POLYGON_MODE_x */
|
||||
|
@@ -286,7 +286,7 @@ update_blend( struct st_context *st )
|
||||
|
||||
{
|
||||
struct pipe_blend_color bc;
|
||||
COPY_4FV(bc.color, st->ctx->Color.BlendColor);
|
||||
COPY_4FV(bc.color, st->ctx->Color.BlendColorUnclamped);
|
||||
cso_set_blend_color(st->cso_context, &bc);
|
||||
}
|
||||
}
|
||||
|
@@ -142,7 +142,7 @@ update_depth_stencil_alpha(struct st_context *st)
|
||||
if (ctx->Color.AlphaEnabled) {
|
||||
dsa->alpha.enabled = 1;
|
||||
dsa->alpha.func = st_compare_func_to_pipe(ctx->Color.AlphaFunc);
|
||||
dsa->alpha.ref_value = ctx->Color.AlphaRef;
|
||||
dsa->alpha.ref_value = ctx->Color.AlphaRefUnclamped;
|
||||
}
|
||||
|
||||
cso_set_depth_stencil_alpha(st->cso_context, dsa);
|
||||
|
@@ -112,6 +112,8 @@ static void update_raster_state( struct st_context *st )
|
||||
raster->light_twoside = 1;
|
||||
}
|
||||
|
||||
raster->clamp_vertex_color = ctx->Light._ClampVertexColor;
|
||||
|
||||
/* _NEW_POLYGON
|
||||
*/
|
||||
if (ctx->Polygon.CullFlag) {
|
||||
@@ -252,6 +254,9 @@ static void update_raster_state( struct st_context *st )
|
||||
if (ctx->Scissor.Enabled)
|
||||
raster->scissor = 1;
|
||||
|
||||
/* _NEW_FRAG_CLAMP */
|
||||
raster->clamp_fragment_color = ctx->Color._ClampFragmentColor;
|
||||
|
||||
raster->gl_rasterization_rules = 1;
|
||||
|
||||
cso_set_rasterizer(st->cso_context, raster);
|
||||
@@ -267,7 +272,8 @@ const struct st_tracked_state st_update_rasterizer = {
|
||||
_NEW_POINT |
|
||||
_NEW_POLYGON |
|
||||
_NEW_PROGRAM |
|
||||
_NEW_SCISSOR), /* mesa state dependencies*/
|
||||
_NEW_SCISSOR |
|
||||
_NEW_FRAG_CLAMP), /* mesa state dependencies*/
|
||||
ST_NEW_VERTEX_PROGRAM, /* state tracker dependencies */
|
||||
},
|
||||
update_raster_state /* update function */
|
||||
|
@@ -323,7 +323,7 @@ clear_with_quad(struct gl_context *ctx,
|
||||
set_vertex_shader(st);
|
||||
|
||||
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
|
||||
st_translate_color(ctx->Color.ClearColor,
|
||||
st_translate_color(ctx->Color.ClearColorUnclamped,
|
||||
ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
|
||||
clearColor);
|
||||
}
|
||||
@@ -585,7 +585,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
|
||||
clearColor);
|
||||
}
|
||||
|
||||
st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColor,
|
||||
st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColorUnclamped,
|
||||
ctx->Depth.Clear, ctx->Stencil.Clear);
|
||||
}
|
||||
if (mask & BUFFER_BIT_ACCUM)
|
||||
|
@@ -582,6 +582,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
|
||||
{
|
||||
struct pipe_rasterizer_state rasterizer;
|
||||
memset(&rasterizer, 0, sizeof(rasterizer));
|
||||
rasterizer.clamp_fragment_color = ctx->Color._ClampFragmentColor;
|
||||
rasterizer.gl_rasterization_rules = 1;
|
||||
rasterizer.scissor = ctx->Scissor.Enabled;
|
||||
cso_set_rasterizer(cso, &rasterizer);
|
||||
|
@@ -331,7 +331,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
GLfloat (*temp)[4];
|
||||
const GLbitfield transferOps = ctx->_ImageTransferState;
|
||||
GLbitfield transferOps = ctx->_ImageTransferState;
|
||||
GLsizei i, j;
|
||||
GLint yStep, dfStride;
|
||||
GLfloat *df;
|
||||
@@ -391,7 +391,10 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h
|
||||
return;
|
||||
}
|
||||
|
||||
if (format == GL_RGBA && type == GL_FLOAT) {
|
||||
if(ctx->Color._ClampReadColor)
|
||||
transferOps |= IMAGE_CLAMP_BIT;
|
||||
|
||||
if (format == GL_RGBA && type == GL_FLOAT && !transferOps) {
|
||||
/* write tile(row) directly into user's buffer */
|
||||
df = (GLfloat *) _mesa_image_address2d(&clippedPacking, dest, width,
|
||||
height, format, type, 0, 0);
|
||||
|
@@ -508,6 +508,13 @@ void st_init_extensions(struct st_context *st)
|
||||
ctx->Extensions.ARB_depth_clamp = GL_TRUE;
|
||||
}
|
||||
|
||||
/* this extension does not actually require support of floating point
|
||||
* render targets, just clamping controls
|
||||
*/
|
||||
if(screen->get_param(screen, PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL) &&
|
||||
screen->get_param(screen, PIPE_CAP_VERTEX_COLOR_CLAMP_CONTROL))
|
||||
ctx->Extensions.ARB_color_buffer_float = GL_TRUE;
|
||||
|
||||
if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
|
||||
ctx->Extensions.ARB_shader_stencil_export = GL_TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user