diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-07-18 18:02:05 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-07-19 15:38:32 +0300 |
commit | f9e3d7d7eb897da5cc9ea0503707eb35c9a57b68 (patch) | |
tree | 1010c079198d7cf9d58a9d6442b06ac45fac08bd | |
parent | e02e140ef1f43c92d2dfe44ecf0eda4b737a3fad (diff) |
GPU: Batch: Reverse order of VBO binding
This is to ensure the vbo[0] always has predecence over other VBO.
This is important for overriding attributes by switching vbo binding order.
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 196a8a0f3b9..f972718afa7 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -447,8 +447,11 @@ static void create_bindings(GPUVertBuf *verts, static void batch_update_program_bindings(GPUBatch *batch, uint v_first) { - for (int v = 0; v < GPU_BATCH_VBO_MAX_LEN && batch->verts[v] != NULL; ++v) { - create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); + /* Reverse order so first vbos have more prevalence (in term of attrib override). */ + for (int v = GPU_BATCH_VBO_MAX_LEN - 1; v > -1; --v) { + if (batch->verts[v] != NULL) { + create_bindings(batch->verts[v], batch->interface, (batch->inst) ? 0 : v_first, false); + } } if (batch->inst) { create_bindings(batch->inst, batch->interface, v_first, true); |