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
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user