mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 07:00:12 +01:00
vulkan: add common entrypoints for sparse image requirements/properties
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12416>
This commit is contained in:
parent
e62d3db64b
commit
f695171e38
4 changed files with 97 additions and 9 deletions
|
|
@ -23,15 +23,7 @@
|
||||||
|
|
||||||
#include "vk_common_entrypoints.h"
|
#include "vk_common_entrypoints.h"
|
||||||
#include "vk_device.h"
|
#include "vk_device.h"
|
||||||
|
#include "vk_util.h"
|
||||||
#define STACK_ARRAY_SIZE 8
|
|
||||||
|
|
||||||
#define STACK_ARRAY(type, name, size) \
|
|
||||||
type _stack_##name[STACK_ARRAY_SIZE], *const name = \
|
|
||||||
(size) <= STACK_ARRAY_SIZE ? _stack_##name : malloc((size) * sizeof(type))
|
|
||||||
|
|
||||||
#define STACK_ARRAY_FINISH(name) \
|
|
||||||
if (name != _stack_##name) free(name)
|
|
||||||
|
|
||||||
VKAPI_ATTR void VKAPI_CALL
|
VKAPI_ATTR void VKAPI_CALL
|
||||||
vk_common_CmdCopyBuffer(VkCommandBuffer commandBuffer,
|
vk_common_CmdCopyBuffer(VkCommandBuffer commandBuffer,
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "vk_common_entrypoints.h"
|
#include "vk_common_entrypoints.h"
|
||||||
#include "vk_instance.h"
|
#include "vk_instance.h"
|
||||||
#include "vk_physical_device.h"
|
#include "vk_physical_device.h"
|
||||||
|
#include "vk_util.h"
|
||||||
#include "util/hash_table.h"
|
#include "util/hash_table.h"
|
||||||
#include "util/ralloc.h"
|
#include "util/ralloc.h"
|
||||||
|
|
||||||
|
|
@ -219,3 +220,42 @@ vk_common_BindImageMemory(VkDevice _device,
|
||||||
|
|
||||||
return device->dispatch_table.BindImageMemory2(_device, 1, &bind);
|
return device->dispatch_table.BindImageMemory2(_device, 1, &bind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VKAPI_ATTR void VKAPI_CALL
|
||||||
|
vk_common_GetImageSparseMemoryRequirements(VkDevice _device,
|
||||||
|
VkImage image,
|
||||||
|
uint32_t *pSparseMemoryRequirementCount,
|
||||||
|
VkSparseImageMemoryRequirements *pSparseMemoryRequirements)
|
||||||
|
{
|
||||||
|
VK_FROM_HANDLE(vk_device, device, _device);
|
||||||
|
|
||||||
|
VkImageSparseMemoryRequirementsInfo2 info = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2,
|
||||||
|
.image = image,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!pSparseMemoryRequirements) {
|
||||||
|
device->dispatch_table.GetImageSparseMemoryRequirements2(_device,
|
||||||
|
&info,
|
||||||
|
pSparseMemoryRequirementCount,
|
||||||
|
NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STACK_ARRAY(VkSparseImageMemoryRequirements2, mem_reqs2, *pSparseMemoryRequirementCount);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < *pSparseMemoryRequirementCount; ++i) {
|
||||||
|
mem_reqs2[i].sType = VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2;
|
||||||
|
mem_reqs2[i].pNext = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
device->dispatch_table.GetImageSparseMemoryRequirements2(_device,
|
||||||
|
&info,
|
||||||
|
pSparseMemoryRequirementCount,
|
||||||
|
mem_reqs2);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < *pSparseMemoryRequirementCount; ++i)
|
||||||
|
pSparseMemoryRequirements[i] = mem_reqs2[i].memoryRequirements;
|
||||||
|
|
||||||
|
STACK_ARRAY_FINISH(mem_reqs2);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,3 +205,50 @@ vk_common_GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VKAPI_ATTR void VKAPI_CALL
|
||||||
|
vk_common_GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice,
|
||||||
|
VkFormat format,
|
||||||
|
VkImageType type,
|
||||||
|
uint32_t samples,
|
||||||
|
VkImageUsageFlags usage,
|
||||||
|
VkImageTiling tiling,
|
||||||
|
uint32_t *pNumProperties,
|
||||||
|
VkSparseImageFormatProperties *pProperties)
|
||||||
|
{
|
||||||
|
VK_FROM_HANDLE(vk_physical_device, pdevice, physicalDevice);
|
||||||
|
|
||||||
|
VkPhysicalDeviceSparseImageFormatInfo2 info = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2,
|
||||||
|
.format = format,
|
||||||
|
.type = type,
|
||||||
|
.samples = samples,
|
||||||
|
.usage = usage,
|
||||||
|
.tiling = tiling
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!pProperties) {
|
||||||
|
pdevice->dispatch_table.GetPhysicalDeviceSparseImageFormatProperties2(physicalDevice,
|
||||||
|
&info,
|
||||||
|
pNumProperties,
|
||||||
|
NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
STACK_ARRAY(VkSparseImageFormatProperties2, props2, *pNumProperties);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < *pNumProperties; ++i) {
|
||||||
|
props2[i].sType = VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2;
|
||||||
|
props2[i].pNext = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pdevice->dispatch_table.GetPhysicalDeviceSparseImageFormatProperties2(physicalDevice,
|
||||||
|
&info,
|
||||||
|
pNumProperties,
|
||||||
|
props2);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < *pNumProperties; ++i)
|
||||||
|
pProperties[i] = props2[i].properties;
|
||||||
|
|
||||||
|
STACK_ARRAY_FINISH(props2);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,15 @@ struct nir_spirv_specialization*
|
||||||
vk_spec_info_to_nir_spirv(const VkSpecializationInfo *spec_info,
|
vk_spec_info_to_nir_spirv(const VkSpecializationInfo *spec_info,
|
||||||
uint32_t *out_num_spec_entries);
|
uint32_t *out_num_spec_entries);
|
||||||
|
|
||||||
|
#define STACK_ARRAY_SIZE 8
|
||||||
|
|
||||||
|
#define STACK_ARRAY(type, name, size) \
|
||||||
|
type _stack_##name[STACK_ARRAY_SIZE], *const name = \
|
||||||
|
(size) <= STACK_ARRAY_SIZE ? _stack_##name : malloc((size) * sizeof(type))
|
||||||
|
|
||||||
|
#define STACK_ARRAY_FINISH(name) \
|
||||||
|
if (name != _stack_##name) free(name)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue