svga: eliminiate unnecessary constant buffer updates
Currently if the texture binding is changed, emit_fs_consts() is triggered to update texture scaling factor for rectangle texture or texture buffer size in the constant buffer. But the update is only relevant if the texture binding includes a rectangle texture or a texture buffer. To eliminate the unnecessary constant buffer updates due to other texture binding changes, a new flag SVGA_NEW_TEXTURE_CONSTS will be used to trigger fragment shader constant buffer update when a rectangle texture or a texture buffer is bound. With this patch, the number of constant buffer updates in Lightsmark2008 reduces from hundreds per frame to about 28 per frame. Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
686cd3c606
commit
c4cb879f00
|
@ -291,6 +291,8 @@ struct svga_state
|
|||
struct {
|
||||
unsigned flag_1d;
|
||||
unsigned flag_srgb;
|
||||
unsigned flag_rect; /* sampler views with rectangular texture target */
|
||||
unsigned flag_buf; /* sampler views with texture buffer target */
|
||||
} tex_flags;
|
||||
|
||||
unsigned sample_mask;
|
||||
|
@ -586,6 +588,7 @@ struct svga_context
|
|||
#define SVGA_NEW_GS 0x10000000
|
||||
#define SVGA_NEW_GS_CONST_BUFFER 0x20000000
|
||||
#define SVGA_NEW_GS_VARIANT 0x40000000
|
||||
#define SVGA_NEW_TEXTURE_CONSTS 0x80000000
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -421,6 +421,8 @@ svga_set_sampler_views(struct pipe_context *pipe,
|
|||
struct svga_context *svga = svga_context(pipe);
|
||||
unsigned flag_1d = 0;
|
||||
unsigned flag_srgb = 0;
|
||||
unsigned flag_rect = 0;
|
||||
unsigned flag_buf = 0;
|
||||
uint i;
|
||||
boolean any_change = FALSE;
|
||||
|
||||
|
@ -432,6 +434,8 @@ svga_set_sampler_views(struct pipe_context *pipe,
|
|||
return;
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
enum pipe_texture_target target;
|
||||
|
||||
if (svga->curr.sampler_views[shader][start + i] != views[i]) {
|
||||
/* Note: we're using pipe_sampler_view_release() here to work around
|
||||
* a possible crash when the old view belongs to another context that
|
||||
|
@ -449,8 +453,13 @@ svga_set_sampler_views(struct pipe_context *pipe,
|
|||
if (util_format_is_srgb(views[i]->format))
|
||||
flag_srgb |= 1 << (start + i);
|
||||
|
||||
if (views[i]->texture->target == PIPE_TEXTURE_1D)
|
||||
target = views[i]->texture->target;
|
||||
if (target == PIPE_TEXTURE_1D)
|
||||
flag_1d |= 1 << (start + i);
|
||||
else if (target == PIPE_TEXTURE_RECT)
|
||||
flag_rect |= 1 << (start + i);
|
||||
else if (target == PIPE_BUFFER)
|
||||
flag_buf |= 1 << (start + i);
|
||||
}
|
||||
|
||||
if (!any_change) {
|
||||
|
@ -474,6 +483,15 @@ svga_set_sampler_views(struct pipe_context *pipe,
|
|||
svga->curr.tex_flags.flag_srgb = flag_srgb;
|
||||
}
|
||||
|
||||
if (flag_rect != svga->curr.tex_flags.flag_rect ||
|
||||
flag_buf != svga->curr.tex_flags.flag_buf)
|
||||
{
|
||||
/* Need to re-emit texture constants */
|
||||
svga->dirty |= SVGA_NEW_TEXTURE_CONSTS;
|
||||
svga->curr.tex_flags.flag_rect = flag_rect;
|
||||
svga->curr.tex_flags.flag_buf = flag_buf;
|
||||
}
|
||||
|
||||
/* Check if any of the sampler view resources collide with the framebuffer
|
||||
* color buffers or depth stencil resource. If so, enable the NEW_FRAME_BUFFER
|
||||
* dirty bit so that emit_framebuffer can be invoked to create backed view
|
||||
|
|
|
@ -788,7 +788,7 @@ struct svga_tracked_state svga_hw_fs_constants =
|
|||
"hw fs params",
|
||||
(SVGA_NEW_FS_CONST_BUFFER |
|
||||
SVGA_NEW_FS_VARIANT |
|
||||
SVGA_NEW_TEXTURE_BINDING),
|
||||
SVGA_NEW_TEXTURE_CONSTS),
|
||||
emit_fs_consts
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue