Fix RHI unit test failures and OpenGL backend issues

- Fix D3D12Texture::GetTextureType() to return correct type based on D3D12 resource dimension
- Fix OpenGL CommandQueue::Signal() to properly call fence->Signal()
- Fix OpenGL CommandQueue::GetTimestampFrequency() using GL_TIMESTAMP
- Fix OpenGL Device::GetNativeDevice() to return m_hglrc
- Fix OpenGL Fence::Signal() to create GL sync object and update completedValue
- Fix OpenGL Fence::Wait() to properly wait for fence
- Fix OpenGL Fence::GetNativeHandle() to create sync on first call
- Fix OpenGL SwapChain::GetCurrentBackBuffer() to return backbuffer texture
- Fix OpenGL SwapChain::Initialize() to create backbuffer texture
- Fix OpenGL SwapChain::Shutdown() to cleanup backbuffer texture
- Fix RHI unit tests: add missing sampleCount/sampleQuality/depth/arraySize fields
- Fix RHI unit tests: add complete TextureDesc fields where needed
This commit is contained in:
2026-03-23 21:09:15 +08:00
parent bc6b47ffcf
commit 0fa4f2e3a8
10 changed files with 86 additions and 21 deletions

View File

@@ -44,7 +44,14 @@ public:
uint32_t GetArraySize() const { return GetDesc().DepthOrArraySize; }
Format GetFormat() const override { return static_cast<Format>(GetDesc().Format); }
TextureType GetTextureType() const override { return TextureType::Texture2D; }
TextureType GetTextureType() const override {
switch (GetDesc().Dimension) {
case D3D12_RESOURCE_DIMENSION_TEXTURE1D: return TextureType::Texture1D;
case D3D12_RESOURCE_DIMENSION_TEXTURE2D: return TextureType::Texture2D;
case D3D12_RESOURCE_DIMENSION_TEXTURE3D: return TextureType::Texture3D;
default: return TextureType::Texture2D;
}
}
bool OwnsResource() const { return m_ownsResource; }

View File

@@ -19,7 +19,7 @@ public:
void WaitForIdle() override;
CommandQueueType GetType() const override { return CommandQueueType::Direct; }
uint64_t GetTimestampFrequency() const override { return 0; }
uint64_t GetTimestampFrequency() const override;
void* GetNativeHandle() override { return nullptr; }
void WaitForPreviousFrame() override {}

View File

@@ -31,7 +31,7 @@ public:
uint64_t GetCompletedValue() const override;
uint64_t GetCurrentValue() const { return m_fenceValue; }
void* GetNativeHandle() override { return m_sync; }
void* GetNativeHandle() override;
private:
void* m_sync;

View File

@@ -3,6 +3,7 @@
#include <cstdint>
#include "../RHISwapChain.h"
#include "OpenGLTexture.h"
struct HWND__;
struct HDC__;
@@ -72,6 +73,7 @@ private:
bool m_shouldClose;
bool m_fullscreen;
PresentMode m_presentMode;
OpenGLTexture* m_backBufferTexture;
};
} // namespace RHI