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

@ -148,12 +148,6 @@ void Renderer::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
m_current_framebuffer = framebuffer;
}
std::unique_ptr<AbstractShader> Renderer::CreateShaderFromSource(ShaderStage stage,
const std::string& source)
{
return CreateShaderFromSource(stage, source.c_str(), source.size());
}
bool Renderer::EFBHasAlphaChannel() const
{
return m_prev_efb_format == PEControl::RGBA6_Z24;
@ -980,10 +974,10 @@ bool Renderer::InitializeImGui()
const std::string vertex_shader_source = GenerateImGuiVertexShader();
const std::string pixel_shader_source = GenerateImGuiPixelShader();
std::unique_ptr<AbstractShader> vertex_shader = CreateShaderFromSource(
ShaderStage::Vertex, vertex_shader_source.c_str(), vertex_shader_source.size());
std::unique_ptr<AbstractShader> pixel_shader = CreateShaderFromSource(
ShaderStage::Pixel, pixel_shader_source.c_str(), pixel_shader_source.size());
std::unique_ptr<AbstractShader> vertex_shader =
CreateShaderFromSource(ShaderStage::Vertex, vertex_shader_source);
std::unique_ptr<AbstractShader> pixel_shader =
CreateShaderFromSource(ShaderStage::Pixel, pixel_shader_source);
if (!vertex_shader || !pixel_shader)
{
PanicAlert("Failed to compile imgui shaders");