Fix RHI format conversion and test viewDesc initialization

- Fix CreateTexture to use ToD3D12() for format conversion
- Fix CreateRenderTargetView to use ToD3D12() for format conversion
- Fix CreateDepthStencilView to use ToD3D12() for format conversion
- Fix CreateShaderResourceView to use ToD3D12() for format conversion
- Update test to pass correct format in ResourceViewDesc

These fixes resolve CommandList_ClearDepthStencil_WithRealView test.
Other RTV-related tests still fail with DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
from CreateCommandAllocator - further investigation needed.
This commit is contained in:
2026-03-25 17:43:59 +08:00
parent 295459067f
commit 6612330347
2 changed files with 7 additions and 1 deletions

View File

@@ -537,6 +537,10 @@ RHIResourceView* D3D12Device::CreateRenderTargetView(RHITexture* texture, const
} }
RHIResourceView* D3D12Device::CreateDepthStencilView(RHITexture* texture, const ResourceViewDesc& desc) { RHIResourceView* D3D12Device::CreateDepthStencilView(RHITexture* texture, const ResourceViewDesc& desc) {
{
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
if (f) { fprintf(f, "[CreateDepthStencilView] Start, desc.format=%d\n", desc.format); fclose(f); }
}
auto* view = new D3D12ResourceView(); auto* view = new D3D12ResourceView();
auto* d3d12Texture = static_cast<D3D12Texture*>(texture); auto* d3d12Texture = static_cast<D3D12Texture*>(texture);
ID3D12Resource* resource = d3d12Texture->GetResource(); ID3D12Resource* resource = d3d12Texture->GetResource();

View File

@@ -187,7 +187,9 @@ TEST_P(RHITestFixture, CommandList_ClearRenderTarget_WithRealView) {
RHITexture* texture = GetDevice()->CreateTexture(texDesc); RHITexture* texture = GetDevice()->CreateTexture(texDesc);
ASSERT_NE(texture, nullptr); ASSERT_NE(texture, nullptr);
RHIResourceView* rtv = GetDevice()->CreateRenderTargetView(texture, {}); ResourceViewDesc viewDesc = {};
viewDesc.format = texDesc.format;
RHIResourceView* rtv = GetDevice()->CreateRenderTargetView(texture, viewDesc);
ASSERT_NE(rtv, nullptr); ASSERT_NE(rtv, nullptr);
float color[4] = { 1.0f, 0.0f, 0.0f, 1.0f }; float color[4] = { 1.0f, 0.0f, 0.0f, 1.0f };