diff options
author | Dave Airlie <[email protected]> | 2011-09-16 09:39:34 +0100 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2011-09-18 15:12:47 +0100 |
commit | 6dd284f7c8fac22f64c13fdf9909094f5ec59086 (patch) | |
tree | 8fe6c89638f05d1638b3a5d0395e011d68eda336 /src/gallium/auxiliary | |
parent | 78026b8acef9d6eea4f37d9c5435447944d1befd (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]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/postprocess/pp_mlaa.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/postprocess/pp_program.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/postprocess/pp_run.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.c | 44 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.h | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_clear.h | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_surface.c | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_surface.h | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_compositor.c | 20 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_compositor.h | 6 |
10 files changed, 44 insertions, 48 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 |