Fix RHI D3D12 RTV creation and GetFormat bug

1. Add ALLOW_RENDER_TARGET flag for color textures in CreateTexture
   - This was the root cause of 5 failing RTV-related tests
   - Without this flag, creating RTV caused device removal

2. Add FromD3D12() reverse conversion for Format enum
   - GetFormat() was incorrectly casting DXGI_FORMAT to Format
   - DXGI_FORMAT_R8G8B8A8_UNORM=28 but Format::R8G8B8A8_UNorm=3
   - Added FromD3D12() to properly convert back

3. Update RHITestFixture to pre-create CommandQueue and Fence
   - Prevents potential timing issues with GPU synchronization

4. Update RHITestFixture tests to pass correct format in ResourceViewDesc
   - Previously passed empty desc.format=0 which caused issues

All 234 RHI unit tests now pass (117 D3D12 + 117 OpenGL)
This commit is contained in:
2026-03-25 18:12:50 +08:00
parent b0d0576763
commit b11f59e144
5 changed files with 72 additions and 41 deletions

View File

@@ -37,6 +37,9 @@ protected:
private:
RHIDevice* mDevice = nullptr;
HWND mWindow = nullptr;
RHICommandQueue* mCommandQueue = nullptr;
RHIFence* mFence = nullptr;
uint64_t mFenceValue = 0;
};
} // namespace RHI