anv/device: Add support for combined image and sampler descriptors
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Oct 2015 22:17:27 +0000 (15:17 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Oct 2015 22:17:27 +0000 (15:17 -0700)
src/vulkan/anv_cmd_buffer.c
src/vulkan/anv_device.c

index 2801f730478fd8d08c568921c647ce982ddeb8cb..19ad31167bf74d1db9ff9b21d597e8d0865e0ce6 100644 (file)
@@ -608,6 +608,7 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
       switch (desc->type) {
       case ANV_DESCRIPTOR_TYPE_EMPTY:
       case ANV_DESCRIPTOR_TYPE_SAMPLER:
+         /* Nothing for us to do here */
          continue;
       case ANV_DESCRIPTOR_TYPE_BUFFER_VIEW:
          surface_state = &desc->buffer_view->surface_state;
@@ -626,13 +627,11 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
          break;
       }
       case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW:
+      case ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER:
          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;
@@ -677,6 +676,10 @@ anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer,
 
       struct anv_sampler *sampler = desc->sampler;
 
+      /* FIXME: We shouldn't have to do this */
+      if (sampler == NULL)
+         continue;
+
       memcpy(state->map + (s * 16),
              sampler->state, sizeof(sampler->state));
    }
index d9065b053904c056b23528a58b3a2f028c5d5546..2ae39741fe67f3eb7fe2c87e1a749e11cc5e87ea 100644 (file)
@@ -1646,7 +1646,6 @@ void anv_UpdateDescriptorSets(
 
       switch (write->descriptorType) {
       case VK_DESCRIPTOR_TYPE_SAMPLER:
-      case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
          for (uint32_t j = 0; j < write->count; j++) {
             ANV_FROM_HANDLE(anv_sampler, sampler,
                             write->pDescriptors[j].sampler);
@@ -1656,11 +1655,22 @@ void anv_UpdateDescriptorSets(
                .sampler = sampler,
             };
          }
+         break;
 
-         if (write->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER)
-            break;
+      case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
+         for (uint32_t j = 0; j < write->count; j++) {
+            ANV_FROM_HANDLE(anv_image_view, iview,
+                            write->pDescriptors[j].imageView);
+            ANV_FROM_HANDLE(anv_sampler, sampler,
+                            write->pDescriptors[j].sampler);
 
-         /* fallthrough */
+            set->descriptors[write->destBinding + j] = (struct anv_descriptor) {
+               .type = ANV_DESCRIPTOR_TYPE_IMAGE_VIEW_AND_SAMPLER,
+               .image_view = iview,
+               .sampler = sampler,
+            };
+         }
+         break;
 
       case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
       case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: