ilo: move internal shader interface to a new header
authorChia-I Wu <olvaffe@gmail.com>
Thu, 20 Jun 2013 03:52:03 +0000 (11:52 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Tue, 25 Jun 2013 03:51:26 +0000 (11:51 +0800)
Move it to ilo_shader_internal.h.  The goal is to make files not part of the
compiler include only ilo_shader.h eventually.

13 files changed:
src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
src/gallium/drivers/ilo/ilo_gpe_gen6.c
src/gallium/drivers/ilo/ilo_gpe_gen6.h
src/gallium/drivers/ilo/ilo_gpe_gen7.c
src/gallium/drivers/ilo/ilo_shader.c
src/gallium/drivers/ilo/ilo_shader.h
src/gallium/drivers/ilo/ilo_state.c
src/gallium/drivers/ilo/shader/ilo_shader_cs.c
src/gallium/drivers/ilo/shader/ilo_shader_fs.c
src/gallium/drivers/ilo/shader/ilo_shader_gs.c
src/gallium/drivers/ilo/shader/ilo_shader_internal.h [new file with mode: 0644]
src/gallium/drivers/ilo/shader/ilo_shader_vs.c

index 1f855dc34d08f3c38944b6dbff0b3072b8b12241..228131c26124911d7d458f757c3821fbab7c3256 100644 (file)
@@ -29,6 +29,7 @@
 #include "util/u_prim.h"
 #include "intel_reg.h"
 
+#include "shader/ilo_shader_internal.h"
 #include "ilo_3d.h"
 #include "ilo_context.h"
 #include "ilo_cp.h"
index 1c7260f7fd113db0740c9a7a8a1da8e05044895f..ed88f465d862ea9610fb9cdd3dc4aea73917d902 100644 (file)
@@ -28,6 +28,7 @@
 #include "util/u_dual_blend.h"
 #include "intel_reg.h"
 
+#include "shader/ilo_shader_internal.h"
 #include "ilo_common.h"
 #include "ilo_context.h"
 #include "ilo_cp.h"
index 56db7da8ee3ef0f8c6a597c761bdbff01c0dbf3e..5a18fead0f3ea55187f38722418656b8fd36429d 100644 (file)
@@ -30,6 +30,7 @@
 #include "brw_defines.h"
 #include "intel_reg.h"
 
+#include "shader/ilo_shader_internal.h"
 #include "ilo_context.h"
 #include "ilo_cp.h"
 #include "ilo_format.h"
index 6e27364547163d295e084a41e52237fcbe96e478..5f2b85aebb3548bec7bfdd18a4c0bf3123d8e279 100644 (file)
@@ -29,6 +29,7 @@
 #define ILO_GPE_GEN6_H
 
 #include "ilo_common.h"
+#include "ilo_gpe.h"
 
 #define ILO_GPE_VALID_GEN(dev, min_gen, max_gen) \
    assert((dev)->gen >= ILO_GEN(min_gen) && (dev)->gen <= ILO_GEN(max_gen))
index c3211b5387303e5a5ed4166438ed4cb26d251808..74ba793dea1569ac2cc6b6dce058cde3c33b36ab 100644 (file)
@@ -29,6 +29,7 @@
 #include "brw_defines.h"
 #include "intel_reg.h"
 
+#include "shader/ilo_shader_internal.h"
 #include "ilo_cp.h"
 #include "ilo_format.h"
 #include "ilo_resource.h"
index 584e1301f3578685589ce5fd341691c186c8d416..765cc037806ed352fc7c01e6b952b3dc29be8430 100644 (file)
@@ -28,6 +28,7 @@
 #include "tgsi/tgsi_parse.h"
 #include "intel_winsys.h"
 
+#include "shader/ilo_shader_internal.h"
 #include "ilo_shader.h"
 
 struct ilo_shader_cache {
index 9318785adbd700ba0e37535ee1ecb0645f7562ed..f286a9f785f6e1563bdd0e970b758d43df34ad39 100644 (file)
 #define ILO_SHADER_H
 
 #include "ilo_common.h"
-#include "ilo_context.h"
 
+struct intel_bo;
+struct ilo_context;
 struct ilo_shader_cache;
-
-/* XXX The interface needs to be reworked */
-
-/**
- * A shader variant.  It consists of non-orthogonal states of the pipe context
- * affecting the compilation of a shader.
- */
-struct ilo_shader_variant {
-   union {
-      struct {
-         bool rasterizer_discard;
-         int num_ucps;
-      } vs;
-
-      struct {
-         bool rasterizer_discard;
-         int num_inputs;
-         int semantic_names[PIPE_MAX_SHADER_INPUTS];
-         int semantic_indices[PIPE_MAX_SHADER_INPUTS];
-      } gs;
-
-      struct {
-         bool flatshade;
-         int fb_height;
-         int num_cbufs;
-      } fs;
-   } u;
-
-   int num_sampler_views;
-   struct {
-      unsigned r:3;
-      unsigned g:3;
-      unsigned b:3;
-      unsigned a:3;
-   } sampler_view_swizzles[ILO_MAX_SAMPLER_VIEWS];
-
-   uint32_t saturate_tex_coords[3];
-};
-
-/**
- * A compiled shader.
- */
-struct ilo_shader {
-   struct ilo_shader_variant variant;
-
-   struct {
-      int semantic_names[PIPE_MAX_SHADER_INPUTS];
-      int semantic_indices[PIPE_MAX_SHADER_INPUTS];
-      int interp[PIPE_MAX_SHADER_INPUTS];
-      bool centroid[PIPE_MAX_SHADER_INPUTS];
-      int count;
-
-      int start_grf;
-      bool has_pos;
-      bool has_linear_interp;
-      int barycentric_interpolation_mode;
-      bool discard_adj;
-   } in;
-
-   struct {
-      int register_indices[PIPE_MAX_SHADER_OUTPUTS];
-      int semantic_names[PIPE_MAX_SHADER_OUTPUTS];
-      int semantic_indices[PIPE_MAX_SHADER_OUTPUTS];
-      int count;
-
-      bool has_pos;
-   } out;
-
-   bool has_kill;
-   bool dispatch_16;
-
-   bool stream_output;
-   int svbi_post_inc;
-   /* for VS stream output / rasterizer discard */
-   int gs_offsets[3];
-   int gs_start_grf;
-
-   void *kernel;
-   int kernel_size;
-
-   /* what does the push constant buffer consist of? */
-   struct {
-      int clip_state_size;
-   } pcb;
-
-   struct list_head list;
-
-   /* managed by shader cache */
-   bool uploaded;
-   uint32_t cache_offset;
-};
-
-/**
- * Information about a shader state.
- */
-struct ilo_shader_info {
-   const struct ilo_dev_info *dev;
-   int type;
-
-   const struct tgsi_token *tokens;
-
-   struct pipe_stream_output_info stream_output;
-   struct {
-      unsigned req_local_mem;
-      unsigned req_private_mem;
-      unsigned req_input_mem;
-   } compute;
-
-   bool has_color_interp;
-   bool has_pos;
-   bool has_vertexid;
-   bool has_instanceid;
-   bool fs_color0_writes_all_cbufs;
-
-   int edgeflag_in;
-   int edgeflag_out;
-
-   uint32_t shadow_samplers;
-   int num_samplers;
-};
-
-/**
- * A shader state.
- */
-struct ilo_shader_state {
-   struct ilo_shader_info info;
-
-   struct list_head variants;
-   int num_variants, total_size;
-
-   struct ilo_shader *shader;
-
-   /* managed by shader cache */
-   struct ilo_shader_cache *cache;
-   struct list_head list;
-};
+struct ilo_shader_state;
 
 struct ilo_shader_cache *
 ilo_shader_cache_create(void);
@@ -188,11 +54,6 @@ ilo_shader_cache_upload(struct ilo_shader_cache *shc,
                         struct intel_bo *bo, unsigned offset,
                         bool incremental);
 
-void
-ilo_shader_variant_init(struct ilo_shader_variant *variant,
-                        const struct ilo_shader_info *info,
-                        const struct ilo_context *ilo);
-
 struct ilo_shader_state *
 ilo_shader_state_create(const struct ilo_context *ilo,
                         int type, const void *templ);
@@ -200,41 +61,4 @@ ilo_shader_state_create(const struct ilo_context *ilo,
 void
 ilo_shader_state_destroy(struct ilo_shader_state *state);
 
-struct ilo_shader *
-ilo_shader_state_add_variant(struct ilo_shader_state *state,
-                             const struct ilo_shader_variant *variant);
-
-bool
-ilo_shader_state_use_variant(struct ilo_shader_state *state,
-                             const struct ilo_shader_variant *variant);
-
-struct ilo_shader *
-ilo_shader_compile_vs(const struct ilo_shader_state *state,
-                      const struct ilo_shader_variant *variant);
-
-struct ilo_shader *
-ilo_shader_compile_gs(const struct ilo_shader_state *state,
-                      const struct ilo_shader_variant *variant);
-
-bool
-ilo_shader_compile_gs_passthrough(const struct ilo_shader_state *vs_state,
-                                  const struct ilo_shader_variant *vs_variant,
-                                  const int *so_mapping,
-                                  struct ilo_shader *vs);
-
-struct ilo_shader *
-ilo_shader_compile_fs(const struct ilo_shader_state *state,
-                      const struct ilo_shader_variant *variant);
-
-struct ilo_shader *
-ilo_shader_compile_cs(const struct ilo_shader_state *state,
-                      const struct ilo_shader_variant *variant);
-
-static inline void
-ilo_shader_destroy(struct ilo_shader *sh)
-{
-   FREE(sh->kernel);
-   FREE(sh);
-}
-
 #endif /* ILO_SHADER_H */
index b284e7c112bce679a1551f5e1544e76059eb92f8..80fa7414e825fd1e8b59b59c2aa0c520284c0c58 100644 (file)
@@ -28,6 +28,7 @@
 #include "util/u_framebuffer.h"
 #include "util/u_helpers.h"
 
+#include "shader/ilo_shader_internal.h"
 #include "ilo_context.h"
 #include "ilo_resource.h"
 #include "ilo_shader.h"
index 85182f2a1b7ab1a01590cdf018b515adcbce4384..880ec57ae41b9f8a989f1fa2b5f3a11891e9743d 100644 (file)
@@ -25,7 +25,7 @@
  *    Chia-I Wu <olv@lunarg.com>
  */
 
-#include "ilo_shader.h"
+#include "ilo_shader_internal.h"
 
 /**
  * Compile the compute shader.
index b414b50365ca5a50d5183a50b4dd7fa485c1eb12..eca118aa2a1a0b4c15a8311747c314938dad489f 100644 (file)
@@ -33,7 +33,7 @@
 #include "toy_optimize.h"
 #include "toy_helpers.h"
 #include "ilo_context.h"
-#include "ilo_shader.h"
+#include "ilo_shader_internal.h"
 
 struct fs_compile_context {
    struct ilo_shader *shader;
index caa0b17b9c7fa4d59d669be937d6fddeb4245d10..c4266f41b0c3a8572715a3058c82415bc8647ee2 100644 (file)
@@ -31,7 +31,7 @@
 #include "toy_legalize.h"
 #include "toy_optimize.h"
 #include "toy_helpers.h"
-#include "ilo_shader.h"
+#include "ilo_shader_internal.h"
 
 /* XXX Below is proof-of-concept code.  Skip this file! */
 
diff --git a/src/gallium/drivers/ilo/shader/ilo_shader_internal.h b/src/gallium/drivers/ilo/shader/ilo_shader_internal.h
new file mode 100644 (file)
index 0000000..c444e56
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2012-2013 LunarG, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Chia-I Wu <olv@lunarg.com>
+ */
+
+#ifndef ILO_SHADER_INTERNAL_H
+#define ILO_SHADER_INTERNAL_H
+
+#include "ilo_common.h"
+#include "ilo_context.h"
+
+/* XXX The interface needs to be reworked */
+
+/**
+ * A shader variant.  It consists of non-orthogonal states of the pipe context
+ * affecting the compilation of a shader.
+ */
+struct ilo_shader_variant {
+   union {
+      struct {
+         bool rasterizer_discard;
+         int num_ucps;
+      } vs;
+
+      struct {
+         bool rasterizer_discard;
+         int num_inputs;
+         int semantic_names[PIPE_MAX_SHADER_INPUTS];
+         int semantic_indices[PIPE_MAX_SHADER_INPUTS];
+      } gs;
+
+      struct {
+         bool flatshade;
+         int fb_height;
+         int num_cbufs;
+      } fs;
+   } u;
+
+   int num_sampler_views;
+   struct {
+      unsigned r:3;
+      unsigned g:3;
+      unsigned b:3;
+      unsigned a:3;
+   } sampler_view_swizzles[ILO_MAX_SAMPLER_VIEWS];
+
+   uint32_t saturate_tex_coords[3];
+};
+
+/**
+ * A compiled shader.
+ */
+struct ilo_shader {
+   struct ilo_shader_variant variant;
+
+   struct {
+      int semantic_names[PIPE_MAX_SHADER_INPUTS];
+      int semantic_indices[PIPE_MAX_SHADER_INPUTS];
+      int interp[PIPE_MAX_SHADER_INPUTS];
+      bool centroid[PIPE_MAX_SHADER_INPUTS];
+      int count;
+
+      int start_grf;
+      bool has_pos;
+      bool has_linear_interp;
+      int barycentric_interpolation_mode;
+      bool discard_adj;
+   } in;
+
+   struct {
+      int register_indices[PIPE_MAX_SHADER_OUTPUTS];
+      int semantic_names[PIPE_MAX_SHADER_OUTPUTS];
+      int semantic_indices[PIPE_MAX_SHADER_OUTPUTS];
+      int count;
+
+      bool has_pos;
+   } out;
+
+   bool has_kill;
+   bool dispatch_16;
+
+   bool stream_output;
+   int svbi_post_inc;
+   /* for VS stream output / rasterizer discard */
+   int gs_offsets[3];
+   int gs_start_grf;
+
+   void *kernel;
+   int kernel_size;
+
+   /* what does the push constant buffer consist of? */
+   struct {
+      int clip_state_size;
+   } pcb;
+
+   struct list_head list;
+
+   /* managed by shader cache */
+   bool uploaded;
+   uint32_t cache_offset;
+};
+
+/**
+ * Information about a shader state.
+ */
+struct ilo_shader_info {
+   const struct ilo_dev_info *dev;
+   int type;
+
+   const struct tgsi_token *tokens;
+
+   struct pipe_stream_output_info stream_output;
+   struct {
+      unsigned req_local_mem;
+      unsigned req_private_mem;
+      unsigned req_input_mem;
+   } compute;
+
+   bool has_color_interp;
+   bool has_pos;
+   bool has_vertexid;
+   bool has_instanceid;
+   bool fs_color0_writes_all_cbufs;
+
+   int edgeflag_in;
+   int edgeflag_out;
+
+   uint32_t shadow_samplers;
+   int num_samplers;
+};
+
+/**
+ * A shader state.
+ */
+struct ilo_shader_state {
+   struct ilo_shader_info info;
+
+   struct list_head variants;
+   int num_variants, total_size;
+
+   struct ilo_shader *shader;
+
+   /* managed by shader cache */
+   struct ilo_shader_cache *cache;
+   struct list_head list;
+};
+
+void
+ilo_shader_variant_init(struct ilo_shader_variant *variant,
+                        const struct ilo_shader_info *info,
+                        const struct ilo_context *ilo);
+
+struct ilo_shader *
+ilo_shader_state_add_variant(struct ilo_shader_state *state,
+                             const struct ilo_shader_variant *variant);
+
+bool
+ilo_shader_state_use_variant(struct ilo_shader_state *state,
+                             const struct ilo_shader_variant *variant);
+
+struct ilo_shader *
+ilo_shader_compile_vs(const struct ilo_shader_state *state,
+                      const struct ilo_shader_variant *variant);
+
+struct ilo_shader *
+ilo_shader_compile_gs(const struct ilo_shader_state *state,
+                      const struct ilo_shader_variant *variant);
+
+bool
+ilo_shader_compile_gs_passthrough(const struct ilo_shader_state *vs_state,
+                                  const struct ilo_shader_variant *vs_variant,
+                                  const int *so_mapping,
+                                  struct ilo_shader *vs);
+
+struct ilo_shader *
+ilo_shader_compile_fs(const struct ilo_shader_state *state,
+                      const struct ilo_shader_variant *variant);
+
+struct ilo_shader *
+ilo_shader_compile_cs(const struct ilo_shader_state *state,
+                      const struct ilo_shader_variant *variant);
+
+static inline void
+ilo_shader_destroy(struct ilo_shader *sh)
+{
+   FREE(sh->kernel);
+   FREE(sh);
+}
+
+#endif /* ILO_SHADER_INTERNAL_H */
index 3563d0b9114502bcbc17060b02954f1a5d100e56..fcb9cb53e55094443748b77380739a46648d8f9f 100644 (file)
@@ -33,7 +33,7 @@
 #include "toy_optimize.h"
 #include "toy_helpers.h"
 #include "ilo_context.h"
-#include "ilo_shader.h"
+#include "ilo_shader_internal.h"
 
 struct vs_compile_context {
    struct ilo_shader *shader;