summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2011-09-16 09:39:34 +0100
committerDave Airlie <[email protected]>2011-09-18 15:12:47 +0100
commit6dd284f7c8fac22f64c13fdf9909094f5ec59086 (patch)
tree8fe6c89638f05d1638b3a5d0395e011d68eda336
parent78026b8acef9d6eea4f37d9c5435447944d1befd (diff)
gallium: move clear paths from rgba to a pointer to a color union (v2)
This moves the gallium interface for clears from using a pointer to 4 floats to a pointer to a union of float/unsigned/int values. Notes: 1. the value is opaque. 2. only when the value is used should it be interpretered according to the surface format it is going to be used with. 3. float clears on integer buffers and vice-versa are undefined. v2: fixed up vega and graw, dropped hunks that shouldn't have been in patch. Signed-off-by: Dave Airlie <[email protected]>
-rw-r--r--src/gallium/auxiliary/postprocess/pp_mlaa.c2
-rw-r--r--src/gallium/auxiliary/postprocess/pp_program.h2
-rw-r--r--src/gallium/auxiliary/postprocess/pp_run.c2
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c44
-rw-r--r--src/gallium/auxiliary/util/u_blitter.h6
-rw-r--r--src/gallium/auxiliary/util/u_clear.h4
-rw-r--r--src/gallium/auxiliary/util/u_surface.c4
-rw-r--r--src/gallium/auxiliary/util/u_surface.h2
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c20
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.h6
-rw-r--r--src/gallium/drivers/cell/ppu/cell_clear.c5
-rw-r--r--src/gallium/drivers/cell/ppu/cell_clear.h3
-rw-r--r--src/gallium/drivers/galahad/glhd_context.c8
-rw-r--r--src/gallium/drivers/i915/i915_clear.c17
-rw-r--r--src/gallium/drivers/i915/i915_context.h9
-rw-r--r--src/gallium/drivers/i915/i915_surface.c8
-rw-r--r--src/gallium/drivers/i965/brw_pipe_clear.c8
-rw-r--r--src/gallium/drivers/identity/id_context.c8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_clear.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_clear.h3
-rw-r--r--src/gallium/drivers/noop/noop_pipe.c4
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h3
-rw-r--r--src/gallium/drivers/nv50/nv50_surface.c21
-rw-r--r--src/gallium/drivers/nvc0/nvc0_context.h3
-rw-r--r--src/gallium/drivers/nvc0/nvc0_surface.c21
-rw-r--r--src/gallium/drivers/nvfx/nvfx_clear.c4
-rw-r--r--src/gallium/drivers/nvfx/nvfx_context.h3
-rw-r--r--src/gallium/drivers/nvfx/nvfx_surface.c6
-rw-r--r--src/gallium/drivers/r300/r300_blit.c10
-rw-r--r--src/gallium/drivers/r300/r300_render.c20
-rw-r--r--src/gallium/drivers/r600/r600_blit.c11
-rw-r--r--src/gallium/drivers/rbug/rbug_context.c8
-rw-r--r--src/gallium/drivers/softpipe/sp_clear.c7
-rw-r--r--src/gallium/drivers/softpipe/sp_clear.h3
-rw-r--r--src/gallium/drivers/svga/svga_context.h2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_clear.c11
-rw-r--r--src/gallium/drivers/trace/tr_context.c14
-rw-r--r--src/gallium/include/pipe/p_context.h10
-rw-r--r--src/gallium/include/pipe/p_defines.h6
-rw-r--r--src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp10
-rw-r--r--src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h7
-rw-r--r--src/gallium/state_trackers/vdpau/presentation.c16
-rw-r--r--src/gallium/state_trackers/vega/api_masks.c7
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c7
-rw-r--r--src/gallium/tests/graw/clear.c4
-rw-r--r--src/gallium/tests/graw/fs-test.c4
-rw-r--r--src/gallium/tests/graw/gs-test.c4
-rw-r--r--src/gallium/tests/graw/quad-sample.c4
-rw-r--r--src/gallium/tests/graw/quad-tex.c4
-rw-r--r--src/gallium/tests/graw/shader-leak.c4
-rw-r--r--src/gallium/tests/graw/tri-gs.c4
-rw-r--r--src/gallium/tests/graw/tri-instanced.c4
-rw-r--r--src/gallium/tests/graw/tri.c4
-rw-r--r--src/gallium/tests/graw/vs-test.c4
-rw-r--r--src/gallium/tests/trivial/quad-tex.c12
-rw-r--r--src/gallium/tests/trivial/tri.c12
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c22
57 files changed, 256 insertions, 209 deletions
diff --git a/src/gallium/auxiliary/postprocess/pp_mlaa.c b/src/gallium/auxiliary/postprocess/pp_mlaa.c
index 476502fca93..5708687a1c2 100644
--- a/src/gallium/auxiliary/postprocess/pp_mlaa.c
+++ b/src/gallium/auxiliary/postprocess/pp_mlaa.c
@@ -121,7 +121,7 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
pp_filter_misc_state(p);
cso_set_depth_stencil_alpha(p->cso, &mstencil);
p->pipe->clear(p->pipe, PIPE_CLEAR_STENCIL | PIPE_CLEAR_COLOR,
- p->clear_color, 0, 0);
+ &p->clear_color, 0, 0);
cso_single_sampler(p->cso, 0, &p->sampler_point);
cso_single_sampler_done(p->cso);
diff --git a/src/gallium/auxiliary/postprocess/pp_program.h b/src/gallium/auxiliary/postprocess/pp_program.h
index 2749b35b372..a85ba6ea797 100644
--- a/src/gallium/auxiliary/postprocess/pp_program.h
+++ b/src/gallium/auxiliary/postprocess/pp_program.h
@@ -49,7 +49,7 @@ struct program
struct pipe_framebuffer_state framebuffer;
struct pipe_vertex_element velem[2];
- float clear_color[4];
+ union pipe_color_union clear_color;
void *passvs;
diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c
index ce671aea360..de1fe559e49 100644
--- a/src/gallium/auxiliary/postprocess/pp_run.c
+++ b/src/gallium/auxiliary/postprocess/pp_run.c
@@ -184,5 +184,5 @@ void
pp_filter_set_clear_fb(struct program *p)
{
cso_set_framebuffer(p->cso, &p->framebuffer);
- p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0);
+ p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0);
}
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index d69fb1a11ab..58a52b3f2de 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -111,7 +111,7 @@ static void blitter_draw_rectangle(struct blitter_context *blitter,
unsigned width, unsigned height,
float depth,
enum blitter_attrib_type type,
- const float attrib[4]);
+ const union pipe_color_union *attrib);
struct blitter_context *util_blitter_create(struct pipe_context *pipe)
@@ -398,16 +398,16 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx,
}
static void blitter_set_clear_color(struct blitter_context_priv *ctx,
- const float *rgba)
+ const union pipe_color_union *color)
{
int i;
- if (rgba) {
+ if (color) {
for (i = 0; i < 4; i++) {
- ctx->vertices[i][1][0] = rgba[0];
- ctx->vertices[i][1][1] = rgba[1];
- ctx->vertices[i][1][2] = rgba[2];
- ctx->vertices[i][1][3] = rgba[3];
+ ctx->vertices[i][1][0] = color->f[0];
+ ctx->vertices[i][1][1] = color->f[1];
+ ctx->vertices[i][1][2] = color->f[2];
+ ctx->vertices[i][1][3] = color->f[3];
}
} else {
for (i = 0; i < 4; i++) {
@@ -647,7 +647,7 @@ static void blitter_draw_rectangle(struct blitter_context *blitter,
unsigned x2, unsigned y2,
float depth,
enum blitter_attrib_type type,
- const float attrib[4])
+ const union pipe_color_union *attrib)
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
@@ -657,7 +657,7 @@ static void blitter_draw_rectangle(struct blitter_context *blitter,
break;
case UTIL_BLITTER_ATTRIB_TEXCOORD:
- set_texcoords_in_vertices(attrib, &ctx->vertices[0][1][0], 8);
+ set_texcoords_in_vertices(attrib->f, &ctx->vertices[0][1][0], 8);
break;
default:;
@@ -674,7 +674,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth, unsigned stencil,
void *custom_blend, void *custom_dsa)
{
@@ -717,7 +717,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, width, height);
blitter->draw_rectangle(blitter, 0, 0, width, height, depth,
- UTIL_BLITTER_ATTRIB_COLOR, rgba);
+ UTIL_BLITTER_ATTRIB_COLOR, color);
blitter_restore_CSOs(ctx);
}
@@ -725,11 +725,11 @@ void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth, unsigned stencil)
{
util_blitter_clear_custom(blitter, width, height, num_cbufs,
- clear_buffers, rgba, depth, stencil,
+ clear_buffers, color, depth, stencil,
NULL, NULL);
}
@@ -737,9 +737,9 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter,
unsigned width, unsigned height,
double depth, void *custom_dsa)
{
- const float rgba[4] = {0, 0, 0, 0};
+ static const union pipe_color_union color;
util_blitter_clear_custom(blitter, width, height, 0,
- 0, rgba, depth, 0, NULL, custom_dsa);
+ 0, &color, depth, 0, NULL, custom_dsa);
}
static
@@ -869,14 +869,16 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
case PIPE_TEXTURE_2D:
case PIPE_TEXTURE_RECT:
{
- /* Set texture coordinates. */
- float coord[4];
+ /* Set texture coordinates. - use a pipe color union
+ * for interface purposes
+ */
+ union pipe_color_union coord;
get_texcoords(src, srclevel, srcbox->x, srcbox->y,
- srcbox->x+width, srcbox->y+height, normalized, coord);
+ srcbox->x+width, srcbox->y+height, normalized, coord.f);
/* Draw. */
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
- UTIL_BLITTER_ATTRIB_TEXCOORD, coord);
+ UTIL_BLITTER_ATTRIB_TEXCOORD, &coord);
}
break;
@@ -925,7 +927,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
/* Clear a region of a color surface to a constant value. */
void util_blitter_clear_render_target(struct blitter_context *blitter,
struct pipe_surface *dstsurf,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -959,7 +961,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
- UTIL_BLITTER_ATTRIB_COLOR, rgba);
+ UTIL_BLITTER_ATTRIB_COLOR, color);
blitter_restore_CSOs(ctx);
}
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index df6f023a638..a9ad023644c 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -77,7 +77,7 @@ struct blitter_context
unsigned x1, unsigned y1, unsigned x2, unsigned y2,
float depth,
enum blitter_attrib_type type,
- const float attrib[4]);
+ const union pipe_color_union *color);
/* Whether the blitter is running. */
boolean running;
@@ -144,7 +144,7 @@ void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height,
unsigned num_cbufs,
unsigned clear_buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth, unsigned stencil);
void util_blitter_clear_depth_custom(struct blitter_context *blitter,
@@ -190,7 +190,7 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
*/
void util_blitter_clear_render_target(struct blitter_context *blitter,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height);
diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h
index ad69df3f898..e9fd874b1fc 100644
--- a/src/gallium/auxiliary/util/u_clear.h
+++ b/src/gallium/auxiliary/util/u_clear.h
@@ -40,13 +40,13 @@
static INLINE void
util_clear(struct pipe_context *pipe,
struct pipe_framebuffer_state *framebuffer, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
+ const union pipe_color_union *color, double depth, unsigned stencil)
{
if (buffers & PIPE_CLEAR_COLOR) {
unsigned i;
for (i = 0; i < framebuffer->nr_cbufs; i++) {
struct pipe_surface *ps = framebuffer->cbufs[i];
- pipe->clear_render_target(pipe, ps, rgba, 0, 0, ps->width, ps->height);
+ pipe->clear_render_target(pipe, ps, color, 0, 0, ps->width, ps->height);
}
}
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index 8e123867da6..308511b33c4 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -228,7 +228,7 @@ util_resource_copy_region(struct pipe_context *pipe,
void
util_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -254,7 +254,7 @@ util_clear_render_target(struct pipe_context *pipe,
if (dst_map) {
assert(dst_trans->stride > 0);
- util_pack_color(rgba, dst->texture->format, &uc);
+ util_pack_color(color->f, dst->texture->format, &uc);
util_fill_rect(dst_map, dst->texture->format,
dst_trans->stride,
0, 0, width, height, &uc);
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
index 6a7cc82b055..1117b78da7a 100644
--- a/src/gallium/auxiliary/util/u_surface.h
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -68,7 +68,7 @@ util_resource_copy_region(struct pipe_context *pipe,
extern void
util_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height);
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index ebe6d7ae45c..322ef8e9954 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -552,26 +552,20 @@ vl_compositor_reset_dirty_area(struct vl_compositor *c)
}
void
-vl_compositor_set_clear_color(struct vl_compositor *c, float color[4])
+vl_compositor_set_clear_color(struct vl_compositor *c, union pipe_color_union *color)
{
- unsigned i;
-
assert(c);
- for (i = 0; i < 4; ++i)
- c->clear_color[i] = color[i];
+ c->clear_color = *color;
}
void
-vl_compositor_get_clear_color(struct vl_compositor *c, float color[4])
+vl_compositor_get_clear_color(struct vl_compositor *c, union pipe_color_union *color)
{
- unsigned i;
-
assert(c);
assert(color);
- for (i = 0; i < 4; ++i)
- color[i] = c->clear_color[i];
+ *color = c->clear_color;
}
void
@@ -760,7 +754,7 @@ vl_compositor_render(struct vl_compositor *c,
if (clear_dirty_area && (c->dirty_tl.x < c->dirty_br.x ||
c->dirty_tl.y < c->dirty_br.y)) {
- util_clear_render_target(c->pipe, dst_surface, c->clear_color,
+ util_clear_render_target(c->pipe, dst_surface, &c->clear_color,
0, 0, dst_surface->width, dst_surface->height);
c->dirty_tl.x = c->dirty_tl.y = 1.0f;
c->dirty_br.x = c->dirty_br.y = 0.0f;
@@ -804,8 +798,8 @@ vl_compositor_init(struct vl_compositor *c, struct pipe_context *pipe)
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, csc_matrix);
vl_compositor_set_csc_matrix(c, csc_matrix);
- c->clear_color[0] = c->clear_color[1] = 0.0f;
- c->clear_color[2] = c->clear_color[3] = 0.0f;
+ c->clear_color.f[0] = c->clear_color.f[1] = 0.0f;
+ c->clear_color.f[2] = c->clear_color.f[3] = 0.0f;
vl_compositor_reset_dirty_area(c);
return true;
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
index 0b9b9939a8c..f60f7da3ec1 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -81,7 +81,7 @@ struct vl_compositor
void *yuv;
} fs_palette;
- float clear_color[4];
+ union pipe_color_union clear_color;
struct vertex2f dirty_tl, dirty_br;
unsigned used_layers:VL_COMPOSITOR_MAX_LAYERS;
@@ -110,13 +110,13 @@ vl_compositor_reset_dirty_area(struct vl_compositor *compositor);
* set the clear color
*/
void
-vl_compositor_set_clear_color(struct vl_compositor *compositor, float color[4]);
+vl_compositor_set_clear_color(struct vl_compositor *compositor, union pipe_color_union *color);
/**
* get the clear color
*/
void
-vl_compositor_get_clear_color(struct vl_compositor *compositor, float color[4]);
+vl_compositor_get_clear_color(struct vl_compositor *compositor, union pipe_color_union *color);
/**
* set overlay samplers
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c
index 246fe210542..6a525ef4e41 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.c
+++ b/src/gallium/drivers/cell/ppu/cell_clear.c
@@ -49,7 +49,8 @@
* Called via pipe->clear()
*/
void
-cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+cell_clear(struct pipe_context *pipe, unsigned buffers,
+ const pipe_color_union *color,
double depth, unsigned stencil)
{
struct cell_context *cell = cell_context(pipe);
@@ -61,7 +62,7 @@ cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
uint surfIndex = 0;
union util_color uc;
- util_pack_color(rgba, cell->framebuffer.cbufs[0]->format, &uc);
+ util_pack_color(color->f, cell->framebuffer.cbufs[0]->format, &uc);
/* Build a CLEAR command and place it in the current batch buffer */
STATIC_ASSERT(sizeof(struct cell_command_clear_surface) % 16 == 0);
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.h b/src/gallium/drivers/cell/ppu/cell_clear.h
index 08e091adfdb..a365feb0f00 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.h
+++ b/src/gallium/drivers/cell/ppu/cell_clear.h
@@ -34,7 +34,8 @@ struct pipe_context;
extern void
-cell_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+cell_clear(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil);
diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c
index f73d8a5d32e..a4afa813f89 100644
--- a/src/gallium/drivers/galahad/glhd_context.c
+++ b/src/gallium/drivers/galahad/glhd_context.c
@@ -705,7 +705,7 @@ galahad_resource_copy_region(struct pipe_context *_pipe,
static void
galahad_clear(struct pipe_context *_pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -714,7 +714,7 @@ galahad_clear(struct pipe_context *_pipe,
pipe->clear(pipe,
buffers,
- rgba,
+ color,
depth,
stencil);
}
@@ -722,7 +722,7 @@ galahad_clear(struct pipe_context *_pipe,
static void
galahad_clear_render_target(struct pipe_context *_pipe,
struct pipe_surface *_dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -733,7 +733,7 @@ galahad_clear_render_target(struct pipe_context *_pipe,
pipe->clear_render_target(pipe,
dst,
- rgba,
+ color,
dstx,
dsty,
width,
diff --git a/src/gallium/drivers/i915/i915_clear.c b/src/gallium/drivers/i915/i915_clear.c
index 4f9aa2c3120..c682c06cb58 100644
--- a/src/gallium/drivers/i915/i915_clear.c
+++ b/src/gallium/drivers/i915/i915_clear.c
@@ -41,7 +41,8 @@
#include "i915_state.h"
void
-i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil,
unsigned destx, unsigned desty, unsigned width, unsigned height)
{
@@ -60,13 +61,13 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *rgba,
clear_params |= CLEARPARAM_WRITE_COLOR;
cbuf_tex = i915_texture(cbuf->texture);
- util_pack_color(rgba, cbuf->format, &u_color);
+ util_pack_color(color->f, cbuf->format, &u_color);
if (util_format_get_blocksize(cbuf_tex->b.b.format) == 4)
clear_color = u_color.ui;
else
clear_color = (u_color.ui & 0xffff) | (u_color.ui << 16);
- util_pack_color(rgba, cbuf->format, &u_color);
+ util_pack_color(color->f, cbuf->format, &u_color);
clear_color8888 = u_color.ui;
} else
clear_color = clear_color8888 = 0;
@@ -135,15 +136,17 @@ i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *rgba,
* No masking, no scissor (clear entire buffer).
*/
void
-i915_clear_blitter(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+i915_clear_blitter(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil)
{
- util_clear(pipe, &i915_context(pipe)->framebuffer, buffers, rgba, depth,
+ util_clear(pipe, &i915_context(pipe)->framebuffer, buffers, color, depth,
stencil);
}
void
-i915_clear_render(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+i915_clear_render(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil)
{
struct i915_context *i915 = i915_context(pipe);
@@ -151,6 +154,6 @@ i915_clear_render(struct pipe_context *pipe, unsigned buffers, const float *rgba
if (i915->dirty)
i915_update_derived(i915);
- i915_clear_emit(pipe, buffers, rgba, depth, stencil,
+ i915_clear_emit(pipe, buffers, color, depth, stencil,
0, 0, i915->framebuffer.width, i915->framebuffer.height);
}
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index fca8688a526..f16bb725a4b 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -368,11 +368,14 @@ void i915_emit_hardware_state(struct i915_context *i915 );
/***********************************************************************
* i915_clear.c:
*/
-void i915_clear_blitter(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+void i915_clear_blitter(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil);
-void i915_clear_render(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+void i915_clear_render(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil);
-void i915_clear_emit(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+void i915_clear_emit(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil,
unsigned destx, unsigned desty, unsigned width, unsigned height);
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index 41146be9311..4ba99a33d70 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -87,7 +87,7 @@ i915_surface_copy_render(struct pipe_context *pipe,
static void
i915_clear_render_target_render(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -106,7 +106,7 @@ i915_clear_render_target_render(struct pipe_context *pipe,
if (i915->dirty)
i915_update_derived(i915);
- i915_clear_emit(pipe, PIPE_CLEAR_COLOR, rgba, 0.0, 0x0,
+ i915_clear_emit(pipe, PIPE_CLEAR_COLOR, color, 0.0, 0x0,
dstx, dsty, width, height);
pipe->set_framebuffer_state(pipe, &i915->blitter->saved_fb_state);
@@ -202,7 +202,7 @@ i915_surface_copy_blitter(struct pipe_context *pipe,
static void
i915_clear_render_target_blitter(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -214,7 +214,7 @@ i915_clear_render_target_blitter(struct pipe_context *pipe,
assert(util_format_get_blockwidth(pt->format) == 1);
assert(util_format_get_blockheight(pt->format) == 1);
- util_pack_color(rgba, dst->format, &uc);
+ util_pack_color(color->f, dst->format, &uc);
i915_fill_blit( i915_context(pipe),
util_format_get_blocksize(pt->format),
XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB,
diff --git a/src/gallium/drivers/i965/brw_pipe_clear.c b/src/gallium/drivers/i965/brw_pipe_clear.c
index 7bf3ea6994a..847b11565d4 100644
--- a/src/gallium/drivers/i965/brw_pipe_clear.c
+++ b/src/gallium/drivers/i965/brw_pipe_clear.c
@@ -201,7 +201,7 @@ static void zstencil_clear(struct brw_context *brw,
*/
static void brw_clear(struct pipe_context *pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -212,7 +212,7 @@ static void brw_clear(struct pipe_context *pipe,
for (i = 0; i < brw->curr.fb.nr_cbufs; i++) {
color_clear( brw,
brw_surface(brw->curr.fb.cbufs[i]),
- rgba );
+ color->f );
}
}
@@ -229,7 +229,7 @@ static void brw_clear(struct pipe_context *pipe,
/* XXX should respect region */
static void brw_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -237,7 +237,7 @@ static void brw_clear_render_target(struct pipe_context *pipe,
color_clear( brw,
brw_surface(dst),
- rgba );
+ color->f );
}
/* XXX should respect region */
diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c
index 2a9d7360155..a9043c1590b 100644
--- a/src/gallium/drivers/identity/id_context.c
+++ b/src/gallium/drivers/identity/id_context.c
@@ -606,7 +606,7 @@ identity_resource_copy_region(struct pipe_context *_pipe,
static void
identity_clear(struct pipe_context *_pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -615,7 +615,7 @@ identity_clear(struct pipe_context *_pipe,
pipe->clear(pipe,
buffers,
- rgba,
+ color,
depth,
stencil);
}
@@ -623,7 +623,7 @@ identity_clear(struct pipe_context *_pipe,
static void
identity_clear_render_target(struct pipe_context *_pipe,
struct pipe_surface *_dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -634,7 +634,7 @@ identity_clear_render_target(struct pipe_context *_pipe,
pipe->clear_render_target(pipe,
dst,
- rgba,
+ color,
dstx,
dsty,
width,
diff --git a/src/gallium/drivers/llvmpipe/lp_clear.c b/src/gallium/drivers/llvmpipe/lp_clear.c
index b486b243eb5..be2fce1307c 100644
--- a/src/gallium/drivers/llvmpipe/lp_clear.c
+++ b/src/gallium/drivers/llvmpipe/lp_clear.c
@@ -46,7 +46,7 @@
void
llvmpipe_clear(struct pipe_context *pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -58,5 +58,5 @@ llvmpipe_clear(struct pipe_context *pipe,
if (LP_PERF & PERF_NO_DEPTH)
buffers &= ~PIPE_CLEAR_DEPTHSTENCIL;
- lp_setup_clear( llvmpipe->setup, rgba, depth, stencil, buffers );
+ lp_setup_clear( llvmpipe->setup, color->f, depth, stencil, buffers );
}
diff --git a/src/gallium/drivers/llvmpipe/lp_clear.h b/src/gallium/drivers/llvmpipe/lp_clear.h
index 6d4ffccdf45..29ca0b796c3 100644
--- a/src/gallium/drivers/llvmpipe/lp_clear.h
+++ b/src/gallium/drivers/llvmpipe/lp_clear.h
@@ -36,7 +36,8 @@
struct pipe_context;
extern void
-llvmpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+llvmpipe_clear(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil);
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c
index 7c133c5f159..ead97df494c 100644
--- a/src/gallium/drivers/noop/noop_pipe.c
+++ b/src/gallium/drivers/noop/noop_pipe.c
@@ -224,13 +224,13 @@ static void noop_transfer_inline_write(struct pipe_context *pipe,
* clear/copy
*/
static void noop_clear(struct pipe_context *ctx, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
+ const union pipe_color_union *color, double depth, unsigned stencil)
{
}
static void noop_clear_render_target(struct pipe_context *ctx,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index ecffbbf86e6..edd79159e72 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -178,7 +178,8 @@ extern boolean nv50_state_validate(struct nv50_context *, uint32_t state_mask,
/* nv50_surface.c */
extern void nv50_clear(struct pipe_context *, unsigned buffers,
- const float *rgba, double depth, unsigned stencil);
+ const union pipe_color_union *color,
+ double depth, unsigned stencil);
extern void nv50_init_surface_functions(struct nv50_context *);
/* nv50_tex.c */
diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c
index b0a8497c1e7..83bb9434afa 100644
--- a/src/gallium/drivers/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nv50/nv50_surface.c
@@ -261,7 +261,7 @@ nv50_resource_copy_region(struct pipe_context *pipe,
static void
nv50_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -273,10 +273,10 @@ nv50_clear_render_target(struct pipe_context *pipe,
struct nouveau_bo *bo = mt->base.bo;
BEGIN_RING(chan, RING_3D(CLEAR_COLOR(0)), 4);
- OUT_RINGf (chan, rgba[0]);
- OUT_RINGf (chan, rgba[1]);
- OUT_RINGf (chan, rgba[2]);
- OUT_RINGf (chan, rgba[3]);
+ OUT_RINGf (chan, color->f[0]);
+ OUT_RINGf (chan, color->f[1]);
+ OUT_RINGf (chan, color->f[2]);
+ OUT_RINGf (chan, color->f[3]);
if (MARK_RING(chan, 18, 2))
return;
@@ -374,7 +374,8 @@ nv50_clear_depth_stencil(struct pipe_context *pipe,
void
nv50_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
+ const union pipe_color_union *color,
+ double depth, unsigned stencil)
{
struct nv50_context *nv50 = nv50_context(pipe);
struct nouveau_channel *chan = nv50->screen->base.channel;
@@ -388,10 +389,10 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers,
if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) {
BEGIN_RING(chan, RING_3D(CLEAR_COLOR(0)), 4);
- OUT_RINGf (chan, rgba[0]);
- OUT_RINGf (chan, rgba[1]);
- OUT_RINGf (chan, rgba[2]);
- OUT_RINGf (chan, rgba[3]);
+ OUT_RINGf (chan, color->f[0]);
+ OUT_RINGf (chan, color->f[1]);
+ OUT_RINGf (chan, color->f[2]);
+ OUT_RINGf (chan, color->f[3]);
mode =
NV50_3D_CLEAR_BUFFERS_R | NV50_3D_CLEAR_BUFFERS_G |
NV50_3D_CLEAR_BUFFERS_B | NV50_3D_CLEAR_BUFFERS_A;
diff --git a/src/gallium/drivers/nvc0/nvc0_context.h b/src/gallium/drivers/nvc0/nvc0_context.h
index c11d1c32efe..c4e481c28cb 100644
--- a/src/gallium/drivers/nvc0/nvc0_context.h
+++ b/src/gallium/drivers/nvc0/nvc0_context.h
@@ -187,7 +187,8 @@ extern boolean nvc0_state_validate(struct nvc0_context *, uint32_t state_mask,
/* nvc0_surface.c */
extern void nvc0_clear(struct pipe_context *, unsigned buffers,
- const float *rgba, double depth, unsigned stencil);
+ const union pipe_color_union *color,
+ double depth, unsigned stencil);
extern void nvc0_init_surface_functions(struct nvc0_context *);
/* nvc0_tex.c */
diff --git a/src/gallium/drivers/nvc0/nvc0_surface.c b/src/gallium/drivers/nvc0/nvc0_surface.c
index 61aa1a17f1d..ff07aad00d0 100644
--- a/src/gallium/drivers/nvc0/nvc0_surface.c
+++ b/src/gallium/drivers/nvc0/nvc0_surface.c
@@ -267,7 +267,7 @@ nvc0_resource_copy_region(struct pipe_context *pipe,
static void
nvc0_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -279,10 +279,10 @@ nvc0_clear_render_target(struct pipe_context *pipe,
struct nouveau_bo *bo = mt->base.bo;
BEGIN_RING(chan, RING_3D(CLEAR_COLOR(0)), 4);
- OUT_RINGf (chan, rgba[0]);
- OUT_RINGf (chan, rgba[1]);
- OUT_RINGf (chan, rgba[2]);
- OUT_RINGf (chan, rgba[3]);
+ OUT_RINGf (chan, color->f[0]);
+ OUT_RINGf (chan, color->f[1]);
+ OUT_RINGf (chan, color->f[2]);
+ OUT_RINGf (chan, color->f[3]);
if (MARK_RING(chan, 18, 2))
return;
@@ -377,7 +377,8 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe,
void
nvc0_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
+ const union pipe_color_union *color,
+ double depth, unsigned stencil)
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
struct nouveau_channel *chan = nvc0->screen->base.channel;
@@ -391,10 +392,10 @@ nvc0_clear(struct pipe_context *pipe, unsigned buffers,
if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) {
BEGIN_RING(chan, RING_3D(CLEAR_COLOR(0)), 4);
- OUT_RINGf (chan, rgba[0]);
- OUT_RINGf (chan, rgba[1]);
- OUT_RINGf (chan, rgba[2]);
- OUT_RINGf (chan, rgba[3]);
+ OUT_RINGf (chan, color->f[0]);
+ OUT_RINGf (chan, color->f[1]);
+ OUT_RINGf (chan, color->f[2]);
+ OUT_RINGf (chan, color->f[3]);
mode =
NVC0_3D_CLEAR_BUFFERS_R | NVC0_3D_CLEAR_BUFFERS_G |
NVC0_3D_CLEAR_BUFFERS_B | NVC0_3D_CLEAR_BUFFERS_A;
diff --git a/src/gallium/drivers/nvfx/nvfx_clear.c b/src/gallium/drivers/nvfx/nvfx_clear.c
index 2be70fcee40..46f23e38260 100644
--- a/src/gallium/drivers/nvfx/nvfx_clear.c
+++ b/src/gallium/drivers/nvfx/nvfx_clear.c
@@ -7,8 +7,8 @@
void
nvfx_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
+ const union pipe_color_union *color, double depth, unsigned stencil)
{
- util_clear(pipe, &nvfx_context(pipe)->framebuffer, buffers, rgba, depth,
+ util_clear(pipe, &nvfx_context(pipe)->framebuffer, buffers, color, depth,
stencil);
}
diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
index cb40a521d1b..3d05ecc7807 100644
--- a/src/gallium/drivers/nvfx/nvfx_context.h
+++ b/src/gallium/drivers/nvfx/nvfx_context.h
@@ -238,7 +238,8 @@ nvfx_create(struct pipe_screen *pscreen, void *priv);
/* nvfx_clear.c */
extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
- const float *rgba, double depth, unsigned stencil);
+ const union pipe_color_union *color,
+ double depth, unsigned stencil);
/* nvfx_draw.c */
extern struct draw_stage *nvfx_draw_render_stage(struct nvfx_context *nvfx);
diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c b/src/gallium/drivers/nvfx/nvfx_surface.c
index 91ca1c3750e..d489bbf9473 100644
--- a/src/gallium/drivers/nvfx/nvfx_surface.c
+++ b/src/gallium/drivers/nvfx/nvfx_surface.c
@@ -478,19 +478,19 @@ nvfx_surface_flush(struct pipe_context* pipe, struct pipe_surface* surf)
static void
nvfx_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
union util_color uc;
- util_pack_color(rgba, dst->format, &uc);
+ util_pack_color(color->f, dst->format, &uc);
if(util_format_get_blocksizebits(dst->format) > 32
|| nvfx_surface_fill(pipe, dst, dstx, dsty, width, height, uc.ui))
{
// TODO: probably should use hardware clear here instead if possible
struct blitter_context* blitter = nvfx_get_blitter(pipe, 0);
- util_blitter_clear_render_target(blitter, dst, rgba, dstx, dsty, width, height);
+ util_blitter_clear_render_target(blitter, dst, color, dstx, dsty, width, height);
nvfx_put_blitter(pipe, blitter);
}
}
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index ddf5448a34b..3c1b3648a24 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -174,7 +174,7 @@ static uint32_t r300_hiz_clear_value(double depth)
/* Clear currently bound buffers. */
static void r300_clear(struct pipe_context* pipe,
unsigned buffers,
- const float* rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -281,7 +281,7 @@ static void r300_clear(struct pipe_context* pipe,
struct r300_surface *surf = r300_surface(fb->cbufs[0]);
hyperz->zb_depthclearvalue =
- r300_depth_clear_cb_value(surf->base.format, rgba);
+ r300_depth_clear_cb_value(surf->base.format, color->f);
width = surf->cbzb_width;
height = surf->cbzb_height;
@@ -298,7 +298,7 @@ static void r300_clear(struct pipe_context* pipe,
width,
height,
fb->nr_cbufs,
- buffers, rgba, depth, stencil);
+ buffers, color, depth, stencil);
r300_blitter_end(r300);
} else if (r300->zmask_clear.dirty || r300->hiz_clear.dirty) {
/* Just clear zmask and hiz now, this does not use the standard draw
@@ -348,14 +348,14 @@ static void r300_clear(struct pipe_context* pipe,
/* Clear a region of a color surface to a constant value. */
static void r300_clear_render_target(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
struct r300_context *r300 = r300_context(pipe);
r300_blitter_begin(r300, R300_CLEAR_SURFACE);
- util_blitter_clear_render_target(r300->blitter, dst, rgba,
+ util_blitter_clear_render_target(r300->blitter, dst, color,
dstx, dsty, width, height);
r300_blitter_end(r300);
}
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index d69b4cf4275..fc3ba335886 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -1186,7 +1186,7 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter,
unsigned x2, unsigned y2,
float depth,
enum blitter_attrib_type type,
- const float attrib[4])
+ const union pipe_color_union *attrib)
{
struct r300_context *r300 = r300_context(util_blitter_get_pipe(blitter));
unsigned last_sprite_coord_enable = r300->sprite_coord_enable;
@@ -1196,7 +1196,7 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter,
type == UTIL_BLITTER_ATTRIB_COLOR || !r300->draw ? 8 : 4;
unsigned dwords = 13 + vertex_size +
(type == UTIL_BLITTER_ATTRIB_TEXCOORD ? 7 : 0);
- const float zeros[4] = {0, 0, 0, 0};
+ static const union pipe_color_union zeros;
CS_LOCALS(r300);
if (r300->skip_rendering)
@@ -1227,10 +1227,10 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter,
OUT_CS_REG(R300_GB_ENABLE, R300_GB_POINT_STUFF_ENABLE |
(R300_GB_TEX_STR << R300_GB_TEX0_SOURCE_SHIFT));
OUT_CS_REG_SEQ(R300_GA_POINT_S0, 4);
- OUT_CS_32F(attrib[0]);
- OUT_CS_32F(attrib[3]);
- OUT_CS_32F(attrib[2]);
- OUT_CS_32F(attrib[1]);
+ OUT_CS_32F(attrib->f[0]);
+ OUT_CS_32F(attrib->f[3]);
+ OUT_CS_32F(attrib->f[2]);
+ OUT_CS_32F(attrib->f[1]);
}
/* Set up VAP controls. */
@@ -1253,8 +1253,8 @@ static void r300_blitter_draw_rectangle(struct blitter_context *blitter,
if (vertex_size == 8) {
if (!attrib)
- attrib = zeros;
- OUT_CS_TABLE(attrib, 4);
+ attrib = &zeros;
+ OUT_CS_TABLE(attrib->f, 4);
}
END_CS;
@@ -1273,7 +1273,7 @@ static void r300_resource_resolve(struct pipe_context *pipe,
struct r300_context *r300 = r300_context(pipe);
struct pipe_surface *srcsurf, *dstsurf, surf_tmpl;
struct r300_aa_state *aa = (struct r300_aa_state*)r300->aa_state.state;
- float color[] = {0, 0, 0, 0};
+ static const union pipe_color_union color;
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
surf_tmpl.format = info->src.res->format;
@@ -1301,7 +1301,7 @@ static void r300_resource_resolve(struct pipe_context *pipe,
/* Resolve the surface. */
/* XXX: y1 < 0 ==> Y flip */
r300->context.clear_render_target(pipe,
- srcsurf, color, 0, 0,
+ srcsurf, &color, 0, 0,
info->dst.x1 - info->dst.x0,
info->dst.y1 - info->dst.y0);
diff --git a/src/gallium/drivers/r600/r600_blit.c b/src/gallium/drivers/r600/r600_blit.c
index 9a71c8447c6..dfc43feb5d9 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -200,28 +200,29 @@ void r600_flush_depth_textures(struct r600_pipe_context *rctx)
}
static void r600_clear(struct pipe_context *ctx, unsigned buffers,
- const float *rgba, double depth, unsigned stencil)
+ const union pipe_color_union *color,
+ double depth, unsigned stencil)
{
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
struct pipe_framebuffer_state *fb = &rctx->framebuffer;
r600_blitter_begin(ctx, R600_CLEAR);
util_blitter_clear(rctx->blitter, fb->width, fb->height,
- fb->nr_cbufs, buffers, rgba, depth,
- stencil);
+ fb->nr_cbufs, buffers, color, depth,
+ stencil);
r600_blitter_end(ctx);
}
static void r600_clear_render_target(struct pipe_context *ctx,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
r600_blitter_begin(ctx, R600_CLEAR_SURFACE);
- util_blitter_clear_render_target(rctx->blitter, dst, rgba,
+ util_blitter_clear_render_target(rctx->blitter, dst, color,
dstx, dsty, width, height);
r600_blitter_end(ctx);
}
diff --git a/src/gallium/drivers/rbug/rbug_context.c b/src/gallium/drivers/rbug/rbug_context.c
index 6e2d6ba1efa..6690c0208bd 100644
--- a/src/gallium/drivers/rbug/rbug_context.c
+++ b/src/gallium/drivers/rbug/rbug_context.c
@@ -873,7 +873,7 @@ rbug_resource_copy_region(struct pipe_context *_pipe,
static void
rbug_clear(struct pipe_context *_pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -883,7 +883,7 @@ rbug_clear(struct pipe_context *_pipe,
pipe_mutex_lock(rb_pipe->call_mutex);
pipe->clear(pipe,
buffers,
- rgba,
+ color,
depth,
stencil);
pipe_mutex_unlock(rb_pipe->call_mutex);
@@ -892,7 +892,7 @@ rbug_clear(struct pipe_context *_pipe,
static void
rbug_clear_render_target(struct pipe_context *_pipe,
struct pipe_surface *_dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -904,7 +904,7 @@ rbug_clear_render_target(struct pipe_context *_pipe,
pipe_mutex_lock(rb_pipe->call_mutex);
pipe->clear_render_target(pipe,
dst,
- rgba,
+ color,
dstx,
dsty,
width,
diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c
index 22e8a2e5817..bfb16be82ac 100644
--- a/src/gallium/drivers/softpipe/sp_clear.c
+++ b/src/gallium/drivers/softpipe/sp_clear.c
@@ -45,7 +45,8 @@
* No masking, no scissor (clear entire buffer).
*/
void
-softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+softpipe_clear(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -67,8 +68,8 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
struct pipe_surface *ps = softpipe->framebuffer.cbufs[i];
- util_pack_color(rgba, ps->format, &uc);
- sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, uc.ui);
+ util_pack_color(color->f, ps->format, &uc);
+ sp_tile_cache_clear(softpipe->cbuf_cache[i], color->f, uc.ui);
}
}
diff --git a/src/gallium/drivers/softpipe/sp_clear.h b/src/gallium/drivers/softpipe/sp_clear.h
index 9be3b86fe9f..6dd7d132fe8 100644
--- a/src/gallium/drivers/softpipe/sp_clear.h
+++ b/src/gallium/drivers/softpipe/sp_clear.h
@@ -35,7 +35,8 @@
struct pipe_context;
extern void
-softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+softpipe_clear(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil);
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index 34b9e85c1a3..f8c1ab40345 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -414,7 +414,7 @@ struct svga_context
*/
void svga_clear(struct pipe_context *pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil);
diff --git a/src/gallium/drivers/svga/svga_pipe_clear.c b/src/gallium/drivers/svga/svga_pipe_clear.c
index 2bba77769ad..d9ff79cc5ee 100644
--- a/src/gallium/drivers/svga/svga_pipe_clear.c
+++ b/src/gallium/drivers/svga/svga_pipe_clear.c
@@ -37,7 +37,7 @@
static enum pipe_error
try_clear(struct svga_context *svga,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -61,7 +61,7 @@ try_clear(struct svga_context *svga,
if ((buffers & PIPE_CLEAR_COLOR) && fb->cbufs[0]) {
flags |= SVGA3D_CLEAR_COLOR;
- util_pack_color(rgba, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
+ util_pack_color(color->f, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
rect.w = fb->cbufs[0]->width;
rect.h = fb->cbufs[0]->height;
@@ -104,7 +104,8 @@ try_clear(struct svga_context *svga,
* No masking, no scissor (clear entire buffer).
*/
void
-svga_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
+svga_clear(struct pipe_context *pipe, unsigned buffers,
+ const union pipe_color_union *color,
double depth, unsigned stencil)
{
struct svga_context *svga = svga_context( pipe );
@@ -114,14 +115,14 @@ svga_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
SVGA_DBG(DEBUG_DMA, "clear sid %p\n",
svga_surface(svga->curr.framebuffer.cbufs[0])->handle);
- ret = try_clear( svga, buffers, rgba, depth, stencil );
+ ret = try_clear( svga, buffers, color, depth, stencil );
if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
/* Flush command buffer and retry:
*/
svga_context_flush( svga, NULL );
- ret = try_clear( svga, buffers, rgba, depth, stencil );
+ ret = try_clear( svga, buffers, color, depth, stencil );
}
/*
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 254976e099c..6021bb92ab6 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1105,7 +1105,7 @@ trace_context_resource_copy_region(struct pipe_context *_pipe,
static INLINE void
trace_context_clear(struct pipe_context *_pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
@@ -1116,14 +1116,14 @@ trace_context_clear(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(uint, buffers);
- if (rgba)
- trace_dump_arg_array(float, rgba, 4);
+ if (color)
+ trace_dump_arg_array(float, color->f, 4);
else
trace_dump_null();
trace_dump_arg(float, depth);
trace_dump_arg(uint, stencil);
- pipe->clear(pipe, buffers, rgba, depth, stencil);
+ pipe->clear(pipe, buffers, color, depth, stencil);
trace_dump_call_end();
}
@@ -1132,7 +1132,7 @@ trace_context_clear(struct pipe_context *_pipe,
static INLINE void
trace_context_clear_render_target(struct pipe_context *_pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height)
{
@@ -1145,13 +1145,13 @@ trace_context_clear_render_target(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, dst);
- trace_dump_arg_array(float, rgba, 4);
+ trace_dump_arg_array(float, color->f, 4);
trace_dump_arg(uint, dstx);
trace_dump_arg(uint, dsty);
trace_dump_arg(uint, width);
trace_dump_arg(uint, height);
- pipe->clear_render_target(pipe, dst, rgba, dstx, dsty, width, height);
+ pipe->clear_render_target(pipe, dst, color, dstx, dsty, width, height);
trace_dump_call_end();
}
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 49c12ec64fb..b2d5f9543e6 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -63,7 +63,7 @@ struct pipe_vertex_element;
struct pipe_video_buffer;
struct pipe_video_decoder;
struct pipe_viewport_state;
-
+union pipe_color_union;
/**
* Gallium rendering context. Basically:
@@ -281,23 +281,23 @@ struct pipe_context {
* The entire buffers are cleared (no scissor, no colormask, etc).
*
* \param buffers bitfield of PIPE_CLEAR_* values.
- * \param rgba pointer to an array of one float for each of r, g, b, a.
+ * \param color pointer to a union of fiu array for each of r, g, b, a.
* \param depth depth clear value in [0,1].
* \param stencil stencil clear value
*/
void (*clear)(struct pipe_context *pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil);
/**
* Clear a color rendertarget surface.
- * \param rgba pointer to an array of one float for each of r, g, b, a.
+ * \param color pointer to an union of fiu array for each of r, g, b, a.
*/
void (*clear_render_target)(struct pipe_context *pipe,
struct pipe_surface *dst,
- const float *rgba,
+ const union pipe_color_union *color,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height);
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 777a177a90f..1773d9d3175 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -515,6 +515,12 @@ struct pipe_query_data_timestamp_disjoint
boolean disjoint;
};
+union pipe_color_union
+{
+ float f[4];
+ int i[4];
+ unsigned int ui[4];
+};
#ifdef __cplusplus
}
diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
index 2bf001261eb..e3329e4d5d3 100644
--- a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
+++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
@@ -1162,7 +1162,7 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX
if(1)
{
unsigned blit_x, blit_y, blit_w, blit_h;
- float black[4] = {0, 0, 0, 0};
+ static const union pipe_color_union black;
if(!formats_compatible || src->width0 != dst_w || src->height0 != dst_h) {
struct pipe_surface templat;
@@ -1205,9 +1205,9 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX
}
if(blit_x)
- pipe->clear_render_target(pipe, dst_surface, black, rect.left, rect.top, blit_x, dst_h);
+ pipe->clear_render_target(pipe, dst_surface, &black, rect.left, rect.top, blit_x, dst_h);
if(blit_y)
- pipe->clear_render_target(pipe, dst_surface, black, rect.left, rect.top, dst_w, blit_y);
+ pipe->clear_render_target(pipe, dst_surface, &black, rect.left, rect.top, dst_w, blit_y);
if(formats_compatible && blit_w == src->width0 && blit_h == src->height0)
{
@@ -1226,9 +1226,9 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX
}
if(blit_w != dst_w)
- pipe->clear_render_target(pipe, dst_surface, black, rect.left + blit_x + blit_w, rect.top, dst_w - blit_x - blit_w, dst_h);
+ pipe->clear_render_target(pipe, dst_surface, &black, rect.left + blit_x + blit_w, rect.top, dst_w - blit_x - blit_w, dst_h);
if(blit_h != dst_h)
- pipe->clear_render_target(pipe, dst_surface, black, rect.left, rect.top + blit_y + blit_h, dst_w, dst_h - blit_y - blit_h);
+ pipe->clear_render_target(pipe, dst_surface, &black, rect.left, rect.top + blit_y + blit_h, dst_w, dst_h - blit_y - blit_h);
}
if(dst_surface)
diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
index d43fdeab963..fcb82a19624 100644
--- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
+++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
@@ -1594,7 +1594,12 @@ changed:
{
SYNCHRONIZED;
GalliumD3D11RenderTargetView* view = ((GalliumD3D11RenderTargetView*)render_target_view);
- pipe->clear_render_target(pipe, view->object, color, 0, 0, view->object->width, view->object->height);
+ union pipe_color_union cc;
+ cc.f[0] = color[0];
+ cc.f[1] = color[1];
+ cc.f[2] = color[2];
+ cc.f[3] = color[3];
+ pipe->clear_render_target(pipe, view->object, &cc, 0, 0, view->object->width, view->object->height);
}
virtual void STDMETHODCALLTYPE ClearDepthStencilView(
diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c
index b30b778aa19..888cf31d5af 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -119,6 +119,7 @@ vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue
VdpColor *const background_color)
{
vlVdpPresentationQueue *pq;
+ union pipe_color_union color;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Setting background color\n");
@@ -129,7 +130,12 @@ vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue
if (!pq)
return VDP_STATUS_INVALID_HANDLE;
- vl_compositor_set_clear_color(&pq->compositor, (float*)background_color);
+ color.f[0] = background_color->red;
+ color.f[1] = background_color->green;
+ color.f[2] = background_color->blue;
+ color.f[3] = background_color->alpha;
+
+ vl_compositor_set_clear_color(&pq->compositor, &color);
return VDP_STATUS_OK;
}
@@ -142,6 +148,7 @@ vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue
VdpColor *const background_color)
{
vlVdpPresentationQueue *pq;
+ union pipe_color_union color;
VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Getting background color\n");
@@ -152,7 +159,12 @@ vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue
if (!pq)
return VDP_STATUS_INVALID_HANDLE;
- vl_compositor_get_clear_color(&pq->compositor, (float*)background_color);
+ vl_compositor_get_clear_color(&pq->compositor, &color);
+
+ background_color->red = color.f[0];
+ background_color->green = color.f[1];
+ background_color->blue = color.f[2];
+ background_color->alpha = color.f[3];
return VDP_STATUS_OK;
}
diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c
index cdbf0026e89..0ddcdfb75c1 100644
--- a/src/gallium/state_trackers/vega/api_masks.c
+++ b/src/gallium/state_trackers/vega/api_masks.c
@@ -92,8 +92,13 @@ void vegaClear(VGint x, VGint y,
/* check for a whole surface clear */
if (!ctx->state.vg.scissoring &&
(x == 0 && y == 0 && width == stfb->width && height == stfb->height)) {
+ union pipe_color_union clear_color;
+ clear_color.f[0] = ctx->state.vg.clear_color[0];
+ clear_color.f[1] = ctx->state.vg.clear_color[1];
+ clear_color.f[2] = ctx->state.vg.clear_color[2];
+ clear_color.f[3] = ctx->state.vg.clear_color[3];
ctx->pipe->clear(ctx->pipe, PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL,
- ctx->state.vg.clear_color, 1., 0);
+ &clear_color, 1., 0);
} else if (renderer_clear_begin(ctx->renderer)) {
/* XXX verify coord round-off */
renderer_clear(ctx->renderer, x, y, width, height, ctx->state.vg.clear_color);
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index b072f53aa91..db0167ba4c4 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -386,7 +386,12 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
if (x0 == 0 && y0 == 0 &&
x1 == pPixmap->drawable.width && y1 == pPixmap->drawable.height) {
- exa->pipe->clear(exa->pipe, PIPE_CLEAR_COLOR, exa->solid_color, 0.0, 0);
+ union pipe_color_union solid_color;
+ solid_color.f[0] = exa->solid_color[0];
+ solid_color.f[1] = exa->solid_color[1];
+ solid_color.f[2] = exa->solid_color[2];
+ solid_color.f[3] = exa->solid_color[3];
+ exa->pipe->clear(exa->pipe, PIPE_CLEAR_COLOR, &solid_color, 0.0, 0);
return;
}
diff --git a/src/gallium/tests/graw/clear.c b/src/gallium/tests/graw/clear.c
index 392d1503f19..9c9eeebe0af 100644
--- a/src/gallium/tests/graw/clear.c
+++ b/src/gallium/tests/graw/clear.c
@@ -26,9 +26,9 @@ static void *window = NULL;
static void draw( void )
{
- float clear_color[4] = {1,0,1,1};
+ union pipe_color_union clear_color = { .f = {1, 0, 1, 1} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
ctx->flush(ctx, NULL);
graw_save_surface_to_file(ctx, surf, NULL);
diff --git a/src/gallium/tests/graw/fs-test.c b/src/gallium/tests/graw/fs-test.c
index fda23bd7c9f..47bc101846f 100644
--- a/src/gallium/tests/graw/fs-test.c
+++ b/src/gallium/tests/graw/fs-test.c
@@ -272,9 +272,9 @@ static void set_fragment_shader( const char *filename )
static void draw( void )
{
- float clear_color[4] = {.1,.3,.5,0};
+ union pipe_color_union clear_color = { .f = {.1,.3,.5,0} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
ctx->flush(ctx, NULL);
diff --git a/src/gallium/tests/graw/gs-test.c b/src/gallium/tests/graw/gs-test.c
index ebb26d2f3f4..511f5d53438 100644
--- a/src/gallium/tests/graw/gs-test.c
+++ b/src/gallium/tests/graw/gs-test.c
@@ -331,9 +331,9 @@ static void set_geometry_shader( void )
static void draw( void )
{
- float clear_color[4] = {.1,.3,.5,0};
+ union pipe_color_union clear_color = { .f = {.1,.3,.5,0} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
if (draw_strip)
util_draw_arrays(ctx, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
else
diff --git a/src/gallium/tests/graw/quad-sample.c b/src/gallium/tests/graw/quad-sample.c
index 6903046cf0e..152e1edb3fd 100644
--- a/src/gallium/tests/graw/quad-sample.c
+++ b/src/gallium/tests/graw/quad-sample.c
@@ -146,9 +146,9 @@ static void set_fragment_shader( void )
static void draw( void )
{
- float clear_color[4] = {.5,.5,.5,1};
+ union pipe_color_union clear_color = { .f = {.5,.5,.5,1} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_arrays(ctx, PIPE_PRIM_QUADS, 0, 4);
ctx->flush(ctx, NULL);
diff --git a/src/gallium/tests/graw/quad-tex.c b/src/gallium/tests/graw/quad-tex.c
index fd01cb3f84f..ca742a699d4 100644
--- a/src/gallium/tests/graw/quad-tex.c
+++ b/src/gallium/tests/graw/quad-tex.c
@@ -143,9 +143,9 @@ static void set_fragment_shader( void )
static void draw( void )
{
- float clear_color[4] = {.5,.5,.5,1};
+ union pipe_color_union clear_color = { .f = {.5,.5,.5,1} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_arrays(ctx, PIPE_PRIM_QUADS, 0, 4);
ctx->flush(ctx, NULL);
diff --git a/src/gallium/tests/graw/shader-leak.c b/src/gallium/tests/graw/shader-leak.c
index 004b1691b6b..098faec5896 100644
--- a/src/gallium/tests/graw/shader-leak.c
+++ b/src/gallium/tests/graw/shader-leak.c
@@ -137,7 +137,7 @@ set_fragment_shader( void )
static void draw( void )
{
- float clear_color[4] = {0, 0, 0, 1};
+ union pipe_color_union clear_color = { .f = {0,0,0,1} };
int i;
printf("Creating %d shaders\n", num_iters);
@@ -147,7 +147,7 @@ static void draw( void )
ctx->bind_fs_state(ctx, fs);
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_arrays(ctx, PIPE_PRIM_POINTS, 0, 1);
ctx->flush(ctx, NULL);
diff --git a/src/gallium/tests/graw/tri-gs.c b/src/gallium/tests/graw/tri-gs.c
index ab0116bed73..3c9e56882e5 100644
--- a/src/gallium/tests/graw/tri-gs.c
+++ b/src/gallium/tests/graw/tri-gs.c
@@ -159,9 +159,9 @@ static void set_geometry_shader( void )
static void draw( void )
{
- float clear_color[4] = {1,0,1,1};
+ union pipe_color_union clear_color = { .f = {1,0,1,1} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
ctx->flush(ctx, NULL);
diff --git a/src/gallium/tests/graw/tri-instanced.c b/src/gallium/tests/graw/tri-instanced.c
index bed34374666..50389e08725 100644
--- a/src/gallium/tests/graw/tri-instanced.c
+++ b/src/gallium/tests/graw/tri-instanced.c
@@ -196,10 +196,10 @@ static void set_fragment_shader( void )
static void draw( void )
{
- float clear_color[4] = {1,0,1,1};
+ union pipe_color_union clear_color = { .f = {1,0,1,1} };
struct pipe_draw_info info;
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_init_info(&info);
info.indexed = (draw_elements != 0);
diff --git a/src/gallium/tests/graw/tri.c b/src/gallium/tests/graw/tri.c
index 30ead999a47..2b779ff8704 100644
--- a/src/gallium/tests/graw/tri.c
+++ b/src/gallium/tests/graw/tri.c
@@ -136,9 +136,9 @@ static void set_fragment_shader( void )
static void draw( void )
{
- float clear_color[4] = {1,0,1,1};
+ union pipe_color_union clear_color = { .f = {1,0,1,1} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
ctx->flush(ctx, NULL);
diff --git a/src/gallium/tests/graw/vs-test.c b/src/gallium/tests/graw/vs-test.c
index 18e056dcb35..b98c8f53562 100644
--- a/src/gallium/tests/graw/vs-test.c
+++ b/src/gallium/tests/graw/vs-test.c
@@ -223,9 +223,9 @@ static void set_fragment_shader( void )
static void draw( void )
{
- float clear_color[4] = {.1,.3,.5,0};
+ union pipe_color_union clear_color = { .f = {.1,.3,.5,0} };
- ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
+ ctx->clear(ctx, PIPE_CLEAR_COLOR, &clear_color, 0, 0);
util_draw_arrays(ctx, PIPE_PRIM_POINTS, 0, Elements(vertices));
ctx->flush(ctx, NULL);
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index 6c38b1096c1..79c66e0e67e 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -82,7 +82,7 @@ struct program
void *vs;
void *fs;
- float clear_color[4];
+ union pipe_color_union clear_color;
struct pipe_resource *vbuf;
struct pipe_resource *target;
@@ -103,10 +103,10 @@ static void init_prog(struct program *p)
p->cso = cso_create_context(p->pipe);
/* set clear color */
- p->clear_color[0] = 0.3;
- p->clear_color[1] = 0.1;
- p->clear_color[2] = 0.3;
- p->clear_color[3] = 1.0;
+ p->clear_color.f[0] = 0.3;
+ p->clear_color.f[1] = 0.1;
+ p->clear_color.f[2] = 0.3;
+ p->clear_color.f[3] = 1.0;
/* vertex buffer */
{
@@ -307,7 +307,7 @@ static void draw(struct program *p)
cso_set_framebuffer(p->cso, &p->framebuffer);
/* clear the render target */
- p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0);
+ p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0);
/* set misc state we care about */
cso_set_blend(p->cso, &p->blend);
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index 656e92ee886..d036db80039 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -79,7 +79,7 @@ struct program
void *vs;
void *fs;
- float clear_color[4];
+ union pipe_color_union clear_color;
struct pipe_resource *vbuf;
struct pipe_resource *target;
@@ -98,10 +98,10 @@ static void init_prog(struct program *p)
p->cso = cso_create_context(p->pipe);
/* set clear color */
- p->clear_color[0] = 0.3;
- p->clear_color[1] = 0.1;
- p->clear_color[2] = 0.3;
- p->clear_color[3] = 1.0;
+ p->clear_color.f[0] = 0.3;
+ p->clear_color.f[1] = 0.1;
+ p->clear_color.f[2] = 0.3;
+ p->clear_color.f[3] = 1.0;
/* vertex buffer */
{
@@ -243,7 +243,7 @@ static void draw(struct program *p)
cso_set_framebuffer(p->cso, &p->framebuffer);
/* clear the render target */
- p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, p->clear_color, 0, 0);
+ p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0);
/* set misc state we care about */
cso_set_blend(p->cso, &p->blend);
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index a4799e3cc92..83802a5ea67 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -136,7 +136,7 @@ set_vertex_shader(struct st_context *st)
static void
draw_quad(struct st_context *st,
float x0, float y0, float x1, float y1, GLfloat z,
- const GLfloat color[4])
+ const union pipe_color_union *color)
{
struct pipe_context *pipe = st->pipe;
@@ -182,10 +182,10 @@ draw_quad(struct st_context *st,
for (i = 0; i < 4; i++) {
st->clear.vertices[i][0][2] = z;
st->clear.vertices[i][0][3] = 1.0;
- st->clear.vertices[i][1][0] = color[0];
- st->clear.vertices[i][1][1] = color[1];
- st->clear.vertices[i][1][2] = color[2];
- st->clear.vertices[i][1][3] = color[3];
+ st->clear.vertices[i][1][0] = color->f[0];
+ st->clear.vertices[i][1][1] = color->f[1];
+ st->clear.vertices[i][1][2] = color->f[2];
+ st->clear.vertices[i][1][3] = color->f[3];
}
/* put vertex data into vbuf */
@@ -227,7 +227,7 @@ clear_with_quad(struct gl_context *ctx,
const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f;
const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f;
const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f;
- float clearColor[4];
+ union pipe_color_union clearColor;
/*
printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__,
@@ -325,11 +325,11 @@ clear_with_quad(struct gl_context *ctx,
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
st_translate_color(ctx->Color.ClearColor.f,
ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- clearColor);
+ clearColor.f);
}
/* draw quad matching scissor rect */
- draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, clearColor);
+ draw_quad(st, x0, y0, x1, y1, (GLfloat) ctx->Depth.Clear, &clearColor);
/* Restore pipe state */
cso_restore_blend(st->cso_context);
@@ -572,7 +572,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
* required from the visual. Hence fix this up to avoid potential
* read-modify-write in the driver.
*/
- float clearColor[4];
+ union pipe_color_union clearColor;
if ((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) &&
((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) &&
@@ -584,10 +584,10 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
st_translate_color(ctx->Color.ClearColor.f,
ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- clearColor);
+ clearColor.f);
}
- st->pipe->clear(st->pipe, clear_buffers, clearColor,
+ st->pipe->clear(st->pipe, clear_buffers, &clearColor,
ctx->Depth.Clear, ctx->Stencil.Clear);
}
if (mask & BUFFER_BIT_ACCUM)