mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
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:
@ -86,24 +86,23 @@ static std::unique_ptr<VKShader> CreateShaderObject(ShaderStage stage,
|
||||
return std::make_unique<VKShader>(std::move(spv), pipeline);
|
||||
}
|
||||
|
||||
std::unique_ptr<VKShader> VKShader::CreateFromSource(ShaderStage stage, const char* source,
|
||||
size_t length)
|
||||
std::unique_ptr<VKShader> VKShader::CreateFromSource(ShaderStage stage, std::string_view source)
|
||||
{
|
||||
ShaderCompiler::SPIRVCodeVector spv;
|
||||
bool result;
|
||||
switch (stage)
|
||||
{
|
||||
case ShaderStage::Vertex:
|
||||
result = ShaderCompiler::CompileVertexShader(&spv, source, length);
|
||||
result = ShaderCompiler::CompileVertexShader(&spv, source);
|
||||
break;
|
||||
case ShaderStage::Geometry:
|
||||
result = ShaderCompiler::CompileGeometryShader(&spv, source, length);
|
||||
result = ShaderCompiler::CompileGeometryShader(&spv, source);
|
||||
break;
|
||||
case ShaderStage::Pixel:
|
||||
result = ShaderCompiler::CompileFragmentShader(&spv, source, length);
|
||||
result = ShaderCompiler::CompileFragmentShader(&spv, source);
|
||||
break;
|
||||
case ShaderStage::Compute:
|
||||
result = ShaderCompiler::CompileComputeShader(&spv, source, length);
|
||||
result = ShaderCompiler::CompileComputeShader(&spv, source);
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
|
Reference in New Issue
Block a user