vk/0.170.2: Update VkImageSubresourceRange
authorChad Versace <chad.versace@intel.com>
Mon, 5 Oct 2015 13:48:14 +0000 (06:48 -0700)
committerChad Versace <chad.versace@intel.com>
Mon, 5 Oct 2015 15:10:57 +0000 (08:10 -0700)
Replace 'aspect' with 'aspectMask'.

include/vulkan/vulkan.h
src/vulkan/anv_image.c
src/vulkan/anv_meta.c
src/vulkan/anv_private.h
src/vulkan/gen7_state.c
src/vulkan/gen8_state.c

index 923a3b69ea36a0c1639e542428730c84c19cbd18..fc6a1c638c6ede6fa54b5f0469c62b4e8be96f59 100644 (file)
@@ -1505,7 +1505,7 @@ typedef struct {
 } VkChannelMapping;
 
 typedef struct {
-    VkImageAspect                               aspect;
+    VkImageAspectFlags                          aspectMask;
     uint32_t                                    baseMipLevel;
     uint32_t                                    mipLevels;
     uint32_t                                    baseArraySlice;
index dce4208ed5fb106685466cdc7a769a143b6c2a11..2045aa27219b3b453e0287d4b991021f30537bbe 100644 (file)
@@ -415,8 +415,7 @@ anv_validate_CreateImageView(VkDevice _device,
    assert(pCreateInfo->channels.a <= VK_CHANNEL_SWIZZLE_END_RANGE);
 
    /* Validate subresource. */
-   assert(subresource->aspect >= VK_IMAGE_ASPECT_BEGIN_RANGE);
-   assert(subresource->aspect <= VK_IMAGE_ASPECT_END_RANGE);
+   assert(subresource->aspectMask != 0);
    assert(subresource->mipLevels > 0);
    assert(subresource->arraySize > 0);
    assert(subresource->baseMipLevel < image->levels);
@@ -430,28 +429,33 @@ anv_validate_CreateImageView(VkDevice _device,
       assert(subresource->arraySize % 6 == 0);
    }
 
+   const VkImageAspectFlags ds_flags = VK_IMAGE_ASPECT_DEPTH_BIT
+                                     | VK_IMAGE_ASPECT_STENCIL_BIT;
+
    /* Validate format. */
-   switch (subresource->aspect) {
-   case VK_IMAGE_ASPECT_COLOR:
+   if (subresource->aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) {
+      assert(subresource->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
       assert(!image->format->depth_format);
       assert(!image->format->has_stencil);
       assert(!view_format_info->depth_format);
       assert(!view_format_info->has_stencil);
       assert(view_format_info->cpp == image->format->cpp);
-      break;
-   case VK_IMAGE_ASPECT_DEPTH:
-      assert(image->format->depth_format);
-      assert(view_format_info->depth_format);
-      assert(view_format_info->cpp == image->format->cpp);
-      break;
-   case VK_IMAGE_ASPECT_STENCIL:
-      /* FINISHME: Is it legal to have an R8 view of S8? */
-      assert(image->format->has_stencil);
-      assert(view_format_info->has_stencil);
-      break;
-   default:
-      assert(!"bad VkImageAspect");
-      break;
+   } else if (subresource->aspectMask & ds_flags) {
+      assert((subresource->aspectMask & ~ds_flags) == 0);
+
+      if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) {
+         assert(image->format->depth_format);
+         assert(view_format_info->depth_format);
+         assert(view_format_info->cpp == image->format->cpp);
+      }
+
+      if (subresource->aspectMask & VK_IMAGE_ASPECT_STENCIL) {
+         /* FINISHME: Is it legal to have an R8 view of S8? */
+         assert(image->format->has_stencil);
+         assert(view_format_info->has_stencil);
+      }
+   } else {
+      assert(!"bad VkImageSubresourceRange::aspectFlags");
    }
 
    return anv_CreateImageView(_device, pCreateInfo, pView);
@@ -528,19 +532,27 @@ anv_depth_stencil_view_init(struct anv_depth_stencil_view *view,
 }
 
 struct anv_surface *
-anv_image_get_surface_for_aspect(struct anv_image *image, VkImageAspect aspect)
+anv_image_get_surface_for_aspect_mask(struct anv_image *image, VkImageAspectFlags aspect_mask)
 {
-   switch (aspect) {
-   case VK_IMAGE_ASPECT_COLOR:
+   switch (aspect_mask) {
+   case VK_IMAGE_ASPECT_COLOR_BIT:
       assert(anv_format_is_color(image->format));
       return &image->color_surface;
-   case VK_IMAGE_ASPECT_DEPTH:
+   case VK_IMAGE_ASPECT_DEPTH_BIT:
       assert(image->format->depth_format);
       return &image->depth_surface;
-   case VK_IMAGE_ASPECT_STENCIL:
+   case VK_IMAGE_ASPECT_STENCIL_BIT:
       assert(image->format->has_stencil);
       anv_finishme("stencil image views");
       return &image->stencil_surface;
+   case VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT:
+      /* FINISHME: Support combined depthstencil aspect. Does the Vulkan spec
+       * allow is to reject it? Until we support it, filter out the stencil
+       * aspect and use only the depth aspect.
+       */
+      anv_finishme("combined depthstencil aspect");
+      assert(image->format->depth_format);
+      return &image->depth_surface;
     default:
        unreachable("image does not have aspect");
        return NULL;
index e43d11b06eebfaeb48de6b93f22785044328c9ee..dd8f3a958a6a69024917dca614043247c462d29b 100644 (file)
@@ -1013,7 +1013,7 @@ do_buffer_copy(struct anv_cmd_buffer *cmd_buffer,
             VK_CHANNEL_SWIZZLE_A
          },
          .subresourceRange = {
-            .aspect = VK_IMAGE_ASPECT_COLOR,
+            .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
             .baseMipLevel = 0,
             .mipLevels = 1,
             .baseArraySlice = 0,
@@ -1161,7 +1161,7 @@ void anv_CmdCopyImage(
                VK_CHANNEL_SWIZZLE_A
             },
             .subresourceRange = {
-               .aspect = pRegions[r].srcSubresource.aspect,
+               .aspectMask = 1 << pRegions[r].srcSubresource.aspect,
                .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
                .mipLevels = 1,
                .baseArraySlice = pRegions[r].srcSubresource.arraySlice,
@@ -1247,7 +1247,7 @@ void anv_CmdBlitImage(
                VK_CHANNEL_SWIZZLE_A
             },
             .subresourceRange = {
-               .aspect = pRegions[r].srcSubresource.aspect,
+               .aspectMask = 1 << pRegions[r].srcSubresource.aspect,
                .baseMipLevel = pRegions[r].srcSubresource.mipLevel,
                .mipLevels = 1,
                .baseArraySlice = pRegions[r].srcSubresource.arraySlice,
@@ -1377,7 +1377,7 @@ void anv_CmdCopyBufferToImage(
                VK_CHANNEL_SWIZZLE_A
             },
             .subresourceRange = {
-               .aspect = proxy_aspect,
+               .aspectMask = 1 << proxy_aspect,
                .baseMipLevel = 0,
                .mipLevels = 1,
                .baseArraySlice = 0,
@@ -1464,7 +1464,7 @@ void anv_CmdCopyImageToBuffer(
                VK_CHANNEL_SWIZZLE_A
             },
             .subresourceRange = {
-               .aspect = pRegions[r].imageSubresource.aspect,
+               .aspectMask = 1 << pRegions[r].imageSubresource.aspect,
                .baseMipLevel = pRegions[r].imageSubresource.mipLevel,
                .mipLevels = 1,
                .baseArraySlice = pRegions[r].imageSubresource.arraySlice,
index f0d288342d6efbf62f97480f2681f125a323c8a8..a2211bb76b3d1f29dc3010f7d3526d7dccf6680a 100644 (file)
@@ -1273,7 +1273,8 @@ VkResult anv_image_create(VkDevice _device,
                           VkImage *pImage);
 
 struct anv_surface *
-anv_image_get_surface_for_aspect(struct anv_image *image, VkImageAspect aspect);
+anv_image_get_surface_for_aspect_mask(struct anv_image *image,
+                                      VkImageAspectFlags aspect_mask);
 
 struct anv_surface *
 anv_image_get_surface_for_color_attachment(struct anv_image *image);
index faf99a5aef844c4db6ecfab7ec50ab3d0d7b54d1..f93349da0b06bf8c6841f95ce14b779d95a86ac2 100644 (file)
@@ -274,7 +274,7 @@ gen7_image_view_init(struct anv_image_view *iview,
    const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
    struct anv_surface_view *view = &iview->view;
    struct anv_surface *surface =
-      anv_image_get_surface_for_aspect(image, range->aspect);
+      anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
 
    const struct anv_format *format =
       anv_format_for_vk_format(pCreateInfo->format);
index 5646637e4a0beee023a2d3027c962ca7fad159e9..3709a50005d74636f234d4910f926bb94e2fa7cf 100644 (file)
@@ -150,7 +150,7 @@ gen8_image_view_init(struct anv_image_view *iview,
    const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
    struct anv_surface_view *view = &iview->view;
    struct anv_surface *surface =
-      anv_image_get_surface_for_aspect(image, range->aspect);
+      anv_image_get_surface_for_aspect_mask(image, range->aspectMask);
 
    uint32_t depth = 1; /* RENDER_SURFACE_STATE::Depth */
    uint32_t rt_view_extent = 1; /* RENDER_SURFACE_STATE::RenderTargetViewExtent */