summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo/ilo_state.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-08-07 16:42:53 +0800
committerChia-I Wu <[email protected]>2013-08-07 18:10:32 +0800
commit2811dba1d0a5a0a7cd57fa06c6cb1829ac5ac4ba (patch)
tree7159781d1e06747d2b938bbedf6b5b9142b4d4c2 /src/gallium/drivers/ilo/ilo_state.c
parent186dab5b8fd1d937dfb3b4379d00e4e88f929c36 (diff)
ilo: simplify setting of shader samplers and views
Remove the special path that unbinds all samplers/views not in the range. Just make another call to unbind them.
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_state.c')
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c77
1 files changed, 33 insertions, 44 deletions
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index fea530af2bd..b92ddee2ce2 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -250,25 +250,6 @@ ilo_bind_sampler_states(struct pipe_context *pipe, unsigned shader,
assert(start + count <= Elements(dst->cso));
- if (likely(shader != PIPE_SHADER_COMPUTE)) {
- if (!samplers) {
- start = 0;
- count = 0;
- }
-
- /* samplers not in range are also unbound */
- for (i = 0; i < start; i++)
- dst->cso[i] = NULL;
- for (; i < start + count; i++)
- dst->cso[i] = samplers[i - start];
- for (; i < dst->count; i++)
- dst->cso[i] = NULL;
-
- dst->count = start + count;
-
- return;
- }
-
if (samplers) {
for (i = 0; i < count; i++)
dst->cso[start + i] = samplers[i];
@@ -301,6 +282,11 @@ ilo_bind_fragment_sampler_states(struct pipe_context *pipe,
ilo_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT,
0, num_samplers, samplers);
+ if (ilo->sampler[PIPE_SHADER_FRAGMENT].count > num_samplers) {
+ ilo_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, num_samplers,
+ ilo->sampler[PIPE_SHADER_FRAGMENT].count - num_samplers, NULL);
+ }
+
ilo->dirty |= ILO_DIRTY_SAMPLER_FS;
}
@@ -314,6 +300,11 @@ ilo_bind_vertex_sampler_states(struct pipe_context *pipe,
ilo_bind_sampler_states(pipe, PIPE_SHADER_VERTEX,
0, num_samplers, samplers);
+ if (ilo->sampler[PIPE_SHADER_VERTEX].count > num_samplers) {
+ ilo_bind_sampler_states(pipe, PIPE_SHADER_VERTEX, num_samplers,
+ ilo->sampler[PIPE_SHADER_VERTEX].count - num_samplers, NULL);
+ }
+
ilo->dirty |= ILO_DIRTY_SAMPLER_VS;
}
@@ -327,6 +318,11 @@ ilo_bind_geometry_sampler_states(struct pipe_context *pipe,
ilo_bind_sampler_states(pipe, PIPE_SHADER_GEOMETRY,
0, num_samplers, samplers);
+ if (ilo->sampler[PIPE_SHADER_GEOMETRY].count > num_samplers) {
+ ilo_bind_sampler_states(pipe, PIPE_SHADER_GEOMETRY, num_samplers,
+ ilo->sampler[PIPE_SHADER_GEOMETRY].count - num_samplers, NULL);
+ }
+
ilo->dirty |= ILO_DIRTY_SAMPLER_GS;
}
@@ -765,25 +761,6 @@ ilo_set_sampler_views(struct pipe_context *pipe, unsigned shader,
assert(start + count <= Elements(dst->states));
- if (likely(shader != PIPE_SHADER_COMPUTE)) {
- if (!views) {
- start = 0;
- count = 0;
- }
-
- /* views not in range are also unbound */
- for (i = 0; i < start; i++)
- pipe_sampler_view_reference(&dst->states[i], NULL);
- for (; i < start + count; i++)
- pipe_sampler_view_reference(&dst->states[i], views[i - start]);
- for (; i < dst->count; i++)
- pipe_sampler_view_reference(&dst->states[i], NULL);
-
- dst->count = start + count;
-
- return;
- }
-
if (views) {
for (i = 0; i < count; i++)
pipe_sampler_view_reference(&dst->states[start + i], views[i]);
@@ -813,8 +790,12 @@ ilo_set_fragment_sampler_views(struct pipe_context *pipe,
{
struct ilo_context *ilo = ilo_context(pipe);
- ilo_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT,
- 0, num_views, views);
+ ilo_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, num_views, views);
+
+ if (ilo->view[PIPE_SHADER_FRAGMENT].count > num_views) {
+ ilo_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, num_views,
+ ilo->view[PIPE_SHADER_FRAGMENT].count - num_views, NULL);
+ }
ilo->dirty |= ILO_DIRTY_VIEW_FS;
}
@@ -826,8 +807,12 @@ ilo_set_vertex_sampler_views(struct pipe_context *pipe,
{
struct ilo_context *ilo = ilo_context(pipe);
- ilo_set_sampler_views(pipe, PIPE_SHADER_VERTEX,
- 0, num_views, views);
+ ilo_set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, num_views, views);
+
+ if (ilo->view[PIPE_SHADER_VERTEX].count > num_views) {
+ ilo_set_sampler_views(pipe, PIPE_SHADER_VERTEX, num_views,
+ ilo->view[PIPE_SHADER_VERTEX].count - num_views, NULL);
+ }
ilo->dirty |= ILO_DIRTY_VIEW_VS;
}
@@ -839,8 +824,12 @@ ilo_set_geometry_sampler_views(struct pipe_context *pipe,
{
struct ilo_context *ilo = ilo_context(pipe);
- ilo_set_sampler_views(pipe, PIPE_SHADER_GEOMETRY,
- 0, num_views, views);
+ ilo_set_sampler_views(pipe, PIPE_SHADER_GEOMETRY, 0, num_views, views);
+
+ if (ilo->view[PIPE_SHADER_GEOMETRY].count > num_views) {
+ ilo_set_sampler_views(pipe, PIPE_SHADER_GEOMETRY, num_views,
+ ilo->view[PIPE_SHADER_GEOMETRY].count - num_views, NULL);
+ }
ilo->dirty |= ILO_DIRTY_VIEW_GS;
}