[Mesa-dev] [PATCH 04/12] gallium/u_blitter: let drivers set the vertex elements state
Marek Olšák
maraeo at gmail.com
Fri Oct 6 14:10:07 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
radeonsi won't set it.
---
src/gallium/auxiliary/util/u_blitter.c | 54 ++++++++++++++--------------
src/gallium/auxiliary/util/u_blitter.h | 2 ++
src/gallium/drivers/r300/r300_context.h | 1 +
src/gallium/drivers/r300/r300_render.c | 7 ++--
src/gallium/drivers/r600/r600_pipe_common.c | 3 ++
src/gallium/drivers/r600/r600_pipe_common.h | 1 +
src/gallium/drivers/radeonsi/si_state.h | 1 +
src/gallium/drivers/radeonsi/si_state_draw.c | 4 +++
8 files changed, 45 insertions(+), 28 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 9153ae1..ec03e5f 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -1230,43 +1230,46 @@ static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx,
pipe->bind_gs_state(pipe, NULL);
if (ctx->has_tessellation) {
pipe->bind_tcs_state(pipe, NULL);
pipe->bind_tes_state(pipe, NULL);
}
if (ctx->has_stream_out)
pipe->set_stream_output_targets(pipe, 0, NULL, NULL);
}
static void blitter_draw(struct blitter_context_priv *ctx,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2, float depth,
unsigned num_instances)
{
struct pipe_context *pipe = ctx->base.pipe;
struct pipe_vertex_buffer vb = {0};
blitter_set_rectangle(ctx, x1, y1, x2, y2, depth);
vb.stride = 8 * sizeof(float);
u_upload_data(pipe->stream_uploader, 0, sizeof(ctx->vertices), 4, ctx->vertices,
&vb.buffer_offset, &vb.buffer.resource);
if (!vb.buffer.resource)
return;
u_upload_unmap(pipe->stream_uploader);
pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &vb);
+ pipe->bind_vertex_elements_state(pipe, vertex_elements_cso);
util_draw_arrays_instanced(pipe, PIPE_PRIM_TRIANGLE_FAN, 0, 4,
0, num_instances);
pipe_resource_reference(&vb.buffer.resource, NULL);
}
void util_blitter_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
const union blitter_attrib *attrib)
{
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
unsigned i;
switch (type) {
case UTIL_BLITTER_ATTRIB_COLOR:
@@ -1279,21 +1282,21 @@ void util_blitter_draw_rectangle(struct blitter_context *blitter,
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;
default:;
}
- blitter_draw(ctx, x1, y1, x2, y2, depth, num_instances);
+ blitter_draw(ctx, vertex_elements_cso, x1, y1, x2, y2, depth, num_instances);
}
static void *get_clear_blend_state(struct blitter_context_priv *ctx,
unsigned clear_buffers)
{
struct pipe_context *pipe = ctx->base.pipe;
int index;
clear_buffers &= PIPE_CLEAR_COLOR;
@@ -1373,38 +1376,37 @@ static void util_blitter_clear_custom(struct blitter_context *blitter,
struct pipe_stencil_ref sr = { { 0 } };
assert(ctx->has_layered || num_layers <= 1);
util_blitter_common_clear_setup(blitter, width, height, clear_buffers,
custom_blend, custom_dsa);
sr.ref_value[0] = stencil & 0xff;
pipe->set_stencil_ref(pipe, &sr);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
bind_fs_write_all_cbufs(ctx);
union blitter_attrib attrib;
memcpy(attrib.color, color->ui, sizeof(color->ui));
bool pass_generic = (clear_buffers & PIPE_CLEAR_COLOR) != 0;
enum blitter_attrib_type type = pass_generic ? UTIL_BLITTER_ATTRIB_COLOR :
UTIL_BLITTER_ATTRIB_NONE;
if (num_layers > 1 && ctx->has_layered) {
blitter_set_common_draw_rect_state(ctx, false, true, pass_generic);
- blitter->draw_rectangle(blitter, 0, 0, width, height, (float) depth,
- num_layers, type, &attrib);
+ blitter->draw_rectangle(blitter, ctx->velem_state, 0, 0, width, height,
+ (float) depth, num_layers, type, &attrib);
} else {
blitter_set_common_draw_rect_state(ctx, false, false, pass_generic);
- blitter->draw_rectangle(blitter, 0, 0, width, height, (float) depth,
- 1, type, &attrib);
+ blitter->draw_rectangle(blitter, ctx->velem_state, 0, 0, width, height,
+ (float) depth, 1, type, &attrib);
}
util_blitter_restore_vertex_states(blitter);
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_render_cond(blitter);
util_blitter_unset_running_flag(blitter);
}
void util_blitter_clear(struct blitter_context *blitter,
unsigned width, unsigned height, unsigned num_layers,
@@ -1622,24 +1624,26 @@ blitter_draw_tex(struct blitter_context_priv *ctx,
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);
+ blitter_draw(ctx, ctx->velem_state,
+ 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);
+ ctx->base.draw_rectangle(&ctx->base, ctx->velem_state,
+ 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,
struct pipe_sampler_view *src,
unsigned src_width0,
unsigned src_height0,
const struct pipe_box *srcbox,
@@ -1931,21 +1935,20 @@ void util_blitter_blit_generic(struct blitter_context *blitter,
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
0, 1, &sampler_state);
pipe_sampler_view_reference(&view, NULL);
} else {
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 1, &src);
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
0, 1, &sampler_state);
}
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
if (scissor) {
pipe->set_scissor_states(pipe, 0, 1, scissor);
}
blitter_set_common_draw_rect_state(ctx, scissor != NULL, false, true);
do_blits(ctx, dst, dstbox, src, src_width0, src_height0,
srcbox, blit_depth || blit_stencil, use_txf);
util_blitter_restore_vertex_states(blitter);
@@ -2042,21 +2045,20 @@ void util_blitter_generate_mipmap(struct blitter_context *blitter,
}
if (target == PIPE_TEXTURE_RECT) {
sampler_state = ctx->sampler_state_rect_linear;
} else {
sampler_state = ctx->sampler_state_linear;
}
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
0, 1, &sampler_state);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
blitter_set_common_draw_rect_state(ctx, false, false, true);
for (src_level = base_level; src_level < last_level; src_level++) {
struct pipe_box dstbox = {0}, srcbox = {0};
unsigned dst_level = src_level + 1;
dstbox.width = u_minify(tex->width0, dst_level);
dstbox.height = u_minify(tex->height0, dst_level);
srcbox.width = u_minify(tex->width0, src_level);
@@ -2118,44 +2120,45 @@ void util_blitter_clear_render_target(struct blitter_context *blitter,
util_blitter_set_running_flag(blitter);
blitter_check_saved_vertex_states(ctx);
blitter_check_saved_fragment_states(ctx);
blitter_check_saved_fb_state(ctx);
blitter_disable_render_cond(ctx);
/* bind states */
pipe->bind_blend_state(pipe, ctx->blend[PIPE_MASK_RGBA][0]);
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
bind_fs_write_one_cbuf(ctx);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
fb_state.width = dstsurf->width;
fb_state.height = dstsurf->height;
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dstsurf;
fb_state.zsbuf = 0;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
union blitter_attrib attrib;
memcpy(attrib.color, color->ui, sizeof(color->ui));
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, true);
- blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
+ blitter->draw_rectangle(blitter, ctx->velem_state,
+ dstx, dsty, dstx+width, dsty+height, 0,
num_layers, UTIL_BLITTER_ATTRIB_COLOR, &attrib);
} else {
blitter_set_common_draw_rect_state(ctx, false, false, true);
- blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height, 0,
+ blitter->draw_rectangle(blitter, ctx->velem_state,
+ dstx, dsty, dstx+width, dsty+height, 0,
1, UTIL_BLITTER_ATTRIB_COLOR, &attrib);
}
util_blitter_restore_vertex_states(blitter);
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_fb_state(blitter);
util_blitter_restore_render_cond(blitter);
util_blitter_unset_running_flag(blitter);
}
@@ -2198,43 +2201,42 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter,
else if (clear_flags & PIPE_CLEAR_STENCIL) {
sr.ref_value[0] = stencil & 0xff;
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_write_stencil);
pipe->set_stencil_ref(pipe, &sr);
}
else
/* hmm that should be illegal probably, or make it a no-op somewhere */
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
bind_fs_empty(ctx);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
fb_state.width = dstsurf->width;
fb_state.height = dstsurf->height;
fb_state.nr_cbufs = 0;
fb_state.cbufs[0] = 0;
fb_state.zsbuf = dstsurf;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
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, false);
- blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height,
- depth, num_layers,
- UTIL_BLITTER_ATTRIB_NONE, NULL);
+ blitter->draw_rectangle(blitter, ctx->velem_state,
+ dstx, dsty, dstx+width, dsty+height, depth,
+ num_layers, UTIL_BLITTER_ATTRIB_NONE, NULL);
} else {
blitter_set_common_draw_rect_state(ctx, false, false, false);
- blitter->draw_rectangle(blitter, dstx, dsty, dstx+width, dsty+height,
- depth, 1,
+ blitter->draw_rectangle(blitter, ctx->velem_state,
+ dstx, dsty, dstx+width, dsty+height, depth, 1,
UTIL_BLITTER_ATTRIB_NONE, NULL);
}
util_blitter_restore_vertex_states(blitter);
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_fb_state(blitter);
util_blitter_restore_render_cond(blitter);
util_blitter_unset_running_flag(blitter);
}
@@ -2261,40 +2263,40 @@ void util_blitter_custom_depth_stencil(struct blitter_context *blitter,
blitter_disable_render_cond(ctx);
/* bind states */
pipe->bind_blend_state(pipe, cbsurf ? ctx->blend[PIPE_MASK_RGBA][0] :
ctx->blend[0][0]);
pipe->bind_depth_stencil_alpha_state(pipe, dsa_stage);
if (cbsurf)
bind_fs_write_one_cbuf(ctx);
else
bind_fs_empty(ctx);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
/* set a framebuffer state */
fb_state.width = zsurf->width;
fb_state.height = zsurf->height;
fb_state.nr_cbufs = 1;
if (cbsurf) {
fb_state.cbufs[0] = cbsurf;
fb_state.nr_cbufs = 1;
} else {
fb_state.cbufs[0] = NULL;
fb_state.nr_cbufs = 0;
}
fb_state.zsbuf = zsurf;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, sample_mask);
blitter_set_common_draw_rect_state(ctx, false, false, false);
blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height);
- blitter->draw_rectangle(blitter, 0, 0, zsurf->width, zsurf->height, depth,
+ blitter->draw_rectangle(blitter, ctx->velem_state, 0, 0,
+ zsurf->width, zsurf->height, depth,
1, UTIL_BLITTER_ATTRIB_NONE, NULL);
util_blitter_restore_vertex_states(blitter);
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_fb_state(blitter);
util_blitter_restore_render_cond(blitter);
util_blitter_unset_running_flag(blitter);
}
void util_blitter_copy_buffer(struct blitter_context *blitter,
@@ -2451,21 +2453,20 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
struct pipe_surface *srcsurf, *dstsurf, surf_tmpl;
util_blitter_set_running_flag(blitter);
blitter_check_saved_vertex_states(ctx);
blitter_check_saved_fragment_states(ctx);
blitter_disable_render_cond(ctx);
/* bind states */
pipe->bind_blend_state(pipe, custom_blend);
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
bind_fs_write_one_cbuf(ctx);
pipe->set_sample_mask(pipe, sample_mask);
memset(&surf_tmpl, 0, sizeof(surf_tmpl));
surf_tmpl.format = format;
surf_tmpl.u.tex.level = dst_level;
surf_tmpl.u.tex.first_layer = dst_layer;
surf_tmpl.u.tex.last_layer = dst_layer;
dstsurf = pipe->create_surface(pipe, dst, &surf_tmpl);
@@ -2480,21 +2481,22 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
fb_state.width = src->width0;
fb_state.height = src->height0;
fb_state.nr_cbufs = 2;
fb_state.cbufs[0] = srcsurf;
fb_state.cbufs[1] = dstsurf;
fb_state.zsbuf = NULL;
pipe->set_framebuffer_state(pipe, &fb_state);
blitter_set_common_draw_rect_state(ctx, false, false, false);
blitter_set_dst_dimensions(ctx, src->width0, src->height0);
- blitter->draw_rectangle(blitter, 0, 0, src->width0, src->height0,
+ blitter->draw_rectangle(blitter, ctx->velem_state,
+ 0, 0, src->width0, src->height0,
0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL);
util_blitter_restore_fb_state(blitter);
util_blitter_restore_vertex_states(blitter);
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_render_cond(blitter);
util_blitter_unset_running_flag(blitter);
pipe_surface_reference(&srcsurf, NULL);
pipe_surface_reference(&dstsurf, NULL);
}
@@ -2516,33 +2518,33 @@ void util_blitter_custom_color(struct blitter_context *blitter,
blitter_check_saved_vertex_states(ctx);
blitter_check_saved_fragment_states(ctx);
blitter_check_saved_fb_state(ctx);
blitter_disable_render_cond(ctx);
/* bind states */
pipe->bind_blend_state(pipe, custom_blend ? custom_blend
: ctx->blend[PIPE_MASK_RGBA][0]);
pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil);
bind_fs_write_one_cbuf(ctx);
- pipe->bind_vertex_elements_state(pipe, ctx->velem_state);
pipe->set_sample_mask(pipe, (1ull << MAX2(1, dstsurf->texture->nr_samples)) - 1);
/* set a framebuffer state */
fb_state.width = dstsurf->width;
fb_state.height = dstsurf->height;
fb_state.nr_cbufs = 1;
fb_state.cbufs[0] = dstsurf;
fb_state.zsbuf = 0;
pipe->set_framebuffer_state(pipe, &fb_state);
pipe->set_sample_mask(pipe, ~0);
blitter_set_common_draw_rect_state(ctx, false, false, false);
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
- blitter->draw_rectangle(blitter, 0, 0, dstsurf->width, dstsurf->height,
+ blitter->draw_rectangle(blitter, ctx->velem_state,
+ 0, 0, dstsurf->width, dstsurf->height,
0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL);
util_blitter_restore_vertex_states(blitter);
util_blitter_restore_fragment_states(blitter);
util_blitter_restore_fb_state(blitter);
util_blitter_restore_render_cond(blitter);
util_blitter_unset_running_flag(blitter);
}
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index 626d46a..868f1da 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -74,20 +74,21 @@ struct blitter_context
* coordinates of the rectangle, respectively, and should go
* to the GENERIC0 varying slot of a fragment shader.
*
* \param attrib See type.
*
* \note A driver may optionally override this callback to implement
* a specialized hardware path for drawing a rectangle, e.g. using
* a rectangular point sprite.
*/
void (*draw_rectangle)(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
const union blitter_attrib *attrib);
/* Whether the blitter is running. */
bool running;
/* Private members, really. */
struct pipe_context *pipe; /**< pipe context */
@@ -148,20 +149,21 @@ struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter)
/**
* Override PIPE_CAP_TEXTURE_MULTISAMPLE as reported by the driver.
*/
void util_blitter_set_texture_multisample(struct blitter_context *blitter,
bool supported);
/* The default function to draw a rectangle. This can only be used
* inside of the draw_rectangle callback if the driver overrides it. */
void util_blitter_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
const union blitter_attrib *attrib);
/*
* These states must be saved before any of the following functions are called:
* - vertex buffers
* - vertex elements
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 84b8748..b2d7f6d 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -736,20 +736,21 @@ void r300_translate_index_buffer(struct r300_context *r300,
struct pipe_resource **out_index_buffer,
unsigned *index_size, unsigned index_offset,
unsigned *start, unsigned count);
/* r300_render_stencilref.c */
void r300_plug_in_stencil_ref_fallback(struct r300_context *r300);
/* r300_render.c */
void r500_emit_index_bias(struct r300_context *r300, int index_bias);
void r300_blitter_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
const union blitter_attrib *attrib);
/* r300_state.c */
enum r300_fb_state_change {
R300_CHANGED_FB_STATE = 0,
R300_CHANGED_HYPERZ_FLAG,
R300_CHANGED_MULTIWRITE,
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index ddd2452..7808669 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -1106,20 +1106,21 @@ struct draw_stage* r300_draw_stage(struct r300_context* r300)
/****************************************************************************
* End of SW TCL functions *
***************************************************************************/
/* This functions is used to draw a rectangle for the blitter module.
*
* If we rendered a quad, the pixels on the main diagonal
* would be computed and stored twice, which makes the clear/copy codepaths
* somewhat inefficient. Instead we use a rectangular point sprite. */
void r300_blitter_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
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;
unsigned width = x2 - x1;
unsigned height = y2 - y1;
unsigned vertex_size =
@@ -1127,28 +1128,30 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
unsigned dwords = 13 + vertex_size +
(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);
+ util_blitter_draw_rectangle(blitter, vertex_elements_cso, x1, y1, x2, y2,
+ depth, num_instances, type, attrib);
return;
}
if (r300->skip_rendering)
return;
+ r300->context.bind_vertex_elements_state(&r300->context, vertex_elements_cso);
+
if (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY)
r300->sprite_coord_enable = 1;
r300_update_derived_state(r300);
/* Mark some states we don't care about as non-dirty. */
r300->viewport_state.dirty = FALSE;
if (!r300_prepare_for_rendering(r300, PREP_EMIT_STATES, NULL, dwords, 0, 0, -1))
goto done;
diff --git a/src/gallium/drivers/r600/r600_pipe_common.c b/src/gallium/drivers/r600/r600_pipe_common.c
index 4fbcd3a..0e8a12a 100644
--- a/src/gallium/drivers/r600/r600_pipe_common.c
+++ b/src/gallium/drivers/r600/r600_pipe_common.c
@@ -204,32 +204,35 @@ void r600_gfx_wait_fence(struct r600_common_context *ctx,
radeon_emit(cs, PKT3(PKT3_WAIT_REG_MEM, 5, 0));
radeon_emit(cs, WAIT_REG_MEM_EQUAL | WAIT_REG_MEM_MEM_SPACE(1));
radeon_emit(cs, va);
radeon_emit(cs, va >> 32);
radeon_emit(cs, ref); /* reference value */
radeon_emit(cs, mask); /* mask */
radeon_emit(cs, 4); /* poll interval */
}
void r600_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
const union blitter_attrib *attrib)
{
struct r600_common_context *rctx =
(struct r600_common_context*)util_blitter_get_pipe(blitter);
struct pipe_viewport_state viewport;
struct pipe_resource *buf = NULL;
unsigned offset = 0;
float *vb;
+ rctx->b.bind_vertex_elements_state(&rctx->b, vertex_elements_cso);
+
/* Some operations (like color resolve on r6xx) don't work
* with the conventional primitive types.
* One that works is PT_RECTLIST, which we use here. */
/* setup viewport */
viewport.scale[0] = 1.0f;
viewport.scale[1] = 1.0f;
viewport.scale[2] = 1.0f;
viewport.translate[0] = 0.0f;
viewport.translate[1] = 0.0f;
diff --git a/src/gallium/drivers/r600/r600_pipe_common.h b/src/gallium/drivers/r600/r600_pipe_common.h
index 719efb9..37dcbd3 100644
--- a/src/gallium/drivers/r600/r600_pipe_common.h
+++ b/src/gallium/drivers/r600/r600_pipe_common.h
@@ -755,20 +755,21 @@ void r600_replace_buffer_storage(struct pipe_context *ctx,
/* r600_common_pipe.c */
void r600_gfx_write_event_eop(struct r600_common_context *ctx,
unsigned event, unsigned event_flags,
unsigned data_sel,
struct r600_resource *buf, uint64_t va,
uint32_t new_fence, unsigned query_type);
unsigned r600_gfx_write_fence_dwords(struct r600_common_screen *screen);
void r600_gfx_wait_fence(struct r600_common_context *ctx,
uint64_t va, uint32_t ref, uint32_t mask);
void r600_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
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);
void r600_preflush_suspend_features(struct r600_common_context *ctx);
void r600_postflush_resume_features(struct r600_common_context *ctx);
bool r600_common_context_init(struct r600_common_context *rctx,
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index eccc87e..c9745a5 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -401,20 +401,21 @@ bool si_init_shader_cache(struct si_screen *sscreen);
void si_destroy_shader_cache(struct si_screen *sscreen);
void si_get_active_slot_masks(const struct tgsi_shader_info *info,
uint32_t *const_and_shader_buffers,
uint64_t *samplers_and_images);
/* si_state_draw.c */
void si_init_ia_multi_vgt_param_table(struct si_context *sctx);
void si_emit_cache_flush(struct si_context *sctx);
void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo);
void si_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
const union blitter_attrib *attrib);
void si_trace_emit(struct si_context *sctx);
static inline unsigned
si_tile_mode_index(struct r600_texture *rtex, unsigned level, bool stencil)
{
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c b/src/gallium/drivers/radeonsi/si_state_draw.c
index adebba6..ceb90d2 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -1484,20 +1484,21 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
if (info->primitive_restart)
sctx->b.num_prim_restart_calls++;
if (G_0286E8_WAVESIZE(sctx->spi_tmpring_size))
sctx->b.num_spill_draw_calls++;
}
if (index_size && indexbuf != info->index.resource)
pipe_resource_reference(&indexbuf, NULL);
}
void si_draw_rectangle(struct blitter_context *blitter,
+ void *vertex_elements_cso,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
const union blitter_attrib *attrib)
{
struct pipe_context *pipe = util_blitter_get_pipe(blitter);
struct si_context *sctx = (struct si_context*)pipe;
struct pipe_viewport_state viewport;
struct pipe_resource *buf = NULL;
unsigned offset = 0;
@@ -1558,20 +1559,23 @@ void si_draw_rectangle(struct blitter_context *blitter,
}
/* draw */
struct pipe_vertex_buffer vbuffer = {};
vbuffer.buffer.resource = buf;
vbuffer.stride = 2 * 4 * sizeof(float); /* vertex size */
vbuffer.buffer_offset = offset;
pipe->set_vertex_buffers(pipe, blitter->vb_slot, 1, &vbuffer);
+ if (sctx->vertex_elements != vertex_elements_cso)
+ pipe->bind_vertex_elements_state(pipe, vertex_elements_cso);
+
struct pipe_draw_info info = {};
info.mode = R600_PRIM_RECTANGLE_LIST;
info.count = 3;
info.instance_count = num_instances;
si_draw_vbo(pipe, &info);
pipe_resource_reference(&buf, NULL);
}
void si_trace_emit(struct si_context *sctx)
--
2.7.4
More information about the mesa-dev
mailing list