Merge remote-tracking branch 'public/master' into vulkan
[mesa.git] / src / mesa / state_tracker / st_program.h
index a74531581b4c2d89a49fbdb850eb37c1c3e941f6..028fba99a7483dc33a50224ce715158601397df2 100644 (file)
@@ -171,25 +171,24 @@ struct st_vertex_program
 
 
 
-/** Geometry program variant key */
-struct st_gp_variant_key
+/** Key shared by all shaders except VP, FP */
+struct st_basic_variant_key
 {
    struct st_context *st;          /**< variants are per-context */
-   /* no other fields yet */
 };
 
 
 /**
  * Geometry program variant.
  */
-struct st_gp_variant
+struct st_basic_variant
 {
    /* Parameters which generated this variant. */
-   struct st_gp_variant_key key;
+   struct st_basic_variant_key key;
 
    void *driver_shader;
 
-   struct st_gp_variant *next;
+   struct st_basic_variant *next;
 };
 
 
@@ -202,30 +201,7 @@ struct st_geometry_program
    struct pipe_shader_state tgsi;
    struct glsl_to_tgsi_visitor* glsl_to_tgsi;
 
-   struct st_gp_variant *variants;
-};
-
-
-
-/** Tessellation control program variant key */
-struct st_tcp_variant_key
-{
-   struct st_context *st;          /**< variants are per-context */
-   /* no other fields yet */
-};
-
-
-/**
- * Tessellation control program variant.
- */
-struct st_tcp_variant
-{
-   /* Parameters which generated this variant. */
-   struct st_tcp_variant_key key;
-
-   void *driver_shader;
-
-   struct st_tcp_variant *next;
+   struct st_basic_variant *variants;
 };
 
 
@@ -238,47 +214,36 @@ struct st_tessctrl_program
    struct pipe_shader_state tgsi;
    struct glsl_to_tgsi_visitor* glsl_to_tgsi;
 
-   struct st_tcp_variant *variants;
-};
-
-
-
-/** Tessellation evaluation program variant key */
-struct st_tep_variant_key
-{
-   struct st_context *st;          /**< variants are per-context */
-   /* no other fields yet */
+   struct st_basic_variant *variants;
 };
 
 
 /**
- * Tessellation evaluation program variant.
+ * Derived from Mesa gl_tess_eval_program:
  */
-struct st_tep_variant
+struct st_tesseval_program
 {
-   /* Parameters which generated this variant. */
-   struct st_tep_variant_key key;
-
-   void *driver_shader;
+   struct gl_tess_eval_program Base;  /**< The Mesa tess eval program */
+   struct pipe_shader_state tgsi;
+   struct glsl_to_tgsi_visitor* glsl_to_tgsi;
 
-   struct st_tep_variant *next;
+   struct st_basic_variant *variants;
 };
 
 
 /**
- * Derived from Mesa gl_tess_eval_program:
+ * Derived from Mesa gl_compute_program:
  */
-struct st_tesseval_program
+struct st_compute_program
 {
-   struct gl_tess_eval_program Base;  /**< The Mesa tess eval program */
-   struct pipe_shader_state tgsi;
+   struct gl_compute_program Base;  /**< The Mesa compute program */
+   struct pipe_compute_state tgsi;
    struct glsl_to_tgsi_visitor* glsl_to_tgsi;
 
-   struct st_tep_variant *variants;
+   struct st_basic_variant *variants;
 };
 
 
-
 static inline struct st_fragment_program *
 st_fragment_program( struct gl_fragment_program *fp )
 {
@@ -310,6 +275,12 @@ st_tesseval_program( struct gl_tess_eval_program *tep )
    return (struct st_tesseval_program *)tep;
 }
 
+static inline struct st_compute_program *
+st_compute_program( struct gl_compute_program *cp )
+{
+   return (struct st_compute_program *)cp;
+}
+
 static inline void
 st_reference_vertprog(struct st_context *st,
                       struct st_vertex_program **ptr,
@@ -360,6 +331,16 @@ st_reference_tesseprog(struct st_context *st,
                            (struct gl_program *) prog);
 }
 
+static inline void
+st_reference_compprog(struct st_context *st,
+                      struct st_compute_program **ptr,
+                      struct st_compute_program *prog)
+{
+   _mesa_reference_program(st->ctx,
+                           (struct gl_program **) ptr,
+                           (struct gl_program *) prog);
+}
+
 /**
  * This defines mapping from Mesa VARYING_SLOTs to TGSI GENERIC slots.
  */
@@ -397,21 +378,16 @@ st_get_fp_variant(struct st_context *st,
                   struct st_fragment_program *stfp,
                   const struct st_fp_variant_key *key);
 
+extern struct st_basic_variant *
+st_get_cp_variant(struct st_context *st,
+                  struct pipe_compute_state *tgsi,
+                  struct st_basic_variant **variants);
 
-extern struct st_gp_variant *
-st_get_gp_variant(struct st_context *st,
-                  struct st_geometry_program *stgp,
-                  const struct st_gp_variant_key *key);
-
-extern struct st_tcp_variant *
-st_get_tcp_variant(struct st_context *st,
-                   struct st_tessctrl_program *sttcp,
-                   const struct st_tcp_variant_key *key);
-
-extern struct st_tep_variant *
-st_get_tep_variant(struct st_context *st,
-                   struct st_tesseval_program *sttep,
-                   const struct st_tep_variant_key *key);
+extern struct st_basic_variant *
+st_get_basic_variant(struct st_context *st,
+                     unsigned pipe_shader,
+                     struct pipe_shader_state *tgsi,
+                     struct st_basic_variant **variants);
 
 extern void
 st_release_vp_variants( struct st_context *st,
@@ -422,16 +398,13 @@ st_release_fp_variants( struct st_context *st,
                         struct st_fragment_program *stfp );
 
 extern void
-st_release_gp_variants(struct st_context *st,
-                       struct st_geometry_program *stgp);
-
-extern void
-st_release_tcp_variants(struct st_context *st,
-                        struct st_tessctrl_program *sttcp);
+st_release_cp_variants(struct st_context *st,
+                        struct st_compute_program *stcp);
 
 extern void
-st_release_tep_variants(struct st_context *st,
-                        struct st_tesseval_program *sttep);
+st_release_basic_variants(struct st_context *st, GLenum target,
+                          struct st_basic_variant **variants,
+                          struct pipe_shader_state *tgsi);
 
 extern void
 st_destroy_program_variants(struct st_context *st);
@@ -456,6 +429,10 @@ extern bool
 st_translate_tesseval_program(struct st_context *st,
                               struct st_tesseval_program *sttep);
 
+extern bool
+st_translate_compute_program(struct st_context *st,
+                             struct st_compute_program *stcp);
+
 extern void
 st_print_current_vertex_program(void);