Add command flag for picking between shaders

The new `-s`, `--shaders` command line flag allows you to specify whether you want to load the glsl or hlsl shaders.
Defaults to glsl.

Issue: #723
This commit is contained in:
Ben Clayton 2020-05-29 16:36:27 +01:00
parent 8c35694de9
commit 301e8abf12
7 changed files with 45 additions and 20 deletions

View file

@ -129,6 +129,11 @@ void VulkanExampleBase::destroyCommandBuffers()
vkFreeCommandBuffers(device, cmdPool, static_cast<uint32_t>(drawCmdBuffers.size()), drawCmdBuffers.data());
}
std::string VulkanExampleBase::getShadersPath() const
{
return getAssetPath() + "shaders/" + shaderDir + "/";
}
void VulkanExampleBase::createPipelineCache()
{
VkPipelineCacheCreateInfo pipelineCacheCreateInfo = {};
@ -642,6 +647,18 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation)
uint32_t h = strtol(args[i + 1], &numConvPtr, 10);
if (numConvPtr != args[i + 1]) { height = h; };
}
// Select between glsl and hlsl shaders
if ((args[i] == std::string("-s")) || (args[i] == std::string("--shaders"))) {
std::string type;
if (args.size() > i + 1) {
type = args[i + 1];
}
if (type == "glsl" || type == "hlsl") {
shaderDir = type;
} else {
std::cerr << args[i] << " must be one of 'glsl' or 'hlsl'" << std::endl;
}
}
// Benchmark
if ((args[i] == std::string("-b")) || (args[i] == std::string("--benchmark"))) {
benchmark.active = true;