GPUShader: Fix linking working even if one shader compilation failed
Linking without valid shaders works on some drivers. Avoid this case by forcing linking step to return false.
This commit is contained in:
parent
3a6e981bcd
commit
2e630297af
Notes:
blender-bot
2023-02-14 02:27:56 +01:00
Referenced by issue #80168, Crash if shader compilation fails
|
@ -151,6 +151,7 @@ GLuint GLShader::create_shader_stage(GLenum gl_stage, MutableSpan<const char *>
|
|||
}
|
||||
if (!status) {
|
||||
glDeleteShader(shader);
|
||||
compilation_failed_ = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -193,6 +194,10 @@ void GLShader::fragment_shader_from_glsl(MutableSpan<const char *> sources)
|
|||
|
||||
bool GLShader::finalize(void)
|
||||
{
|
||||
if (compilation_failed_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
glLinkProgram(shader_program_);
|
||||
|
||||
GLint status;
|
||||
|
|
|
@ -39,10 +39,12 @@ class GLShader : public Shader {
|
|||
private:
|
||||
/** Handle for full program (links shader stages below). */
|
||||
GLuint shader_program_ = 0;
|
||||
|
||||
/** Individual shader stages. */
|
||||
GLuint vert_shader_ = 0;
|
||||
GLuint geom_shader_ = 0;
|
||||
GLuint frag_shader_ = 0;
|
||||
/** True if any shader failed to compile. */
|
||||
bool compilation_failed_ = false;
|
||||
|
||||
eGPUShaderTFBType transform_feedback_type_ = GPU_SHADER_TFB_NONE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue