aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorCharmaine Lee <[email protected]>2016-04-22 16:06:32 -0700
committerBrian Paul <[email protected]>2016-04-25 12:59:29 -0600
commitc4cb879f00de89c300462e7b2d0f221d920c396f (patch)
tree8c6b251b6cdb626832ffa52de4b149a503300956 /src/gallium
parent686cd3c606536cff3fe6d80f8ebeeca7afa1b37e (diff)
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 <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/svga/svga_context.h3
-rw-r--r--src/gallium/drivers/svga/svga_pipe_sampler.c20
-rw-r--r--src/gallium/drivers/svga/svga_state_constants.c2
3 files changed, 23 insertions, 2 deletions
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index b485485f0be..007d5bc3b51 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -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
diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
index 0780c95ad9c..845eebbd014 100644
--- a/src/gallium/drivers/svga/svga_pipe_sampler.c
+++ b/src/gallium/drivers/svga/svga_pipe_sampler.c
@@ -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
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
index 51f393f9b0c..8784f47413f 100644
--- a/src/gallium/drivers/svga/svga_state_constants.c
+++ b/src/gallium/drivers/svga/svga_state_constants.c
@@ -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
};