Add Vulkan sphere integration support
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
#include "XCEngine/RHI/RHICommandList.h"
|
||||
#include "XCEngine/RHI/RHISwapChain.h"
|
||||
#include "XCEngine/RHI/RHIScreenshot.h"
|
||||
#include "XCEngine/RHI/RHIResourceView.h"
|
||||
#include "XCEngine/RHI/RHIEnums.h"
|
||||
#include "XCEngine/RHI/RHITexture.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLDevice.h"
|
||||
#include "XCEngine/Debug/Logger.h"
|
||||
#include "XCEngine/Debug/ConsoleLogSink.h"
|
||||
@@ -68,12 +70,12 @@ private:
|
||||
HWND mWindow = nullptr;
|
||||
int mCurrentBackBufferIndex = 0;
|
||||
std::vector<RHIResourceView*> mBackBufferViews;
|
||||
RHITexture* mDepthStencilTexture = nullptr;
|
||||
RHIResourceView* mDepthStencilView = nullptr;
|
||||
|
||||
#if defined(XCENGINE_SUPPORT_D3D12)
|
||||
D3D12DescriptorHeap* mRTVHeap = nullptr;
|
||||
D3D12DescriptorHeap* mDSVHeap = nullptr;
|
||||
D3D12Texture* mDepthStencilTexture = nullptr;
|
||||
RHIResourceView* mDSV = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user