[Bf-blender-cvs] [576963d7c1e] master: Fix crash running GPU shader.format_calc() with attributes like gl_VertexID
Jeroen Bakker
noreply at git.blender.org
Mon Jul 15 11:25:08 CEST 2019
Commit: 576963d7c1e46c0fb59ee4c8741098cf690d0f27
Author: Jeroen Bakker
Date: Mon Jul 15 11:24:18 2019 +0200
Branches: master
https://developer.blender.org/rB576963d7c1e46c0fb59ee4c8741098cf690d0f27
Fix crash running GPU shader.format_calc() with attributes like gl_VertexID
When using opengl attributes such as gl_VertexID in a shader its
location is set to -1. This location was used without checking in an
attribute array. This fails big time when called from python. For
example `print(shader.format_calc())` made python crash immediately.
this fixes https://github.com/JacquesLucke/animation_nodes/issues/1141
Reviewed By: fclem, brecht
Differential Revision: https://developer.blender.org/D5231
===================================================================
M source/blender/gpu/intern/gpu_vertex_format.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c
index 37e1f9cf9da..e745c525df6 100644
--- a/source/blender/gpu/intern/gpu_vertex_format.c
+++ b/source/blender/gpu/intern/gpu_vertex_format.c
@@ -365,6 +365,11 @@ void GPU_vertformat_from_interface(GPUVertFormat *format, const GPUShaderInterfa
input = next;
next = input->next;
+ /* OpenGL attributes such as `gl_VertexID` have a location of -1. */
+ if (input->location < 0) {
+ continue;
+ }
+
format->name_len++; /* multiname support */
format->attr_len++;
More information about the Bf-blender-cvs
mailing list