diff options
author | Charmaine Lee <[email protected]> | 2016-08-15 18:35:28 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2016-08-26 06:19:52 -0600 |
commit | 3f51a3f6ac2aad0400e25ef6f772ff9c4b240d5f (patch) | |
tree | 89532be17dc2d46015fe95211d77ed3e4dfbab83 | |
parent | 6a43148e202806b210c6aaf5c65b92916bc01581 (diff) |
svga: avoid emitting redundant DXSetSamplers command
This patch avoid emitting redundant DXSetSamplers command.
Tested with Lightsmark2008, Heaven, MTT piglit, glretrace, viewperf.
Reviewed-by: Brian Paul <[email protected]>
-rw-r--r-- | src/gallium/drivers/svga/svga_context.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/svga/svga_state_sampler.c | 31 |
2 files changed, 25 insertions, 8 deletions
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index d422aec051e..7ac90f71755 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -232,6 +232,8 @@ struct pipe_context *svga_context_create(struct pipe_screen *screen, memset(&svga->state.hw_draw, 0xcd, sizeof(svga->state.hw_draw)); memset(&svga->state.hw_draw.views, 0x0, sizeof(svga->state.hw_draw.views)); + memset(&svga->state.hw_draw.num_samplers, 0, + sizeof(svga->state.hw_draw.num_samplers)); memset(&svga->state.hw_draw.num_sampler_views, 0, sizeof(svga->state.hw_draw.num_sampler_views)); svga->state.hw_draw.num_views = 0; diff --git a/src/gallium/drivers/svga/svga_state_sampler.c b/src/gallium/drivers/svga/svga_state_sampler.c index 2f0f838f1d3..216ab8180fb 100644 --- a/src/gallium/drivers/svga/svga_state_sampler.c +++ b/src/gallium/drivers/svga/svga_state_sampler.c @@ -304,6 +304,7 @@ update_samplers(struct svga_context *svga, unsigned dirty ) const unsigned count = svga->curr.num_samplers[shader]; SVGA3dSamplerId ids[PIPE_MAX_SAMPLERS]; unsigned i; + unsigned nsamplers; for (i = 0; i < count; i++) { if (svga->curr.sampler[shader][i]) { @@ -315,20 +316,25 @@ update_samplers(struct svga_context *svga, unsigned dirty ) } } - if (count > 0) { + for (; i < svga->state.hw_draw.num_samplers[shader]; i++) { + ids[i] = SVGA3D_INVALID_ID; + } + + nsamplers = MAX2(svga->state.hw_draw.num_samplers[shader], count); + if (nsamplers > 0) { if (count != svga->state.hw_draw.num_samplers[shader] || memcmp(ids, svga->state.hw_draw.samplers[shader], count * sizeof(ids[0])) != 0) { /* HW state is really changing */ ret = SVGA3D_vgpu10_SetSamplers(svga->swc, - count, + nsamplers, 0, /* start */ svga_shader_type(shader), /* type */ ids); if (ret != PIPE_OK) return ret; memcpy(svga->state.hw_draw.samplers[shader], ids, - count * sizeof(ids[0])); + nsamplers * sizeof(ids[0])); svga->state.hw_draw.num_samplers[shader] = count; } } @@ -344,11 +350,20 @@ update_samplers(struct svga_context *svga, unsigned dirty ) return PIPE_OK; /* probably out of memory */ } - ret = SVGA3D_vgpu10_SetSamplers(svga->swc, - 1, /* count */ - unit, /* start */ - SVGA3D_SHADERTYPE_PS, - &sampler->id); + if (svga->state.hw_draw.samplers[PIPE_SHADER_FRAGMENT][unit] + != sampler->id) { + ret = SVGA3D_vgpu10_SetSamplers(svga->swc, + 1, /* count */ + unit, /* start */ + SVGA3D_SHADERTYPE_PS, + &sampler->id); + if (ret != PIPE_OK) + return ret; + + /* save the polygon stipple sampler in the hw draw state */ + svga->state.hw_draw.samplers[PIPE_SHADER_FRAGMENT][unit] = + sampler->id; + } } return ret; |