fix(rhi): honor firstSet in set-aware d3d12 bindings

This commit is contained in:
2026-03-26 14:43:51 +08:00
parent 476a56724f
commit 9218ea20b5
6 changed files with 529 additions and 103 deletions

View File

@@ -44,6 +44,8 @@ struct MatrixBufferData {
constexpr float kSphereRadius = 1.0f;
constexpr int kSphereSegments = 32;
constexpr float kPi = 3.14159265358979323846f;
constexpr uint32_t kSphereDescriptorFirstSet = 1;
constexpr uint32_t kSphereDescriptorSetCount = 4;
std::filesystem::path GetExecutableDirectory() {
char exePath[MAX_PATH] = {};
@@ -452,10 +454,15 @@ void SphereTest::InitializeSphereResources() {
ASSERT_NE(mSamplerSet, nullptr);
mSamplerSet->UpdateSampler(0, mSampler);
DescriptorSetLayoutDesc setLayouts[kSphereDescriptorSetCount] = {};
// Reserve set0 so the integration test exercises non-zero firstSet binding.
setLayouts[1] = constantLayoutDesc;
setLayouts[2] = textureLayoutDesc;
setLayouts[3] = samplerLayoutDesc;
RHIPipelineLayoutDesc pipelineLayoutDesc = {};
pipelineLayoutDesc.constantBufferCount = 1;
pipelineLayoutDesc.textureCount = 1;
pipelineLayoutDesc.samplerCount = 1;
pipelineLayoutDesc.setLayouts = setLayouts;
pipelineLayoutDesc.setLayoutCount = kSphereDescriptorSetCount;
mPipelineLayout = GetDevice()->CreatePipelineLayout(pipelineLayoutDesc);
ASSERT_NE(mPipelineLayout, nullptr);
@@ -584,7 +591,7 @@ void SphereTest::RenderFrame() {
cmdList->SetPipelineState(mPipelineState);
RHIDescriptorSet* descriptorSets[] = { mConstantSet, mTextureSet, mSamplerSet };
cmdList->SetGraphicsDescriptorSets(0, 3, descriptorSets, mPipelineLayout);
cmdList->SetGraphicsDescriptorSets(kSphereDescriptorFirstSet, 3, descriptorSets, mPipelineLayout);
cmdList->SetPrimitiveTopology(PrimitiveTopology::TriangleList);
RHIResourceView* vertexBuffers[] = { mVertexBufferView };