diff options
author | Jason Ekstrand <[email protected]> | 2015-11-30 14:52:38 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-12-03 13:43:47 -0800 |
commit | 569f70be56908b3d74222bbb73cc0145f5f39735 (patch) | |
tree | a6e5bfc0b144756c66856df41ea30abe1bdcfa87 | |
parent | 4ab9391fbb35e627f2033494f0440536bb3341a8 (diff) |
vk/0.210.0: Rework copy/clear/blit API
-rw-r--r-- | include/vulkan/vulkan.h | 127 | ||||
-rw-r--r-- | src/vulkan/anv_dump.c | 18 | ||||
-rw-r--r-- | src/vulkan/anv_meta.c | 78 | ||||
-rw-r--r-- | src/vulkan/anv_meta_clear.c | 20 |
4 files changed, 114 insertions, 129 deletions
diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index d378598b0d3..3ff673f6fe4 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -1932,74 +1932,81 @@ typedef struct { VkFramebuffer framebuffer; } VkCommandBufferBeginInfo; -typedef struct { +typedef struct VkBufferCopy { VkDeviceSize srcOffset; - VkDeviceSize destOffset; - VkDeviceSize copySize; + VkDeviceSize dstOffset; + VkDeviceSize size; } VkBufferCopy; -typedef struct { - VkImageAspect aspect; +typedef struct VkImageSubresourceLayers { + VkImageAspectFlags aspectMask; uint32_t mipLevel; - uint32_t arrayLayer; - uint32_t arraySize; -} VkImageSubresourceCopy; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkImageSubresourceLayers; -typedef struct { - VkImageSubresourceCopy srcSubresource; +typedef struct VkImageCopy { + VkImageSubresourceLayers srcSubresource; VkOffset3D srcOffset; - VkImageSubresourceCopy destSubresource; - VkOffset3D destOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; VkExtent3D extent; } VkImageCopy; -typedef struct { - VkImageSubresourceCopy srcSubresource; +typedef struct VkImageBlit { + VkImageSubresourceLayers srcSubresource; VkOffset3D srcOffset; VkExtent3D srcExtent; - VkImageSubresourceCopy destSubresource; - VkOffset3D destOffset; - VkExtent3D destExtent; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; + VkExtent3D dstExtent; } VkImageBlit; -typedef struct { +typedef struct VkBufferImageCopy { VkDeviceSize bufferOffset; uint32_t bufferRowLength; uint32_t bufferImageHeight; - VkImageSubresourceCopy imageSubresource; + VkImageSubresourceLayers imageSubresource; VkOffset3D imageOffset; VkExtent3D imageExtent; } VkBufferImageCopy; -typedef union { +typedef union VkClearColorValue { float float32[4]; int32_t int32[4]; uint32_t uint32[4]; } VkClearColorValue; -typedef struct { +typedef struct VkClearDepthStencilValue { float depth; uint32_t stencil; } VkClearDepthStencilValue; -typedef struct { - VkOffset3D offset; - VkExtent3D extent; -} VkRect3D; +typedef union VkClearValue { + VkClearColorValue color; + VkClearDepthStencilValue depthStencil; +} VkClearValue; -typedef struct { - VkImageSubresourceCopy srcSubresource; +typedef struct VkClearAttachment { + VkImageAspectFlags aspectMask; + uint32_t colorAttachment; + VkClearValue clearValue; +} VkClearAttachment; + +typedef struct VkClearRect { + VkRect2D rect; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkClearRect; + +typedef struct VkImageResolve { + VkImageSubresourceLayers srcSubresource; VkOffset3D srcOffset; - VkImageSubresourceCopy destSubresource; - VkOffset3D destOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; VkExtent3D extent; } VkImageResolve; -typedef union { - VkClearColorValue color; - VkClearDepthStencilValue depthStencil; -} VkClearValue; - typedef struct { VkStructureType sType; const void* pNext; @@ -2192,9 +2199,8 @@ typedef void (VKAPI_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, V typedef void (VKAPI_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data); typedef void (VKAPI_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); typedef void (VKAPI_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); -typedef void (VKAPI_PTR *PFN_vkCmdClearColorAttachment)(VkCommandBuffer commandBuffer, uint32_t colorAttachment, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rectCount, const VkRect3D* pRects); -typedef void (VKAPI_PTR *PFN_vkCmdClearDepthStencilAttachment)(VkCommandBuffer commandBuffer, VkImageAspectFlags aspectMask, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rectCount, const VkRect3D* pRects); -typedef void (VKAPI_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout, uint32_t regionCount, const VkImageResolve* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects); +typedef void (VKAPI_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions); typedef void (VKAPI_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); typedef void (VKAPI_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags destStageMask, uint32_t memBarrierCount, const void* const* ppMemBarriers); @@ -2816,7 +2822,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect( VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer( VkCommandBuffer commandBuffer, VkBuffer srcBuffer, - VkBuffer destBuffer, + VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions); @@ -2824,8 +2830,8 @@ VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage( VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage destImage, - VkImageLayout destImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions); @@ -2833,8 +2839,8 @@ VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage( VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage destImage, - VkImageLayout destImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkTexFilter filter); @@ -2842,8 +2848,8 @@ VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage( VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage( VkCommandBuffer commandBuffer, VkBuffer srcBuffer, - VkImage destImage, - VkImageLayout destImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions); @@ -2851,22 +2857,22 @@ VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer( VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkBuffer destBuffer, + VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions); VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer( VkCommandBuffer commandBuffer, - VkBuffer destBuffer, - VkDeviceSize destOffset, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, VkDeviceSize dataSize, const uint32_t* pData); VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( VkCommandBuffer commandBuffer, - VkBuffer destBuffer, - VkDeviceSize destOffset, - VkDeviceSize fillSize, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + VkDeviceSize size, uint32_t data); VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage( @@ -2885,28 +2891,19 @@ VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage( uint32_t rangeCount, const VkImageSubresourceRange* pRanges); -VKAPI_ATTR void VKAPI_CALL vkCmdClearColorAttachment( - VkCommandBuffer commandBuffer, - uint32_t colorAttachment, - VkImageLayout imageLayout, - const VkClearColorValue* pColor, - uint32_t rectCount, - const VkRect3D* pRects); - -VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilAttachment( +VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments( VkCommandBuffer commandBuffer, - VkImageAspectFlags aspectMask, - VkImageLayout imageLayout, - const VkClearDepthStencilValue* pDepthStencil, + uint32_t attachmentCount, + const VkClearAttachment* pAttachments, uint32_t rectCount, - const VkRect3D* pRects); + const VkClearRect* pRects); VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage( VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage destImage, - VkImageLayout destImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions); diff --git a/src/vulkan/anv_dump.c b/src/vulkan/anv_dump.c index 9d0c4d700e5..52b9ca17b43 100644 --- a/src/vulkan/anv_dump.c +++ b/src/vulkan/anv_dump.c @@ -103,10 +103,10 @@ anv_dump_image_to_ppm(struct anv_device *device, copy_image, VK_IMAGE_LAYOUT_GENERAL, 1, &(VkImageBlit) { .srcSubresource = { - .aspect = VK_IMAGE_ASPECT_COLOR, + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .mipLevel = miplevel, - .arrayLayer = array_layer, - .arraySize = 1, + .baseArrayLayer = array_layer, + .layerCount = 1, }, .srcOffset = (VkOffset3D) { 0, 0, 0 }, .srcExtent = (VkExtent3D) { @@ -114,14 +114,14 @@ anv_dump_image_to_ppm(struct anv_device *device, extent.height, 1 }, - .destSubresource = { - .aspect = VK_IMAGE_ASPECT_COLOR, + .dstSubresource = { + .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .mipLevel = 0, - .arrayLayer = 0, - .arraySize = 1, + .baseArrayLayer = 0, + .layerCount = 1, }, - .destOffset = (VkOffset3D) { 0, 0, 0 }, - .destExtent = (VkExtent3D) { + .dstOffset = (VkOffset3D) { 0, 0, 0 }, + .dstExtent = (VkExtent3D) { extent.width, extent.height, 1 diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index eabe207389e..3b4c8890b13 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -163,13 +163,13 @@ meta_blit_get_src_image_view_type(const struct anv_image *src_image) static uint32_t meta_blit_get_dest_view_base_array_slice(const struct anv_image *dest_image, - const VkImageSubresourceCopy *dest_subresource, + const VkImageSubresourceLayers *dest_subresource, const VkOffset3D *dest_offset) { switch (dest_image->type) { case VK_IMAGE_TYPE_1D: case VK_IMAGE_TYPE_2D: - return dest_subresource->arrayLayer; + return dest_subresource->baseArrayLayer; case VK_IMAGE_TYPE_3D: /* HACK: Vulkan does not allow attaching a 3D image to a framebuffer, * but meta does it anyway. When doing so, we translate the @@ -757,8 +757,8 @@ void anv_CmdCopyBuffer( for (unsigned r = 0; r < regionCount; r++) { uint64_t src_offset = src_buffer->offset + pRegions[r].srcOffset; - uint64_t dest_offset = dest_buffer->offset + pRegions[r].destOffset; - uint64_t copy_size = pRegions[r].copySize; + uint64_t dest_offset = dest_buffer->offset + pRegions[r].dstOffset; + uint64_t copy_size = pRegions[r].size; /* First, we compute the biggest format that can be used with the * given offsets and size. @@ -775,10 +775,10 @@ void anv_CmdCopyBuffer( bs = MIN2(bs, 1 << fs); assert(dest_offset % bs == 0); - fs = ffs(pRegions[r].copySize) - 1; + fs = ffs(pRegions[r].size) - 1; if (fs != -1) bs = MIN2(bs, 1 << fs); - assert(pRegions[r].copySize % bs == 0); + assert(pRegions[r].size % bs == 0); VkFormat copy_format = vk_format_for_size(bs); @@ -847,37 +847,37 @@ void anv_CmdCopyImage( .viewType = src_iview_type, .format = src_image->format->vk_format, .subresourceRange = { - .aspectMask = 1 << pRegions[r].srcSubresource.aspect, + .aspectMask = pRegions[r].srcSubresource.aspectMask, .baseMipLevel = pRegions[r].srcSubresource.mipLevel, .mipLevels = 1, - .baseArrayLayer = pRegions[r].srcSubresource.arrayLayer, - .arraySize = pRegions[r].destSubresource.arraySize, + .baseArrayLayer = pRegions[r].srcSubresource.baseArrayLayer, + .arraySize = pRegions[r].dstSubresource.layerCount, }, }, cmd_buffer); const VkOffset3D dest_offset = { - .x = pRegions[r].destOffset.x, - .y = pRegions[r].destOffset.y, + .x = pRegions[r].dstOffset.x, + .y = pRegions[r].dstOffset.y, .z = 0, }; unsigned num_slices; if (src_image->type == VK_IMAGE_TYPE_3D) { - assert(pRegions[r].srcSubresource.arraySize == 1 && - pRegions[r].destSubresource.arraySize == 1); + assert(pRegions[r].srcSubresource.layerCount == 1 && + pRegions[r].dstSubresource.layerCount == 1); num_slices = pRegions[r].extent.depth; } else { - assert(pRegions[r].srcSubresource.arraySize == - pRegions[r].destSubresource.arraySize); + assert(pRegions[r].srcSubresource.layerCount == + pRegions[r].dstSubresource.layerCount); assert(pRegions[r].extent.depth == 1); - num_slices = pRegions[r].destSubresource.arraySize; + num_slices = pRegions[r].dstSubresource.layerCount; } const uint32_t dest_base_array_slice = meta_blit_get_dest_view_base_array_slice(dest_image, - &pRegions[r].destSubresource, - &pRegions[r].destOffset); + &pRegions[r].dstSubresource, + &pRegions[r].dstOffset); for (unsigned slice = 0; slice < num_slices; slice++) { VkOffset3D src_offset = pRegions[r].srcOffset; @@ -892,7 +892,7 @@ void anv_CmdCopyImage( .format = dest_image->format->vk_format, .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .baseMipLevel = pRegions[r].destSubresource.mipLevel, + .baseMipLevel = pRegions[r].dstSubresource.mipLevel, .mipLevels = 1, .baseArrayLayer = dest_base_array_slice + slice, .arraySize = 1 @@ -947,30 +947,30 @@ void anv_CmdBlitImage( .viewType = src_iview_type, .format = src_image->format->vk_format, .subresourceRange = { - .aspectMask = 1 << pRegions[r].srcSubresource.aspect, + .aspectMask = pRegions[r].srcSubresource.aspectMask, .baseMipLevel = pRegions[r].srcSubresource.mipLevel, .mipLevels = 1, - .baseArrayLayer = pRegions[r].srcSubresource.arrayLayer, + .baseArrayLayer = pRegions[r].srcSubresource.baseArrayLayer, .arraySize = 1 }, }, cmd_buffer); const VkOffset3D dest_offset = { - .x = pRegions[r].destOffset.x, - .y = pRegions[r].destOffset.y, + .x = pRegions[r].dstOffset.x, + .y = pRegions[r].dstOffset.y, .z = 0, }; const uint32_t dest_array_slice = meta_blit_get_dest_view_base_array_slice(dest_image, - &pRegions[r].destSubresource, - &pRegions[r].destOffset); + &pRegions[r].dstSubresource, + &pRegions[r].dstOffset); - if (pRegions[r].srcSubresource.arraySize > 1) + if (pRegions[r].srcSubresource.layerCount > 1) anv_finishme("FINISHME: copy multiple array layers"); - if (pRegions[r].destExtent.depth > 1) + if (pRegions[r].dstExtent.depth > 1) anv_finishme("FINISHME: copy multiple depth layers"); struct anv_image_view dest_iview; @@ -982,7 +982,7 @@ void anv_CmdBlitImage( .format = dest_image->format->vk_format, .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .baseMipLevel = pRegions[r].destSubresource.mipLevel, + .baseMipLevel = pRegions[r].dstSubresource.mipLevel, .mipLevels = 1, .baseArrayLayer = dest_array_slice, .arraySize = 1 @@ -996,7 +996,7 @@ void anv_CmdBlitImage( pRegions[r].srcExtent, dest_image, &dest_iview, dest_offset, - pRegions[r].destExtent, + pRegions[r].dstExtent, filter); } @@ -1063,11 +1063,11 @@ void anv_CmdCopyBufferToImage( for (unsigned r = 0; r < regionCount; r++) { VkFormat proxy_format = orig_format; - VkImageAspect proxy_aspect = pRegions[r].imageSubresource.aspect; + VkImageAspectFlags proxy_aspect = pRegions[r].imageSubresource.aspectMask; if (orig_format == VK_FORMAT_S8_UINT) { proxy_format = VK_FORMAT_R8_UINT; - proxy_aspect = VK_IMAGE_ASPECT_COLOR; + proxy_aspect = VK_IMAGE_ASPECT_COLOR_BIT; } struct anv_image *src_image = @@ -1082,11 +1082,11 @@ void anv_CmdCopyBufferToImage( unsigned num_slices; if (dest_image->type == VK_IMAGE_TYPE_3D) { - assert(pRegions[r].imageSubresource.arraySize == 1); + assert(pRegions[r].imageSubresource.layerCount == 1); num_slices = pRegions[r].imageExtent.depth; } else { assert(pRegions[r].imageExtent.depth == 1); - num_slices = pRegions[r].imageSubresource.arraySize; + num_slices = pRegions[r].imageSubresource.layerCount; } for (unsigned slice = 0; slice < num_slices; slice++) { @@ -1098,7 +1098,7 @@ void anv_CmdCopyBufferToImage( .viewType = VK_IMAGE_VIEW_TYPE_2D, .format = proxy_format, .subresourceRange = { - .aspectMask = 1 << proxy_aspect, + .aspectMask = proxy_aspect, .baseMipLevel = 0, .mipLevels = 1, .baseArrayLayer = 0, @@ -1186,11 +1186,11 @@ void anv_CmdCopyImageToBuffer( .viewType = src_iview_type, .format = src_image->format->vk_format, .subresourceRange = { - .aspectMask = 1 << pRegions[r].imageSubresource.aspect, + .aspectMask = pRegions[r].imageSubresource.aspectMask, .baseMipLevel = pRegions[r].imageSubresource.mipLevel, .mipLevels = 1, - .baseArrayLayer = pRegions[r].imageSubresource.arrayLayer, - .arraySize = pRegions[r].imageSubresource.arraySize, + .baseArrayLayer = pRegions[r].imageSubresource.baseArrayLayer, + .arraySize = pRegions[r].imageSubresource.layerCount, }, }, cmd_buffer); @@ -1207,11 +1207,11 @@ void anv_CmdCopyImageToBuffer( unsigned num_slices; if (src_image->type == VK_IMAGE_TYPE_3D) { - assert(pRegions[r].imageSubresource.arraySize == 1); + assert(pRegions[r].imageSubresource.layerCount == 1); num_slices = pRegions[r].imageExtent.depth; } else { assert(pRegions[r].imageExtent.depth == 1); - num_slices = pRegions[r].imageSubresource.arraySize; + num_slices = pRegions[r].imageSubresource.layerCount; } for (unsigned slice = 0; slice < num_slices; slice++) { diff --git a/src/vulkan/anv_meta_clear.c b/src/vulkan/anv_meta_clear.c index a9bcbc3be9e..d1f1d95a3aa 100644 --- a/src/vulkan/anv_meta_clear.c +++ b/src/vulkan/anv_meta_clear.c @@ -798,24 +798,12 @@ void anv_CmdClearDepthStencilImage( stub(); } -void anv_CmdClearColorAttachment( +void anv_CmdClearAttachments( VkCommandBuffer commandBuffer, - uint32_t colorAttachment, - VkImageLayout imageLayout, - const VkClearColorValue* pColor, - uint32_t rectCount, - const VkRect3D* pRects) -{ - stub(); -} - -void anv_CmdClearDepthStencilAttachment( - VkCommandBuffer commandBuffer, - VkImageAspectFlags aspectMask, - VkImageLayout imageLayout, - const VkClearDepthStencilValue* pDepthStencil, + uint32_t attachmentCount, + const VkClearAttachment* pAttachments, uint32_t rectCount, - const VkRect3D* pRects) + const VkClearRect* pRects) { stub(); } |