adding D3D11 base, working on Vulkan backend

This commit is contained in:
2024-10-08 09:40:39 +02:00
parent 9f753ecae3
commit 8de4b8677b
21 changed files with 755 additions and 16 deletions

View File

@@ -16,7 +16,7 @@ extern "C" {
#include "PulseProfile.h"
#define PULSE_VERSION PULSE_MAKE_VERSION(1, 0, 0)
#define PULSE_VERSION PULSE_MAKE_VERSION(0, 0, 1)
// Types
typedef uint64_t PulseDeviceSize;
@@ -35,7 +35,9 @@ PULSE_DEFINE_NULLABLE_HANDLE(PulseImage);
typedef enum PulseBackendBits
{
PULSE_BACKEND_INVALID = PULSE_BIT(1),
PULSE_BACKEND_VULKAN = PULSE_BIT(2),
PULSE_BACKEND_ANY = PULSE_BIT(2),
PULSE_BACKEND_VULKAN = PULSE_BIT(3),
PULSE_BACKEND_D3D11 = PULSE_BIT(4),
// More to come
} PulseBackendBits;
typedef PulseFlags PulseBackendFlags;
@@ -65,13 +67,30 @@ typedef PulseFlags PulseImageUsageFlags;
typedef enum PulseShaderFormatsBits
{
PULSE_SHADER_FORMAT_INVALID_BIT = PULSE_BIT(1),
PULSE_SHADER_FORMAT_SPIRV_BIT = PULSE_BIT(2),
PULSE_SHADER_FORMAT_SPIRV_BIT = PULSE_BIT(1), // Can be used by Vulkan | D3D11 backends
PULSE_SHADER_FORMAT_DXBC_BIT = PULSE_BIT(2), // Can be used by D3D11 backend only
// More to come
} PulseShaderFormatsBits;
typedef PulseFlags PulseShaderFormatsFlags;
// Enums
typedef enum PulseDebugLevel
{
PULSE_NO_DEBUG,
PULSE_LOW_DEBUG,
PULSE_HIGH_DEBUG,
PULSE_PARANOID_DEBUG // Causes every warning to be treated as error
} PulseDebugLevel;
typedef enum PulseErrorType
{
PULSE_ERROR_NONE,
PULSE_ERROR_BACKENDS_CANDIDATES_SHADER_FORMAT_MISMATCH,
PULSE_ERROR_INITIALIZATION_FAILED,
PULSE_ERROR_INVALID_HANDLE,
} PulseErrorType;
typedef enum PulseImageType
{
PULSE_IMAGE_TYPE_2D,
@@ -180,7 +199,6 @@ typedef struct PulseComputePipelineCreateInfo
const uint8_t* code;
const char* entrypoint;
PulseShaderFormatsFlags format;
uint32_t num_samplers;
uint32_t num_readonly_storage_images;
uint32_t num_readonly_storage_buffers;
uint32_t num_readwrite_storage_images;
@@ -230,10 +248,14 @@ typedef struct PulseImageRegion
} PulseImageRegion;
// Functions
PULSE_API PulseDevice PulseCreateDevice(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used);
PULSE_API PulseDevice PulseCreateDevice(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used, PulseDebugLevel debug_level);
PULSE_API void PulseDestroyDevice(PulseDevice device);
PULSE_API PulseBackendBits PulseGetBackendInUseByDevice(PulseDevice device);
PULSE_API bool PulseSupportsBackend(PulseBackendFlags backend_candidates, PulseShaderFormatsFlags shader_formats_used);
PULSE_API bool PulseDeviceSupportsSahderFormats(PulseDevice device, PulseShaderFormatsFlags shader_formats_used);
PULSE_API PulseErrorType PulseGetLastErrorType(); // /!\ Warning /!\ Call to this function resets the internal last error variable
PULSE_API const char* PulseVerbaliseErrorType(PulseErrorType error);
#ifdef __cplusplus
}

View File

@@ -7,6 +7,8 @@
#ifndef PULSE_PROFILE_H_
#define PULSE_PROFILE_H_
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -76,6 +78,42 @@ extern "C" {
#define PULSE_API
#endif
#ifndef __cplusplus // if we compile in C
#ifdef __STDC__
#ifdef __STDC_VERSION__
#if __STDC_VERSION__ == 199409L
#define PULSE_C_VERSION 1994
#elif __STDC_VERSION__ == 199901L
#define PULSE_C_VERSION 1999
#elif __STDC_VERSION__ == 201112L
#define PULSE_C_VERSION 2011
#elif __STDC_VERSION__ == 201710L
#define PULSE_C_VERSION 2017
#elif __STDC_VERSION__ == 202311L
#define PULSE_C_VERSION 2023
#else
#define PULSE_C_VERSION 0
#endif
#else
#define PULSE_C_VERSION 0
#endif
#else
#define PULSE_C_VERSION 0
#endif
#else
#define PULSE_C_VERSION 0
#endif
#if PULSE_C_VERSION >= 2023
#if defined(PULSE_COMPILER_GCC) || defined(PULSE_COMPILER_CLANG) // for now only GCC and Clang supports nullptr
#define PULSE_NULLPTR nullptr
#else
#define PULSE_NULLPTR NULL
#endif
#else
#define PULSE_NULLPTR NULL
#endif
#define PULSE_DEFINE_NULLABLE_HANDLE(object) typedef struct object##Handler* object
#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))