From 9771dcc530d79b5cfc523b5143e7fd2acaf3056b Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Sun, 2 Mar 2025 21:37:17 +0100 Subject: [PATCH] adding software computer base --- Examples/Software/main.c | 29 ++++++++++++ Examples/Software/xmake.lua | 7 +++ Examples/xmake.lua | 3 ++ Includes/Pulse.h | 20 ++++----- Sources/Backends/Software/Soft.c | 42 ++++++++++++++++++ Sources/Backends/Software/Soft.h | 22 ++++++++++ Sources/Backends/Software/SoftBuffer.c | 32 ++++++++++++++ Sources/Backends/Software/SoftBuffer.h | 28 ++++++++++++ Sources/Backends/Software/SoftCommandList.c | 20 +++++++++ Sources/Backends/Software/SoftCommandlist.h | 24 ++++++++++ Sources/Backends/Software/SoftComputePass.c | 44 +++++++++++++++++++ Sources/Backends/Software/SoftComputePass.h | 31 +++++++++++++ .../Backends/Software/SoftComputePipeline.c | 16 +++++++ .../Backends/Software/SoftComputePipeline.h | 23 ++++++++++ Sources/Backends/Software/SoftDevice.c | 16 +++++++ Sources/Backends/Software/SoftDevice.h | 23 ++++++++++ Sources/Backends/Software/SoftFence.c | 24 ++++++++++ Sources/Backends/Software/SoftFence.h | 29 ++++++++++++ Sources/Backends/Software/SoftImage.c | 28 ++++++++++++ Sources/Backends/Software/SoftImage.h | 26 +++++++++++ Sources/PulseBackend.c | 9 ++++ Sources/PulseInternal.h | 3 ++ Xmake/packages/s/spirv-vm/xmake.lua | 30 +++++++++++++ Xmake/packages/t/tiny-c-thread/xmake.lua | 30 ++++++------- xmake.lua | 5 +++ 25 files changed, 539 insertions(+), 25 deletions(-) create mode 100644 Examples/Software/main.c create mode 100644 Examples/Software/xmake.lua create mode 100644 Sources/Backends/Software/Soft.c create mode 100644 Sources/Backends/Software/Soft.h create mode 100644 Sources/Backends/Software/SoftBuffer.c create mode 100644 Sources/Backends/Software/SoftBuffer.h create mode 100644 Sources/Backends/Software/SoftCommandList.c create mode 100644 Sources/Backends/Software/SoftCommandlist.h create mode 100644 Sources/Backends/Software/SoftComputePass.c create mode 100644 Sources/Backends/Software/SoftComputePass.h create mode 100644 Sources/Backends/Software/SoftComputePipeline.c create mode 100644 Sources/Backends/Software/SoftComputePipeline.h create mode 100644 Sources/Backends/Software/SoftDevice.c create mode 100644 Sources/Backends/Software/SoftDevice.h create mode 100644 Sources/Backends/Software/SoftFence.c create mode 100644 Sources/Backends/Software/SoftFence.h create mode 100644 Sources/Backends/Software/SoftImage.c create mode 100644 Sources/Backends/Software/SoftImage.h create mode 100644 Xmake/packages/s/spirv-vm/xmake.lua diff --git a/Examples/Software/main.c b/Examples/Software/main.c new file mode 100644 index 0000000..a6ba17f --- /dev/null +++ b/Examples/Software/main.c @@ -0,0 +1,29 @@ +#include + +#include +#include + +void DebugCallBack(PulseDebugMessageSeverity severity, const char* message) +{ + if(severity == PULSE_DEBUG_MESSAGE_SEVERITY_ERROR) + { + fprintf(stderr, "Pulse Error: %s\n", message); + exit(1); + } + else if(severity == PULSE_DEBUG_MESSAGE_SEVERITY_WARNING) + fprintf(stderr, "Pulse Warning: %s\n", message); + else + printf("Pulse: %s\n", message); +} + +int main(void) +{ + PulseBackend backend = PulseLoadBackend(PULSE_BACKEND_SOFTWARE, PULSE_SHADER_FORMAT_SPIRV_BIT, PULSE_HIGH_DEBUG); + PulseSetDebugCallback(backend, DebugCallBack); + PulseDevice device = PulseCreateDevice(backend, NULL, 0); + + PulseDestroyDevice(device); + PulseUnloadBackend(backend); + puts("Successfully executed Pulse example using Software backend !"); + return 0; +} diff --git a/Examples/Software/xmake.lua b/Examples/Software/xmake.lua new file mode 100644 index 0000000..3f05ff9 --- /dev/null +++ b/Examples/Software/xmake.lua @@ -0,0 +1,7 @@ +target("SoftwareExample") + add_deps("pulse_gpu") + if is_plat("linux") then + set_extension(".x86_64") + end + add_files("*.c") +target_end() diff --git a/Examples/xmake.lua b/Examples/xmake.lua index 7ee7673..fa470a8 100644 --- a/Examples/xmake.lua +++ b/Examples/xmake.lua @@ -8,4 +8,7 @@ if has_config("examples") then if has_config("webgpu") then includes("WebGPU/xmake.lua") end + if has_config("software") then + includes("Software/xmake.lua") + end end diff --git a/Includes/Pulse.h b/Includes/Pulse.h index 32404dd..c0229f8 100644 --- a/Includes/Pulse.h +++ b/Includes/Pulse.h @@ -34,12 +34,12 @@ PULSE_DEFINE_NULLABLE_HANDLE(PulseComputePass); // Flags typedef enum PulseBackendBits { - PULSE_BACKEND_INVALID = PULSE_BIT(1), - PULSE_BACKEND_ANY = PULSE_BIT(2), - PULSE_BACKEND_VULKAN = PULSE_BIT(3), - PULSE_BACKEND_METAL = PULSE_BIT(4), - PULSE_BACKEND_WEBGPU = PULSE_BIT(5), - // More to come + PULSE_BACKEND_INVALID = PULSE_BIT(1), + PULSE_BACKEND_ANY = PULSE_BIT(2), + PULSE_BACKEND_VULKAN = PULSE_BIT(3), + PULSE_BACKEND_METAL = PULSE_BIT(4), + PULSE_BACKEND_WEBGPU = PULSE_BIT(5), + PULSE_BACKEND_SOFTWARE = PULSE_BIT(6), } PulseBackendBits; typedef PulseFlags PulseBackendFlags; @@ -68,10 +68,10 @@ typedef PulseFlags PulseImageUsageFlags; typedef enum PulseShaderFormatsBits { - PULSE_SHADER_FORMAT_SPIRV_BIT = PULSE_BIT(1), // Can be used by Vulkan - PULSE_SHADER_FORMAT_MSL_BIT = PULSE_BIT(2), // Can be used by Metal - PULSE_SHADER_FORMAT_METALLIB_BIT = PULSE_BIT(3), // Can be used by Metal - PULSE_SHADER_FORMAT_WGSL_BIT = PULSE_BIT(4), // Can be used by WebGPU + PULSE_SHADER_FORMAT_SPIRV_BIT = PULSE_BIT(1), // Can be used by Vulkan and Software backends + PULSE_SHADER_FORMAT_MSL_BIT = PULSE_BIT(2), // Can be used by Metal backend + PULSE_SHADER_FORMAT_METALLIB_BIT = PULSE_BIT(3), // Can be used by Metal backend + PULSE_SHADER_FORMAT_WGSL_BIT = PULSE_BIT(4), // Can be used by WebGPU backend // More to come } PulseShaderFormatsBits; typedef PulseFlags PulseShaderFormatsFlags; diff --git a/Sources/Backends/Software/Soft.c b/Sources/Backends/Software/Soft.c new file mode 100644 index 0000000..91ead63 --- /dev/null +++ b/Sources/Backends/Software/Soft.c @@ -0,0 +1,42 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include +#include "../../PulseInternal.h" + +#include "Soft.h" +#include "SoftDevice.h" + +PulseBackendFlags SoftCheckSupport(PulseBackendFlags candidates, PulseShaderFormatsFlags shader_formats_used) +{ + if(candidates != PULSE_BACKEND_ANY && (candidates & PULSE_BACKEND_SOFTWARE) == 0) + return PULSE_BACKEND_INVALID; + if((shader_formats_used & PULSE_SHADER_FORMAT_SPIRV_BIT) == 0) + return PULSE_BACKEND_INVALID; + return PULSE_BACKEND_SOFTWARE; // Software computer is always supported +} + +bool SoftLoadBackend(PulseBackend backend, PulseDebugLevel debug_level) +{ + PULSE_UNUSED(backend); + PULSE_UNUSED(debug_level); + SoftDriverData* driver_data = (SoftDriverData*)calloc(1, sizeof(SoftDriverData)); + PULSE_CHECK_ALLOCATION_RETVAL(driver_data, false); + WebGPUDriver.driver_data = driver_data; + return true; +} + +void SoftUnloadBackend(PulseBackend backend) +{ + free(backend->driver_data); +} + +PulseBackendHandler SoftwareDriver = { + .PFN_LoadBackend = SoftLoadBackend, + .PFN_UnloadBackend = SoftUnloadBackend, + .PFN_CreateDevice = SoftCreateDevice, + .backend = PULSE_BACKEND_SOFTWARE, + .supported_shader_formats = PULSE_SHADER_FORMAT_SPIRV_BIT, + .driver_data = PULSE_NULLPTR +}; diff --git a/Sources/Backends/Software/Soft.h b/Sources/Backends/Software/Soft.h new file mode 100644 index 0000000..941fe32 --- /dev/null +++ b/Sources/Backends/Software/Soft.h @@ -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 + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_H_ +#define PULSE_SOFTWARE_H_ + +#define SOFTWARE_RETRIEVE_DRIVER_DATA_AS(handle, cast) ((cast)handle->driver_data) + +typedef struct SoftDriverData +{ +} SoftDriverData; + +PulseBackendFlags SoftCheckSupport(PulseBackendFlags candidates, PulseShaderFormatsFlags shader_formats_used); // Return PULSE_BACKEND_SOFTWARE in case of success and PULSE_BACKEND_INVALID otherwise + +#endif // PULSE_SOFTWARE_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/Backends/Software/SoftBuffer.c b/Sources/Backends/Software/SoftBuffer.c new file mode 100644 index 0000000..16ecb7b --- /dev/null +++ b/Sources/Backends/Software/SoftBuffer.c @@ -0,0 +1,32 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include +#include "../../PulseInternal.h" +#include "Soft.h" +#include "SoftBuffer.h" + +PulseBuffer SoftCreateBuffer(PulseDevice device, const PulseBufferCreateInfo* create_infos) +{ +} + +bool SoftMapBuffer(PulseBuffer buffer, PulseMapMode mode, void** data) +{ +} + +void SoftUnmapBuffer(PulseBuffer buffer) +{ +} + +bool SoftCopyBufferToBuffer(PulseCommandList cmd, const PulseBufferRegion* src, const PulseBufferRegion* dst) +{ +} + +bool SoftCopyBufferToImage(PulseCommandList cmd, const PulseBufferRegion* src, const PulseImageRegion* dst) +{ +} + +void SoftDestroyBuffer(PulseDevice device, PulseBuffer buffer) +{ +} diff --git a/Sources/Backends/Software/SoftBuffer.h b/Sources/Backends/Software/SoftBuffer.h new file mode 100644 index 0000000..1caf437 --- /dev/null +++ b/Sources/Backends/Software/SoftBuffer.h @@ -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 + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_BUFFER_H_ +#define PULSE_SOFTWARE_BUFFER_H_ + +#include "Soft.h" + +typedef struct SoftBuffer +{ + void* map; +} SoftBuffer; + +PulseBuffer SoftCreateBuffer(PulseDevice device, const PulseBufferCreateInfo* create_infos); +bool SoftMapBuffer(PulseBuffer buffer, PulseMapMode mode, void** data); +void SoftUnmapBuffer(PulseBuffer buffer); +bool SoftCopyBufferToBuffer(PulseCommandList cmd, const PulseBufferRegion* src, const PulseBufferRegion* dst); +bool SoftCopyBufferToImage(PulseCommandList cmd, const PulseBufferRegion* src, const PulseImageRegion* dst); +void SoftDestroyBuffer(PulseDevice device, PulseBuffer buffer); + +#endif // PULSE_SOFTWARE_BUFFER_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/Backends/Software/SoftCommandList.c b/Sources/Backends/Software/SoftCommandList.c new file mode 100644 index 0000000..53fcb57 --- /dev/null +++ b/Sources/Backends/Software/SoftCommandList.c @@ -0,0 +1,20 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include +#include "../../PulseInternal.h" +#include "Soft.h" +#include "SoftCommandlist.h" + +PulseCommandList SoftRequestCommandList(PulseDevice device, PulseCommandListUsage usage) +{ +} + +bool SoftSubmitCommandList(PulseDevice device, PulseCommandList cmd, PulseFence fence) +{ +} + +void SoftReleaseCommandList(PulseDevice device, PulseCommandList cmd) +{ +} diff --git a/Sources/Backends/Software/SoftCommandlist.h b/Sources/Backends/Software/SoftCommandlist.h new file mode 100644 index 0000000..16c5ef6 --- /dev/null +++ b/Sources/Backends/Software/SoftCommandlist.h @@ -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 + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_COMMAND_LIST_H_ +#define PULSE_SOFTWARE_COMMAND_LIST_H_ + +#include "Soft.h" + +typedef struct SoftCommandList +{ +} SoftCommandList; + +PulseCommandList SoftRequestCommandList(PulseDevice device, PulseCommandListUsage usage); +bool SoftSubmitCommandList(PulseDevice device, PulseCommandList cmd, PulseFence fence); +void SoftReleaseCommandList(PulseDevice device, PulseCommandList cmd); + +#endif // PULSE_SOFTWARE_COMMAND_LIST_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/Backends/Software/SoftComputePass.c b/Sources/Backends/Software/SoftComputePass.c new file mode 100644 index 0000000..1578ee8 --- /dev/null +++ b/Sources/Backends/Software/SoftComputePass.c @@ -0,0 +1,44 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include +#include "../../PulseInternal.h" +#include "Soft.h" +#include "SoftComputePass.h" + +PulseComputePass SoftCreateComputePass(PulseDevice device, PulseCommandList cmd) +{ +} + +void SoftDestroyComputePass(PulseDevice device, PulseComputePass pass) +{ +} + +PulseComputePass SoftBeginComputePass(PulseCommandList cmd) +{ +} + +void SoftEndComputePass(PulseComputePass pass) +{ +} + +void SoftBindStorageBuffers(PulseComputePass pass, const PulseBuffer* buffers, uint32_t num_buffers) +{ +} + +void SoftBindUniformData(PulseComputePass pass, uint32_t slot, const void* data, uint32_t data_size) +{ +} + +void SoftBindStorageImages(PulseComputePass pass, const PulseImage* images, uint32_t num_images) +{ +} + +void SoftBindComputePipeline(PulseComputePass pass, PulseComputePipeline pipeline) +{ +} + +void SoftDispatchComputations(PulseComputePass pass, uint32_t groupcount_x, uint32_t groupcount_y, uint32_t groupcount_z) +{ +} diff --git a/Sources/Backends/Software/SoftComputePass.h b/Sources/Backends/Software/SoftComputePass.h new file mode 100644 index 0000000..d3f0e68 --- /dev/null +++ b/Sources/Backends/Software/SoftComputePass.h @@ -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 + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_COMPUTE_PASS_H_ +#define PULSE_SOFTWARE_COMPUTE_PASS_H_ + +#include "Soft.h" + +typedef struct SoftComputePass +{ +} SoftComputePass; + +PulseComputePass SoftCreateComputePass(PulseDevice device, PulseCommandList cmd); +void SoftDestroyComputePass(PulseDevice device, PulseComputePass pass); + +PulseComputePass SoftBeginComputePass(PulseCommandList cmd); +void SoftEndComputePass(PulseComputePass pass); +void SoftBindStorageBuffers(PulseComputePass pass, const PulseBuffer* buffers, uint32_t num_buffers); +void SoftBindUniformData(PulseComputePass pass, uint32_t slot, const void* data, uint32_t data_size); +void SoftBindStorageImages(PulseComputePass pass, const PulseImage* images, uint32_t num_images); +void SoftBindComputePipeline(PulseComputePass pass, PulseComputePipeline pipeline); +void SoftDispatchComputations(PulseComputePass pass, uint32_t groupcount_x, uint32_t groupcount_y, uint32_t groupcount_z); + +#endif // PULSE_SOFTWARE_COMPUTE_PASS_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/Backends/Software/SoftComputePipeline.c b/Sources/Backends/Software/SoftComputePipeline.c new file mode 100644 index 0000000..cbd3065 --- /dev/null +++ b/Sources/Backends/Software/SoftComputePipeline.c @@ -0,0 +1,16 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include +#include "../../PulseInternal.h" +#include "Soft.h" +#include "SoftComputePipeline.h" + +PulseComputePipeline SoftCreateComputePipeline(PulseDevice device, const PulseComputePipelineCreateInfo* info) +{ +} + +void SoftDestroyComputePipeline(PulseDevice device, PulseComputePipeline pipeline) +{ +} diff --git a/Sources/Backends/Software/SoftComputePipeline.h b/Sources/Backends/Software/SoftComputePipeline.h new file mode 100644 index 0000000..40f5f3b --- /dev/null +++ b/Sources/Backends/Software/SoftComputePipeline.h @@ -0,0 +1,23 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_COMPUTE_PIPELINE_H_ +#define PULSE_SOFTWARE_COMPUTE_PIPELINE_H_ + +#include "Soft.h" + +typedef struct SoftComputePipeline +{ +} SoftComputePipeline; + +PulseComputePipeline SoftCreateComputePipeline(PulseDevice device, const PulseComputePipelineCreateInfo* info); +void SoftDestroyComputePipeline(PulseDevice device, PulseComputePipeline pipeline); + +#endif // PULSE_SOFTWARE_COMPUTE_PIPELINE_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/Backends/Software/SoftDevice.c b/Sources/Backends/Software/SoftDevice.c new file mode 100644 index 0000000..fb4d48b --- /dev/null +++ b/Sources/Backends/Software/SoftDevice.c @@ -0,0 +1,16 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include +#include "../../PulseInternal.h" +#include "Soft.h" +#include "SoftDevice.h" + +PulseDevice SoftCreateDevice(PulseBackend backend, PulseDevice* forbiden_devices, uint32_t forbiden_devices_count) +{ +} + +void SoftDestroyDevice(PulseDevice device) +{ +} diff --git a/Sources/Backends/Software/SoftDevice.h b/Sources/Backends/Software/SoftDevice.h new file mode 100644 index 0000000..5911005 --- /dev/null +++ b/Sources/Backends/Software/SoftDevice.h @@ -0,0 +1,23 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_DEVICE_H_ +#define PULSE_SOFTWARE_DEVICE_H_ + +#include "Soft.h" + +typedef struct SoftDevice +{ +} SoftDevice; + +PulseDevice SoftCreateDevice(PulseBackend backend, PulseDevice* forbiden_devices, uint32_t forbiden_devices_count); +void SoftDestroyDevice(PulseDevice device); + +#endif // PULSE_SOFTWARE_DEVICE_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/Backends/Software/SoftFence.c b/Sources/Backends/Software/SoftFence.c new file mode 100644 index 0000000..8d1eae2 --- /dev/null +++ b/Sources/Backends/Software/SoftFence.c @@ -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 +#include "../../PulseInternal.h" +#include "Soft.h" +#include "SoftFence.h" + +PulseFence SoftCreateFence(PulseDevice device) +{ +} + +void SoftDestroyFence(PulseDevice device, PulseFence fence) +{ +} + +bool SoftIsFenceReady(PulseDevice device, PulseFence fence) +{ +} + +bool SoftWaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all) +{ +} diff --git a/Sources/Backends/Software/SoftFence.h b/Sources/Backends/Software/SoftFence.h new file mode 100644 index 0000000..827ac2a --- /dev/null +++ b/Sources/Backends/Software/SoftFence.h @@ -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 + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_FENCE_H_ +#define PULSE_SOFTWARE_FENCE_H_ + +#include + +#include +#include "Soft.h" + +typedef struct SoftFence +{ + atomic_bool signal; +} SoftFence; + +PulseFence SoftCreateFence(PulseDevice device); +void SoftDestroyFence(PulseDevice device, PulseFence fence); +bool SoftIsFenceReady(PulseDevice device, PulseFence fence); +bool SoftWaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all); + +#endif // PULSE_SOFTWARE_FENCE_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/Backends/Software/SoftImage.c b/Sources/Backends/Software/SoftImage.c new file mode 100644 index 0000000..0b6b800 --- /dev/null +++ b/Sources/Backends/Software/SoftImage.c @@ -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 +#include "../../PulseInternal.h" +#include "Soft.h" +#include "SoftImage.h" + +PulseImage SoftCreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos) +{ +} + +bool SoftIsImageFormatValid(PulseDevice device, PulseImageFormat format, PulseImageType type, PulseImageUsageFlags usage) +{ +} + +bool SoftCopyImageToBuffer(PulseCommandList cmd, const PulseImageRegion* src, const PulseBufferRegion* dst) +{ +} + +bool SoftBlitImage(PulseCommandList cmd, const PulseImageRegion* src, const PulseImageRegion* dst) +{ +} + +void SoftDestroyImage(PulseDevice device, PulseImage image) +{ +} diff --git a/Sources/Backends/Software/SoftImage.h b/Sources/Backends/Software/SoftImage.h new file mode 100644 index 0000000..a4aa281 --- /dev/null +++ b/Sources/Backends/Software/SoftImage.h @@ -0,0 +1,26 @@ +// Copyright (C) 2025 kanel +// This file is part of "Pulse" +// For conditions of distribution and use, see copyright notice in LICENSE + +#include + +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + +#ifndef PULSE_SOFTWARE_IMAGE_H_ +#define PULSE_SOFTWARE_IMAGE_H_ + +#include "Soft.h" + +typedef struct SoftImage +{ +} SoftImage; + +PulseImage SoftCreateImage(PulseDevice device, const PulseImageCreateInfo* create_infos); +bool SoftIsImageFormatValid(PulseDevice device, PulseImageFormat format, PulseImageType type, PulseImageUsageFlags usage); +bool SoftCopyImageToBuffer(PulseCommandList cmd, const PulseImageRegion* src, const PulseBufferRegion* dst); +bool SoftBlitImage(PulseCommandList cmd, const PulseImageRegion* src, const PulseImageRegion* dst); +void SoftDestroyImage(PulseDevice device, PulseImage image); + +#endif // PULSE_SOFTWARE_IMAGE_H_ + +#endif // PULSE_ENABLE_SOFTWARE_BACKEND diff --git a/Sources/PulseBackend.c b/Sources/PulseBackend.c index 42ad079..d0b7c6c 100644 --- a/Sources/PulseBackend.c +++ b/Sources/PulseBackend.c @@ -17,6 +17,9 @@ #ifdef PULSE_ENABLE_WEBGPU_BACKEND #include "Backends/WebGPU/WebGPU.h" #endif +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + #include "Backends/Software/Soft.h" +#endif // Ordered by default preference static const PulseCheckBackendSupportPFN backends_supports[] = { @@ -29,6 +32,9 @@ static const PulseCheckBackendSupportPFN backends_supports[] = { #ifdef PULSE_ENABLE_WEBGPU_BACKEND WebGPUCheckSupport, #endif + #ifdef PULSE_ENABLE_SOFTWARE_BACKEND + SoftCheckSupport, + #endif PULSE_NULLPTR }; @@ -99,6 +105,9 @@ static PulseBackend PulseGetBackendFromFlag(PulseBackendBits flag) #ifdef PULSE_ENABLE_WEBGPU_BACKEND case PULSE_BACKEND_WEBGPU: return &WebGPUDriver; #endif + #ifdef PULSE_ENABLE_SOFTWARE_BACKEND + case PULSE_BACKEND_SOFTWARE: return &SoftwareDriver; + #endif default: break; } diff --git a/Sources/PulseInternal.h b/Sources/PulseInternal.h index 7103b1c..cca4ee0 100644 --- a/Sources/PulseInternal.h +++ b/Sources/PulseInternal.h @@ -178,5 +178,8 @@ void PulseLogBackend(PulseBackend backend, PulseDebugMessageSeverity type, const #ifdef PULSE_ENABLE_WEBGPU_BACKEND extern PulseBackendHandler WebGPUDriver; #endif // PULSE_ENABLE_WEBGPU_BACKEND +#ifdef PULSE_ENABLE_SOFTWARE_BACKEND + extern PulseBackendHandler SoftwareDriver; +#endif // PULSE_ENABLE_SOFTWARE_BACKEND #endif // PULSE_INTERNAL_H_ diff --git a/Xmake/packages/s/spirv-vm/xmake.lua b/Xmake/packages/s/spirv-vm/xmake.lua new file mode 100644 index 0000000..14cced3 --- /dev/null +++ b/Xmake/packages/s/spirv-vm/xmake.lua @@ -0,0 +1,30 @@ +package("spirv-vm") + set_homepage("https://github.com/dfranx/SPIRV-VM/") + set_description("A Virtual machine for executing SPIR-V.") + set_license("MIT") + + add_urls("https://github.com/dfranx/SPIRV-VM.git") + + on_install(function (package) + os.cp("inc/spvm", package:installdir("include")) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("spirv-vm") + set_kind("$(kind)") + add_files("src/**.c") + add_includedirs("inc/") + --add_headerfiles("inc/**.h") + ]]) + import("package.tools.xmake").install(package) + end) + + on_test(function (package) + assert(package:check_csnippets({test = [[ + #include + void test() + { + spvm_context_t ctx = spvm_context_initialize(); + spvm_context_deinitialize(ctx); + } + ]]})) + end) diff --git a/Xmake/packages/t/tiny-c-thread/xmake.lua b/Xmake/packages/t/tiny-c-thread/xmake.lua index 5238675..afc5e6a 100644 --- a/Xmake/packages/t/tiny-c-thread/xmake.lua +++ b/Xmake/packages/t/tiny-c-thread/xmake.lua @@ -1,21 +1,21 @@ package("tiny-c-thread") set_homepage("https://github.com/tinycthread/tinycthread") - set_description("A small, portable implementation of the C11 threads API.") - set_license("MIT") + set_description("A small, portable implementation of the C11 threads API.") + set_license("MIT") - add_urls("https://github.com/tinycthread/tinycthread.git") + add_urls("https://github.com/tinycthread/tinycthread.git") on_install(function (package) - io.writefile("xmake.lua", [[ - add_rules("mode.debug", "mode.release") - target("tiny-c-thread") - set_kind("static") - add_files("source/*.c") - add_headerfiles("source/*.h") - ]]) - import("package.tools.xmake").install(package) - end) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + target("tiny-c-thread") + set_kind("static") + add_files("source/*.c") + add_headerfiles("source/*.h") + ]]) + import("package.tools.xmake").install(package) + end) - on_test(function (package) - assert(package:has_ctypes("thrd_t", {configs = {languages = "c11"}, includes = "tinycthread.h"})) - end) + on_test(function (package) + assert(package:has_ctypes("thrd_t", {configs = {languages = "c11"}, includes = "tinycthread.h"})) + end) diff --git a/xmake.lua b/xmake.lua index 297d30b..19094e2 100644 --- a/xmake.lua +++ b/xmake.lua @@ -29,6 +29,11 @@ local backends = { add_packages("wgpu-native") end end + }, + Software = { + option = "software", + default = true, + packages = { "spirv-vm" } } }