vulkan/util,vulkan/wsi,radv: Add typed outarray API
MSVC cannot perform GCC __typeof__ for C code. (C++ has decltype.) Add adjacent functions to allow specifying types manually. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7270>
This commit is contained in:
@@ -887,7 +887,8 @@ VkResult radv_EnumeratePhysicalDevices(
|
||||
VkPhysicalDevice* pPhysicalDevices)
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_instance, instance, _instance);
|
||||
VK_OUTARRAY_MAKE(out, pPhysicalDevices, pPhysicalDeviceCount);
|
||||
VK_OUTARRAY_MAKE_TYPED(VkPhysicalDevice, out, pPhysicalDevices,
|
||||
pPhysicalDeviceCount);
|
||||
|
||||
VkResult result = radv_enumerate_physical_devices(instance);
|
||||
if (result != VK_SUCCESS)
|
||||
@@ -895,7 +896,7 @@ VkResult radv_EnumeratePhysicalDevices(
|
||||
|
||||
list_for_each_entry(struct radv_physical_device, pdevice,
|
||||
&instance->physical_devices, link) {
|
||||
vk_outarray_append(&out, i) {
|
||||
vk_outarray_append_typed(VkPhysicalDevice , &out, i) {
|
||||
*i = radv_physical_device_to_handle(pdevice);
|
||||
}
|
||||
}
|
||||
@@ -909,8 +910,9 @@ VkResult radv_EnumeratePhysicalDeviceGroups(
|
||||
VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties)
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_instance, instance, _instance);
|
||||
VK_OUTARRAY_MAKE(out, pPhysicalDeviceGroupProperties,
|
||||
pPhysicalDeviceGroupCount);
|
||||
VK_OUTARRAY_MAKE_TYPED(VkPhysicalDeviceGroupProperties, out,
|
||||
pPhysicalDeviceGroupProperties,
|
||||
pPhysicalDeviceGroupCount);
|
||||
|
||||
VkResult result = radv_enumerate_physical_devices(instance);
|
||||
if (result != VK_SUCCESS)
|
||||
@@ -918,7 +920,7 @@ VkResult radv_EnumeratePhysicalDeviceGroups(
|
||||
|
||||
list_for_each_entry(struct radv_physical_device, pdevice,
|
||||
&instance->physical_devices, link) {
|
||||
vk_outarray_append(&out, p) {
|
||||
vk_outarray_append_typed(VkPhysicalDeviceGroupProperties, &out, p) {
|
||||
p->physicalDeviceCount = 1;
|
||||
memset(p->physicalDevices, 0, sizeof(p->physicalDevices));
|
||||
p->physicalDevices[0] = radv_physical_device_to_handle(pdevice);
|
||||
@@ -4977,11 +4979,12 @@ VkResult radv_EnumerateInstanceExtensionProperties(
|
||||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties)
|
||||
{
|
||||
VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
|
||||
VK_OUTARRAY_MAKE_TYPED(VkExtensionProperties, out, pProperties,
|
||||
pPropertyCount);
|
||||
|
||||
for (int i = 0; i < RADV_INSTANCE_EXTENSION_COUNT; i++) {
|
||||
if (radv_instance_extensions_supported.extensions[i]) {
|
||||
vk_outarray_append(&out, prop) {
|
||||
vk_outarray_append_typed(VkExtensionProperties, &out, prop) {
|
||||
*prop = radv_instance_extensions[i];
|
||||
}
|
||||
}
|
||||
@@ -4997,11 +5000,12 @@ VkResult radv_EnumerateDeviceExtensionProperties(
|
||||
VkExtensionProperties* pProperties)
|
||||
{
|
||||
RADV_FROM_HANDLE(radv_physical_device, device, physicalDevice);
|
||||
VK_OUTARRAY_MAKE(out, pProperties, pPropertyCount);
|
||||
VK_OUTARRAY_MAKE_TYPED(VkExtensionProperties, out, pProperties,
|
||||
pPropertyCount);
|
||||
|
||||
for (int i = 0; i < RADV_DEVICE_EXTENSION_COUNT; i++) {
|
||||
if (device->supported_extensions.extensions[i]) {
|
||||
vk_outarray_append(&out, prop) {
|
||||
vk_outarray_append_typed(VkExtensionProperties, &out, prop) {
|
||||
*prop = radv_device_extensions[i];
|
||||
}
|
||||
}
|
||||
@@ -7967,10 +7971,11 @@ VkResult radv_GetPhysicalDeviceCalibrateableTimeDomainsEXT(
|
||||
VkTimeDomainEXT *pTimeDomains)
|
||||
{
|
||||
int d;
|
||||
VK_OUTARRAY_MAKE(out, pTimeDomains, pTimeDomainCount);
|
||||
VK_OUTARRAY_MAKE_TYPED(VkTimeDomainEXT, out, pTimeDomains,
|
||||
pTimeDomainCount);
|
||||
|
||||
for (d = 0; d < ARRAY_SIZE(radv_time_domains); d++) {
|
||||
vk_outarray_append(&out, i) {
|
||||
vk_outarray_append_typed(VkTimeDomainEXT, &out, i) {
|
||||
*i = radv_time_domains[d];
|
||||
}
|
||||
}
|
||||
|
@@ -146,14 +146,18 @@ __vk_outarray_next(struct __vk_outarray *a, size_t elem_size)
|
||||
__vk_outarray_init(&(a)->base, (data), (len))
|
||||
|
||||
#define VK_OUTARRAY_MAKE(name, data, len) \
|
||||
vk_outarray(__typeof__((data)[0])) name; \
|
||||
VK_OUTARRAY_MAKE_TYPED(__typeof__((data)[0]), name, data, len)
|
||||
#define VK_OUTARRAY_MAKE_TYPED(type, name, data, len) \
|
||||
vk_outarray(type) name; \
|
||||
vk_outarray_init(&name, (data), (len))
|
||||
|
||||
#define vk_outarray_status(a) \
|
||||
__vk_outarray_status(&(a)->base)
|
||||
|
||||
#define vk_outarray_next(a) \
|
||||
((vk_outarray_typeof_elem(a) *) \
|
||||
vk_outarray_next_typed(vk_outarray_typeof_elem(a), a)
|
||||
#define vk_outarray_next_typed(type, a) \
|
||||
((type *) \
|
||||
__vk_outarray_next(&(a)->base, vk_outarray_sizeof_elem(a)))
|
||||
|
||||
/**
|
||||
@@ -176,7 +180,9 @@ __vk_outarray_next(struct __vk_outarray *a, size_t elem_size)
|
||||
* points to the newly appended element.
|
||||
*/
|
||||
#define vk_outarray_append(a, elem) \
|
||||
for (vk_outarray_typeof_elem(a) *elem = vk_outarray_next(a); \
|
||||
vk_outarray_append_typed(vk_outarray_typeof_elem(a), a, elem)
|
||||
#define vk_outarray_append_typed(type, a, elem) \
|
||||
for (type *elem = vk_outarray_next_typed(type, a); \
|
||||
elem != NULL; elem = NULL)
|
||||
|
||||
static inline void *
|
||||
|
@@ -1088,10 +1088,10 @@ wsi_common_get_images(VkSwapchainKHR _swapchain,
|
||||
VkImage *pSwapchainImages)
|
||||
{
|
||||
VK_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
|
||||
VK_OUTARRAY_MAKE(images, pSwapchainImages, pSwapchainImageCount);
|
||||
VK_OUTARRAY_MAKE_TYPED(VkImage, images, pSwapchainImages, pSwapchainImageCount);
|
||||
|
||||
for (uint32_t i = 0; i < swapchain->image_count; i++) {
|
||||
vk_outarray_append(&images, image) {
|
||||
vk_outarray_append_typed(VkImage, &images, image) {
|
||||
*image = swapchain->get_wsi_image(swapchain, i)->image;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user