freedreno/ir3: Fix assertion failures dumping CS high full regs.
[mesa.git] / src / freedreno / vulkan / tu_descriptor_set.h
index 5692e11b14e7f105520020550ab223cac007cfbe..ba0e57d7faa5df56b9ad09750c85aef43515e7c5 100644 (file)
 
 #include <vulkan/vulkan.h>
 
-#define MAX_SETS 32
+/* The hardware supports 5 descriptor sets, but we reserve 1 for dynamic
+ * descriptors and input attachments.
+ */
+#define MAX_SETS 4
 
 struct tu_descriptor_set_binding_layout
 {
@@ -35,21 +38,38 @@ struct tu_descriptor_set_binding_layout
    /* Number of array elements in this binding */
    uint32_t array_size;
 
+   /* The size in bytes of each Vulkan descriptor. */
+   uint32_t size;
+
    uint32_t offset;
+
+   /* For descriptors that point to a buffer, index into the array of BO's to
+    * be added to the cmdbuffer's used BO list.
+    */
    uint32_t buffer_offset;
-   uint16_t dynamic_offset_offset;
 
-   uint16_t dynamic_offset_count;
-   /* redundant with the type, each for a single array element */
-   uint32_t size;
+   /* Index into the pDynamicOffsets array for dynamic descriptors, as well as
+    * the array of dynamic descriptors (offsetted by
+    * tu_pipeline_layout::set::dynamic_offset_start).
+    */
+   uint32_t dynamic_offset_offset;
 
    /* Offset in the tu_descriptor_set_layout of the immutable samplers, or 0
     * if there are no immutable samplers. */
    uint32_t immutable_samplers_offset;
+
+   /* Offset in the tu_descriptor_set_layout of the ycbcr samplers, or 0
+    * if there are no immutable samplers. */
+   uint32_t ycbcr_samplers_offset;
+
+   /* Shader stages that use this binding */
+   uint32_t shader_stages;
 };
 
 struct tu_descriptor_set_layout
 {
+   struct vk_object_base base;
+
    /* The create flags for this descriptor set layout */
    VkDescriptorSetLayoutCreateFlags flags;
 
@@ -61,14 +81,17 @@ struct tu_descriptor_set_layout
 
    /* Shader stages affected by this descriptor set */
    uint16_t shader_stages;
-   uint16_t dynamic_shader_stages;
-
-   /* Number of buffers in this descriptor set */
-   uint32_t buffer_count;
 
    /* Number of dynamic offsets used by this descriptor set */
    uint16_t dynamic_offset_count;
 
+   /* A bitfield of which dynamic buffers are ubo's, to make the
+    * descriptor-binding-time patching easier.
+    */
+   uint32_t dynamic_ubo;
+
+   uint32_t buffer_count;
+
    bool has_immutable_samplers;
    bool has_variable_descriptors;
 
@@ -78,6 +101,8 @@ struct tu_descriptor_set_layout
 
 struct tu_pipeline_layout
 {
+   struct vk_object_base base;
+
    struct
    {
       struct tu_descriptor_set_layout *layout;
@@ -96,7 +121,17 @@ static inline const uint32_t *
 tu_immutable_samplers(const struct tu_descriptor_set_layout *set,
                       const struct tu_descriptor_set_binding_layout *binding)
 {
-   return (const uint32_t *) ((const char *) set +
-                              binding->immutable_samplers_offset);
+   return (void *) ((const char *) set + binding->immutable_samplers_offset);
 }
+
+static inline const struct tu_sampler_ycbcr_conversion *
+tu_immutable_ycbcr_samplers(const struct tu_descriptor_set_layout *set,
+                            const struct tu_descriptor_set_binding_layout *binding)
+{
+   if (!binding->ycbcr_samplers_offset)
+      return NULL;
+
+   return (void *) ((const char *) set + binding->ycbcr_samplers_offset);
+}
+
 #endif /* TU_DESCRIPTOR_SET_H */