Add slang shaders for headless samples
This commit is contained in:
parent
a442bdd683
commit
04ab171247
4 changed files with 104 additions and 9 deletions
|
|
@ -97,6 +97,8 @@ public:
|
|||
|
||||
VkDebugReportCallbackEXT debugReportCallback{};
|
||||
|
||||
std::string shaderDir = "glsl";
|
||||
|
||||
uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties) {
|
||||
VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
|
||||
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
|
||||
|
|
@ -163,11 +165,19 @@ public:
|
|||
vks::android::loadVulkanLibrary();
|
||||
#endif
|
||||
|
||||
if (commandLineParser.isSet("shaders")) {
|
||||
shaderDir = commandLineParser.getValueAsString("shaders", "glsl");
|
||||
}
|
||||
|
||||
VkApplicationInfo appInfo = {};
|
||||
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
appInfo.pApplicationName = "Vulkan headless example";
|
||||
appInfo.pEngineName = "VulkanExample";
|
||||
appInfo.apiVersion = VK_API_VERSION_1_0;
|
||||
// Shaders generated by Slang require a certain SPIR-V environment that can't be satisfied by Vulkan 1.0, so we need to expliclity up that to at least 1.1 and enable some required extensions
|
||||
if (shaderDir == "slang") {
|
||||
appInfo.apiVersion = VK_API_VERSION_1_1;
|
||||
}
|
||||
|
||||
/*
|
||||
Vulkan instance creation (without surface extensions)
|
||||
|
|
@ -190,7 +200,7 @@ public:
|
|||
bool layersAvailable = true;
|
||||
for (auto layerName : validationLayers) {
|
||||
bool layerAvailable = false;
|
||||
for (auto instanceLayer : instanceLayers) {
|
||||
for (auto& instanceLayer : instanceLayers) {
|
||||
if (strcmp(instanceLayer.layerName, layerName) == 0) {
|
||||
layerAvailable = true;
|
||||
break;
|
||||
|
|
@ -290,8 +300,15 @@ public:
|
|||
deviceCreateInfo.queueCreateInfoCount = 1;
|
||||
deviceCreateInfo.pQueueCreateInfos = &queueCreateInfo;
|
||||
std::vector<const char*> deviceExtensions = {};
|
||||
|
||||
// Shaders generated by Slang require a certain SPIR-V environment that can't be satisfied by Vulkan 1.0, so we need to expliclity up that to at least 1.1 and enable some required extensions
|
||||
if (shaderDir == "slang") {
|
||||
deviceExtensions.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
|
||||
deviceExtensions.push_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
|
||||
}
|
||||
|
||||
#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
|
||||
// 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);
|
||||
if (deviceExtCount > 0)
|
||||
|
|
@ -643,7 +660,6 @@ public:
|
|||
|
||||
pipelineCreateInfo.pVertexInputState = &vertexInputState;
|
||||
|
||||
std::string shaderDir = "glsl";
|
||||
if (commandLineParser.isSet("shaders")) {
|
||||
shaderDir = commandLineParser.getValueAsString("shaders", "glsl");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue