[Bf-blender-cvs] [0ca2118] blender2.8: safety checks in GPU shader library
Mike Erwin
noreply at git.blender.org
Tue Sep 27 21:25:51 CEST 2016
Commit: 0ca211885182bf9b07329eeac7e0a930a410984a
Author: Mike Erwin
Date: Tue Sep 27 19:38:35 2016 +0200
Branches: blender2.8
https://developer.blender.org/rB0ca211885182bf9b07329eeac7e0a930a410984a
safety checks in GPU shader library
If shader compilation fails, or for some other reason the shader is NULL or 0, we need to know.
===================================================================
M source/blender/gpu/intern/gpu_shader.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 41a4537..6a730f3 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -470,6 +470,8 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode,
void GPU_shader_bind(GPUShader *shader)
{
+ BLI_assert(shader && shader->program);
+
glUseProgram(shader->program);
}
@@ -480,6 +482,8 @@ void GPU_shader_unbind(void)
void GPU_shader_free(GPUShader *shader)
{
+ BLI_assert(shader);
+
if (shader->vertex)
glDeleteShader(shader->vertex);
if (shader->geometry)
@@ -497,6 +501,8 @@ void GPU_shader_free(GPUShader *shader)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
{
+ BLI_assert(shader && shader->program);
+
return glGetUniformLocation(shader->program, name);
}
@@ -584,6 +590,8 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText
int GPU_shader_get_attribute(GPUShader *shader, const char *name)
{
+ BLI_assert(shader && shader->program);
+
return glGetAttribLocation(shader->program, name);
}
More information about the Bf-blender-cvs
mailing list