anv/state: Pull sampler vk-to-gen maps into genX_state_util.h
[mesa.git] / src / vulkan / anv_private.h
index 95096748a9d94472682a5507ceb71ccee8bc130e..5bd50258c8ae42d125d92aa42a8bb1d61e1e5a88 100644 (file)
@@ -86,6 +86,12 @@ align_u32(uint32_t v, uint32_t a)
    return (v + a - 1) & ~(a - 1);
 }
 
+static inline uint64_t
+align_u64(uint64_t v, uint64_t a)
+{
+   return (v + a - 1) & ~(a - 1);
+}
+
 static inline int32_t
 align_i32(int32_t v, int32_t a)
 {
@@ -552,6 +558,9 @@ struct anv_meta_state {
    struct {
       VkRenderPass render_pass;
 
+      /** Pipeline that blits from a 1D image. */
+      VkPipeline pipeline_1d_src;
+
       /** Pipeline that blits from a 2D image. */
       VkPipeline pipeline_2d_src;
 
@@ -571,6 +580,16 @@ struct anv_queue {
     struct anv_state_pool *                     pool;
 };
 
+struct anv_pipeline_cache {
+   struct anv_device *                          device;
+   struct anv_state_stream                      program_stream;
+   pthread_mutex_t                              mutex;
+};
+
+void anv_pipeline_cache_init(struct anv_pipeline_cache *cache,
+                             struct anv_device *device);
+void anv_pipeline_cache_finish(struct anv_pipeline_cache *cache);
+
 struct anv_device {
     VK_LOADER_DATA                              _loader_data;
 
@@ -589,6 +608,8 @@ struct anv_device {
     struct anv_state_pool                       dynamic_state_pool;
 
     struct anv_block_pool                       instruction_block_pool;
+    struct anv_pipeline_cache                   default_pipeline_cache;
+
     struct anv_block_pool                       surface_state_block_pool;
     struct anv_state_pool                       surface_state_pool;
 
@@ -1282,7 +1303,6 @@ struct anv_pipeline {
    } urb;
 
    VkShaderStageFlags                           active_stages;
-   struct anv_state_stream                      program_stream;
    struct anv_state                             blend_state;
    uint32_t                                     vs_simd8;
    uint32_t                                     vs_vec4;
@@ -1331,18 +1351,21 @@ struct anv_graphics_pipeline_create_info {
 
 VkResult
 anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
+                  struct anv_pipeline_cache *cache,
                   const VkGraphicsPipelineCreateInfo *pCreateInfo,
                   const struct anv_graphics_pipeline_create_info *extra,
                   const VkAllocationCallbacks *alloc);
 
 VkResult
 anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
+                        struct anv_pipeline_cache *cache,
                         const VkComputePipelineCreateInfo *info,
                         struct anv_shader_module *module,
                         const char *entrypoint_name);
 
 VkResult
 anv_graphics_pipeline_create(VkDevice device,
+                             VkPipelineCache cache,
                              const VkGraphicsPipelineCreateInfo *pCreateInfo,
                              const struct anv_graphics_pipeline_create_info *extra,
                              const VkAllocationCallbacks *alloc,
@@ -1350,6 +1373,7 @@ anv_graphics_pipeline_create(VkDevice device,
 
 VkResult
 gen7_graphics_pipeline_create(VkDevice _device,
+                              struct anv_pipeline_cache *cache,
                               const VkGraphicsPipelineCreateInfo *pCreateInfo,
                               const struct anv_graphics_pipeline_create_info *extra,
                               const VkAllocationCallbacks *alloc,
@@ -1357,6 +1381,7 @@ gen7_graphics_pipeline_create(VkDevice _device,
 
 VkResult
 gen75_graphics_pipeline_create(VkDevice _device,
+                               struct anv_pipeline_cache *cache,
                                const VkGraphicsPipelineCreateInfo *pCreateInfo,
                                const struct anv_graphics_pipeline_create_info *extra,
                                const VkAllocationCallbacks *alloc,
@@ -1364,34 +1389,40 @@ gen75_graphics_pipeline_create(VkDevice _device,
 
 VkResult
 gen8_graphics_pipeline_create(VkDevice _device,
+                              struct anv_pipeline_cache *cache,
                               const VkGraphicsPipelineCreateInfo *pCreateInfo,
                               const struct anv_graphics_pipeline_create_info *extra,
                               const VkAllocationCallbacks *alloc,
                               VkPipeline *pPipeline);
 VkResult
 gen9_graphics_pipeline_create(VkDevice _device,
+                              struct anv_pipeline_cache *cache,
                               const VkGraphicsPipelineCreateInfo *pCreateInfo,
                               const struct anv_graphics_pipeline_create_info *extra,
                               const VkAllocationCallbacks *alloc,
                               VkPipeline *pPipeline);
 VkResult
 gen7_compute_pipeline_create(VkDevice _device,
+                             struct anv_pipeline_cache *cache,
                              const VkComputePipelineCreateInfo *pCreateInfo,
                              const VkAllocationCallbacks *alloc,
                              VkPipeline *pPipeline);
 VkResult
 gen75_compute_pipeline_create(VkDevice _device,
+                              struct anv_pipeline_cache *cache,
                               const VkComputePipelineCreateInfo *pCreateInfo,
                               const VkAllocationCallbacks *alloc,
                               VkPipeline *pPipeline);
 
 VkResult
 gen8_compute_pipeline_create(VkDevice _device,
+                             struct anv_pipeline_cache *cache,
                              const VkComputePipelineCreateInfo *pCreateInfo,
                              const VkAllocationCallbacks *alloc,
                              VkPipeline *pPipeline);
 VkResult
 gen9_compute_pipeline_create(VkDevice _device,
+                             struct anv_pipeline_cache *cache,
                              const VkComputePipelineCreateInfo *pCreateInfo,
                              const VkAllocationCallbacks *alloc,
                              VkPipeline *pPipeline);
@@ -1401,7 +1432,6 @@ struct anv_format {
    const char *name;
    enum isl_format surface_format; /**< RENDER_SURFACE_STATE.SurfaceFormat */
    const struct isl_format_layout *isl_layout;
-   uint8_t num_channels;
    uint16_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
    bool has_stencil;
 };
@@ -1410,7 +1440,8 @@ const struct anv_format *
 anv_format_for_vk_format(VkFormat format);
 
 enum isl_format
-anv_get_isl_format(VkFormat format, VkImageAspectFlags aspect);
+anv_get_isl_format(VkFormat format, VkImageAspectFlags aspect,
+                   VkImageTiling tiling);
 
 static inline bool
 anv_format_is_color(const struct anv_format *format)
@@ -1438,11 +1469,16 @@ struct anv_surface {
 
 struct anv_image {
    VkImageType type;
+   /* The original VkFormat provided by the client.  This may not match any
+    * of the actual surface formats.
+    */
+   VkFormat vk_format;
    const struct anv_format *format;
    VkExtent3D extent;
    uint32_t levels;
    uint32_t array_size;
    VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */
+   VkImageTiling tiling; /** VkImageCreateInfo::tiling */
 
    VkDeviceSize size;
    uint32_t alignment;
@@ -1479,9 +1515,12 @@ struct anv_image {
 
 struct anv_image_view {
    const struct anv_image *image; /**< VkImageViewCreateInfo::image */
-   const struct anv_format *format; /**< VkImageViewCreateInfo::format */
    struct anv_bo *bo;
    uint32_t offset; /**< Offset into bo. */
+
+   VkImageAspectFlags aspect_mask;
+   VkFormat vk_format;
+   enum isl_format format;
    VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
 
    /** RENDER_SURFACE_STATE when using image as a color render target. */
@@ -1608,6 +1647,7 @@ struct anv_render_pass_attachment {
 struct anv_render_pass {
    uint32_t                                     attachment_count;
    uint32_t                                     subpass_count;
+   uint32_t *                                   subpass_attachments;
    struct anv_render_pass_attachment *          attachments;
    struct anv_subpass                           subpasses[0];
 };
@@ -1626,7 +1666,7 @@ struct anv_query_pool {
    struct anv_bo                                bo;
 };
 
-void anv_device_init_meta(struct anv_device *device);
+VkResult anv_device_init_meta(struct anv_device *device);
 void anv_device_finish_meta(struct anv_device *device);
 
 void *anv_lookup_entrypoint(const char *name);
@@ -1683,6 +1723,7 @@ ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_event, VkEvent)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_framebuffer, VkFramebuffer)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_image, VkImage)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_image_view, VkImageView);
+ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline_cache, VkPipelineCache)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline, VkPipeline)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline_layout, VkPipelineLayout)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_query_pool, VkQueryPool)