aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c181
-rw-r--r--src/gallium/auxiliary/util/u_blitter.h5
-rw-r--r--src/gallium/drivers/r300/r300_render.c7
-rw-r--r--src/gallium/drivers/radeon/r600_pipe_common.c6
4 files changed, 107 insertions, 92 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index fff598d61e2..f7606a6a1d0 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -755,8 +755,9 @@ static void blitter_set_clear_color(struct blitter_context_priv *ctx,
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,
- union blitter_attrib *out)
+ int x1, int y1, int x2, int y2,
+ float layer, unsigned sample,
+ bool uses_txf, union blitter_attrib *out)
{
unsigned level = src->u.tex.first_level;
bool normalized = !uses_txf &&
@@ -774,49 +775,9 @@ static void get_texcoords(struct pipe_sampler_view *src,
out->texcoord.x2 = x2;
out->texcoord.y2 = y2;
}
-}
-static void set_texcoords_in_vertices(const union blitter_attrib *attrib,
- float *out, unsigned stride)
-{
- out[0] = attrib->texcoord.x1;
- out[1] = attrib->texcoord.y1;
- out += stride;
- out[0] = attrib->texcoord.x2;
- out[1] = attrib->texcoord.y1;
- out += stride;
- out[0] = attrib->texcoord.x2;
- out[1] = attrib->texcoord.y2;
- out += stride;
- out[0] = attrib->texcoord.x1;
- out[1] = attrib->texcoord.y2;
-}
-
-static void blitter_set_texcoords(struct blitter_context_priv *ctx,
- struct pipe_sampler_view *src,
- unsigned src_width0, unsigned src_height0,
- float layer, unsigned sample,
- int x1, int y1, int x2, int y2,
- bool uses_txf)
-{
- unsigned i;
- union blitter_attrib coord;
- float face_coord[4][2];
-
- get_texcoords(src, src_width0, src_height0, x1, y1, x2, y2, uses_txf,
- &coord);
-
- if (src->target == PIPE_TEXTURE_CUBE ||
- src->target == PIPE_TEXTURE_CUBE_ARRAY) {
- 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);
- }
+ out->texcoord.z = 0;
+ out->texcoord.w = 0;
/* Set the layer. */
switch (src->target) {
@@ -827,32 +788,25 @@ static void blitter_set_texcoords(struct blitter_context_priv *ctx,
if (!uses_txf)
r /= u_minify(src->texture->depth0, src->u.tex.first_level);
- for (i = 0; i < 4; i++)
- ctx->vertices[i][1][2] = r; /*r*/
+ out->texcoord.z = r;
}
break;
case PIPE_TEXTURE_1D_ARRAY:
- for (i = 0; i < 4; i++)
- ctx->vertices[i][1][1] = (float) layer; /*t*/
+ out->texcoord.y1 = out->texcoord.y2 = layer;
break;
case PIPE_TEXTURE_2D_ARRAY:
- for (i = 0; i < 4; i++) {
- ctx->vertices[i][1][2] = (float) layer; /*r*/
- ctx->vertices[i][1][3] = (float) sample; /*q*/
- }
+ out->texcoord.z = layer;
+ out->texcoord.w = sample;
break;
case PIPE_TEXTURE_CUBE_ARRAY:
- for (i = 0; i < 4; i++)
- ctx->vertices[i][1][3] = (float) ((unsigned)layer / 6); /*w*/
+ out->texcoord.w = (unsigned)layer / 6;
break;
case PIPE_TEXTURE_2D:
- for (i = 0; i < 4; i++) {
- ctx->vertices[i][1][3] = (float) sample; /*r*/
- }
+ out->texcoord.w = sample;
break;
default:;
@@ -866,6 +820,22 @@ static void blitter_set_dst_dimensions(struct blitter_context_priv *ctx,
ctx->dst_height = height;
}
+static void set_texcoords_in_vertices(const union blitter_attrib *attrib,
+ float *out, unsigned stride)
+{
+ out[0] = attrib->texcoord.x1;
+ out[1] = attrib->texcoord.y1;
+ out += stride;
+ out[0] = attrib->texcoord.x2;
+ out[1] = attrib->texcoord.y1;
+ out += stride;
+ out[0] = attrib->texcoord.x2;
+ out[1] = attrib->texcoord.y2;
+ out += stride;
+ out[0] = attrib->texcoord.x1;
+ out[1] = attrib->texcoord.y2;
+}
+
static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
enum pipe_format src_format,
enum pipe_format dst_format,
@@ -1274,13 +1244,20 @@ void util_blitter_draw_rectangle(struct blitter_context *blitter,
const union blitter_attrib *attrib)
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
+ unsigned i;
switch (type) {
case UTIL_BLITTER_ATTRIB_COLOR:
blitter_set_clear_color(ctx, attrib->color);
break;
- case UTIL_BLITTER_ATTRIB_TEXCOORD:
+ case UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW:
+ for (i = 0; i < 4; i++) {
+ ctx->vertices[i][1][2] = attrib->texcoord.z;
+ ctx->vertices[i][1][3] = attrib->texcoord.w;
+ }
+ /* fall through */
+ case UTIL_BLITTER_ATTRIB_TEXCOORD_XY:
set_texcoords_in_vertices(attrib, &ctx->vertices[0][1][0], 8);
break;
@@ -1597,6 +1574,42 @@ void util_blitter_copy_texture(struct blitter_context *blitter,
pipe_sampler_view_reference(&src_view, NULL);
}
+static void
+blitter_draw_tex(struct blitter_context_priv *ctx,
+ int dst_x1, int dst_y1, int dst_x2, int dst_y2,
+ struct pipe_sampler_view *src,
+ unsigned src_width0, unsigned src_height0,
+ int src_x1, int src_y1, int src_x2, int src_y2,
+ float layer, unsigned sample,
+ bool uses_txf, enum blitter_attrib_type type)
+{
+ union blitter_attrib coord;
+
+ get_texcoords(src, src_width0, src_height0,
+ src_x1, src_y1, src_x2, src_y2, layer, sample,
+ uses_txf, &coord);
+
+ if (src->target == PIPE_TEXTURE_CUBE ||
+ src->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ float face_coord[4][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);
+ for (unsigned i = 0; i < 4; i++)
+ ctx->vertices[i][1][3] = coord.texcoord.w;
+
+ /* Cubemaps don't use draw_rectangle. */
+ blitter_draw(ctx, dst_x1, dst_y1, dst_x2, dst_y2, 0, 1);
+ } else {
+ ctx->base.draw_rectangle(&ctx->base, dst_x1, dst_y1, dst_x2, dst_y2, 0,
+ 1, type, &coord);
+ }
+}
+
static void do_blits(struct blitter_context_priv *ctx,
struct pipe_surface *dst,
const struct pipe_box *dstbox,
@@ -1624,14 +1637,6 @@ static void do_blits(struct blitter_context_priv *ctx,
src_target == PIPE_TEXTURE_2D ||
src_target == PIPE_TEXTURE_RECT) &&
src_samples <= 1) {
- /* Draw the quad with the draw_rectangle callback. */
-
- /* 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);
-
/* Set framebuffer state. */
if (is_zsbuf) {
fb_state.zsbuf = dst;
@@ -1642,10 +1647,12 @@ static void do_blits(struct blitter_context_priv *ctx,
/* Draw. */
pipe->set_sample_mask(pipe, ~0);
- ctx->base.draw_rectangle(&ctx->base, dstbox->x, dstbox->y,
- dstbox->x + dstbox->width,
- dstbox->y + dstbox->height, 0, 1,
- UTIL_BLITTER_ATTRIB_TEXCOORD, &coord);
+ blitter_draw_tex(ctx, dstbox->x, dstbox->y,
+ dstbox->x + dstbox->width,
+ dstbox->y + dstbox->height,
+ src, src_width0, src_height0, srcbox->x, srcbox->y,
+ srcbox->x + srcbox->width, srcbox->y + srcbox->height,
+ 0, 0, uses_txf, UTIL_BLITTER_ATTRIB_TEXCOORD_XY);
} else {
/* Draw the quad with the generic codepath. */
int dst_z;
@@ -1689,26 +1696,28 @@ static void do_blits(struct blitter_context_priv *ctx,
for (i = 0; i <= max_sample; i++) {
pipe->set_sample_mask(pipe, 1 << i);
- blitter_set_texcoords(ctx, src, src_width0, src_height0,
- srcbox->z + src_z,
- i, srcbox->x, srcbox->y,
- srcbox->x + srcbox->width,
- srcbox->y + srcbox->height, uses_txf);
- blitter_draw(ctx, dstbox->x, dstbox->y,
- dstbox->x + dstbox->width,
- dstbox->y + dstbox->height, 0, 1);
+ blitter_draw_tex(ctx, dstbox->x, dstbox->y,
+ dstbox->x + dstbox->width,
+ dstbox->y + dstbox->height,
+ src, src_width0, src_height0,
+ srcbox->x, srcbox->y,
+ srcbox->x + srcbox->width,
+ srcbox->y + srcbox->height,
+ srcbox->z + src_z, i, uses_txf,
+ UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW);
}
} else {
/* Normal copy, MSAA upsampling, or MSAA resolve. */
pipe->set_sample_mask(pipe, ~0);
- blitter_set_texcoords(ctx, src, src_width0, src_height0,
- srcbox->z + src_z, 0,
- srcbox->x, srcbox->y,
- srcbox->x + srcbox->width,
- srcbox->y + srcbox->height, uses_txf);
- blitter_draw(ctx, dstbox->x, dstbox->y,
- dstbox->x + dstbox->width,
- dstbox->y + dstbox->height, 0, 1);
+ blitter_draw_tex(ctx, dstbox->x, dstbox->y,
+ dstbox->x + dstbox->width,
+ dstbox->y + dstbox->height,
+ src, src_width0, src_height0,
+ srcbox->x, srcbox->y,
+ srcbox->x + srcbox->width,
+ srcbox->y + srcbox->height,
+ srcbox->z + src_z, 0, uses_txf,
+ UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW);
}
/* Get the next surface or (if this is the last iteration)
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index b335de0ef58..626d46aae47 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -41,14 +41,15 @@ struct pipe_context;
enum blitter_attrib_type {
UTIL_BLITTER_ATTRIB_NONE,
UTIL_BLITTER_ATTRIB_COLOR,
- UTIL_BLITTER_ATTRIB_TEXCOORD
+ UTIL_BLITTER_ATTRIB_TEXCOORD_XY,
+ UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW,
};
union blitter_attrib {
float color[4];
struct {
- float x1, y1, x2, y2;
+ float x1, y1, x2, y2, z, w;
} texcoord;
};
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 1f896da22e9..ddd24523ca6 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -1125,13 +1125,14 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
unsigned vertex_size =
type == UTIL_BLITTER_ATTRIB_COLOR || !r300->draw ? 8 : 4;
unsigned dwords = 13 + vertex_size +
- (type == UTIL_BLITTER_ATTRIB_TEXCOORD ? 7 : 0);
+ (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY ? 7 : 0);
static const union blitter_attrib zeros;
CS_LOCALS(r300);
/* XXX workaround for a lockup in MSAA resolve on SWTCL chipsets, this
* function most probably doesn't handle type=NONE correctly */
if ((!r300->screen->caps.has_tcl && type == UTIL_BLITTER_ATTRIB_NONE) ||
+ type == UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW ||
num_instances > 1) {
util_blitter_draw_rectangle(blitter, x1, y1, x2, y2, depth,
num_instances, type, attrib);
@@ -1141,7 +1142,7 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
if (r300->skip_rendering)
return;
- if (type == UTIL_BLITTER_ATTRIB_TEXCOORD)
+ if (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY)
r300->sprite_coord_enable = 1;
r300_update_derived_state(r300);
@@ -1158,7 +1159,7 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
/* Set up GA. */
OUT_CS_REG(R300_GA_POINT_SIZE, (height * 6) | ((width * 6) << 16));
- if (type == UTIL_BLITTER_ATTRIB_TEXCOORD) {
+ if (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY) {
/* Set up the GA to generate texcoords. */
OUT_CS_REG(R300_GB_ENABLE, R300_GB_POINT_STUFF_ENABLE |
(R300_GB_TEX_STR << R300_GB_TEX0_SOURCE_SHIFT));
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c
index f5f15246176..72553292f59 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -266,7 +266,11 @@ void r600_draw_rectangle(struct blitter_context *blitter,
memcpy(vb+12, attrib->color, sizeof(float)*4);
memcpy(vb+20, attrib->color, sizeof(float)*4);
break;
- case UTIL_BLITTER_ATTRIB_TEXCOORD:
+ case UTIL_BLITTER_ATTRIB_TEXCOORD_XYZW:
+ vb[6] = vb[14] = vb[22] = attrib->texcoord.z;
+ vb[7] = vb[15] = vb[23] = attrib->texcoord.w;
+ /* fall through */
+ case UTIL_BLITTER_ATTRIB_TEXCOORD_XY:
vb[4] = attrib->texcoord.x1;
vb[5] = attrib->texcoord.y1;
vb[12] = attrib->texcoord.x1;