aboutsummaryrefslogtreecommitdiffstats
path: root/api-test
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2025-01-23 00:16:41 +0100
committerladevieq <ladevie.quentin@gmail.com>2025-01-23 00:16:57 +0100
commit0dd7e34602d0abec6442e4b63c22a8b2e760aad2 (patch)
tree99c4c5a4fb04517069b8d95ee92950e83bb3211f /api-test
parent11ede6055d54480d3b7486c5811a44f6f63e1c61 (diff)
Dx12 surface creation
Diffstat (limited to 'api-test')
-rw-r--r--api-test/dx12-device.cpp28
-rw-r--r--api-test/main.cpp11
2 files changed, 33 insertions, 6 deletions
diff --git a/api-test/dx12-device.cpp b/api-test/dx12-device.cpp
index 86340d1..4de63b6 100644
--- a/api-test/dx12-device.cpp
+++ b/api-test/dx12-device.cpp
@@ -37,17 +37,35 @@ void dx12device::init() {
SUCCEEDED(device->CreateCommandQueue(&queue_desc, IID_PPV_ARGS(&queues[2U])));
}
-void dx12device::create_surface(const surface_desc& desc)
+handle<dx12::device_surface> dx12device::create_surface(const dx12::surface_desc& desc) {
+ dx12::device_surface surface {
+ };
DXGI_MODE_DESC mode_desc{
- .Width = desc.
+ .Width = 0U,
+ .Height = 0U,
+ .RefreshRate = {
+ .Numerator = 1U,
+ .Denominator = 60U,
+ },
+ .Format = desc.surface_format,
+ .ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED,
+ .Scaling = DXGI_MODE_SCALING_CENTERED,
};
DXGI_SAMPLE_DESC sample_desc{
-
+ .Count = 1U,
+ .Quality = 0U,
};
DXGI_SWAP_CHAIN_DESC swapchain_desc{
.BufferDesc = mode_desc,
.SampleDesc = sample_desc,
- .BufferUsage = DXGI_USAGE_UNORDERED_ACCESS | DXGI_USAGE_RENDER_TARGET_OUTPUT,
+ .BufferUsage = desc.usages,
+ .BufferCount = desc.image_count,
+ .OutputWindow = desc.window_handle,
+ .Windowed = TRUE,
+ .SwapEffect = desc.present_mode,
+ .Flags = 0U,
};
- factory->CreateSwapChain(device, )
+ HRESULT hr = factory->CreateSwapChain(device, &swapchain_desc, &surface.swapchain);
+
+ return surfaces.add(surface);
}
diff --git a/api-test/main.cpp b/api-test/main.cpp
index 9fa7ef9..f61fa13 100644
--- a/api-test/main.cpp
+++ b/api-test/main.cpp
@@ -114,8 +114,9 @@ int main() {
#endif
device.init();
- auto main_scene = scene(camera(position, target, v_fov, aspect_ratio, aperture, focus_distance), window_width, window_height);
+ // auto main_scene = scene(camera(position, target, v_fov, aspect_ratio, aperture, focus_distance), window_width, window_height);
+#ifdef VK
auto surface_handle = device.create_surface({
.window_handle = wnd.handle,
.surface_format = {
@@ -125,6 +126,14 @@ int main() {
.present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR,
.usages = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT,
});
+#else
+ auto surface_handle = device.create_surface({
+ .window_handle = wnd.handle,
+ .surface_format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
+ .present_mode = DXGI_SWAP_EFFECT_FLIP_DISCARD,
+ .usages = DXGI_USAGE_UNORDERED_ACCESS | DXGI_USAGE_RENDER_TARGET_OUTPUT,
+ });
+#endif
auto& surface = device.get_surface(surface_handle);
#ifdef VK