adding backend bootstrapper

This commit is contained in:
2025-08-27 23:36:32 +02:00
parent 08d25cd631
commit 84bb6854c1
33 changed files with 925 additions and 7 deletions

View File

@@ -19,6 +19,8 @@ PulseBackendFlags Direct3D11CheckSupport(PulseBackendFlags candidates, PulseShad
bool Direct3D11LoadBackend(PulseBackend backend, PulseDebugLevel debug_level)
{
PULSE_UNUSED(backend);
PULSE_UNUSED(debug_level);
return true;
}
@@ -34,4 +36,3 @@ PulseBackendHandler D3D11Driver = {
.supported_shader_formats = PULSE_SHADER_FORMAT_DXBC_BIT,
.driver_data = PULSE_NULLPTR
};

View File

@@ -2,6 +2,8 @@
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_H_
@@ -18,7 +20,7 @@
#define D3D11_RETRIEVE_DRIVER_DATA_AS(handle, cast) ((cast)handle->driver_data)
PulseBackendFlags Direct3D11CheckSupport(PulseBackendFlags candidates, PulseShaderFormatsFlags shader_formats_used); // Return PULSE_BACKEND_D3D11 in case of success and PULSE_BACKEND_INVALID otherwise
PulseBackendFlags Direct3D11CheckSupport(PulseBackendFlags candidates, PulseShaderFormatsFlags shader_formats_used); // Returns corresponding PULSE_BACKEND enum in case of success and PULSE_BACKEND_INVALID otherwise
#endif // PULSE_D3D11_H_

41
Sources/Backends/D3D11/D3D11Buffer.c git.filemode.normal_file
View File

@@ -0,0 +1,41 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <string.h>
#include <Pulse.h>
#include "../../PulseInternal.h"
#include "D3D11.h"
#include "D3D11Buffer.h"
#include "D3D11CommandList.h"
PulseBuffer Direct3D11CreateBuffer(PulseDevice device, const PulseBufferCreateInfo* create_infos)
{
PulseBuffer buffer = (PulseBuffer)calloc(1, sizeof(PulseBufferHandler));
PULSE_CHECK_ALLOCATION_RETVAL(buffer, PULSE_NULL_HANDLE);
return buffer;
}
bool Direct3D11MapBuffer(PulseBuffer buffer, PulseMapMode mode, void** data)
{
return true;
}
void Direct3D11UnmapBuffer(PulseBuffer buffer)
{
}
bool Direct3D11CopyBufferToBuffer(PulseCommandList cmd, const PulseBufferRegion* src, const PulseBufferRegion* dst)
{
return true;
}
bool Direct3D11CopyBufferToImage(PulseCommandList cmd, const PulseBufferRegion* src, const PulseImageRegion* dst)
{
return true;
}
void Direct3D11DestroyBuffer(PulseDevice device, PulseBuffer buffer)
{
}

28
Sources/Backends/D3D11/D3D11Buffer.h git.filemode.normal_file
View File

@@ -0,0 +1,28 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_BUFFER_H_
#define PULSE_D3D11_BUFFER_H_
#include "D3D11.h"
typedef struct Direct3D11Buffer
{
int dummy;
} Direct3D11Buffer;
PulseBuffer Direct3D11CreateBuffer(PulseDevice device, const PulseBufferCreateInfo* create_infos);
bool Direct3D11MapBuffer(PulseBuffer buffer, PulseMapMode mode, void** data);
void Direct3D11UnmapBuffer(PulseBuffer buffer);
bool Direct3D11CopyBufferToBuffer(PulseCommandList cmd, const PulseBufferRegion* src, const PulseBufferRegion* dst);
bool Direct3D11CopyBufferToImage(PulseCommandList cmd, const PulseBufferRegion* src, const PulseImageRegion* dst);
void Direct3D11DestroyBuffer(PulseDevice device, PulseBuffer buffer);
#endif // PULSE_D3D11_BUFFER_H_
#endif // PULSE_ENABLE_D3D11_BACKEND

29
Sources/Backends/D3D11/D3D11CommandList.c git.filemode.normal_file
View File

@@ -0,0 +1,29 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#include "../../PulseInternal.h"
#include "D3D11.h"
#include "D3D11Fence.h"
#include "D3D11Device.h"
#include "D3D11CommandList.h"
#include "D3D11ComputePass.h"
#include "D3D11ComputePipeline.h"
#include "D3D11Buffer.h"
PulseCommandList Direct3D11RequestCommandList(PulseDevice device, PulseCommandListUsage usage)
{
PULSE_CHECK_HANDLE_RETVAL(device, PULSE_NULL_HANDLE);
PulseCommandList cmd = (PulseCommandList)calloc(1, sizeof(PulseCommandListHandler));
PULSE_CHECK_ALLOCATION_RETVAL(cmd, PULSE_NULL_HANDLE);
return cmd;
}
bool Direct3D11SubmitCommandList(PulseDevice device, PulseCommandList cmd, PulseFence fence)
{
}
void Direct3D11ReleaseCommandList(PulseDevice device, PulseCommandList cmd)
{
}

29
Sources/Backends/D3D11/D3D11CommandList.h git.filemode.normal_file
View File

@@ -0,0 +1,29 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_COMMAND_LIST_H_
#define PULSE_D3D11_COMMAND_LIST_H_
#include <stdatomic.h>
#include <tinycthread.h>
#include "D3D11.h"
#include "D3D11Fence.h"
typedef struct Direct3D11CommandList
{
int dummy;
} Direct3D11CommandList;
PulseCommandList Direct3D11RequestCommandList(PulseDevice device, PulseCommandListUsage usage);
bool Direct3D11SubmitCommandList(PulseDevice device, PulseCommandList cmd, PulseFence fence);
void Direct3D11ReleaseCommandList(PulseDevice device, PulseCommandList cmd);
#endif // PULSE_D3D11_COMMAND_LIST_H_
#endif // PULSE_ENABLE_D3D11_BACKEND

49
Sources/Backends/D3D11/D3D11ComputePass.c git.filemode.normal_file
View File

@@ -0,0 +1,49 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#include "../../PulseInternal.h"
#include "D3D11.h"
#include "D3D11ComputePass.h"
#include "D3D11CommandList.h"
PulseComputePass Direct3D11CreateComputePass(PulseDevice device, PulseCommandList cmd)
{
PULSE_UNUSED(device);
PulseComputePass pass = (PulseComputePass)calloc(1, sizeof(PulseComputePassHandler));
PULSE_CHECK_ALLOCATION_RETVAL(pass, PULSE_NULL_HANDLE);
return pass;
}
void Direct3D11DestroyComputePass(PulseDevice device, PulseComputePass pass)
{
}
PulseComputePass Direct3D11BeginComputePass(PulseCommandList cmd)
{
}
void Direct3D11EndComputePass(PulseComputePass pass)
{
}
void Direct3D11BindStorageBuffers(PulseComputePass pass, const PulseBuffer* buffers, uint32_t num_buffers)
{
}
void Direct3D11BindUniformData(PulseComputePass pass, uint32_t slot, const void* data, uint32_t data_size)
{
}
void Direct3D11BindStorageImages(PulseComputePass pass, const PulseImage* images, uint32_t num_images)
{
}
void Direct3D11BindComputePipeline(PulseComputePass pass, PulseComputePipeline pipeline)
{
}
void Direct3D11DispatchComputations(PulseComputePass pass, uint32_t groupcount_x, uint32_t groupcount_y, uint32_t groupcount_z)
{
}

27
Sources/Backends/D3D11/D3D11ComputePass.h git.filemode.normal_file
View File

@@ -0,0 +1,27 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_COMPUTE_PASS_H_
#define PULSE_D3D11_COMPUTE_PASS_H_
#include "D3D11.h"
PulseComputePass Direct3D11CreateComputePass(PulseDevice device, PulseCommandList cmd);
void Direct3D11DestroyComputePass(PulseDevice device, PulseComputePass pass);
PulseComputePass Direct3D11BeginComputePass(PulseCommandList cmd);
void Direct3D11EndComputePass(PulseComputePass pass);
void Direct3D11BindStorageBuffers(PulseComputePass pass, const PulseBuffer* buffers, uint32_t num_buffers);
void Direct3D11BindUniformData(PulseComputePass pass, uint32_t slot, const void* data, uint32_t data_size);
void Direct3D11BindStorageImages(PulseComputePass pass, const PulseImage* images, uint32_t num_images);
void Direct3D11BindComputePipeline(PulseComputePass pass, PulseComputePipeline pipeline);
void Direct3D11DispatchComputations(PulseComputePass pass, uint32_t groupcount_x, uint32_t groupcount_y, uint32_t groupcount_z);
#endif // PULSE_D3D11_COMPUTE_PASS_H_
#endif // PULSE_ENABLE_D3D11_BACKEND

22
Sources/Backends/D3D11/D3D11ComputePipeline.c git.filemode.normal_file
View File

@@ -0,0 +1,22 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#include "../../PulseInternal.h"
#include "D3D11.h"
#include "D3D11Device.h"
#include "D3D11ComputePipeline.h"
PulseComputePipeline Direct3D11CreateComputePipeline(PulseDevice device, const PulseComputePipelineCreateInfo* info)
{
PulseComputePipelineHandler* pipeline = (PulseComputePipelineHandler*)calloc(1, sizeof(PulseComputePipelineHandler));
PULSE_CHECK_ALLOCATION_RETVAL(pipeline, PULSE_NULL_HANDLE);
if(PULSE_IS_BACKEND_HIGH_LEVEL_DEBUG(device->backend))
PulseLogInfoFmt(device->backend, "(D3D11) created new compute pipeline %p", pipeline);
return pipeline;
}
void Direct3D11DestroyComputePipeline(PulseDevice device, PulseComputePipeline pipeline)
{
}

24
Sources/Backends/D3D11/D3D11ComputePipeline.h git.filemode.normal_file
View File

@@ -0,0 +1,24 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_COMPUTE_PIPELINE_H_
#define PULSE_D3D11_COMPUTE_PIPELINE_H_
#include "D3D11.h"
typedef struct Direct3D11ComputePipeline
{
int dummy;
} Direct3D11ComputePipeline;
PulseComputePipeline Direct3D11CreateComputePipeline(PulseDevice device, const PulseComputePipelineCreateInfo* info);
void Direct3D11DestroyComputePipeline(PulseDevice device, PulseComputePipeline pipeline);
#endif // PULSE_D3D11_COMPUTE_PIPELINE_H_
#endif // PULSE_ENABLE_D3D11_BACKEND

View File

@@ -2,13 +2,18 @@
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#include <wchar.h>
#include <Pulse.h>
#include "../../PulseInternal.h"
#include "D3D11.h"
#include "D3D11ComputePipeline.h"
#include "D3D11CommandList.h"
#include "D3D11Device.h"
#include "D3D11Fence.h"
#include "D3D11Buffer.h"
#include "D3D11Image.h"
#include "D3D11ComputePass.h"
bool Direct3D11IsDedicatedAdapter(IDXGIAdapter1* adapter)
{
@@ -146,8 +151,7 @@ PulseDevice Direct3D11CreateDevice(PulseBackend backend, PulseDevice* forbiden_d
};
D3D11CreateDevice((IDXGIAdapter*)device->adapter, D3D_DRIVER_TYPE_UNKNOWN, PULSE_NULLPTR, 0, feature_levels, PULSE_SIZEOF_ARRAY(feature_levels), D3D11_SDK_VERSION, &device->device, PULSE_NULLPTR, &device->context);
pulse_device->PFN_DestroyDevice = Direct3D11DestroyDevice;
PULSE_LOAD_DRIVER_DEVICE(Direct3D11);
if(PULSE_IS_BACKEND_HIGH_LEVEL_DEBUG(backend))
PulseLogInfoFmt(backend, "(D3D11) created device from %ls", device->description.Description);

View File

@@ -2,12 +2,13 @@
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_DEVICE_H_
#define PULSE_D3D11_DEVICE_H_
#include <Pulse.h>
#include "D3D11.h"
typedef struct Direct3D11Device

31
Sources/Backends/D3D11/D3D11Fence.c git.filemode.normal_file
View File

@@ -0,0 +1,31 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#include "../../PulseInternal.h"
#include "D3D11.h"
#include "D3D11Fence.h"
#include "D3D11CommandList.h"
PulseFence Direct3D11CreateFence(PulseDevice device)
{
PulseFence fence = (PulseFence)calloc(1, sizeof(PulseFence));
PULSE_CHECK_ALLOCATION_RETVAL(fence, PULSE_NULL_HANDLE);
return fence;
}
void Direct3D11DestroyFence(PulseDevice device, PulseFence fence)
{
free(fence);
}
bool Direct3D11IsFenceReady(PulseDevice device, PulseFence fence)
{
return true;
}
bool Direct3D11WaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all)
{
return true;
}

27
Sources/Backends/D3D11/D3D11Fence.h git.filemode.normal_file
View File

@@ -0,0 +1,27 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_FENCE_H_
#define PULSE_D3D11_FENCE_H_
#include <Pulse.h>
#include "D3D11.h"
typedef struct Direct3D11Fence
{
int dummy;
} Direct3D11Fence;
PulseFence Direct3D11CreateFence(PulseDevice device);
void Direct3D11DestroyFence(PulseDevice device, PulseFence fence);
bool Direct3D11IsFenceReady(PulseDevice device, PulseFence fence);
bool Direct3D11WaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all);
#endif // PULSE_D3D11_FENCE_H_
#endif // PULSE_ENABLE_D3D11_BACKEND

