summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi
diff options
context:
space:
mode:
authorChristian König <[email protected]>2012-07-19 10:31:44 +0200
committerChristian König <[email protected]>2012-07-24 12:29:30 +0200
commitbaf20397569fb499f736e5ad2350b008b8207fad (patch)
treea0c8ed4f692ece51253db98813112adc76566eba /src/gallium/drivers/radeonsi
parent3c09f11e5cefd437bb8185539430786dc245c96f (diff)
radeonsi: move sampler states into new handling
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi')
-rw-r--r--src/gallium/drivers/radeonsi/evergreen_state.c105
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_pipe.h2
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c113
-rw-r--r--src/gallium/drivers/radeonsi/si_state.h2
4 files changed, 115 insertions, 107 deletions
diff --git a/src/gallium/drivers/radeonsi/evergreen_state.c b/src/gallium/drivers/radeonsi/evergreen_state.c
index bb027eee448..1b4f6699f8a 100644
--- a/src/gallium/drivers/radeonsi/evergreen_state.c
+++ b/src/gallium/drivers/radeonsi/evergreen_state.c
@@ -941,107 +941,6 @@ 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_ps_sampler_view(struct pipe_context *ctx, unsigned count,
- struct pipe_sampler_view **views)
-{
- struct r600_context *rctx = (struct r600_context *)ctx;
- struct si_pipe_sampler_view **resource = (struct si_pipe_sampler_view **)views;
- struct r600_pipe_state *rstate = &rctx->ps_samplers.views_state;
- struct r600_resource *bo;
- int i;
- int has_depth = 0;
- uint64_t va;
- char *ptr;
-
- if (!count)
- goto out;
-
- r600_inval_texture_cache(rctx);
-
- bo = (struct r600_resource*)
- pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
- count * sizeof(resource[0]->state));
- ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
-
- for (i = 0; i < count; i++, ptr += sizeof(resource[0]->state)) {
- pipe_sampler_view_reference(
- (struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
- views[i]);
-
- if (resource[i]) {
- if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
- has_depth = 1;
-
- memcpy(ptr, resource[i]->state, sizeof(resource[0]->state));
- } else
- memset(ptr, 0, sizeof(resource[0]->state));
- }
-
- rctx->ws->buffer_unmap(bo->cs_buf);
-
- for (i = count; i < NUM_TEX_UNITS; i++) {
- if (rctx->ps_samplers.views[i])
- pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
- }
-
- rstate->nregs = 0;
- va = r600_resource_va(ctx->screen, (void *)bo);
- r600_pipe_state_add_reg(rstate, R_00B040_SPI_SHADER_USER_DATA_PS_4, va, bo, RADEON_USAGE_READ);
- r600_pipe_state_add_reg(rstate, R_00B044_SPI_SHADER_USER_DATA_PS_5, va >> 32, NULL, 0);
- r600_context_pipe_state_set(rctx, rstate);
-
-out:
- rctx->have_depth_texture = has_depth;
- rctx->ps_samplers.n_views = count;
-}
-
-static void evergreen_bind_ps_sampler(struct pipe_context *ctx, unsigned count, void **states)
-{
- struct r600_context *rctx = (struct r600_context *)ctx;
- struct si_pipe_sampler_state **rstates = (struct si_pipe_sampler_state **)states;
- struct r600_pipe_state *rstate = &rctx->ps_samplers.samplers_state;
- struct r600_resource *bo;
- uint64_t va;
- char *ptr;
- int i;
-
- if (!count)
- goto out;
-
- r600_inval_texture_cache(rctx);
-
- bo = (struct r600_resource*)
- pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
- count * sizeof(rstates[0]->val));
- ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
-
- for (i = 0; i < count; i++, ptr += sizeof(rstates[0]->val)) {
- memcpy(ptr, rstates[i]->val, sizeof(rstates[0]->val));
- }
-
- rctx->ws->buffer_unmap(bo->cs_buf);
-
- memcpy(rctx->ps_samplers.samplers, states, sizeof(void*) * count);
-
- rstate->nregs = 0;
- va = r600_resource_va(ctx->screen, (void *)bo);
- r600_pipe_state_add_reg(rstate, R_00B038_SPI_SHADER_USER_DATA_PS_2, va, bo, RADEON_USAGE_READ);
- r600_pipe_state_add_reg(rstate, R_00B03C_SPI_SHADER_USER_DATA_PS_3, va >> 32, NULL, 0);
- r600_context_pipe_state_set(rctx, rstate);
-
-out:
- rctx->ps_samplers.n_samplers = count;
-}
-
-static void evergreen_bind_vs_sampler(struct pipe_context *ctx, unsigned count, void **states)
-{
-}
-
static void evergreen_set_polygon_stipple(struct pipe_context *ctx,
const struct pipe_poly_stipple *state)
{
@@ -1057,18 +956,14 @@ void cayman_init_state_functions(struct r600_context *rctx)
rctx->context.create_sampler_state = si_create_sampler_state;
rctx->context.create_sampler_view = evergreen_create_sampler_view;
rctx->context.create_vertex_elements_state = si_create_vertex_elements;
- rctx->context.bind_fragment_sampler_states = evergreen_bind_ps_sampler;
rctx->context.bind_vertex_elements_state = r600_bind_vertex_elements;
- rctx->context.bind_vertex_sampler_states = evergreen_bind_vs_sampler;
rctx->context.delete_sampler_state = si_delete_sampler_state;
rctx->context.delete_vertex_elements_state = r600_delete_vertex_element;
rctx->context.set_constant_buffer = r600_set_constant_buffer;
- rctx->context.set_fragment_sampler_views = evergreen_set_ps_sampler_view;
rctx->context.set_polygon_stipple = evergreen_set_polygon_stipple;
rctx->context.set_sample_mask = evergreen_set_sample_mask;
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.sampler_view_destroy = r600_sampler_view_destroy;
rctx->context.texture_barrier = r600_texture_barrier;
rctx->context.create_stream_output_target = r600_create_so_target;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index 6adc7a4aea8..63f9109a5f8 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -120,8 +120,6 @@ struct si_pipe_sampler_state {
#define NUM_TEX_UNITS 16
struct r600_textures_info {
- struct r600_pipe_state views_state;
- struct r600_pipe_state samplers_state;
struct si_pipe_sampler_view *views[NUM_TEX_UNITS];
struct si_pipe_sampler_state *samplers[NUM_TEX_UNITS];
unsigned n_views;
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 159e9890f82..12936725803 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1529,6 +1529,113 @@ void si_pipe_shader_ps(struct pipe_context *ctx, struct si_pipe_shader *shader)
si_pm4_bind_state(rctx, ps, shader->pm4);
}
+/*
+ * Samplers
+ */
+
+static void si_set_vs_sampler_view(struct pipe_context *ctx, unsigned count,
+ struct pipe_sampler_view **views)
+{
+ assert(count == 0);
+}
+
+static void si_set_ps_sampler_view(struct pipe_context *ctx, unsigned count,
+ struct pipe_sampler_view **views)
+{
+ struct r600_context *rctx = (struct r600_context *)ctx;
+ struct si_pipe_sampler_view **resource = (struct si_pipe_sampler_view **)views;
+ struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+ struct r600_resource *bo;
+ int i;
+ int has_depth = 0;
+ uint64_t va;
+ char *ptr;
+
+ if (!count)
+ goto out;
+
+ si_pm4_inval_texture_cache(pm4);
+
+ bo = (struct r600_resource*)
+ pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
+ count * sizeof(resource[0]->state));
+ ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
+
+ for (i = 0; i < count; i++, ptr += sizeof(resource[0]->state)) {
+ pipe_sampler_view_reference(
+ (struct pipe_sampler_view **)&rctx->ps_samplers.views[i],
+ views[i]);
+
+ if (resource[i]) {
+ if (((struct r600_resource_texture *)resource[i]->base.texture)->depth)
+ has_depth = 1;
+
+ memcpy(ptr, resource[i]->state, sizeof(resource[0]->state));
+ } else
+ memset(ptr, 0, sizeof(resource[0]->state));
+ }
+
+ rctx->ws->buffer_unmap(bo->cs_buf);
+
+ for (i = count; i < NUM_TEX_UNITS; i++) {
+ if (rctx->ps_samplers.views[i])
+ pipe_sampler_view_reference((struct pipe_sampler_view **)&rctx->ps_samplers.views[i], NULL);
+ }
+
+ va = r600_resource_va(ctx->screen, (void *)bo);
+ si_pm4_add_bo(pm4, bo, RADEON_USAGE_READ);
+ si_pm4_set_reg(pm4, R_00B040_SPI_SHADER_USER_DATA_PS_4, va);
+ si_pm4_set_reg(pm4, R_00B044_SPI_SHADER_USER_DATA_PS_5, va >> 32);
+
+out:
+ si_pm4_set_state(rctx, ps_sampler_views, pm4);
+ rctx->have_depth_texture = has_depth;
+ rctx->ps_samplers.n_views = count;
+}
+
+static void si_bind_vs_sampler(struct pipe_context *ctx, unsigned count, void **states)
+{
+ assert(0);
+}
+
+static void si_bind_ps_sampler(struct pipe_context *ctx, unsigned count, void **states)
+{
+ struct r600_context *rctx = (struct r600_context *)ctx;
+ struct si_pipe_sampler_state **rstates = (struct si_pipe_sampler_state **)states;
+ struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
+ struct r600_resource *bo;
+ uint64_t va;
+ char *ptr;
+ int i;
+
+ if (!count)
+ goto out;
+
+ si_pm4_inval_texture_cache(pm4);
+
+ bo = (struct r600_resource*)
+ pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE,
+ count * sizeof(rstates[0]->val));
+ ptr = rctx->ws->buffer_map(bo->cs_buf, rctx->cs, PIPE_TRANSFER_WRITE);
+
+ for (i = 0; i < count; i++, ptr += sizeof(rstates[0]->val)) {
+ memcpy(ptr, rstates[i]->val, sizeof(rstates[0]->val));
+ }
+
+ rctx->ws->buffer_unmap(bo->cs_buf);
+
+ memcpy(rctx->ps_samplers.samplers, states, sizeof(void*) * count);
+
+ va = r600_resource_va(ctx->screen, (void *)bo);
+ si_pm4_add_bo(pm4, bo, RADEON_USAGE_READ);
+ si_pm4_set_reg(pm4, R_00B038_SPI_SHADER_USER_DATA_PS_2, va);
+ si_pm4_set_reg(pm4, R_00B03C_SPI_SHADER_USER_DATA_PS_3, va >> 32);
+
+out:
+ si_pm4_set_state(rctx, ps_sampler, pm4);
+ rctx->ps_samplers.n_samplers = count;
+}
+
void si_init_state_functions(struct r600_context *rctx)
{
rctx->context.create_blend_state = si_create_blend_state;
@@ -1558,6 +1665,12 @@ void si_init_state_functions(struct r600_context *rctx)
rctx->context.bind_fs_state = si_bind_ps_shader;
rctx->context.delete_vs_state = si_delete_vs_shader;
rctx->context.delete_fs_state = si_delete_ps_shader;
+
+ rctx->context.bind_vertex_sampler_states = si_bind_vs_sampler;
+ rctx->context.bind_fragment_sampler_states = si_bind_ps_sampler;
+
+ rctx->context.set_vertex_sampler_views = si_set_vs_sampler_view;
+ rctx->context.set_fragment_sampler_views = si_set_ps_sampler_view;
}
void si_init_config(struct r600_context *rctx)
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index cd2b9626a92..739766e877e 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -117,6 +117,8 @@ union si_state {
struct si_pm4_state *dsa_stencil_ref;
struct si_pm4_state *vs;
struct si_pm4_state *ps;
+ struct si_pm4_state *ps_sampler_views;
+ struct si_pm4_state *ps_sampler;
struct si_pm4_state *spi;
struct si_pm4_state *draw_info;
} named;