anv: Add initial support for cube maps
[mesa.git] / src / vulkan / anv_private.h
index 7c8cf2416247c43b56ffab5c09ee239880f897f0..d2b65711fc4092eb6f2e460299fa59d386cc2460 100644 (file)
@@ -266,7 +266,7 @@ anv_vector_finish(struct anv_vector *queue)
         __anv_vector_offset += (queue)->element_size)
 
 struct anv_bo {
-   int gem_handle;
+   uint32_t gem_handle;
 
    /* Index into the current validation list.  This is used by the
     * validation list building alrogithm to track which buffers are already
@@ -597,25 +597,24 @@ struct anv_device {
 };
 
 void* anv_gem_mmap(struct anv_device *device,
-                   uint32_t gem_handle, uint64_t offset, uint64_t size);
+                   uint32_t gem_handle, uint64_t offset, uint64_t size, uint32_t flags);
 void anv_gem_munmap(void *p, uint64_t size);
 uint32_t anv_gem_create(struct anv_device *device, size_t size);
-void anv_gem_close(struct anv_device *device, int gem_handle);
-int anv_gem_userptr(struct anv_device *device, void *mem, size_t size);
-int anv_gem_wait(struct anv_device *device, int gem_handle, int64_t *timeout_ns);
+void anv_gem_close(struct anv_device *device, uint32_t gem_handle);
+uint32_t anv_gem_userptr(struct anv_device *device, void *mem, size_t size);
+int anv_gem_wait(struct anv_device *device, uint32_t gem_handle, int64_t *timeout_ns);
 int anv_gem_execbuffer(struct anv_device *device,
                        struct drm_i915_gem_execbuffer2 *execbuf);
-int anv_gem_set_tiling(struct anv_device *device, int gem_handle,
+int anv_gem_set_tiling(struct anv_device *device, uint32_t gem_handle,
                        uint32_t stride, uint32_t tiling);
 int anv_gem_create_context(struct anv_device *device);
 int anv_gem_destroy_context(struct anv_device *device, int context);
 int anv_gem_get_param(int fd, uint32_t param);
 int anv_gem_get_aperture(int fd, uint64_t *size);
-int anv_gem_handle_to_fd(struct anv_device *device, int gem_handle);
-int anv_gem_fd_to_handle(struct anv_device *device, int fd);
-int anv_gem_userptr(struct anv_device *device, void *mem, size_t size);
-int anv_gem_set_caching(struct anv_device *device, int gem_handle, uint32_t caching);
-int anv_gem_set_domain(struct anv_device *device, int gem_handle,
+int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle);
+uint32_t anv_gem_fd_to_handle(struct anv_device *device, int fd);
+int anv_gem_set_caching(struct anv_device *device, uint32_t gem_handle, uint32_t caching);
+int anv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
                        uint32_t read_domains, uint32_t write_domain);
 
 VkResult anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size);
@@ -815,6 +814,9 @@ struct anv_descriptor_set_binding_layout {
 
       /* Index into the sampler table for the associated sampler */
       int16_t sampler_index;
+
+      /* Index into the image table for the associated image */
+      int16_t image_index;
    } stage[MESA_SHADER_STAGES];
 
    /* Immutable samplers (or NULL if no immutable samplers) */
@@ -849,6 +851,8 @@ struct anv_descriptor {
          struct anv_sampler *sampler;
       };
 
