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;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "fixtures/RHITestFixture.h"
|
||||
#include "XCEngine/RHI/D3D12/D3D12PipelineLayout.h"
|
||||
#include "XCEngine/RHI/RHIPipelineLayout.h"
|
||||
#include "XCEngine/RHI/RHIDescriptorSet.h"
|
||||
|
||||
@@ -151,4 +152,28 @@ TEST_P(RHITestFixture, PipelineLayout_DescriptorSetAllocation) {
|
||||
|
||||
layout->Shutdown();
|
||||
delete layout;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, PipelineLayout_D3D12ConstantBuffers_MapToDistinctRootParameters) {
|
||||
if (GetBackendType() != RHIType::D3D12) {
|
||||
GTEST_SKIP() << "D3D12-specific root parameter verification";
|
||||
}
|
||||
|
||||
RHIPipelineLayoutDesc desc = {};
|
||||
desc.constantBufferCount = 2;
|
||||
desc.textureCount = 1;
|
||||
desc.samplerCount = 1;
|
||||
|
||||
RHIPipelineLayout* layout = GetDevice()->CreatePipelineLayout(desc);
|
||||
ASSERT_NE(layout, nullptr);
|
||||
|
||||
auto* d3d12Layout = static_cast<D3D12PipelineLayout*>(layout);
|
||||
EXPECT_TRUE(d3d12Layout->HasRootParameter(0));
|
||||
EXPECT_TRUE(d3d12Layout->HasRootParameter(1));
|
||||
EXPECT_TRUE(d3d12Layout->HasRootParameter(100));
|
||||
EXPECT_TRUE(d3d12Layout->HasRootParameter(200));
|
||||
EXPECT_NE(d3d12Layout->GetRootParameterIndex(0), d3d12Layout->GetRootParameterIndex(1));
|
||||
|
||||
layout->Shutdown();
|
||||
delete layout;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user