Refresh/include/Refresh.h

1381 lines
40 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 */
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Type Declarations */
2020-12-16 02:29:26 +00:00
typedef struct REFRESH_Device REFRESH_Device;
2020-12-16 23:15:42 +00:00
typedef struct REFRESH_Buffer REFRESH_Buffer;
2020-12-15 23:00:46 +00:00
typedef struct REFRESH_Texture REFRESH_Texture;
2020-12-18 22:35:33 +00:00
typedef struct REFRESH_DepthStencilTexture REFRESH_DepthStencilTexture;
2020-12-16 20:47:54 +00:00
typedef struct REFRESH_Sampler REFRESH_Sampler;
2020-12-16 02:08:49 +00:00
typedef struct REFRESH_ColorTarget REFRESH_ColorTarget;
2020-12-16 22:02:03 +00:00
typedef struct REFRESH_DepthStencilTarget REFRESH_DepthStencilTarget;
2020-12-16 02:08:49 +00:00
typedef struct REFRESH_Framebuffer REFRESH_Framebuffer;
2020-12-16 22:53:34 +00:00
typedef struct REFRESH_ShaderModule REFRESH_ShaderModule;
2020-12-16 02:08:49 +00:00
typedef struct REFRESH_RenderPass REFRESH_RenderPass;
2020-12-29 22:52:24 +00:00
typedef struct REFRESH_ComputePipeline REFRESH_ComputePipeline;
2020-12-16 22:53:34 +00:00
typedef struct REFRESH_GraphicsPipeline REFRESH_GraphicsPipeline;
2020-12-16 02:08:49 +00:00
2020-12-17 03:50:31 +00:00
typedef enum REFRESH_PresentMode
{
REFRESH_PRESENTMODE_IMMEDIATE,
REFRESH_PRESENTMODE_MAILBOX,
REFRESH_PRESENTMODE_FIFO,
REFRESH_PRESENTMODE_FIFO_RELAXED
} REFRESH_PresentMode;
2020-12-16 02:29:26 +00:00
typedef enum REFRESH_PrimitiveType
{
REFRESH_PRIMITIVETYPE_POINTLIST,
REFRESH_PRIMITIVETYPE_LINELIST,
REFRESH_PRIMITIVETYPE_LINESTRIP,
REFRESH_PRIMITIVETYPE_TRIANGLELIST,
2020-12-17 00:27:14 +00:00
REFRESH_PRIMITIVETYPE_TRIANGLESTRIP
2020-12-16 02:29:26 +00:00
} REFRESH_PrimitiveType;
2020-12-16 02:08:49 +00:00
typedef enum REFRESH_LoadOp
{
REFRESH_LOADOP_LOAD,
REFRESH_LOADOP_CLEAR,
REFRESH_LOADOP_DONT_CARE
} REFRESH_LoadOp;
typedef enum REFRESH_StoreOp
{
REFRESH_STOREOP_STORE,
REFRESH_STOREOP_DONT_CARE
} REFRESH_StoreOp;
2020-12-15 23:00:46 +00:00
typedef enum REFRESH_ClearOptions
{
2020-12-29 06:19:46 +00:00
REFRESH_CLEAROPTIONS_COLOR = 1,
2020-12-15 23:00:46 +00:00
REFRESH_CLEAROPTIONS_DEPTH = 2,
REFRESH_CLEAROPTIONS_STENCIL = 4,
} REFRESH_ClearOptions;
typedef enum REFRESH_IndexElementSize
{
REFRESH_INDEXELEMENTSIZE_16BIT,
REFRESH_INDEXELEMENTSIZE_32BIT
} REFRESH_IndexElementSize;
typedef enum REFRESH_SurfaceFormat
{
REFRESH_SURFACEFORMAT_R8G8B8A8,
REFRESH_SURFACEFORMAT_R5G6B5,
REFRESH_SURFACEFORMAT_A1R5G5B5,
REFRESH_SURFACEFORMAT_B4G4R4A4,
REFRESH_SURFACEFORMAT_BC1,
REFRESH_SURFACEFORMAT_BC2,
REFRESH_SURFACEFORMAT_BC3,
REFRESH_SURFACEFORMAT_R8G8_SNORM,
REFRESH_SURFACEFORMAT_R8G8B8A8_SNORM,
REFRESH_SURFACEFORMAT_A2R10G10B10,
REFRESH_SURFACEFORMAT_R16G16,
REFRESH_SURFACEFORMAT_R16G16B16A16,
REFRESH_SURFACEFORMAT_R8,
REFRESH_SURFACEFORMAT_R32_SFLOAT,
REFRESH_SURFACEFORMAT_R32G32_SFLOAT,
REFRESH_SURFACEFORMAT_R32G32B32A32_SFLOAT,
REFRESH_SURFACEFORMAT_R16_SFLOAT,
REFRESH_SURFACEFORMAT_R16G16_SFLOAT,
REFRESH_SURFACEFORMAT_R16G16B16A16_SFLOAT
} REFRESH_SurfaceFormat;
typedef enum REFRESH_DepthFormat
{
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
} REFRESH_DepthFormat;
typedef enum REFRESH_TextureUsageFlagBits
2020-12-28 20:15:17 +00:00
{
REFRESH_TEXTUREUSAGE_SAMPLER_BIT = 0x00000001,
REFRESH_TEXTUREUSAGE_COLOR_TARGET_BIT = 0x00000002
} REFRESH_TextureUsageFlagBits;
typedef uint32_t REFRESH_TextureUsageFlags;
2020-12-28 20:15:17 +00:00
2020-12-17 08:19:02 +00:00
typedef enum REFRESH_SampleCount
{
REFRESH_SAMPLECOUNT_1,
REFRESH_SAMPLECOUNT_2,
REFRESH_SAMPLECOUNT_4,
REFRESH_SAMPLECOUNT_8,
REFRESH_SAMPLECOUNT_16,
REFRESH_SAMPLECOUNT_32,
REFRESH_SAMPLECOUNT_64
} REFRESH_SampleCount;
2020-12-15 23:00:46 +00:00
typedef enum REFRESH_CubeMapFace
{
REFRESH_CUBEMAPFACE_POSITIVEX,
REFRESH_CUBEMAPFACE_NEGATIVEX,
REFRESH_CUBEMAPFACE_POSITIVEY,
REFRESH_CUBEMAPFACE_NEGATIVEY,
REFRESH_CUBEMAPFACE_POSITIVEZ,
REFRESH_CUBEMAPFACE_NEGATIVEZ
} REFRESH_CubeMapFace;
2020-12-31 04:39:47 +00:00
typedef enum REFRESH_BufferUsageFlagBits
{
2020-12-31 06:28:37 +00:00
REFRESH_BUFFERUSAGE_VERTEX_BIT = 0x00000001,
REFRESH_BUFFERUSAGE_INDEX_BIT = 0x00000002,
REFRESH_BUFFERUSAGE_COMPUTE_BIT = 0x00000004
2020-12-31 04:39:47 +00:00
} REFRESH_BufferUsageFlagBits;
typedef uint32_t REFRESH_BufferUsageFlags;
2020-12-16 20:11:43 +00:00
typedef enum REFRESH_VertexElementFormat
{
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
} REFRESH_VertexElementFormat;
typedef enum REFRESH_VertexInputRate
{
REFRESH_VERTEXINPUTRATE_VERTEX = 0,
REFRESH_VERTEXINPUTRATE_INSTANCE = 1
} REFRESH_VertexInputRate;
typedef enum REFRESH_FillMode
{
REFRESH_FILLMODE_FILL,
REFRESH_FILLMODE_LINE,
REFRESH_FILLMODE_POINT
} REFRESH_FillMode;
typedef enum REFRESH_CullMode
{
REFRESH_CULLMODE_NONE,
REFRESH_CULLMODE_FRONT,
REFRESH_CULLMODE_BACK,
REFRESH_CULLMODE_FRONT_AND_BACK
} REFRESH_CullMode;
typedef enum REFRESH_FrontFace
{
REFRESH_FRONTFACE_COUNTER_CLOCKWISE,
REFRESH_FRONTFACE_CLOCKWISE
} REFRESH_FrontFace;
typedef enum REFRESH_CompareOp
{
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
} REFRESH_CompareOp;
typedef enum REFRESH_StencilOp
{
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
} REFRESH_StencilOp;
typedef enum REFRESH_BlendOp
{
2020-12-17 19:40:49 +00:00
REFRESH_BLENDOP_ADD,
REFRESH_BLENDOP_SUBTRACT,
REFRESH_BLENDOP_REVERSE_SUBTRACT,
REFRESH_BLENDOP_MIN,
REFRESH_BLENDOP_MAX
2020-12-16 20:11:43 +00:00
} REFRESH_BlendOp;
2020-12-17 19:40:49 +00:00
typedef enum REFRESH_LogicOp
{
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
} REFRESH_LogicOp;
2020-12-16 20:11:43 +00:00
typedef enum REFRESH_BlendFactor
{
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
} REFRESH_BlendFactor;
typedef enum REFRESH_ColorComponentFlagBits
{
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
2020-12-16 20:11:43 +00:00
} REFRESH_ColorComponentFlagBits;
typedef uint32_t REFRESH_ColorComponentFlags;
2020-12-16 22:53:34 +00:00
typedef enum REFRESH_ShaderStageType
2020-12-16 20:11:43 +00:00
{
REFRESH_SHADERSTAGE_VERTEX,
REFRESH_SHADERSTAGE_FRAGMENT
2020-12-16 22:53:34 +00:00
} REFRESH_ShaderStageType;
2020-12-16 20:11:43 +00:00
2020-12-16 20:47:54 +00:00
typedef enum REFRESH_SamplerFilter
{
REFRESH_SAMPLERFILTER_NEAREST,
REFRESH_SAMPLERFILTER_LINEAR
} REFRESH_SamplerFilter;
typedef enum REFRESH_SamplerMipmapMode
{
REFRESH_SAMPLERMIPMAPMODE_NEAREST,
REFRESH_SAMPLERMIPMAPMODE_LINEAR
} REFRESH_SamplerMipmapMode;
typedef enum REFRESH_SamplerAddressMode
{
REFRESH_SAMPLERADDRESSMODE_REPEAT,
REFRESH_SAMPLERADDRESSMODE_MIRRORED_REPEAT,
REFRESH_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
REFRESH_SAMPLERADDRESSMODE_CLAMP_TO_BORDER
} REFRESH_SamplerAddressMode;
typedef enum REFRESH_BorderColor
{
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
} REFRESH_BorderColor;
2020-12-15 23:27:06 +00:00
/* Structures */
2020-12-15 23:00:46 +00:00
2020-12-16 02:29:26 +00:00
typedef struct REFRESH_Color
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} REFRESH_Color;
2020-12-16 21:28:06 +00:00
typedef struct REFRESH_DepthStencilValue
{
float depth;
uint32_t stencil;
} REFRESH_DepthStencilValue;
2020-12-16 02:29:26 +00:00
typedef struct REFRESH_Rect
{
int32_t x;
int32_t y;
int32_t w;
int32_t h;
} REFRESH_Rect;
typedef struct REFRESH_Vec4
{
float x;
float y;
float z;
float w;
} REFRESH_Vec4;
typedef struct REFRESH_Viewport
{
float x;
float y;
float w;
float h;
2020-12-16 02:29:26 +00:00
float minDepth;
float maxDepth;
} REFRESH_Viewport;
2020-12-19 00:39:03 +00:00
typedef struct REFRESH_TextureSlice
{
REFRESH_Texture *texture;
uint32_t layer; /* 0-5 for cube, or z-slice for 3D */
} REFRESH_TextureSlice;
2020-12-22 00:18:21 +00:00
typedef struct REFRESH_PresentationParameters
{
void* deviceWindowHandle;
REFRESH_PresentMode presentMode;
} REFRESH_PresentationParameters;
2020-12-16 20:11:43 +00:00
/* State structures */
2020-12-16 20:47:54 +00:00
typedef struct REFRESH_SamplerStateCreateInfo
{
REFRESH_SamplerFilter minFilter;
REFRESH_SamplerFilter magFilter;
REFRESH_SamplerMipmapMode mipmapMode;
REFRESH_SamplerAddressMode addressModeU;
REFRESH_SamplerAddressMode addressModeV;
REFRESH_SamplerAddressMode addressModeW;
float mipLodBias;
uint8_t anisotropyEnable;
float maxAnisotropy;
uint8_t compareEnable;
REFRESH_CompareOp compareOp;
float minLod;
float maxLod;
REFRESH_BorderColor borderColor;
} REFRESH_SamplerStateCreateInfo;
2020-12-16 20:11:43 +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;
REFRESH_VertexInputRate inputRate;
} REFRESH_VertexBinding;
typedef struct REFRESH_VertexAttribute
{
uint32_t location;
uint32_t binding;
REFRESH_VertexElementFormat format;
uint32_t offset;
} REFRESH_VertexAttribute;
typedef struct REFRESH_VertexInputState
{
const REFRESH_VertexBinding *vertexBindings;
uint32_t vertexBindingCount;
const REFRESH_VertexAttribute *vertexAttributes;
uint32_t vertexAttributeCount;
} REFRESH_VertexInputState;
2020-12-16 02:29:26 +00:00
2020-12-16 20:11:43 +00:00
typedef struct REFRESH_StencilOpState
2020-12-15 23:00:46 +00:00
{
2020-12-16 20:11:43 +00:00
REFRESH_StencilOp failOp;
REFRESH_StencilOp passOp;
REFRESH_StencilOp depthFailOp;
2020-12-23 05:53:39 +00:00
REFRESH_CompareOp compareOp;
2020-12-16 20:11:43 +00:00
uint32_t compareMask;
uint32_t writeMask;
uint32_t reference;
} REFRESH_StencilOpState;
2020-12-23 06:56:26 +00:00
typedef struct REFRESH_ColorTargetBlendState
2020-12-16 20:11:43 +00:00
{
uint8_t blendEnable;
REFRESH_BlendFactor srcColorBlendFactor;
REFRESH_BlendFactor dstColorBlendFactor;
REFRESH_BlendOp colorBlendOp;
REFRESH_BlendFactor srcAlphaBlendFactor;
REFRESH_BlendFactor dstAlphaBlendFactor;
REFRESH_BlendOp alphaBlendOp;
REFRESH_ColorComponentFlags colorWriteMask;
2020-12-23 06:56:26 +00:00
} REFRESH_ColorTargetBlendState;
2020-12-16 20:11:43 +00:00
2020-12-29 22:52:24 +00:00
typedef struct REFRESH_ComputePipelineLayoutCreateInfo
{
uint32_t bufferBindingCount;
uint32_t imageBindingCount;
} REFRESH_ComputePipelineLayoutCreateInfo;
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;
2020-12-29 22:52:24 +00:00
} REFRESH_GraphicsPipelineLayoutCreateInfo;
2020-12-16 20:28:45 +00:00
2020-12-16 21:28:06 +00:00
typedef struct REFRESH_ColorTargetDescription
2020-12-16 20:11:43 +00:00
{
REFRESH_SurfaceFormat format;
2020-12-17 08:19:02 +00:00
REFRESH_SampleCount multisampleCount;
2020-12-16 20:11:43 +00:00
REFRESH_LoadOp loadOp;
REFRESH_StoreOp storeOp;
2020-12-16 21:28:06 +00:00
} REFRESH_ColorTargetDescription;
2020-12-29 04:09:31 +00:00
typedef struct REFRESH_DepthStencilTargetDescription
2020-12-16 21:28:06 +00:00
{
REFRESH_DepthFormat depthFormat;
REFRESH_LoadOp loadOp;
REFRESH_StoreOp storeOp;
2020-12-16 20:11:43 +00:00
REFRESH_LoadOp stencilLoadOp;
REFRESH_StoreOp stencilStoreOp;
2020-12-29 04:09:31 +00:00
} REFRESH_DepthStencilTargetDescription;
2020-12-16 20:11:43 +00:00
typedef struct REFRESH_RenderPassCreateInfo
2020-12-15 23:00:46 +00:00
{
2020-12-16 21:28:06 +00:00
const REFRESH_ColorTargetDescription *colorTargetDescriptions;
uint32_t colorTargetCount;
2020-12-29 04:09:31 +00:00
const REFRESH_DepthStencilTargetDescription *depthTargetDescription; /* can be NULL */
2020-12-16 20:11:43 +00:00
} REFRESH_RenderPassCreateInfo;
2020-12-15 23:00:46 +00:00
2020-12-16 22:59:14 +00:00
typedef struct REFRESH_ShaderModuleCreateInfo
{
size_t codeSize;
const uint32_t *byteCode;
} REFRESH_ShaderModuleCreateInfo;
2020-12-16 20:11:43 +00:00
/* Pipeline state structures */
2020-12-31 04:39:47 +00:00
typedef struct REFRESH_ShaderStageState
2020-12-16 22:53:34 +00:00
{
REFRESH_ShaderModule *shaderModule;
const char* entryPointName;
2020-12-23 21:11:09 +00:00
uint64_t uniformBufferSize;
2020-12-31 04:39:47 +00:00
} REFRESH_ShaderStageState;
2020-12-16 22:53:34 +00:00
2020-12-16 20:11:43 +00:00
typedef struct REFRESH_TopologyState
{
2020-12-16 22:53:34 +00:00
REFRESH_PrimitiveType topology;
2020-12-16 20:11:43 +00:00
} REFRESH_TopologyState;
typedef struct REFRESH_ViewportState
{
2020-12-17 19:40:49 +00:00
const REFRESH_Viewport *viewports;
2020-12-16 20:11:43 +00:00
uint32_t viewportCount;
const REFRESH_Rect *scissors;
uint32_t scissorCount;
} REFRESH_ViewportState;
typedef struct REFRESH_RasterizerState
{
uint8_t depthClampEnable;
REFRESH_FillMode fillMode;
REFRESH_CullMode cullMode;
REFRESH_FrontFace frontFace;
uint8_t depthBiasEnable;
float depthBiasConstantFactor;
float depthBiasClamp;
float depthBiasSlopeFactor;
float lineWidth;
} REFRESH_RasterizerState;
typedef struct REFRESH_MultisampleState
{
2020-12-17 19:40:49 +00:00
REFRESH_SampleCount multisampleCount;
2020-12-16 20:11:43 +00:00
const uint32_t *sampleMask;
} REFRESH_MultisampleState;
typedef struct REFRESH_DepthStencilState
{
uint8_t depthTestEnable;
uint8_t depthWriteEnable;
REFRESH_CompareOp compareOp;
uint8_t depthBoundsTestEnable;
uint8_t stencilTestEnable;
REFRESH_StencilOpState frontStencilState;
REFRESH_StencilOpState backStencilState;
float minDepthBounds;
float maxDepthBounds;
} REFRESH_DepthStencilState;
typedef struct REFRESH_ColorBlendState
{
2020-12-31 04:39:47 +00:00
uint8_t logicOpEnable;
2020-12-17 19:40:49 +00:00
REFRESH_LogicOp logicOp;
2020-12-23 06:56:26 +00:00
const REFRESH_ColorTargetBlendState *blendStates;
2020-12-16 20:11:43 +00:00
uint32_t blendStateCount;
float blendConstants[4];
} REFRESH_ColorBlendState;
2020-12-29 22:52:24 +00:00
typedef struct REFRESH_ComputePipelineCreateInfo
{
2020-12-31 04:39:47 +00:00
REFRESH_ShaderStageState computeShaderState;
2020-12-29 22:52:24 +00:00
REFRESH_ComputePipelineLayoutCreateInfo pipelineLayoutCreateInfo;
} REFRESH_ComputePipelineCreateInfo;
2020-12-16 22:53:34 +00:00
typedef struct REFRESH_GraphicsPipelineCreateInfo
{
2020-12-31 04:39:47 +00:00
REFRESH_ShaderStageState vertexShaderState;
REFRESH_ShaderStageState fragmentShaderState;
2020-12-23 04:22:17 +00:00
REFRESH_VertexInputState vertexInputState;
REFRESH_TopologyState topologyState;
REFRESH_ViewportState viewportState;
REFRESH_RasterizerState rasterizerState;
REFRESH_MultisampleState multisampleState;
REFRESH_DepthStencilState depthStencilState;
REFRESH_ColorBlendState colorBlendState;
2020-12-29 22:52:24 +00:00
REFRESH_GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo;
2020-12-16 20:11:43 +00:00
REFRESH_RenderPass *renderPass;
2020-12-16 22:53:34 +00:00
} REFRESH_GraphicsPipelineCreateInfo;
2020-12-15 23:00:46 +00:00
2020-12-16 21:28:06 +00:00
typedef struct REFRESH_FramebufferCreateInfo
{
REFRESH_RenderPass *renderPass;
2020-12-22 01:59:08 +00:00
REFRESH_ColorTarget **pColorTargets;
2020-12-16 21:28:06 +00:00
uint32_t colorTargetCount;
2020-12-23 07:17:09 +00:00
REFRESH_DepthStencilTarget *pDepthStencilTarget;
2020-12-16 21:28:06 +00:00
uint32_t width;
uint32_t height;
} REFRESH_FramebufferCreateInfo;
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) \
)
REFRESHAPI uint32_t REFRESH_LinkedVersion(void);
/* Functions */
2020-12-17 02:38:22 +00:00
/* Logging */
typedef void (REFRESHCALL * REFRESH_LogFunc)(const char *msg);
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
*/
REFRESHAPI REFRESH_Device* REFRESH_CreateDevice(
2020-12-22 00:18:21 +00:00
REFRESH_PresentationParameters *presentationParameters,
2020-12-17 03:28:02 +00:00
uint8_t debugMode
2020-12-16 23:33:09 +00:00
);
/* Destroys a rendering context previously returned by REFRESH_CreateDevice. */
REFRESHAPI void REFRESH_DestroyDevice(REFRESH_Device *device);
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
*/
REFRESHAPI void REFRESH_Clear(
REFRESH_Device *device,
2020-12-29 06:19:46 +00:00
REFRESH_Rect *clearRect,
2020-12-16 21:28:06 +00:00
REFRESH_ClearOptions options,
2020-12-29 06:19:46 +00:00
REFRESH_Color *colors,
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.
* minVertexIndex: The lowest index value expected from the index buffer.
* numVertices: The highest offset expected from the index 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.
* indices: The index buffer to bind for this draw call.
2020-12-16 02:29:26 +00:00
* indexElementSize: The size of the index type for this index buffer.
* 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
*/
2020-12-20 09:29:15 +00:00
REFRESHAPI void REFRESH_DrawInstancedPrimitives(
2020-12-16 02:29:26 +00:00
REFRESH_Device *device,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t minVertexIndex,
uint32_t numVertices,
uint32_t startIndex,
uint32_t primitiveCount,
2020-12-20 09:29:15 +00:00
uint32_t instanceCount,
2020-12-16 02:29:26 +00:00
REFRESH_Buffer *indices,
REFRESH_IndexElementSize indexElementSize,
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.
* minVertexIndex: The lowest index value expected from the index buffer.
* numVertices: The highest offset expected from the index buffer.
* startIndex: The starting offset to read from the index buffer.
* primitiveCount: The number of primitives to draw.
* indices: The index buffer to bind for this draw call.
2020-12-16 02:29:26 +00:00
* indexElementSize: The size of the index type for this index buffer.
* 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
*/
2020-12-20 09:29:15 +00:00
REFRESHAPI void REFRESH_DrawIndexedPrimitives(
2020-12-16 02:29:26 +00:00
REFRESH_Device *device,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t minVertexIndex,
uint32_t numVertices,
uint32_t startIndex,
uint32_t primitiveCount,
2020-12-16 02:29:26 +00:00
REFRESH_Buffer *indices,
REFRESH_IndexElementSize indexElementSize,
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
*/
REFRESHAPI void REFRESH_DrawPrimitives(
REFRESH_Device *device,
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
*/
REFRESHAPI void REFRESH_DispatchCompute(
REFRESH_Device *device,
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. */
REFRESHAPI REFRESH_RenderPass* REFRESH_CreateRenderPass(
2020-12-16 20:11:43 +00:00
REFRESH_Device *device,
REFRESH_RenderPassCreateInfo *renderPassCreateInfo
);
2020-12-29 22:52:24 +00:00
/* Returns an allocated ComputePipeline* object. */
REFRESHAPI REFRESH_ComputePipeline* REFRESH_CreateComputePipeline(
REFRESH_Device *device,
REFRESH_ComputePipelineCreateInfo *pipelineCreateInfo
);
/* Returns an allocated GraphicsPipeline* object. */
2020-12-16 22:53:34 +00:00
REFRESHAPI REFRESH_GraphicsPipeline* REFRESH_CreateGraphicsPipeline(
2020-12-16 20:11:43 +00:00
REFRESH_Device *device,
2020-12-16 22:53:34 +00:00
REFRESH_GraphicsPipelineCreateInfo *pipelineCreateInfo
2020-12-16 20:11:43 +00:00
);
2020-12-16 21:49:10 +00:00
/* Returns an allocated Sampler* object. */
REFRESHAPI REFRESH_Sampler* REFRESH_CreateSampler(
2020-12-16 20:47:54 +00:00
REFRESH_Device *device,
REFRESH_SamplerStateCreateInfo *samplerStateCreateInfo
);
2020-12-16 21:49:10 +00:00
/* Returns an allocated Framebuffer* object. */
REFRESHAPI REFRESH_Framebuffer* REFRESH_CreateFramebuffer(
2020-12-16 21:28:06 +00:00
REFRESH_Device *device,
REFRESH_FramebufferCreateInfo *framebufferCreateInfo
);
2020-12-16 22:59:14 +00:00
/* Returns an allocated ShaderModule* object. */
REFRESHAPI REFRESH_ShaderModule* REFRESH_CreateShaderModule(
REFRESH_Device *device,
REFRESH_ShaderModuleCreateInfo *shaderModuleCreateInfo
);
2020-12-16 21:49:10 +00:00
/* Creates a 2D texture.
*
* format: The pixel format of the texture data.
* width: The width of the texture image.
* height: The height of the texture image.
* levelCount: The number of mipmap levels to allocate.
* usageFlags: Specifies how the texture will be used.
*
2020-12-16 21:49:10 +00:00
* Returns an allocated REFRESH_Texture* object. Note that the contents of
* the texture are undefined until SetData is called.
*/
REFRESHAPI REFRESH_Texture* REFRESH_CreateTexture2D(
REFRESH_Device *device,
REFRESH_SurfaceFormat format,
uint32_t width,
uint32_t height,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
REFRESH_TextureUsageFlags usageFlags
2020-12-16 21:49:10 +00:00
);
/* Creates a 3D texture.
*
* format: The pixel format of the texture data.
* width: The width of the texture image.
* height: The height of the texture image.
* depth: The depth of the texture image.
* levelCount: The number of mipmap levels to allocate.
* usageFlags: Specifies how the texture will be used.
2020-12-16 21:49:10 +00:00
*
* Returns an allocated REFRESH_Texture* object. Note that the contents of
* the texture are undefined until SetData is called.
*/
REFRESHAPI REFRESH_Texture* REFRESH_CreateTexture3D(
REFRESH_Device *device,
REFRESH_SurfaceFormat format,
uint32_t width,
uint32_t height,
uint32_t depth,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
REFRESH_TextureUsageFlags usageFlags
2020-12-16 21:49:10 +00:00
);
/* Creates a texture cube.
*
* format: The pixel format of the texture data.
* size: The length of the cube side.
* levelCount: The number of mipmap levels to allocate.
* usageFlags: Specifies how the texture will be used.
*
2020-12-16 21:49:10 +00:00
* Returns an allocated REFRESH_Texture* object. Note that the contents of
* the texture are undefined until SetData is called.
*/
REFRESHAPI REFRESH_Texture* REFRESH_CreateTextureCube(
REFRESH_Device *device,
REFRESH_SurfaceFormat format,
uint32_t size,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
REFRESH_TextureUsageFlags usageFlags
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
*/
2020-12-21 23:50:12 +00:00
REFRESHAPI REFRESH_ColorTarget* REFRESH_CreateColorTarget(
2020-12-16 22:02:03 +00:00
REFRESH_Device *device,
2020-12-19 00:39:03 +00:00
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.
*/
2020-12-21 23:50:12 +00:00
REFRESHAPI REFRESH_DepthStencilTarget* REFRESH_CreateDepthStencilTarget(
2020-12-16 22:02:03 +00:00
REFRESH_Device *device,
uint32_t width,
uint32_t height,
2020-12-19 00:39:03 +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
*/
2020-12-31 04:39:47 +00:00
REFRESHAPI REFRESH_Buffer* REFRESH_CreateBuffer(
2020-12-16 22:02:03 +00:00
REFRESH_Device *device,
2020-12-31 04:39:47 +00:00
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 */
/* Uploads image data to a 2D texture object.
2020-12-16 22:02:03 +00:00
*
2020-12-16 22:53:34 +00:00
* texture: The texture to be updated.
* x: The x offset of the subregion being updated.
* y: The y offset of the subregion being updated.
* w: The width of the subregion being updated.
* h: The height of the subregion being updated.
* level: The mipmap level being updated.
* data: A pointer to the image data.
* dataLength: The size of the image data in bytes.
2020-12-16 22:02:03 +00:00
*/
2020-12-16 22:53:34 +00:00
REFRESHAPI void REFRESH_SetTextureData2D(
2020-12-16 22:02:03 +00:00
REFRESH_Device *device,
2020-12-16 22:53:34 +00:00
REFRESH_Texture *texture,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
uint32_t level,
void *data,
uint32_t dataLengthInBytes
2020-12-16 22:02:03 +00:00
);
2020-12-16 22:53:34 +00:00
/* Uploads image data to a 3D texture object.
2020-12-16 22:02:03 +00:00
*
2020-12-16 22:53:34 +00:00
* texture: The texture to be updated.
* x: The x offset of the subregion being updated.
* y: The y offset of the subregion being updated.
* z: The z offset of the subregion being updated.
* w: The width of the subregion being updated.
* h: The height of the subregion being updated.
* d: The depth of the subregion being updated.
* level: The mipmap level being updated.
* data: A pointer to the image data.
* dataLength: The size of the image data in bytes.
2020-12-16 22:02:03 +00:00
*/
2020-12-16 22:53:34 +00:00
REFRESHAPI void REFRESH_SetTextureData3D(
2020-12-16 22:02:03 +00:00
REFRESH_Device *device,
2020-12-16 22:53:34 +00:00
REFRESH_Texture *texture,
uint32_t x,
uint32_t y,
uint32_t z,
uint32_t w,
uint32_t h,
uint32_t d,
uint32_t level,
void* data,
uint32_t dataLength
);
/* Uploads image data to a single face of a texture cube object.
*
* texture: The texture to be updated.
* x: The x offset of the subregion being updated.
* y: The y offset of the subregion being updated.
* w: The width of the subregion being updated.
* h: The height of the subregion being updated.
* cubeMapFace: The face of the cube being updated.
* level: The mipmap level being updated.
* data: A pointer to the image data.
* dataLength: The size of the image data in bytes.
*/
REFRESHAPI void REFRESH_SetTextureDataCube(
REFRESH_Device *device,
REFRESH_Texture *texture,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
REFRESH_CubeMapFace cubeMapFace,
uint32_t level,
void* data,
uint32_t dataLength
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.
*/
REFRESHAPI void REFRESH_SetTextureDataYUV(
REFRESH_Device *device,
REFRESH_Texture *y,
REFRESH_Texture *u,
REFRESH_Texture *v,
uint32_t yWidth,
uint32_t yHeight,
uint32_t uvWidth,
uint32_t uvHeight,
void* data,
uint32_t dataLength
);
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
*/
2020-12-31 04:39:47 +00:00
REFRESHAPI void REFRESH_SetBufferData(
2020-12-16 22:53:34 +00:00
REFRESH_Device *device,
REFRESH_Buffer *buffer,
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
*/
REFRESHAPI uint32_t REFRESH_PushVertexShaderParams(
REFRESH_Device *device,
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.
*/
REFRESHAPI uint32_t REFRESH_PushFragmentShaderParams(
2020-12-17 00:27:14 +00:00
REFRESH_Device *device,
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.
*/
REFRESHAPI uint32_t REFRESH_PushComputeShaderParams(
REFRESH_Device *device,
void *data,
uint32_t paramBlockCount
);
2020-12-16 21:40:11 +00:00
/* Sets textures/samplers for use with the currently bound vertex shader.
*
2020-12-19 05:35:21 +00:00
* NOTE:
* The length of the passed arrays must be equal to the number
2020-12-28 07:13:49 +00:00
* of sampler bindings specified by the pipeline.
2020-12-19 05:35:21 +00:00
*
* textures: A pointer to an array of textures.
* samplers: A pointer to an array of samplers.
2020-12-16 21:40:11 +00:00
*/
REFRESHAPI void REFRESH_SetVertexSamplers(
2020-12-16 20:47:54 +00:00
REFRESH_Device *device,
2020-12-19 05:35:21 +00:00
REFRESH_Texture **pTextures,
REFRESH_Sampler **pSamplers
2020-12-16 21:40:11 +00:00
);
/* Sets textures/samplers for use with the currently bound fragment shader.
*
2020-12-19 05:35:21 +00:00
* NOTE:
* The length of the passed arrays must be equal to the number
2020-12-28 07:13:49 +00:00
* of sampler bindings specified by the pipeline.
2020-12-19 05:35:21 +00:00
*
* textures: A pointer to an array of textures.
* samplers: A pointer to an array of samplers.
2020-12-16 21:40:11 +00:00
*/
REFRESHAPI void REFRESH_SetFragmentSamplers(
REFRESH_Device *device,
2020-12-19 05:35:21 +00:00
REFRESH_Texture **pTextures,
REFRESH_Sampler **pSamplers
2020-12-16 21:40:11 +00:00
);
2020-12-16 22:53:34 +00:00
/* Getters */
/* Pulls image data from a 2D texture into client memory. Like any GetData,
* this is generally asking for a massive CPU/GPU sync point, don't call this
* unless there's absolutely no other way to use the image data!
*
* texture: The texture object being read.
* x: The x offset of the subregion being read.
* y: The y offset of the subregion being read.
* w: The width of the subregion being read.
* h: The height of the subregion being read.
* level: The mipmap level being read.
* data: The pointer being filled with the image data.
*/
REFRESHAPI void REFRESH_GetTextureData2D(
REFRESH_Device *device,
REFRESH_Texture *texture,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
uint32_t level,
2020-12-29 07:41:59 +00:00
void* data
2020-12-16 22:53:34 +00:00
);
/* Pulls image data from a single face of a texture cube object into client
* memory. Like any GetData, this is generally asking for a massive CPU/GPU sync
* point, don't call this unless there's absolutely no other way to use the
* image data!
*
2020-12-29 07:41:59 +00:00
* texture: The texture object being read.
* x: The x offset of the subregion being read.
* y: The y offset of the subregion being read.
* w: The width of the subregion being read.
* h: The height of the subregion being read.
2020-12-16 22:53:34 +00:00
* cubeMapFace: The face of the cube being read.
2020-12-29 07:41:59 +00:00
* level: The mipmap level being read.
* data: The pointer being filled with the image data.
2020-12-16 22:53:34 +00:00
*/
REFRESHAPI void REFRESH_GetTextureDataCube(
REFRESH_Device *device,
REFRESH_Texture *texture,
uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
REFRESH_CubeMapFace cubeMapFace,
uint32_t level,
2020-12-29 07:41:59 +00:00
void* data
2020-12-16 22:53:34 +00:00
);
/* Disposal */
/* Sends a texture to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* texture: The REFRESH_Texture to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeTexture(
REFRESH_Device *device,
REFRESH_Texture *texture
);
2020-12-16 23:15:42 +00:00
/* Sends a sampler to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* texture: The REFRESH_Sampler to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeSampler(
REFRESH_Device *device,
REFRESH_Sampler *sampler
);
/* Sends a vertex buffer to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* buffer: The REFRESH_Buffer to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeVertexBuffer(
REFRESH_Device *device,
REFRESH_Buffer *buffer
);
/* Sends an index buffer to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* buffer: The REFRESH_Buffer to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeIndexBuffer(
REFRESH_Device *device,
REFRESH_Buffer *buffer
);
2020-12-16 22:53:34 +00:00
/* Sends a color target to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* colorTarget: The REFRESH_ColorTarget to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeColorTarget(
REFRESH_Device *device,
REFRESH_ColorTarget *colorTarget
);
/* Sends a depth/stencil target to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* depthStencilTarget: The REFRESH_DepthStencilTarget to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeDepthStencilTarget(
REFRESH_Device *device,
REFRESH_DepthStencilTarget *depthStencilTarget
);
2020-12-16 23:15:42 +00:00
/* Sends a framebuffer to be destroyed by the renderer. Note that we call it
2020-12-16 22:53:34 +00:00
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2020-12-16 23:15:42 +00:00
* framebuffer: The REFRESH_Framebuffer to be destroyed.
2020-12-16 22:53:34 +00:00
*/
2020-12-16 23:15:42 +00:00
REFRESHAPI void REFRESH_AddDisposeFramebuffer(
2020-12-16 22:53:34 +00:00
REFRESH_Device *device,
2020-12-16 23:15:42 +00:00
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
2020-12-16 22:53:34 +00:00
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2020-12-16 23:15:42 +00:00
* shaderModule: The REFRESH_ShaderModule to be destroyed.
2020-12-16 22:53:34 +00:00
*/
2020-12-16 23:15:42 +00:00
REFRESHAPI void REFRESH_AddDisposeShaderModule(
2020-12-16 22:53:34 +00:00
REFRESH_Device *device,
2020-12-16 23:15:42 +00:00
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
2020-12-16 22:59:14 +00:00
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
2020-12-16 23:15:42 +00:00
* renderPass: The REFRESH_RenderPass to be destroyed.
2020-12-16 22:59:14 +00:00
*/
2020-12-16 23:15:42 +00:00
REFRESHAPI void REFRESH_AddDisposeRenderPass(
2020-12-16 22:59:14 +00:00
REFRESH_Device *device,
2020-12-16 23:15:42 +00:00
REFRESH_RenderPass *renderPass
);
2020-12-29 22:52:24 +00:00
/* Sends a compute pipeline to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* computePipeline: The REFRESH_ComputePipeline to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeComputePipeline(
REFRESH_Device *device,
REFRESH_ComputePipeline *computePipeline
);
2020-12-16 23:15:42 +00:00
/* Sends a graphics pipeline to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* graphicsPipeline: The REFRESH_GraphicsPipeline to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeGraphicsPipeline(
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:
2020-12-20 08:05:12 +00:00
* A pointer to an array of REFRESH_Color structures
* 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
*/
REFRESHAPI void REFRESH_BeginRenderPass(
REFRESH_Device *device,
REFRESH_RenderPass *renderPass,
REFRESH_Framebuffer *framebuffer,
REFRESH_Rect renderArea,
2020-12-20 08:05:12 +00:00
REFRESH_Color *pColorClearValues,
uint32_t colorClearCount,
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. */
REFRESHAPI void REFRESH_EndRenderPass(
REFRESH_Device *device
);
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. */
2020-12-16 22:53:34 +00:00
REFRESHAPI void REFRESH_BindGraphicsPipeline(
REFRESH_Device *device,
REFRESH_GraphicsPipeline *graphicsPipeline
);
2020-12-21 23:44:43 +00:00
/* Binds vertex buffers for use with subsequent draw calls. */
2020-12-20 07:31:55 +00:00
REFRESHAPI void REFRESH_BindVertexBuffers(
REFRESH_Device *device,
uint32_t firstBinding,
uint32_t bindingCount,
REFRESH_Buffer **pBuffers,
uint64_t *pOffsets
);
2020-12-21 23:44:43 +00:00
/* Binds an index buffer for use with subsequent draw calls. */
2020-12-20 07:31:55 +00:00
REFRESHAPI void REFRESH_BindIndexBuffer(
REFRESH_Device *device,
REFRESH_Buffer *buffer,
uint64_t offset,
REFRESH_IndexElementSize indexElementSize
);
2020-12-30 01:31:39 +00:00
/* Binds a compute pipeline to the compute bind point. */
REFRESHAPI void REFRESH_BindComputePipeline(
REFRESH_Device *device,
REFRESH_ComputePipeline *computePipeline
);
/* 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.
*/
REFRESHAPI void REFRESH_BindComputeBuffers(
REFRESH_Device *device,
REFRESH_Buffer **pBuffers
);
/* 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.
*/
REFRESHAPI void REFRESH_BindComputeTextures(
REFRESH_Device *device,
REFRESH_Texture **pTextures
);
2020-12-21 23:44:43 +00:00
/* Submission/Presentation */
2020-12-17 04:19:11 +00:00
/* Queues an image to be presented to the screen.
2020-12-21 23:44:43 +00:00
* The image will be presented upon the next REFRESH_Submit call.
*
* 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.
2020-12-21 23:44:43 +00:00
* sourceRectangle: The region of the image to present (or NULL).
* destinationRectangle: The region of the window to update (or NULL).
*/
REFRESHAPI void REFRESH_QueuePresent(
2020-12-17 04:19:11 +00:00
REFRESH_Device *device,
REFRESH_TextureSlice *textureSlice,
2020-12-17 04:19:11 +00:00
REFRESH_Rect *sourceRectangle,
REFRESH_Rect *destinationRectangle
);
2020-12-21 23:44:43 +00:00
/* Submits all of the enqueued commands. */
REFRESHAPI void REFRESH_Submit(
REFRESH_Device* device
);
2020-12-15 23:00:46 +00:00
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* REFRESH_H */
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */