zink: move shader state methods for pipe_context into zink_program.c
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Sat, 13 Jun 2020 14:45:22 +0000 (10:45 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 7 Aug 2020 12:36:58 +0000 (12:36 +0000)
just moving these so all the shader code can be in one place

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5970>

src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_program.c
src/gallium/drivers/zink/zink_program.h

index 792027ceb93ef7b84fe7cad24e90ff6206e46259..2f9a38573d4e4fac6d6b2dee40fc00e8a338cd71 100644 (file)
@@ -28,6 +28,7 @@
 #include "zink_fence.h"
 #include "zink_framebuffer.h"
 #include "zink_helpers.h"
+#include "zink_program.h"
 #include "zink_pipeline.h"
 #include "zink_query.h"
 #include "zink_render_pass.h"
@@ -292,69 +293,6 @@ zink_sampler_view_destroy(struct pipe_context *pctx,
    FREE(view);
 }
 
-static void *
-zink_create_vs_state(struct pipe_context *pctx,
-                     const struct pipe_shader_state *shader)
-{
-   struct nir_shader *nir;
-   if (shader->type != PIPE_SHADER_IR_NIR)
-      nir = zink_tgsi_to_nir(pctx->screen, shader->tokens);
-   else
-      nir = (struct nir_shader *)shader->ir.nir;
-
-   return zink_compile_nir(zink_screen(pctx->screen), nir, &shader->stream_output);
-}
-
-static void
-bind_stage(struct zink_context *ctx, enum pipe_shader_type stage,
-           struct zink_shader *shader)
-{
-   assert(stage < PIPE_SHADER_COMPUTE);
-   ctx->gfx_stages[stage] = shader;
-   ctx->dirty_program = true;
-}
-
-static void
-zink_bind_vs_state(struct pipe_context *pctx,
-                   void *cso)
-{
-   bind_stage(zink_context(pctx), PIPE_SHADER_VERTEX, cso);
-}
-
-static void
-zink_delete_vs_state(struct pipe_context *pctx,
-                     void *cso)
-{
-   zink_shader_free(zink_context(pctx), cso);
-}
-
-static void *
-zink_create_fs_state(struct pipe_context *pctx,
-                     const struct pipe_shader_state *shader)
-{
-   struct nir_shader *nir;
-   if (shader->type != PIPE_SHADER_IR_NIR)
-      nir = zink_tgsi_to_nir(pctx->screen, shader->tokens);
-   else
-      nir = (struct nir_shader *)shader->ir.nir;
-
-   return zink_compile_nir(zink_screen(pctx->screen), nir, NULL);
-}
-
-static void
-zink_bind_fs_state(struct pipe_context *pctx,
-                   void *cso)
-{
-   bind_stage(zink_context(pctx), PIPE_SHADER_FRAGMENT, cso);
-}
-
-static void
-zink_delete_fs_state(struct pipe_context *pctx,
-                     void *cso)
-{
-   zink_shader_free(zink_context(pctx), cso);
-}
-
 static void
 zink_set_polygon_stipple(struct pipe_context *pctx,
                          const struct pipe_poly_stipple *ps)
@@ -1127,13 +1065,7 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    ctx->base.set_sampler_views = zink_set_sampler_views;
    ctx->base.sampler_view_destroy = zink_sampler_view_destroy;
 
-   ctx->base.create_vs_state = zink_create_vs_state;
-   ctx->base.bind_vs_state = zink_bind_vs_state;
-   ctx->base.delete_vs_state = zink_delete_vs_state;
-
-   ctx->base.create_fs_state = zink_create_fs_state;
-   ctx->base.bind_fs_state = zink_bind_fs_state;
-   ctx->base.delete_fs_state = zink_delete_fs_state;
+   zink_program_init(ctx);
 
    ctx->base.set_polygon_stipple = zink_set_polygon_stipple;
    ctx->base.set_vertex_buffers = zink_set_vertex_buffers;
index 341c3293ac2a2dea0d8bd9a310603d92dfcdb6d5..4bc1b21988c2e8e84c72fea58c5171016d787493 100644 (file)
@@ -278,3 +278,80 @@ zink_get_gfx_pipeline(struct zink_screen *screen,
 
    return ((struct pipeline_cache_entry *)(entry->data))->pipeline;
 }
+
+
+static void *
+zink_create_vs_state(struct pipe_context *pctx,
+                     const struct pipe_shader_state *shader)
+{
+   struct nir_shader *nir;
+   if (shader->type != PIPE_SHADER_IR_NIR)
+      nir = zink_tgsi_to_nir(pctx->screen, shader->tokens);
+   else
+      nir = (struct nir_shader *)shader->ir.nir;
+
+   return zink_compile_nir(zink_screen(pctx->screen), nir, &shader->stream_output);
+}
+
+static void
+bind_stage(struct zink_context *ctx, enum pipe_shader_type stage,
+           struct zink_shader *shader)
+{
+   assert(stage < PIPE_SHADER_COMPUTE);
+   ctx->gfx_stages[stage] = shader;
+   ctx->dirty_program = true;
+}
+
+static void
+zink_bind_vs_state(struct pipe_context *pctx,
+                   void *cso)
+{
+   bind_stage(zink_context(pctx), PIPE_SHADER_VERTEX, cso);
+}
+
+static void
+zink_delete_vs_state(struct pipe_context *pctx,
+                     void *cso)
+{
+   zink_shader_free(zink_context(pctx), cso);
+}
+
+static void *
+zink_create_fs_state(struct pipe_context *pctx,
+                     const struct pipe_shader_state *shader)
+{
+   struct nir_shader *nir;
+   if (shader->type != PIPE_SHADER_IR_NIR)
+      nir = zink_tgsi_to_nir(pctx->screen, shader->tokens);
+   else
+      nir = (struct nir_shader *)shader->ir.nir;
+
+   return zink_compile_nir(zink_screen(pctx->screen), nir, NULL);
+}
+
+static void
+zink_bind_fs_state(struct pipe_context *pctx,
+                   void *cso)
+{
+   bind_stage(zink_context(pctx), PIPE_SHADER_FRAGMENT, cso);
+}
+
+static void
+zink_delete_fs_state(struct pipe_context *pctx,
+                     void *cso)
+{
+   zink_shader_free(zink_context(pctx), cso);
+}
+
+
+void
+zink_program_init(struct zink_context *ctx)
+{
+   ctx->base.create_vs_state = zink_create_vs_state;
+   ctx->base.bind_vs_state = zink_bind_vs_state;
+   ctx->base.delete_vs_state = zink_delete_vs_state;
+
+   ctx->base.create_fs_state = zink_create_fs_state;
+   ctx->base.bind_fs_state = zink_bind_fs_state;
+   ctx->base.delete_fs_state = zink_delete_fs_state;
+}
index 91460aa2341cbdfeebaf2cf4e339b717c6a31dc5..aaad9f31a93f2f1e8037e881342e5e6129b15e85 100644 (file)
@@ -59,4 +59,6 @@ zink_get_gfx_pipeline(struct zink_screen *screen,
                       struct zink_gfx_pipeline_state *state,
                       enum pipe_prim_type mode);
 
+void
+zink_program_init(struct zink_context *ctx);
 #endif