Fix RHI format conversion and add debug logging for D3D12 tests
This commit is contained in:
@@ -273,6 +273,12 @@ RHIBuffer* D3D12Device::CreateBuffer(const BufferDesc& desc) {
|
||||
}
|
||||
|
||||
RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
|
||||
OutputDebugStringA("[CreateTexture] Start\n");
|
||||
{
|
||||
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
||||
if (f) { fprintf(f, "[CreateTexture] Start, m_device=%p\n", m_device.Get()); fclose(f); }
|
||||
}
|
||||
|
||||
auto* texture = new D3D12Texture();
|
||||
D3D12_RESOURCE_DESC d3d12Desc = {};
|
||||
|
||||
@@ -282,7 +288,7 @@ RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
|
||||
d3d12Desc.Height = desc.height;
|
||||
d3d12Desc.DepthOrArraySize = desc.depth > 0 ? desc.depth : 1;
|
||||
d3d12Desc.MipLevels = desc.mipLevels > 0 ? desc.mipLevels : 1;
|
||||
d3d12Desc.Format = static_cast<DXGI_FORMAT>(desc.format);
|
||||
d3d12Desc.Format = ToD3D12(static_cast<Format>(desc.format));
|
||||
d3d12Desc.SampleDesc.Count = desc.sampleCount > 0 ? desc.sampleCount : 1;
|
||||
d3d12Desc.SampleDesc.Quality = desc.sampleQuality;
|
||||
d3d12Desc.Flags = static_cast<D3D12_RESOURCE_FLAGS>(desc.flags);
|
||||
@@ -294,9 +300,19 @@ RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
|
||||
}
|
||||
|
||||
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 (texture->Initialize(m_device.Get(), d3d12Desc)) {
|
||||
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
||||
if (f) { fprintf(f, "[CreateTexture] Initialize succeeded\n"); fclose(f); }
|
||||
return texture;
|
||||
}
|
||||
{
|
||||
FILE* f = fopen("D:\\Xuanchi\\Main\\XCEngine\\debug_rhi.log", "a");
|
||||
if (f) { fprintf(f, "[CreateTexture] Initialize FAILED\n"); fclose(f); }
|
||||
}
|
||||
delete texture;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -489,7 +505,7 @@ RHIResourceView* D3D12Device::CreateRenderTargetView(RHITexture* texture, const
|
||||
}
|
||||
|
||||
D3D12_RENDER_TARGET_VIEW_DESC rtvDesc = {};
|
||||
rtvDesc.Format = static_cast<DXGI_FORMAT>(desc.format);
|
||||
rtvDesc.Format = ToD3D12(static_cast<Format>(desc.format));
|
||||
rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
{
|
||||
@@ -526,7 +542,7 @@ RHIResourceView* D3D12Device::CreateDepthStencilView(RHITexture* texture, const
|
||||
ID3D12Resource* resource = d3d12Texture->GetResource();
|
||||
|
||||
D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = {};
|
||||
dsvDesc.Format = static_cast<DXGI_FORMAT>(desc.format);
|
||||
dsvDesc.Format = ToD3D12(static_cast<Format>(desc.format));
|
||||
dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
|
||||
|
||||
auto heap = std::make_unique<D3D12DescriptorHeap>();
|
||||
@@ -549,7 +565,7 @@ RHIResourceView* D3D12Device::CreateShaderResourceView(RHITexture* texture, cons
|
||||
ID3D12Resource* resource = d3d12Texture->GetResource();
|
||||
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
srvDesc.Format = static_cast<DXGI_FORMAT>(desc.format);
|
||||
srvDesc.Format = ToD3D12(static_cast<Format>(desc.format));
|
||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = desc.mipLevel > 0 ? desc.mipLevel : 1;
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
|
||||
Reference in New Issue
Block a user