Add Vulkan sphere integration support

This commit is contained in:
2026-03-27 15:07:21 +08:00
parent 18fd09b36f
commit 22ccdfb371
16 changed files with 429 additions and 63 deletions

View File

@@ -139,13 +139,35 @@ void RHIIntegrationFixture::SetUp() {
mBackBufferViews.push_back(rtv);
}
mDepthStencilTexture = new D3D12Texture();
ASSERT_NE(mDepthStencilTexture, nullptr);
ASSERT_TRUE(mDepthStencilTexture->InitializeDepthStencil(device, width, height));
auto* depthStencilTexture = new D3D12Texture();
ASSERT_NE(depthStencilTexture, nullptr);
ASSERT_TRUE(depthStencilTexture->InitializeDepthStencil(device, width, height));
mDepthStencilTexture = depthStencilTexture;
D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = D3D12ResourceView::CreateDepthStencilDesc(Format::D24_UNorm_S8_UInt, D3D12_DSV_DIMENSION_TEXTURE2D);
auto* d3d12DSV = new D3D12ResourceView();
d3d12DSV->InitializeAsDepthStencil(device, mDepthStencilTexture->GetResource(), &dsvDesc, mDSVHeap, 0);
mDSV = d3d12DSV;
d3d12DSV->InitializeAsDepthStencil(device, depthStencilTexture->GetResource(), &dsvDesc, mDSVHeap, 0);
mDepthStencilView = d3d12DSV;
} else if (GetParam() == RHIType::Vulkan) {
TextureDesc depthDesc = {};
depthDesc.width = static_cast<uint32_t>(width);
depthDesc.height = static_cast<uint32_t>(height);
depthDesc.depth = 1;
depthDesc.mipLevels = 1;
depthDesc.arraySize = 1;
depthDesc.format = static_cast<uint32_t>(Format::D24_UNorm_S8_UInt);
depthDesc.textureType = static_cast<uint32_t>(TextureType::Texture2D);
depthDesc.sampleCount = 1;
depthDesc.sampleQuality = 0;
depthDesc.flags = 0;
mDepthStencilTexture = mDevice->CreateTexture(depthDesc);
ASSERT_NE(mDepthStencilTexture, nullptr);
ResourceViewDesc depthViewDesc = {};
depthViewDesc.dimension = ResourceViewDimension::Texture2D;
depthViewDesc.format = static_cast<uint32_t>(Format::D24_UNorm_S8_UInt);
mDepthStencilView = mDevice->CreateDepthStencilView(mDepthStencilTexture, depthViewDesc);
ASSERT_NE(mDepthStencilView, nullptr);
}
mScreenshot = RHIScreenshot::Create(GetParam());
@@ -179,7 +201,7 @@ void RHIIntegrationFixture::SetRenderTargetForClear(bool includeDepthStencil) {
d3d12CmdList->TransitionBarrier(backBuffer->GetResource(), ResourceStates::Present, ResourceStates::RenderTarget);
RHIResourceView* rtv = mBackBufferViews[mCurrentBackBufferIndex];
Log("[TEST] SetRenderTargetForClear: calling SetRenderTargets, rtv=%p", (void*)rtv);
mCommandList->SetRenderTargets(1, &rtv, includeDepthStencil ? mDSV : nullptr);
mCommandList->SetRenderTargets(1, &rtv, includeDepthStencil ? mDepthStencilView : nullptr);
Log("[TEST] SetRenderTargetForClear: done");
} else {
Log("[TEST] SetRenderTargetForClear: skipped - condition failed");
@@ -204,7 +226,7 @@ void RHIIntegrationFixture::SetRenderTargetForClear(bool includeDepthStencil) {
ASSERT_NE(mBackBufferViews[backBufferIndex], nullptr);
RHIResourceView* rtv = mBackBufferViews[backBufferIndex];
mCommandList->SetRenderTargets(1, &rtv, nullptr);
mCommandList->SetRenderTargets(1, &rtv, includeDepthStencil ? mDepthStencilView : nullptr);
}
}
@@ -232,19 +254,19 @@ void RHIIntegrationFixture::TearDown() {
}
mBackBufferViews.clear();
if (mDepthStencilView) {
mDepthStencilView->Shutdown();
delete mDepthStencilView;
mDepthStencilView = nullptr;
}
if (mDepthStencilTexture) {
mDepthStencilTexture->Shutdown();
delete mDepthStencilTexture;
mDepthStencilTexture = nullptr;
}
if (GetParam() == RHIType::D3D12) {
if (mDSV) {
mDSV->Shutdown();
delete mDSV;
mDSV = nullptr;
}
if (mDepthStencilTexture) {
mDepthStencilTexture->Shutdown();
delete mDepthStencilTexture;
mDepthStencilTexture = nullptr;
}
if (mRTVHeap) {
mRTVHeap->Shutdown();
delete mRTVHeap;