freedreno/a3xx/compiler: refactor trans_samp()
[mesa.git] / src / gallium / drivers / freedreno / freedreno_texture.c
index ff8a445dec6c56d7137e6a2da5bac7538f1ed6b0..8fb9419dd2ae3c13722db9423f294882e0197dde 100644 (file)
@@ -92,20 +92,29 @@ static void set_sampler_views(struct fd_texture_stateobj *prog,
 }
 
 static void
-fd_fragtex_sampler_states_bind(struct pipe_context *pctx,
+fd_sampler_states_bind(struct pipe_context *pctx,
+               unsigned shader, unsigned start,
                unsigned nr, void **hwcso)
 {
        struct fd_context *ctx = fd_context(pctx);
 
-       /* on a2xx, since there is a flat address space for textures/samplers,
-        * a change in # of fragment textures/samplers will trigger patching and
-        * re-emitting the vertex shader:
-        */
-       if (nr != ctx->fragtex.num_samplers)
-               ctx->dirty |= FD_DIRTY_TEXSTATE;
+       assert(start == 0);
 
-       bind_sampler_states(&ctx->fragtex, nr, hwcso);
-       ctx->dirty |= FD_DIRTY_FRAGTEX;
+       if (shader == PIPE_SHADER_FRAGMENT) {
+               /* on a2xx, since there is a flat address space for textures/samplers,
+                * a change in # of fragment textures/samplers will trigger patching and
+                * re-emitting the vertex shader:
+                */
+               if (nr != ctx->fragtex.num_samplers)
+                       ctx->dirty |= FD_DIRTY_TEXSTATE;
+
+               bind_sampler_states(&ctx->fragtex, nr, hwcso);
+               ctx->dirty |= FD_DIRTY_FRAGTEX;
+       }
+       else if (shader == PIPE_SHADER_VERTEX) {
+               bind_sampler_states(&ctx->verttex, nr, hwcso);
+               ctx->dirty |= FD_DIRTY_VERTTEX;
+       }
 }
 
 
@@ -127,22 +136,30 @@ fd_fragtex_set_sampler_views(struct pipe_context *pctx, unsigned nr,
 }
 
 static void
-fd_verttex_sampler_states_bind(struct pipe_context *pctx,
-               unsigned nr, void **hwcso)
+fd_verttex_set_sampler_views(struct pipe_context *pctx, unsigned nr,
+               struct pipe_sampler_view **views)
 {
        struct fd_context *ctx = fd_context(pctx);
-       bind_sampler_states(&ctx->verttex, nr, hwcso);
+       set_sampler_views(&ctx->verttex, nr, views);
        ctx->dirty |= FD_DIRTY_VERTTEX;
 }
 
-
 static void
-fd_verttex_set_sampler_views(struct pipe_context *pctx, unsigned nr,
-               struct pipe_sampler_view **views)
+fd_set_sampler_views(struct pipe_context *pctx, unsigned shader,
+                     unsigned start, unsigned nr,
+                     struct pipe_sampler_view **views)
 {
-       struct fd_context *ctx = fd_context(pctx);
-       set_sampler_views(&ctx->verttex, nr, views);
-       ctx->dirty |= FD_DIRTY_VERTTEX;
+   assert(start == 0);
+   switch (shader) {
+   case PIPE_SHADER_FRAGMENT:
+      fd_fragtex_set_sampler_views(pctx, nr, views);
+      break;
+   case PIPE_SHADER_VERTEX:
+      fd_verttex_set_sampler_views(pctx, nr, views);
+      break;
+   default:
+      ;
+   }
 }
 
 void
@@ -152,9 +169,6 @@ fd_texture_init(struct pipe_context *pctx)
 
        pctx->sampler_view_destroy = fd_sampler_view_destroy;
 
-       pctx->bind_fragment_sampler_states = fd_fragtex_sampler_states_bind;
-       pctx->set_fragment_sampler_views = fd_fragtex_set_sampler_views;
-
-       pctx->bind_vertex_sampler_states = fd_verttex_sampler_states_bind;
-       pctx->set_vertex_sampler_views = fd_verttex_set_sampler_views;
+       pctx->bind_sampler_states = fd_sampler_states_bind;
+       pctx->set_sampler_views = fd_set_sampler_views;
 }