在创建图形管道时,
VkPipelineDynamicStateCreateInfo.pDynamicStates = { VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY };
字符串
(将其设置为VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT
没有区别,它们在我的计算机上是相同的值)并在创建VkDevice时启用extendedDynamicState
功能:
uint32_t deviceExtensionCount = 1;
const char* deviceExtensions[] = { "VK_KHR_swapchain", "VK_EXT_extended_dynamic_state" };
const float queuePriority[] = { 1.0f };
VkPhysicalDeviceFeatures features;
vkGetPhysicalDeviceFeatures(s_VkData.PhysicalDevice, &features);
VkPhysicalDeviceExtendedDynamicStateFeaturesEXT featuresEXT{};
featuresEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT;
featuresEXT.extendedDynamicState = VK_TRUE;
VkPhysicalDeviceFeatures2 features2{};
features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
features2.features = features;
features2.pNext = &featuresEXT;
VkDeviceQueueCreateInfo queueInfo[1] = {};
queueInfo[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queueInfo[0].queueFamilyIndex = s_VkData.QueueFamily;
queueInfo[0].queueCount = 1;
queueInfo[0].pQueuePriorities = queuePriority;
VkDeviceCreateInfo deviceInfo{};
deviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
deviceInfo.queueCreateInfoCount = sizeof(queueInfo) / sizeof(queueInfo[0]);
deviceInfo.pQueueCreateInfos = queueInfo;
deviceInfo.enabledExtensionCount = deviceExtensionCount;
deviceInfo.ppEnabledExtensionNames = deviceExtensions;
deviceInfo.pNext = &features2;
VkResult result = vkCreateDevice(PhysicalDevice, &deviceInfo, s_VkData.Allocator, &s_VkData.Device);
CheckVkResult(result);
型
但是当我调用vkCmdSetPrimitiveTopology
或vkCmdSetPrimitiveTopologyEXT
记录命令缓冲区时,我得到了一个访问冲突异常。我的命令缓冲区是有效的(用visual studio的调试器检查了这个),我没有得到任何验证错误。用vkGetInstanceProcAddr
加载vkCmdSetPrimitiveTopologyEXT
不会改变这个结果。
1条答案
按热度按时间fslejnso1#
您正在调用不属于Vulkan Core 1.0的函数。除非您执行某些操作来加载这些函数,否则调用它们将导致崩溃,因为它们没有有效的函数指针。
有三种方法可以解决这个问题:
vkCmdSetPrimitiveTopology
(无EXT后缀)等核心函数。如果是这样,您需要使用API版本创建Vulkan示例,其中这些函数是核心的一部分。这将是VK_API_VERSION_1_3
并启用核心功能。然后函数指针将可用作核心函数。请注意,这仅适用于支持Vulkan 1.3及更高版本的设备。vkCmdSetPrimitiveTopologyEXT´ and manually load the function pointers. For this you enable the extension, the extension feature and then use
vkGetInstanceProcAddr`等扩展函数来获取有效的函数指针。