From 7f69685ff263681ccc9925a6d228dcf0590c3702 Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Mon, 1 Mar 2021 19:06:14 +0000 Subject: [PATCH] Bind uniform buffers using UBO Change-Id: I063b0f22e5f7ed3bbb8f1c159944eddadef128e2 --- .../gles-impl/gles-graphics-command-buffer.h | 23 ++++++++++++++++++++++ .../graphics/gles-impl/gles-graphics-program.cpp | 1 - .../graphics/gles-impl/gles-graphics-types.h | 10 ++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h b/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h index 614b066..6601fc5 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h @@ -40,6 +40,7 @@ enum class CommandType BIND_SAMPLERS, BIND_VERTEX_BUFFERS, BIND_INDEX_BUFFER, + BIND_UNIFORM_BUFFER, BIND_PIPELINE, DRAW, DRAW_INDEXED, @@ -137,6 +138,11 @@ struct Command bindIndexBuffer = rhs.bindIndexBuffer; break; } + case CommandType::BIND_UNIFORM_BUFFER: + { + bindUniformBuffers = std::move(rhs.bindUniformBuffers); + break; + } case CommandType::BIND_SAMPLERS: { bindSamplers = std::move(rhs.bindSamplers); @@ -206,6 +212,12 @@ struct Command struct { + using Binding = GLES::UniformBufferBindingDescriptor; + std::vector uniformBufferBindings; + } bindUniformBuffers; + + struct + { const GLES::Pipeline* pipeline{nullptr}; } bindPipeline; @@ -249,6 +261,17 @@ public: void BindUniformBuffers(const std::vector& bindings) override { + printf("BindUniformBuffers: bindings.size(): %lu\n", bindings.size()); + + mCommands.emplace_back(); + mCommands.back().type = CommandType::BIND_UNIFORM_BUFFER; + auto& uniformBufferBindings = mCommands.back().bindUniformBuffers.uniformBufferBindings; + + for(auto i = 0u; i < bindings.size(); ++i) + { + const auto& binding = bindings[i]; + printf("bindings[%u]->buffer: %p, dataSize: %u, offset: %u, binding: %u\n", i, binding.buffer, binding.dataSize, binding.offset, binding.binding); + } } void BindPipeline(const Graphics::Pipeline& pipeline) override diff --git a/dali/internal/graphics/gles-impl/gles-graphics-program.cpp b/dali/internal/graphics/gles-impl/gles-graphics-program.cpp index 2e28eca..9171203 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-program.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-program.cpp @@ -113,7 +113,6 @@ bool ProgramImpl::Create() // Initialize reflection mImpl->reflection->BuildUniformReflection(); mImpl->reflection->BuildVertexAttributeReflection(); - mImpl->reflection->BuildUniformBlockReflection(); return true; } diff --git a/dali/internal/graphics/gles-impl/gles-graphics-types.h b/dali/internal/graphics/gles-impl/gles-graphics-types.h index 4246adf..b59fed1 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-types.h +++ b/dali/internal/graphics/gles-impl/gles-graphics-types.h @@ -1270,6 +1270,16 @@ struct IndexBufferBindingDescriptor }; /** + * @brief Descriptor of uniform buffer binding within + * command buffer. + */ +struct UniformBufferBindingDescriptor +{ + const GLES::Buffer* buffer{nullptr}; + uint32_t offset{0u}; +}; + +/** * @brief The descriptor of draw call */ struct DrawCallDescriptor -- 2.7.4