mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 13:49:53 -06:00
VideoVulkan/ShaderCompiler: Use a std::optional instead of bool+out variable
Now that we utilize C++17, we can simply return an optional containing the code instead of using an out variable and a boolean result, essentially combining them into one. This provides a much more straightforward interface.
This commit is contained in:
@ -88,31 +88,29 @@ static std::unique_ptr<VKShader> CreateShaderObject(ShaderStage stage,
|
||||
|
||||
std::unique_ptr<VKShader> VKShader::CreateFromSource(ShaderStage stage, std::string_view source)
|
||||
{
|
||||
ShaderCompiler::SPIRVCodeVector spv;
|
||||
bool result;
|
||||
std::optional<ShaderCompiler::SPIRVCodeVector> spv;
|
||||
switch (stage)
|
||||
{
|
||||
case ShaderStage::Vertex:
|
||||
result = ShaderCompiler::CompileVertexShader(&spv, source);
|
||||
spv = ShaderCompiler::CompileVertexShader(source);
|
||||
break;
|
||||
case ShaderStage::Geometry:
|
||||
result = ShaderCompiler::CompileGeometryShader(&spv, source);
|
||||
spv = ShaderCompiler::CompileGeometryShader(source);
|
||||
break;
|
||||
case ShaderStage::Pixel:
|
||||
result = ShaderCompiler::CompileFragmentShader(&spv, source);
|
||||
spv = ShaderCompiler::CompileFragmentShader(source);
|
||||
break;
|
||||
case ShaderStage::Compute:
|
||||
result = ShaderCompiler::CompileComputeShader(&spv, source);
|
||||
spv = ShaderCompiler::CompileComputeShader(source);
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!result)
|
||||
if (!spv)
|
||||
return nullptr;
|
||||
|
||||
return CreateShaderObject(stage, std::move(spv));
|
||||
return CreateShaderObject(stage, std::move(*spv));
|
||||
}
|
||||
|
||||
std::unique_ptr<VKShader> VKShader::CreateFromBinary(ShaderStage stage, const void* data,
|
||||
|
Reference in New Issue
Block a user