Merge branch 'vulkan'
[mesa.git] / src / intel / vulkan / anv_private.h
index 0ef840da10e65e9c8463717c7109a3a46cfb0ba0..ae2e08d2dfb405a36b19dfe42672ced9414281e7 100644 (file)
@@ -468,15 +468,13 @@ struct anv_state anv_state_stream_alloc(struct anv_state_stream *stream,
 struct anv_bo_pool {
    struct anv_device *device;
 
-   uint32_t bo_size;
-
-   void *free_list;
+   void *free_list[16];
 };
 
-void anv_bo_pool_init(struct anv_bo_pool *pool,
-                      struct anv_device *device, uint32_t block_size);
+void anv_bo_pool_init(struct anv_bo_pool *pool, struct anv_device *device);
 void anv_bo_pool_finish(struct anv_bo_pool *pool);
-VkResult anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo);
+VkResult anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo,
+                           uint32_t size);
 void anv_bo_pool_free(struct anv_bo_pool *pool, const struct anv_bo *bo);
 
 
@@ -548,6 +546,7 @@ struct anv_physical_device {
     uint64_t                                    aperture_size;
     struct brw_compiler *                       compiler;
     struct isl_device                           isl_dev;
+    int                                         cmd_parser_version;
 };
 
 struct anv_wsi_interaface;
@@ -607,6 +606,21 @@ struct anv_meta_state {
       VkDescriptorSetLayout                     ds_layout;
    } blit;
 
+   struct {
+      VkRenderPass render_pass;
+
+      VkPipelineLayout                          img_p_layout;
+      VkDescriptorSetLayout                     img_ds_layout;
+      VkPipelineLayout                          buf_p_layout;
+      VkDescriptorSetLayout                     buf_ds_layout;
+
+      /* Pipelines indexed by source and destination type.  See the
+       * blit2d_src_type and blit2d_dst_type enums in anv_meta_blit2d.c to
+       * see what these mean.
+       */
+      VkPipeline pipelines[2][3];
+   } blit2d;
+
    struct {
       /** Pipeline [i] resolves an image with 2^(i+1) samples.  */
       VkPipeline                                pipelines[MAX_SAMPLES_LOG2];
@@ -664,6 +678,7 @@ struct anv_device {
     struct isl_device                           isl_dev;
     int                                         context_id;
     int                                         fd;
+    bool                                        can_chain_batches;
 
     struct anv_bo_pool                          batch_bo_pool;
 
@@ -804,6 +819,15 @@ __gen_combine_address(struct anv_batch *batch, void *location,
 #define __anv_cmd_length_bias(cmd) cmd ## _length_bias
 #define __anv_cmd_header(cmd) cmd ## _header
 #define __anv_cmd_pack(cmd) cmd ## _pack
+#define __anv_reg_num(reg) reg ## _num
+
+#define anv_pack_struct(dst, struc, ...) do {                              \
+      struct struc __template = {                                          \
+         __VA_ARGS__                                                       \
+      };                                                                   \
+      __anv_cmd_pack(struc)(NULL, dst, &__template);                       \
+      VG(VALGRIND_CHECK_MEM_IS_DEFINED(dst, __anv_cmd_length(struc) * 4)); \
+   } while (0)
 
 #define anv_batch_emit(batch, cmd, ...) do {                               \
       void *__dst = anv_batch_emit_dwords(batch, __anv_cmd_length(cmd));   \
@@ -1184,6 +1208,7 @@ struct anv_cmd_pool {
 enum anv_cmd_buffer_exec_mode {
    ANV_CMD_BUFFER_EXEC_MODE_PRIMARY,
    ANV_CMD_BUFFER_EXEC_MODE_EMIT,
+   ANV_CMD_BUFFER_EXEC_MODE_GROW_AND_EMIT,
    ANV_CMD_BUFFER_EXEC_MODE_CHAIN,
    ANV_CMD_BUFFER_EXEC_MODE_COPY_AND_CHAIN,
 };
@@ -1463,8 +1488,6 @@ struct anv_graphics_pipeline_create_info {
    int8_t color_attachment_count;
 
    bool                                         use_repclear;
-   bool                                         disable_viewport;
-   bool                                         disable_scissor;
    bool                                         disable_vs;
    bool                                         use_rectlist;
 };
@@ -1642,7 +1665,6 @@ 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,
                          VkImageUsageFlags usage_mask);
 
 struct anv_buffer_view {
@@ -1657,9 +1679,47 @@ struct anv_buffer_view {
    struct brw_image_param storage_image_param;
 };
 
+void anv_buffer_view_init(struct anv_buffer_view *view,
+                          struct anv_device *device,
+                          const VkBufferViewCreateInfo* pCreateInfo,
+                          struct anv_cmd_buffer *cmd_buffer);
+
 const struct anv_format *
 anv_format_for_descriptor_type(VkDescriptorType type);
 
+static inline struct VkExtent3D
+anv_sanitize_image_extent(const VkImageType imageType,
+                          const struct VkExtent3D imageExtent)
+{
+   switch (imageType) {
+   case VK_IMAGE_TYPE_1D:
+      return (VkExtent3D) { imageExtent.width, 1, 1 };
+   case VK_IMAGE_TYPE_2D:
+      return (VkExtent3D) { imageExtent.width, imageExtent.height, 1 };
+   case VK_IMAGE_TYPE_3D:
+      return imageExtent;
+   default:
+      unreachable("invalid image type");
+   }
+}
+
+static inline struct VkOffset3D
+anv_sanitize_image_offset(const VkImageType imageType,
+                          const struct VkOffset3D imageOffset)
+{
+   switch (imageType) {
+   case VK_IMAGE_TYPE_1D:
+      return (VkOffset3D) { imageOffset.x, 0, 0 };
+   case VK_IMAGE_TYPE_2D:
+      return (VkOffset3D) { imageOffset.x, imageOffset.y, 0 };
+   case VK_IMAGE_TYPE_3D:
+      return imageOffset;
+   default:
+      unreachable("invalid image type");
+   }
+}
+
+
 void anv_fill_buffer_surface_state(struct anv_device *device,
                                    struct anv_state state,
                                    enum isl_format format,