mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 13:10:10 +01:00
turnip: Drop some legacy wrappers in favor of common code
Acked-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8676>
This commit is contained in:
parent
0870cf4c06
commit
3a8060271c
4 changed files with 110 additions and 118 deletions
|
|
@ -222,7 +222,13 @@ tu_import_memory_from_gralloc_handle(VkDevice device_h,
|
|||
if (result != VK_SUCCESS)
|
||||
goto fail_create_image;
|
||||
|
||||
tu_BindImageMemory(device_h, image_h, memory_h, 0);
|
||||
VkBindImageMemoryInfo bind_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
|
||||
.image = image_h,
|
||||
.memory = memory_h,
|
||||
.memoryOffset = 0,
|
||||
};
|
||||
tu_BindImageMemory2(device_h, 1, &bind_info);
|
||||
|
||||
image->owned_memory = memory_h;
|
||||
|
||||
|
|
|
|||
|
|
@ -983,9 +983,11 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
|
||||
/* Check enabled features */
|
||||
if (pCreateInfo->pEnabledFeatures) {
|
||||
VkPhysicalDeviceFeatures supported_features;
|
||||
tu_GetPhysicalDeviceFeatures(physicalDevice, &supported_features);
|
||||
VkBool32 *supported_feature = (VkBool32 *) &supported_features;
|
||||
VkPhysicalDeviceFeatures2 supported_features = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
};
|
||||
tu_GetPhysicalDeviceFeatures2(physicalDevice, &supported_features);
|
||||
VkBool32 *supported_feature = (VkBool32 *) &supported_features.features;
|
||||
VkBool32 *enabled_feature = (VkBool32 *) pCreateInfo->pEnabledFeatures;
|
||||
unsigned num_features =
|
||||
sizeof(VkPhysicalDeviceFeatures) / sizeof(VkBool32);
|
||||
|
|
|
|||
|
|
@ -13,26 +13,6 @@
|
|||
#include "tu_entrypoints.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
void
|
||||
tu_GetPhysicalDeviceFeatures(VkPhysicalDevice pdev, VkPhysicalDeviceFeatures *features)
|
||||
{
|
||||
VkPhysicalDeviceFeatures2 features2;
|
||||
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
features2.pNext = NULL;
|
||||
tu_GetPhysicalDeviceFeatures2(pdev, &features2);
|
||||
*features = features2.features;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetPhysicalDeviceProperties(VkPhysicalDevice pdev, VkPhysicalDeviceProperties *props)
|
||||
{
|
||||
VkPhysicalDeviceProperties2 props2;
|
||||
props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
props2.pNext = NULL;
|
||||
tu_GetPhysicalDeviceProperties2(pdev, &props2);
|
||||
*props = props2.properties;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice pdev,
|
||||
uint32_t *count,
|
||||
|
|
@ -51,46 +31,6 @@ tu_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice pdev,
|
|||
props[i] = props2[i].queueFamilyProperties;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice pdev, VkPhysicalDeviceMemoryProperties *props)
|
||||
{
|
||||
VkPhysicalDeviceMemoryProperties2 props2;
|
||||
props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
|
||||
props2.pNext = NULL;
|
||||
tu_GetPhysicalDeviceMemoryProperties2(pdev, &props2);
|
||||
*props = props2.memoryProperties;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetPhysicalDeviceFormatProperties(VkPhysicalDevice pdev, VkFormat format, VkFormatProperties *props)
|
||||
{
|
||||
VkFormatProperties2 props2 = { .sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2 };
|
||||
tu_GetPhysicalDeviceFormatProperties2(pdev, format, &props2);
|
||||
*props = props2.formatProperties;
|
||||
}
|
||||
|
||||
VkResult
|
||||
tu_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice pdev,
|
||||
VkFormat format,
|
||||
VkImageType type,
|
||||
VkImageTiling tiling,
|
||||
VkImageUsageFlags usage,
|
||||
VkImageCreateFlags flags,
|
||||
VkImageFormatProperties *props)
|
||||
{
|
||||
VkImageFormatProperties2 props2 = { .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 };
|
||||
VkResult result = tu_GetPhysicalDeviceImageFormatProperties2(pdev, &(VkPhysicalDeviceImageFormatInfo2) {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
|
||||
.format = format,
|
||||
.type = type,
|
||||
.tiling = tiling,
|
||||
.usage = usage,
|
||||
.flags = flags
|
||||
}, &props2);
|
||||
*props = props2.imageFormatProperties;
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice pdev,
|
||||
VkFormat format,
|
||||
|
|
@ -123,38 +63,6 @@ tu_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice pdev,
|
|||
props[i] = props2[i].properties;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue)
|
||||
{
|
||||
tu_GetDeviceQueue2(device, &(VkDeviceQueueInfo2) {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2,
|
||||
.queueFamilyIndex = queueFamilyIndex,
|
||||
.queueIndex = queueIndex
|
||||
}, pQueue);
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *reqs)
|
||||
{
|
||||
VkMemoryRequirements2 reqs2 = { .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 };
|
||||
tu_GetBufferMemoryRequirements2(device, &(VkBufferMemoryRequirementsInfo2) {
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2,
|
||||
.buffer = buffer
|
||||
}, &reqs2);
|
||||
*reqs = reqs2.memoryRequirements;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *reqs)
|
||||
{
|
||||
VkMemoryRequirements2 reqs2 = { .sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 };
|
||||
tu_GetImageMemoryRequirements2(device, &(VkImageMemoryRequirementsInfo2) {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2,
|
||||
.image = image
|
||||
}, &reqs2);
|
||||
*reqs = reqs2.memoryRequirements;
|
||||
}
|
||||
|
||||
void
|
||||
tu_GetImageSparseMemoryRequirements(VkDevice device,
|
||||
VkImage image,
|
||||
|
|
@ -179,28 +87,6 @@ tu_GetImageSparseMemoryRequirements(VkDevice device,
|
|||
reqs[i] = reqs2[i].memoryRequirements;
|
||||
}
|
||||
|
||||
VkResult
|
||||
tu_BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize offset)
|
||||
{
|
||||
return tu_BindBufferMemory2(device, 1, &(VkBindBufferMemoryInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO,
|
||||
.buffer = buffer,
|
||||
.memory = memory,
|
||||
.memoryOffset = offset
|
||||
});
|
||||
}
|
||||
|
||||
VkResult
|
||||
tu_BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize offset)
|
||||
{
|
||||
return tu_BindImageMemory2(device, 1, &(VkBindImageMemoryInfo) {
|
||||
.sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO,
|
||||
.image = image,
|
||||
.memory = memory,
|
||||
.memoryOffset = offset
|
||||
});
|
||||
}
|
||||
|
||||
static void
|
||||
translate_references(VkAttachmentReference2 **reference_ptr,
|
||||
const VkAttachmentReference *reference,
|
||||
|
|
|
|||
|
|
@ -89,3 +89,101 @@ vk_common_EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
|
|||
|
||||
return vk_outarray_status(&out);
|
||||
}
|
||||
|
||||
void
|
||||
vk_common_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceFeatures *pFeatures)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
|
||||
|
||||
/* Don't zero-init this struct since the driver fills it out entirely */
|
||||
VkPhysicalDeviceFeatures2 features2;
|
||||
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
features2.pNext = NULL;
|
||||
|
||||
pdevice->dispatch_table.GetPhysicalDeviceFeatures2(physicalDevice,
|
||||
&features2);
|
||||
*pFeatures = features2.features;
|
||||
}
|
||||
|
||||
void
|
||||
vk_common_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceProperties *pProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
|
||||
|
||||
/* Don't zero-init this struct since the driver fills it out entirely */
|
||||
VkPhysicalDeviceProperties2 props2;
|
||||
props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
|
||||
props2.pNext = NULL;
|
||||
|
||||
pdevice->dispatch_table.GetPhysicalDeviceProperties2(physicalDevice,
|
||||
&props2);
|
||||
*pProperties = props2.properties;
|
||||
}
|
||||
|
||||
void
|
||||
vk_common_GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceMemoryProperties *pMemoryProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
|
||||
|
||||
/* Don't zero-init this struct since the driver fills it out entirely */
|
||||
VkPhysicalDeviceMemoryProperties2 props2;
|
||||
props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
|
||||
props2.pNext = NULL;
|
||||
|
||||
pdevice->dispatch_table.GetPhysicalDeviceMemoryProperties2(physicalDevice,
|
||||
&props2);
|
||||
*pMemoryProperties = props2.memoryProperties;
|
||||
}
|
||||
|
||||
void
|
||||
vk_common_GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice,
|
||||
VkFormat format,
|
||||
VkFormatProperties *pFormatProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
|
||||
|
||||
/* Don't zero-init this struct since the driver fills it out entirely */
|
||||
VkFormatProperties2 props2;
|
||||
props2.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
|
||||
props2.pNext = NULL;
|
||||
|
||||
pdevice->dispatch_table.GetPhysicalDeviceFormatProperties2(physicalDevice,
|
||||
format, &props2);
|
||||
*pFormatProperties = props2.formatProperties;
|
||||
}
|
||||
|
||||
VkResult
|
||||
vk_common_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice,
|
||||
VkFormat format,
|
||||
VkImageType type,
|
||||
VkImageTiling tiling,
|
||||
VkImageUsageFlags usage,
|
||||
VkImageCreateFlags flags,
|
||||
VkImageFormatProperties *pImageFormatProperties)
|
||||
{
|
||||
VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
|
||||
|
||||
VkPhysicalDeviceImageFormatInfo2 info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2,
|
||||
.format = format,
|
||||
.type = type,
|
||||
.tiling = tiling,
|
||||
.usage = usage,
|
||||
.flags = flags
|
||||
};
|
||||
|
||||
/* Don't zero-init this struct since the driver fills it out entirely */
|
||||
VkImageFormatProperties2 props2;
|
||||
props2.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
|
||||
props2.pNext = NULL;
|
||||
|
||||
VkResult result =
|
||||
pdevice->dispatch_table.GetPhysicalDeviceImageFormatProperties2(physicalDevice,
|
||||
&info, &props2);
|
||||
*pImageFormatProperties = props2.imageFormatProperties;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue