anv: Store prog data in pipeline cache stream
[mesa.git] / src / intel / vulkan / anv_private.h
index e50a6dbdbfeda76ab125ee6e1787a9f01ac13e90..70b6dd995a1d8472d4262db3952022dcf7762dab 100644 (file)
@@ -41,6 +41,7 @@
 #endif
 
 #include "brw_device_info.h"
+#include "brw_compiler.h"
 #include "util/macros.h"
 #include "util/list.h"
 
@@ -632,19 +633,20 @@ struct anv_pipeline_cache {
    uint32_t                                     total_size;
    uint32_t                                     table_size;
    uint32_t                                     kernel_count;
-   uint32_t                                    *table;
+   uint32_t *                                   hash_table;
 };
 
 void anv_pipeline_cache_init(struct anv_pipeline_cache *cache,
                              struct anv_device *device);
 void anv_pipeline_cache_finish(struct anv_pipeline_cache *cache);
 uint32_t anv_pipeline_cache_search(struct anv_pipeline_cache *cache,
-                                   const unsigned char *sha1, void *prog_data);
+                                   const unsigned char *sha1,
+                                   const struct brw_stage_prog_data **prog_data);
 uint32_t anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
                                           const unsigned char *sha1,
                                           const void *kernel,
                                           size_t kernel_size,
-                                          const void *prog_data,
+                                          const struct brw_stage_prog_data **prog_data,
                                           size_t prog_data_size);
 
 struct anv_device {
@@ -1403,12 +1405,8 @@ struct anv_pipeline {
 
    bool                                         use_repclear;
 
-   struct brw_vs_prog_data                      vs_prog_data;
-   struct brw_wm_prog_data                      wm_prog_data;
-   struct brw_gs_prog_data                      gs_prog_data;
-   struct brw_cs_prog_data                      cs_prog_data;
    bool                                         writes_point_size;
-   struct brw_stage_prog_data *                 prog_data[MESA_SHADER_STAGES];
+   const struct brw_stage_prog_data *           prog_data[MESA_SHADER_STAGES];
    uint32_t                                     scratch_start[MESA_SHADER_STAGES];
    uint32_t                                     total_scratch;
    struct {
@@ -1456,6 +1454,30 @@ struct anv_pipeline {
    } gen9;
 };
 
+static inline const struct brw_vs_prog_data *
+get_vs_prog_data(struct anv_pipeline *pipeline)
+{
+   return (const struct brw_vs_prog_data *) pipeline->prog_data[MESA_SHADER_VERTEX];
+}
+
+static inline const struct brw_gs_prog_data *
+get_gs_prog_data(struct anv_pipeline *pipeline)
+{
+   return (const struct brw_gs_prog_data *) pipeline->prog_data[MESA_SHADER_GEOMETRY];
+}
+
+static inline const struct brw_wm_prog_data *
+get_wm_prog_data(struct anv_pipeline *pipeline)
+{
+   return (const struct brw_wm_prog_data *) pipeline->prog_data[MESA_SHADER_FRAGMENT];
+}
+
+static inline const struct brw_cs_prog_data *
+get_cs_prog_data(struct anv_pipeline *pipeline)
+{
+   return (const struct brw_cs_prog_data *) pipeline->prog_data[MESA_SHADER_COMPUTE];
+}
+
 struct anv_graphics_pipeline_create_info {
    /**
     * If non-negative, overrides the color attachment count of the pipeline's
@@ -1640,6 +1662,23 @@ struct anv_image {
    };
 };
 
+static inline uint32_t
+anv_get_layerCount(const struct anv_image *image,
+                   const VkImageSubresourceRange *range)
+{
+   return range->layerCount == VK_REMAINING_ARRAY_LAYERS ?
+          image->array_size - range->baseArrayLayer : range->layerCount;
+}
+
+static inline uint32_t
+anv_get_levelCount(const struct anv_image *image,
+                   const VkImageSubresourceRange *range)
+{
+   return range->levelCount == VK_REMAINING_MIP_LEVELS ?
+          image->levels - range->baseMipLevel : range->levelCount;
+}
+
+
 struct anv_image_view {
    const struct anv_image *image; /**< VkImageViewCreateInfo::image */
    struct anv_bo *bo;
@@ -1659,6 +1698,8 @@ struct anv_image_view {
 
    /** RENDER_SURFACE_STATE when using image as a storage image. */
    struct anv_state storage_surface_state;
+
+   struct brw_image_param storage_image_param;
 };
 
 struct anv_image_create_info {
@@ -1680,7 +1721,8 @@ void anv_image_view_init(struct anv_image_view *view,
                          struct anv_device *device,
                          const VkImageViewCreateInfo* pCreateInfo,
                          struct anv_cmd_buffer *cmd_buffer,
-                         uint32_t offset);
+                         uint32_t offset,
+                         VkImageUsageFlags usage_mask);
 
 void
 anv_fill_image_surface_state(struct anv_device *device, struct anv_state state,
@@ -1716,6 +1758,8 @@ struct anv_buffer_view {
 
    struct anv_state surface_state;
    struct anv_state storage_surface_state;
+
+   struct brw_image_param storage_image_param;
 };
 
 const struct anv_format *