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

@@ -38,26 +38,22 @@ void OpenGLFence::Signal() {
void OpenGLFence::Signal(uint64_t value) {
glFlush();
m_fenceValue = value;
m_completedValue = value;
m_signaled = true;
if (m_sync) {
glDeleteSync(static_cast<GLsync>(m_sync));
}
m_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
void OpenGLFence::Wait(uint64_t timeoutNs) {
if (!m_signaled || !m_sync) {
glFinish();
m_completedValue = m_fenceValue;
m_signaled = true;
return;
}
GLsync sync = static_cast<GLsync>(m_sync);
GLenum result = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, timeoutNs);
while (result == GL_TIMEOUT_EXPIRED && timeoutNs > 0) {
result = glClientWaitSync(sync, 0, timeoutNs);
}
if (result == GL_ALREADY_SIGNALED || result == GL_CONDITION_SATISFIED) {
m_completedValue = m_fenceValue;
if (m_signaled && m_sync) {
GLsync sync = static_cast<GLsync>(m_sync);
glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
}
glFinish();
m_completedValue = m_fenceValue;
m_signaled = true;
}
void OpenGLFence::Reset() {
@@ -91,5 +87,12 @@ uint64_t OpenGLFence::GetCompletedValue() const {
return m_completedValue;
}
void* OpenGLFence::GetNativeHandle() {
if (!m_sync) {
m_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
return m_sync;
}
} // namespace RHI
} // namespace XCEngine