Re: [Mesa-dev] [PATCH 2/2] vulkan/wsi/radv: add initial prime support
Feel free to add my "Tested by" to these Tested with vulkaninfo, vulkancube, vulkanscene and The Talos Principle 32bit & 64bit Cheers Mike On 21 February 2017 at 02:26, Dave Airliewrote: > From: Dave Airlie > > This is a complete rewrite of my previous rfc patches. > > This adds the ability to present to a different GPU that rendering > using a driver side operation that can copy from the tiled to > linear shared image. > > This does prime support completely in the swapchain present code, > and each queue has a precreated command buffer for each image > and for the each queue family. This means presenting should work > on graphics and compute queues and transfer in the future. > > Signed-off-by: Dave Airlie > --- > src/amd/vulkan/radv_meta.h | 3 + > src/amd/vulkan/radv_meta_copy.c | 20 ++ > src/amd/vulkan/radv_wsi.c | 136 > +--- > src/amd/vulkan/radv_wsi_x11.c | 4 +- > src/intel/vulkan/anv_wsi.c | 5 +- > src/intel/vulkan/anv_wsi_x11.c | 4 +- > src/vulkan/wsi/wsi_common.h | 8 +++ > src/vulkan/wsi/wsi_common_wayland.c | 4 ++ > src/vulkan/wsi/wsi_common_x11.c | 59 ++-- > src/vulkan/wsi/wsi_common_x11.h | 1 + > 10 files changed, 223 insertions(+), 21 deletions(-) > > diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h > index 8eb3df3..d70fef1 100644 > --- a/src/amd/vulkan/radv_meta.h > +++ b/src/amd/vulkan/radv_meta.h > @@ -208,6 +208,9 @@ void radv_meta_resolve_compute_image(struct > radv_cmd_buffer *cmd_buffer, > uint32_t region_count, > const VkImageResolve *regions); > > +void radv_blit_to_prime_linear(struct radv_cmd_buffer *cmd_buffer, > + struct radv_image *image, > + struct radv_image *linear_image); > #ifdef __cplusplus > } > #endif > diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c > index 2bd20b5..5473764 100644 > --- a/src/amd/vulkan/radv_meta_copy.c > +++ b/src/amd/vulkan/radv_meta_copy.c > @@ -430,3 +430,23 @@ void radv_CmdCopyImage( > meta_copy_image(cmd_buffer, src_image, dest_image, > regionCount, pRegions); > } > + > +void radv_blit_to_prime_linear(struct radv_cmd_buffer *cmd_buffer, > + struct radv_image *image, > + struct radv_image *linear_image) > +{ > + struct VkImageCopy image_copy = { 0 }; > + > + image_copy.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; > + image_copy.srcSubresource.layerCount = 1; > + > + image_copy.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; > + image_copy.dstSubresource.layerCount = 1; > + > + image_copy.extent.width = image->extent.width; > + image_copy.extent.height = image->extent.height; > + image_copy.extent.depth = 1; > + > + meta_copy_image(cmd_buffer, image, linear_image, > + 1, _copy); > +} > diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c > index ea8e784..4d0168f 100644 > --- a/src/amd/vulkan/radv_wsi.c > +++ b/src/amd/vulkan/radv_wsi.c > @@ -24,6 +24,7 @@ > */ > > #include "radv_private.h" > +#include "radv_meta.h" > #include "wsi_common.h" > > static const struct wsi_callbacks wsi_cbs = { > @@ -92,7 +93,7 @@ VkResult radv_GetPhysicalDeviceSurfaceSupportKHR( > > return iface->get_support(surface, >wsi_device, > >instance->alloc, > - queueFamilyIndex, device->local_fd, > pSupported); > + queueFamilyIndex, device->local_fd, true, > pSupported); > } > > VkResult radv_GetPhysicalDeviceSurfaceCapabilitiesKHR( > @@ -139,6 +140,8 @@ static VkResult > radv_wsi_image_create(VkDevice device_h, > const VkSwapchainCreateInfoKHR *pCreateInfo, > const VkAllocationCallbacks* pAllocator, > + bool needs_linear_copy, > + bool linear, > VkImage *image_p, > VkDeviceMemory *memory_p, > uint32_t *size, > @@ -169,7 +172,7 @@ radv_wsi_image_create(VkDevice device_h, >.arrayLayers = 1, >.samples = 1, >/* FIXME: Need a way to > use X tiling to allow scanout */ > - .tiling = > VK_IMAGE_TILING_OPTIMAL, > + .tiling = linear ? > VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL, >.usage = > VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, >
[Mesa-dev] [PATCH 2/2] vulkan/wsi/radv: add initial prime support
From: Dave AirlieThis is a complete rewrite of my previous rfc patches. This adds the ability to present to a different GPU that rendering using a driver side operation that can copy from the tiled to linear shared image. This does prime support completely in the swapchain present code, and each queue has a precreated command buffer for each image and for the each queue family. This means presenting should work on graphics and compute queues and transfer in the future. Signed-off-by: Dave Airlie --- src/amd/vulkan/radv_meta.h | 3 + src/amd/vulkan/radv_meta_copy.c | 20 ++ src/amd/vulkan/radv_wsi.c | 136 +--- src/amd/vulkan/radv_wsi_x11.c | 4 +- src/intel/vulkan/anv_wsi.c | 5 +- src/intel/vulkan/anv_wsi_x11.c | 4 +- src/vulkan/wsi/wsi_common.h | 8 +++ src/vulkan/wsi/wsi_common_wayland.c | 4 ++ src/vulkan/wsi/wsi_common_x11.c | 59 ++-- src/vulkan/wsi/wsi_common_x11.h | 1 + 10 files changed, 223 insertions(+), 21 deletions(-) diff --git a/src/amd/vulkan/radv_meta.h b/src/amd/vulkan/radv_meta.h index 8eb3df3..d70fef1 100644 --- a/src/amd/vulkan/radv_meta.h +++ b/src/amd/vulkan/radv_meta.h @@ -208,6 +208,9 @@ void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, uint32_t region_count, const VkImageResolve *regions); +void radv_blit_to_prime_linear(struct radv_cmd_buffer *cmd_buffer, + struct radv_image *image, + struct radv_image *linear_image); #ifdef __cplusplus } #endif diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c index 2bd20b5..5473764 100644 --- a/src/amd/vulkan/radv_meta_copy.c +++ b/src/amd/vulkan/radv_meta_copy.c @@ -430,3 +430,23 @@ void radv_CmdCopyImage( meta_copy_image(cmd_buffer, src_image, dest_image, regionCount, pRegions); } + +void radv_blit_to_prime_linear(struct radv_cmd_buffer *cmd_buffer, + struct radv_image *image, + struct radv_image *linear_image) +{ + struct VkImageCopy image_copy = { 0 }; + + image_copy.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + image_copy.srcSubresource.layerCount = 1; + + image_copy.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + image_copy.dstSubresource.layerCount = 1; + + image_copy.extent.width = image->extent.width; + image_copy.extent.height = image->extent.height; + image_copy.extent.depth = 1; + + meta_copy_image(cmd_buffer, image, linear_image, + 1, _copy); +} diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c index ea8e784..4d0168f 100644 --- a/src/amd/vulkan/radv_wsi.c +++ b/src/amd/vulkan/radv_wsi.c @@ -24,6 +24,7 @@ */ #include "radv_private.h" +#include "radv_meta.h" #include "wsi_common.h" static const struct wsi_callbacks wsi_cbs = { @@ -92,7 +93,7 @@ VkResult radv_GetPhysicalDeviceSurfaceSupportKHR( return iface->get_support(surface, >wsi_device, >instance->alloc, - queueFamilyIndex, device->local_fd, pSupported); + queueFamilyIndex, device->local_fd, true, pSupported); } VkResult radv_GetPhysicalDeviceSurfaceCapabilitiesKHR( @@ -139,6 +140,8 @@ static VkResult radv_wsi_image_create(VkDevice device_h, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks* pAllocator, + bool needs_linear_copy, + bool linear, VkImage *image_p, VkDeviceMemory *memory_p, uint32_t *size, @@ -169,7 +172,7 @@ radv_wsi_image_create(VkDevice device_h, .arrayLayers = 1, .samples = 1, /* FIXME: Need a way to use X tiling to allow scanout */ - .tiling = VK_IMAGE_TILING_OPTIMAL, + .tiling = linear ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL, .usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, .flags = 0, }, @@ -180,14 +183,14 @@ radv_wsi_image_create(VkDevice device_h, return result; image = radv_image_from_handle(image_h); - VkDeviceMemory memory_h; struct radv_device_memory *memory; + result = radv_AllocateMemory(device_h,