Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fe41ddf
feat(d3d12): expose `D3D12_FEATURE_FEATURE_LEVELS`
9Shain Jul 8, 2026
e1d5638
feat(dxmt): provide plane count in format query
9Shain Jul 8, 2026
8daaacc
feat(d3d12): expose `D3D12_FEATURE_FORMAT_INFO`
9Shain Jul 8, 2026
d8033a5
feat(d3d12): expose `D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT`
9Shain Jul 8, 2026
8c918f7
feat(d3d12): expose `D3D12_FEATURE_SHADER_MODEL`
9Shain Jul 8, 2026
c01cbbc
fix(d3d12): don't unregister residency if resource is not successfull…
9Shain Jul 8, 2026
78c8b07
feat(d3d12): validate resource initial state
9Shain Jul 8, 2026
67264f2
feat(d3d12): implement `GetCustomHeapProperties()`
9Shain Jul 9, 2026
e989c62
feat(d3d12): implement basic resource descriptor validation
9Shain Jul 9, 2026
fbfb663
feat(d3d12): expose `D3D12_FEATURE_DATA_D3D12_OPTIONS`
9Shain Jul 9, 2026
825cab5
feat(d3d12): expose `D3D12_FEATURE_D3D12_OPTIONS16`
9Shain Jul 9, 2026
2588d04
feat(d3d12): implement sampler descriptor
9Shain Jul 9, 2026
5c1c49b
feat(d3d12): expose `D3D12_FEATURE_FORMAT_SUPPORT`
9Shain Jul 28, 2026
939e724
feat(d3d12): validate resource heap properties
9Shain Jul 28, 2026
32e4ef9
feat(d3d12): implement texture and texel buffer UAV descriptor
9Shain Jul 28, 2026
41a68a8
feat(d3d12): add d3d12 command signature stubs
9Shain Jul 28, 2026
c813ba1
feat(d3d12): implement basic compute pipeline state
9Shain Jul 28, 2026
38a10bd
fix(d3d12): handle default and invalid mip count
9Shain Jul 28, 2026
cd5eb3d
feat(util): introduce `ConcurrentComPrivateData`
9Shain Jul 28, 2026
ca431e4
fix(d3d12): use `ConcurrentComPrivateData`
9Shain Jul 28, 2026
3a7d364
feat(d3d12): introduce compute encoder
9Shain Jul 28, 2026
2a35336
feat(d3d12): implement `Dispatch()`
9Shain Jul 28, 2026
1bc139d
fix(d3d12): properly handle depth-stencil planar in buffer-to-texture…
9Shain Jul 29, 2026
3525d41
feat(d3d12): implement basic compute root argument encoding
9Shain Jul 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions src/d3d12/d3d12_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "d3d12_device.hpp"
#include "d3d12_pageable.hpp"
#include "com/com_pointer.hpp"
#include "dxmt_format.hpp"

