VideoCommon/RenderBase: Use a std::string_view with CreateShaderFromSource()

Greatly simplifies the overall interface when it comes to compiling
shaders. Also allows getting rid of a std::string overload of the same
name. Now std::string and const char* both go through the same function.
This commit is contained in:
Lioncash
2019-05-30 03:07:40 -04:00
parent 80d8173d29
commit e60268bd42
25 changed files with 94 additions and 117 deletions

View File

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