anv: Use VkDescriptorType instead of anv_descriptor_type
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 6 Nov 2015 22:09:52 +0000 (14:09 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 6 Nov 2015 22:09:52 +0000 (14:09 -0800)
src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_device.c
src/vulkan/anv_private.h

index c0e28bdf0475026855581d35986f42fee2c1612e..77471941071fc0e7b45b3a28e7cbc8b6f1d4eb55 100644 (file)
@@ -610,11 +610,14 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
       uint32_t bo_offset;
 
       switch (desc->type) {
-      case ANV_DESCRIPTOR_TYPE_EMPTY:
-      case ANV_DESCRIPTOR_TYPE_SAMPLER:
+      case VK_DESCRIPTOR_TYPE_SAMPLER:
          /* Nothing for us to do here */
          continue;
-      case ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET: {
+
+      case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
+      case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
+      case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
+      case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
          bo = desc->buffer->bo;
          bo_offset = desc->buffer->offset + desc->offset;
 
@@ -625,12 +628,20 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
                                        bo_offset, desc->range);
          break;
       }
-      case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW:
-      case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER:
+
+      case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
+      case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
+      case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
          surface_state = desc->image_view->nonrt_surface_state;
          bo = desc->image_view->bo;
          bo_offset = desc->image_view->offset;
          break;
+
+      case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
+      case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
+      case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
+         assert(!"Unsupported descriptor type");
+         break;
       }
 
       bt_map[bias + s] = surface_state.offset + state_offset;
@@ -669,13 +680,15 @@ 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 &&
-          desc->type != ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER)
+      if (desc->type != VK_DESCRIPTOR_TYPE_SAMPLER &&
+          desc->type != VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
          continue;
 
       struct anv_sampler *sampler = desc->sampler;
 
-      /* FIXME: We shouldn't have to do this */
+      /* This can happen if we have an unfilled slot since TYPE_SAMPLER
+       * happens to be zero.
+       */
       if (sampler == NULL)
          continue;
 
index 9483816b53f353307cba8b148f48b85d85f66c07..dcb3ef20115f7c8a2b1a400dbdd2b401909ef9d1 100644 (file)
@@ -1715,7 +1715,7 @@ void anv_UpdateDescriptorSets(
                             write->pDescriptors[j].sampler);
 
             desc[j] = (struct anv_descriptor) {
-               .type = ANV_DESCRIPTOR_TYPE_SAMPLER,
+               .type = VK_DESCRIPTOR_TYPE_SAMPLER,
                .sampler = sampler,
             };
          }
@@ -1728,7 +1728,7 @@ void anv_UpdateDescriptorSets(
             ANV_FROM_HANDLE(anv_sampler, sampler,
                             write->pDescriptors[j].sampler);
 
-            desc[j].type = ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER;
+            desc[j].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
             desc[j].image_view = iview;
 
             /* If this descriptor has an immutable sampler, we don't want
@@ -1746,7 +1746,7 @@ void anv_UpdateDescriptorSets(
                             write->pDescriptors[j].imageView);
 
             desc[j] = (struct anv_descriptor) {
-               .type = ANV_DESCRIPTOR_TYPE_IMAGE_VIEW,
+               .type = write->descriptorType,
                .image_view = iview,
             };
          }
@@ -1772,7 +1772,7 @@ void anv_UpdateDescriptorSets(
             assert(buffer);
 
             desc[j] = (struct anv_descriptor) {
-               .type = ANV_DESCRIPTOR_TYPE_BUFFER_AND_OFFSET,
+               .type = write->descriptorType,
                .buffer = buffer,
                .offset = write->pDescriptors[j].bufferInfo.offset,
                .range = write->pDescriptors[j].bufferInfo.range,
index 821e16164eb6f6e9429923ec7aeb45a2c5948597..6ba2e460a8d9d3039d0973d9bbd66328390bf8f0 100644 (file)
@@ -724,16 +724,8 @@ struct anv_descriptor_set_layout {
    struct anv_descriptor_set_binding_layout binding[0];
 };
 
-enum anv_descriptor_type {
-   ANV_DESCRIPTOR_TYPE_EMPTY = 0,
-   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;
+   VkDescriptorType type;
 
    union {
       struct {