nouveau: implement pipe_context::bind_sampler_states()
authorBrian Paul <brianp@vmware.com>
Fri, 13 Sep 2013 00:09:33 +0000 (18:09 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 3 Oct 2013 20:05:27 +0000 (14:05 -0600)
src/gallium/drivers/nouveau/nv30/nv30_context.h
src/gallium/drivers/nouveau/nv30/nv30_fragtex.c
src/gallium/drivers/nouveau/nv30/nv30_texture.c
src/gallium/drivers/nouveau/nv30/nv40_verttex.c
src/gallium/drivers/nouveau/nv50/nv50_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c

index 12ae0c71e4f59732c029c2c651190e92d4979138..292dcfe61a423a62a78fff8f01970effdbe79268 100644 (file)
@@ -186,6 +186,14 @@ nv40_verttex_init(struct pipe_context *pipe);
 void
 nv40_verttex_validate(struct nv30_context *nv30);
 
+void
+nv30_fragtex_sampler_states_bind(struct pipe_context *pipe,
+                                 unsigned nr, void **hwcso);
+
+void
+nv40_verttex_sampler_states_bind(struct pipe_context *pipe,
+                                 unsigned nr, void **hwcso);
+
 void
 nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info);
 
index 60ffb03c89f1c459877f7c6723434c09ed3028e3..ac819786a6c2e95a4d676a8cf74da65e6b7905c6 100644 (file)
@@ -149,7 +149,7 @@ nv30_fragtex_validate(struct nv30_context *nv30)
    nv30->fragprog.dirty_samplers = 0;
 }
 
-static void
+void
 nv30_fragtex_sampler_states_bind(struct pipe_context *pipe,
                                  unsigned nr, void **hwcso)
 {
index d3cffcfb2619985762180cce293c9ab167b3fc25..c356721744235bd4476883a23b88f669d5ff8612 100644 (file)
@@ -186,6 +186,21 @@ nv30_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
    FREE(hwcso);
 }
 
+static void
+nv30_bind_sampler_states(struct pipe_context *pipe,
+                         unsigned shader, unsigned start_slot,
+                         unsigned num_samplers, void **samplers)
+{
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      nv40_verttex_sampler_states_bind(pipe, num_samplers, samplers);
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      nv30_fragtex_sampler_states_bind(pipe, num_samplers, samplers);
+      break;
+   }
+}
+
 static INLINE uint32_t
 swizzle(const struct nv30_texfmt *fmt, unsigned cmp, unsigned swz)
 {
@@ -301,6 +316,8 @@ nv30_texture_init(struct pipe_context *pipe)
 {
    pipe->create_sampler_state = nv30_sampler_state_create;
    pipe->delete_sampler_state = nv30_sampler_state_delete;
+   pipe->bind_sampler_states = nv30_bind_sampler_states;
+
    pipe->create_sampler_view = nv30_sampler_view_create;
    pipe->sampler_view_destroy = nv30_sampler_view_destroy;
 }
index 9a7163c448f6aaef6ca542767e030964594e95dd..c099208fb603247c4d7b1a28e82abe1ea8b78820 100644 (file)
@@ -47,7 +47,7 @@ nv40_verttex_validate(struct nv30_context *nv30)
    nv30->vertprog.dirty_samplers = 0;
 }
 
-static void
+void
 nv40_verttex_sampler_states_bind(struct pipe_context *pipe,
                                  unsigned nr, void **hwcso)
 {
index 7dceb51c19e59bfcc31c4a43320e2182648d45eb..03a2ebb63b974a4d5ff19cde95e649c2a9410660 100644 (file)
@@ -606,6 +606,27 @@ nv50_gp_sampler_states_bind(struct pipe_context *pipe, unsigned nr, void **s)
    nv50_stage_sampler_states_bind(nv50_context(pipe), 1, nr, s);
 }
 
+static void
+nv50_bind_sampler_states(struct pipe_context *pipe,
+                         unsigned shader, unsigned start,
+                         unsigned num_samplers, void **samplers)
+{
+   assert(start == 0);
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      nv50_vp_sampler_states_bind(pipe, num_samplers, samplers);
+      break;
+   case PIPE_SHADER_GEOMETRY:
+      nv50_gp_sampler_states_bind(pipe, num_samplers, samplers);
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      nv50_fp_sampler_states_bind(pipe, num_samplers, samplers);
+      break;
+   }
+}
+
+
+
 /* NOTE: only called when not referenced anywhere, won't be bound */
 static void
 nv50_sampler_view_destroy(struct pipe_context *pipe,
@@ -1067,6 +1088,7 @@ nv50_init_state_functions(struct nv50_context *nv50)
 
    pipe->create_sampler_state = nv50_sampler_state_create;
    pipe->delete_sampler_state = nv50_sampler_state_delete;
+   pipe->bind_sampler_states   = nv50_bind_sampler_states;
    pipe->bind_vertex_sampler_states   = nv50_vp_sampler_states_bind;
    pipe->bind_fragment_sampler_states = nv50_fp_sampler_states_bind;
    pipe->bind_geometry_sampler_states = nv50_gp_sampler_states_bind;
index e56ef0160f216a2a06d93d7ef13154f7031081a0..e3117d443a2da01b6278cd85650cc63309ded06f 100644 (file)
@@ -540,6 +540,32 @@ nvc0_cp_sampler_states_bind(struct pipe_context *pipe,
    nvc0_context(pipe)->dirty_cp |= NVC0_NEW_CP_SAMPLERS;
 }
 
+static void
+nvc0_bind_sampler_states(struct pipe_context *pipe, unsigned shader,
+                         unsigned start, unsigned nr, void **s)
+{
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      assert(start == 0);
+      nvc0_stage_sampler_states_bind(nvc0_context(pipe), 0, nr, s);
+      break;
+   case PIPE_SHADER_GEOMETRY:
+      assert(start == 0);
+      nvc0_stage_sampler_states_bind(nvc0_context(pipe), 3, nr, s);
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      assert(start == 0);
+      nvc0_stage_sampler_states_bind(nvc0_context(pipe), 4, nr, s);
+      break;
+   case PIPE_SHADER_COMPUTE:
+      nvc0_stage_sampler_states_bind_range(nvc0_context(pipe), 5,
+                                           start, nr, s);
+      nvc0_context(pipe)->dirty_cp |= NVC0_NEW_CP_SAMPLERS;
+      break;
+   }
+}
+
+
 /* NOTE: only called when not referenced anywhere, won't be bound */
 static void
 nvc0_sampler_view_destroy(struct pipe_context *pipe,
@@ -1194,6 +1220,7 @@ nvc0_init_state_functions(struct nvc0_context *nvc0)
 
    pipe->create_sampler_state = nv50_sampler_state_create;
    pipe->delete_sampler_state = nvc0_sampler_state_delete;
+   pipe->bind_sampler_states = nvc0_bind_sampler_states;
    pipe->bind_vertex_sampler_states   = nvc0_vp_sampler_states_bind;
    pipe->bind_fragment_sampler_states = nvc0_fp_sampler_states_bind;
    pipe->bind_geometry_sampler_states = nvc0_gp_sampler_states_bind;