diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-07-02 17:38:23 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-07-02 17:38:23 +0300 |
commit | f4dcad7b2472f803174c83c0af2e70b321cdd80c (patch) | |
tree | 302e86ddc7a80e51ef7866a1230dc6b888a466ef | |
parent | fd4652d4f621ca71fd2945c8003de764c6e7a800 (diff) |
GPU: Sizecheck for push constants buffer.temp-gpu-push-constants
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.
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.cc | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_uniform_buffer_private.hh | 5 |
2 files changed, 9 insertions, 0 deletions
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. */ |