Commit 0a3b5a02 authored by Marek Olšák's avatar Marek Olšák

gallium/u_blitter: let drivers decide which VS to use for draw_rectangle

This approach allows drivers to set their own vertex shader and skip
compilation of u_blitter vertex shaders.
Reviewed-by: default avatarNicolai Hähnle <nicolai.haehnle@amd.com>
parent a46bcf0a
This diff is collapsed.
......@@ -53,11 +53,20 @@ union blitter_attrib {
} texcoord;
};
struct blitter_context;
typedef void *(*blitter_get_vs_func)(struct blitter_context *blitter);
struct blitter_context
{
/**
* Draw a rectangle.
*
* \param get_vs Callback for obtaining the vertex shader for the draw call.
* It might invoke the shader compiler. The driver is
* responsible for setting the vertex shader, and the callback
* allows the driver to query the vertex shader CSO if it
* wants to use the default one.
* \param x1 An X coordinate of the top-left corner.
* \param y1 A Y coordinate of the top-left corner.
* \param x2 An X coordinate of the bottom-right corner.
......@@ -82,6 +91,7 @@ struct blitter_context
*/
void (*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,
......@@ -157,6 +167,7 @@ void util_blitter_set_texture_multisample(struct blitter_context *blitter,
* inside of the draw_rectangle callback if the driver overrides it. */
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,
......
......@@ -744,6 +744,7 @@ void r300_plug_in_stencil_ref_fallback(struct r300_context *r300);
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,
blitter_get_vs_func get_vs,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
......
......@@ -1114,6 +1114,7 @@ struct draw_stage* r300_draw_stage(struct r300_context* r300)
* somewhat inefficient. Instead we use a rectangular point sprite. */
void r300_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,
......@@ -1135,7 +1136,8 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
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, vertex_elements_cso, x1, y1, x2, y2,
util_blitter_draw_rectangle(blitter, vertex_elements_cso, get_vs,
x1, y1, x2, y2,
depth, num_instances, type, attrib);
return;
}
......@@ -1144,6 +1146,7 @@ void r300_blitter_draw_rectangle(struct blitter_context *blitter,
return;
r300->context.bind_vertex_elements_state(&r300->context, vertex_elements_cso);
r300->context.bind_vs_state(&r300->context, get_vs(blitter));
if (type == UTIL_BLITTER_ATTRIB_TEXCOORD_XY)
r300->sprite_coord_enable = 1;
......
......@@ -212,6 +212,7 @@ void r600_gfx_wait_fence(struct r600_common_context *ctx,
void r600_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,
......@@ -225,6 +226,7 @@ void r600_draw_rectangle(struct blitter_context *blitter,
float *vb;
rctx->b.bind_vertex_elements_state(&rctx->b, vertex_elements_cso);
rctx->b.bind_vs_state(&rctx->b, get_vs(blitter));
/* Some operations (like color resolve on r6xx) don't work
* with the conventional primitive types.
......
......@@ -763,6 +763,7 @@ 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,
blitter_get_vs_func get_vs,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
......
......@@ -409,6 +409,7 @@ 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,
blitter_get_vs_func get_vs,
int x1, int y1, int x2, int y2,
float depth, unsigned num_instances,
enum blitter_attrib_type type,
......
......@@ -1492,6 +1492,7 @@ void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info)
void si_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,
......@@ -1565,6 +1566,7 @@ void si_draw_rectangle(struct blitter_context *blitter,
vbuffer.buffer_offset = offset;
pipe->set_vertex_buffers(pipe, blitter->vb_slot, 1, &vbuffer);
pipe->bind_vs_state(pipe, get_vs(blitter));
if (sctx->vertex_elements != vertex_elements_cso)
pipe->bind_vertex_elements_state(pipe, vertex_elements_cso);
......
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