Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-09-01 15:46:17 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-09-02 20:37:15 +0300
commite48a6fcc6397e5a964f2096d937ac189f07ce999 (patch)
tree37f98d5dab5c869b7248fc65a35edfc1b618b531 /source/blender/draw/intern/draw_manager.cc
parent356460f5cf659ef071daa1267ab368b733b4133e (diff)
DRW-Next: Add uniform attributes (object attributes) support
This replaces the direct shader uniform layout declaration by a linear search through a global buffer. Each instance has an attribute offset inside the global buffer and an attribute count. This removes any padding and tighly pack all uniform attributes inside a single buffer. This would also remove the limit of 8 attribute but it is kept because of compatibility with the old system that is still used by the old draw manager.
Diffstat (limited to 'source/blender/draw/intern/draw_manager.cc')
-rw-r--r--source/blender/draw/intern/draw_manager.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc
index 8fb2ffb39e8..2841abb53e7 100644
--- a/source/blender/draw/intern/draw_manager.cc
+++ b/source/blender/draw/intern/draw_manager.cc
@@ -43,6 +43,7 @@ void Manager::begin_sync()
memset(infos_buf.data(), 0xF0, resource_len_ * sizeof(*infos_buf.data()));
#endif
resource_len_ = 0;
+ attribute_len_ = 0;
/* TODO(fclem): Resize buffers if too big, but with an hysteresis threshold. */
object_active = DST.draw_ctx.obact;
@@ -58,6 +59,8 @@ void Manager::end_sync()
matrix_buf.push_update();
bounds_buf.push_update();
infos_buf.push_update();
+ attributes_buf.push_update();
+ attributes_buf_legacy.push_update();
debug_bind();
@@ -90,6 +93,16 @@ void Manager::debug_bind()
#endif
}
+void Manager::resource_bind()
+{
+ GPU_storagebuf_bind(matrix_buf, DRW_OBJ_MAT_SLOT);
+ GPU_storagebuf_bind(infos_buf, DRW_OBJ_INFOS_SLOT);
+ GPU_storagebuf_bind(attributes_buf, DRW_OBJ_ATTR_SLOT);
+ /* 2 is the hardcoded location of the uniform attr UBO. */
+ /* TODO(@fclem): Remove this workaround. */
+ GPU_uniformbuf_bind(attributes_buf_legacy, 2);
+}
+
void Manager::submit(PassSimple &pass, View &view)
{
view.bind();
@@ -101,9 +114,7 @@ void Manager::submit(PassSimple &pass, View &view)
pass.draw_commands_buf_.bind(state, pass.headers_, pass.commands_);
- GPU_storagebuf_bind(matrix_buf, DRW_OBJ_MAT_SLOT);
- GPU_storagebuf_bind(infos_buf, DRW_OBJ_INFOS_SLOT);
- // GPU_storagebuf_bind(attribute_buf, DRW_OBJ_ATTR_SLOT); /* TODO */
+ resource_bind();
pass.submit(state);
@@ -126,9 +137,7 @@ void Manager::submit(PassMain &pass, View &view)
pass.draw_commands_buf_.bind(state, pass.headers_, pass.commands_, view.visibility_buf_);
- GPU_storagebuf_bind(matrix_buf, DRW_OBJ_MAT_SLOT);
- GPU_storagebuf_bind(infos_buf, DRW_OBJ_INFOS_SLOT);
- // GPU_storagebuf_bind(attribute_buf, DRW_OBJ_ATTR_SLOT); /* TODO */
+ resource_bind();
pass.submit(state);
@@ -150,9 +159,7 @@ void Manager::submit(PassSimple &pass)
pass.draw_commands_buf_.bind(state, pass.headers_, pass.commands_);
- GPU_storagebuf_bind(matrix_buf, DRW_OBJ_MAT_SLOT);
- GPU_storagebuf_bind(infos_buf, DRW_OBJ_INFOS_SLOT);
- // GPU_storagebuf_bind(attribute_buf, DRW_OBJ_ATTR_SLOT); /* TODO */
+ resource_bind();
pass.submit(state);