Refresh/include/Refresh.h

1380 lines
39 KiB
C
Raw Normal View History

2020-12-15 23:00:46 +00:00
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
*
* 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 */
2021-01-14 01:37:54 +00:00
#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
VK_DEFINE_HANDLE(VkInstance)
VK_DEFINE_HANDLE(VkDevice)
VK_DEFINE_HANDLE(VkPhysicalDevice)
2020-12-15 23:00:46 +00:00
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* 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_ColorTarget Refresh_ColorTarget;
typedef struct Refresh_DepthStencilTarget Refresh_DepthStencilTarget;
typedef struct Refresh_Framebuffer Refresh_Framebuffer;
typedef struct Refresh_ShaderModule Refresh_ShaderModule;
typedef struct Refresh_RenderPass Refresh_RenderPass;
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
{
REFRESH_PRIMITIVETYPE_POINTLIST,
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
{
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
{
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
{
2021-01-06 00:19:27 +00:00
REFRESH_CLEAROPTIONS_COLOR = 0x00000001,
REFRESH_CLEAROPTIONS_DEPTH = 0x00000002,
REFRESH_CLEAROPTIONS_STENCIL = 0x00000004,
} 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
{
REFRESH_INDEXELEMENTSIZE_16BIT,
REFRESH_INDEXELEMENTSIZE_32BIT
2021-01-05 23:00:51 +00:00
} Refresh_IndexElementSize;
2020-12-15 23:00:46 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_ColorFormat
2021-01-03 22:53:12 +00:00
{
REFRESH_COLORFORMAT_R8G8B8A8,
REFRESH_COLORFORMAT_R5G6B5,
REFRESH_COLORFORMAT_A1R5G5B5,
REFRESH_COLORFORMAT_B4G4R4A4,
REFRESH_COLORFORMAT_BC1,
REFRESH_COLORFORMAT_BC2,
REFRESH_COLORFORMAT_BC3,
REFRESH_COLORFORMAT_R8G8_SNORM,
REFRESH_COLORFORMAT_R8G8B8A8_SNORM,
REFRESH_COLORFORMAT_A2R10G10B10,
REFRESH_COLORFORMAT_R16G16,
REFRESH_COLORFORMAT_R16G16B16A16,
REFRESH_COLORFORMAT_R8,
REFRESH_COLORFORMAT_R32_SFLOAT,
REFRESH_COLORFORMAT_R32G32_SFLOAT,
REFRESH_COLORFORMAT_R32G32B32A32_SFLOAT,
REFRESH_COLORFORMAT_R16_SFLOAT,
REFRESH_COLORFORMAT_R16G16_SFLOAT,
REFRESH_COLORFORMAT_R16G16B16A16_SFLOAT
2021-01-05 23:00:51 +00:00
} Refresh_ColorFormat;
2020-12-15 23:00:46 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_DepthFormat
2020-12-15 23:00:46 +00:00
{
2020-12-17 08:19:02 +00:00
REFRESH_DEPTHFORMAT_D16_UNORM,
REFRESH_DEPTHFORMAT_D32_SFLOAT,
2020-12-15 23:00:46 +00:00
REFRESH_DEPTHFORMAT_D16_UNORM_S8_UINT,
REFRESH_DEPTHFORMAT_D32_SFLOAT_S8_UINT
2021-01-05 23:00:51 +00:00
} Refresh_DepthFormat;
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
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
{
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,
REFRESH_FILLMODE_LINE,
REFRESH_FILLMODE_POINT
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,
REFRESH_CULLMODE_BACK,
REFRESH_CULLMODE_FRONT_AND_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_LogicOp
2020-12-17 19:40:49 +00:00
{
REFRESH_LOGICOP_CLEAR = 0,
REFRESH_LOGICOP_AND = 1,
REFRESH_LOGICOP_AND_REVERSE = 2,
REFRESH_LOGICOP_COPY = 3,
REFRESH_LOGICOP_AND_INVERTED = 4,
REFRESH_LOGICOP_NO_OP = 5,
REFRESH_LOGICOP_XOR = 6,
REFRESH_LOGICOP_OR = 7,
REFRESH_LOGICOP_NOR = 8,
REFRESH_LOGICOP_EQUIVALENT = 9,
REFRESH_LOGICOP_INVERT = 10,
REFRESH_LOGICOP_OR_REVERSE = 11,
REFRESH_LOGICOP_COPY_INVERTED = 12,
REFRESH_LOGICOP_OR_INVERTED = 13,
REFRESH_LOGICOP_NAND = 14,
REFRESH_LOGICOP_SET = 15
2021-01-05 23:00:51 +00:00
} Refresh_LogicOp;
2020-12-17 19:40:49 +00:00
2021-01-05 23:00:51 +00:00
typedef enum Refresh_BlendFactor
2020-12-16 20:11:43 +00:00
{
REFRESH_BLENDFACTOR_ZERO = 0,
REFRESH_BLENDFACTOR_ONE = 1,
REFRESH_BLENDFACTOR_SRC_COLOR = 2,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 3,
REFRESH_BLENDFACTOR_DST_COLOR = 4,
REFRESH_BLENDFACTOR_ONE_MINUS_DST_COLOR = 5,
REFRESH_BLENDFACTOR_SRC_ALPHA = 6,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 7,
REFRESH_BLENDFACTOR_DST_ALPHA = 8,
REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 9,
REFRESH_BLENDFACTOR_CONSTANT_COLOR = 10,
REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR = 11,
REFRESH_BLENDFACTOR_CONSTANT_ALPHA = 12,
REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_ALPHA = 13,
REFRESH_BLENDFACTOR_SRC_ALPHA_SATURATE = 14,
REFRESH_BLENDFACTOR_SRC1_COLOR = 15,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_COLOR = 16,
REFRESH_BLENDFACTOR_SRC1_ALPHA = 17,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_ALPHA = 18
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
{
REFRESH_COLORCOMPONENT_R_BIT = 0x00000001,
REFRESH_COLORCOMPONENT_G_BIT = 0x00000002,
REFRESH_COLORCOMPONENT_B_BIT = 0x00000004,
2020-12-23 05:53:39 +00:00
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_ShaderStageType
2020-12-16 20:11:43 +00:00
{
REFRESH_SHADERSTAGE_VERTEX,
REFRESH_SHADERSTAGE_FRAGMENT
2021-01-05 23:00:51 +00:00
} Refresh_ShaderStageType;
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,
REFRESH_FILTER_LINEAR,
REFRESH_FILTER_CUBIC
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
{
REFRESH_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK = 0,
REFRESH_BORDERCOLOR_INT_TRANSPARENT_BLACK = 1,
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_BLACK = 2,
REFRESH_BORDERCOLOR_INT_OPAQUE_BLACK = 3,
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_WHITE = 4,
REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE = 5
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_Color
2020-12-16 02:29:26 +00:00
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
2021-01-05 23:00:51 +00:00
} Refresh_Color;
2020-12-16 02:29:26 +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
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ColorTargetBlendState
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_ColorTargetBlendState;
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_GraphicsPipelineLayoutCreateInfo
2020-12-16 20:28:45 +00:00
{
2020-12-17 19:40:49 +00:00
uint32_t vertexSamplerBindingCount;
uint32_t fragmentSamplerBindingCount;
2021-01-05 23:00:51 +00:00
} Refresh_GraphicsPipelineLayoutCreateInfo;
2020-12-16 20:28:45 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ColorTargetDescription
2020-12-16 20:11:43 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_ColorFormat format;
Refresh_SampleCount multisampleCount;
Refresh_LoadOp loadOp;
Refresh_StoreOp storeOp;
} Refresh_ColorTargetDescription;
2020-12-16 21:28:06 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_DepthStencilTargetDescription
2020-12-16 21:28:06 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_DepthFormat depthFormat;
Refresh_LoadOp loadOp;
Refresh_StoreOp storeOp;
Refresh_LoadOp stencilLoadOp;
Refresh_StoreOp stencilStoreOp;
} Refresh_DepthStencilTargetDescription;
typedef struct Refresh_RenderPassCreateInfo
2020-12-15 23:00:46 +00:00
{
2021-01-05 23:00:51 +00:00
const Refresh_ColorTargetDescription *colorTargetDescriptions;
2020-12-16 21:28:06 +00:00
uint32_t colorTargetCount;
2021-01-05 23:00:51 +00:00
const Refresh_DepthStencilTargetDescription *depthTargetDescription; /* can be NULL */
} Refresh_RenderPassCreateInfo;
2020-12-15 23:00:46 +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_ColorFormat format;
Refresh_TextureUsageFlags usageFlags;
} Refresh_TextureCreateInfo;
2020-12-16 20:11:43 +00:00
/* Pipeline state structures */
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ShaderStageState
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;
2021-01-05 23:00:51 +00:00
} Refresh_ShaderStageState;
2020-12-16 22:53:34 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ViewportState
2020-12-16 20:11:43 +00:00
{
2021-01-05 23:00:51 +00:00
const Refresh_Viewport *viewports;
2020-12-16 20:11:43 +00:00
uint32_t viewportCount;
2021-01-05 23:00:51 +00:00
const Refresh_Rect *scissors;
2020-12-16 20:11:43 +00:00
uint32_t scissorCount;
2021-01-05 23:00:51 +00:00
} Refresh_ViewportState;
2020-12-16 20:11:43 +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
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ColorBlendState
2020-12-16 20:11:43 +00:00
{
2020-12-31 04:39:47 +00:00
uint8_t logicOpEnable;
2021-01-05 23:00:51 +00:00
Refresh_LogicOp logicOp;
const Refresh_ColorTargetBlendState *blendStates;
2020-12-16 20:11:43 +00:00
uint32_t blendStateCount;
float blendConstants[4];
2021-01-05 23:00:51 +00:00
} Refresh_ColorBlendState;
2020-12-16 20:11:43 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_ComputePipelineCreateInfo
2020-12-29 22:52:24 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_ShaderStageState computeShaderState;
Refresh_ComputePipelineLayoutCreateInfo pipelineLayoutCreateInfo;
} Refresh_ComputePipelineCreateInfo;
2020-12-29 22:52:24 +00:00
2021-01-05 23:00:51 +00:00
typedef struct Refresh_GraphicsPipelineCreateInfo
2020-12-16 22:53:34 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_ShaderStageState vertexShaderState;
Refresh_ShaderStageState fragmentShaderState;
Refresh_VertexInputState vertexInputState;
Refresh_PrimitiveType primitiveType;
2021-01-05 23:00:51 +00:00
Refresh_ViewportState viewportState;
Refresh_RasterizerState rasterizerState;
Refresh_MultisampleState multisampleState;
Refresh_DepthStencilState depthStencilState;
Refresh_ColorBlendState colorBlendState;
Refresh_GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo;
Refresh_RenderPass *renderPass;
} Refresh_GraphicsPipelineCreateInfo;
typedef struct Refresh_FramebufferCreateInfo
2020-12-16 21:28:06 +00:00
{
2021-01-05 23:00:51 +00:00
Refresh_RenderPass *renderPass;
Refresh_ColorTarget **pColorTargets;
2020-12-16 21:28:06 +00:00
uint32_t colorTargetCount;
2021-01-05 23:00:51 +00:00
Refresh_DepthStencilTarget *pDepthStencilTarget;
2020-12-16 21:28:06 +00:00
uint32_t width;
uint32_t height;
2021-01-05 23:00:51 +00:00
} Refresh_FramebufferCreateInfo;
2020-12-16 21:28:06 +00:00
2021-01-14 01:37:54 +00:00
/* Interop Structs */
typedef enum Refresh_SysRendererType
{
REFRESH_RENDERER_TYPE_VULKAN
} Refresh_SysRendererType;
typedef struct Refresh_SysRenderer
{
Refresh_SysRendererType rendererType;
union
{
#if REFRESH_DRIVER_VULKAN
struct
{
VkInstance instance;
VkPhysicalDevice physicalDevice;
VkDevice logicalDevice;
uint32_t queueFamilyIndex;
} vulkan;
#endif /* REFRESH_DRIVER_VULKAN */
uint8_t filler[64];
} renderer;
} Refresh_SysRenderer;
typedef struct Refresh_TextureHandles
{
Refresh_SysRendererType rendererType;
union
{
#if REFRESH_DRIVER_VULKAN
#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
#define REFRESH_VULKAN_HANDLE_TYPE void*
#else
#define REFRESH_VULKAN_HANDLE_TYPE uint64_t
#endif
struct
{
REFRESH_VULKAN_HANDLE_TYPE image; /* VkImage */
REFRESH_VULKAN_HANDLE_TYPE view; /* VkImageView */
} vulkan;
#endif /* REFRESH_DRIVER_VULKAN */
uint8_t filler[64];
} texture;
} Refresh_TextureHandles;
2020-12-15 23:00:46 +00:00
/* Version API */
#define REFRESH_ABI_VERSION 0
#define REFRESH_MAJOR_VERSION 0
#define REFRESH_MINOR_VERSION 1
#define REFRESH_PATCH_VERSION 0
#define REFRESH_COMPILED_VERSION ( \
(REFRESH_ABI_VERSION * 100 * 100 * 100) + \
(REFRESH_MAJOR_VERSION * 100 * 100) + \
(REFRESH_MINOR_VERSION * 100) + \
(REFRESH_PATCH_VERSION) \
)
2021-01-05 23:00:51 +00:00
REFRESHAPI uint32_t Refresh_LinkedVersion(void);
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.
*
2020-12-22 00:18:21 +00:00
* presentationParameters:
* If the windowHandle is NULL, Refresh will run in headless 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-14 01:37:54 +00:00
/* Create a rendering context by taking an externally-initialized VkDevice.
* Only valid with Vulkan backend.
* Useful for piggybacking on a separate graphics library like FNA3D.
*
* sysRenderer: Externally-initialized device info.
* debugMode: Enable debug mode properties.
*/
REFRESHAPI Refresh_Device* Refresh_CreateDeviceUsingExternal(
Refresh_SysRenderer *sysRenderer,
uint8_t debugMode
);
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
*
2020-12-29 06:19:46 +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.
* depth: The new value of the cleared depth buffer.
* stencil: The new value of the cleared 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,
Refresh_Color *colors,
2020-12-29 06:19:46 +00:00
uint32_t colorCount,
2020-12-16 02:29:26 +00:00
float depth,
int32_t stencil
);
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-16 21:49:10 +00:00
/* Returns an allocated RenderPass* object. */
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_RenderPass* Refresh_CreateRenderPass(
Refresh_Device *device,
Refresh_RenderPassCreateInfo *renderPassCreateInfo
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,
Refresh_ComputePipelineCreateInfo *pipelineCreateInfo
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 21:49:10 +00:00
/* Returns an allocated Framebuffer* object. */
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_Framebuffer* Refresh_CreateFramebuffer(
Refresh_Device *device,
Refresh_FramebufferCreateInfo *framebufferCreateInfo
2020-12-16 21:28:06 +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-16 22:02:03 +00:00
/* Creates a color target.
*
* multisampleCount: The MSAA value for the color target.
2020-12-19 00:39:03 +00:00
* textureSlice: The texture slice that the color target will resolve to.
2020-12-16 22:02:03 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_ColorTarget* Refresh_CreateColorTarget(
Refresh_Device *device,
Refresh_SampleCount multisampleCount,
Refresh_TextureSlice *textureSlice
2020-12-16 22:02:03 +00:00
);
/* Creates a depth/stencil target.
*
* width: The width of the depth/stencil target.
* height: The height of the depth/stencil target.
* format: The storage format of the depth/stencil target.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI Refresh_DepthStencilTarget* Refresh_CreateDepthStencilTarget(
Refresh_Device *device,
2020-12-16 22:02:03 +00:00
uint32_t width,
uint32_t height,
2021-01-05 23:00:51 +00:00
Refresh_DepthFormat format
2020-12-16 22:02:03 +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_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_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_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.
* paramBlockCount: The number of param-sized blocks from the client buffer to write.
2020-12-17 00:27:14 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI uint32_t Refresh_PushVertexShaderParams(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t paramBlockCount
);
/* 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.
* paramBlockCount: The number of param-sized blocks from the client buffer to write.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI uint32_t Refresh_PushFragmentShaderParams(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-17 00:27:14 +00:00
void *data,
2020-12-29 07:44:54 +00:00
uint32_t paramBlockCount
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.
*
* data: The client data to write into the buffer.
* paramBlockData: The number of param-sized blocks from the client buffer to write.
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI uint32_t Refresh_PushComputeShaderParams(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-31 04:39:47 +00:00
void *data,
uint32_t paramBlockCount
);
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
);
2020-12-16 22:53:34 +00:00
/* Sends a color target 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
* colorTarget: The Refresh_ColorTarget to be destroyed.
2020-12-16 22:53:34 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyColorTarget(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_ColorTarget *colorTarget
2020-12-16 22:53:34 +00:00
);
/* Sends a depth/stencil target 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
* depthStencilTarget: The Refresh_DepthStencilTarget to be destroyed.
2020-12-16 22:53:34 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyDepthStencilTarget(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_DepthStencilTarget *depthStencilTarget
2020-12-16 22:53:34 +00:00
);
2020-12-16 23:15:42 +00:00
/* Sends a framebuffer 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
* framebuffer: The Refresh_Framebuffer to be destroyed.
2020-12-16 22:53:34 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyFramebuffer(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Framebuffer *frameBuffer
2020-12-16 22:53:34 +00:00
);
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-16 23:15:42 +00:00
/* Sends a render pass 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:59:14 +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
* renderPass: The Refresh_RenderPass to be destroyed.
2020-12-16 22:59:14 +00:00
*/
2021-01-06 01:02:36 +00:00
REFRESHAPI void Refresh_QueueDestroyRenderPass(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_RenderPass *renderPass
2020-12-16 23:15:42 +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.
*
* renderPass: The renderpass to begin.
* framebuffer: The framebuffer to bind for the render pass.
* renderArea:
* The area affected by the render pass.
* All load, store and resolve operations are restricted
* to the given rectangle.
* clearValues:
2021-01-05 23:00:51 +00:00
* A pointer to an array of Refresh_Color structures
2020-12-20 08:05:12 +00:00
* that contains clear values for each color target in the
* framebuffer. May be NULL.
* clearCount: The amount of color structs in the above array.
* depthStencilClearValue: The depth/stencil 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,
Refresh_RenderPass *renderPass,
Refresh_Framebuffer *framebuffer,
Refresh_Rect renderArea,
Refresh_Color *pColorClearValues,
2020-12-20 08:05:12 +00:00
uint32_t colorClearCount,
2021-01-05 23:00:51 +00:00
Refresh_DepthStencilValue *depthStencilClearValue
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
);
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
);
/* Queues an image to be presented to the screen.
2021-01-05 23:00:51 +00:00
* The image will be presented upon the next Refresh_Submit call.
2020-12-21 23:44:43 +00:00
*
* NOTE:
* It is an error to call this function in headless mode.
2020-12-22 00:18:21 +00:00
*
* textureSlice: The texture slice to present.
2021-01-03 22:37:02 +00:00
* destinationRectangle: The region of the window to update. Can be NULL.
2021-01-03 21:01:29 +00:00
* filter: The filter to use if scaling is required.
2020-12-21 23:44:43 +00:00
*/
2021-01-05 23:00:51 +00:00
REFRESHAPI void Refresh_QueuePresent(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
Refresh_Rect *destinationRectangle,
Refresh_Filter filter
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
);
2021-01-03 05:07:51 +00:00
/* Waits for the previous submission 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
);
2021-01-14 01:37:54 +00:00
/* Export handles to be consumed by another API */
REFRESHAPI void Refresh_GetTextureHandles(
Refresh_Device* device,
Refresh_Texture* texture,
Refresh_TextureHandles* handles
);
2020-12-15 23:00:46 +00:00
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* REFRESH_H */
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */