mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
OGL: Store shader source in OGLShader
So it can be dumped with info log when linking fails.
This commit is contained in:
@ -24,15 +24,16 @@ static GLenum GetGLShaderTypeForStage(ShaderStage stage)
|
||||
}
|
||||
}
|
||||
|
||||
OGLShader::OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id)
|
||||
OGLShader::OGLShader(ShaderStage stage, GLenum gl_type, GLuint gl_id, std::string source)
|
||||
: AbstractShader(stage), m_id(ProgramShaderCache::GenerateShaderID()), m_type(gl_type),
|
||||
m_gl_id(gl_id)
|
||||
m_gl_id(gl_id), m_source(std::move(source))
|
||||
{
|
||||
}
|
||||
|
||||
OGLShader::OGLShader(GLuint gl_compute_program_id)
|
||||
OGLShader::OGLShader(GLuint gl_compute_program_id, std::string source)
|
||||
: AbstractShader(ShaderStage::Compute), m_id(ProgramShaderCache::GenerateShaderID()),
|
||||
m_type(GL_COMPUTE_SHADER), m_gl_compute_program_id(gl_compute_program_id)
|
||||
m_type(GL_COMPUTE_SHADER), m_gl_compute_program_id(gl_compute_program_id),
|
||||
m_source(std::move(source))
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,22 +48,22 @@ OGLShader::~OGLShader()
|
||||
std::unique_ptr<OGLShader> OGLShader::CreateFromSource(ShaderStage stage, const char* source,
|
||||
size_t length)
|
||||
{
|
||||
std::string source_str(source, length);
|
||||
if (stage != ShaderStage::Compute)
|
||||
{
|
||||
GLenum shader_type = GetGLShaderTypeForStage(stage);
|
||||
GLuint shader_id =
|
||||
ProgramShaderCache::CompileSingleShader(shader_type, std::string(source, length));
|
||||
GLuint shader_id = ProgramShaderCache::CompileSingleShader(shader_type, source_str);
|
||||
if (!shader_id)
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<OGLShader>(stage, shader_type, shader_id);
|
||||
return std::make_unique<OGLShader>(stage, shader_type, shader_id, std::move(source_str));
|
||||
}
|
||||
|
||||
// Compute shaders.
|
||||
SHADER prog;
|
||||
if (!ProgramShaderCache::CompileComputeShader(prog, std::string(source, length)))
|
||||
if (!ProgramShaderCache::CompileComputeShader(prog, source_str))
|
||||
return nullptr;
|
||||
return std::make_unique<OGLShader>(prog.glprogid);
|
||||
return std::make_unique<OGLShader>(prog.glprogid, std::move(source_str));
|
||||
}
|
||||
|
||||
} // namespace OGL
|
||||
|
Reference in New Issue
Block a user