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:
@@ -297,12 +297,14 @@ RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
|
||||
if (format == Format::D24_UNorm_S8_UInt || format == Format::D32_Float ||
|
||||
format == Format::D16_UNorm) {
|
||||
d3d12Desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
|
||||
} else if (d3d12Desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && desc.width > 0 && desc.height > 0) {
|
||||
d3d12Desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
|
||||
}
|
||||
|
||||
d3d12Desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
||||
{
|
||||
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
||||
if (f) { fprintf(f, "[CreateTexture] Calling Initialize, device=%p, format=%d\n", m_device.Get(), (int)d3d12Desc.Format); fclose(f); }
|
||||
if (f) { fprintf(f, "[CreateTexture] Calling Initialize, device=%p, format=%d, flags=0x%X\n", m_device.Get(), (int)d3d12Desc.Format, d3d12Desc.Flags); fclose(f); }
|
||||
}
|
||||
if (texture->Initialize(m_device.Get(), d3d12Desc)) {
|
||||
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
||||
|
||||
Reference in New Issue
Block a user