[Bf-blender-cvs] [f4dcad7b247] temp-gpu-push-constants: GPU: Sizecheck for push constants buffer.

Jeroen Bakker noreply at git.blender.org
Fri Jul 2 16:39:50 CEST 2021


Commit: f4dcad7b2472f803174c83c0af2e70b321cdd80c
Author: Jeroen Bakker
Date:   Fri Jul 2 16:38:23 2021 +0200
Branches: temp-gpu-push-constants
https://developer.blender.org/rBf4dcad7b2472f803174c83c0af2e70b321cdd80c

GPU: Sizecheck for push constants buffer.

According to the specs platforms should at least support push constants
of 128 bytes. As there are known platforms that have set this as their
maximum (Mesa for example) we should use this as the maximum as well.

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

M	source/blender/gpu/intern/gpu_shader.cc
M	source/blender/gpu/intern/gpu_uniform_buffer_private.hh

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

diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index 1c66b43d93e..e108fb4a977 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -558,7 +558,11 @@ void GPU_shader_uniform_4fv_array(GPUShader *sh, const char *name, int len, cons
 
 void GPU_shader_uniform_push_constant(GPUShader *sh, GPUUniformBuf *ubo)
 {
+  /* According to the specification all platforms should at least support 128 bytes. We should
+   * support only upto the minimum size as some platforms have set this as their max. */
+  static constexpr size_t MAX_PUSH_CONSTANTS_LEN = 128;
   UniformBuf *buf = unwrap(ubo);
+  BLI_assert(buf->size_in_bytes() < MAX_PUSH_CONSTANTS_LEN);
   unwrap(sh)->uniform_push_constant(buf);
 }
 
diff --git a/source/blender/gpu/intern/gpu_uniform_buffer_private.hh b/source/blender/gpu/intern/gpu_uniform_buffer_private.hh
index e8fc1343eaf..603af550d28 100644
--- a/source/blender/gpu/intern/gpu_uniform_buffer_private.hh
+++ b/source/blender/gpu/intern/gpu_uniform_buffer_private.hh
@@ -63,6 +63,11 @@ class UniformBuf {
   {
     data_ = data;
   }
+
+  size_t size_in_bytes() const
+  {
+    return size_in_bytes_;
+  }
 };
 
 /* Syntactic sugar. */



More information about the Bf-blender-cvs mailing list