diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-12-18 02:55:22 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-12-18 02:55:54 +0300 |
commit | 214a56ce8c67bb7a3af45aaafca8aa4a5ec85129 (patch) | |
tree | 442f85a7070eea078c5b1d995972f56c010e24ca /source/blender/gpu | |
parent | 8e31e53aa0ee9693582ad5b72cfe5732b57c72fd (diff) |
GPU: add memory barriers for vertex and index buffers
This adds memory barriers to use with `GPU_memory_barrier` to ensure that
writes to a vertex or index buffer issued before the barrier are
completed after it, so they can be safely read later by another shader.
`GPU_BARRIER_VERTEX_ATTRIB_ARRAY` should be used for vertex buffers (`GPUVertBuf`),
and `GPU_BARRIER_ELEMENT_ARRAY` should be used for index buffers (`GPUIndexBuf`).
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D13595
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_state.h | 4 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_state.hh | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index fa70a8934db..7b69012dcbc 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -40,9 +40,11 @@ typedef enum eGPUBarrier { GPU_BARRIER_SHADER_IMAGE_ACCESS = (1 << 0), GPU_BARRIER_TEXTURE_FETCH = (1 << 1), GPU_BARRIER_SHADER_STORAGE = (1 << 2), + GPU_BARRIER_VERTEX_ATTRIB_ARRAY = (1 << 3), + GPU_BARRIER_ELEMENT_ARRAY = (1 << 4), } eGPUBarrier; -ENUM_OPERATORS(eGPUBarrier, GPU_BARRIER_SHADER_STORAGE) +ENUM_OPERATORS(eGPUBarrier, GPU_BARRIER_ELEMENT_ARRAY) /** * Defines the fixed pipeline blending equation. diff --git a/source/blender/gpu/opengl/gl_state.hh b/source/blender/gpu/opengl/gl_state.hh index 979644b41c9..f5c38a33628 100644 --- a/source/blender/gpu/opengl/gl_state.hh +++ b/source/blender/gpu/opengl/gl_state.hh @@ -130,6 +130,12 @@ static inline GLbitfield to_gl(eGPUBarrier barrier_bits) if (barrier_bits & GPU_BARRIER_SHADER_STORAGE) { barrier |= GL_SHADER_STORAGE_BARRIER_BIT; } + if (barrier_bits & GPU_BARRIER_VERTEX_ATTRIB_ARRAY) { + barrier |= GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT; + } + if (barrier_bits & GPU_BARRIER_ELEMENT_ARRAY) { + barrier |= GL_ELEMENT_ARRAY_BARRIER_BIT; + } return barrier; } |