namespace dxmt {

Expand Down Expand Up @@ -53,7 +54,8 @@ class MTLD3D12Buffer : public MTLD3D12Pageable<MTLD3D12Resource> {
};

~MTLD3D12Buffer() {
device_->UnregisterResidencyAndVA(buffer->current());
if (buffer)
device_->UnregisterResidencyAndVA(buffer->current());
}

HRESULT
Expand Down Expand Up @@ -138,8 +140,40 @@ class MTLD3D12Buffer : public MTLD3D12Pageable<MTLD3D12Resource> {
CreateUnorderedAccessView(
ID3D12Resource *pCounter, const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, D3D12_CPU_DESCRIPTOR_HANDLE Descriptor
) {
IMPLEMENT_ME
return S_OK;
HRESULT hr;
D3D12_UNORDERED_ACCESS_VIEW_DESC ViewDesc;
if (!pDesc) {
hr = ExtractEntireResourceViewDescription(desc_, &ViewDesc);
if (FAILED(hr))
return hr;
} else {
ViewDesc = *pDesc;
}

if (ViewDesc.ViewDimension != D3D12_UAV_DIMENSION_BUFFER)
return E_INVALIDARG;

auto [Heap, Index] = GetShaderVisibleDescriptorHeap(device_, Descriptor);
BufferSlice Slice;

if (ViewDesc.Format == DXGI_FORMAT_UNKNOWN || ViewDesc.Buffer.Flags & D3D12_BUFFER_UAV_FLAG_RAW) {
// TODO(d3d12): structured/raw buffer view
IMPLEMENT_ME
}

MTL_DXGI_FORMAT_DESC Format;
if (FAILED(MTLQueryDXGIFormat(device_->GetMTLDevice(), ViewDesc.Format, Format))) {
ERR("D3D12Buffer::CreateUnorderedAccessView: not an ordinary or packed format: ", ViewDesc.Format);
return E_FAIL;
}
BufferViewDescriptor view_descriptor{Format.PixelFormat};
Slice.firstElement = ViewDesc.Buffer.FirstElement;
Slice.elementCount = ViewDesc.Buffer.NumElements;
Slice.byteOffset = Format.BytesPerTexel * ViewDesc.Buffer.FirstElement;
Slice.byteLength = Format.BytesPerTexel * ViewDesc.Buffer.NumElements;

auto view = buffer->createView(view_descriptor);
return Heap->AddUnorderedAccessView(Index, buffer.ptr(), view, Slice);
};

virtual HRESULT STDMETHODCALLTYPE
Expand Down Expand Up @@ -168,7 +202,6 @@ CreateCommittedBuffer(
const D3D12_RESOURCE_DESC *pDesc, D3D12_RESOURCE_STATES InitialState, const D3D12_CLEAR_VALUE *OptimizedClearValue,
REFIID riid, void **ppResource
) {
InitReturnPtr(ppResource);
auto buffer = Com(new MTLD3D12Buffer(pDevice));
HRESULT hr = buffer->Initialize(pHeapProps, HeapFlags, pDesc, OptimizedClearValue, nullptr);
if (FAILED(hr))
Expand All @@ -183,7 +216,6 @@ CreatePlacedBuffer(
MTLD3D12Device *pDevice, MTLD3D12Heap *pHeap, const D3D12_RESOURCE_DESC *pDesc, D3D12_RESOURCE_STATES InitialState,
const D3D12_CLEAR_VALUE *OptimizedClearValue, REFIID riid, void **ppResource
) {
InitReturnPtr(ppResource);
auto buffer = Com(new MTLD3D12Buffer(pDevice));
D3D12_HEAP_DESC heap_desc = pHeap->GetDesc();
HRESULT hr = buffer->Initialize(&heap_desc.Properties, heap_desc.Flags, pDesc, OptimizedClearValue, pHeap);
Expand Down
3 changes: 3 additions & 0 deletions src/d3d12/d3d12_command_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ MTLD3D12CommandAllocatorImpl::Reset() {
case EncoderType::Blit:
reinterpret_cast<BlitEncoderData *>(next)->~BlitEncoderData();
break;
case EncoderType::Compute:
reinterpret_cast<ComputeEncoderData *>(next)->~ComputeEncoderData();
break;
}
next = next->next;
}
Expand Down
12 changes: 12 additions & 0 deletions src/d3d12/d3d12_command_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ class MTLD3D12CommandAllocatorImpl : public MTLD3D12Pageable<MTLD3D12CommandAllo
return *storage;
}

template <typename cmd_struct>
cmd_struct &
EncodeComputeCommand() {
assert(encoder_current->type == EncoderType::Compute);
auto encoder = static_cast<ComputeEncoderData *>(encoder_current);
auto storage = (cmd_struct *)AllocateCPUHeap(sizeof(cmd_struct), 16);
encoder->cmd_tail->next.set(storage);
encoder->cmd_tail = (wmtcmd_base *)storage;
storage->next.set(nullptr);
return *storage;
}

std::tuple<void *, size_t>
AllocateGPUHeap(size_t Length, size_t Alignment) {
if (!Length)
Expand Down
6 changes: 6 additions & 0 deletions src/d3d12/d3d12_command_encoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum class EncoderType {
Clear,
Render,
Blit,
Compute,
};

struct EncoderData {
Expand Down Expand Up @@ -107,4 +108,9 @@ struct BlitEncoderData : EncoderData {
wmtcmd_base *cmd_tail;
};

struct ComputeEncoderData : EncoderData {
wmtcmd_compute_nop cmd_head;
wmtcmd_base *cmd_tail;
};

}; // namespace dxmt
Loading
Loading