Commit d86ad382 authored by Thomas Hellstrom's avatar Thomas Hellstrom

st/xa: Render update. Better support for solid pictures

Remove unused and obsolete code for gradients and component-alpha
Support solid source- and mask pictures using a variable number
of samplers in the composite pipeline rather than the fixed number
we used before.

Tested using rendercheck for XA.
Signed-off-by: 's avatarThomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent 4bba2809
......@@ -308,7 +308,7 @@ xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst,
xa_pixel_to_float4_a8(fg, ctx->solid_color);
else
xa_pixel_to_float4(fg, ctx->solid_color);
ctx->has_solid_color = 1;
ctx->has_solid_src = 1;
ctx->dst = dst;
......@@ -320,8 +320,8 @@ xa_solid_prepare(struct xa_context *ctx, struct xa_surface *dst,
exa->solid_color[2], exa->solid_color[3]);
#endif
vs_traits = VS_SOLID_FILL;
fs_traits = FS_SOLID_FILL;
vs_traits = VS_SRC_SRC | VS_COMPOSITE;
fs_traits = FS_SRC_SRC | VS_COMPOSITE;
renderer_bind_destination(ctx, ctx->srf);
bind_solid_blend_state(ctx);
......@@ -342,7 +342,7 @@ XA_EXPORT void
xa_solid(struct xa_context *ctx, int x, int y, int width, int height)
{
xa_scissor_update(ctx, x, y, x + width, y + height);
renderer_solid(ctx, x, y, x + width, y + height, ctx->solid_color);
renderer_solid(ctx, x, y, x + width, y + height);
}
XA_EXPORT void
......@@ -350,7 +350,7 @@ xa_solid_done(struct xa_context *ctx)
{
renderer_draw_flush(ctx);
ctx->comp = NULL;
ctx->has_solid_color = FALSE;
ctx->has_solid_src = FALSE;
ctx->num_bound_samplers = 0;
}
......
......@@ -113,7 +113,8 @@ struct xa_context {
int simple_copy;
int has_solid_color;
int has_solid_src;
int has_solid_mask;
float solid_color[4];
unsigned int num_bound_samplers;
......@@ -145,35 +146,26 @@ xa_scissor_update(struct xa_context *ctx, unsigned minx, unsigned miny,
enum xa_vs_traits {
VS_COMPOSITE = 1 << 0,
VS_MASK = 1 << 1,
VS_SOLID_FILL = 1 << 2,
VS_LINGRAD_FILL = 1 << 3,
VS_RADGRAD_FILL = 1 << 4,
VS_YUV = 1 << 5,
VS_FILL = (VS_SOLID_FILL | VS_LINGRAD_FILL | VS_RADGRAD_FILL)
VS_SRC_SRC = 1 << 2,
VS_MASK_SRC = 1 << 3,
VS_YUV = 1 << 4,
};
enum xa_fs_traits {
FS_COMPOSITE = 1 << 0,
FS_MASK = 1 << 1,
FS_SOLID_FILL = 1 << 2,
FS_LINGRAD_FILL = 1 << 3,
FS_RADGRAD_FILL = 1 << 4,
FS_CA_FULL = 1 << 5, /* src.rgba * mask.rgba */
FS_CA_SRCALPHA = 1 << 6, /* src.aaaa * mask.rgba */
FS_YUV = 1 << 7,
FS_SRC_REPEAT_NONE = 1 << 8,
FS_MASK_REPEAT_NONE = 1 << 9,
FS_SRC_SWIZZLE_RGB = 1 << 10,
FS_MASK_SWIZZLE_RGB = 1 << 11,
FS_SRC_SET_ALPHA = 1 << 12,
FS_MASK_SET_ALPHA = 1 << 13,
FS_SRC_LUMINANCE = 1 << 14,
FS_MASK_LUMINANCE = 1 << 15,
FS_DST_LUMINANCE = 1 << 16,
FS_FILL = (FS_SOLID_FILL | FS_LINGRAD_FILL | FS_RADGRAD_FILL),
FS_COMPONENT_ALPHA = (FS_CA_FULL | FS_CA_SRCALPHA)
FS_SRC_SRC = 1 << 2,
FS_MASK_SRC = 1 << 3,
FS_YUV = 1 << 4,
FS_SRC_REPEAT_NONE = 1 << 5,
FS_MASK_REPEAT_NONE = 1 << 6,
FS_SRC_SWIZZLE_RGB = 1 << 7,
FS_MASK_SWIZZLE_RGB = 1 << 8,
FS_SRC_SET_ALPHA = 1 << 9,
FS_MASK_SET_ALPHA = 1 << 10,
FS_SRC_LUMINANCE = 1 << 11,
FS_MASK_LUMINANCE = 1 << 12,
FS_DST_LUMINANCE = 1 << 13,
};
struct xa_shader {
......@@ -282,7 +274,7 @@ void renderer_draw_flush(struct xa_context *r);
void renderer_begin_solid(struct xa_context *r);
void renderer_solid(struct xa_context *r,
int x0, int y0, int x1, int y1, float *color);
int x0, int y0, int x1, int y1);
void
renderer_begin_textures(struct xa_context *r);
......
......@@ -137,7 +137,7 @@ renderer_init_state(struct xa_context *r)
}
static inline void
add_vertex_color(struct xa_context *r, float x, float y, float color[4])
add_vertex_none(struct xa_context *r, float x, float y)
{
float *vertex = r->buffer + r->buffer_size;
......@@ -146,12 +146,7 @@ add_vertex_color(struct xa_context *r, float x, float y, float color[4])
vertex[2] = 0.f; /*z */
vertex[3] = 1.f; /*w */
vertex[4] = color[0]; /*r */
vertex[5] = color[1]; /*g */
vertex[6] = color[2]; /*b */
vertex[7] = color[3]; /*a */
r->buffer_size += 8;
r->buffer_size += 4;
}
static inline void
......@@ -554,27 +549,29 @@ void
renderer_begin_solid(struct xa_context *r)
{
r->buffer_size = 0;
r->attrs_per_vertex = 2;
r->attrs_per_vertex = 1;
renderer_set_constants(r, PIPE_SHADER_FRAGMENT, r->solid_color,
4 * sizeof(float));
}
void
renderer_solid(struct xa_context *r,
int x0, int y0, int x1, int y1, float *color)
int x0, int y0, int x1, int y1)
{
/*
* debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n",
* x0, y0, x1, y1, color[0], color[1], color[2], color[3]); */
renderer_draw_conditional(r, 4 * 8);
renderer_draw_conditional(r, 4 * 4);
/* 1st vertex */
add_vertex_color(r, x0, y0, color);
add_vertex_none(r, x0, y0);
/* 2nd vertex */
add_vertex_color(r, x1, y0, color);
add_vertex_none(r, x1, y0);
/* 3rd vertex */
add_vertex_color(r, x1, y1, color);
add_vertex_none(r, x1, y1);
/* 4th vertex */
add_vertex_color(r, x0, y1, color);
add_vertex_none(r, x0, y1);
}
void
......@@ -588,6 +585,9 @@ renderer_begin_textures(struct xa_context *r)
{
r->attrs_per_vertex = 1 + r->num_bound_samplers;
r->buffer_size = 0;
if (r->has_solid_src || r->has_solid_mask)
renderer_set_constants(r, PIPE_SHADER_FRAGMENT, r->solid_color,
4 * sizeof(float));
}
void
......@@ -617,11 +617,19 @@ renderer_texture(struct xa_context *r,
switch(r->attrs_per_vertex) {
case 2:
renderer_draw_conditional(r, 4 * 8);
add_vertex_data1(r,
pos[0], pos[1], /* src */
pos[4], pos[5], /* dst */
width, height,
sampler_view[0]->texture, src_matrix);
if (!r->has_solid_src) {
add_vertex_data1(r,
pos[0], pos[1], /* src */
pos[4], pos[5], /* dst */
width, height,
sampler_view[0]->texture, src_matrix);
} else {
add_vertex_data1(r,
pos[2], pos[3], /* mask */
pos[4], pos[5], /* dst */
width, height,
sampler_view[0]->texture, mask_matrix);
}
break;
case 3:
renderer_draw_conditional(r, 4 * 12);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment