Fix RHI constant binding and add sphere test
This commit is contained in:
@@ -493,3 +493,57 @@ TEST_P(RHITestFixture, DescriptorSet_Update_UsesBindingNumberOnOpenGL) {
|
||||
pool->Shutdown();
|
||||
delete pool;
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, DescriptorSet_BindConstantBuffer_UsesBindingNumberOnOpenGL) {
|
||||
if (GetBackendType() != RHIType::OpenGL) {
|
||||
GTEST_SKIP() << "OpenGL-specific constant buffer binding verification";
|
||||
}
|
||||
|
||||
auto* openGLDevice = static_cast<OpenGLDevice*>(GetDevice());
|
||||
ASSERT_NE(openGLDevice, nullptr);
|
||||
ASSERT_TRUE(openGLDevice->MakeContextCurrent());
|
||||
|
||||
DescriptorPoolDesc poolDesc = {};
|
||||
poolDesc.type = DescriptorHeapType::CBV_SRV_UAV;
|
||||
poolDesc.descriptorCount = 1;
|
||||
poolDesc.shaderVisible = false;
|
||||
|
||||
RHIDescriptorPool* pool = GetDevice()->CreateDescriptorPool(poolDesc);
|
||||
ASSERT_NE(pool, nullptr);
|
||||
|
||||
DescriptorSetLayoutBinding binding = {};
|
||||
binding.binding = 3;
|
||||
binding.type = static_cast<uint32_t>(DescriptorType::CBV);
|
||||
binding.count = 1;
|
||||
|
||||
DescriptorSetLayoutDesc layoutDesc = {};
|
||||
layoutDesc.bindings = &binding;
|
||||
layoutDesc.bindingCount = 1;
|
||||
|
||||
RHIDescriptorSet* set = pool->AllocateSet(layoutDesc);
|
||||
ASSERT_NE(set, nullptr);
|
||||
|
||||
const float matrixData[16] = {
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f,
|
||||
};
|
||||
set->WriteConstant(3, matrixData, sizeof(matrixData));
|
||||
set->Bind();
|
||||
|
||||
GLint boundBuffer = 0;
|
||||
glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, 3, &boundBuffer);
|
||||
EXPECT_NE(boundBuffer, 0);
|
||||
|
||||
set->Unbind();
|
||||
|
||||
GLint unboundBuffer = -1;
|
||||
glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, 3, &unboundBuffer);
|
||||
EXPECT_EQ(unboundBuffer, 0);
|
||||
|
||||
set->Shutdown();
|
||||
delete set;
|
||||
pool->Shutdown();
|
||||
delete pool;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user