From 7b7fe714c458347b1fe7b8ea0ec36958e7260fad Mon Sep 17 00:00:00 2001 From: Ren Liu Date: Thu, 12 Dec 2024 17:44:49 -0800 Subject: [PATCH] ManagedUniformBuffer support OpenGL ComputeNode Differential Revision: D67106593 fbshipit-source-id: f871f75f0dbef1f6776e1023f00f0c1c7383af5f --- IGLU/managedUniformBuffer/ManagedUniformBuffer.cpp | 13 +++++++++++-- IGLU/managedUniformBuffer/ManagedUniformBuffer.h | 4 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/IGLU/managedUniformBuffer/ManagedUniformBuffer.cpp b/IGLU/managedUniformBuffer/ManagedUniformBuffer.cpp index 82fc276cf3..178149ea43 100644 --- a/IGLU/managedUniformBuffer/ManagedUniformBuffer.cpp +++ b/IGLU/managedUniformBuffer/ManagedUniformBuffer.cpp @@ -150,9 +150,18 @@ void ManagedUniformBuffer::bind(const igl::IDevice& device, } } -void ManagedUniformBuffer::bind(const igl::IDevice& device, igl::IComputeCommandEncoder& encoder) { +void ManagedUniformBuffer::bind(const igl::IDevice& device, + const igl::IComputePipelineState& pipelineState, + igl::IComputeCommandEncoder& encoder) { if (device.getBackendType() == igl::BackendType::OpenGL) { - IGL_DEBUG_ABORT("No ComputeEncoder supported for OpenGL\n"); + for (auto& uniform : uniformInfo.uniforms) { + uniform.location = pipelineState.getIndexByName(igl::genNameHandle(uniform.name)); + if (uniform.location >= 0) { + encoder.bindUniform(uniform, data_); + } else { + IGL_LOG_ERROR_ONCE("The uniform %s was not found in shader\n", uniform.name.c_str()); + } + } } else { if (useBindBytes_) { encoder.bindBytes(uniformInfo.index, data_, length_); diff --git a/IGLU/managedUniformBuffer/ManagedUniformBuffer.h b/IGLU/managedUniformBuffer/ManagedUniformBuffer.h index ed13511777..b21fde6e9e 100644 --- a/IGLU/managedUniformBuffer/ManagedUniformBuffer.h +++ b/IGLU/managedUniformBuffer/ManagedUniformBuffer.h @@ -34,7 +34,9 @@ class ManagedUniformBuffer { void bind(const igl::IDevice& device, const igl::IRenderPipelineState& pipelineState, igl::IRenderCommandEncoder& encoder); - void bind(const igl::IDevice& device, igl::IComputeCommandEncoder& encoder); + void bind(const igl::IDevice& device, + const igl::IComputePipelineState& pipelineState, + igl::IComputeCommandEncoder& encoder); void* getData();