fix: D3D12 CreateTexture defaults and CommandList RTV support

- Add default value handling for sampleCount, mipLevels, depth in CreateTexture
- Add RTV descriptor heap to D3D12CommandList for future ClearRenderTarget implementation
- ClearRenderTarget remains stub (requires full D3D12 render pipeline state)
This commit is contained in:
2026-03-23 21:46:14 +08:00
parent 003d6ed630
commit 89d13a4ae4
2 changed files with 15 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ bool D3D12CommandList::Initialize(ID3D12Device* device, CommandQueueType type, I
D3D12_COMMAND_LIST_TYPE listType = ToD3D12(type);
m_commandAllocator = allocator;
m_device = device;
HRESULT hResult = device->CreateCommandList(
0,
@@ -34,11 +35,22 @@ bool D3D12CommandList::Initialize(ID3D12Device* device, CommandQueueType type, I
m_type = type;
D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {};
heapDesc.NumDescriptors = 16;
heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
heapDesc.NodeMask = 0;
hResult = device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&m_rtvHeap));
if (FAILED(hResult)) {
return false;
}
return true;
}
void D3D12CommandList::Shutdown() {
m_commandList.Reset();
m_rtvHeap.Reset();
m_resourceStateMap.clear();
m_trackedResources.clear();
}
@@ -312,8 +324,6 @@ void D3D12CommandList::DrawIndexedInstancedIndirectInternal(ID3D12Resource* argB
}
void D3D12CommandList::ClearRenderTargetView(ID3D12Resource* renderTarget, const float color[4], uint32_t rectCount, const D3D12_RECT* rects) {
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = {};
m_commandList->ClearRenderTargetView(rtvHandle, color, rectCount, rects);
}
void D3D12CommandList::ClearRenderTargetView(D3D12_CPU_DESCRIPTOR_HANDLE renderTargetHandle, const float color[4], uint32_t rectCount, const D3D12_RECT* rects) {

View File

@@ -279,10 +279,10 @@ RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
d3d12Desc.Width = desc.width;
d3d12Desc.Height = desc.height;
d3d12Desc.DepthOrArraySize = desc.depth;
d3d12Desc.MipLevels = desc.mipLevels;
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.SampleDesc.Count = desc.sampleCount;
d3d12Desc.SampleDesc.Count = desc.sampleCount > 0 ? desc.sampleCount : 1;
d3d12Desc.SampleDesc.Quality = desc.sampleQuality;
d3d12Desc.Flags = static_cast<D3D12_RESOURCE_FLAGS>(desc.flags);
d3d12Desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;