llvmpipe: Treat state changes systematically.
That is: - check for no op - update/flush draw module - update bound state and mark it as dirty In particular flushing the draw module is important since it may contain unflushed primitives which would otherwise be draw with wrong state.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_debug_dump.h"
|
||||
#include "draw/draw_context.h"
|
||||
#include "lp_screen.h"
|
||||
#include "lp_context.h"
|
||||
#include "lp_state.h"
|
||||
@@ -51,6 +52,11 @@ void llvmpipe_bind_blend_state( struct pipe_context *pipe,
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
|
||||
if (llvmpipe->blend == blend)
|
||||
return;
|
||||
|
||||
draw_flush(llvmpipe->draw);
|
||||
|
||||
llvmpipe->blend = blend;
|
||||
|
||||
llvmpipe->dirty |= LP_NEW_BLEND;
|
||||
@@ -69,6 +75,11 @@ void llvmpipe_set_blend_color( struct pipe_context *pipe,
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
unsigned i, j;
|
||||
|
||||
if(memcmp(&llvmpipe->blend_color, blend_color, sizeof *blend_color) == 0)
|
||||
return;
|
||||
|
||||
draw_flush(llvmpipe->draw);
|
||||
|
||||
memcpy(&llvmpipe->blend_color, blend_color, sizeof *blend_color);
|
||||
|
||||
if(!llvmpipe->jit_context.blend_color)
|
||||
@@ -99,7 +110,12 @@ llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe,
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
|
||||
llvmpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
|
||||
if (llvmpipe->depth_stencil == depth_stencil)
|
||||
return;
|
||||
|
||||
draw_flush(llvmpipe->draw);
|
||||
|
||||
llvmpipe->depth_stencil = depth_stencil;
|
||||
|
||||
if(llvmpipe->depth_stencil)
|
||||
llvmpipe->jit_context.alpha_ref_value = llvmpipe->depth_stencil->alpha.ref_value;
|
||||
|
||||
@@ -673,7 +673,12 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
|
||||
llvmpipe->fs = (struct lp_fragment_shader *) fs;
|
||||
if (llvmpipe->fs == fs)
|
||||
return;
|
||||
|
||||
draw_flush(llvmpipe->draw);
|
||||
|
||||
llvmpipe->fs = fs;
|
||||
|
||||
llvmpipe->dirty |= LP_NEW_FS;
|
||||
}
|
||||
@@ -723,8 +728,7 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
|
||||
assert(shader < PIPE_SHADER_TYPES);
|
||||
assert(index == 0);
|
||||
|
||||
if(shader == PIPE_SHADER_VERTEX)
|
||||
draw_flush(llvmpipe->draw);
|
||||
draw_flush(llvmpipe->draw);
|
||||
|
||||
/* note: reference counting */
|
||||
pipe_buffer_reference(&llvmpipe->constants[shader].buffer, buffer);
|
||||
|
||||
@@ -41,14 +41,17 @@ llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
|
||||
}
|
||||
|
||||
void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe,
|
||||
void *setup)
|
||||
void *rasterizer)
|
||||
{
|
||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||
|
||||
/* pass-through to draw module */
|
||||
draw_set_rasterizer_state(llvmpipe->draw, setup);
|
||||
if (llvmpipe->rasterizer == rasterizer)
|
||||
return;
|
||||
|
||||
llvmpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
|
||||
/* pass-through to draw module */
|
||||
draw_set_rasterizer_state(llvmpipe->draw, rasterizer);
|
||||
|
||||
llvmpipe->rasterizer = rasterizer;
|
||||
|
||||
llvmpipe->dirty |= LP_NEW_RASTERIZER;
|
||||
}
|
||||
|
||||
@@ -70,14 +70,18 @@ fail:
|
||||
|
||||
|
||||
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);
|
||||
const struct lp_vertex_shader *vs = (const struct lp_vertex_shader *)_vs;
|
||||
|
||||
llvmpipe->vs = (const struct lp_vertex_shader *)vs;
|
||||
if (llvmpipe->vs == vs)
|
||||
return;
|
||||
|
||||
draw_bind_vertex_shader(llvmpipe->draw,
|
||||
(llvmpipe->vs ? llvmpipe->vs->draw_data : NULL));
|
||||
draw_bind_vertex_shader(llvmpipe->draw,
|
||||
vs ? vs->draw_data : NULL);
|
||||
|
||||
llvmpipe->vs = vs;
|
||||
|
||||
llvmpipe->dirty |= LP_NEW_VS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user