summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/r600')
-rw-r--r--src/gallium/drivers/r600/evergreen_state.c58
-rw-r--r--src/gallium/drivers/r600/r600_pipe.h5
-rw-r--r--src/gallium/drivers/r600/r600_state.c42
-rw-r--r--src/gallium/drivers/r600/r600_state_common.c47
4 files changed, 62 insertions, 90 deletions
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index ad0eb2f949b..5885aecdc9d 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -1099,58 +1099,20 @@ static struct pipe_sampler_view *evergreen_create_sampler_view(struct pipe_conte
return &view->base;
}
-static void evergreen_set_vs_sampler_view(struct pipe_context *ctx, unsigned count,
- struct pipe_sampler_view **views)
+static void evergreen_set_vs_sampler_views(struct pipe_context *ctx, unsigned count,
+ struct pipe_sampler_view **views)
{
struct r600_context *rctx = (struct r600_context *)ctx;
- struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
-
- for (int i = 0; i < count; i++) {
- if (resource[i]) {
- r600_context_pipe_state_set_vs_resource(rctx, &resource[i]->state,
- i + R600_MAX_CONST_BUFFERS);
- }
- }
+ r600_set_sampler_views(rctx, &rctx->vs_samplers, count, views,
+ r600_context_pipe_state_set_vs_resource);
}
-static void evergreen_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
- struct pipe_sampler_view **views)
+static void evergreen_set_ps_sampler_views(struct pipe_context *ctx, unsigned count,
+ struct pipe_sampler_view **views)
{
struct r600_context *rctx = (struct r600_context *)ctx;
- struct r600_pipe_sampler_view **resource = (struct r600_pipe_sampler_view **)views;
- int i;
- int has_depth = 0;
-
- for (i = 0; i < count; i++) {
- if (&rctx->ps_samplers.views[i]->base != views[i]) {
- if (resource[i]) {
- if (((struct r600_resource_texture *)resource[i]->base.texture)->is_depth)
- has_depth = 1;
- r600_context_pipe_state_set_ps_resource(rctx, &resource[i]->state,
- i + R600_MAX_CONST_BUFFERS);
- } else
- r600_context_pipe_state_set_ps_resource(rctx, NULL,
- i + R600_MAX_CONST_BUFFERS);
-
- pipe_sampler_view_reference(
- (struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
- views[i]);
- } else {
- if (resource[i]) {
- if (((struct r600_resource_texture *)resource[i]->base.texture)->is_depth)
- has_depth = 1;
- }
- }
- }
- for (i = count; i < NUM_TEX_UNITS; i++) {
- if (rctx->ps_samplers.views[i]) {
- r600_context_pipe_state_set_ps_resource(rctx, NULL,
- i + R600_MAX_CONST_BUFFERS);
- pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
- }
- }
- rctx->have_depth_texture = has_depth;
- rctx->ps_samplers.n_views = count;
+ r600_set_sampler_views(rctx, &rctx->ps_samplers, count, views,
+ r600_context_pipe_state_set_ps_resource);
}
static void evergreen_bind_ps_sampler(struct pipe_context *ctx, unsigned count, void **states)
@@ -1929,7 +1891,7 @@ void evergreen_init_state_functions(struct r600_context *rctx)
rctx->context.set_blend_color = r600_set_blend_color;
rctx->context.set_clip_state = evergreen_set_clip_state;
rctx->context.set_constant_buffer = r600_set_constant_buffer;
- rctx->context.set_fragment_sampler_views = evergreen_set_ps_sampler_view;
+ rctx->context.set_fragment_sampler_views = evergreen_set_ps_sampler_views;
rctx->context.set_framebuffer_state = evergreen_set_framebuffer_state;
rctx->context.set_polygon_stipple = evergreen_set_polygon_stipple;
rctx->context.set_sample_mask = evergreen_set_sample_mask;
@@ -1937,7 +1899,7 @@ void evergreen_init_state_functions(struct r600_context *rctx)
rctx->context.set_stencil_ref = r600_set_pipe_stencil_ref;
rctx->context.set_vertex_buffers = r600_set_vertex_buffers;
rctx->context.set_index_buffer = r600_set_index_buffer;
- rctx->context.set_vertex_sampler_views = evergreen_set_vs_sampler_view;
+ rctx->context.set_vertex_sampler_views = evergreen_set_vs_sampler_views;
rctx->context.set_viewport_state = evergreen_set_viewport_state;
rctx->context.sampler_view_destroy = r600_sampler_view_destroy;
rctx->context.texture_barrier = r600_texture_barrier;
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 4688b62f2fb..fd11134567d 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -528,6 +528,11 @@ void r600_set_index_buffer(struct pipe_context *ctx,
void r600_vertex_buffers_dirty(struct r600_context *rctx);
void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
const struct pipe_vertex_buffer *input);
+void r600_set_sampler_views(struct r600_context *rctx,
+ struct r600_textures_info *dst,
+ unsigned count,
+ struct pipe_sampler_view **views,
+ void (*set_resource)(struct r600_context*, struct r600_pipe_resource_state*, unsigned));
void *r600_create_vertex_elements(struct pipe_context *ctx,
unsigned count,
const struct pipe_vertex_element *elements);
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 0091fe77c5c..508b6c66d7d 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1124,48 +1124,6 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
return &view->base;
}
-static void r600_set_sampler_views(struct r600_context *rctx,
- struct r600_textures_info *dst,
- unsigned count,
- struct pipe_sampler_view **views,
- void (*set_resource)(struct r600_context*, struct r600_pipe_resource_state*, unsigned))
-{
- struct r600_pipe_sampler_view **rviews = (struct r600_pipe_sampler_view **)views;
- unsigned i;
-
- if (count)
- r600_inval_texture_cache(rctx);
-
- for (i = 0; i < count; i++) {
- if (rviews[i]) {
- if (((struct r600_resource_texture *)rviews[i]->base.texture)->is_depth)
- rctx->have_depth_texture = true;
-
- /* Changing from array to non-arrays textures and vice versa requires updating TEX_ARRAY_OVERRIDE. */
- if ((rviews[i]->base.texture->target == PIPE_TEXTURE_1D_ARRAY ||
- rviews[i]->base.texture->target == PIPE_TEXTURE_2D_ARRAY) != dst->is_array_sampler[i])
- dst->samplers_dirty = true;
-
- set_resource(rctx, &rviews[i]->state, i + R600_MAX_CONST_BUFFERS);
- } else {
- set_resource(rctx, NULL, i + R600_MAX_CONST_BUFFERS);
- }
-
- pipe_sampler_view_reference(
- (struct pipe_sampler_view **)&dst->views[i],
- views[i]);
- }
-
- for (i = count; i < dst->n_views; i++) {
- if (dst->views[i]) {
- set_resource(rctx, NULL, i + R600_MAX_CONST_BUFFERS);
- pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views[i], NULL);
- }
- }
-
- dst->n_views = count;
-}
-
static void r600_set_vs_sampler_views(struct pipe_context *ctx, unsigned count,
struct pipe_sampler_view **views)
{
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 84c7d5e5e6d..76a28ff0210 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -457,6 +457,53 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
r600_vertex_buffers_dirty(rctx);
}
+void r600_set_sampler_views(struct r600_context *rctx,
+ struct r600_textures_info *dst,
+ unsigned count,
+ struct pipe_sampler_view **views,
+ void (*set_resource)(struct r600_context*, struct r600_pipe_resource_state*, unsigned))
+{
+ struct r600_pipe_sampler_view **rviews = (struct r600_pipe_sampler_view **)views;
+ unsigned i;
+
+ if (count)
+ r600_inval_texture_cache(rctx);
+
+ for (i = 0; i < count; i++) {
+ if (rviews[i] == dst->views[i]) {
+ continue;
+ }
+
+ if (rviews[i]) {
+ if (((struct r600_resource_texture *)rviews[i]->base.texture)->is_depth)
+ rctx->have_depth_texture = true;
+
+ /* Changing from array to non-arrays textures and vice
+ * versa requires updating TEX_ARRAY_OVERRIDE on R6xx-R7xx. */
+ if (rctx->chip_class <= R700 &&
+ (rviews[i]->base.texture->target == PIPE_TEXTURE_1D_ARRAY ||
+ rviews[i]->base.texture->target == PIPE_TEXTURE_2D_ARRAY) != dst->is_array_sampler[i]) {
+ dst->samplers_dirty = true;
+ }
+
+ set_resource(rctx, &rviews[i]->state, i + R600_MAX_CONST_BUFFERS);
+ } else {
+ set_resource(rctx, NULL, i + R600_MAX_CONST_BUFFERS);
+ }
+
+ pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views[i], views[i]);
+ }
+
+ for (i = count; i < dst->n_views; i++) {
+ if (dst->views[i]) {
+ set_resource(rctx, NULL, i + R600_MAX_CONST_BUFFERS);
+ pipe_sampler_view_reference((struct pipe_sampler_view **)&dst->views[i], NULL);
+ }
+ }
+
+ dst->n_views = count;
+}
+
void *r600_create_vertex_elements(struct pipe_context *ctx,
unsigned count,
const struct pipe_vertex_element *elements)