From 799a9db24c334713c0ba5995f59b7db5f782e85e Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 23 Mar 2022 13:37:47 +0100 Subject: [PATCH] turnip: Stop using VK_OUTARRAY_MAKE() We're trying to replace VK_OUTARRAY_MAKE() by VK_OUTARRAY_MAKE_TYPED() so people don't get tempted to use it and make things incompatible with MSVC (which doesn't support typeof()). Suggested-by: Daniel Stone Reviewed-by: Danylo Piliaiev Reviewed-by: Jason Ekstrand Part-of: --- src/freedreno/vulkan/tu_device.c | 17 ++++++----- src/freedreno/vulkan/tu_formats.c | 9 +++--- src/freedreno/vulkan/tu_pipeline.c | 47 ++++++++++++++++-------------- src/freedreno/vulkan/tu_query.c | 9 +++--- 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 0a1ecfbab3e..04d963af4e4 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -462,7 +462,8 @@ tu_EnumeratePhysicalDevices(VkInstance _instance, VkPhysicalDevice *pPhysicalDevices) { TU_FROM_HANDLE(tu_instance, instance, _instance); - VK_OUTARRAY_MAKE(out, pPhysicalDevices, pPhysicalDeviceCount); + VK_OUTARRAY_MAKE_TYPED(VkPhysicalDevice, out, + pPhysicalDevices, pPhysicalDeviceCount); VkResult result; @@ -473,7 +474,7 @@ tu_EnumeratePhysicalDevices(VkInstance _instance, } for (uint32_t i = 0; i < instance->physical_device_count; ++i) { - vk_outarray_append(&out, p) + vk_outarray_append_typed(VkPhysicalDevice, &out, p) { *p = tu_physical_device_to_handle(instance->physical_devices + i); } @@ -489,8 +490,9 @@ tu_EnumeratePhysicalDeviceGroups( VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties) { TU_FROM_HANDLE(tu_instance, instance, _instance); - VK_OUTARRAY_MAKE(out, pPhysicalDeviceGroupProperties, - pPhysicalDeviceGroupCount); + VK_OUTARRAY_MAKE_TYPED(VkPhysicalDeviceGroupProperties, out, + pPhysicalDeviceGroupProperties, + pPhysicalDeviceGroupCount); VkResult result; if (instance->physical_device_count < 0) { @@ -500,7 +502,7 @@ tu_EnumeratePhysicalDeviceGroups( } for (uint32_t i = 0; i < instance->physical_device_count; ++i) { - vk_outarray_append(&out, p) + vk_outarray_append_typed(VkPhysicalDeviceGroupProperties, &out, p) { p->physicalDeviceCount = 1; p->physicalDevices[0] = @@ -1298,9 +1300,10 @@ tu_GetPhysicalDeviceQueueFamilyProperties2( uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties) { - VK_OUTARRAY_MAKE(out, pQueueFamilyProperties, pQueueFamilyPropertyCount); + VK_OUTARRAY_MAKE_TYPED(VkQueueFamilyProperties2, out, + pQueueFamilyProperties, pQueueFamilyPropertyCount); - vk_outarray_append(&out, p) + vk_outarray_append_typed(VkQueueFamilyProperties2, &out, p) { p->queueFamilyProperties = tu_queue_family_properties; } diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c index 536bff0a57f..ae7bac41e17 100644 --- a/src/freedreno/vulkan/tu_formats.c +++ b/src/freedreno/vulkan/tu_formats.c @@ -310,11 +310,12 @@ tu_GetPhysicalDeviceFormatProperties2( VkDrmFormatModifierPropertiesListEXT *list = vk_find_struct(pFormatProperties->pNext, DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT); if (list) { - VK_OUTARRAY_MAKE(out, list->pDrmFormatModifierProperties, - &list->drmFormatModifierCount); + VK_OUTARRAY_MAKE_TYPED(VkDrmFormatModifierProperties2EXT, out, + list->pDrmFormatModifierProperties, + &list->drmFormatModifierCount); if (pFormatProperties->formatProperties.linearTilingFeatures) { - vk_outarray_append(&out, mod_props) { + vk_outarray_append_typed(VkDrmFormatModifierProperties2EXT, &out, mod_props) { mod_props->drmFormatModifier = DRM_FORMAT_MOD_LINEAR; mod_props->drmFormatModifierPlaneCount = 1; mod_props->drmFormatModifierTilingFeatures = @@ -326,7 +327,7 @@ tu_GetPhysicalDeviceFormatProperties2( if (pFormatProperties->formatProperties.optimalTilingFeatures && tiling_possible(format) && ubwc_possible(format, VK_IMAGE_TYPE_2D, 0, 0, physical_device->info, VK_SAMPLE_COUNT_1_BIT)) { - vk_outarray_append(&out, mod_props) { + vk_outarray_append_typed(VkDrmFormatModifierProperties2EXT, &out, mod_props) { mod_props->drmFormatModifier = DRM_FORMAT_MOD_QCOM_COMPRESSED; mod_props->drmFormatModifierPlaneCount = 1; mod_props->drmFormatModifierTilingFeatures = diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index a8787758512..1c3faba8179 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -3654,10 +3654,11 @@ tu_GetPipelineExecutablePropertiesKHR( { TU_FROM_HANDLE(tu_device, dev, _device); TU_FROM_HANDLE(tu_pipeline, pipeline, pPipelineInfo->pipeline); - VK_OUTARRAY_MAKE(out, pProperties, pExecutableCount); + VK_OUTARRAY_MAKE_TYPED(VkPipelineExecutablePropertiesKHR, out, + pProperties, pExecutableCount); util_dynarray_foreach (&pipeline->executables, struct tu_pipeline_executable, exe) { - vk_outarray_append(&out, props) { + vk_outarray_append_typed(VkPipelineExecutablePropertiesKHR, &out, props) { gl_shader_stage stage = exe->stage; props->stages = mesa_to_vk_shader_stage(stage); @@ -3684,12 +3685,13 @@ tu_GetPipelineExecutableStatisticsKHR( VkPipelineExecutableStatisticKHR* pStatistics) { TU_FROM_HANDLE(tu_pipeline, pipeline, pExecutableInfo->pipeline); - VK_OUTARRAY_MAKE(out, pStatistics, pStatisticCount); + VK_OUTARRAY_MAKE_TYPED(VkPipelineExecutableStatisticKHR, out, + pStatistics, pStatisticCount); const struct tu_pipeline_executable *exe = tu_pipeline_get_executable(pipeline, pExecutableInfo->executableIndex); - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Max Waves Per Core"); WRITE_STR(stat->description, "Maximum number of simultaneous waves per core."); @@ -3697,7 +3699,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.max_waves; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Instruction Count"); WRITE_STR(stat->description, "Total number of IR3 instructions in the final generated " @@ -3706,7 +3708,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.instrs_count; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Code size"); WRITE_STR(stat->description, "Total number of dwords in the final generated " @@ -3715,7 +3717,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.sizedwords; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "NOPs Count"); WRITE_STR(stat->description, "Number of NOP instructions in the final generated " @@ -3724,7 +3726,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.nops_count; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "MOV Count"); WRITE_STR(stat->description, "Number of MOV instructions in the final generated " @@ -3733,7 +3735,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.mov_count; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "COV Count"); WRITE_STR(stat->description, "Number of COV instructions in the final generated " @@ -3742,7 +3744,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.cov_count; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Registers used"); WRITE_STR(stat->description, "Number of registers used in the final generated " @@ -3751,7 +3753,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.max_reg + 1; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Half-registers used"); WRITE_STR(stat->description, "Number of half-registers used in the final generated " @@ -3760,7 +3762,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.max_half_reg + 1; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Instructions with SS sync bit"); WRITE_STR(stat->description, "SS bit is set for instructions which depend on a result " @@ -3769,7 +3771,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.ss; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Instructions with SY sync bit"); WRITE_STR(stat->description, "SY bit is set for instructions which depend on a result " @@ -3778,7 +3780,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.sy; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Estimated cycles stalled on SS"); WRITE_STR(stat->description, "A better metric to estimate the impact of SS syncs."); @@ -3786,7 +3788,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.sstall; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "Estimated cycles stalled on SY"); WRITE_STR(stat->description, "A better metric to estimate the impact of SY syncs."); @@ -3795,7 +3797,7 @@ tu_GetPipelineExecutableStatisticsKHR( } for (int i = 0; i < ARRAY_SIZE(exe->stats.instrs_per_cat); i++) { - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "cat%d instructions", i); WRITE_STR(stat->description, "Number of cat%d instructions.", i); @@ -3804,7 +3806,7 @@ tu_GetPipelineExecutableStatisticsKHR( } } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "STP Count"); WRITE_STR(stat->description, "Number of STore Private instructions in the final generated " @@ -3813,7 +3815,7 @@ tu_GetPipelineExecutableStatisticsKHR( stat->value.u64 = exe->stats.stp_count; } - vk_outarray_append(&out, stat) { + vk_outarray_append_typed(VkPipelineExecutableStatisticKHR, &out, stat) { WRITE_STR(stat->name, "LDP Count"); WRITE_STR(stat->description, "Number of LoaD Private instructions in the final generated " @@ -3854,14 +3856,15 @@ tu_GetPipelineExecutableInternalRepresentationsKHR( VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations) { TU_FROM_HANDLE(tu_pipeline, pipeline, pExecutableInfo->pipeline); - VK_OUTARRAY_MAKE(out, pInternalRepresentations, pInternalRepresentationCount); + VK_OUTARRAY_MAKE_TYPED(VkPipelineExecutableInternalRepresentationKHR, out, + pInternalRepresentations, pInternalRepresentationCount); bool incomplete_text = false; const struct tu_pipeline_executable *exe = tu_pipeline_get_executable(pipeline, pExecutableInfo->executableIndex); if (exe->nir_from_spirv) { - vk_outarray_append(&out, ir) { + vk_outarray_append_typed(VkPipelineExecutableInternalRepresentationKHR, &out, ir) { WRITE_STR(ir->name, "NIR from SPIRV"); WRITE_STR(ir->description, "Initial NIR before any optimizations"); @@ -3872,7 +3875,7 @@ tu_GetPipelineExecutableInternalRepresentationsKHR( } if (exe->nir_final) { - vk_outarray_append(&out, ir) { + vk_outarray_append_typed(VkPipelineExecutableInternalRepresentationKHR, &out, ir) { WRITE_STR(ir->name, "Final NIR"); WRITE_STR(ir->description, "Final NIR before going into the back-end compiler"); @@ -3883,7 +3886,7 @@ tu_GetPipelineExecutableInternalRepresentationsKHR( } if (exe->disasm) { - vk_outarray_append(&out, ir) { + vk_outarray_append_typed(VkPipelineExecutableInternalRepresentationKHR, &out, ir) { WRITE_STR(ir->name, "IR3 Assembly"); WRITE_STR(ir->description, "Final IR3 assembly for the generated shader binary"); diff --git a/src/freedreno/vulkan/tu_query.c b/src/freedreno/vulkan/tu_query.c index 1650a0d858e..81a67a05239 100644 --- a/src/freedreno/vulkan/tu_query.c +++ b/src/freedreno/vulkan/tu_query.c @@ -1424,13 +1424,14 @@ tu_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( const struct fd_perfcntr_group *group = fd_perfcntrs(&phydev->dev_id, &group_count); - VK_OUTARRAY_MAKE(out, pCounters, pCounterCount); - VK_OUTARRAY_MAKE(out_desc, pCounterDescriptions, &desc_count); + VK_OUTARRAY_MAKE_TYPED(VkPerformanceCounterKHR, out, pCounters, pCounterCount); + VK_OUTARRAY_MAKE_TYPED(VkPerformanceCounterDescriptionKHR, out_desc, + pCounterDescriptions, &desc_count); for (int i = 0; i < group_count; i++) { for (int j = 0; j < group[i].num_countables; j++) { - vk_outarray_append(&out, counter) { + vk_outarray_append_typed(VkPerformanceCounterKHR, &out, counter) { counter->scope = VK_QUERY_SCOPE_COMMAND_BUFFER_KHR; counter->unit = fd_perfcntr_type_to_vk_unit[group[i].countables[j].query_type]; @@ -1444,7 +1445,7 @@ tu_EnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( memcpy(counter->uuid, sha1_result, sizeof(counter->uuid)); } - vk_outarray_append(&out_desc, desc) { + vk_outarray_append_typed(VkPerformanceCounterDescriptionKHR, &out_desc, desc) { desc->flags = 0; snprintf(desc->name, sizeof(desc->name),