Refactor D3D12: remove ICommandQueue, IFence dependencies

This commit is contained in:
2026-03-16 21:50:54 +08:00
parent 4a0f6d65d1
commit 472f106a12
7 changed files with 37 additions and 63 deletions

View File

@@ -36,23 +36,13 @@ void D3D12CommandQueue::Shutdown() {
m_commandQueue.Reset();
}
void D3D12CommandQueue::ExecuteCommandLists(uint32_t count, ICommandList** lists) {
std::vector<ID3D12CommandList*> d3d12Lists(count);
for (uint32_t i = 0; i < count; ++i) {
if (lists[i]) {
d3d12Lists[i] = reinterpret_cast<D3D12CommandList*>(lists[i])->GetCommandList();
}
}
m_commandQueue->ExecuteCommandLists(count, d3d12Lists.data());
}
void D3D12CommandQueue::ExecuteCommandLists(uint32_t count, ID3D12CommandList** lists) {
m_commandQueue->ExecuteCommandLists(count, lists);
}
void D3D12CommandQueue::Signal(IFence* fence, uint64_t value) {
void D3D12CommandQueue::Signal(D3D12Fence* fence, uint64_t value) {
if (fence) {
m_commandQueue->Signal(reinterpret_cast<D3D12Fence*>(fence)->GetFence(), value);
m_commandQueue->Signal(fence->GetFence(), value);
}
}
@@ -62,9 +52,9 @@ void D3D12CommandQueue::Signal(ID3D12Fence* fence, uint64_t value) {
}
}
void D3D12CommandQueue::Wait(IFence* fence, uint64_t value) {
void D3D12CommandQueue::Wait(D3D12Fence* fence, uint64_t value) {
if (fence) {
m_commandQueue->Wait(reinterpret_cast<D3D12Fence*>(fence)->GetFence(), value);
m_commandQueue->Wait(fence->GetFence(), value);
}
}

View File

@@ -75,7 +75,7 @@ bool D3D12Device::Initialize(bool enableDebugLayer) {
return false;
}
QueryDeviceInfo();
QueryAdapterInfo();
m_initialized = true;
return true;
}
@@ -118,7 +118,7 @@ bool D3D12Device::CreateDevice(IDXGIAdapter1* adapter) {
return SUCCEEDED(hr);
}
void D3D12Device::QueryDeviceInfo() {
void D3D12Device::QueryAdapterInfo() {
if (!m_adapter) {
return;
}
@@ -126,26 +126,20 @@ void D3D12Device::QueryDeviceInfo() {
DXGI_ADAPTER_DESC1 desc;
m_adapter->GetDesc1(&desc);
m_deviceInfo.vendorId = desc.VendorId;
m_deviceInfo.deviceId = desc.DeviceId;
m_deviceInfo.dedicatedVideoMemory = desc.DedicatedVideoMemory;
m_deviceInfo.dedicatedSystemMemory = desc.DedicatedSystemMemory;
m_deviceInfo.sharedSystemMemory = desc.SharedSystemMemory;
m_deviceInfo.deviceName = desc.Description;
m_deviceInfo.supportsRaytracing = false;
m_deviceInfo.supportsMeshShaders = false;
m_deviceInfo.supportsSamplerFeedback = false;
m_adapterInfo.vendorId = desc.VendorId;
m_adapterInfo.deviceId = desc.DeviceId;
m_adapterInfo.dedicatedVideoMemory = desc.DedicatedVideoMemory;
m_adapterInfo.dedicatedSystemMemory = desc.DedicatedSystemMemory;
m_adapterInfo.sharedSystemMemory = desc.SharedSystemMemory;
m_adapterInfo.description = desc.Description;
m_adapterInfo.isSoftware = (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) != 0;
D3D12_FEATURE_DATA_D3D12_OPTIONS5 options5 = {};
if (SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &options5, sizeof(options5)))) {
m_deviceInfo.supportsRaytracing = (options5.RaytracingTier != D3D12_RAYTRACING_TIER_NOT_SUPPORTED);
}
D3D12_FEATURE_DATA_D3D12_OPTIONS7 options7 = {};
if (SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &options7, sizeof(options7)))) {
m_deviceInfo.supportsSamplerFeedback = (options7.SamplerFeedbackTier != D3D12_SAMPLER_FEEDBACK_TIER_NOT_SUPPORTED);
m_deviceInfo.supportsMeshShaders = (options7.MeshShaderTier != D3D12_MESH_SHADER_TIER_NOT_SUPPORTED);
}
}
@@ -187,10 +181,6 @@ UINT D3D12Device::GetDescriptorHandleIncrementSize(DescriptorHeapType type) cons
return m_device->GetDescriptorHandleIncrementSize(ToD3D12(type));
}
void D3D12Device::GetDeviceInfo(DeviceInfo& info) const {
info = m_deviceInfo;
}
void* D3D12Device::GetNativeHandle() const {
return m_device.Get();
}