macOS/iOS fixes plus other generic fixes for clang and validation warnings (#1117)
* Fix clang Objective-C++ flags for macOS command line builds * Fix getAssetPath() and getShaderBasePath() for macOS command line builds * Protect debugUtilsMessageCallback() from failing when pMessageIdName is NULL * Fix a few clang function override and mismatched type warnings * Fix validation layer warnings on exit for computeraytracing example * Fix regression in text visibility toggle for textOverlay example * Support VK_USE_PLATFORM_METAL_EXT vs. deprecated VK_USE_PLATFORM_MACOS_MVK / DVK_USE_PLATFORM_IOS_MVK * Check dynamic state features before enabling capabilities in dynamicstate example * Fix vkCmdDraw() vertexCount argument (PARTICLE_COUNT) in particlesystem example * Update examples list and restore benchmarking script (to top level) * Fix validation warning in descriptorindexing example * Fix device max recursion depth validation warnings in ray tracing examples * Fix OpenMP build settings for texture3d example on all platforms * Update and simplify build instructions for macOS * Update CI script with correct library path for libomp on macOS x86_64 * Update CI scipt to install libomp prior to macOS builds * Trying one more time to get the CI script working for macOS libomp * Fix vertexCount argument using calculated size in particlesystem example * Fix combined image descriptor offset calculation in descriptorbuffer example * macOS: Support non-system level Vulkan SDK installs, with fallback to MoltenVK library
This commit is contained in:
parent
4a0c8b8f23
commit
bdfd4709ff
29 changed files with 320 additions and 88 deletions
|
|
@ -65,7 +65,9 @@ function(buildExample EXAMPLE_NAME)
|
|||
endif()
|
||||
find_package(OpenMP)
|
||||
if(OpenMP_CXX_FOUND)
|
||||
link_directories(${OpenMP_CXX_LIBRARY_DIRS})
|
||||
set_target_properties(${EXAMPLE_NAME} PROPERTIES COMPILE_FLAGS ${OpenMP_CXX_FLAGS})
|
||||
target_include_directories(${EXAMPLE_NAME} PRIVATE ${OpenMP_CXX_INCLUDE_DIRS})
|
||||
target_link_libraries(${EXAMPLE_NAME} ${OpenMP_CXX_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
#define VK_ENABLE_BETA_EXTENSIONS
|
||||
#endif
|
||||
#include <vulkan/vulkan.h>
|
||||
|
|
@ -177,7 +177,7 @@ public:
|
|||
instanceCreateInfo.enabledLayerCount = layerCount;
|
||||
}
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - When running on macOS with MoltenVK, enable VK_KHR_get_physical_device_properties2 (required by VK_KHR_portability_subset)
|
||||
instanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
#if defined(VK_KHR_portability_enumeration)
|
||||
|
|
@ -260,7 +260,7 @@ public:
|
|||
deviceCreateInfo.queueCreateInfoCount = 1;
|
||||
deviceCreateInfo.pQueueCreateInfos = &queueCreateInfo;
|
||||
std::vector<const char*> deviceExtensions = {};
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK) && defined(VK_KHR_portability_subset)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)) && defined(VK_KHR_portability_subset)
|
||||
// SRS - When running on macOS with MoltenVK and VK_KHR_portability_subset is defined and supported by the device, enable the extension
|
||||
uint32_t deviceExtCount = 0;
|
||||
vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &deviceExtCount, nullptr);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public:
|
|||
camera.rotationSpeed = 0.0f;
|
||||
camera.movementSpeed = 2.5f;
|
||||
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - on macOS set environment variable to ensure MoltenVK disables Metal argument buffers for this example
|
||||
setenv("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", "0", 1);
|
||||
#endif
|
||||
|
|
@ -429,6 +429,8 @@ public:
|
|||
VkBufferCopy copyRegion = { 0, 0, storageBufferSize};
|
||||
vkCmdCopyBuffer(copyCmd, stagingBuffer.buffer, compute.objectStorageBuffer.buffer, 1, ©Region);
|
||||
vulkanDevice->flushCommandBuffer(copyCmd, queue, true);
|
||||
|
||||
stagingBuffer.destroy();
|
||||
}
|
||||
|
||||
// The descriptor pool will be shared between graphics and compute
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public:
|
|||
|
||||
// [POI] Enable required extensions
|
||||
enabledInstanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_KHR_MAINTENANCE1_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_KHR_MAINTENANCE3_EXTENSION_NAME);
|
||||
enabledDeviceExtensions.push_back(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
|
||||
|
||||
|
|
@ -67,7 +68,7 @@ public:
|
|||
|
||||
deviceCreatepNextChain = &physicalDeviceDescriptorIndexingFeatures;
|
||||
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - on macOS set environment variable to configure MoltenVK for using Metal argument buffers (needed for descriptor indexing)
|
||||
// - MoltenVK supports Metal argument buffers on macOS, iOS possible in future (see https://github.com/KhronosGroup/MoltenVK/issues/1651)
|
||||
setenv("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", "1", 1);
|
||||
|
|
@ -213,7 +214,7 @@ public:
|
|||
vks::initializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, static_cast<uint32_t>(textures.size()))
|
||||
};
|
||||
VkDescriptorPoolCreateInfo descriptorPoolInfo = vks::initializers::descriptorPoolCreateInfo(poolSizes, 2);
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - increase the per-stage descriptor samplers limit on macOS (maxPerStageDescriptorUpdateAfterBindSamplers > maxPerStageDescriptorSamplers)
|
||||
descriptorPoolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT;
|
||||
#endif
|
||||
|
|
@ -243,7 +244,7 @@ public:
|
|||
setLayoutBindingFlags.pBindingFlags = descriptorBindingFlags.data();
|
||||
|
||||
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCI = vks::initializers::descriptorSetLayoutCreateInfo(setLayoutBindings);
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - increase the per-stage descriptor samplers limit on macOS (maxPerStageDescriptorUpdateAfterBindSamplers > maxPerStageDescriptorSamplers)
|
||||
descriptorSetLayoutCI.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -94,23 +94,35 @@ public:
|
|||
|
||||
void getEnabledExtensions()
|
||||
{
|
||||
// Get the full list of extended dynamic state features supported by the device
|
||||
extendedDynamicStateFeaturesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT;
|
||||
extendedDynamicStateFeaturesEXT.pNext = &extendedDynamicState2FeaturesEXT;
|
||||
extendedDynamicState2FeaturesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT;
|
||||
extendedDynamicState2FeaturesEXT.pNext = &extendedDynamicState3FeaturesEXT;
|
||||
extendedDynamicState3FeaturesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT;
|
||||
extendedDynamicState3FeaturesEXT.pNext = nullptr;
|
||||
|
||||
VkPhysicalDeviceFeatures2 physicalDeviceFeatures2;
|
||||
physicalDeviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||
physicalDeviceFeatures2.pNext = &extendedDynamicStateFeaturesEXT;
|
||||
vkGetPhysicalDeviceFeatures2(physicalDevice, &physicalDeviceFeatures2);
|
||||
|
||||
// Check what dynamic states are supported by the current implementation
|
||||
hasDynamicState = vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
|
||||
hasDynamicState2 = vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME);
|
||||
hasDynamicState3 = vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME);
|
||||
// Checking for available features is probably sufficient, but retained redundant extension checks for clarity and consistency
|
||||
hasDynamicState = vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) && extendedDynamicStateFeaturesEXT.extendedDynamicState;
|
||||
hasDynamicState2 = vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) && extendedDynamicState2FeaturesEXT.extendedDynamicState2;
|
||||
hasDynamicState3 = vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME) && extendedDynamicState3FeaturesEXT.extendedDynamicState3ColorBlendEnable && extendedDynamicState3FeaturesEXT.extendedDynamicState3ColorBlendEquation;
|
||||
hasDynamicVertexState = vulkanDevice->extensionSupported(VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME);
|
||||
|
||||
// Enable dynamic state extensions if present. This function is called after physical and before logical device creation, so we can enabled extensions based on a list of supported extensions
|
||||
if (vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME)) {
|
||||
if (hasDynamicState) {
|
||||
enabledDeviceExtensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
|
||||
extendedDynamicStateFeaturesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT;
|
||||
extendedDynamicStateFeaturesEXT.extendedDynamicState = VK_TRUE;
|
||||
extendedDynamicStateFeaturesEXT.pNext = nullptr;
|
||||
deviceCreatepNextChain = &extendedDynamicStateFeaturesEXT;
|
||||
}
|
||||
if (vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME)) {
|
||||
if (hasDynamicState2) {
|
||||
enabledDeviceExtensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME);
|
||||
extendedDynamicState2FeaturesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT;
|
||||
extendedDynamicState2FeaturesEXT.extendedDynamicState2 = VK_TRUE;
|
||||
extendedDynamicState2FeaturesEXT.pNext = nullptr;
|
||||
if (hasDynamicState) {
|
||||
extendedDynamicStateFeaturesEXT.pNext = &extendedDynamicState2FeaturesEXT;
|
||||
}
|
||||
|
|
@ -118,11 +130,8 @@ public:
|
|||
deviceCreatepNextChain = &extendedDynamicState2FeaturesEXT;
|
||||
}
|
||||
}
|
||||
if (vulkanDevice->extensionSupported(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME)) {
|
||||
if (hasDynamicState3) {
|
||||
enabledDeviceExtensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME);
|
||||
extendedDynamicState3FeaturesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT;
|
||||
extendedDynamicState3FeaturesEXT.extendedDynamicState3ColorBlendEnable = VK_TRUE;
|
||||
extendedDynamicState3FeaturesEXT.extendedDynamicState3ColorBlendEquation = VK_TRUE;
|
||||
if (hasDynamicState2) {
|
||||
extendedDynamicState2FeaturesEXT.pNext = &extendedDynamicState3FeaturesEXT;
|
||||
}
|
||||
|
|
@ -131,7 +140,7 @@ public:
|
|||
}
|
||||
|
||||
}
|
||||
if (vulkanDevice->extensionSupported(VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME)) {
|
||||
if (hasDynamicVertexState) {
|
||||
enabledDeviceExtensions.push_back(VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME);
|
||||
}
|
||||
}
|
||||
|
|
@ -377,7 +386,7 @@ public:
|
|||
rebuildCB |= overlay->checkBox("Depth test", &dynamicState.depthTest);
|
||||
rebuildCB |= overlay->checkBox("Depth write", &dynamicState.depthWrite);
|
||||
} else {
|
||||
overlay->text("Extension not supported");
|
||||
overlay->text("Extension or features not supported");
|
||||
}
|
||||
}
|
||||
if (overlay->header("Dynamic state 2")) {
|
||||
|
|
@ -385,7 +394,7 @@ public:
|
|||
rebuildCB |= overlay->checkBox("Rasterizer discard", &dynamicState2.rasterizerDiscardEnable);
|
||||
}
|
||||
else {
|
||||
overlay->text("Extension not supported");
|
||||
overlay->text("Extension or features not supported");
|
||||
}
|
||||
}
|
||||
if (overlay->header("Dynamic state 3")) {
|
||||
|
|
@ -394,7 +403,7 @@ public:
|
|||
rebuildCB |= overlay->colorPicker("Clear color", clearColor);
|
||||
}
|
||||
else {
|
||||
overlay->text("Extension not supported");
|
||||
overlay->text("Extension or features not supported");
|
||||
}
|
||||
}
|
||||
if (rebuildCB) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public:
|
|||
imageInfo.mipLevels = 1;
|
||||
imageInfo.arrayLayers = 1;
|
||||
imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - On macOS/iOS use linear tiling for atomic image access, see https://github.com/KhronosGroup/MoltenVK/issues/1027
|
||||
imageInfo.tiling = VK_IMAGE_TILING_LINEAR;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public:
|
|||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets.particles, 0, nullptr);
|
||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.particles);
|
||||
vkCmdBindVertexBuffers(drawCmdBuffers[i], 0, 1, &particles.buffer, offsets);
|
||||
vkCmdDraw(drawCmdBuffers[i], static_cast<uint32_t>(particles.size), 1, 0, 0);
|
||||
vkCmdDraw(drawCmdBuffers[i], static_cast<uint32_t>(particleBuffer.size()), 1, 0, 0);
|
||||
|
||||
drawUI(drawCmdBuffers[i]);
|
||||
|
||||
|
|
|
|||
|
|
@ -463,12 +463,20 @@ public:
|
|||
shaderGroups.push_back(shaderGroup);
|
||||
}
|
||||
|
||||
// Get max pipeline ray tracing recursion depth for physical device
|
||||
VkPhysicalDeviceRayTracingPipelinePropertiesKHR physicalDeviceRayTracingPipelinePropertiesKHR {};
|
||||
physicalDeviceRayTracingPipelinePropertiesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR;
|
||||
VkPhysicalDeviceProperties2 physicalDeviceProperties2;
|
||||
physicalDeviceProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
|
||||
physicalDeviceProperties2.pNext = &physicalDeviceRayTracingPipelinePropertiesKHR;
|
||||
vkGetPhysicalDeviceProperties2(physicalDevice, &physicalDeviceProperties2);
|
||||
|
||||
VkRayTracingPipelineCreateInfoKHR rayTracingPipelineCI = vks::initializers::rayTracingPipelineCreateInfoKHR();
|
||||
rayTracingPipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
|
||||
rayTracingPipelineCI.pStages = shaderStages.data();
|
||||
rayTracingPipelineCI.groupCount = static_cast<uint32_t>(shaderGroups.size());
|
||||
rayTracingPipelineCI.pGroups = shaderGroups.data();
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = 2;
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = std::min(uint32_t(2), physicalDeviceRayTracingPipelinePropertiesKHR.maxRayRecursionDepth);
|
||||
rayTracingPipelineCI.layout = pipelineLayout;
|
||||
VK_CHECK_RESULT(vkCreateRayTracingPipelinesKHR(device, VK_NULL_HANDLE, VK_NULL_HANDLE, 1, &rayTracingPipelineCI, nullptr, &pipeline));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -431,12 +431,20 @@ public:
|
|||
shaderGroups.push_back(shaderGroup);
|
||||
}
|
||||
|
||||
// Get max pipeline ray tracing recursion depth for physical device
|
||||
VkPhysicalDeviceRayTracingPipelinePropertiesKHR physicalDeviceRayTracingPipelinePropertiesKHR {};
|
||||
physicalDeviceRayTracingPipelinePropertiesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR;
|
||||
VkPhysicalDeviceProperties2 physicalDeviceProperties2;
|
||||
physicalDeviceProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
|
||||
physicalDeviceProperties2.pNext = &physicalDeviceRayTracingPipelinePropertiesKHR;
|
||||
vkGetPhysicalDeviceProperties2(physicalDevice, &physicalDeviceProperties2);
|
||||
|
||||
VkRayTracingPipelineCreateInfoKHR rayTracingPipelineCI = vks::initializers::rayTracingPipelineCreateInfoKHR();
|
||||
rayTracingPipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
|
||||
rayTracingPipelineCI.pStages = shaderStages.data();
|
||||
rayTracingPipelineCI.groupCount = static_cast<uint32_t>(shaderGroups.size());
|
||||
rayTracingPipelineCI.pGroups = shaderGroups.data();
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = 2;
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = std::min(uint32_t(2), physicalDeviceRayTracingPipelinePropertiesKHR.maxRayRecursionDepth);
|
||||
rayTracingPipelineCI.layout = pipelineLayout;
|
||||
VK_CHECK_RESULT(vkCreateRayTracingPipelinesKHR(device, VK_NULL_HANDLE, VK_NULL_HANDLE, 1, &rayTracingPipelineCI, nullptr, &pipeline));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -393,12 +393,20 @@ public:
|
|||
shaderGroups.push_back(shaderGroup);
|
||||
}
|
||||
|
||||
// Get max pipeline ray tracing recursion depth for physical device
|
||||
VkPhysicalDeviceRayTracingPipelinePropertiesKHR physicalDeviceRayTracingPipelinePropertiesKHR {};
|
||||
physicalDeviceRayTracingPipelinePropertiesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR;
|
||||
VkPhysicalDeviceProperties2 physicalDeviceProperties2;
|
||||
physicalDeviceProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
|
||||
physicalDeviceProperties2.pNext = &physicalDeviceRayTracingPipelinePropertiesKHR;
|
||||
vkGetPhysicalDeviceProperties2(physicalDevice, &physicalDeviceProperties2);
|
||||
|
||||
VkRayTracingPipelineCreateInfoKHR rayTracingPipelineCI = vks::initializers::rayTracingPipelineCreateInfoKHR();
|
||||
rayTracingPipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
|
||||
rayTracingPipelineCI.pStages = shaderStages.data();
|
||||
rayTracingPipelineCI.groupCount = static_cast<uint32_t>(shaderGroups.size());
|
||||
rayTracingPipelineCI.pGroups = shaderGroups.data();
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = 4;
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = std::min(uint32_t(4), physicalDeviceRayTracingPipelinePropertiesKHR.maxRayRecursionDepth);
|
||||
rayTracingPipelineCI.layout = pipelineLayout;
|
||||
VK_CHECK_RESULT(vkCreateRayTracingPipelinesKHR(device, VK_NULL_HANDLE, VK_NULL_HANDLE, 1, &rayTracingPipelineCI, nullptr, &pipeline));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -393,12 +393,20 @@ public:
|
|||
shaderGroups.push_back(shaderGroup);
|
||||
}
|
||||
|
||||
// Get max pipeline ray tracing recursion depth for physical device
|
||||
VkPhysicalDeviceRayTracingPipelinePropertiesKHR physicalDeviceRayTracingPipelinePropertiesKHR {};
|
||||
physicalDeviceRayTracingPipelinePropertiesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR;
|
||||
VkPhysicalDeviceProperties2 physicalDeviceProperties2;
|
||||
physicalDeviceProperties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
|
||||
physicalDeviceProperties2.pNext = &physicalDeviceRayTracingPipelinePropertiesKHR;
|
||||
vkGetPhysicalDeviceProperties2(physicalDevice, &physicalDeviceProperties2);
|
||||
|
||||
VkRayTracingPipelineCreateInfoKHR rayTracingPipelineCI = vks::initializers::rayTracingPipelineCreateInfoKHR();
|
||||
rayTracingPipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
|
||||
rayTracingPipelineCI.pStages = shaderStages.data();
|
||||
rayTracingPipelineCI.groupCount = static_cast<uint32_t>(shaderGroups.size());
|
||||
rayTracingPipelineCI.pGroups = shaderGroups.data();
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = 2;
|
||||
rayTracingPipelineCI.maxPipelineRayRecursionDepth = std::min(uint32_t(2), physicalDeviceRayTracingPipelinePropertiesKHR.maxRayRecursionDepth);
|
||||
rayTracingPipelineCI.layout = pipelineLayout;
|
||||
VK_CHECK_RESULT(vkCreateRayTracingPipelinesKHR(device, VK_NULL_HANDLE, VK_NULL_HANDLE, 1, &rayTracingPipelineCI, nullptr, &pipeline));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
#define VK_ENABLE_BETA_EXTENSIONS
|
||||
#endif
|
||||
#include <vulkan/vulkan.h>
|
||||
|
|
@ -208,7 +208,7 @@ public:
|
|||
instanceCreateInfo.enabledLayerCount = layerCount;
|
||||
}
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - When running on macOS with MoltenVK, enable VK_KHR_get_physical_device_properties2 (required by VK_KHR_portability_subset)
|
||||
instanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
#if defined(VK_KHR_portability_enumeration)
|
||||
|
|
@ -290,7 +290,7 @@ public:
|
|||
deviceCreateInfo.queueCreateInfoCount = 1;
|
||||
deviceCreateInfo.pQueueCreateInfos = &queueCreateInfo;
|
||||
std::vector<const char*> deviceExtensions = {};
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK) && defined(VK_KHR_portability_subset)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)) && defined(VK_KHR_portability_subset)
|
||||
// SRS - When running on macOS with MoltenVK and VK_KHR_portability_subset is defined and supported by the device, enable the extension
|
||||
uint32_t deviceExtCount = 0;
|
||||
vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &deviceExtCount, nullptr);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public:
|
|||
camera.setRotation(glm::vec3(-40.0f, -90.0f, 0.0f));
|
||||
camera.setTranslation(glm::vec3(0.0f, 0.0f, -2.0f));
|
||||
|
||||
#if defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - on macOS set environment variable to ensure MoltenVK disables Metal argument buffers for this example
|
||||
setenv("MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS", "0", 1);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -516,7 +516,9 @@ public:
|
|||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
||||
model.draw(drawCmdBuffers[i]);
|
||||
|
||||
textOverlay->draw(drawCmdBuffers[i]);
|
||||
if (textOverlay->visible) {
|
||||
textOverlay->draw(drawCmdBuffers[i]);
|
||||
}
|
||||
|
||||
vkCmdEndRenderPass(drawCmdBuffers[i]);
|
||||
|
||||
|
|
@ -709,6 +711,7 @@ public:
|
|||
case KEY_KPADD:
|
||||
case KEY_SPACE:
|
||||
textOverlay->visible = !textOverlay->visible;
|
||||
buildCommandBuffers();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1160,7 +1160,7 @@ int main(const int argc, const char *argv[])
|
|||
delete(vulkanExample);
|
||||
return 0;
|
||||
}
|
||||
#elif (defined(VK_USE_PLATFORM_MACOS_MVK) && defined(VK_EXAMPLE_XCODE_GENERATED))
|
||||
#elif (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)) && defined(VK_EXAMPLE_XCODE_GENERATED)
|
||||
VulkanExample *vulkanExample;
|
||||
int main(const int argc, const char *argv[])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,18 +53,18 @@ public:
|
|||
|
||||
VulkanExample();
|
||||
~VulkanExample();
|
||||
virtual void getEnabledFeatures();
|
||||
virtual void getEnabledFeatures() override;
|
||||
void handleResize();
|
||||
void buildCommandBuffers();
|
||||
void buildCommandBuffers() override;
|
||||
void loadAssets();
|
||||
void prepareShadingRateImage();
|
||||
void setupDescriptors();
|
||||
void preparePipelines();
|
||||
void prepareUniformBuffers();
|
||||
void updateUniformBuffers();
|
||||
void prepare();
|
||||
void prepare() override;
|
||||
void setupFrameBuffer() override;
|
||||
void setupRenderPass() override;
|
||||
virtual void render();
|
||||
virtual void OnUpdateUIOverlay(vks::UIOverlay* overlay);
|
||||
};
|
||||
virtual void render() override;
|
||||
virtual void OnUpdateUIOverlay(vks::UIOverlay* overlay) override;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue