summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2011-02-16 00:14:49 +0100
committerMarek Olšák <[email protected]>2011-03-29 12:04:55 +0200
commit47e3896dfd89a26abbe4ca2469c2480f3982b204 (patch)
tree3f64fd4340c66ee84da89506afd92c1f29f6dbb7 /src/mesa
parente5c6a92a12b5cd7db205d72039f58d302b0be9d5 (diff)
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 <[email protected]> Date: Thu Aug 26 18:17:54 2010 +0200 mesa/st: respect fragment clamping in st_DrawPixels commit 546a31e42cad459d7a7a10ebf77fc5ffcf89e9b8 Author: Luca Barbieri <[email protected]> Date: Thu Aug 26 18:17:28 2010 +0200 mesa/st: support fragment and vertex color clamping commit c406514a1fbee6891da4cf9ac3eebe4e4407ec13 Author: Luca Barbieri <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> Date: Thu Aug 26 18:18:25 2010 +0200 gallium: add color clamping to the interface
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_blend.c2
-rw-r--r--src/mesa/state_tracker/st_atom_depth.c2
-rw-r--r--src/mesa/state_tracker/st_atom_rasterizer.c8
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c4
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c1
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c7
-rw-r--r--src/mesa/state_tracker/st_extensions.c7
7 files changed, 24 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c
index fb1c7a4efee..d1844e1066f 100644
--- a/src/mesa/state_tracker/st_atom_blend.c
+++ b/src/mesa/state_tracker/st_atom_blend.c
@@ -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);
}
}
diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c
index aaee432a216..6c51b1ac1a2 100644
--- a/src/mesa/state_tracker/st_atom_depth.c
+++ b/src/mesa/state_tracker/st_atom_depth.c
@@ -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);
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 8bccceeec53..250cbb2260c 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -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 */
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 1eb748e0d5d..181fedd2b99 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -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)
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index eccc207579b..dc53e276cb3 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -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);
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index f8da2a4d158..03f58bf0fc4 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -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);
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index bbcae3b02e9..89bb03046c1 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -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;
}