28
Sources/Backends/D3D11/D3D11Image.c git.filemode.normal_file
View File

@@ -0,0 +1,28 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#include "../../PulseInternal.h"
#include "D3D11.h"
#include "D3D11Image.h"
PulseImage Direct3D11CreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos)
{
}
bool Direct3D11IsImageFormatValid(PulseDevice device, PulseImageFormat format, PulseImageType type, PulseImageUsageFlags usage)
{
}
bool Direct3D11CopyImageToBuffer(PulseCommandList cmd, const PulseImageRegion* src, const PulseBufferRegion* dst)
{
}
bool Direct3D11BlitImage(PulseCommandList cmd, const PulseImageRegion* src, const PulseImageRegion* dst)
{
}
void Direct3D11DestroyImage(PulseDevice device, PulseImage image)
{
}

27
Sources/Backends/D3D11/D3D11Image.h git.filemode.normal_file
View File

@@ -0,0 +1,27 @@
// Copyright (C) 2025 kanel
// This file is part of "Pulse"
// For conditions of distribution and use, see copyright notice in LICENSE
#include <Pulse.h>
#ifdef PULSE_ENABLE_D3D11_BACKEND
#ifndef PULSE_D3D11_IMAGE_H_
#define PULSE_D3D11_IMAGE_H_
#include "D3D11.h"
typedef struct Direct3D11Image
{
int dummy;
} Direct3D11Image;
PulseImage Direct3D11CreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos);
bool Direct3D11IsImageFormatValid(PulseDevice device, PulseImageFormat format, PulseImageType type, PulseImageUsageFlags usage);
bool Direct3D11CopyImageToBuffer(PulseCommandList cmd, const PulseImageRegion* src, const PulseBufferRegion* dst);
bool Direct3D11BlitImage(PulseCommandList cmd, const PulseImageRegion* src, const PulseImageRegion* dst);
void Direct3D11DestroyImage(PulseDevice device, PulseImage image);
#endif // PULSE_D3D11_IMAGE_H_
#endif // PULSE_ENABLE_D3D11_BACKEND