anv: Add support for BufferInfo in descriptor sets
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Oct 2015 20:45:53 +0000 (13:45 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Oct 2015 20:45:53 +0000 (13:45 -0700)
src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_device.c
src/vulkan/anv_private.h

index df076d0cac604c4a0babe08b67581a494142a992..2801f730478fd8d08c568921c647ce982ddeb8cb 100644 (file)
@@ -614,11 +614,25 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
          bo = desc->buffer_view->bo;
          bo_offset = desc->buffer_view->offset;
          break;
+      case ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET: {
+         struct anv_state state =
+            anv_cmd_buffer_alloc_surface_state(cmd_buffer);
+         anv_fill_buffer_surface_state(cmd_buffer->device, state.map,
+                                       anv_format_for_vk_format(VK_FORMAT_R32G32B32A32_SFLOAT),
+                                       desc->offset, desc->range);
+         surface_state = &state;
+         bo = desc->buffer_view->bo;
+         bo_offset = desc->buffer_view->offset;
+         break;
+      }
       case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW:
          surface_state = &desc->image_view->nonrt_surface_state;
          bo = desc->image_view->bo;
          bo_offset = desc->image_view->offset;
          break;
+      case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER:
+         /* Nothing for us to do here */
+         break;
       }
 
       bt_map[bias + s] = surface_state->offset + state_offset;
@@ -657,7 +671,8 @@ anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer,
          cmd_buffer->state.descriptors[binding->set];
       struct anv_descriptor *desc = &set->descriptors[binding->offset];
 
-      if (desc->type != ANV_DESCRIPTOR_TYPE_SAMPLER)
+      if (desc->type != ANV_DESCRIPTOR_TYPE_SAMPLER &&
+          desc->type != ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER)
          continue;
 
       struct anv_sampler *sampler = desc->sampler;
index 98c1b2334e6b0956f2ccf60e298c6fa4ae2acb18..cc9ead86e73ee49cd3fa04355487e4e027243530 100644 (file)
@@ -1698,13 +1698,28 @@ void anv_UpdateDescriptorSets(
       case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
       case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
          for (uint32_t j = 0; j < write->count; j++) {
-            ANV_FROM_HANDLE(anv_buffer_view, bview,
-                            write->pDescriptors[j].bufferView);
-
-            set->descriptors[write->destBinding + j] = (struct anv_descriptor) {
-               .type = ANV_DESCRIPTOR_TYPE_BUFFER_VIEW,
-               .buffer_view = bview,
-            };
+            if (write->pDescriptors[j].bufferView.handle) {
+               ANV_FROM_HANDLE(anv_buffer_view, bview,
+                               write->pDescriptors[j].bufferView);
+
+               set->descriptors[write->destBinding + j] =
+                  (struct anv_descriptor) {
+                     .type = ANV_DESCRIPTOR_TYPE_BUFFER_VIEW,
+                     .buffer_view = bview,
+                  };
+            } else {
+               ANV_FROM_HANDLE(anv_buffer, buffer,
+                               write->pDescriptors[j].bufferInfo.buffer);
+               assert(buffer);
+
+               set->descriptors[write->destBinding + j] =
+                  (struct anv_descriptor) {
+                     .type = ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET,
+                     .buffer = buffer,
+                     .offset = write->pDescriptors[j].bufferInfo.offset,
+                     .range = write->pDescriptors[j].bufferInfo.range,
+                  };
+            }
          }
 
       default:
index bcfb6fada50b064edf92f1b96b8c1ac6f9a23951..6bbf7c0291ba87b24075c684378c8e7a785c2250 100644 (file)
@@ -696,18 +696,30 @@ struct anv_descriptor_set_layout {
 enum anv_descriptor_type {
    ANV_DESCRIPTOR_TYPE_EMPTY = 0,
    ANV_DESCRIPTOR_TYPE_BUFFER_VIEW,
+   ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET,
    ANV_DESCRIPTOR_TYPE_IMAGE_VIEW,
    ANV_DESCRIPTOR_TYPE_SAMPLER,
+   ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER,
 };
 
 struct anv_descriptor {
+   enum anv_descriptor_type type;
+
    union {
-      struct anv_buffer_view *buffer_view;
-      struct anv_image_view *image_view;
-      struct anv_sampler *sampler;
-   };
+      struct {
+         union {
+            struct anv_buffer_view *buffer_view;
+            struct anv_image_view *image_view;
+         };
+         struct anv_sampler *sampler;
+      };
 
-   enum anv_descriptor_type type;
+      struct {
+         struct anv_buffer *buffer;
+         uint64_t offset;
+         uint64_t range;
+      };
+   };
 };
 
 struct anv_descriptor_set {