aboutsummaryrefslogtreecommitdiffstats
path: root/include/api-test/dx12-device.hpp
diff options
context:
space:
mode:
authorQuentin LADEVIE <qladevie@wanadev.fr>2025-01-26 22:27:10 +0100
committerQuentin LADEVIE <qladevie@wanadev.fr>2025-01-26 22:27:10 +0100
commitc29105b461135f3909cca0308fb05715cee45763 (patch)
tree49c6c41bb88377f6af73ebdf39821038b88b05cf /include/api-test/dx12-device.hpp
parent3490db941ea16e67da72f60ebda75ec0f8bb8051 (diff)
DX12 command buffers and resourcesapi-proto
Diffstat (limited to 'include/api-test/dx12-device.hpp')
-rw-r--r--include/api-test/dx12-device.hpp106
1 files changed, 78 insertions, 28 deletions
diff --git a/include/api-test/dx12-device.hpp b/include/api-test/dx12-device.hpp
index 83d8888..baa5b60 100644
--- a/include/api-test/dx12-device.hpp
+++ b/include/api-test/dx12-device.hpp
@@ -1,47 +1,97 @@
+#pragma once
+
#include <d3d12.h>
+#include <dxgi1_3.h>
#include "freelist.hpp"
#include "dx12-device-types.hpp"
-class dx12device {
- struct queue {
- ID3D12CommandQueue* dx_queue;
- };
- public:
- void init();
+#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<device_surface> create_surface(const surface_desc& desc);
+
+ handle<device_buffer> create_buffer(const buffer_desc& desc);
+
+ handle<device_texture> create_texture(const texture_desc& desc);
- static inline dx12device& get_render_device() {
- return render_device;
- }
+ void create_graphics_pipeline() {};
- handle<dx12::device_surface> create_surface(const dx12::surface_desc& desc);
+ void create_compute_pipeline() {};
- void create_buffer() {};
+ void allocate_command_buffers(command_buffer* buffers, size_t count, QueueType type);
- void create_texture() {};
- void create_graphics_pipeline() {};
+ [[nodiscard]] inline device_surface& get_surface(handle<device_surface> handle) {
+ return surfaces[handle];
+ }
- void create_compute_pipeline() {};
+ [[nodiscard]] inline device_buffer& get_buffer(handle<device_buffer> handle) {
+ return buffers[handle];
+ }
- void allocate_command_buffers() {};
+ [[nodiscard]] inline device_texture& get_texture(handle<device_texture> handle) {
+ return textures[handle];
+ }
- void get_buffer() {};
+ [[nodiscard]] inline ID3D12Device* get_device() const {
+ return device;
+ }
- void get_texture() {};
+ uint32_t submit(command_buffer* buffers, uint32_t count);
- [[nodiscard]] inline dx12::device_surface& get_surface(handle<dx12::device_surface> handle) {
- return surfaces[handle];
- }
+ void wait();
- private:
- IDXGIFactory* factory;
- IDXGIAdapter* adapter;
+ private:
+ IDXGIFactory3* factory;
+ IDXGIAdapter* adapter;
+ ID3D12Debug* debug_interface;
- ID3D12Device* device;
- queue queues[static_cast<uint32_t>(dx12::QueueType::MAX)];
+ D3D12MA::Allocator* allocator;
- freelist<dx12::device_surface> surfaces;
+ ID3D12Device* device;
+ ID3D12Fence* fence;
+ uint64_t fence_value = 0U;
+ queue queues[static_cast<uint32_t>(QueueType::MAX)];
+
+ freelist<device_surface> surfaces;
+ freelist<device_buffer> buffers;
+ freelist<device_texture> 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;
+ }
+ };
- static dx12device render_device;
-};
+}