Implement IShader and ISwapChain interfaces for D3D12 backend

- D3D12Shader now implements IShader interface with GetBytecode, GetBytecodeSize, GetType, GetInputLayout
- D3D12SwapChain now implements ISwapChain interface with GetBackBuffer returning IResource*
- Added D3D12Texture back buffer storage to SwapChain
- Fixed ISwapChain const correctness (GetCurrentBackBufferIndex, GetBackBuffer)
- main.cpp: use GetD3D12Bytecode() instead of GetBytecode() for PSO creation
This commit is contained in:
2026-03-16 12:38:17 +08:00
parent f4d94bda3d
commit 554c48448b
10 changed files with 84 additions and 46 deletions

View File

@@ -38,18 +38,6 @@ void D3D12DescriptorHeap::Shutdown() {
m_descriptorHeap.Reset();
}
D3D12_CPU_DESCRIPTOR_HANDLE D3D12DescriptorHeap::GetCPUDescriptorHandle(uint32_t index) const {
D3D12_CPU_DESCRIPTOR_HANDLE handle = m_descriptorHeap->GetCPUDescriptorHandleForHeapStart();
handle.ptr += index * m_descriptorSize;
return handle;
}
D3D12_GPU_DESCRIPTOR_HANDLE D3D12DescriptorHeap::GetGPUDescriptorHandle(uint32_t index) const {
D3D12_GPU_DESCRIPTOR_HANDLE handle = m_descriptorHeap->GetGPUDescriptorHandleForHeapStart();
handle.ptr += index * m_descriptorSize;
return handle;
}
D3D12_CPU_DESCRIPTOR_HANDLE D3D12DescriptorHeap::GetCPUDescriptorHandleForHeapStart() const {
return m_descriptorHeap->GetCPUDescriptorHandleForHeapStart();
}
@@ -59,15 +47,19 @@ D3D12_GPU_DESCRIPTOR_HANDLE D3D12DescriptorHeap::GetGPUDescriptorHandleForHeapSt
}
CPUDescriptorHandle D3D12DescriptorHeap::GetCPUDescriptorHandle(uint32_t index) {
CPUDescriptorHandle handle;
handle.ptr = GetCPUDescriptorHandle(index).ptr;
return handle;
D3D12_CPU_DESCRIPTOR_HANDLE handle = m_descriptorHeap->GetCPUDescriptorHandleForHeapStart();
handle.ptr += index * m_descriptorSize;
CPUDescriptorHandle result;
result.ptr = handle.ptr;
return result;
}
GPUDescriptorHandle D3D12DescriptorHeap::GetGPUDescriptorHandle(uint32_t index) {
GPUDescriptorHandle handle;
handle.ptr = GetGPUDescriptorHandle(index).ptr;
return handle;
D3D12_GPU_DESCRIPTOR_HANDLE handle = m_descriptorHeap->GetGPUDescriptorHandleForHeapStart();
handle.ptr += index * m_descriptorSize;
GPUDescriptorHandle result;
result.ptr = handle.ptr;
return result;
}
DescriptorType D3D12DescriptorHeap::GetType() const {