llvmpipe: Simplify vertex and geometry shaders.
Eliminate lp_vertex_shader, as it added nothing over draw_vertex_shader. Simplify lp_geometry_shader, as most of the incoming state is unneeded. (We could also just use draw_geometry_shader if we were willing to peek inside the structure.) Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Zack Rusin <zackr@vmware.com>
This commit is contained in:
@@ -46,8 +46,8 @@
|
|||||||
struct llvmpipe_vbuf_render;
|
struct llvmpipe_vbuf_render;
|
||||||
struct draw_context;
|
struct draw_context;
|
||||||
struct draw_stage;
|
struct draw_stage;
|
||||||
|
struct draw_vertex_shader;
|
||||||
struct lp_fragment_shader;
|
struct lp_fragment_shader;
|
||||||
struct lp_vertex_shader;
|
|
||||||
struct lp_blend_state;
|
struct lp_blend_state;
|
||||||
struct lp_setup_context;
|
struct lp_setup_context;
|
||||||
struct lp_setup_variant;
|
struct lp_setup_variant;
|
||||||
@@ -63,7 +63,7 @@ struct llvmpipe_context {
|
|||||||
const struct pipe_depth_stencil_alpha_state *depth_stencil;
|
const struct pipe_depth_stencil_alpha_state *depth_stencil;
|
||||||
const struct pipe_rasterizer_state *rasterizer;
|
const struct pipe_rasterizer_state *rasterizer;
|
||||||
struct lp_fragment_shader *fs;
|
struct lp_fragment_shader *fs;
|
||||||
const struct lp_vertex_shader *vs;
|
struct draw_vertex_shader *vs;
|
||||||
const struct lp_geometry_shader *gs;
|
const struct lp_geometry_shader *gs;
|
||||||
const struct lp_velems_state *velems;
|
const struct lp_velems_state *velems;
|
||||||
const struct lp_so_state *so;
|
const struct lp_so_state *so;
|
||||||
|
@@ -112,11 +112,11 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
|
|||||||
llvmpipe_prepare_geometry_sampling(lp,
|
llvmpipe_prepare_geometry_sampling(lp,
|
||||||
lp->num_sampler_views[PIPE_SHADER_GEOMETRY],
|
lp->num_sampler_views[PIPE_SHADER_GEOMETRY],
|
||||||
lp->sampler_views[PIPE_SHADER_GEOMETRY]);
|
lp->sampler_views[PIPE_SHADER_GEOMETRY]);
|
||||||
if (lp->gs && !lp->gs->shader.tokens) {
|
if (lp->gs && lp->gs->no_tokens) {
|
||||||
/* we have an empty geometry shader with stream output, so
|
/* we have an empty geometry shader with stream output, so
|
||||||
attach the stream output info to the current vertex shader */
|
attach the stream output info to the current vertex shader */
|
||||||
if (lp->vs) {
|
if (lp->vs) {
|
||||||
draw_vs_attach_so(lp->vs->draw_data, &lp->gs->shader.stream_output);
|
draw_vs_attach_so(lp->vs, &lp->gs->stream_output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
draw_collect_pipeline_statistics(draw,
|
draw_collect_pipeline_statistics(draw,
|
||||||
@@ -136,11 +136,11 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
|
|||||||
}
|
}
|
||||||
draw_set_mapped_so_targets(draw, 0, NULL);
|
draw_set_mapped_so_targets(draw, 0, NULL);
|
||||||
|
|
||||||
if (lp->gs && !lp->gs->shader.tokens) {
|
if (lp->gs && lp->gs->no_tokens) {
|
||||||
/* we have attached stream output to the vs for rendering,
|
/* we have attached stream output to the vs for rendering,
|
||||||
now lets reset it */
|
now lets reset it */
|
||||||
if (lp->vs) {
|
if (lp->vs) {
|
||||||
draw_vs_reset_so(lp->vs->draw_data);
|
draw_vs_reset_so(lp->vs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,17 +65,10 @@ struct llvmpipe_context;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Subclass of pipe_shader_state */
|
|
||||||
struct lp_vertex_shader
|
|
||||||
{
|
|
||||||
struct pipe_shader_state shader;
|
|
||||||
struct draw_vertex_shader *draw_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Subclass of pipe_shader_state */
|
|
||||||
struct lp_geometry_shader {
|
struct lp_geometry_shader {
|
||||||
struct pipe_shader_state shader;
|
boolean no_tokens;
|
||||||
struct draw_geometry_shader *draw_data;
|
struct pipe_stream_output_info stream_output;
|
||||||
|
struct draw_geometry_shader *dgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Vertex element state */
|
/** Vertex element state */
|
||||||
|
@@ -48,7 +48,7 @@ llvmpipe_create_gs_state(struct pipe_context *pipe,
|
|||||||
|
|
||||||
state = CALLOC_STRUCT(lp_geometry_shader);
|
state = CALLOC_STRUCT(lp_geometry_shader);
|
||||||
if (state == NULL )
|
if (state == NULL )
|
||||||
goto fail;
|
goto no_state;
|
||||||
|
|
||||||
/* debug */
|
/* debug */
|
||||||
if (LP_DEBUG & DEBUG_TGSI) {
|
if (LP_DEBUG & DEBUG_TGSI) {
|
||||||
@@ -57,26 +57,19 @@ llvmpipe_create_gs_state(struct pipe_context *pipe,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy stream output info */
|
/* copy stream output info */
|
||||||
state->shader = *templ;
|
state->no_tokens = !templ->tokens;
|
||||||
if (templ->tokens) {
|
memcpy(&state->stream_output, &templ->stream_output, sizeof state->stream_output);
|
||||||
/* copy shader tokens, the ones passed in will go away. */
|
|
||||||
state->shader.tokens = tgsi_dup_tokens(templ->tokens);
|
|
||||||
if (state->shader.tokens == NULL)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
state->draw_data = draw_create_geometry_shader(llvmpipe->draw, templ);
|
state->dgs = draw_create_geometry_shader(llvmpipe->draw, templ);
|
||||||
if (state->draw_data == NULL)
|
if (state->dgs == NULL) {
|
||||||
goto fail;
|
goto no_dgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|
||||||
fail:
|
no_dgs:
|
||||||
if (state) {
|
FREE( state );
|
||||||
FREE( (void *)state->shader.tokens );
|
no_state:
|
||||||
FREE( state->draw_data );
|
|
||||||
FREE( state );
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +82,7 @@ llvmpipe_bind_gs_state(struct pipe_context *pipe, void *gs)
|
|||||||
llvmpipe->gs = (struct lp_geometry_shader *)gs;
|
llvmpipe->gs = (struct lp_geometry_shader *)gs;
|
||||||
|
|
||||||
draw_bind_geometry_shader(llvmpipe->draw,
|
draw_bind_geometry_shader(llvmpipe->draw,
|
||||||
(llvmpipe->gs ? llvmpipe->gs->draw_data : NULL));
|
(llvmpipe->gs ? llvmpipe->gs->dgs : NULL));
|
||||||
|
|
||||||
llvmpipe->dirty |= LP_NEW_GS;
|
llvmpipe->dirty |= LP_NEW_GS;
|
||||||
}
|
}
|
||||||
@@ -107,8 +100,7 @@ llvmpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_delete_geometry_shader(llvmpipe->draw, state->draw_data);
|
draw_delete_geometry_shader(llvmpipe->draw, state->dgs);
|
||||||
FREE( (void *)state->shader.tokens );
|
|
||||||
FREE(state);
|
FREE(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,36 +43,19 @@ llvmpipe_create_vs_state(struct pipe_context *pipe,
|
|||||||
const struct pipe_shader_state *templ)
|
const struct pipe_shader_state *templ)
|
||||||
{
|
{
|
||||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||||
struct lp_vertex_shader *state;
|
struct draw_vertex_shader *vs;
|
||||||
|
|
||||||
state = CALLOC_STRUCT(lp_vertex_shader);
|
vs = draw_create_vertex_shader(llvmpipe->draw, templ);
|
||||||
if (state == NULL )
|
if (vs == NULL) {
|
||||||
goto fail;
|
return NULL;
|
||||||
|
}
|
||||||
/* copy shader tokens, the ones passed in will go away.
|
|
||||||
*/
|
|
||||||
state->shader.tokens = tgsi_dup_tokens(templ->tokens);
|
|
||||||
if (state->shader.tokens == NULL)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
state->draw_data = draw_create_vertex_shader(llvmpipe->draw, templ);
|
|
||||||
if (state->draw_data == NULL)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (LP_DEBUG & DEBUG_TGSI) {
|
if (LP_DEBUG & DEBUG_TGSI) {
|
||||||
debug_printf("llvmpipe: Create vertex shader %p:\n", (void *) state);
|
debug_printf("llvmpipe: Create vertex shader %p:\n", (void *) vs);
|
||||||
tgsi_dump(templ->tokens, 0);
|
tgsi_dump(templ->tokens, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return vs;
|
||||||
|
|
||||||
fail:
|
|
||||||
if (state) {
|
|
||||||
FREE( (void *)state->shader.tokens );
|
|
||||||
FREE( state->draw_data );
|
|
||||||
FREE( state );
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -80,13 +63,12 @@ static void
|
|||||||
llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs)
|
llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs)
|
||||||
{
|
{
|
||||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||||
const struct lp_vertex_shader *vs = (const struct lp_vertex_shader *)_vs;
|
struct draw_vertex_shader *vs = (struct draw_vertex_shader *)_vs;
|
||||||
|
|
||||||
if (llvmpipe->vs == vs)
|
if (llvmpipe->vs == vs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
draw_bind_vertex_shader(llvmpipe->draw,
|
draw_bind_vertex_shader(llvmpipe->draw, vs);
|
||||||
vs ? vs->draw_data : NULL);
|
|
||||||
|
|
||||||
llvmpipe->vs = vs;
|
llvmpipe->vs = vs;
|
||||||
|
|
||||||
@@ -95,16 +77,12 @@ llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
llvmpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
|
llvmpipe_delete_vs_state(struct pipe_context *pipe, void *_vs)
|
||||||
{
|
{
|
||||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||||
|
struct draw_vertex_shader *vs = (struct draw_vertex_shader *)_vs;
|
||||||
|
|
||||||
struct lp_vertex_shader *state =
|
draw_delete_vertex_shader(llvmpipe->draw, vs);
|
||||||
(struct lp_vertex_shader *)vs;
|
|
||||||
|
|
||||||
draw_delete_vertex_shader(llvmpipe->draw, state->draw_data);
|
|
||||||
FREE( (void *)state->shader.tokens );
|
|
||||||
FREE( state );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user