Refresh/include/Refresh.h

1177 lines
33 KiB
C
Raw Normal View History

2022-03-02 19:10:28 +00:00
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
2020-12-15 23:00:46 +00:00
*
* Copyright (c) 2020 Evan Hemsley
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
* Evan "cosmonaut" Hemsley <evan@moonside.games>
*
*/
2020-12-16 22:59:14 +00:00
#include <stddef.h>
2020-12-15 23:00:46 +00:00
#ifndef REFRESH_H
#define REFRESH_H
#ifdef _WIN32
#define REFRESHAPI __declspec(dllexport)
#define REFRESHCALL __cdecl
#else
#define REFRESHAPI
#define REFRESHCALL
#endif
/* -Wpedantic nameless union/struct silencing */
#ifndef REFRESHNAMELESS
#ifdef __GNUC__
#define REFRESHNAMELESS __extension__
#else
#define REFRESHNAMELESS
#endif /* __GNUC__ */
#endif /* REFRESHNAMELESS */
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
2022-03-04 01:31:33 +00:00
/* Version API */
#define REFRESH_MAJOR_VERSION 1
2022-03-04 21:18:58 +00:00
#define REFRESH_MINOR_VERSION 2
2022-03-04 21:39:31 +00:00
#define REFRESH_PATCH_VERSION 1
2022-03-04 01:31:33 +00:00
#define REFRESH_COMPILED_VERSION ( \
(REFRESH_MAJOR_VERSION * 100 * 100) + \
(REFRESH_MINOR_VERSION * 100) + \
(REFRESH_PATCH_VERSION) \
)
REFRESHAPI uint32_t Refresh_LinkedVersion(void);
2020-12-15 23:00:46 +00:00
/* Type Declarations */
2021-01-05 23:00:51 +00:00
typedef struct Refresh_Device Refresh_Device;
typedef struct Refresh_Buffer Refresh_Buffer;
typedef struct Refresh_Texture Refresh_Texture;
typedef struct Refresh_Sampler Refresh_Sampler;
typedef struct Refresh_ShaderModule Refresh_ShaderModule;
typedef struct Refresh_ComputePipeline Refresh_ComputePipeline;
typedef struct Refresh_GraphicsPipeline Refresh_GraphicsPipeline;
typedef struct Refresh_CommandBuffer Refresh_CommandBuffer;
typedef enum Refresh_PresentMode
2020-12-17 03:50:31 +00:00
{
REFRESH_PRESENTMODE_IMMEDIATE,
REFRESH_PRESENTMODE_MAILBOX,
REFRESH_PRESENTMODE_FIFO,
REFRESH_PRESENTMODE_FIFO_RELAXED
2021-01-05 23:00:51 +00:00
} Refresh_PresentMode;
2020-12-17 03:50:31 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_PrimitiveType
2020-12-16 02:29:26 +00:00
{
2022-02-25 21:42:11 +00:00
REFRESH_PRIMITIVETYPE_POINTLIST,
2020-12-16 02:29:26 +00:00
REFRESH_PRIMITIVETYPE_LINELIST,
REFRESH_PRIMITIVETYPE_LINESTRIP,
REFRESH_PRIMITIVETYPE_TRIANGLELIST,
2020-12-17 00:27:14 +00:00
REFRESH_PRIMITIVETYPE_TRIANGLESTRIP
2021-01-05 23:00:51 +00:00
} Refresh_PrimitiveType;
2020-12-16 02:29:26 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_LoadOp
2020-12-16 02:08:49 +00:00
{
2022-02-25 21:42:11 +00:00
REFRESH_LOADOP_LOAD,
REFRESH_LOADOP_CLEAR,
REFRESH_LOADOP_DONT_CARE
2021-01-05 23:00:51 +00:00
} Refresh_LoadOp;
2020-12-16 02:08:49 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_StoreOp
2020-12-16 02:08:49 +00:00
{
2022-02-25 21:42:11 +00:00
REFRESH_STOREOP_STORE,
REFRESH_STOREOP_DONT_CARE
2021-01-05 23:00:51 +00:00
} Refresh_StoreOp;
2020-12-15 23:00:46 +00:00
2021-01-06 00:19:27 +00:00
typedef enum Refresh_ClearOptionsBits
2020-12-15 23:00:46 +00:00
{
2022-02-25 21:42:11 +00:00
REFRESH_CLEAROPTIONS_COLOR = 0x00000001,
REFRESH_CLEAROPTIONS_DEPTH = 0x00000002,
REFRESH_CLEAROPTIONS_STENCIL = 0x00000004,
2021-01-06 00:19:27 +00:00
} Refresh_ClearOptionsBits;
typedef uint32_t Refresh_ClearOptions;
2020-12-15 23:00:46 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_IndexElementSize
2020-12-15 23:00:46 +00:00
{
2022-02-25 21:42:11 +00:00
REFRESH_INDEXELEMENTSIZE_16BIT,
REFRESH_INDEXELEMENTSIZE_32BIT
2021-01-05 23:00:51 +00:00
} Refresh_IndexElementSize;
2020-12-15 23:00:46 +00:00
typedef enum Refresh_TextureFormat
2021-01-03 22:53:12 +00:00
{
/* Color Formats */
2022-02-25 21:42:11 +00:00
REFRESH_TEXTUREFORMAT_R8G8B8A8,
REFRESH_TEXTUREFORMAT_B8G8R8A8,
2022-02-25 21:42:11 +00:00
REFRESH_TEXTUREFORMAT_R5G6B5,
REFRESH_TEXTUREFORMAT_A1R5G5B5,
REFRESH_TEXTUREFORMAT_B4G4R4A4,
REFRESH_TEXTUREFORMAT_BC1,
REFRESH_TEXTUREFORMAT_BC2,
REFRESH_TEXTUREFORMAT_BC3,
REFRESH_TEXTUREFORMAT_R8G8_SNORM,
REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM,
REFRESH_TEXTUREFORMAT_A2R10G10B10,
REFRESH_TEXTUREFORMAT_R16G16,
REFRESH_TEXTUREFORMAT_R16G16B16A16,
REFRESH_TEXTUREFORMAT_R8,
REFRESH_TEXTUREFORMAT_R32_SFLOAT,
REFRESH_TEXTUREFORMAT_R32G32_SFLOAT,
REFRESH_TEXTUREFORMAT_R32G32B32A32_SFLOAT,
REFRESH_TEXTUREFORMAT_R16_SFLOAT,
REFRESH_TEXTUREFORMAT_R16G16_SFLOAT,
REFRESH_TEXTUREFORMAT_R16G16B16A16_SFLOAT,
/* Depth Formats */
REFRESH_TEXTUREFORMAT_D16_UNORM,
REFRESH_TEXTUREFORMAT_D32_SFLOAT,
2022-02-25 21:42:11 +00:00
REFRESH_TEXTUREFORMAT_D16_UNORM_S8_UINT,
REFRESH_TEXTUREFORMAT_D32_SFLOAT_S8_UINT
} Refresh_TextureFormat;
2020-12-15 23:00:46 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_TextureUsageFlagBits
2020-12-28 20:15:17 +00:00
{
REFRESH_TEXTUREUSAGE_SAMPLER_BIT = 0x00000001,
REFRESH_TEXTUREUSAGE_COLOR_TARGET_BIT = 0x00000002,
REFRESH_TEXTUREUSAGE_DEPTH_STENCIL_TARGET_BIT = 0x00000004
2021-01-05 23:00:51 +00:00
} Refresh_TextureUsageFlagBits;
2021-01-05 23:00:51 +00:00
typedef uint32_t Refresh_TextureUsageFlags;
2020-12-28 20:15:17 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_SampleCount
2020-12-17 08:19:02 +00:00
{
REFRESH_SAMPLECOUNT_1,
REFRESH_SAMPLECOUNT_2,
REFRESH_SAMPLECOUNT_4,
REFRESH_SAMPLECOUNT_8,
REFRESH_SAMPLECOUNT_16,
REFRESH_SAMPLECOUNT_32,
REFRESH_SAMPLECOUNT_64
2021-01-05 23:00:51 +00:00
} Refresh_SampleCount;
2020-12-17 08:19:02 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_CubeMapFace
2020-12-15 23:00:46 +00:00
{
2022-02-25 21:42:11 +00:00
REFRESH_CUBEMAPFACE_POSITIVEX,
REFRESH_CUBEMAPFACE_NEGATIVEX,
REFRESH_CUBEMAPFACE_POSITIVEY,
REFRESH_CUBEMAPFACE_NEGATIVEY,
REFRESH_CUBEMAPFACE_POSITIVEZ,
REFRESH_CUBEMAPFACE_NEGATIVEZ
2021-01-05 23:00:51 +00:00
} Refresh_CubeMapFace;
2020-12-15 23:00:46 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_BufferUsageFlagBits
2020-12-31 04:39:47 +00:00
{
2020-12-31 06:28:37 +00:00
REFRESH_BUFFERUSAGE_VERTEX_BIT = 0x00000001,
REFRESH_BUFFERUSAGE_INDEX_BIT = 0x00000002,
REFRESH_BUFFERUSAGE_COMPUTE_BIT = 0x00000004
2021-01-05 23:00:51 +00:00
} Refresh_BufferUsageFlagBits;
2020-12-31 04:39:47 +00:00
2021-01-05 23:00:51 +00:00
typedef uint32_t Refresh_BufferUsageFlags;
2020-12-31 04:39:47 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_VertexElementFormat
2020-12-16 20:11:43 +00:00
{
REFRESH_VERTEXELEMENTFORMAT_SINGLE,
REFRESH_VERTEXELEMENTFORMAT_VECTOR2,
REFRESH_VERTEXELEMENTFORMAT_VECTOR3,
REFRESH_VERTEXELEMENTFORMAT_VECTOR4,
REFRESH_VERTEXELEMENTFORMAT_COLOR,
REFRESH_VERTEXELEMENTFORMAT_BYTE4,
REFRESH_VERTEXELEMENTFORMAT_SHORT2,
REFRESH_VERTEXELEMENTFORMAT_SHORT4,
REFRESH_VERTEXELEMENTFORMAT_NORMALIZEDSHORT2,
REFRESH_VERTEXELEMENTFORMAT_NORMALIZEDSHORT4,
REFRESH_VERTEXELEMENTFORMAT_HALFVECTOR2,
REFRESH_VERTEXELEMENTFORMAT_HALFVECTOR4
2021-01-05 23:00:51 +00:00
} Refresh_VertexElementFormat;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_VertexInputRate
2020-12-16 20:11:43 +00:00
{
REFRESH_VERTEXINPUTRATE_VERTEX = 0,
REFRESH_VERTEXINPUTRATE_INSTANCE = 1
2021-01-05 23:00:51 +00:00
} Refresh_VertexInputRate;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_FillMode
2020-12-16 20:11:43 +00:00
{
REFRESH_FILLMODE_FILL,
2022-03-02 19:10:28 +00:00
REFRESH_FILLMODE_LINE
2021-01-05 23:00:51 +00:00
} Refresh_FillMode;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_CullMode
2020-12-16 20:11:43 +00:00
{
REFRESH_CULLMODE_NONE,
REFRESH_CULLMODE_FRONT,
2022-03-02 19:10:28 +00:00
REFRESH_CULLMODE_BACK
2021-01-05 23:00:51 +00:00
} Refresh_CullMode;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_FrontFace
2020-12-16 20:11:43 +00:00
{
REFRESH_FRONTFACE_COUNTER_CLOCKWISE,
REFRESH_FRONTFACE_CLOCKWISE
2021-01-05 23:00:51 +00:00
} Refresh_FrontFace;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_CompareOp
2020-12-16 20:11:43 +00:00
{
REFRESH_COMPAREOP_NEVER,
REFRESH_COMPAREOP_LESS,
REFRESH_COMPAREOP_EQUAL,
REFRESH_COMPAREOP_LESS_OR_EQUAL,
REFRESH_COMPAREOP_GREATER,
REFRESH_COMPAREOP_NOT_EQUAL,
REFRESH_COMPAREOP_GREATER_OR_EQUAL,
REFRESH_COMPAREOP_ALWAYS
2021-01-05 23:00:51 +00:00
} Refresh_CompareOp;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_StencilOp
2020-12-16 20:11:43 +00:00
{
REFRESH_STENCILOP_KEEP,
REFRESH_STENCILOP_ZERO,
REFRESH_STENCILOP_REPLACE,
REFRESH_STENCILOP_INCREMENT_AND_CLAMP,
REFRESH_STENCILOP_DECREMENT_AND_CLAMP,
REFRESH_STENCILOP_INVERT,
REFRESH_STENCILOP_INCREMENT_AND_WRAP,
REFRESH_STENCILOP_DECREMENT_AND_WRAP
2021-01-05 23:00:51 +00:00
} Refresh_StencilOp;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_BlendOp
2020-12-16 20:11:43 +00:00
{
2020-12-17 19:40:49 +00:00
REFRESH_BLENDOP_ADD,
REFRESH_BLENDOP_SUBTRACT,
REFRESH_BLENDOP_REVERSE_SUBTRACT,
REFRESH_BLENDOP_MIN,
REFRESH_BLENDOP_MAX
2021-01-05 23:00:51 +00:00
} Refresh_BlendOp;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_BlendFactor
2020-12-16 20:11:43 +00:00
{
2022-03-02 19:10:28 +00:00
REFRESH_BLENDFACTOR_ZERO,
REFRESH_BLENDFACTOR_ONE,
REFRESH_BLENDFACTOR_SRC_COLOR,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_COLOR,
REFRESH_BLENDFACTOR_DST_COLOR,
REFRESH_BLENDFACTOR_ONE_MINUS_DST_COLOR,
REFRESH_BLENDFACTOR_SRC_ALPHA,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
REFRESH_BLENDFACTOR_DST_ALPHA,
REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA,
REFRESH_BLENDFACTOR_CONSTANT_COLOR,
REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR,
REFRESH_BLENDFACTOR_SRC_ALPHA_SATURATE,
REFRESH_BLENDFACTOR_SRC1_COLOR,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_COLOR,
REFRESH_BLENDFACTOR_SRC1_ALPHA,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_ALPHA
2021-01-05 23:00:51 +00:00
} Refresh_BlendFactor;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_ColorComponentFlagBits
2020-12-16 20:11:43 +00:00
{
2022-02-25 21:42:11 +00:00
REFRESH_COLORCOMPONENT_R_BIT = 0x00000001,
REFRESH_COLORCOMPONENT_G_BIT = 0x00000002,
REFRESH_COLORCOMPONENT_B_BIT = 0x00000004,
REFRESH_COLORCOMPONENT_A_BIT = 0x00000008
2021-01-05 23:00:51 +00:00
} Refresh_ColorComponentFlagBits;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef uint32_t Refresh_ColorComponentFlags;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_Filter
2020-12-16 20:47:54 +00:00
{
2021-01-03 21:01:29 +00:00
REFRESH_FILTER_NEAREST,
2022-03-02 19:10:28 +00:00
REFRESH_FILTER_LINEAR
2021-01-05 23:00:51 +00:00
} Refresh_Filter;
2020-12-16 20:47:54 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_SamplerMipmapMode
2020-12-16 20:47:54 +00:00
{
REFRESH_SAMPLERMIPMAPMODE_NEAREST,
REFRESH_SAMPLERMIPMAPMODE_LINEAR
2021-01-05 23:00:51 +00:00
} Refresh_SamplerMipmapMode;
2020-12-16 20:47:54 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_SamplerAddressMode
2020-12-16 20:47:54 +00:00
{
REFRESH_SAMPLERADDRESSMODE_REPEAT,
REFRESH_SAMPLERADDRESSMODE_MIRRORED_REPEAT,
REFRESH_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
REFRESH_SAMPLERADDRESSMODE_CLAMP_TO_BORDER
2021-01-05 23:00:51 +00:00
} Refresh_SamplerAddressMode;
2020-12-16 20:47:54 +00:00
2021-01-05 23:53:16 +00:00
/* FIXME: we should probably make a library-level decision about color types */
2021-01-05 23:00:51 +00:00
typedef enum Refresh_BorderColor
2020-12-16 20:47:54 +00:00
{
2022-03-02 19:10:28 +00:00
REFRESH_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK,
REFRESH_BORDERCOLOR_INT_TRANSPARENT_BLACK,
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_BLACK,
REFRESH_BORDERCOLOR_INT_OPAQUE_BLACK,
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_WHITE,
REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE
2021-01-05 23:00:51 +00:00
} Refresh_BorderColor;
2020-12-16 20:47:54 +00:00
2020-12-15 23:27:06 +00:00
/* Structures */
2020-12-15 23:00:46 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_DepthStencilValue
2020-12-16 21:28:06 +00:00
{
float depth;
uint32_t stencil;
2021-01-05 23:00:51 +00:00
} Refresh_DepthStencilValue;
2020-12-16 21:28:06 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_Rect
2020-12-16 02:29:26 +00:00
{
int32_t x;
int32_t y;
int32_t w;
int32_t h;
2021-01-05 23:00:51 +00:00
} Refresh_Rect;
2020-12-16 02:29:26 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_Vec4
2020-12-16 02:29:26 +00:00
{
float x;
float y;
float z;
float w;
2021-01-05 23:00:51 +00:00
} Refresh_Vec4;
2020-12-16 02:29:26 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_Viewport
2020-12-16 02:29:26 +00:00
{
float x;
float y;
float w;
float h;
2020-12-16 02:29:26 +00:00
float minDepth;
float maxDepth;
2021-01-05 23:00:51 +00:00
} Refresh_Viewport;
2020-12-16 02:29:26 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_TextureSlice
2020-12-19 00:39:03 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_Texture *texture;
Refresh_Rect rectangle;
2021-01-03 22:37:02 +00:00
uint32_t depth; /* 0 unless 3D */
uint32_t layer; /* 0 unless cube */
2021-01-03 21:01:29 +00:00
uint32_t level;
2021-01-05 23:00:51 +00:00
} Refresh_TextureSlice;
2020-12-19 00:39:03 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_PresentationParameters
2020-12-22 00:18:21 +00:00
{
void* deviceWindowHandle;
2021-01-05 23:00:51 +00:00
Refresh_PresentMode presentMode;
} Refresh_PresentationParameters;
2020-12-22 00:18:21 +00:00
2020-12-16 20:11:43 +00:00
/* State structures */
2021-01-05 23:00:51 +00:00
typedef struct Refresh_SamplerStateCreateInfo
2020-12-16 20:47:54 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_Filter minFilter;
Refresh_Filter magFilter;
Refresh_SamplerMipmapMode mipmapMode;
Refresh_SamplerAddressMode addressModeU;
Refresh_SamplerAddressMode addressModeV;
Refresh_SamplerAddressMode addressModeW;
2020-12-16 20:47:54 +00:00
float mipLodBias;
uint8_t anisotropyEnable;
float maxAnisotropy;
uint8_t compareEnable;
2021-01-05 23:00:51 +00:00
Refresh_CompareOp compareOp;
2020-12-16 20:47:54 +00:00
float minLod;
float maxLod;
2021-01-05 23:00:51 +00:00
Refresh_BorderColor borderColor;
} Refresh_SamplerStateCreateInfo;
2020-12-16 20:47:54 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_VertexBinding
2020-12-16 02:29:26 +00:00
{
2020-12-16 20:11:43 +00:00
uint32_t binding;
uint32_t stride;
2021-01-05 23:00:51 +00:00
Refresh_VertexInputRate inputRate;
} Refresh_VertexBinding;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_VertexAttribute
2020-12-16 20:11:43 +00:00
{
uint32_t location;
uint32_t binding;
2021-01-05 23:00:51 +00:00
Refresh_VertexElementFormat format;
2020-12-16 20:11:43 +00:00
uint32_t offset;
2021-01-05 23:00:51 +00:00
} Refresh_VertexAttribute;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_VertexInputState
2020-12-16 20:11:43 +00:00
{
2021-01-05 23:00:51 +00:00
const Refresh_VertexBinding *vertexBindings;
2020-12-16 20:11:43 +00:00
uint32_t vertexBindingCount;
2021-01-05 23:00:51 +00:00
const Refresh_VertexAttribute *vertexAttributes;
2020-12-16 20:11:43 +00:00
uint32_t vertexAttributeCount;
2021-01-05 23:00:51 +00:00
} Refresh_VertexInputState;
2020-12-16 02:29:26 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_StencilOpState
2020-12-15 23:00:46 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_StencilOp failOp;
Refresh_StencilOp passOp;
Refresh_StencilOp depthFailOp;
Refresh_CompareOp compareOp;
2020-12-16 20:11:43 +00:00
uint32_t compareMask;
uint32_t writeMask;
uint32_t reference;
2021-01-05 23:00:51 +00:00
} Refresh_StencilOpState;
2020-12-16 20:11:43 +00:00
typedef struct Refresh_ColorAttachmentBlendState
2020-12-16 20:11:43 +00:00
{
uint8_t blendEnable;
2021-01-05 23:00:51 +00:00
Refresh_BlendFactor srcColorBlendFactor;
Refresh_BlendFactor dstColorBlendFactor;
Refresh_BlendOp colorBlendOp;
Refresh_BlendFactor srcAlphaBlendFactor;
Refresh_BlendFactor dstAlphaBlendFactor;
Refresh_BlendOp alphaBlendOp;
Refresh_ColorComponentFlags colorWriteMask;
} Refresh_ColorAttachmentBlendState;
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ComputePipelineLayoutCreateInfo
2020-12-29 22:52:24 +00:00
{
uint32_t bufferBindingCount;
uint32_t imageBindingCount;
2021-01-05 23:00:51 +00:00
} Refresh_ComputePipelineLayoutCreateInfo;
2020-12-29 22:52:24 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ShaderModuleCreateInfo
2020-12-16 22:59:14 +00:00
{
size_t codeSize;
const uint32_t *byteCode;
2021-01-05 23:00:51 +00:00
} Refresh_ShaderModuleCreateInfo;
2020-12-16 22:59:14 +00:00
typedef struct Refresh_TextureCreateInfo
{
uint32_t width;
uint32_t height;
uint32_t depth;
2021-01-14 10:05:21 +00:00
uint8_t isCube;
Refresh_SampleCount sampleCount;
uint32_t levelCount;
Refresh_TextureFormat format;
Refresh_TextureUsageFlags usageFlags;
} Refresh_TextureCreateInfo;
2020-12-16 20:11:43 +00:00
/* Pipeline state structures */
2022-03-02 19:22:52 +00:00
typedef struct Refresh_GraphicsShaderInfo
2020-12-16 22:53:34 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_ShaderModule *shaderModule;
2020-12-16 22:53:34 +00:00
const char* entryPointName;
2020-12-23 21:11:09 +00:00
uint64_t uniformBufferSize;
2022-03-02 19:10:28 +00:00
uint32_t samplerBindingCount;
2022-03-02 19:22:52 +00:00
} Refresh_GraphicsShaderInfo;
typedef struct Refresh_ComputeShaderInfo
{
Refresh_ShaderModule* shaderModule;
const char* entryPointName;
uint64_t uniformBufferSize;
uint32_t bufferBindingCount;
uint32_t imageBindingCount;
} Refresh_ComputeShaderInfo;
2020-12-16 22:53:34 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_RasterizerState
2020-12-16 20:11:43 +00:00
{
uint8_t depthClampEnable;
2021-01-05 23:00:51 +00:00
Refresh_FillMode fillMode;
Refresh_CullMode cullMode;
Refresh_FrontFace frontFace;
2020-12-16 20:11:43 +00:00
uint8_t depthBiasEnable;
float depthBiasConstantFactor;
float depthBiasClamp;
float depthBiasSlopeFactor;
float lineWidth;
2021-01-05 23:00:51 +00:00
} Refresh_RasterizerState;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_MultisampleState
2020-12-16 20:11:43 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_SampleCount multisampleCount;
2021-01-06 02:05:01 +00:00
uint32_t sampleMask;
2021-01-05 23:00:51 +00:00
} Refresh_MultisampleState;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_DepthStencilState
2020-12-16 20:11:43 +00:00
{
uint8_t depthTestEnable;
uint8_t depthWriteEnable;
2021-01-05 23:00:51 +00:00
Refresh_CompareOp compareOp;
2020-12-16 20:11:43 +00:00
uint8_t depthBoundsTestEnable;
uint8_t stencilTestEnable;
2021-01-05 23:00:51 +00:00
Refresh_StencilOpState frontStencilState;
Refresh_StencilOpState backStencilState;
2020-12-16 20:11:43 +00:00
float minDepthBounds;
float maxDepthBounds;
2021-01-05 23:00:51 +00:00
} Refresh_DepthStencilState;
2020-12-16 20:11:43 +00:00
typedef struct Refresh_ColorAttachmentDescription
{
Refresh_TextureFormat format;
Refresh_SampleCount sampleCount;
Refresh_ColorAttachmentBlendState blendState;
} Refresh_ColorAttachmentDescription;
typedef struct Refresh_GraphicsPipelineAttachmentInfo
{
Refresh_ColorAttachmentDescription *colorAttachmentDescriptions;
uint32_t colorAttachmentCount;
uint8_t hasDepthStencilAttachment;
Refresh_TextureFormat depthStencilFormat;
} Refresh_GraphicsPipelineAttachmentInfo;
2021-01-05 23:00:51 +00:00
typedef struct Refresh_GraphicsPipelineCreateInfo
2020-12-16 22:53:34 +00:00
{
2022-03-02 19:22:52 +00:00
Refresh_GraphicsShaderInfo vertexShaderInfo;
Refresh_GraphicsShaderInfo fragmentShaderInfo;
2021-01-05 23:00:51 +00:00
Refresh_VertexInputState vertexInputState;
Refresh_PrimitiveType primitiveType;
2021-01-05 23:00:51 +00:00
Refresh_RasterizerState rasterizerState;
Refresh_MultisampleState multisampleState;
Refresh_DepthStencilState depthStencilState;
Refresh_GraphicsPipelineAttachmentInfo attachmentInfo;
2022-03-02 19:10:28 +00:00
float blendConstants[4];
2021-01-05 23:00:51 +00:00
} Refresh_GraphicsPipelineCreateInfo;
/* Render pass structures */
typedef struct Refresh_ColorAttachmentInfo
{
Refresh_Texture *texture; /* We can't use TextureSlice because render passes take a single rectangle. */
uint32_t depth;
uint32_t layer;
uint32_t level;
Refresh_SampleCount sampleCount;
Refresh_Vec4 clearColor; /* Can be ignored by RenderPass */
Refresh_LoadOp loadOp;
Refresh_StoreOp storeOp;
} Refresh_ColorAttachmentInfo;
typedef struct Refresh_DepthStencilAttachmentInfo
2020-12-16 21:28:06 +00:00
{
Refresh_Texture *texture; /* We can't use TextureSlice because render passes take a single rectangle. */
uint32_t depth;
uint32_t layer;
uint32_t level;
Refresh_DepthStencilValue depthStencilClearValue; /* Can be ignored by RenderPass */
Refresh_LoadOp loadOp;
Refresh_StoreOp storeOp;
Refresh_LoadOp stencilLoadOp;
Refresh_StoreOp stencilStoreOp;
} Refresh_DepthStencilAttachmentInfo;
2020-12-16 21:28:06 +00:00
2020-12-15 23:00:46 +00:00
/* Functions */
2020-12-17 02:38:22 +00:00
/* Logging */
2021-01-05 23:00:51 +00:00
typedef void (REFRESHCALL * Refresh_LogFunc)(const char *msg);
2020-12-17 02:38:22 +00:00
2021-01-06 00:07:42 +00:00
/* Reroutes Refresh's logging to custom logging functions.
*
* info: Basic logs that might be useful to have stored for support.
* warn: Something went wrong, but it's really just annoying, not fatal.
* error: You better have this stored somewhere because it's crashing now!
*/
REFRESHAPI void Refresh_HookLogFunctions(
Refresh_LogFunc info,
Refresh_LogFunc warn,
Refresh_LogFunc error
);
2020-12-16 23:33:09 +00:00
/* Device */
/* Create a rendering context for use on the calling thread.
*
2022-03-02 23:49:40 +00:00
* presentationParameters: A window handle and presentation mode.
2020-12-17 03:28:02 +00:00
* debugMode: Enable debug mode properties.
2020-12-16 23:33:09 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_Device* Refresh_CreateDevice(
Refresh_PresentationParameters *presentationParameters,
2020-12-17 03:28:02 +00:00
uint8_t debugMode
2020-12-16 23:33:09 +00:00
);
2021-01-05 23:00:51 +00:00
/* Destroys a rendering context previously returned by Refresh_CreateDevice. */
REFRESHAPI void Refresh_DestroyDevice(Refresh_Device *device);
2020-12-16 23:33:09 +00:00
2020-12-16 02:29:26 +00:00
/* Drawing */
2020-12-16 21:40:11 +00:00
/* Clears the targets of the currently bound framebuffer.
2020-12-29 06:19:46 +00:00
* If fewer colors are passed than the number of color targets in the
* framebuffer, this function will clear the first n color targets.
*
2020-12-16 21:28:06 +00:00
* NOTE:
* It is generally recommended to clear in BeginRenderPass
2020-12-29 06:19:46 +00:00
* rather than by calling this function unless necessary.
2020-12-16 02:29:26 +00:00
*
* clearRect: Area to clear.
* options: Bitflags to specify color/depth/stencil buffers for clearing.
* colors: An array of color values for the cleared color buffers.
* colorCount: The number of colors in the above array.
* depthStencil: Depth and stencil values for the cleared depth stencil buffer.
2020-12-16 02:29:26 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_Clear(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
2021-02-10 06:51:49 +00:00
Refresh_Vec4 *colors,
2020-12-29 06:19:46 +00:00
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
2020-12-16 02:29:26 +00:00
);
2020-12-20 09:29:15 +00:00
/* Draws data from vertex/index buffers with instancing enabled.
2020-12-16 02:29:26 +00:00
*
2020-12-20 09:29:15 +00:00
* baseVertex: The starting offset to read from the vertex buffer.
* startIndex: The starting offset to read from the index buffer.
* primitiveCount: The number of primitives to draw.
* instanceCount: The number of instances that will be drawn.
* vertexParamOffset: The offset of the vertex shader param data.
* fragmentParamOffset: The offset of the fragment shader param data.
2020-12-16 02:29:26 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_DrawInstancedPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
2020-12-20 09:29:15 +00:00
uint32_t instanceCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-16 02:29:26 +00:00
);
2020-12-20 09:29:15 +00:00
/* Draws data from vertex/index buffers.
2020-12-16 02:29:26 +00:00
*
2020-12-20 09:29:15 +00:00
* baseVertex: The starting offset to read from the vertex buffer.
* startIndex: The starting offset to read from the index buffer.
* primitiveCount: The number of primitives to draw.
* vertexParamOffset: The offset of the vertex shader param data.
* fragmentParamOffset: The offset of the fragment shader param data.
2020-12-16 02:29:26 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_DrawIndexedPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-16 02:29:26 +00:00
);
/* Draws data from vertex buffers.
2020-12-20 09:29:15 +00:00
*
* vertexStart: The starting offset to read from the vertex buffer.
* primitiveCount: The number of primitives to draw.
* vertexParamOffset: The offset of the vertex shader param data.
* fragmentParamOffset: The offset of the fragment shader param data.
2020-12-16 02:29:26 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_DrawPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t vertexStart,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-16 02:29:26 +00:00
);
2020-12-30 01:31:39 +00:00
/* Dispatches work compute items.
*
2020-12-31 04:39:47 +00:00
* groupCountX: Number of local workgroups to dispatch in the X dimension.
* groupCountY: Number of local workgroups to dispatch in the Y dimension.
* groupCountZ: Number of local workgroups to dispatch in the Z dimension.
* computeParamOffset: The offset of the compute shader param data.
2020-12-30 01:31:39 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_DispatchCompute(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-30 01:31:39 +00:00
uint32_t groupCountX,
uint32_t groupCountY,
2020-12-31 04:39:47 +00:00
uint32_t groupCountZ,
uint32_t computeParamOffset
2020-12-30 01:31:39 +00:00
);
2020-12-16 20:47:54 +00:00
/* State Creation */
2020-12-16 20:11:43 +00:00
2020-12-29 22:52:24 +00:00
/* Returns an allocated ComputePipeline* object. */
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_ComputePipeline* Refresh_CreateComputePipeline(
Refresh_Device *device,
2022-03-02 19:22:52 +00:00
Refresh_ComputeShaderInfo *computeShaderInfo
2020-12-29 22:52:24 +00:00
);
/* Returns an allocated GraphicsPipeline* object. */
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_GraphicsPipeline* Refresh_CreateGraphicsPipeline(
Refresh_Device *device,
Refresh_GraphicsPipelineCreateInfo *pipelineCreateInfo
2020-12-16 20:11:43 +00:00
);
2020-12-16 21:49:10 +00:00
/* Returns an allocated Sampler* object. */
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_Sampler* Refresh_CreateSampler(
Refresh_Device *device,
Refresh_SamplerStateCreateInfo *samplerStateCreateInfo
2020-12-16 20:47:54 +00:00
);
2020-12-16 22:59:14 +00:00
/* Returns an allocated ShaderModule* object. */
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_ShaderModule* Refresh_CreateShaderModule(
Refresh_Device *device,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
2020-12-16 22:59:14 +00:00
);
/* Returns an allocated Refresh_Texture* object. Note that the contents of
2020-12-16 21:49:10 +00:00
* the texture are undefined until SetData is called.
*/
REFRESHAPI Refresh_Texture* Refresh_CreateTexture(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_TextureCreateInfo *textureCreateInfo
2020-12-18 22:35:33 +00:00
);
2020-12-31 04:39:47 +00:00
/* Creates a buffer.
2020-12-16 22:02:03 +00:00
*
2020-12-31 04:39:47 +00:00
* usageFlags: Specifies how the buffer will be used.
* sizeInBytes: The length of the buffer.
2020-12-16 22:02:03 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_Buffer* Refresh_CreateBuffer(
Refresh_Device *device,
Refresh_BufferUsageFlags usageFlags,
2020-12-16 22:53:34 +00:00
uint32_t sizeInBytes
2020-12-16 22:02:03 +00:00
);
2020-12-16 22:53:34 +00:00
/* Setters */
2021-01-03 22:37:02 +00:00
/* Uploads image data to a texture object.
2020-12-16 22:02:03 +00:00
*
2021-01-03 22:37:02 +00:00
* textureSlice: The texture slice to be updated.
* data: A pointer to the image data.
* dataLengthInBytes: The size of the image data.
2020-12-16 22:02:03 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_SetTextureData(
Refresh_Device *driverData,
Refresh_CommandBuffer *commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_TextureSlice *textureSlice,
2020-12-16 22:53:34 +00:00
void *data,
uint32_t dataLengthInBytes
2020-12-16 22:02:03 +00:00
);
2020-12-17 00:27:14 +00:00
/* Uploads YUV image data to three R8 texture objects.
2020-12-16 22:53:34 +00:00
*
* y: The texture storing the Y data.
* u: The texture storing the U (Cb) data.
* v: The texture storing the V (Cr) data.
* yWidth: The width of the Y plane.
* yHeight: The height of the Y plane.
* uvWidth: The width of the U/V planes.
* uvHeight: The height of the U/V planes.
* data: A pointer to the raw YUV image data.
* dataLength: The size of the image data in bytes.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_SetTextureDataYUV(
Refresh_Device *driverData,
Refresh_CommandBuffer* commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_Texture *y,
Refresh_Texture *u,
Refresh_Texture *v,
2020-12-16 22:53:34 +00:00
uint32_t yWidth,
uint32_t yHeight,
uint32_t uvWidth,
uint32_t uvHeight,
void* data,
uint32_t dataLength
);
2021-01-03 21:01:29 +00:00
/* Performs an asynchronous texture-to-texture copy.
*
* sourceTextureSlice: The texture slice from which to copy.
* destinationTextureSlice: The texture slice to copy to.
* filter: The filter that will be used if the copy requires scaling.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_CopyTextureToTexture(
Refresh_Device *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *sourceTextureSlice,
Refresh_TextureSlice *destinationTextureSlice,
Refresh_Filter filter
2021-01-03 21:01:29 +00:00
);
/* Asynchronously copies image data from a texture slice into a buffer.
*
* NOTE:
* The buffer will not contain correct data until the command buffer
* is submitted and completed.
*
* textureSlice: The texture object being copied.
* buffer: The buffer being filled with the image data.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_CopyTextureToBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
Refresh_Buffer *buffer
2021-01-03 21:01:29 +00:00
);
2020-12-31 04:39:47 +00:00
/* Sets a region of the buffer with client data.
2020-12-20 07:35:30 +00:00
*
* NOTE:
* Calling this function on a buffer after the buffer
2020-12-31 04:39:47 +00:00
* has been bound without calling Submit first is an error.
2020-12-16 22:53:34 +00:00
*
2020-12-31 04:39:47 +00:00
* buffer: The vertex buffer to be updated.
2020-12-16 22:53:34 +00:00
* offsetInBytes: The starting offset of the buffer to write into.
2020-12-31 04:39:47 +00:00
* data: The client data to write into the buffer.
* dataLength: The length of data from the client buffer to write.
2020-12-16 22:53:34 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_SetBufferData(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_Buffer *buffer,
2020-12-16 22:53:34 +00:00
uint32_t offsetInBytes,
void* data,
uint32_t dataLength
);
2020-12-16 20:47:54 +00:00
/* Pushes vertex shader params to the device.
* Returns a starting offset value to be used with draw calls.
2020-12-17 00:27:14 +00:00
*
2020-12-23 21:11:09 +00:00
* NOTE:
* A pipeline must be bound.
* Will use the block size of the currently bound vertex shader.
*
2020-12-17 00:27:14 +00:00
* data: The client data to write into the buffer.
2021-02-03 00:37:01 +00:00
* dataLengthInBytes: The length of the data to write.
2020-12-17 00:27:14 +00:00
*/
REFRESHAPI uint32_t Refresh_PushVertexShaderUniforms(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_CommandBuffer * commandBuffer,
void *data,
2021-02-03 00:37:01 +00:00
uint32_t dataLengthInBytes
);
/* Pushes fragment shader params to the device.
* Returns a starting offset value to be used with draw calls.
*
2020-12-23 21:11:09 +00:00
* NOTE:
2020-12-31 04:39:47 +00:00
* A graphics pipeline must be bound.
2020-12-23 21:11:09 +00:00
* Will use the block size of the currently bound fragment shader.
*
* data: The client data to write into the buffer.
2021-02-03 00:37:01 +00:00
* dataLengthInBytes: The length of the data to write.
*/
REFRESHAPI uint32_t Refresh_PushFragmentShaderUniforms(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-17 00:27:14 +00:00
void *data,
2021-02-03 00:37:01 +00:00
uint32_t dataLengthInBytes
2020-12-17 00:27:14 +00:00
);
2020-12-31 04:39:47 +00:00
/* Pushes compute shader params to the device.
* Returns a starting offset value to be used with draw calls.
*
* NOTE:
* A compute pipeline must be bound.
* Will use the block size of the currently bound compute shader.
*
2021-02-03 00:37:01 +00:00
* data: The client data to write into the buffer.
* dataLengthInBytes: The length of the data to write.
2020-12-31 04:39:47 +00:00
*/
REFRESHAPI uint32_t Refresh_PushComputeShaderUniforms(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_CommandBuffer * commandBuffer,
2020-12-31 04:39:47 +00:00
void *data,
2021-02-03 00:37:01 +00:00
uint32_t dataLengthInBytes
2020-12-31 04:39:47 +00:00
);
2020-12-16 22:53:34 +00:00
/* Getters */
2021-01-03 01:00:52 +00:00
/* Synchronously copies data from a buffer to a pointer.
* You probably want to wait for a sync point to call this.
*
* buffer: The buffer to copy data from.
* data: The pointer to copy data to.
* dataLengthInBytes: The length of data to copy.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_GetBufferData(
Refresh_Device *device,
Refresh_Buffer *buffer,
2021-01-03 01:00:52 +00:00
void *data,
uint32_t dataLengthInBytes
);
2020-12-16 22:53:34 +00:00
/* Disposal */
/* Sends a texture to be destroyed by the renderer. Note that we call it
2021-01-06 01:02:36 +00:00
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
2020-12-16 22:53:34 +00:00
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2021-01-05 23:00:51 +00:00
* texture: The Refresh_Texture to be destroyed.
2020-12-16 22:53:34 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyTexture(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Texture *texture
2020-12-16 22:53:34 +00:00
);
2020-12-16 23:15:42 +00:00
/* Sends a sampler to be destroyed by the renderer. Note that we call it
2021-01-06 01:02:36 +00:00
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
2020-12-16 23:15:42 +00:00
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2021-01-05 23:00:51 +00:00
* texture: The Refresh_Sampler to be destroyed.
2020-12-16 23:15:42 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroySampler(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Sampler *sampler
2020-12-16 23:15:42 +00:00
);
/* Sends a buffer to be destroyed by the renderer. Note that we call it
2021-01-06 01:02:36 +00:00
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
2020-12-16 23:15:42 +00:00
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2021-01-05 23:00:51 +00:00
* buffer: The Refresh_Buffer to be destroyed.
2020-12-16 23:15:42 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyBuffer(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Buffer *buffer
2020-12-16 23:15:42 +00:00
);
/* Sends a shader module to be destroyed by the renderer. Note that we call it
2021-01-06 01:02:36 +00:00
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
2020-12-16 22:53:34 +00:00
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2021-01-05 23:00:51 +00:00
* shaderModule: The Refresh_ShaderModule to be destroyed.
2020-12-16 22:53:34 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyShaderModule(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_ShaderModule *shaderModule
2020-12-16 22:53:34 +00:00
);
2020-12-29 22:52:24 +00:00
/* Sends a compute pipeline to be destroyed by the renderer. Note that we call it
2021-01-06 01:02:36 +00:00
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
2020-12-29 22:52:24 +00:00
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2021-01-05 23:00:51 +00:00
* computePipeline: The Refresh_ComputePipeline to be destroyed.
2020-12-29 22:52:24 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyComputePipeline(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_ComputePipeline *computePipeline
2020-12-29 22:52:24 +00:00
);
2020-12-16 23:15:42 +00:00
/* Sends a graphics pipeline to be destroyed by the renderer. Note that we call it
2021-01-06 01:02:36 +00:00
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
2020-12-16 23:15:42 +00:00
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2021-01-05 23:00:51 +00:00
* graphicsPipeline: The Refresh_GraphicsPipeline to be destroyed.
2020-12-16 23:15:42 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyGraphicsPipeline(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_GraphicsPipeline *graphicsPipeline
2020-12-16 22:59:14 +00:00
);
2020-12-16 22:53:34 +00:00
/* Graphics State */
2020-12-16 20:47:54 +00:00
2020-12-16 21:28:06 +00:00
/* Begins a render pass.
2022-03-04 20:30:33 +00:00
* This will also set a default viewport and scissor state.
2020-12-16 21:28:06 +00:00
*
* renderArea:
* The area affected by the render pass.
* All load, store and resolve operations are restricted
* to the given rectangle.
* If NULL, a sensible default will be chosen.
* colorAttachmentInfos:
* A pointer to an array of Refresh_ColorAttachmentInfo structures
* that contains render targets and clear values. May be NULL.
* colorAttachmentCount: The amount of structs in the above array.
* depthStencilAttachmentInfo: The depth/stencil render target and clear value. May be NULL.
2020-12-16 21:28:06 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_BeginRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2021-01-27 04:27:42 +00:00
Refresh_Rect *renderArea,
Refresh_ColorAttachmentInfo *colorAttachmentInfos,
uint32_t colorAttachmentCount,
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo
2020-12-16 21:28:06 +00:00
);
2020-12-16 20:47:54 +00:00
2020-12-16 21:28:06 +00:00
/* Ends the current render pass. */
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_EndRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer
2020-12-16 21:28:06 +00:00
);
2020-12-16 20:47:54 +00:00
2020-12-30 01:31:39 +00:00
/* Binds a graphics pipeline to the graphics bind point. */
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_BindGraphicsPipeline(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline
2020-12-16 22:53:34 +00:00
);
2022-03-04 20:30:33 +00:00
/* Sets the current viewport state. */
REFRESHAPI void Refresh_SetViewport(
2022-03-04 20:30:33 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Viewport *viewport
);
/* Sets the current scissor state. */
REFRESHAPI void Refresh_SetScissor(
2022-03-04 20:30:33 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *scissor
);
2020-12-21 23:44:43 +00:00
/* Binds vertex buffers for use with subsequent draw calls. */
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_BindVertexBuffers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-20 07:31:55 +00:00
uint32_t firstBinding,
uint32_t bindingCount,
2021-01-05 23:00:51 +00:00
Refresh_Buffer **pBuffers,
2020-12-20 07:31:55 +00:00
uint64_t *pOffsets
);
2020-12-21 23:44:43 +00:00
/* Binds an index buffer for use with subsequent draw calls. */
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_BindIndexBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
2020-12-20 07:31:55 +00:00
uint64_t offset,
2021-01-05 23:00:51 +00:00
Refresh_IndexElementSize indexElementSize
2020-12-20 07:31:55 +00:00
);
2021-01-06 01:00:06 +00:00
/* Sets textures/samplers for use with the currently bound vertex shader.
*
* NOTE:
* The length of the passed arrays must be equal to the number
* of sampler bindings specified by the pipeline.
*
* textures: A pointer to an array of textures.
* samplers: A pointer to an array of samplers.
*/
REFRESHAPI void Refresh_BindVertexSamplers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
);
/* Sets textures/samplers for use with the currently bound fragment shader.
*
* NOTE:
* The length of the passed arrays must be equal to the number
* of sampler bindings specified by the pipeline.
*
* textures: A pointer to an array of textures.
* samplers: A pointer to an array of samplers.
*/
REFRESHAPI void Refresh_BindFragmentSamplers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
);
2020-12-30 01:31:39 +00:00
/* Binds a compute pipeline to the compute bind point. */
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_BindComputePipeline(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_ComputePipeline *computePipeline
2020-12-30 01:31:39 +00:00
);
/* Binds buffers for use with the currently bound compute pipeline.
*
* pBuffers: An array of buffers to bind.
* Length must be equal to the number of buffers
* specified by the compute pipeline.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_BindComputeBuffers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer **pBuffers
2020-12-30 01:31:39 +00:00
);
/* Binds textures for use with the currently bound compute pipeline.
*
* pTextures: An array of textures to bind.
* Length must be equal to the number of buffers
* specified by the compute pipeline.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_BindComputeTextures(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures
2020-12-30 01:31:39 +00:00
);
2020-12-21 23:44:43 +00:00
/* Submission/Presentation */
2020-12-17 04:19:11 +00:00
2021-01-05 23:00:51 +00:00
/* Returns an allocated Refresh_CommandBuffer* object.
2021-01-03 03:03:25 +00:00
* This command buffer is managed by the implementation and
* should NOT be freed by the user.
2021-01-02 06:07:15 +00:00
*
* NOTE:
* A command buffer may only be used on the thread that
* it was acquired on. Using it on any other thread is an error.
*
* fixed:
* If a command buffer is designated as fixed, it can be
* acquired once, have commands recorded into it, and
* be re-submitted indefinitely.
*
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
Refresh_Device *device,
2021-01-02 06:07:15 +00:00
uint8_t fixed
);
/* Acquires a texture to use for presentation.
* May return NULL under certain conditions.
* If NULL, the user must ensure to not present.
* Once a swapchain texture is acquired,
* it will automatically be presented on command buffer submission.
2020-12-21 23:44:43 +00:00
*
* NOTE:
* It is not recommended to hold a reference to this texture long term.
2020-12-21 23:44:43 +00:00
*/
REFRESHAPI Refresh_Texture* Refresh_AcquireSwapchainTexture(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *windowHandle
);
/* Returns the format of the swapchain for the given window. */
REFRESHAPI Refresh_TextureFormat Refresh_GetSwapchainFormat(
Refresh_Device *device,
void *windowHandle
2020-12-17 04:19:11 +00:00
);
2020-12-21 23:44:43 +00:00
/* Submits all of the enqueued commands. */
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_Submit(
Refresh_Device* device,
2021-01-03 22:57:46 +00:00
uint32_t commandBufferCount,
2021-01-05 23:00:51 +00:00
Refresh_CommandBuffer **pCommandBuffers
2020-12-21 23:44:43 +00:00
);
/* Waits for all submissions to complete. */
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_Wait(
Refresh_Device *device
2021-01-03 05:07:51 +00:00
);
2020-12-15 23:00:46 +00:00
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* REFRESH_H */
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */