Fix RHI constant binding and add sphere test

This commit is contained in:
2026-03-26 01:23:29 +08:00
parent c5605c2a32
commit 39edb0b497
17 changed files with 959 additions and 35 deletions

View File

@@ -140,10 +140,22 @@ void OpenGLDescriptorSet::Bind() {
}
glBindBuffer(GL_UNIFORM_BUFFER, m_constantBuffer);
glBufferData(GL_UNIFORM_BUFFER, m_constantBufferData.size(), m_constantBufferData.data(), GL_DYNAMIC_DRAW);
glBindBufferBase(GL_UNIFORM_BUFFER, 0, m_constantBuffer);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
m_constantBufferDirty = false;
}
if (m_constantBuffer != 0) {
for (const auto& binding : m_bindings) {
if (binding.type != DescriptorType::CBV) {
continue;
}
for (uint32_t i = 0; i < binding.count; ++i) {
glBindBufferBase(GL_UNIFORM_BUFFER, binding.binding + i, m_constantBuffer);
}
}
}
for (size_t i = 0; i < m_bindings.size(); ++i) {
const auto& binding = m_bindings[i];
@@ -170,6 +182,12 @@ void OpenGLDescriptorSet::Unbind() {
for (size_t i = 0; i < m_bindings.size(); ++i) {
const auto& binding = m_bindings[i];
if (binding.type == DescriptorType::CBV) {
for (uint32_t j = 0; j < binding.count; ++j) {
glBindBufferBase(GL_UNIFORM_BUFFER, binding.binding + j, 0);
}
}
for (size_t j = 0; j < binding.textureUnits.size(); ++j) {
uint32_t unit = binding.textureUnits[j];