From c3aac9026951e2a6e35e76b9c7d36e114a281453 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Tue, 5 May 2026 00:43:54 +0200 Subject: Remove old api and move api-test content to src and include dirs --- include/dx12-device.hpp | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 include/dx12-device.hpp (limited to 'include/dx12-device.hpp') diff --git a/include/dx12-device.hpp b/include/dx12-device.hpp new file mode 100644 index 0000000..baa5b60 --- /dev/null +++ b/include/dx12-device.hpp @@ -0,0 +1,97 @@ +#pragma once + +#include +#include + +#include "freelist.hpp" +#include "dx12-device-types.hpp" + +#include "D3D12MemAlloc.h" + +namespace dx12 { + struct command_buffer; + + class device { + struct queue { + ID3D12CommandQueue* dx_queue; + D3D12_COMMAND_LIST_TYPE type; + }; + public: + void init(); + + static inline device& get_render_device() { + return render_device; + } + + handle create_surface(const surface_desc& desc); + + handle create_buffer(const buffer_desc& desc); + + handle create_texture(const texture_desc& desc); + + void create_graphics_pipeline() {}; + + void create_compute_pipeline() {}; + + void allocate_command_buffers(command_buffer* buffers, size_t count, QueueType type); + + + [[nodiscard]] inline device_surface& get_surface(handle handle) { + return surfaces[handle]; + } + + [[nodiscard]] inline device_buffer& get_buffer(handle handle) { + return buffers[handle]; + } + + [[nodiscard]] inline device_texture& get_texture(handle handle) { + return textures[handle]; + } + + [[nodiscard]] inline ID3D12Device* get_device() const { + return device; + } + + uint32_t submit(command_buffer* buffers, uint32_t count); + + void wait(); + + private: + IDXGIFactory3* factory; + IDXGIAdapter* adapter; + ID3D12Debug* debug_interface; + + D3D12MA::Allocator* allocator; + + ID3D12Device* device; + ID3D12Fence* fence; + uint64_t fence_value = 0U; + queue queues[static_cast(QueueType::MAX)]; + + freelist surfaces; + freelist buffers; + freelist textures; + + static constexpr size_t max_allocable_command_buffers = 16U; + static constexpr size_t max_submitable_command_buffers = 16U; + + static class device render_device; + + struct bindless_model { + void init(); + + [[nodiscard]] inline ID3D12DescriptorHeap* const* get_heaps() const { + return &resources_heap; + } + + ID3D12DescriptorHeap* resources_heap; + ID3D12DescriptorHeap* samplers_heap; + } model; + + public: + [[nodiscard]] static inline const device::bindless_model& get_bindless_model() { + return render_device.model; + } + }; + +} -- cgit v1.3