vulkan,anv: Move a bunch of trivial wrappers to common code

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
This commit is contained in:
Jason Ekstrand 2021-01-24 14:49:57 -06:00 committed by Marge Bot
parent f51155a349
commit ac6be0ef22
4 changed files with 128 additions and 123 deletions

View file

@ -2479,26 +2479,6 @@ anv_device_init_trivial_batch(struct anv_device *device)
return VK_SUCCESS;
}
VkResult anv_EnumerateDeviceExtensionProperties(
VkPhysicalDevice physicalDevice,
const char* pLayerName,
uint32_t* pPropertyCount,
VkExtensionProperties* pProperties)
{
ANV_FROM_HANDLE(anv_physical_device, device, physicalDevice);
VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
for (int i = 0; i < VK_DEVICE_EXTENSION_COUNT; i++) {
if (device->vk.supported_extensions.extensions[i]) {
vk_outarray_append(&out, prop) {
*prop = vk_device_extensions[i];
}
}
}
return vk_outarray_status(&out);
}
static int
vk_priority_to_gen(int priority)
{
@ -3158,37 +3138,6 @@ VkResult anv_EnumerateInstanceLayerProperties(
return vk_error(VK_ERROR_LAYER_NOT_PRESENT);
}
VkResult anv_EnumerateDeviceLayerProperties(
VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
VkLayerProperties* pProperties)
{
if (pProperties == NULL) {
*pPropertyCount = 0;
return VK_SUCCESS;
}
/* None supported at this time */
return vk_error(VK_ERROR_LAYER_NOT_PRESENT);
}
void anv_GetDeviceQueue(
VkDevice _device,
uint32_t queueFamilyIndex,
uint32_t queueIndex,
VkQueue* pQueue)
{
const VkDeviceQueueInfo2 info = {
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2,
.pNext = NULL,
.flags = 0,
.queueFamilyIndex = queueFamilyIndex,
.queueIndex = queueIndex,
};
anv_GetDeviceQueue2(_device, &info, pQueue);
}
void anv_GetDeviceQueue2(
VkDevice _device,
const VkDeviceQueueInfo2* pQueueInfo,
@ -3947,22 +3896,6 @@ VkResult anv_InvalidateMappedMemoryRanges(
return VK_SUCCESS;
}
void anv_GetBufferMemoryRequirements(
VkDevice device,
VkBuffer buffer,
VkMemoryRequirements* pMemoryRequirements)
{
VkBufferMemoryRequirementsInfo2 info = {
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2,
.buffer = buffer,
};
VkMemoryRequirements2 reqs = {
.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
};
anv_GetBufferMemoryRequirements2(device, &info, &reqs);
*pMemoryRequirements = reqs.memoryRequirements;
}
void anv_GetBufferMemoryRequirements2(
VkDevice _device,
const VkBufferMemoryRequirementsInfo2* pInfo,
@ -4017,22 +3950,6 @@ void anv_GetBufferMemoryRequirements2(
}
}
void anv_GetImageMemoryRequirements(
VkDevice device,
VkImage image,
VkMemoryRequirements* pMemoryRequirements)
{
VkImageMemoryRequirementsInfo2 info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2,
.image = image,
};
VkMemoryRequirements2 reqs = {
.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
};
anv_GetImageMemoryRequirements2(device, &info, &reqs);
*pMemoryRequirements = reqs.memoryRequirements;
}
void anv_GetImageMemoryRequirements2(
VkDevice _device,
const VkImageMemoryRequirementsInfo2* pInfo,
@ -4161,23 +4078,6 @@ anv_bind_buffer_memory(const VkBindBufferMemoryInfo *pBindInfo)
}
}
VkResult anv_BindBufferMemory(
VkDevice device,
VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memoryOffset)
{
anv_bind_buffer_memory(
&(VkBindBufferMemoryInfo) {
.sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO,
.buffer = buffer,
.memory = memory,
.memoryOffset = memoryOffset,
});
return VK_SUCCESS;
}
VkResult anv_BindBufferMemory2(
VkDevice device,
uint32_t bindInfoCount,

View file

@ -1089,29 +1089,6 @@ resolve_ahw_image(struct anv_device *device,
#endif
}
VkResult anv_BindImageMemory(
VkDevice _device,
VkImage _image,
VkDeviceMemory _memory,
VkDeviceSize memoryOffset)
{
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_device_memory, mem, _memory);
ANV_FROM_HANDLE(anv_image, image, _image);
if (mem->ahw)
resolve_ahw_image(device, image, mem);
uint32_t aspect_bit;
anv_foreach_image_aspect_bit(aspect_bit, image, image->aspects) {
uint32_t plane =
anv_image_aspect_to_plane(image->aspects, 1UL << aspect_bit);
anv_image_bind_memory_plane(device, image, plane, mem, memoryOffset);
}
return VK_SUCCESS;
}
VkResult anv_BindImageMemory2(
VkDevice _device,
uint32_t bindInfoCount,

View file

@ -119,3 +119,96 @@ vk_common_GetDeviceProcAddr(VkDevice _device,
VK_FROM_HANDLE(vk_device, device, _device);
return vk_device_get_proc_addr(device, pName);
}
void
vk_common_GetDeviceQueue(VkDevice _device,
uint32_t queueFamilyIndex,
uint32_t queueIndex,
VkQueue *pQueue)
{
VK_FROM_HANDLE(vk_device, device, _device);
const VkDeviceQueueInfo2 info = {
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2,
.pNext = NULL,
.flags = 0,
.queueFamilyIndex = queueFamilyIndex,
.queueIndex = queueIndex,
};
device->dispatch_table.GetDeviceQueue2(_device, &info, pQueue);
}
void
vk_common_GetBufferMemoryRequirements(VkDevice _device,
VkBuffer buffer,
VkMemoryRequirements *pMemoryRequirements)
{
VK_FROM_HANDLE(vk_device, device, _device);
VkBufferMemoryRequirementsInfo2 info = {
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2,
.buffer = buffer,
};
VkMemoryRequirements2 reqs = {
.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
};
device->dispatch_table.GetBufferMemoryRequirements2(_device, &info, &reqs);
*pMemoryRequirements = reqs.memoryRequirements;
}
VkResult
vk_common_BindBufferMemory(VkDevice _device,
VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memoryOffset)
{
VK_FROM_HANDLE(vk_device, device, _device);
VkBindBufferMemoryInfo bind = {
.sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO,
.buffer = buffer,
.memory = memory,
.memoryOffset = memoryOffset,
};
return device->dispatch_table.BindBufferMemory2(_device, 1, &bind);
}
void
vk_common_GetImageMemoryRequirements(VkDevice _device,
VkImage image,
VkMemoryRequirements *pMemoryRequirements)
{
VK_FROM_HANDLE(vk_device, device, _device);
VkImageMemoryRequirementsInfo2 info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2,
.image = image,
};
VkMemoryRequirements2 reqs = {
.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2,
};
device->dispatch_table.GetImageMemoryRequirements2(_device, &info, &reqs);
*pMemoryRequirements = reqs.memoryRequirements;
}
VkResult
vk_common_BindImageMemory(VkDevice _device,
VkImage image,
VkDeviceMemory memory,
VkDeviceSize memoryOffset)
{
VK_FROM_HANDLE(vk_device, device, _device);
VkBindImageMemoryInfo bind = {
.sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
.image = image,
.memory = memory,
.memoryOffset = memoryOffset,
};
return device->dispatch_table.BindImageMemory2(_device, 1, &bind);
}

View file

@ -24,6 +24,7 @@
#include "vk_physical_device.h"
#include "vk_common_entrypoints.h"
#include "vk_util.h"
VkResult
vk_physical_device_init(struct vk_physical_device *pdevice,
@ -54,3 +55,37 @@ vk_physical_device_finish(struct vk_physical_device *physical_device)
{
vk_object_base_finish(&physical_device->base);
}
VkResult
vk_common_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
uint32_t *pPropertyCount,
VkLayerProperties *pProperties)
{
if (pProperties == NULL) {
*pPropertyCount = 0;
return VK_SUCCESS;
}
/* None supported at this time */
return VK_ERROR_LAYER_NOT_PRESENT;
}
VkResult
vk_common_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
const char *pLayerName,
uint32_t *pPropertyCount,
VkExtensionProperties *pProperties)
{
VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
for (int i = 0; i < VK_DEVICE_EXTENSION_COUNT; i++) {
if (pdevice->supported_extensions.extensions[i]) {
vk_outarray_append(&out, prop) {
*prop = vk_device_extensions[i];
}
}
}
return vk_outarray_status(&out);
}