[Bf-blender-cvs] [7e18aa4250f] master: Fix T63524: crash selecting an object in texture coordinate node

Brecht Van Lommel noreply at git.blender.org
Thu Apr 25 12:14:28 CEST 2019


Commit: 7e18aa4250ffc8ec6c475fb90fc5549e6a4d5de6
Author: Brecht Van Lommel
Date:   Thu Apr 25 12:11:55 2019 +0200
Branches: master
https://developer.blender.org/rB7e18aa4250ffc8ec6c475fb90fc5549e6a4d5de6

Fix T63524: crash selecting an object in texture coordinate node

Using mat4 in a uniform buffer object was not properly supported.

===================================================================

M	source/blender/gpu/intern/gpu_uniformbuffer.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index 651e3c1aaa7..6b2c9033c13 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -65,7 +65,7 @@ static void gpu_uniformbuffer_inputs_sort(struct ListBase *inputs);
 
 /* Only support up to this type, if you want to extend it, make sure the
  * padding logic is correct for the new types. */
-#define MAX_UBO_GPU_TYPE GPU_VEC4
+#define MAX_UBO_GPU_TYPE GPU_MAT4
 
 static void gpu_uniformbuffer_initialize(GPUUniformBuffer *ubo, const void *data)
 {
@@ -255,11 +255,11 @@ static int inputs_cmp(const void *a, const void *b)
 
 /**
  * Make sure we respect the expected alignment of UBOs.
- * vec4, pad vec3 as vec4, then vec2, then floats.
+ * mat4, vec4, pad vec3 as vec4, then vec2, then floats.
  */
 static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
 {
-  /* Order them as vec4, vec3, vec2, float. */
+  /* Order them as mat4, vec4, vec3, vec2, float. */
   BLI_listbase_sort(inputs, inputs_cmp);
 
   /* Creates a lookup table for the different types; */
@@ -268,6 +268,17 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
 
   for (LinkData *link = inputs->first; link; link = link->next) {
     GPUInput *input = link->data;
+
+    if (input->type == GPU_MAT3) {
+      /* Alignment for mat3 is not handled currently, so not supported */
+      BLI_assert(!"mat3 not supported in UBO");
+      continue;
+    }
+    else if (input->type > MAX_UBO_GPU_TYPE) {
+      BLI_assert(!"GPU type not supported in UBO");
+      continue;
+    }
+
     if (input->type == cur_type) {
       continue;
     }



More information about the Bf-blender-cvs mailing list