Fix RHI swap chain queue binding and restore minimal GT checks
This commit is contained in:
@@ -65,7 +65,7 @@ public:
|
|||||||
|
|
||||||
RHIBuffer* CreateBuffer(const BufferDesc& desc) override;
|
RHIBuffer* CreateBuffer(const BufferDesc& desc) override;
|
||||||
RHITexture* CreateTexture(const TextureDesc& desc) override;
|
RHITexture* CreateTexture(const TextureDesc& desc) override;
|
||||||
RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) override;
|
RHISwapChain* CreateSwapChain(const SwapChainDesc& desc, RHICommandQueue* presentQueue) override;
|
||||||
RHICommandList* CreateCommandList(const CommandListDesc& desc) override;
|
RHICommandList* CreateCommandList(const CommandListDesc& desc) override;
|
||||||
RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) override;
|
RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) override;
|
||||||
RHIShader* CreateShader(const ShaderCompileDesc& desc) override;
|
RHIShader* CreateShader(const ShaderCompileDesc& desc) override;
|
||||||
@@ -114,8 +114,6 @@ private:
|
|||||||
ComPtr<ID3D12Device> m_device;
|
ComPtr<ID3D12Device> m_device;
|
||||||
ComPtr<IDXGIFactory4> m_factory;
|
ComPtr<IDXGIFactory4> m_factory;
|
||||||
ComPtr<IDXGIAdapter1> m_adapter;
|
ComPtr<IDXGIAdapter1> m_adapter;
|
||||||
ComPtr<ID3D12CommandQueue> m_commandQueue;
|
|
||||||
|
|
||||||
AdapterInfo m_adapterInfo;
|
AdapterInfo m_adapterInfo;
|
||||||
RHICapabilities m_capabilities;
|
RHICapabilities m_capabilities;
|
||||||
RHIDeviceInfo m_deviceInfo;
|
RHIDeviceInfo m_deviceInfo;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
RHIBuffer* CreateBuffer(const BufferDesc& desc) override;
|
RHIBuffer* CreateBuffer(const BufferDesc& desc) override;
|
||||||
RHITexture* CreateTexture(const TextureDesc& desc) override;
|
RHITexture* CreateTexture(const TextureDesc& desc) override;
|
||||||
RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) override;
|
RHISwapChain* CreateSwapChain(const SwapChainDesc& desc, RHICommandQueue* presentQueue) override;
|
||||||
RHICommandList* CreateCommandList(const CommandListDesc& desc) override;
|
RHICommandList* CreateCommandList(const CommandListDesc& desc) override;
|
||||||
RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) override;
|
RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) override;
|
||||||
RHIShader* CreateShader(const ShaderCompileDesc& desc) override;
|
RHIShader* CreateShader(const ShaderCompileDesc& desc) override;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
virtual RHIBuffer* CreateBuffer(const BufferDesc& desc) = 0;
|
virtual RHIBuffer* CreateBuffer(const BufferDesc& desc) = 0;
|
||||||
virtual RHITexture* CreateTexture(const TextureDesc& desc) = 0;
|
virtual RHITexture* CreateTexture(const TextureDesc& desc) = 0;
|
||||||
virtual RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) = 0;
|
virtual RHISwapChain* CreateSwapChain(const SwapChainDesc& desc, RHICommandQueue* presentQueue) = 0;
|
||||||
virtual RHICommandList* CreateCommandList(const CommandListDesc& desc) = 0;
|
virtual RHICommandList* CreateCommandList(const CommandListDesc& desc) = 0;
|
||||||
virtual RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) = 0;
|
virtual RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) = 0;
|
||||||
virtual RHIShader* CreateShader(const ShaderCompileDesc& desc) = 0;
|
virtual RHIShader* CreateShader(const ShaderCompileDesc& desc) = 0;
|
||||||
|
|||||||
@@ -78,24 +78,12 @@ bool D3D12Device::Initialize(const RHIDeviceDesc& desc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
|
|
||||||
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
|
||||||
queueDesc.Priority = 0;
|
|
||||||
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
|
||||||
queueDesc.NodeMask = 0;
|
|
||||||
if (FAILED(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_commandQueue)))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryAdapterInfo();
|
QueryAdapterInfo();
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D3D12Device::Shutdown() {
|
void D3D12Device::Shutdown() {
|
||||||
if (m_commandQueue) {
|
|
||||||
m_commandQueue.Reset();
|
|
||||||
}
|
|
||||||
if (m_device) {
|
if (m_device) {
|
||||||
m_device.Reset();
|
m_device.Reset();
|
||||||
}
|
}
|
||||||
@@ -398,10 +386,19 @@ RHIFence* D3D12Device::CreateFence(const FenceDesc& desc) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RHISwapChain* D3D12Device::CreateSwapChain(const SwapChainDesc& desc) {
|
RHISwapChain* D3D12Device::CreateSwapChain(const SwapChainDesc& desc, RHICommandQueue* presentQueue) {
|
||||||
|
if (presentQueue == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* nativeQueue = static_cast<ID3D12CommandQueue*>(presentQueue->GetNativeHandle());
|
||||||
|
if (nativeQueue == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto* swapChain = new D3D12SwapChain();
|
auto* swapChain = new D3D12SwapChain();
|
||||||
HWND hwnd = static_cast<HWND>(desc.windowHandle);
|
HWND hwnd = static_cast<HWND>(desc.windowHandle);
|
||||||
if (swapChain->Initialize(m_factory.Get(), m_commandQueue.Get(), hwnd,
|
if (swapChain->Initialize(m_factory.Get(), nativeQueue, hwnd,
|
||||||
desc.width, desc.height, desc.bufferCount)) {
|
desc.width, desc.height, desc.bufferCount)) {
|
||||||
return swapChain;
|
return swapChain;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,13 +334,19 @@ RHITexture* OpenGLDevice::CreateTexture(const TextureDesc& desc) {
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
RHISwapChain* OpenGLDevice::CreateSwapChain(const SwapChainDesc& desc) {
|
RHISwapChain* OpenGLDevice::CreateSwapChain(const SwapChainDesc& desc, RHICommandQueue* presentQueue) {
|
||||||
|
if (presentQueue == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto* swapChain = new OpenGLSwapChain();
|
auto* swapChain = new OpenGLSwapChain();
|
||||||
HWND hwnd = static_cast<HWND>(desc.windowHandle);
|
HWND hwnd = static_cast<HWND>(desc.windowHandle);
|
||||||
if (hwnd) {
|
if (hwnd && swapChain->Initialize(this, hwnd, desc.width, desc.height)) {
|
||||||
swapChain->Initialize(this, hwnd, desc.width, desc.height);
|
return swapChain;
|
||||||
}
|
}
|
||||||
return swapChain;
|
|
||||||
|
delete swapChain;
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RHICommandList* OpenGLDevice::CreateCommandList(const CommandListDesc& desc) {
|
RHICommandList* OpenGLDevice::CreateCommandList(const CommandListDesc& desc) {
|
||||||
|
|||||||
@@ -21,6 +21,29 @@ namespace XCEngine {
|
|||||||
namespace RHI {
|
namespace RHI {
|
||||||
namespace Integration {
|
namespace Integration {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::filesystem::path GetExecutableDirectory() {
|
||||||
|
char exePath[MAX_PATH] = {};
|
||||||
|
DWORD length = GetModuleFileNameA(nullptr, exePath, MAX_PATH);
|
||||||
|
if (length == 0 || length >= MAX_PATH) {
|
||||||
|
return std::filesystem::current_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::filesystem::path(exePath).parent_path();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::path ResolveRuntimePath(const char* path) {
|
||||||
|
std::filesystem::path resolved(path);
|
||||||
|
if (resolved.is_absolute()) {
|
||||||
|
return resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetExecutableDirectory() / resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void Log(const char* format, ...) {
|
void Log(const char* format, ...) {
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -71,19 +94,19 @@ void RHIIntegrationFixture::SetUp() {
|
|||||||
}
|
}
|
||||||
ASSERT_TRUE(initResult);
|
ASSERT_TRUE(initResult);
|
||||||
|
|
||||||
|
CommandQueueDesc queueDesc = {};
|
||||||
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
||||||
|
mCommandQueue = mDevice->CreateCommandQueue(queueDesc);
|
||||||
|
ASSERT_NE(mCommandQueue, nullptr);
|
||||||
|
|
||||||
SwapChainDesc swapDesc = {};
|
SwapChainDesc swapDesc = {};
|
||||||
swapDesc.windowHandle = mWindow;
|
swapDesc.windowHandle = mWindow;
|
||||||
swapDesc.width = width;
|
swapDesc.width = width;
|
||||||
swapDesc.height = height;
|
swapDesc.height = height;
|
||||||
swapDesc.bufferCount = 2;
|
swapDesc.bufferCount = 2;
|
||||||
mSwapChain = mDevice->CreateSwapChain(swapDesc);
|
mSwapChain = mDevice->CreateSwapChain(swapDesc, mCommandQueue);
|
||||||
ASSERT_NE(mSwapChain, nullptr);
|
ASSERT_NE(mSwapChain, nullptr);
|
||||||
|
|
||||||
CommandQueueDesc queueDesc = {};
|
|
||||||
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
|
||||||
mCommandQueue = mDevice->CreateCommandQueue(queueDesc);
|
|
||||||
ASSERT_NE(mCommandQueue, nullptr);
|
|
||||||
|
|
||||||
CommandListDesc cmdDesc = {};
|
CommandListDesc cmdDesc = {};
|
||||||
cmdDesc.commandListType = static_cast<uint32_t>(CommandQueueType::Direct);
|
cmdDesc.commandListType = static_cast<uint32_t>(CommandQueueType::Direct);
|
||||||
mCommandList = mDevice->CreateCommandList(cmdDesc);
|
mCommandList = mDevice->CreateCommandList(cmdDesc);
|
||||||
@@ -112,11 +135,12 @@ void RHIIntegrationFixture::SetUp() {
|
|||||||
mRTVs.push_back(rtv);
|
mRTVs.push_back(rtv);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12Texture depthStencil;
|
mDepthStencilTexture = new D3D12Texture();
|
||||||
depthStencil.InitializeDepthStencil(device, width, height);
|
ASSERT_NE(mDepthStencilTexture, nullptr);
|
||||||
|
ASSERT_TRUE(mDepthStencilTexture->InitializeDepthStencil(device, width, height));
|
||||||
D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = D3D12ResourceView::CreateDepthStencilDesc(Format::D24_UNorm_S8_UInt, D3D12_DSV_DIMENSION_TEXTURE2D);
|
D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = D3D12ResourceView::CreateDepthStencilDesc(Format::D24_UNorm_S8_UInt, D3D12_DSV_DIMENSION_TEXTURE2D);
|
||||||
auto* d3d12DSV = new D3D12ResourceView();
|
auto* d3d12DSV = new D3D12ResourceView();
|
||||||
d3d12DSV->InitializeAsDepthStencil(device, depthStencil.GetResource(), &dsvDesc, mDSVHeap, 0);
|
d3d12DSV->InitializeAsDepthStencil(device, mDepthStencilTexture->GetResource(), &dsvDesc, mDSVHeap, 0);
|
||||||
mDSV = d3d12DSV;
|
mDSV = d3d12DSV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +202,12 @@ void RHIIntegrationFixture::TearDown() {
|
|||||||
mDSV = nullptr;
|
mDSV = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mDepthStencilTexture) {
|
||||||
|
mDepthStencilTexture->Shutdown();
|
||||||
|
delete mDepthStencilTexture;
|
||||||
|
mDepthStencilTexture = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (mRTVHeap) {
|
if (mRTVHeap) {
|
||||||
mRTVHeap->Shutdown();
|
mRTVHeap->Shutdown();
|
||||||
delete mRTVHeap;
|
delete mRTVHeap;
|
||||||
@@ -255,8 +285,11 @@ bool RHIIntegrationFixture::TakeScreenshot(const char* filename) {
|
|||||||
(void*)mScreenshot, (void*)mDevice, (void*)mSwapChain);
|
(void*)mScreenshot, (void*)mDevice, (void*)mSwapChain);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log("[TEST] TakeScreenshot: capturing to %s", filename);
|
|
||||||
bool result = mScreenshot->Capture(mDevice, mSwapChain, filename);
|
const std::filesystem::path outputPath = ResolveRuntimePath(filename);
|
||||||
|
const std::string outputPathString = outputPath.string();
|
||||||
|
Log("[TEST] TakeScreenshot: capturing to %s", outputPathString.c_str());
|
||||||
|
bool result = mScreenshot->Capture(mDevice, mSwapChain, outputPathString.c_str());
|
||||||
Log("[TEST] TakeScreenshot: result=%d", result);
|
Log("[TEST] TakeScreenshot: result=%d", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -264,9 +297,10 @@ bool RHIIntegrationFixture::TakeScreenshot(const char* filename) {
|
|||||||
bool RHIIntegrationFixture::CompareWithGoldenTemplate(const char* outputPpm, const char* gtPpm, float threshold) {
|
bool RHIIntegrationFixture::CompareWithGoldenTemplate(const char* outputPpm, const char* gtPpm, float threshold) {
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
fs::path exeDir = fs::current_path();
|
fs::path exeDir = GetExecutableDirectory();
|
||||||
fs::path outputPath = exeDir / outputPpm;
|
fs::path outputPath = ResolveRuntimePath(outputPpm);
|
||||||
fs::path gtPath = exeDir / gtPpm;
|
fs::path gtPath = ResolveRuntimePath(gtPpm);
|
||||||
|
fs::path compareScriptPath = exeDir / "compare_ppm.py";
|
||||||
|
|
||||||
if (!fs::exists(outputPath)) {
|
if (!fs::exists(outputPath)) {
|
||||||
std::cerr << "Output file not found: " << outputPath << std::endl;
|
std::cerr << "Output file not found: " << outputPath << std::endl;
|
||||||
@@ -278,7 +312,12 @@ bool RHIIntegrationFixture::CompareWithGoldenTemplate(const char* outputPpm, con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmd = "python compare_ppm.py \"" + outputPath.string() + "\" \"" + gtPath.string() + "\" " + std::to_string(static_cast<int>(threshold));
|
if (!fs::exists(compareScriptPath)) {
|
||||||
|
std::cerr << "Compare script not found: " << compareScriptPath << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmd = "python \"" + compareScriptPath.string() + "\" \"" + outputPath.string() + "\" \"" + gtPath.string() + "\" " + std::to_string(static_cast<int>(threshold));
|
||||||
int result = system(cmd.c_str());
|
int result = system(cmd.c_str());
|
||||||
return result == 0;
|
return result == 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ private:
|
|||||||
#if defined(XCENGINE_SUPPORT_D3D12)
|
#if defined(XCENGINE_SUPPORT_D3D12)
|
||||||
D3D12DescriptorHeap* mRTVHeap = nullptr;
|
D3D12DescriptorHeap* mRTVHeap = nullptr;
|
||||||
D3D12DescriptorHeap* mDSVHeap = nullptr;
|
D3D12DescriptorHeap* mDSVHeap = nullptr;
|
||||||
|
D3D12Texture* mDepthStencilTexture = nullptr;
|
||||||
std::vector<RHIResourceView*> mRTVs;
|
std::vector<RHIResourceView*> mRTVs;
|
||||||
RHIResourceView* mDSV = nullptr;
|
RHIResourceView* mDSV = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -46,10 +46,7 @@ add_custom_command(TARGET rhi_integration_minimal POST_BUILD
|
|||||||
$<TARGET_FILE_DIR:rhi_integration_minimal>/
|
$<TARGET_FILE_DIR:rhi_integration_minimal>/
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
${CMAKE_SOURCE_DIR}/tests/RHI/D3D12/integration/minimal/GT.ppm
|
${CMAKE_SOURCE_DIR}/tests/RHI/D3D12/integration/minimal/GT.ppm
|
||||||
$<TARGET_FILE_DIR:rhi_integration_minimal>/GT_D3D12.ppm
|
$<TARGET_FILE_DIR:rhi_integration_minimal>/GT.ppm
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
||||||
${CMAKE_SOURCE_DIR}/tests/RHI/OpenGL/integration/minimal/GT.ppm
|
|
||||||
$<TARGET_FILE_DIR:rhi_integration_minimal>/GT_OpenGL.ppm
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
${ENGINE_ROOT_DIR}/third_party/renderdoc/renderdoc.dll
|
${ENGINE_ROOT_DIR}/third_party/renderdoc/renderdoc.dll
|
||||||
$<TARGET_FILE_DIR:rhi_integration_minimal>/
|
$<TARGET_FILE_DIR:rhi_integration_minimal>/
|
||||||
|
|||||||
@@ -19,6 +19,14 @@ protected:
|
|||||||
void RenderFrame() override;
|
void RenderFrame() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* GetScreenshotFilename(RHIType type) {
|
||||||
|
return type == RHIType::D3D12 ? "minimal_d3d12.ppm" : "minimal_opengl.ppm";
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetComparisonThreshold(RHIType type) {
|
||||||
|
return type == RHIType::OpenGL ? 5 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void MinimalTest::RenderFrame() {
|
void MinimalTest::RenderFrame() {
|
||||||
RHICommandList* cmdList = GetCommandList();
|
RHICommandList* cmdList = GetCommandList();
|
||||||
RHICommandQueue* cmdQueue = GetCommandQueue();
|
RHICommandQueue* cmdQueue = GetCommandQueue();
|
||||||
@@ -55,6 +63,8 @@ TEST_P(MinimalTest, RenderClear) {
|
|||||||
RHICommandQueue* cmdQueue = GetCommandQueue();
|
RHICommandQueue* cmdQueue = GetCommandQueue();
|
||||||
RHISwapChain* swapChain = GetSwapChain();
|
RHISwapChain* swapChain = GetSwapChain();
|
||||||
const int targetFrameCount = 30;
|
const int targetFrameCount = 30;
|
||||||
|
const char* screenshotFilename = GetScreenshotFilename(GetBackendType());
|
||||||
|
const int comparisonThreshold = GetComparisonThreshold(GetBackendType());
|
||||||
|
|
||||||
for (int frameCount = 0; frameCount <= targetFrameCount; ++frameCount) {
|
for (int frameCount = 0; frameCount <= targetFrameCount; ++frameCount) {
|
||||||
if (frameCount > 0) {
|
if (frameCount > 0) {
|
||||||
@@ -67,8 +77,10 @@ TEST_P(MinimalTest, RenderClear) {
|
|||||||
|
|
||||||
if (frameCount >= targetFrameCount) {
|
if (frameCount >= targetFrameCount) {
|
||||||
cmdQueue->WaitForIdle();
|
cmdQueue->WaitForIdle();
|
||||||
Log("[TEST] MainLoop: frame %d reached, test complete", frameCount);
|
Log("[TEST] MainLoop: frame %d reached, capturing %s", frameCount, screenshotFilename);
|
||||||
// Screenshot temporarily disabled due to device state issue
|
ASSERT_TRUE(TakeScreenshot(screenshotFilename));
|
||||||
|
ASSERT_TRUE(CompareWithGoldenTemplate(screenshotFilename, "GT.ppm", static_cast<float>(comparisonThreshold)));
|
||||||
|
Log("[TEST] MainLoop: frame %d compare passed", frameCount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,25 +41,27 @@ void RHITestFixture::SetUp() {
|
|||||||
desc.enableDebugLayer = false;
|
desc.enableDebugLayer = false;
|
||||||
initResult = mDevice->Initialize(desc);
|
initResult = mDevice->Initialize(desc);
|
||||||
ASSERT_TRUE(initResult);
|
ASSERT_TRUE(initResult);
|
||||||
|
} else if (GetParam() == RHIType::OpenGL) {
|
||||||
|
auto* oglDevice = static_cast<OpenGLDevice*>(mDevice);
|
||||||
|
initResult = oglDevice->InitializeWithExistingWindow(mWindow);
|
||||||
|
ASSERT_TRUE(initResult);
|
||||||
|
}
|
||||||
|
|
||||||
CommandQueueDesc queueDesc = {};
|
CommandQueueDesc queueDesc = {};
|
||||||
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
queueDesc.queueType = static_cast<uint32_t>(CommandQueueType::Direct);
|
||||||
queueDesc.priority = 0;
|
queueDesc.priority = 0;
|
||||||
queueDesc.nodeMask = 0;
|
queueDesc.nodeMask = 0;
|
||||||
queueDesc.flags = 0;
|
queueDesc.flags = 0;
|
||||||
mCommandQueue = mDevice->CreateCommandQueue(queueDesc);
|
mCommandQueue = mDevice->CreateCommandQueue(queueDesc);
|
||||||
ASSERT_NE(mCommandQueue, nullptr);
|
ASSERT_NE(mCommandQueue, nullptr);
|
||||||
|
|
||||||
|
if (GetParam() == RHIType::D3D12) {
|
||||||
FenceDesc fenceDesc = {};
|
FenceDesc fenceDesc = {};
|
||||||
fenceDesc.initialValue = 0;
|
fenceDesc.initialValue = 0;
|
||||||
fenceDesc.flags = 0;
|
fenceDesc.flags = 0;
|
||||||
mFence = mDevice->CreateFence(fenceDesc);
|
mFence = mDevice->CreateFence(fenceDesc);
|
||||||
ASSERT_NE(mFence, nullptr);
|
ASSERT_NE(mFence, nullptr);
|
||||||
mFenceValue = 0;
|
mFenceValue = 0;
|
||||||
} else if (GetParam() == RHIType::OpenGL) {
|
|
||||||
auto* oglDevice = static_cast<OpenGLDevice*>(mDevice);
|
|
||||||
initResult = oglDevice->InitializeWithExistingWindow(mWindow);
|
|
||||||
ASSERT_TRUE(initResult);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ protected:
|
|||||||
void WaitForGPU();
|
void WaitForGPU();
|
||||||
|
|
||||||
RHIDevice* GetDevice() { return mDevice; }
|
RHIDevice* GetDevice() { return mDevice; }
|
||||||
|
RHICommandQueue* GetCommandQueue() { return mCommandQueue; }
|
||||||
RHIType GetBackendType() const { return GetParam(); }
|
RHIType GetBackendType() const { return GetParam(); }
|
||||||
HWND GetWindowHandle() const { return mWindow; }
|
HWND GetWindowHandle() const { return mWindow; }
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ TEST_P(RHITestFixture, Screenshot_Capture_Basic) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
if (swapChain == nullptr) {
|
if (swapChain == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ TEST_P(RHITestFixture, Screenshot_Capture_WithPresent) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
if (swapChain == nullptr) {
|
if (swapChain == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ TEST_P(RHITestFixture, SwapChain_Create) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
swapChain->Shutdown();
|
swapChain->Shutdown();
|
||||||
@@ -26,7 +26,7 @@ TEST_P(RHITestFixture, SwapChain_GetCurrentBackBufferIndex) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
uint32_t index = swapChain->GetCurrentBackBufferIndex();
|
uint32_t index = swapChain->GetCurrentBackBufferIndex();
|
||||||
@@ -44,7 +44,7 @@ TEST_P(RHITestFixture, SwapChain_GetCurrentBackBuffer) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
RHITexture* backBuffer = swapChain->GetCurrentBackBuffer();
|
RHITexture* backBuffer = swapChain->GetCurrentBackBuffer();
|
||||||
@@ -62,7 +62,7 @@ TEST_P(RHITestFixture, SwapChain_Resize) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
swapChain->Resize(1024, 768);
|
swapChain->Resize(1024, 768);
|
||||||
@@ -79,7 +79,7 @@ TEST_P(RHITestFixture, SwapChain_Present_Basic) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
swapChain->Present(0, 0);
|
swapChain->Present(0, 0);
|
||||||
@@ -96,7 +96,7 @@ TEST_P(RHITestFixture, SwapChain_Present_WithSyncInterval) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
swapChain->Present(1, 0);
|
swapChain->Present(1, 0);
|
||||||
@@ -114,7 +114,7 @@ TEST_P(RHITestFixture, SwapChain_Present_Multiple) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
@@ -133,7 +133,7 @@ TEST_P(RHITestFixture, SwapChain_GetNativeHandle) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
void* handle = swapChain->GetNativeHandle();
|
void* handle = swapChain->GetNativeHandle();
|
||||||
@@ -151,7 +151,7 @@ TEST_P(RHITestFixture, SwapChain_Resize_WithPresent) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
swapChain->Present(0, 0);
|
swapChain->Present(0, 0);
|
||||||
@@ -170,7 +170,7 @@ TEST_P(RHITestFixture, SwapChain_TripleBuffering) {
|
|||||||
desc.bufferCount = 3;
|
desc.bufferCount = 3;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
uint32_t index0 = swapChain->GetCurrentBackBufferIndex();
|
uint32_t index0 = swapChain->GetCurrentBackBufferIndex();
|
||||||
@@ -193,7 +193,7 @@ TEST_P(RHITestFixture, SwapChain_DoubleShutdown) {
|
|||||||
desc.bufferCount = 2;
|
desc.bufferCount = 2;
|
||||||
desc.format = Format::R8G8B8A8_UNorm;
|
desc.format = Format::R8G8B8A8_UNorm;
|
||||||
|
|
||||||
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc);
|
RHISwapChain* swapChain = GetDevice()->CreateSwapChain(desc, GetCommandQueue());
|
||||||
ASSERT_NE(swapChain, nullptr);
|
ASSERT_NE(swapChain, nullptr);
|
||||||
|
|
||||||
swapChain->Shutdown();
|
swapChain->Shutdown();
|
||||||
|
|||||||
Reference in New Issue
Block a user