Skip to content

Create, upload, and read back buffers using generic API in DX12.#1309

Merged
manon-traverse merged 19 commits into
llvm:mainfrom
Traverse-Research:improve-buffer-creation-squashed
Jun 19, 2026
Merged

Create, upload, and read back buffers using generic API in DX12.#1309
manon-traverse merged 19 commits into
llvm:mainfrom
Traverse-Research:improve-buffer-creation-squashed

Conversation

@manon-traverse

Copy link
Copy Markdown
Contributor

This is a major step in the generic API that wraps around DX12, Metal and Vulkan.

In the DX12 version of executeProgram all buffer creation, uploading and reading back is now done using only the generic interface. Only binding of resources to the root signature and setting up descriptor tables/heaps is done using DX12 specific code.

This brings the project another step closer to moving executeProgram outside of the graphics API wrapper and into the offloader executable.

Key changes:

  • Create CBV, SRV, and UAVs when resources are created
  • Create all buffers and textures using createBuffer and createTexture calls, no more raw DX12 calls
  • Perform readbacks and uploads using CommandEncoders
  • Remove all DX12 specific code for creating resources and descriptors.

Extra changes:

  • VK and Metal implementations of buffer and texture copy functions

Drive by fixes/changes:

  • Remove log checks from counter buffer tests that are no longer valid
  • Delete the CounterBuffer in Vulkan in the destructor
  • Select correct tiling mode for textures that use the CpuToGpu or GpuToCpu MemoryLocation

@manon-traverse manon-traverse changed the title Create, upload, and readback buffers using generic API in DX12. Create, upload, and read back buffers using generic API in DX12. Jun 15, 2026

@bogner bogner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the Feature/HLSLLib/PartiallyMappedResources.test test fails with this change, which will need looking into

Comment thread lib/API/DX/Device.cpp Outdated
Comment thread lib/API/DX/Device.cpp
Comment thread lib/API/DX/Device.cpp Outdated
Comment thread lib/API/DX/Device.cpp Outdated
Comment thread lib/API/DX/Device.cpp Outdated
Comment thread lib/API/MTL/MTLDevice.cpp Outdated
Comment thread lib/API/DX/Device.cpp Outdated
More WIP.

Almost completed refactor in DX12.

Implement mapping and unmapping of vulkan textures.

Implement copyTextureToBuffer in DX12 and Vulkan.

Use llvm::cast instead of static_cast.

Lots of progress in making agnostic buffers and textures fully work!

Fix resource state issue.

Remove incorrect shadowed variable.

Use correct strides when uploading textures.

Formatting.

Store the size in bytes in the Texture and use that for the memory map.

Use correct stride for computing the readback buffer size.

Counter Buffer WIP.

Get basically all tests passing on DX12.

Clean up transition barriers.

Remove dead code.

Use API agnostic code to readback render target.

Add missing Texture.cpp file.

Add AccelerationStructure entry to isBuffer.

Add vulkan image transitions to the render encoder

Remove dead code.

Add copyBufferToTexture implementation to Metal.

Add copyBufferToTexture implementation on Metal.

Graceful error on counter buffer feature in metal.

Add a not_supported impl for map and unmap on MTLTexture.

Mark sparse memory backing as unsupported on buffers in Metal.
@manon-traverse manon-traverse force-pushed the improve-buffer-creation-squashed branch from 877ac53 to b7b6c72 Compare June 17, 2026 16:10
@manon-traverse

Copy link
Copy Markdown
Contributor Author

Looks like the Feature/HLSLLib/PartiallyMappedResources.test test fails with this change, which will need looking into

It seems that test is being skipped on my machine due to my Intel GPU. I have added a code path for sparse textures and buffers. They are fully mapped just like before, but there is now also a generic API present for mapping specific tiles.

@manon-traverse manon-traverse force-pushed the improve-buffer-creation-squashed branch from b7b6c72 to a2ba2d4 Compare June 17, 2026 16:15
@manon-traverse

Copy link
Copy Markdown
Contributor Author

Looks like there is a bug in the sparse buffer impl. I'll fix that tomorrow.

Comment thread lib/API/DX/Device.cpp
Comment thread lib/API/MTL/MTLDevice.cpp

@bogner bogner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the redundant friend declarations have been cleaned up

Comment thread include/API/Device.h Outdated
Comment thread lib/API/DX/Device.cpp Outdated
@manon-traverse manon-traverse merged commit 9de429f into llvm:main Jun 19, 2026
22 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants