pipe->bind_vs_state(pipe, ctx->vs_pos_only[index]);
}
-static void bind_vs_passthrough_pos_generic(struct blitter_context_priv *ctx)
+static void *get_vs_passthrough_pos_generic(struct blitter_context *blitter)
{
+ struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
if (!ctx->vs) {
util_make_vertex_passthrough_shader(pipe, 2, semantic_names,
semantic_indices, false);
}
-
- pipe->bind_vs_state(pipe, ctx->vs);
+ return ctx->vs;
}
-static void bind_vs_passthrough_pos(struct blitter_context_priv *ctx)
+static void *get_vs_passthrough_pos(struct blitter_context *blitter)
{
+ struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
if (!ctx->vs_nogeneric) {
semantic_names,
semantic_indices, false);
}
-
- pipe->bind_vs_state(pipe, ctx->vs_nogeneric);
+ return ctx->vs_nogeneric;
}
-static void bind_vs_layered(struct blitter_context_priv *ctx)
+static void *get_vs_layered(struct blitter_context *blitter)
{
+ struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
struct pipe_context *pipe = ctx->base.pipe;
if (!ctx->vs_layered) {
ctx->vs_layered = util_make_layered_clear_vertex_shader(pipe);
}
-
- pipe->bind_vs_state(pipe, ctx->vs_layered);
+ return ctx->vs_layered;
}
static void bind_fs_empty(struct blitter_context_priv *ctx)
}
static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx,
- bool scissor,
- bool vs_layered,
- bool vs_pass_generic)
+ bool scissor)
{
struct pipe_context *pipe = ctx->base.pipe;
pipe->bind_rasterizer_state(pipe, scissor ? ctx->rs_state_scissor
: ctx->rs_state);
- if (vs_layered)
- bind_vs_layered(ctx);
- else if (vs_pass_generic)
- bind_vs_passthrough_pos_generic(ctx);
- else
- bind_vs_passthrough_pos(ctx);
-
if (ctx->has_geometry_shader)
pipe->bind_gs_state(pipe, NULL);
if (ctx->has_tessellation) {
static void blitter_draw(struct blitter_context_priv *ctx,
void *vertex_elements_cso,
+ blitter_get_vs_func get_vs,
int x1, int y1, int x2, int y2, float depth,
unsigned num_instances)
{
pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &vb);
pipe->bind_vertex_elements_state(pipe, vertex_elements_cso);
+ pipe->bind_vs_state(pipe, get_vs(&ctx->base));
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,
+ blitter_get_vs_func get_vs,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
default:;
}
- blitter_draw(ctx, vertex_elements_cso, x1, y1, x2, y2, depth, num_instances);
+ blitter_draw(ctx, vertex_elements_cso, get_vs, x1, y1, x2, y2, depth,
+ num_instances);
}
static void *get_clear_blend_state(struct blitter_context_priv *ctx,
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, ctx->velem_state, 0, 0, width, height,
+ blitter_get_vs_func get_vs = get_vs_layered;
+
+ blitter_set_common_draw_rect_state(ctx, false);
+ blitter->draw_rectangle(blitter, ctx->velem_state, get_vs,
+ 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, ctx->velem_state, 0, 0, width, height,
+ blitter_get_vs_func get_vs;
+
+ if (pass_generic)
+ get_vs = get_vs_passthrough_pos_generic;
+ else
+ get_vs = get_vs_passthrough_pos;
+
+ blitter_set_common_draw_rect_state(ctx, false);
+ blitter->draw_rectangle(blitter, ctx->velem_state, get_vs,
+ 0, 0, width, height,
(float) depth, 1, type, &attrib);
}
bool uses_txf, enum blitter_attrib_type type)
{
union blitter_attrib coord;
+ blitter_get_vs_func get_vs = get_vs_passthrough_pos_generic;
get_texcoords(src, src_width0, src_height0,
src_x1, src_y1, src_x2, src_y2, layer, sample,
ctx->vertices[i][1][3] = coord.texcoord.w;
/* Cubemaps don't use draw_rectangle. */
- blitter_draw(ctx, ctx->velem_state,
+ blitter_draw(ctx, ctx->velem_state, get_vs,
dst_x1, dst_y1, dst_x2, dst_y2, 0, 1);
} else {
- ctx->base.draw_rectangle(&ctx->base, ctx->velem_state,
+ ctx->base.draw_rectangle(&ctx->base, ctx->velem_state, get_vs,
dst_x1, dst_y1, dst_x2, dst_y2,
0, 1, type, &coord);
}
pipe->set_scissor_states(pipe, 0, 1, scissor);
}
- blitter_set_common_draw_rect_state(ctx, scissor != NULL, false, true);
+ blitter_set_common_draw_rect_state(ctx, scissor != NULL);
do_blits(ctx, dst, dstbox, src, src_width0, src_height0,
srcbox, blit_depth || blit_stencil, use_txf);
pipe->bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
0, 1, &sampler_state);
- blitter_set_common_draw_rect_state(ctx, false, false, true);
+ blitter_set_common_draw_rect_state(ctx, false);
for (src_level = base_level; src_level < last_level; src_level++) {
struct pipe_box dstbox = {0}, srcbox = {0};
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, ctx->velem_state,
+ blitter_set_common_draw_rect_state(ctx, false);
+ blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_layered,
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_set_common_draw_rect_state(ctx, false);
blitter->draw_rectangle(blitter, ctx->velem_state,
+ get_vs_passthrough_pos_generic,
dstx, dsty, dstx+width, dsty+height, 0,
1, UTIL_BLITTER_ATTRIB_COLOR, &attrib);
}
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, ctx->velem_state,
+ blitter_set_common_draw_rect_state(ctx, false);
+ blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_layered,
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_set_common_draw_rect_state(ctx, false);
blitter->draw_rectangle(blitter, ctx->velem_state,
+ get_vs_passthrough_pos,
dstx, dsty, dstx+width, dsty+height, depth, 1,
UTIL_BLITTER_ATTRIB_NONE, NULL);
}
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_common_draw_rect_state(ctx, false);
blitter_set_dst_dimensions(ctx, zsurf->width, zsurf->height);
- blitter->draw_rectangle(blitter, ctx->velem_state, 0, 0,
- zsurf->width, zsurf->height, depth,
+ blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos,
+ 0, 0, zsurf->width, zsurf->height, depth,
1, UTIL_BLITTER_ATTRIB_NONE, NULL);
util_blitter_restore_vertex_states(blitter);
fb_state.zsbuf = NULL;
pipe->set_framebuffer_state(pipe, &fb_state);
- blitter_set_common_draw_rect_state(ctx, false, false, false);
+ blitter_set_common_draw_rect_state(ctx, false);
blitter_set_dst_dimensions(ctx, src->width0, src->height0);
- blitter->draw_rectangle(blitter, ctx->velem_state,
+ blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos,
0, 0, src->width0, src->height0,
0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL);
util_blitter_restore_fb_state(blitter);
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_common_draw_rect_state(ctx, false);
blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height);
- blitter->draw_rectangle(blitter, ctx->velem_state,
+ blitter->draw_rectangle(blitter, ctx->velem_state, get_vs_passthrough_pos,
0, 0, dstsurf->width, dstsurf->height,
0, 1, UTIL_BLITTER_ATTRIB_NONE, NULL);