mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 22:00:13 +01:00
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 <brianp@vmware.com>
This commit is contained in:
parent
6a43148e20
commit
3f51a3f6ac
2 changed files with 25 additions and 8 deletions
|
|
@ -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, 0xcd, sizeof(svga->state.hw_draw));
|
||||||
memset(&svga->state.hw_draw.views, 0x0, sizeof(svga->state.hw_draw.views));
|
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,
|
memset(&svga->state.hw_draw.num_sampler_views, 0,
|
||||||
sizeof(svga->state.hw_draw.num_sampler_views));
|
sizeof(svga->state.hw_draw.num_sampler_views));
|
||||||
svga->state.hw_draw.num_views = 0;
|
svga->state.hw_draw.num_views = 0;
|
||||||
|
|
|
||||||
|
|
@ -304,6 +304,7 @@ update_samplers(struct svga_context *svga, unsigned dirty )
|
||||||
const unsigned count = svga->curr.num_samplers[shader];
|
const unsigned count = svga->curr.num_samplers[shader];
|
||||||
SVGA3dSamplerId ids[PIPE_MAX_SAMPLERS];
|
SVGA3dSamplerId ids[PIPE_MAX_SAMPLERS];
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
unsigned nsamplers;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
if (svga->curr.sampler[shader][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] ||
|
if (count != svga->state.hw_draw.num_samplers[shader] ||
|
||||||
memcmp(ids, svga->state.hw_draw.samplers[shader],
|
memcmp(ids, svga->state.hw_draw.samplers[shader],
|
||||||
count * sizeof(ids[0])) != 0) {
|
count * sizeof(ids[0])) != 0) {
|
||||||
/* HW state is really changing */
|
/* HW state is really changing */
|
||||||
ret = SVGA3D_vgpu10_SetSamplers(svga->swc,
|
ret = SVGA3D_vgpu10_SetSamplers(svga->swc,
|
||||||
count,
|
nsamplers,
|
||||||
0, /* start */
|
0, /* start */
|
||||||
svga_shader_type(shader), /* type */
|
svga_shader_type(shader), /* type */
|
||||||
ids);
|
ids);
|
||||||
if (ret != PIPE_OK)
|
if (ret != PIPE_OK)
|
||||||
return ret;
|
return ret;
|
||||||
memcpy(svga->state.hw_draw.samplers[shader], ids,
|
memcpy(svga->state.hw_draw.samplers[shader], ids,
|
||||||
count * sizeof(ids[0]));
|
nsamplers * sizeof(ids[0]));
|
||||||
svga->state.hw_draw.num_samplers[shader] = count;
|
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 */
|
return PIPE_OK; /* probably out of memory */
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = SVGA3D_vgpu10_SetSamplers(svga->swc,
|
if (svga->state.hw_draw.samplers[PIPE_SHADER_FRAGMENT][unit]
|
||||||
1, /* count */
|
!= sampler->id) {
|
||||||
unit, /* start */
|
ret = SVGA3D_vgpu10_SetSamplers(svga->swc,
|
||||||
SVGA3D_SHADERTYPE_PS,
|
1, /* count */
|
||||||
&sampler->id);
|
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;
|
return ret;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue