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:
Lioncash
2019-05-30 03:52:05 -04:00
parent e60268bd42
commit d6a60050ff
3 changed files with 30 additions and 30 deletions

View File

@ -5,6 +5,7 @@
#pragma once
#include <cstddef>
#include <optional>
#include <string_view>
#include <vector>
@ -19,16 +20,16 @@ using SPIRVCodeType = u32;
using SPIRVCodeVector = std::vector<SPIRVCodeType>;
// Compile a vertex shader to SPIR-V.
bool CompileVertexShader(SPIRVCodeVector* out_code, std::string_view source_code);
std::optional<SPIRVCodeVector> CompileVertexShader(std::string_view source_code);
// Compile a geometry shader to SPIR-V.
bool CompileGeometryShader(SPIRVCodeVector* out_code, std::string_view source_code);
std::optional<SPIRVCodeVector> CompileGeometryShader(std::string_view source_code);
// Compile a fragment shader to SPIR-V.
bool CompileFragmentShader(SPIRVCodeVector* out_code, std::string_view source_code);
std::optional<SPIRVCodeVector> CompileFragmentShader(std::string_view source_code);
// Compile a compute shader to SPIR-V.
bool CompileComputeShader(SPIRVCodeVector* out_code, std::string_view source_code);
std::optional<SPIRVCodeVector> CompileComputeShader(std::string_view source_code);
} // namespace ShaderCompiler
} // namespace Vulkan