+      struct anv_buffer_view *buffer_view;
+
       struct {
          struct anv_buffer *buffer;
          uint64_t offset;
@@ -895,6 +899,7 @@ struct anv_pipeline_layout {
       struct {
          uint32_t surface_start;
          uint32_t sampler_start;
+         uint32_t image_start;
       } stage[MESA_SHADER_STAGES];
    } set[MAX_SETS];
 
@@ -906,6 +911,7 @@ struct anv_pipeline_layout {
       struct anv_pipeline_binding *surface_to_descriptor;
       uint32_t sampler_count;
       struct anv_pipeline_binding *sampler_to_descriptor;
+      uint32_t image_count;
    } stage[MESA_SHADER_STAGES];
 
    struct anv_pipeline_binding entries[0];
@@ -1180,6 +1186,8 @@ void anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
 struct anv_state
 anv_cmd_buffer_push_constants(struct anv_cmd_buffer *cmd_buffer,
                               gl_shader_stage stage);
+struct anv_state
+anv_cmd_buffer_cs_push_constants(struct anv_cmd_buffer *cmd_buffer);
 
 void anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
                                       struct anv_render_pass *pass,
@@ -1376,16 +1384,12 @@ struct anv_format {
    bool has_stencil;
 };
 
-/**
- * Stencil formats are often a special case. To reduce the number of lookups
- * into the VkFormat-to-anv_format translation table when working with
- * stencil, here is the handle to the table's entry for VK_FORMAT_S8_UINT.
- */
-extern const struct anv_format *const anv_format_s8_uint;
-
 const struct anv_format *
 anv_format_for_vk_format(VkFormat format);
 
+enum isl_format
+anv_get_isl_format(VkFormat format, VkImageAspectFlags aspect);
+
 static inline bool
 anv_format_is_color(const struct anv_format *format)
 {
@@ -1398,15 +1402,6 @@ anv_format_is_depth_or_stencil(const struct anv_format *format)
    return format->depth_format || format->has_stencil;
 }
 
-struct anv_image_view_info {
-   uint8_t surface_type; /**< RENDER_SURFACE_STATE.SurfaceType */
-   bool is_array:1; /**< RENDER_SURFACE_STATE.SurfaceArray */
-   bool is_cube:1; /**< RENDER_SURFACE_STATE.CubeFaceEnable* */
-};
-
-struct anv_image_view_info
-anv_image_view_info_for_vk_image_view_type(VkImageViewType type);
-
 /**
  * Subsurface of an anv_image.
  */
@@ -1434,10 +1429,9 @@ struct anv_image {
    struct anv_bo *bo;
    VkDeviceSize offset;
 
-   uint8_t surface_type; /**< RENDER_SURFACE_STATE.SurfaceType */
-
    bool needs_nonrt_surface_state:1;
    bool needs_color_rt_surface_state:1;
+   bool needs_storage_surface_state:1;
 
    /**
     * Image subsurfaces
@@ -1473,12 +1467,14 @@ struct anv_image_view {
 
    /** RENDER_SURFACE_STATE when using image as a non render target. */
    struct anv_state nonrt_surface_state;
+
+   /** RENDER_SURFACE_STATE when using image as a storage image. */
+   struct anv_state storage_surface_state;
 };
 
 struct anv_image_create_info {
    const VkImageCreateInfo *vk_info;
-   bool force_tiling;
-   enum isl_tiling tiling;
+   isl_tiling_flags_t isl_tiling_flags;
    uint32_t stride;
 };
 
@@ -1520,6 +1516,13 @@ gen9_image_view_init(struct anv_image_view *iview,
                      const VkImageViewCreateInfo* pCreateInfo,
                      struct anv_cmd_buffer *cmd_buffer);
 
+struct anv_buffer_view {
+   struct anv_bo *bo;
+   uint32_t offset; /**< Offset into bo. */
+
+   struct anv_state surface_state;
+};
+
 void anv_fill_buffer_surface_state(struct anv_device *device, void *state,
                                    const struct anv_format *format,
                                    uint32_t offset, uint32_t range,
@@ -1538,6 +1541,10 @@ void gen9_fill_buffer_surface_state(void *state, const struct anv_format *format
                                     uint32_t offset, uint32_t range,
                                     uint32_t stride);
 
+void anv_image_view_fill_image_param(struct anv_device *device,
+                                     struct anv_image_view *view,
+                                     struct brw_image_param *param);
+
 struct anv_sampler {
    uint32_t state[4];
 };
@@ -1636,6 +1643,7 @@ ANV_DEFINE_HANDLE_CASTS(anv_queue, VkQueue)
 
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool, VkCommandPool)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, VkBuffer)
+ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer_view, VkBufferView)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set, VkDescriptorSet)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set_layout, VkDescriptorSetLayout)
 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_device_memory, VkDeviceMemory)