[Mesa-dev] [PATCH 16/16] r600: update sampler, sampler_view code for the future
Brian Paul
brianp at vmware.com
Thu Aug 9 20:11:15 PDT 2012
For when we have pipe->set_sampler_states(pipe, shader, start, num, samplers),
etc.
---
src/gallium/drivers/r600/evergreen_state.c | 6 +--
src/gallium/drivers/r600/r600_pipe.h | 5 +-
src/gallium/drivers/r600/r600_state.c | 6 +--
src/gallium/drivers/r600/r600_state_common.c | 52 +++++++++++++++++++++----
4 files changed, 50 insertions(+), 19 deletions(-)
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 67ae7d3..02b0338 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -1085,15 +1085,13 @@ static struct pipe_sampler_view *evergreen_create_sampler_view(struct pipe_conte
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;
- r600_set_sampler_views(rctx, &rctx->vs_samplers, count, views);
+ r600_set_sampler_views(ctx, PIPE_SHADER_VERTEX, 0, count, 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;
- r600_set_sampler_views(rctx, &rctx->ps_samplers, count, views);
+ r600_set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, count, views);
}
static void evergreen_set_clip_state(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 0464183..ada2e3b 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -551,8 +551,9 @@ void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count,
const struct pipe_vertex_buffer *input);
void r600_sampler_views_dirty(struct r600_context *rctx,
struct r600_samplerview_state *state);
-void r600_set_sampler_views(struct r600_context *rctx,
- struct r600_textures_info *dst,
+void r600_set_sampler_views(struct pipe_context *pipe,
+ unsigned shader,
+ unsigned start,
unsigned count,
struct pipe_sampler_view **views);
void r600_bind_vs_samplers(struct pipe_context *ctx, unsigned count, void **states);
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 9c7ff7f..b1ddea8 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -1079,15 +1079,13 @@ static struct pipe_sampler_view *r600_create_sampler_view(struct pipe_context *c
static void r600_set_vs_sampler_views(struct pipe_context *ctx, unsigned count,
struct pipe_sampler_view **views)
{
- struct r600_context *rctx = (struct r600_context *)ctx;
- r600_set_sampler_views(rctx, &rctx->vs_samplers, count, views);
+ r600_set_sampler_views(ctx, PIPE_SHADER_VERTEX, 0, count, views);
}
static void r600_set_ps_sampler_views(struct pipe_context *ctx, unsigned count,
struct pipe_sampler_view **views)
{
- struct r600_context *rctx = (struct r600_context *)ctx;
- r600_set_sampler_views(rctx, &rctx->ps_samplers, count, views);
+ r600_set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, count, views);
}
static void r600_set_clip_state(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index 4a75c14..cdc7805 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -369,13 +369,30 @@ void r600_sampler_view_destroy(struct pipe_context *ctx,
FREE(resource);
}
-static void r600_bind_samplers(struct r600_context *rctx,
- struct r600_textures_info *dst,
+static void r600_bind_samplers(struct pipe_context *pipe,
+ unsigned shader,
+ unsigned start,
unsigned count, void **states)
{
+ struct r600_context *rctx = (struct r600_context *)pipe;
+ struct r600_textures_info *dst;
int seamless_cube_map = -1;
unsigned i;
+ assert(start == 0); /* XXX fix below */
+
+ switch (shader) {
+ case PIPE_SHADER_VERTEX:
+ dst = &rctx->vs_samplers;
+ break;
+ case PIPE_SHADER_FRAGMENT:
+ dst = &rctx->ps_samplers;
+ break;
+ default:
+ debug_error("bad shader in r600_bind_samplers()");
+ return;
+ }
+
memcpy(dst->samplers, states, sizeof(void*) * count);
dst->n_samplers = count;
dst->atom_sampler.num_dw = 0;
@@ -407,14 +424,12 @@ static void r600_bind_samplers(struct r600_context *rctx,
void r600_bind_vs_samplers(struct pipe_context *ctx, unsigned count, void **states)
{
- struct r600_context *rctx = (struct r600_context *)ctx;
- r600_bind_samplers(rctx, &rctx->vs_samplers, count, states);
+ r600_bind_samplers(ctx, PIPE_SHADER_VERTEX, 0, count, states);
}
void r600_bind_ps_samplers(struct pipe_context *ctx, unsigned count, void **states)
{
- struct r600_context *rctx = (struct r600_context *)ctx;
- r600_bind_samplers(rctx, &rctx->ps_samplers, count, states);
+ r600_bind_samplers(ctx, PIPE_SHADER_FRAGMENT, 0, count, states);
}
void r600_delete_sampler(struct pipe_context *ctx, void *state)
@@ -543,11 +558,14 @@ void r600_sampler_views_dirty(struct r600_context *rctx,
}
}
-void r600_set_sampler_views(struct r600_context *rctx,
- struct r600_textures_info *dst,
+void r600_set_sampler_views(struct pipe_context *pipe,
+ unsigned shader,
+ unsigned start,
unsigned count,
struct pipe_sampler_view **views)
{
+ struct r600_context *rctx = (struct r600_context *) pipe;
+ struct r600_textures_info *dst;
struct r600_pipe_sampler_view **rviews = (struct r600_pipe_sampler_view **)views;
unsigned i;
/* This sets 1-bit for textures with index >= count. */
@@ -556,7 +574,23 @@ void r600_set_sampler_views(struct r600_context *rctx,
uint32_t new_mask = 0;
/* Set textures with index >= count to NULL. */
- uint32_t remaining_mask = dst->views.enabled_mask & disable_mask;
+ uint32_t remaining_mask;
+
+ assert(start == 0); /* XXX fix below */
+
+ switch (shader) {
+ case PIPE_SHADER_VERTEX:
+ dst = &rctx->vs_samplers;
+ break;
+ case PIPE_SHADER_FRAGMENT:
+ dst = &rctx->ps_samplers;
+ break;
+ default:
+ debug_error("bad shader in r600_set_sampler_views()");
+ return;
+ }
+
+ remaining_mask = dst->views.enabled_mask & disable_mask;
while (remaining_mask) {
i = u_bit_scan(&remaining_mask);
--
1.7.3.4
More information about the mesa-dev
mailing list