mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 10:20:20 +01:00
softpipe: implement conditional rendering
This commit is contained in:
parent
c0b4fb06b8
commit
41450b03a8
6 changed files with 57 additions and 0 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include "util/u_pack_color.h"
|
||||
#include "sp_clear.h"
|
||||
#include "sp_context.h"
|
||||
#include "sp_query.h"
|
||||
#include "sp_tile_cache.h"
|
||||
|
||||
|
||||
|
|
@ -55,6 +56,9 @@ softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba,
|
|||
if (softpipe->no_rast)
|
||||
return;
|
||||
|
||||
if (!softpipe_check_render_cond(softpipe))
|
||||
return;
|
||||
|
||||
#if 0
|
||||
softpipe_update_derived(softpipe); /* not needed?? */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -176,6 +176,19 @@ softpipe_is_buffer_referenced( struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
softpipe_render_condition( struct pipe_context *pipe,
|
||||
struct pipe_query *query,
|
||||
uint mode )
|
||||
{
|
||||
struct softpipe_context *softpipe = softpipe_context( pipe );
|
||||
|
||||
softpipe->render_cond_query = query;
|
||||
softpipe->render_cond_mode = mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct pipe_context *
|
||||
softpipe_create( struct pipe_screen *screen )
|
||||
{
|
||||
|
|
@ -252,6 +265,8 @@ softpipe_create( struct pipe_screen *screen )
|
|||
|
||||
softpipe_init_query_funcs( softpipe );
|
||||
|
||||
softpipe->pipe.render_condition = softpipe_render_condition;
|
||||
|
||||
/*
|
||||
* Alloc caches for accessing drawing surfaces and textures.
|
||||
* Must be before quad stage setup!
|
||||
|
|
|
|||
|
|
@ -116,6 +116,10 @@ struct softpipe_context {
|
|||
|
||||
unsigned line_stipple_counter;
|
||||
|
||||
/** Conditional query object and mode */
|
||||
struct pipe_query *render_cond_query;
|
||||
uint render_cond_mode;
|
||||
|
||||
/** Software quad rendering pipeline */
|
||||
struct {
|
||||
struct quad_stage *shade;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "util/u_prim.h"
|
||||
|
||||
#include "sp_context.h"
|
||||
#include "sp_query.h"
|
||||
#include "sp_state.h"
|
||||
|
||||
#include "draw/draw_context.h"
|
||||
|
|
@ -122,6 +123,9 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
|
|||
struct draw_context *draw = sp->draw;
|
||||
unsigned i;
|
||||
|
||||
if (!softpipe_check_render_cond(sp))
|
||||
return TRUE;
|
||||
|
||||
sp->reduced_api_prim = u_reduced_prim(mode);
|
||||
|
||||
if (sp->dirty)
|
||||
|
|
|
|||
|
|
@ -99,6 +99,32 @@ softpipe_get_query_result(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by rendering function to check rendering is conditional.
|
||||
* \return TRUE if we should render, FALSE if we should skip rendering
|
||||
*/
|
||||
boolean
|
||||
softpipe_check_render_cond(struct softpipe_context *sp)
|
||||
{
|
||||
struct pipe_context *pipe = &sp->pipe;
|
||||
boolean b, wait;
|
||||
uint64_t result;
|
||||
|
||||
if (!sp->render_cond_query) {
|
||||
return TRUE; /* no query predicate, draw normally */
|
||||
}
|
||||
|
||||
wait = (sp->render_cond_mode == PIPE_RENDER_COND_WAIT ||
|
||||
sp->render_cond_mode == PIPE_RENDER_COND_BY_REGION_WAIT);
|
||||
|
||||
b = pipe->get_query_result(pipe, sp->render_cond_query, wait, &result);
|
||||
if (b)
|
||||
return result > 0;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void softpipe_init_query_funcs(struct softpipe_context *softpipe )
|
||||
{
|
||||
softpipe->pipe.create_query = softpipe_create_query;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@
|
|||
#ifndef SP_QUERY_H
|
||||
#define SP_QUERY_H
|
||||
|
||||
extern boolean
|
||||
softpipe_check_render_cond(struct softpipe_context *sp);
|
||||
|
||||
|
||||
struct softpipe_context;
|
||||
extern void softpipe_init_query_funcs(struct softpipe_context * );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue