summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c93
-rw-r--r--src/gallium/auxiliary/util/u_blitter.h12
-rw-r--r--src/gallium/drivers/r300/r300_context.h2
-rw-r--r--src/gallium/drivers/r300/r300_render.c14
-rw-r--r--src/gallium/drivers/radeon/r600_pipe_common.c20
-rw-r--r--src/gallium/drivers/radeon/r600_pipe_common.h2
6 files changed, 72 insertions, 71 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 29b4c5b7d88..235e39b9af4 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -740,32 +740,23 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx,
}
static void blitter_set_clear_color(struct blitter_context_priv *ctx,
- const union pipe_color_union *color)
+ const float color[4])
{
int i;
if (color) {
- for (i = 0; i < 4; i++) {
- uint32_t *uiverts = (uint32_t *)ctx->vertices[i][1];
- uiverts[0] = color->ui[0];
- uiverts[1] = color->ui[1];
- uiverts[2] = color->ui[2];
- uiverts[3] = color->ui[3];
- }
+ for (i = 0; i < 4; i++)
+ memcpy(&ctx->vertices[i][1][0], color, sizeof(uint32_t) * 4);
} else {
- for (i = 0; i < 4; i++) {
- ctx->vertices[i][1][0] = 0;
- ctx->vertices[i][1][1] = 0;
- ctx->vertices[i][1][2] = 0;
- ctx->vertices[i][1][3] = 0;
- }
+ for (i = 0; i < 4; i++)
+ memset(&ctx->vertices[i][1][0], 0, sizeof(uint32_t) * 4);
}
}
static void get_texcoords(struct pipe_sampler_view *src,
unsigned src_width0, unsigned src_height0,
int x1, int y1, int x2, int y2, bool uses_txf,
- float out[4])
+ union blitter_attrib *out)
{
unsigned level = src->u.tex.first_level;
bool normalized = !uses_txf &&
@@ -773,32 +764,32 @@ static void get_texcoords(struct pipe_sampler_view *src,
src->texture->nr_samples <= 1;
if (normalized) {
- out[0] = x1 / (float)u_minify(src_width0, level);
- out[1] = y1 / (float)u_minify(src_height0, level);
- out[2] = x2 / (float)u_minify(src_width0, level);
- out[3] = y2 / (float)u_minify(src_height0, level);
+ out->texcoord.x1 = x1 / (float)u_minify(src_width0, level);
+ out->texcoord.y1 = y1 / (float)u_minify(src_height0, level);
+ out->texcoord.x2 = x2 / (float)u_minify(src_width0, level);
+ out->texcoord.y2 = y2 / (float)u_minify(src_height0, level);
} else {
- out[0] = (float) x1;
- out[1] = (float) y1;
- out[2] = (float) x2;
- out[3] = (float) y2;
+ out->texcoord.x1 = x1;
+ out->texcoord.y1 = y1;
+ out->texcoord.x2 = x2;
+ out->texcoord.y2 = y2;
}
}
-static void set_texcoords_in_vertices(const float coord[4],
+static void set_texcoords_in_vertices(const union blitter_attrib *attrib,
float *out, unsigned stride)
{
- out[0] = coord[0]; /*t0.s*/
- out[1] = coord[1]; /*t0.t*/
+ out[0] = attrib->texcoord.x1;
+ out[1] = attrib->texcoord.y1;
out += stride;
- out[0] = coord[2]; /*t1.s*/
- out[1] = coord[1]; /*t1.t*/
+ out[0] = attrib->texcoord.x2;
+ out[1] = attrib->texcoord.y1;
out += stride;
- out[0] = coord[2]; /*t2.s*/
- out[1] = coord[3]; /*t2.t*/
+ out[0] = attrib->texcoord.x2;
+ out[1] = attrib->texcoord.y2;
out += stride;
- out[0] = coord[0]; /*t3.s*/
- out[1] = coord[3]; /*t3.t*/
+ out[0] = attrib->texcoord.x1;
+ out[1] = attrib->texcoord.y2;
}
static void blitter_set_texcoords(struct blitter_context_priv *ctx,
@@ -809,22 +800,22 @@ static void blitter_set_texcoords(struct blitter_context_priv *ctx,
bool uses_txf)
{
unsigned i;
- float coord[4];
+ union blitter_attrib coord;
float face_coord[4][2];
get_texcoords(src, src_width0, src_height0, x1, y1, x2, y2, uses_txf,
- coord);
+ &coord);
if (src->target == PIPE_TEXTURE_CUBE ||
src->target == PIPE_TEXTURE_CUBE_ARRAY) {
- set_texcoords_in_vertices(coord, &face_coord[0][0], 2);
+ set_texcoords_in_vertices(&coord, &face_coord[0][0], 2);
util_map_texcoords2d_onto_cubemap((unsigned)layer % 6,
/* pointer, stride in floats */
&face_coord[0][0], 2,
&ctx->vertices[0][1][0], 8,
false);
} else {
- set_texcoords_in_vertices(coord, &ctx->vertices[0][1][0], 8);
+ set_texcoords_in_vertices(&coord, &ctx->vertices[0][1][0], 8);
}
/* Set the layer. */
@@ -1279,17 +1270,17 @@ static void blitter_draw(struct blitter_context_priv *ctx,
void util_blitter_draw_rectangle(struct blitter_context *blitter,
int x1, int y1, int x2, int y2, float depth,
enum blitter_attrib_type type,
- const union pipe_color_union *attrib)
+ const union blitter_attrib *attrib)
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
switch (type) {
case UTIL_BLITTER_ATTRIB_COLOR:
- blitter_set_clear_color(ctx, attrib);
+ blitter_set_clear_color(ctx, attrib->color);
break;
case UTIL_BLITTER_ATTRIB_TEXCOORD:
- set_texcoords_in_vertices(attrib->f, &ctx->vertices[0][1][0], 8);
+ set_texcoords_in_vertices(attrib, &ctx->vertices[0][1][0], 8);
break;
default:;
@@ -1394,13 +1385,16 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
if (num_layers > 1 && ctx->has_layered) {
blitter_set_common_draw_rect_state(ctx, false, true);
- blitter_set_clear_color(ctx, color);
+ blitter_set_clear_color(ctx, color->f);
blitter_draw(ctx, 0, 0, width, height, depth, num_layers);
}
else {
+ union blitter_attrib attrib;
+
+ memcpy(attrib.color, color->ui, sizeof(color->ui));
blitter_set_common_draw_rect_state(ctx, false, false);
blitter->draw_rectangle(blitter, 0, 0, width, height, (float) depth,
- UTIL_BLITTER_ATTRIB_COLOR, color);
+ UTIL_BLITTER_ATTRIB_COLOR, &attrib);
}
util_blitter_restore_vertex_states(blitter);
@@ -1632,15 +1626,11 @@ static void do_blits(struct blitter_context_priv *ctx,
src_samples <= 1) {
/* Draw the quad with the draw_rectangle callback. */
- /* Set texture coordinates. - use a pipe color union
- * for interface purposes.
- * XXX pipe_color_union is a wrong name since we use that to set
- * texture coordinates too.
- */
- union pipe_color_union coord;
+ /* Set texture coordinates. */
+ union blitter_attrib coord;
get_texcoords(src, src_width0, src_height0, srcbox->x, srcbox->y,
srcbox->x+srcbox->width, srcbox->y+srcbox->height,
- uses_txf, coord.f);
+ uses_txf, &coord);
/* Set framebuffer state. */
if (is_zsbuf) {
@@ -2116,13 +2106,16 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
num_layers = dstsurf->u.tex.last_layer - dstsurf->u.tex.first_layer + 1;
if (num_layers > 1 && ctx->has_layered) {
blitter_set_common_draw_rect_state(ctx, false, true);
- blitter_set_clear_color(ctx, color);
+ blitter_set_clear_color(ctx, color->f);
blitter_draw(ctx, dstx, dsty, dstx+width, dsty+height, 0, num_layers);
}
else {
+ union blitter_attrib attrib;
+
+ memcpy(attrib.color, color->ui, sizeof(color->ui));
blitter_set_common_draw_rect_state(ctx, false, false);
blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
- UTIL_BLITTER_ATTRIB_COLOR, color);
+ UTIL_BLITTER_ATTRIB_COLOR, &attrib);
}
util_blitter_restore_vertex_states(blitter);
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index f38908700e2..8cc588c5300 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -44,6 +44,14 @@ enum blitter_attrib_type {
UTIL_BLITTER_ATTRIB_TEXCOORD
};
+union blitter_attrib {
+ float color[4];
+
+ struct {
+ float x1, y1, x2, y2;
+ } texcoord;
+};
+
struct blitter_context
{
/**
@@ -75,7 +83,7 @@ struct blitter_context
int x1, int y1, int x2, int y2,
float depth,
enum blitter_attrib_type type,
- const union pipe_color_union *color);
+ const union blitter_attrib *attrib);
/* Whether the blitter is running. */
bool running;
@@ -148,7 +156,7 @@ void util_blitter_set_texture_multisample(struct blitter_context *blitter,
void util_blitter_draw_rectangle(struct blitter_context *blitter,
int x1, int y1, int x2, int y2, float depth,
enum blitter_attrib_type type,
- const union pipe_color_union *attrib);
+ const union blitter_attrib *attrib);
/*
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index ce1fab48d5e..a99d50f76c0 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -746,7 +746,7 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
int x1, int y1, int x2, int y2,
float depth,
enum blitter_attrib_type type,
- const union pipe_color_union *attrib);
+ const union blitter_attrib *attrib);
/* r300_state.c */
enum r300_fb_state_change {
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 8eca1438603..e1fabe45035 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -1116,7 +1116,7 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
int x1, int y1, int x2, int y2,
float depth,
enum blitter_attrib_type type,
- const union pipe_color_union *attrib)
+ const union blitter_attrib *attrib)
{
struct r300_context *r300 = r300_context(util_blitter_get_pipe(blitter));
unsigned last_sprite_coord_enable = r300->sprite_coord_enable;
@@ -1126,7 +1126,7 @@ 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);
- static const union pipe_color_union zeros;
+ static const union blitter_attrib zeros;
CS_LOCALS(r300);
/* XXX workaround for a lockup in MSAA resolve on SWTCL chipsets, this
@@ -1161,10 +1161,10 @@ 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->f[0]);
- OUT_CS_32F(attrib->f[3]);
- OUT_CS_32F(attrib->f[2]);
- OUT_CS_32F(attrib->f[1]);
+ OUT_CS_32F(attrib->texcoord.x1);
+ OUT_CS_32F(attrib->texcoord.y2);
+ OUT_CS_32F(attrib->texcoord.x2);
+ OUT_CS_32F(attrib->texcoord.y1);
}
/* Set up VAP controls. */
@@ -1188,7 +1188,7 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
if (vertex_size == 8) {
if (!attrib)
attrib = &zeros;
- OUT_CS_TABLE(attrib->f, 4);
+ OUT_CS_TABLE(attrib->color, 4);
}
END_CS;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index 77c185088c7..1cfab31ea33 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -213,7 +213,7 @@ void r600_gfx_wait_fence(struct r600_common_context *ctx,
void r600_draw_rectangle(struct blitter_context *blitter,
int x1, int y1, int x2, int y2, float depth,
enum blitter_attrib_type type,
- const union pipe_color_union *attrib)
+ const union blitter_attrib *attrib)
{
struct r600_common_context *rctx =
(struct r600_common_context*)util_blitter_get_pipe(blitter);
@@ -261,17 +261,17 @@ void r600_draw_rectangle(struct blitter_context *blitter,
switch (type) {
case UTIL_BLITTER_ATTRIB_COLOR:
- memcpy(vb+4, attrib->f, sizeof(float)*4);
- memcpy(vb+12, attrib->f, sizeof(float)*4);
- memcpy(vb+20, attrib->f, sizeof(float)*4);
+ memcpy(vb+4, attrib->color, sizeof(float)*4);
+ memcpy(vb+12, attrib->color, sizeof(float)*4);
+ memcpy(vb+20, attrib->color, sizeof(float)*4);
break;
case UTIL_BLITTER_ATTRIB_TEXCOORD:
- vb[4] = attrib->f[0]; /* x1 */
- vb[5] = attrib->f[1]; /* y1 */
- vb[12] = attrib->f[0]; /* x1 */
- vb[13] = attrib->f[3]; /* y2 */
- vb[20] = attrib->f[2]; /* x2 */
- vb[21] = attrib->f[1]; /* y1 */
+ vb[4] = attrib->texcoord.x1;
+ vb[5] = attrib->texcoord.y1;
+ vb[12] = attrib->texcoord.x1;
+ vb[13] = attrib->texcoord.y2;
+ vb[20] = attrib->texcoord.x2;
+ vb[21] = attrib->texcoord.y1;
break;
default:; /* Nothing to do. */
}
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 42480ec84b0..48536723b6c 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -767,7 +767,7 @@ void r600_gfx_wait_fence(struct r600_common_context *ctx,
void r600_draw_rectangle(struct blitter_context *blitter,
int x1, int y1, int x2, int y2, float depth,
enum blitter_attrib_type type,
- const union pipe_color_union *attrib);
+ const union blitter_attrib *attrib);
bool r600_common_screen_init(struct r600_common_screen *rscreen,
struct radeon_winsys *ws);
void r600_destroy_common_screen(struct r600_common_screen *rscreen);