mirror of
https://github.com/Kbz-8/Pulse.git
synced 2026-01-11 15:33:34 +00:00
working on command lists
This commit is contained in:
@@ -1,20 +1,31 @@
|
|||||||
#include <Pulse.h>
|
#include <Pulse.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define CHECK_PULSE_HANDLE_RETVAL(handle, retval) \
|
void DebugCallBack(PulseDebugMessageSeverity severity, const char* message)
|
||||||
if(handle == PULSE_NULL_HANDLE) \
|
{
|
||||||
{ \
|
if(severity == PULSE_DEBUG_MESSAGE_SEVERITY_ERROR)
|
||||||
fprintf(stderr, "Error: %s", PulseVerbaliseErrorType(PulseGetLastErrorType())); \
|
{
|
||||||
return retval; \
|
fprintf(stderr, "Pulse Error: %s", message);
|
||||||
} \
|
exit(1);
|
||||||
|
}
|
||||||
|
else if(severity == PULSE_DEBUG_MESSAGE_SEVERITY_WARNING)
|
||||||
|
fprintf(stderr, "Pulse Warning: %s", message);
|
||||||
|
else
|
||||||
|
printf("Pulse: %s", message);
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
PulseBackend backend = PulseLoadBackend(PULSE_BACKEND_VULKAN, PULSE_SHADER_FORMAT_SPIRV_BIT, PULSE_NO_DEBUG);
|
PulseBackend backend = PulseLoadBackend(PULSE_BACKEND_VULKAN, PULSE_SHADER_FORMAT_SPIRV_BIT, PULSE_NO_DEBUG);
|
||||||
CHECK_PULSE_HANDLE_RETVAL(backend, 1);
|
if(backend == PULSE_NULL_HANDLE)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Pulse: could not create backend");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
PulseSetDebugCallback(backend, DebugCallBack);
|
||||||
PulseDevice device = PulseCreateDevice(backend, NULL, 0);
|
PulseDevice device = PulseCreateDevice(backend, NULL, 0);
|
||||||
CHECK_PULSE_HANDLE_RETVAL(device, 1);
|
|
||||||
|
|
||||||
PulseDestroyDevice(device);
|
PulseDestroyDevice(device);
|
||||||
PulseUnloadBackend(backend);
|
PulseUnloadBackend(backend);
|
||||||
|
|||||||
@@ -90,23 +90,6 @@ typedef enum PulseDebugMessageSeverity
|
|||||||
PULSE_DEBUG_MESSAGE_SEVERITY_ERROR
|
PULSE_DEBUG_MESSAGE_SEVERITY_ERROR
|
||||||
} PulseDebugMessageSeverity;
|
} PulseDebugMessageSeverity;
|
||||||
|
|
||||||
typedef enum PulseDebugMessageType
|
|
||||||
{
|
|
||||||
PULSE_DEBUG_MESSAGE_TYPE_GENERAL,
|
|
||||||
PULSE_DEBUG_MESSAGE_TYPE_PERFORMANCE
|
|
||||||
} PulseDebugMessageType;
|
|
||||||
|
|
||||||
typedef enum PulseErrorType
|
|
||||||
{
|
|
||||||
PULSE_ERROR_NONE,
|
|
||||||
|
|
||||||
PULSE_ERROR_BACKENDS_CANDIDATES_SHADER_FORMAT_MISMATCH,
|
|
||||||
PULSE_ERROR_INITIALIZATION_FAILED,
|
|
||||||
PULSE_ERROR_INVALID_HANDLE,
|
|
||||||
PULSE_ERROR_ALLOCATION_FAILED,
|
|
||||||
PULSE_ERROR_DEVICE_LOST,
|
|
||||||
} PulseErrorType;
|
|
||||||
|
|
||||||
typedef enum PulseImageType
|
typedef enum PulseImageType
|
||||||
{
|
{
|
||||||
PULSE_IMAGE_TYPE_2D,
|
PULSE_IMAGE_TYPE_2D,
|
||||||
@@ -264,7 +247,7 @@ typedef struct PulseImageRegion
|
|||||||
} PulseImageRegion;
|
} PulseImageRegion;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
typedef void (*PulseDebugCallbackPFN)(PulseDebugMessageSeverity, PulseDebugMessageType, const char*);
|
typedef void (*PulseDebugCallbackPFN)(PulseDebugMessageSeverity, const char*);
|
||||||
|
|
||||||
PULSE_API PulseBackend PulseLoadBackend(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used, PulseDebugLevel debug_level);
|
PULSE_API PulseBackend PulseLoadBackend(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used, PulseDebugLevel debug_level);
|
||||||
PULSE_API void PulseUnloadBackend(PulseBackend backend);
|
PULSE_API void PulseUnloadBackend(PulseBackend backend);
|
||||||
@@ -289,15 +272,12 @@ PULSE_API void PulseEndGeneralPass(PulseGeneralPass pass);
|
|||||||
PULSE_API PulseFence PulseCreateFence(PulseDevice device);
|
PULSE_API PulseFence PulseCreateFence(PulseDevice device);
|
||||||
PULSE_API void PulseDestroyFence(PulseDevice device, PulseFence fence);
|
PULSE_API void PulseDestroyFence(PulseDevice device, PulseFence fence);
|
||||||
PULSE_API bool PulseIsFenceReady(PulseDevice device, PulseFence fence);
|
PULSE_API bool PulseIsFenceReady(PulseDevice device, PulseFence fence);
|
||||||
PULSE_API bool PulseWaitForFences(PulseDevice device, PulseFence* const* fences, uint32_t fences_count, bool wait_for_all);
|
PULSE_API bool PulseWaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all);
|
||||||
|
|
||||||
PULSE_API PulseComputePipeline PulseCreateComputePipeline(PulseDevice device, const PulseComputePipelineCreateInfo* info);
|
PULSE_API PulseComputePipeline PulseCreateComputePipeline(PulseDevice device, const PulseComputePipelineCreateInfo* info);
|
||||||
PULSE_API void PulseDestroyComputePipeline(PulseDevice device, PulseComputePipeline pipeline);
|
PULSE_API void PulseDestroyComputePipeline(PulseDevice device, PulseComputePipeline pipeline);
|
||||||
PULSE_API void PulseBindComputePipeline(PulseComputePass pass, PulseComputePipeline pipeline);
|
PULSE_API void PulseBindComputePipeline(PulseComputePass pass, PulseComputePipeline pipeline);
|
||||||
|
|
||||||
PULSE_API PulseErrorType PulseGetLastErrorType(); // /!\ Warning /!\ Call to this function resets the internal last error variable
|
|
||||||
PULSE_API const char* PulseVerbaliseErrorType(PulseErrorType error);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,10 +44,13 @@ extern "C" {
|
|||||||
#define PULSE_PLAT_WINDOWS
|
#define PULSE_PLAT_WINDOWS
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#define PULSE_PLAT_LINUX
|
#define PULSE_PLAT_LINUX
|
||||||
|
#define PULSE_PLAT_POSIX
|
||||||
#elif defined(__APPLE__) && defined(__MACH__)
|
#elif defined(__APPLE__) && defined(__MACH__)
|
||||||
#define PULSE_PLAT_MACOS
|
#define PULSE_PLAT_MACOS
|
||||||
|
#define PULSE_PLAT_POSIX
|
||||||
#elif defined(unix) || defined(__unix__) || defined(__unix)
|
#elif defined(unix) || defined(__unix__) || defined(__unix)
|
||||||
#define PULSE_PLAT_UNIX
|
#define PULSE_PLAT_UNIX
|
||||||
|
#define PULSE_PLAT_POSIX
|
||||||
#else
|
#else
|
||||||
#error "Unknown environment (not Windows, not Linux, not MacOS, not Unix)"
|
#error "Unknown environment (not Windows, not Linux, not MacOS, not Unix)"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
32
Sources/Backends/Vulkan/VulkanCommandList.h
git.filemode.normal_file
32
Sources/Backends/Vulkan/VulkanCommandList.h
git.filemode.normal_file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifdef PULSE_ENABLE_VULKAN_BACKEND
|
||||||
|
|
||||||
|
#ifndef PULSE_VULKAN_COMMAND_LIST_H_
|
||||||
|
#define PULSE_VULKAN_COMMAND_LIST_H_
|
||||||
|
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
#include <Pulse.h>
|
||||||
|
#include "../../PulseInternal.h"
|
||||||
|
#include "VulkanCommandPool.h"
|
||||||
|
|
||||||
|
typedef struct VulkanCommandList
|
||||||
|
{
|
||||||
|
PulseDevice device;
|
||||||
|
VulkanCommandPool* pool;
|
||||||
|
PulseThreadID thread_id;
|
||||||
|
VkCommandBuffer cmd;
|
||||||
|
|
||||||
|
PulseComputePipeline* compute_pipelines_bound;
|
||||||
|
uint32_t compute_pipelines_bound_capacity;
|
||||||
|
uint32_t compute_pipelines_bound_size;
|
||||||
|
} VulkanCommandList;
|
||||||
|
|
||||||
|
void VulkanInitCommandList(VulkanCommandPool* pool);
|
||||||
|
|
||||||
|
#endif // PULSE_VULKAN_COMMAND_LIST_H_
|
||||||
|
|
||||||
|
#endif // PULSE_ENABLE_VULKAN_BACKEND
|
||||||
47
Sources/Backends/Vulkan/VulkanCommandPool.c
git.filemode.normal_file
47
Sources/Backends/Vulkan/VulkanCommandPool.c
git.filemode.normal_file
@@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#include "Vulkan.h"
|
||||||
|
#include "VulkanCommandPool.h"
|
||||||
|
#include "VulkanDevice.h"
|
||||||
|
#include "VulkanQueue.h"
|
||||||
|
|
||||||
|
bool VulkanInitCommandPool(PulseDevice device, VulkanCommandPool* pool, VulkanQueueType queue_type)
|
||||||
|
{
|
||||||
|
PULSE_CHECK_HANDLE_RETVAL(device, false);
|
||||||
|
PULSE_CHECK_PTR_RETVAL(pool, false);
|
||||||
|
|
||||||
|
VulkanDevice* vulkan_device = VULKAN_RETRIEVE_DRIVER_DATA_AS(device, VulkanDevice*);
|
||||||
|
|
||||||
|
VkCommandPoolCreateInfo create_info = {};
|
||||||
|
create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
|
create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
||||||
|
create_info.queueFamilyIndex = vulkan_device->queues[queue_type]->queue_family_index;
|
||||||
|
create_info.pNext = PULSE_NULLPTR;
|
||||||
|
CHECK_VK_RETVAL(vulkan_device->vkCreateCommandPool(vulkan_device->device, &create_info, PULSE_NULLPTR, &pool->pool), PULSE_ERROR_INITIALIZATION_FAILED, false);
|
||||||
|
|
||||||
|
pool->thread_id = PulseGetThreadID();
|
||||||
|
|
||||||
|
pool->available_command_lists = PULSE_NULLPTR;
|
||||||
|
pool->available_command_lists_capacity = 0;
|
||||||
|
pool->available_command_lists_size = 0;
|
||||||
|
|
||||||
|
pool->device = device;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VulkanUninitCommandPool(VulkanCommandPool* pool)
|
||||||
|
{
|
||||||
|
PULSE_CHECK_PTR(pool);
|
||||||
|
|
||||||
|
VulkanDevice* vulkan_device = VULKAN_RETRIEVE_DRIVER_DATA_AS(pool->device, VulkanDevice*);
|
||||||
|
vulkan_device->vkDestroyCommandPool(vulkan_device->device, pool->pool, PULSE_NULLPTR);
|
||||||
|
if(pool->available_command_lists != PULSE_NULLPTR)
|
||||||
|
free(pool->available_command_lists);
|
||||||
|
pool->thread_id = 0;
|
||||||
|
pool->available_command_lists = PULSE_NULLPTR;
|
||||||
|
pool->available_command_lists_capacity = 0;
|
||||||
|
pool->available_command_lists_size = 0;
|
||||||
|
}
|
||||||
35
Sources/Backends/Vulkan/VulkanCommandPool.h
git.filemode.normal_file
35
Sources/Backends/Vulkan/VulkanCommandPool.h
git.filemode.normal_file
@@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifdef PULSE_ENABLE_VULKAN_BACKEND
|
||||||
|
|
||||||
|
#ifndef PULSE_VULKAN_COMMAND_POOL_H_
|
||||||
|
#define PULSE_VULKAN_COMMAND_POOL_H_
|
||||||
|
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
#include <Pulse.h>
|
||||||
|
#include "../../PulseInternal.h"
|
||||||
|
#include "VulkanEnums.h"
|
||||||
|
|
||||||
|
typedef struct VulkanCommandPool
|
||||||
|
{
|
||||||
|
PulseDevice device;
|
||||||
|
|
||||||
|
VkCommandPool pool;
|
||||||
|
VulkanQueueType queue_type;
|
||||||
|
|
||||||
|
PulseThreadID thread_id;
|
||||||
|
|
||||||
|
PulseCommandList* available_command_lists;
|
||||||
|
uint32_t available_command_lists_capacity;
|
||||||
|
uint32_t available_command_lists_size;
|
||||||
|
} VulkanCommandPool;
|
||||||
|
|
||||||
|
bool VulkanInitCommandPool(PulseDevice device, VulkanCommandPool* pool, VulkanQueueType queue_type);
|
||||||
|
void VulkanUninitCommandPool(VulkanCommandPool* pool);
|
||||||
|
|
||||||
|
#endif // PULSE_VULKAN_COMMAND_POOL_H_
|
||||||
|
|
||||||
|
#endif // PULSE_ENABLE_VULKAN_BACKEND
|
||||||
@@ -17,11 +17,14 @@
|
|||||||
#include <Pulse.h>
|
#include <Pulse.h>
|
||||||
|
|
||||||
#include "VulkanEnums.h"
|
#include "VulkanEnums.h"
|
||||||
|
#include "VulkanCommandPool.h"
|
||||||
|
|
||||||
struct VulkanQueue;
|
struct VulkanQueue;
|
||||||
|
|
||||||
typedef struct VulkanDevice
|
typedef struct VulkanDevice
|
||||||
{
|
{
|
||||||
|
VulkanCommandPool* cmd_pools;
|
||||||
|
|
||||||
struct VulkanQueue* queues[VULKAN_QUEUE_END_ENUM];
|
struct VulkanQueue* queues[VULKAN_QUEUE_END_ENUM];
|
||||||
|
|
||||||
VkPhysicalDeviceFeatures features;
|
VkPhysicalDeviceFeatures features;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright (C) 2024 kanel
|
// Copyright (C) 2024 kanel
|
||||||
|
//
|
||||||
// This file is part of "Pulse"
|
// This file is part of "Pulse"
|
||||||
// For conditions of distribution and use, see copyright notice in LICENSE
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
// This file is part of "Pulse"
|
// This file is part of "Pulse"
|
||||||
// For conditions of distribution and use, see copyright notice in LICENSE
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
#include "Pulse.h"
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
#include "Vulkan.h"
|
#include "Vulkan.h"
|
||||||
#include "VulkanDevice.h"
|
#include "VulkanDevice.h"
|
||||||
#include "VulkanFence.h"
|
#include "VulkanFence.h"
|
||||||
@@ -45,15 +46,39 @@ bool VulkanIsFenceReady(PulseDevice device, PulseFence fence)
|
|||||||
VkResult res = vulkan_device->vkGetFenceStatus(vulkan_device->device, vulkan_fence);
|
VkResult res = vulkan_device->vkGetFenceStatus(vulkan_device->device, vulkan_fence);
|
||||||
switch(res)
|
switch(res)
|
||||||
{
|
{
|
||||||
case VK_ERROR_DEVICE_LOST: PulseSetInternalError(PULSE_ERROR_DEVICE_LOST); return false;
|
|
||||||
case VK_NOT_READY: return false;
|
|
||||||
case VK_SUCCESS: return true;
|
case VK_SUCCESS: return true;
|
||||||
|
|
||||||
|
case VK_NOT_READY: return false;
|
||||||
|
case VK_ERROR_DEVICE_LOST: PulseSetInternalError(PULSE_ERROR_DEVICE_LOST); return false;
|
||||||
|
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VulkanWaitForFences(PulseDevice device, PulseFence *const *fences, uint32_t fences_count, bool wait_for_all)
|
bool VulkanWaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all)
|
||||||
{
|
{
|
||||||
|
if(fences_count == 0)
|
||||||
|
return true;
|
||||||
|
VulkanDevice* vulkan_device = VULKAN_RETRIEVE_DRIVER_DATA_AS(device, VulkanDevice*);
|
||||||
|
if(vulkan_device == PULSE_NULLPTR || vulkan_device->device == VK_NULL_HANDLE)
|
||||||
|
return false;
|
||||||
|
VkFence* vulkan_fences = (VkFence*)calloc(fences_count, sizeof(VkFence));
|
||||||
|
PULSE_CHECK_ALLOCATION_RETVAL(vulkan_fences, false);
|
||||||
|
for(uint32_t i = 0; i < fences_count; i++)
|
||||||
|
vulkan_fences[i] = VULKAN_RETRIEVE_DRIVER_DATA_AS(((PulseFence)fences + i), VkFence);
|
||||||
|
VkResult result = vulkan_device->vkWaitForFences(vulkan_device->device, fences_count, vulkan_fences, wait_for_all, UINT64_MAX);
|
||||||
|
free(vulkan_fences);
|
||||||
|
switch(result)
|
||||||
|
{
|
||||||
|
case VK_SUCCESS: break;
|
||||||
|
case VK_TIMEOUT: break;
|
||||||
|
|
||||||
|
case VK_ERROR_DEVICE_LOST: PulseSetInternalError(PULSE_ERROR_DEVICE_LOST); return false;
|
||||||
|
case VK_ERROR_OUT_OF_HOST_MEMORY: PulseSetInternalError(PULSE_ERROR_CPU_ALLOCATION_FAILED); return false;
|
||||||
|
case VK_ERROR_OUT_OF_DEVICE_MEMORY: PulseSetInternalError(PULSE_ERROR_DEVICE_ALLOCATION_FAILED); return false;
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,15 +7,13 @@
|
|||||||
#ifndef PULSE_VULKAN_FENCE_H_
|
#ifndef PULSE_VULKAN_FENCE_H_
|
||||||
#define PULSE_VULKAN_FENCE_H_
|
#define PULSE_VULKAN_FENCE_H_
|
||||||
|
|
||||||
#include <vulkan/vulkan_core.h>
|
|
||||||
|
|
||||||
#include <Pulse.h>
|
#include <Pulse.h>
|
||||||
#include "VulkanDevice.h"
|
#include "VulkanDevice.h"
|
||||||
|
|
||||||
PulseFence VulkanCreateFence(PulseDevice device);
|
PulseFence VulkanCreateFence(PulseDevice device);
|
||||||
void VulkanDestroyFence(PulseDevice device, PulseFence fence);
|
void VulkanDestroyFence(PulseDevice device, PulseFence fence);
|
||||||
bool VulkanIsFenceReady(PulseDevice device, PulseFence fence);
|
bool VulkanIsFenceReady(PulseDevice device, PulseFence fence);
|
||||||
bool VulkanWaitForFences(PulseDevice device, PulseFence *const *fences, uint32_t fences_count, bool wait_for_all);
|
bool VulkanWaitForFences(PulseDevice device, const PulseFence* fences, uint32_t fences_count, bool wait_for_all);
|
||||||
|
|
||||||
#endif // PULSE_VULKAN_FENCE_H_
|
#endif // PULSE_VULKAN_FENCE_H_
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// This file is part of "Pulse"
|
// This file is part of "Pulse"
|
||||||
// For conditions of distribution and use, see copyright notice in LICENSE
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Pulse.h>
|
#include <Pulse.h>
|
||||||
#include "PulseInternal.h"
|
#include "PulseInternal.h"
|
||||||
|
|
||||||
@@ -23,11 +25,36 @@ static const PulseCheckBackendSupportPFN backends_supports[] = {
|
|||||||
PULSE_NULLPTR
|
PULSE_NULLPTR
|
||||||
};
|
};
|
||||||
|
|
||||||
static PulseErrorType last_error = PULSE_ERROR_NONE;
|
struct
|
||||||
|
{
|
||||||
void PulseSetInternalError(PulseErrorType error)
|
char file[1024];
|
||||||
|
char function[1024];
|
||||||
|
PulseErrorType type;
|
||||||
|
int line;
|
||||||
|
} last_error = { .file = { 0 }, .function = { 0 }, .type = PULSE_ERROR_NONE, .line = -1 };
|
||||||
|
|
||||||
|
void PulseSetInternalErrorBackend(PulseErrorType error, const char* file, const char* function, int line)
|
||||||
|
{
|
||||||
|
strcpy(last_error.file, file);
|
||||||
|
strcpy(last_error.function, function);
|
||||||
|
last_error.type = error;
|
||||||
|
last_error.line = line;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulseLogErrorBackend(PulseBackend backend, PulseErrorType error, const char* file, const char* function, int line)
|
||||||
|
{
|
||||||
|
if(backend == PULSE_NULL_HANDLE)
|
||||||
|
return;
|
||||||
|
if(!backend->PFN_UserDebugCallback)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulseLogWarningBackend(PulseBackend backend, PulseWarningType warning, const char* file, const char* function, int line)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulseLogInfoBackend(PulseBackend backend, const char* message, const char* file, const char* function, int line)
|
||||||
{
|
{
|
||||||
last_error = error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PulseBackendFlags PulseSelectBackend(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used)
|
static PulseBackendFlags PulseSelectBackend(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used)
|
||||||
@@ -47,6 +74,10 @@ static PulseBackendFlags PulseSelectBackend(PulseBackendFlags backend_candidates
|
|||||||
return PULSE_BACKEND_INVALID;
|
return PULSE_BACKEND_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* PulseVerbaliseErrorType(PulseErrorType error)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static PulseBackend PulseGetBackendFromFlag(PulseBackendBits flag)
|
static PulseBackend PulseGetBackendFromFlag(PulseBackendBits flag)
|
||||||
{
|
{
|
||||||
switch(flag)
|
switch(flag)
|
||||||
@@ -58,9 +89,9 @@ static PulseBackend PulseGetBackendFromFlag(PulseBackendBits flag)
|
|||||||
case PULSE_BACKEND_VULKAN: return &D3D11Driver;
|
case PULSE_BACKEND_VULKAN: return &D3D11Driver;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default: return PULSE_NULL_HANDLE;
|
default: break;
|
||||||
}
|
}
|
||||||
return PULSE_NULL_HANDLE; // To avoid warnings
|
return PULSE_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PULSE_API PulseBackend PulseLoadBackend(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used, PulseDebugLevel debug_level)
|
PULSE_API PulseBackend PulseLoadBackend(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used, PulseDebugLevel debug_level)
|
||||||
@@ -74,6 +105,7 @@ PULSE_API PulseBackend PulseLoadBackend(PulseBackendFlags backend_candidates, Pu
|
|||||||
return PULSE_NULL_HANDLE;
|
return PULSE_NULL_HANDLE;
|
||||||
if(!backend->PFN_LoadBackend(debug_level))
|
if(!backend->PFN_LoadBackend(debug_level))
|
||||||
return PULSE_NULL_HANDLE;
|
return PULSE_NULL_HANDLE;
|
||||||
|
backend->PFN_UserDebugCallback = PULSE_NULLPTR;
|
||||||
return (PulseBackend)backend;
|
return (PulseBackend)backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,24 +128,8 @@ PULSE_API bool PulseSupportsBackend(PulseBackendFlags backend_candidates, PulseS
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PULSE_API PulseErrorType PulseGetLastErrorType()
|
PULSE_API void PulseSetDebugCallback(PulseBackend backend, PulseDebugCallbackPFN callback)
|
||||||
{
|
{
|
||||||
PulseErrorType error = last_error;
|
PULSE_CHECK_HANDLE(backend);
|
||||||
last_error = PULSE_ERROR_NONE;
|
backend->PFN_UserDebugCallback = callback;
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
PULSE_API const char* PulseVerbaliseErrorType(PulseErrorType error)
|
|
||||||
{
|
|
||||||
switch(error)
|
|
||||||
{
|
|
||||||
case PULSE_ERROR_NONE: return "no error";
|
|
||||||
case PULSE_ERROR_BACKENDS_CANDIDATES_SHADER_FORMAT_MISMATCH: return "no backend candidates support the required shader formats";
|
|
||||||
case PULSE_ERROR_INITIALIZATION_FAILED: return "initialization of an object could not be completed for implementation-specific reasons";
|
|
||||||
case PULSE_ERROR_ALLOCATION_FAILED: return "an internal allocation failed";
|
|
||||||
case PULSE_ERROR_DEVICE_LOST: return "device has been lost";
|
|
||||||
|
|
||||||
default: return "invalid error type";
|
|
||||||
};
|
|
||||||
return PULSE_NULLPTR; // To avoid warnings, should be unreachable
|
|
||||||
}
|
}
|
||||||
|
|||||||
32
Sources/PulseDebug.c
git.filemode.normal_file
32
Sources/PulseDebug.c
git.filemode.normal_file
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#include <PulseProfile.h>
|
||||||
|
#include "PulseDebug.h"
|
||||||
|
|
||||||
|
const char* PulseVerbaliseErrorType(PulseErrorType error)
|
||||||
|
{
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case PULSE_ERROR_BACKENDS_CANDIDATES_SHADER_FORMAT_MISMATCH: return "no backend candidates support the required shader formats";
|
||||||
|
case PULSE_ERROR_INITIALIZATION_FAILED: return "initialization of an object could not be completed for implementation-specific reasons";
|
||||||
|
case PULSE_ERROR_CPU_ALLOCATION_FAILED: return "a CPU allocation failed";
|
||||||
|
case PULSE_ERROR_DEVICE_ALLOCATION_FAILED: return "a device allocation failed";
|
||||||
|
case PULSE_ERROR_DEVICE_LOST: return "device has been lost";
|
||||||
|
case PULSE_ERROR_INVALID_INTERNAL_POINTER: return "invalid internal pointer";
|
||||||
|
case PULSE_ERROR_INVALID_HANDLE: return "invalid handle";
|
||||||
|
|
||||||
|
default: return "invalid error type";
|
||||||
|
};
|
||||||
|
return PULSE_NULLPTR; // To avoid warnings, should be unreachable
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* PulseVerbaliseWarningType(PulseWarningType warning)
|
||||||
|
{
|
||||||
|
switch(warning)
|
||||||
|
{
|
||||||
|
default: return "invalid warning type";
|
||||||
|
};
|
||||||
|
return PULSE_NULLPTR; // To avoid warnings, should be unreachable
|
||||||
|
}
|
||||||
13
Sources/PulseDebug.h
git.filemode.normal_file
13
Sources/PulseDebug.h
git.filemode.normal_file
@@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifndef PULSE_DEBUG_H_
|
||||||
|
#define PULSE_DEBUG_H_
|
||||||
|
|
||||||
|
#include "PulseEnums.h"
|
||||||
|
|
||||||
|
const char* PulseVerbaliseErrorType(PulseErrorType error);
|
||||||
|
const char* PulseVerbaliseWarningType(PulseWarningType warning);
|
||||||
|
|
||||||
|
#endif
|
||||||
56
Sources/PulseDefs.h
git.filemode.normal_file
56
Sources/PulseDefs.h
git.filemode.normal_file
@@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifndef PULSE_DEFS_H_
|
||||||
|
#define PULSE_DEFS_H_
|
||||||
|
|
||||||
|
#include <Pulse.h>
|
||||||
|
|
||||||
|
#define PulseStaticAllocStack(size) ((char[size]){ 0 })
|
||||||
|
|
||||||
|
#define PULSE_CHECK_ALLOCATION_RETVAL(ptr, retval) \
|
||||||
|
do { \
|
||||||
|
if(ptr == PULSE_NULLPTR) \
|
||||||
|
{ \
|
||||||
|
PulseSetInternalError(PULSE_ERROR_CPU_ALLOCATION_FAILED); \
|
||||||
|
return retval; \
|
||||||
|
} \
|
||||||
|
} while(0); \
|
||||||
|
|
||||||
|
#define PULSE_CHECK_ALLOCATION(ptr) PULSE_CHECK_ALLOCATION_RETVAL(ptr, )
|
||||||
|
|
||||||
|
#define PULSE_CHECK_HANDLE_RETVAL(handle, retval) \
|
||||||
|
do { \
|
||||||
|
if(handle == PULSE_NULL_HANDLE) \
|
||||||
|
{ \
|
||||||
|
PulseSetInternalError(PULSE_ERROR_INVALID_HANDLE); \
|
||||||
|
return retval; \
|
||||||
|
} \
|
||||||
|
} while(0); \
|
||||||
|
|
||||||
|
#define PULSE_CHECK_HANDLE(handle) PULSE_CHECK_HANDLE_RETVAL(handle, )
|
||||||
|
|
||||||
|
#define PULSE_CHECK_PTR_RETVAL(ptr, retval) \
|
||||||
|
do { \
|
||||||
|
if(ptr == PULSE_NULLPTR) \
|
||||||
|
{ \
|
||||||
|
PulseSetInternalError(PULSE_ERROR_INVALID_INTERNAL_POINTER); \
|
||||||
|
return retval; \
|
||||||
|
} \
|
||||||
|
} while(0); \
|
||||||
|
|
||||||
|
#define PULSE_CHECK_PTR(handle) PULSE_CHECK_PTR_RETVAL(handle, )
|
||||||
|
|
||||||
|
#define PULSE_LOAD_DRIVER_DEVICE_FUNCTION(fn, _namespace) pulse_device->PFN_##fn = _namespace##fn;
|
||||||
|
#define PULSE_LOAD_DRIVER_DEVICE(_namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(DestroyDevice, _namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(CreateComputePipeline, _namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(DestroyComputePipeline, _namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(BindComputePipeline, _namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(CreateFence, _namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(DestroyFence, _namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(IsFenceReady, _namespace) \
|
||||||
|
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(WaitForFences, _namespace) \
|
||||||
|
|
||||||
|
#endif // PULSE_DEFS_H_
|
||||||
35
Sources/PulseEnums.h
git.filemode.normal_file
35
Sources/PulseEnums.h
git.filemode.normal_file
@@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifndef PULSE_ENUMS_H_
|
||||||
|
#define PULSE_ENUMS_H_
|
||||||
|
|
||||||
|
typedef enum PulseCommandListState
|
||||||
|
{
|
||||||
|
PULSE_COMMAND_LIST_STATE_INVALID,
|
||||||
|
PULSE_COMMAND_LIST_STATE_EMPTY,
|
||||||
|
PULSE_COMMAND_LIST_STATE_RECORDING,
|
||||||
|
PULSE_COMMAND_LIST_STATE_READY,
|
||||||
|
PULSE_COMMAND_LIST_STATE_SENT
|
||||||
|
} PulseCommandListState;
|
||||||
|
|
||||||
|
typedef enum PulseErrorType
|
||||||
|
{
|
||||||
|
PULSE_ERROR_NONE,
|
||||||
|
|
||||||
|
PULSE_ERROR_DEVICE_LOST,
|
||||||
|
PULSE_ERROR_INVALID_HANDLE,
|
||||||
|
PULSE_ERROR_INVALID_INTERNAL_POINTER,
|
||||||
|
PULSE_ERROR_INITIALIZATION_FAILED,
|
||||||
|
PULSE_ERROR_CPU_ALLOCATION_FAILED,
|
||||||
|
PULSE_ERROR_DEVICE_ALLOCATION_FAILED,
|
||||||
|
PULSE_ERROR_BACKENDS_CANDIDATES_SHADER_FORMAT_MISMATCH,
|
||||||
|
} PulseErrorType;
|
||||||
|
|
||||||
|
typedef enum PulseWarningType
|
||||||
|
{
|
||||||
|
PULSE_WARNING_NONE,
|
||||||
|
} PulseWarningType;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,48 +7,11 @@
|
|||||||
|
|
||||||
#include <Pulse.h>
|
#include <Pulse.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#include "PulsePFNs.h"
|
||||||
extern "C" {
|
#include "PulseDefs.h"
|
||||||
#endif
|
#include "PulseEnums.h"
|
||||||
|
|
||||||
#define PulseStaticAllocStack(size) ((char[size]){ 0 })
|
typedef uint64_t PulseThreadID;
|
||||||
|
|
||||||
#define PULSE_CHECK_ALLOCATION_RETVAL(ptr, retval) \
|
|
||||||
do { \
|
|
||||||
if(ptr == PULSE_NULLPTR) \
|
|
||||||
{ \
|
|
||||||
PulseSetInternalError(PULSE_ERROR_ALLOCATION_FAILED); \
|
|
||||||
return retval; \
|
|
||||||
} \
|
|
||||||
} while(0); \
|
|
||||||
|
|
||||||
#define PULSE_CHECK_ALLOCATION(ptr) PULSE_CHECK_ALLOCATION_RETVAL(ptr, )
|
|
||||||
|
|
||||||
#define PULSE_CHECK_HANDLE_RETVAL(handle, retval) \
|
|
||||||
do { \
|
|
||||||
if(handle == PULSE_NULL_HANDLE) \
|
|
||||||
{ \
|
|
||||||
PulseSetInternalError(PULSE_ERROR_INVALID_HANDLE); \
|
|
||||||
return retval; \
|
|
||||||
} \
|
|
||||||
} while(0); \
|
|
||||||
|
|
||||||
#define PULSE_CHECK_HANDLE(handle) PULSE_CHECK_HANDLE_RETVAL(handle, )
|
|
||||||
|
|
||||||
typedef PulseBackendFlags (*PulseCheckBackendSupportPFN)(PulseBackendFlags, PulseShaderFormatsFlags);
|
|
||||||
|
|
||||||
typedef bool (*PulseLoadBackendPFN)(PulseDebugLevel);
|
|
||||||
typedef void (*PulseUnloadBackendPFN)(PulseBackend);
|
|
||||||
typedef PulseDevice (*PulseCreateDevicePFN)(PulseBackend, PulseDevice*, uint32_t);
|
|
||||||
|
|
||||||
typedef void (*PulseDestroyDevicePFN)(PulseDevice);
|
|
||||||
typedef PulseComputePipeline (*PulseCreateComputePipelinePFN)(PulseDevice, const PulseComputePipelineCreateInfo*);
|
|
||||||
typedef void (*PulseBindComputePipelinePFN)(PulseComputePass, PulseComputePipeline);
|
|
||||||
typedef void (*PulseDestroyComputePipelinePFN)(PulseDevice, PulseComputePipeline);
|
|
||||||
typedef PulseFence (*PulseCreateFencePFN)(PulseDevice device);
|
|
||||||
typedef void (*PulseDestroyFencePFN)(PulseDevice device, PulseFence fence);
|
|
||||||
typedef bool (*PulseIsFenceReadyPFN)(PulseDevice device, PulseFence fence);
|
|
||||||
typedef bool (*PulseWaitForFencesPFN)(PulseDevice device, PulseFence* const* fences, uint32_t fences_count, bool wait_for_all);
|
|
||||||
|
|
||||||
typedef struct PulseBackendHandler
|
typedef struct PulseBackendHandler
|
||||||
{
|
{
|
||||||
@@ -61,8 +24,32 @@ typedef struct PulseBackendHandler
|
|||||||
PulseBackendFlags backend;
|
PulseBackendFlags backend;
|
||||||
PulseShaderFormatsFlags supported_shader_formats;
|
PulseShaderFormatsFlags supported_shader_formats;
|
||||||
void* driver_data;
|
void* driver_data;
|
||||||
|
PulseDebugCallbackPFN PFN_UserDebugCallback;
|
||||||
} PulseBackendHandler;
|
} PulseBackendHandler;
|
||||||
|
|
||||||
|
typedef struct PulseBufferHandler
|
||||||
|
{
|
||||||
|
void* driver_data;
|
||||||
|
} PulseBufferHandler;
|
||||||
|
|
||||||
|
typedef struct PulseCommandListHandler
|
||||||
|
{
|
||||||
|
PulseDevice device;
|
||||||
|
void* driver_data;
|
||||||
|
PulseCommandListState state;
|
||||||
|
bool is_compute_pipeline_bound;
|
||||||
|
} PulseCommandListHandler;
|
||||||
|
|
||||||
|
typedef struct PulseComputePassHandler
|
||||||
|
{
|
||||||
|
void* driver_data;
|
||||||
|
} PulseComputePassHandler;
|
||||||
|
|
||||||
|
typedef struct PulseComputePipelineHandler
|
||||||
|
{
|
||||||
|
void* driver_data;
|
||||||
|
} PulseComputePipelineHandler;
|
||||||
|
|
||||||
typedef struct PulseDeviceHandler
|
typedef struct PulseDeviceHandler
|
||||||
{
|
{
|
||||||
// PFNs
|
// PFNs
|
||||||
@@ -85,18 +72,25 @@ typedef struct PulseFenceHandler
|
|||||||
void* driver_data;
|
void* driver_data;
|
||||||
} PulseFenceHandler;
|
} PulseFenceHandler;
|
||||||
|
|
||||||
void PulseSetInternalError(PulseErrorType error);
|
typedef struct PulseGeneralPassHandler
|
||||||
|
{
|
||||||
|
void* driver_data;
|
||||||
|
} PulseGeneralPassHandler;
|
||||||
|
|
||||||
#define PULSE_LOAD_DRIVER_DEVICE_FUNCTION(fn, _namespace) pulse_device->PFN_##fn = _namespace##fn;
|
typedef struct PulseImageHandler
|
||||||
#define PULSE_LOAD_DRIVER_DEVICE(_namespace) \
|
{
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(DestroyDevice, _namespace) \
|
void* driver_data;
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(CreateComputePipeline, _namespace) \
|
} PulseImageHandler;
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(DestroyComputePipeline, _namespace) \
|
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(BindComputePipeline, _namespace) \
|
PulseThreadID PulseGetThreadID();
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(CreateFence, _namespace) \
|
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(DestroyFence, _namespace) \
|
void PulseLogErrorBackend(PulseBackend backend, PulseErrorType error, const char* file, const char* function, int line);
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(IsFenceReady, _namespace) \
|
void PulseLogWarningBackend(PulseBackend backend, PulseWarningType warning, const char* file, const char* function, int line);
|
||||||
PULSE_LOAD_DRIVER_DEVICE_FUNCTION(WaitForFences, _namespace) \
|
void PulseLogInfoBackend(PulseBackend backend, const char* message, const char* file, const char* function, int line);
|
||||||
|
|
||||||
|
#define PulseLogError(backend, type) PulseSetInternalErrorBackend(backend, type, __FILE__, __FUNCTION__, __LINE__)
|
||||||
|
#define PulseLogWarning(backend, type) PulseSetInternalErrorBackend(backend, type, __FILE__, __FUNCTION__, __LINE__)
|
||||||
|
#define PulseLogInfo(backend, msg) PulseSetInternalErrorBackend(backend, msg, __FILE__, __FUNCTION__, __LINE__)
|
||||||
|
|
||||||
#ifdef PULSE_ENABLE_VULKAN_BACKEND
|
#ifdef PULSE_ENABLE_VULKAN_BACKEND
|
||||||
extern PulseBackendHandler VulkanDriver;
|
extern PulseBackendHandler VulkanDriver;
|
||||||
@@ -105,8 +99,4 @@ void PulseSetInternalError(PulseErrorType error);
|
|||||||
extern PulseBackendHandler D3D11Driver;
|
extern PulseBackendHandler D3D11Driver;
|
||||||
#endif // PULSE_ENABLE_D3D11_BACKEND
|
#endif // PULSE_ENABLE_D3D11_BACKEND
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // PULSE_INTERNAL_H_
|
#endif // PULSE_INTERNAL_H_
|
||||||
|
|||||||
25
Sources/PulsePFNs.h
git.filemode.normal_file
25
Sources/PulsePFNs.h
git.filemode.normal_file
@@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifndef PULSE_PFNS_H_
|
||||||
|
#define PULSE_PFNS_H_
|
||||||
|
|
||||||
|
#include <Pulse.h>
|
||||||
|
|
||||||
|
typedef PulseBackendFlags (*PulseCheckBackendSupportPFN)(PulseBackendFlags, PulseShaderFormatsFlags);
|
||||||
|
|
||||||
|
typedef bool (*PulseLoadBackendPFN)(PulseDebugLevel);
|
||||||
|
typedef void (*PulseUnloadBackendPFN)(PulseBackend);
|
||||||
|
typedef PulseDevice (*PulseCreateDevicePFN)(PulseBackend, PulseDevice*, uint32_t);
|
||||||
|
|
||||||
|
typedef void (*PulseDestroyDevicePFN)(PulseDevice);
|
||||||
|
typedef PulseComputePipeline (*PulseCreateComputePipelinePFN)(PulseDevice, const PulseComputePipelineCreateInfo*);
|
||||||
|
typedef void (*PulseBindComputePipelinePFN)(PulseComputePass, PulseComputePipeline);
|
||||||
|
typedef void (*PulseDestroyComputePipelinePFN)(PulseDevice, PulseComputePipeline);
|
||||||
|
typedef PulseFence (*PulseCreateFencePFN)(PulseDevice);
|
||||||
|
typedef void (*PulseDestroyFencePFN)(PulseDevice, PulseFence);
|
||||||
|
typedef bool (*PulseIsFenceReadyPFN)(PulseDevice, PulseFence);
|
||||||
|
typedef bool (*PulseWaitForFencesPFN)(PulseDevice, const PulseFence*, uint32_t, bool);
|
||||||
|
|
||||||
|
#endif // PULSE_PFNS_H_
|
||||||
15
Sources/PulsePosix.c
git.filemode.normal_file
15
Sources/PulsePosix.c
git.filemode.normal_file
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#include "PulseInternal.h"
|
||||||
|
#include "PulsePosix.h"
|
||||||
|
|
||||||
|
#ifdef PULSE_PLAT_POSIX
|
||||||
|
|
||||||
|
PulseThreadID PulseGetThreadID()
|
||||||
|
{
|
||||||
|
return (PulseThreadID)pthread_self();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PULSE_PLAT_POSIX
|
||||||
17
Sources/PulsePosix.h
git.filemode.normal_file
17
Sources/PulsePosix.h
git.filemode.normal_file
@@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifndef PULSE_POSIX_H_
|
||||||
|
#define PULSE_POSIX_H_
|
||||||
|
|
||||||
|
#include <PulseProfile.h>
|
||||||
|
#include "PulseInternal.h"
|
||||||
|
|
||||||
|
#ifdef PULSE_PLAT_POSIX
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#endif // PULSE_PLAT_WINDOWS
|
||||||
|
|
||||||
|
#endif // PULSE_POSIX_H_
|
||||||
15
Sources/PulseWindows.c
git.filemode.normal_file
15
Sources/PulseWindows.c
git.filemode.normal_file
@@ -0,0 +1,15 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#include "PulseInternal.h"
|
||||||
|
#include "PulseWindows.h"
|
||||||
|
|
||||||
|
#ifdef PULSE_PLAT_WINDOWS
|
||||||
|
|
||||||
|
PulseThreadID PulseGetThreadID()
|
||||||
|
{
|
||||||
|
return (PulseThreadID)GetCurrentThreadId();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PULSE_PLAT_WINDOWS
|
||||||
18
Sources/PulseWindows.h
git.filemode.normal_file
18
Sources/PulseWindows.h
git.filemode.normal_file
@@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2024 kanel
|
||||||
|
// This file is part of "Pulse"
|
||||||
|
// For conditions of distribution and use, see copyright notice in LICENSE
|
||||||
|
|
||||||
|
#ifndef PULSE_WINDOWS_H_
|
||||||
|
#define PULSE_WINDOWS_H_
|
||||||
|
|
||||||
|
#include <PulseProfile.h>
|
||||||
|
#include "PulseInternal.h"
|
||||||
|
|
||||||
|
#ifdef PULSE_PLAT_WINDOWS
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#endif // PULSE_PLAT_WINDOWS
|
||||||
|
|
||||||
|
#endif // PULSE_WINDOWS_H_
|
||||||
@@ -41,7 +41,7 @@ end
|
|||||||
add_rules("mode.debug", "mode.release")
|
add_rules("mode.debug", "mode.release")
|
||||||
|
|
||||||
add_includedirs("Includes")
|
add_includedirs("Includes")
|
||||||
set_languages("c99", "cxx20")
|
set_languages("c11", "cxx20")
|
||||||
set_encodings("utf-8")
|
set_encodings("utf-8")
|
||||||
set_warnings("allextra")
|
set_warnings("allextra")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user