2022-03-02 19:10:28 +00:00
|
|
|
|
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
|
2020-12-15 23:00:46 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2020 Evan Hemsley
|
|
|
|
|
*
|
|
|
|
|
* This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
|
* In no event will the authors be held liable for any damages arising from
|
|
|
|
|
* the use of this software.
|
|
|
|
|
*
|
|
|
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
|
|
|
* including commercial applications, and to alter it and redistribute it
|
|
|
|
|
* freely, subject to the following restrictions:
|
|
|
|
|
*
|
|
|
|
|
* 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
|
* claim that you wrote the original software. If you use this software in a
|
|
|
|
|
* product, an acknowledgment in the product documentation would be
|
|
|
|
|
* appreciated but is not required.
|
|
|
|
|
*
|
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
|
* misrepresented as being the original software.
|
|
|
|
|
*
|
|
|
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
|
|
|
*
|
|
|
|
|
* Evan "cosmonaut" Hemsley <evan@moonside.games>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-12-16 22:59:14 +00:00
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2020-12-15 23:00:46 +00:00
|
|
|
|
#ifndef REFRESH_H
|
|
|
|
|
#define REFRESH_H
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#define REFRESHAPI __declspec(dllexport)
|
|
|
|
|
#define REFRESHCALL __cdecl
|
|
|
|
|
#else
|
|
|
|
|
#define REFRESHAPI
|
|
|
|
|
#define REFRESHCALL
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* -Wpedantic nameless union/struct silencing */
|
|
|
|
|
#ifndef REFRESHNAMELESS
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
|
#define REFRESHNAMELESS __extension__
|
|
|
|
|
#else
|
|
|
|
|
#define REFRESHNAMELESS
|
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
|
#endif /* REFRESHNAMELESS */
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
2022-03-04 01:31:33 +00:00
|
|
|
|
/* Version API */
|
|
|
|
|
|
|
|
|
|
#define REFRESH_MAJOR_VERSION 1
|
2022-11-09 20:04:01 +00:00
|
|
|
|
#define REFRESH_MINOR_VERSION 9
|
|
|
|
|
#define REFRESH_PATCH_VERSION 0
|
2022-03-04 01:31:33 +00:00
|
|
|
|
|
|
|
|
|
#define REFRESH_COMPILED_VERSION ( \
|
|
|
|
|
(REFRESH_MAJOR_VERSION * 100 * 100) + \
|
|
|
|
|
(REFRESH_MINOR_VERSION * 100) + \
|
|
|
|
|
(REFRESH_PATCH_VERSION) \
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
REFRESHAPI uint32_t Refresh_LinkedVersion(void);
|
|
|
|
|
|
2020-12-15 23:00:46 +00:00
|
|
|
|
/* Type Declarations */
|
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_Device Refresh_Device;
|
|
|
|
|
typedef struct Refresh_Buffer Refresh_Buffer;
|
|
|
|
|
typedef struct Refresh_Texture Refresh_Texture;
|
|
|
|
|
typedef struct Refresh_Sampler Refresh_Sampler;
|
|
|
|
|
typedef struct Refresh_ShaderModule Refresh_ShaderModule;
|
|
|
|
|
typedef struct Refresh_ComputePipeline Refresh_ComputePipeline;
|
|
|
|
|
typedef struct Refresh_GraphicsPipeline Refresh_GraphicsPipeline;
|
|
|
|
|
typedef struct Refresh_CommandBuffer Refresh_CommandBuffer;
|
|
|
|
|
|
|
|
|
|
typedef enum Refresh_PresentMode
|
2020-12-17 03:50:31 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_PRESENTMODE_IMMEDIATE,
|
|
|
|
|
REFRESH_PRESENTMODE_MAILBOX,
|
|
|
|
|
REFRESH_PRESENTMODE_FIFO,
|
|
|
|
|
REFRESH_PRESENTMODE_FIFO_RELAXED
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_PresentMode;
|
2020-12-17 03:50:31 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_PrimitiveType
|
2020-12-16 02:29:26 +00:00
|
|
|
|
{
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_PRIMITIVETYPE_POINTLIST,
|
2020-12-16 02:29:26 +00:00
|
|
|
|
REFRESH_PRIMITIVETYPE_LINELIST,
|
|
|
|
|
REFRESH_PRIMITIVETYPE_LINESTRIP,
|
|
|
|
|
REFRESH_PRIMITIVETYPE_TRIANGLELIST,
|
2020-12-17 00:27:14 +00:00
|
|
|
|
REFRESH_PRIMITIVETYPE_TRIANGLESTRIP
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_PrimitiveType;
|
2020-12-16 02:29:26 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_LoadOp
|
2020-12-16 02:08:49 +00:00
|
|
|
|
{
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_LOADOP_LOAD,
|
|
|
|
|
REFRESH_LOADOP_CLEAR,
|
|
|
|
|
REFRESH_LOADOP_DONT_CARE
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_LoadOp;
|
2020-12-16 02:08:49 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_StoreOp
|
2020-12-16 02:08:49 +00:00
|
|
|
|
{
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_STOREOP_STORE,
|
|
|
|
|
REFRESH_STOREOP_DONT_CARE
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_StoreOp;
|
2020-12-15 23:00:46 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_IndexElementSize
|
2020-12-15 23:00:46 +00:00
|
|
|
|
{
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_INDEXELEMENTSIZE_16BIT,
|
|
|
|
|
REFRESH_INDEXELEMENTSIZE_32BIT
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_IndexElementSize;
|
2020-12-15 23:00:46 +00:00
|
|
|
|
|
2021-01-27 02:57:46 +00:00
|
|
|
|
typedef enum Refresh_TextureFormat
|
2021-01-03 22:53:12 +00:00
|
|
|
|
{
|
2022-09-13 20:51:41 +00:00
|
|
|
|
/* Unsigned Normalized Float Color Formats */
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_R8G8B8A8,
|
2022-03-02 06:33:57 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_B8G8R8A8,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_R5G6B5,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_A1R5G5B5,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_B4G4R4A4,
|
2022-09-13 20:51:41 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_A2R10G10B10,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R16G16,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R16G16B16A16,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R8,
|
|
|
|
|
/* Compressed Unsigned Normalized Float Color Formats */
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_BC1,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_BC2,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_BC3,
|
2022-05-12 04:16:24 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_BC7,
|
2022-09-13 20:51:41 +00:00
|
|
|
|
/* Signed Normalized Float Color Formats */
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_R8G8_SNORM,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM,
|
2022-09-13 20:51:41 +00:00
|
|
|
|
/* Signed Float Color Formats */
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_R16_SFLOAT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R16G16_SFLOAT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R16G16B16A16_SFLOAT,
|
2022-09-13 20:51:41 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_R32_SFLOAT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R32G32_SFLOAT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R32G32B32A32_SFLOAT,
|
|
|
|
|
/* Unsigned Integer Color Formats */
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R8_UINT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R8G8_UINT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R8G8B8A8_UINT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R16_UINT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R16G16_UINT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_R16G16B16A16_UINT,
|
2021-01-27 02:57:46 +00:00
|
|
|
|
/* Depth Formats */
|
|
|
|
|
REFRESH_TEXTUREFORMAT_D16_UNORM,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_D32_SFLOAT,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_TEXTUREFORMAT_D16_UNORM_S8_UINT,
|
|
|
|
|
REFRESH_TEXTUREFORMAT_D32_SFLOAT_S8_UINT
|
2021-01-27 02:57:46 +00:00
|
|
|
|
} Refresh_TextureFormat;
|
2020-12-15 23:00:46 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_TextureUsageFlagBits
|
2020-12-28 20:15:17 +00:00
|
|
|
|
{
|
2021-01-27 02:57:46 +00:00
|
|
|
|
REFRESH_TEXTUREUSAGE_SAMPLER_BIT = 0x00000001,
|
|
|
|
|
REFRESH_TEXTUREUSAGE_COLOR_TARGET_BIT = 0x00000002,
|
2022-08-25 19:21:49 +00:00
|
|
|
|
REFRESH_TEXTUREUSAGE_DEPTH_STENCIL_TARGET_BIT = 0x00000004,
|
|
|
|
|
REFRESH_TEXTUREUSAGE_COMPUTE_BIT = 0X00000008
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_TextureUsageFlagBits;
|
2020-12-28 21:40:26 +00:00
|
|
|
|
|
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,
|
Miscellaneous API changes + more MSAA fixes (#26)
**Breaking API Changes**
* Removed `REFRESH_SAMPLECOUNT_16/32/64`, since hardware support for these sample counts is generally poor (and completely non-existent with MoltenVK and certain consoles).
* Removed unused `sampleCount` parameter from `Refresh_TextureCreateInfo`.
* Removed `sampleCount` parameter from `Refresh_ColorAttachmentDescription`. The existence of this parameter meant you had to sync up three different sample count values (render pass, pipeline, and color attachment description) whenever you wanted to use multisampling. However, Vulkan requires that all color attachments in a given pipeline _must_ match the pipeline's sample count anyway, so we can assume all color attachments will use the pipeline's sample count.
* Removed the `renderArea` parameter from `Refresh_BeginRenderPass()` since it didn't serve much practical purpose and slightly complicated things on the MoonWorks managed side.
**Behavior Changes**
* When creating a render pass or graphics pipeline, the requested multisample count will be converted into a sample count that's actually supported by the GPU. For example, if you request 8x MSAA on a device that only supports up to 4x MSAA, it will silently fall back to 4x MSAA.
* All color attachments are now forced to have an internal store op of `STORE`, even if `REFRESH_STORE_OP_DONTCARE` is specified. The one exception is internal multisample textures -- if `DONTCARE` is used, those textures will be discarded to save on bandwidth. (Their resolve textures will still be stored.)
* The RenderPass hashing logic was updated so that it would still work correctly with the removal of `Refresh_ColorAttachmentDescription.sampleCount`.
**Bug Fixes**
* Fixed bugs where multisampling logic wasn't kicking in for certain sample counts due to incorrect enum comparisons.
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
Reviewed-on: https://gitea.moonside.games/MoonsideGames/Refresh/pulls/26
Co-authored-by: TheSpydog <thespydog@noreply.example.org>
Co-committed-by: TheSpydog <thespydog@noreply.example.org>
2022-11-08 19:09:21 +00:00
|
|
|
|
REFRESH_SAMPLECOUNT_8
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_SampleCount;
|
2020-12-17 08:19:02 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_CubeMapFace
|
2020-12-15 23:00:46 +00:00
|
|
|
|
{
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_CUBEMAPFACE_POSITIVEX,
|
|
|
|
|
REFRESH_CUBEMAPFACE_NEGATIVEX,
|
|
|
|
|
REFRESH_CUBEMAPFACE_POSITIVEY,
|
|
|
|
|
REFRESH_CUBEMAPFACE_NEGATIVEY,
|
|
|
|
|
REFRESH_CUBEMAPFACE_POSITIVEZ,
|
|
|
|
|
REFRESH_CUBEMAPFACE_NEGATIVEZ
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_CubeMapFace;
|
2020-12-15 23:00:46 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_BufferUsageFlagBits
|
2020-12-31 04:39:47 +00:00
|
|
|
|
{
|
2022-08-25 19:21:49 +00:00
|
|
|
|
REFRESH_BUFFERUSAGE_VERTEX_BIT = 0x00000001,
|
|
|
|
|
REFRESH_BUFFERUSAGE_INDEX_BIT = 0x00000002,
|
|
|
|
|
REFRESH_BUFFERUSAGE_COMPUTE_BIT = 0x00000004,
|
|
|
|
|
REFRESH_BUFFERUSAGE_INDIRECT_BIT = 0x00000008
|
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
|
|
|
|
{
|
2022-03-17 21:41:16 +00:00
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_UINT,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_FLOAT,
|
2020-12-16 20:11:43 +00:00
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_VECTOR2,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_VECTOR3,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_VECTOR4,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_COLOR,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_BYTE4,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_SHORT2,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_SHORT4,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_NORMALIZEDSHORT2,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_NORMALIZEDSHORT4,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_HALFVECTOR2,
|
|
|
|
|
REFRESH_VERTEXELEMENTFORMAT_HALFVECTOR4
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_VertexElementFormat;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_VertexInputRate
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_VERTEXINPUTRATE_VERTEX = 0,
|
|
|
|
|
REFRESH_VERTEXINPUTRATE_INSTANCE = 1
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_VertexInputRate;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_FillMode
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_FILLMODE_FILL,
|
2022-03-02 19:10:28 +00:00
|
|
|
|
REFRESH_FILLMODE_LINE
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_FillMode;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_CullMode
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_CULLMODE_NONE,
|
|
|
|
|
REFRESH_CULLMODE_FRONT,
|
2022-03-02 19:10:28 +00:00
|
|
|
|
REFRESH_CULLMODE_BACK
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_CullMode;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_FrontFace
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_FRONTFACE_COUNTER_CLOCKWISE,
|
|
|
|
|
REFRESH_FRONTFACE_CLOCKWISE
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_FrontFace;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_CompareOp
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_COMPAREOP_NEVER,
|
|
|
|
|
REFRESH_COMPAREOP_LESS,
|
|
|
|
|
REFRESH_COMPAREOP_EQUAL,
|
|
|
|
|
REFRESH_COMPAREOP_LESS_OR_EQUAL,
|
|
|
|
|
REFRESH_COMPAREOP_GREATER,
|
|
|
|
|
REFRESH_COMPAREOP_NOT_EQUAL,
|
|
|
|
|
REFRESH_COMPAREOP_GREATER_OR_EQUAL,
|
|
|
|
|
REFRESH_COMPAREOP_ALWAYS
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_CompareOp;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_StencilOp
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_STENCILOP_KEEP,
|
|
|
|
|
REFRESH_STENCILOP_ZERO,
|
|
|
|
|
REFRESH_STENCILOP_REPLACE,
|
|
|
|
|
REFRESH_STENCILOP_INCREMENT_AND_CLAMP,
|
|
|
|
|
REFRESH_STENCILOP_DECREMENT_AND_CLAMP,
|
|
|
|
|
REFRESH_STENCILOP_INVERT,
|
|
|
|
|
REFRESH_STENCILOP_INCREMENT_AND_WRAP,
|
|
|
|
|
REFRESH_STENCILOP_DECREMENT_AND_WRAP
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_StencilOp;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_BlendOp
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
2020-12-17 19:40:49 +00:00
|
|
|
|
REFRESH_BLENDOP_ADD,
|
|
|
|
|
REFRESH_BLENDOP_SUBTRACT,
|
|
|
|
|
REFRESH_BLENDOP_REVERSE_SUBTRACT,
|
|
|
|
|
REFRESH_BLENDOP_MIN,
|
|
|
|
|
REFRESH_BLENDOP_MAX
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_BlendOp;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_BlendFactor
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
2022-03-02 19:10:28 +00:00
|
|
|
|
REFRESH_BLENDFACTOR_ZERO,
|
|
|
|
|
REFRESH_BLENDFACTOR_ONE,
|
|
|
|
|
REFRESH_BLENDFACTOR_SRC_COLOR,
|
|
|
|
|
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_COLOR,
|
|
|
|
|
REFRESH_BLENDFACTOR_DST_COLOR,
|
|
|
|
|
REFRESH_BLENDFACTOR_ONE_MINUS_DST_COLOR,
|
|
|
|
|
REFRESH_BLENDFACTOR_SRC_ALPHA,
|
|
|
|
|
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
|
|
|
|
|
REFRESH_BLENDFACTOR_DST_ALPHA,
|
|
|
|
|
REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA,
|
|
|
|
|
REFRESH_BLENDFACTOR_CONSTANT_COLOR,
|
|
|
|
|
REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR,
|
2022-11-19 16:59:38 +00:00
|
|
|
|
REFRESH_BLENDFACTOR_SRC_ALPHA_SATURATE
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_BlendFactor;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_ColorComponentFlagBits
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
2022-02-25 21:42:11 +00:00
|
|
|
|
REFRESH_COLORCOMPONENT_R_BIT = 0x00000001,
|
|
|
|
|
REFRESH_COLORCOMPONENT_G_BIT = 0x00000002,
|
|
|
|
|
REFRESH_COLORCOMPONENT_B_BIT = 0x00000004,
|
|
|
|
|
REFRESH_COLORCOMPONENT_A_BIT = 0x00000008
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_ColorComponentFlagBits;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef uint32_t Refresh_ColorComponentFlags;
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_Filter
|
2020-12-16 20:47:54 +00:00
|
|
|
|
{
|
2021-01-03 21:01:29 +00:00
|
|
|
|
REFRESH_FILTER_NEAREST,
|
2022-03-02 19:10:28 +00:00
|
|
|
|
REFRESH_FILTER_LINEAR
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_Filter;
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_SamplerMipmapMode
|
2020-12-16 20:47:54 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_SAMPLERMIPMAPMODE_NEAREST,
|
|
|
|
|
REFRESH_SAMPLERMIPMAPMODE_LINEAR
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_SamplerMipmapMode;
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_SamplerAddressMode
|
2020-12-16 20:47:54 +00:00
|
|
|
|
{
|
|
|
|
|
REFRESH_SAMPLERADDRESSMODE_REPEAT,
|
|
|
|
|
REFRESH_SAMPLERADDRESSMODE_MIRRORED_REPEAT,
|
|
|
|
|
REFRESH_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
|
|
|
|
|
REFRESH_SAMPLERADDRESSMODE_CLAMP_TO_BORDER
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_SamplerAddressMode;
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2021-01-05 23:53:16 +00:00
|
|
|
|
/* FIXME: we should probably make a library-level decision about color types */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef enum Refresh_BorderColor
|
2020-12-16 20:47:54 +00:00
|
|
|
|
{
|
2022-03-02 19:10:28 +00:00
|
|
|
|
REFRESH_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK,
|
|
|
|
|
REFRESH_BORDERCOLOR_INT_TRANSPARENT_BLACK,
|
|
|
|
|
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_BLACK,
|
|
|
|
|
REFRESH_BORDERCOLOR_INT_OPAQUE_BLACK,
|
|
|
|
|
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_WHITE,
|
|
|
|
|
REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_BorderColor;
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2022-09-29 21:11:25 +00:00
|
|
|
|
typedef enum Refresh_Backend
|
|
|
|
|
{
|
|
|
|
|
REFRESH_BACKEND_DONTCARE,
|
|
|
|
|
REFRESH_BACKEND_VULKAN,
|
|
|
|
|
REFRESH_BACKEND_PS5,
|
|
|
|
|
REFRESH_BACKEND_INVALID
|
|
|
|
|
} Refresh_Backend;
|
|
|
|
|
|
2020-12-15 23:27:06 +00:00
|
|
|
|
/* Structures */
|
2020-12-15 23:00:46 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_DepthStencilValue
|
2020-12-16 21:28:06 +00:00
|
|
|
|
{
|
|
|
|
|
float depth;
|
|
|
|
|
uint32_t stencil;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_DepthStencilValue;
|
2020-12-16 21:28:06 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_Rect
|
2020-12-16 02:29:26 +00:00
|
|
|
|
{
|
|
|
|
|
int32_t x;
|
|
|
|
|
int32_t y;
|
|
|
|
|
int32_t w;
|
|
|
|
|
int32_t h;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_Rect;
|
2020-12-16 02:29:26 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_Vec4
|
2020-12-16 02:29:26 +00:00
|
|
|
|
{
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float z;
|
|
|
|
|
float w;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_Vec4;
|
2020-12-16 02:29:26 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_Viewport
|
2020-12-16 02:29:26 +00:00
|
|
|
|
{
|
2020-12-18 00:39:25 +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
|
|
|
|
|
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
|
|
|
|
|
2022-02-26 01:37:42 +00:00
|
|
|
|
typedef struct Refresh_ColorAttachmentBlendState
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
|
|
|
|
uint8_t blendEnable;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_BlendFactor srcColorBlendFactor;
|
|
|
|
|
Refresh_BlendFactor dstColorBlendFactor;
|
|
|
|
|
Refresh_BlendOp colorBlendOp;
|
|
|
|
|
Refresh_BlendFactor srcAlphaBlendFactor;
|
|
|
|
|
Refresh_BlendFactor dstAlphaBlendFactor;
|
|
|
|
|
Refresh_BlendOp alphaBlendOp;
|
|
|
|
|
Refresh_ColorComponentFlags colorWriteMask;
|
2022-02-26 01:37:42 +00:00
|
|
|
|
} Refresh_ColorAttachmentBlendState;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
|
|
|
|
|
typedef struct Refresh_ComputePipelineLayoutCreateInfo
|
2020-12-29 22:52:24 +00:00
|
|
|
|
{
|
|
|
|
|
uint32_t bufferBindingCount;
|
|
|
|
|
uint32_t imageBindingCount;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_ComputePipelineLayoutCreateInfo;
|
2020-12-29 22:52:24 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_ShaderModuleCreateInfo
|
2020-12-16 22:59:14 +00:00
|
|
|
|
{
|
|
|
|
|
size_t codeSize;
|
|
|
|
|
const uint32_t *byteCode;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_ShaderModuleCreateInfo;
|
2020-12-16 22:59:14 +00:00
|
|
|
|
|
2021-01-14 09:52:45 +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;
|
2021-01-14 09:52:45 +00:00
|
|
|
|
uint32_t levelCount;
|
2021-01-27 02:57:46 +00:00
|
|
|
|
Refresh_TextureFormat format;
|
2021-01-14 09:52:45 +00:00
|
|
|
|
Refresh_TextureUsageFlags usageFlags;
|
|
|
|
|
} Refresh_TextureCreateInfo;
|
|
|
|
|
|
2020-12-16 20:11:43 +00:00
|
|
|
|
/* Pipeline state structures */
|
|
|
|
|
|
2022-03-02 19:22:52 +00:00
|
|
|
|
typedef struct Refresh_GraphicsShaderInfo
|
2020-12-16 22:53:34 +00:00
|
|
|
|
{
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_ShaderModule *shaderModule;
|
2020-12-16 22:53:34 +00:00
|
|
|
|
const char* entryPointName;
|
2020-12-23 21:11:09 +00:00
|
|
|
|
uint64_t uniformBufferSize;
|
2022-03-02 19:10:28 +00:00
|
|
|
|
uint32_t samplerBindingCount;
|
2022-03-02 19:22:52 +00:00
|
|
|
|
} Refresh_GraphicsShaderInfo;
|
|
|
|
|
|
|
|
|
|
typedef struct Refresh_ComputeShaderInfo
|
|
|
|
|
{
|
|
|
|
|
Refresh_ShaderModule* shaderModule;
|
|
|
|
|
const char* entryPointName;
|
|
|
|
|
uint64_t uniformBufferSize;
|
|
|
|
|
uint32_t bufferBindingCount;
|
|
|
|
|
uint32_t imageBindingCount;
|
|
|
|
|
} Refresh_ComputeShaderInfo;
|
2020-12-16 22:53:34 +00:00
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_RasterizerState
|
2020-12-16 20:11:43 +00:00
|
|
|
|
{
|
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;
|
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
|
|
|
|
|
2022-02-24 22:01:37 +00:00
|
|
|
|
typedef struct Refresh_ColorAttachmentDescription
|
|
|
|
|
{
|
|
|
|
|
Refresh_TextureFormat format;
|
2022-02-26 01:37:42 +00:00
|
|
|
|
Refresh_ColorAttachmentBlendState blendState;
|
2022-02-24 22:01:37 +00:00
|
|
|
|
} Refresh_ColorAttachmentDescription;
|
|
|
|
|
|
|
|
|
|
typedef struct Refresh_GraphicsPipelineAttachmentInfo
|
|
|
|
|
{
|
2022-02-26 01:37:42 +00:00
|
|
|
|
Refresh_ColorAttachmentDescription *colorAttachmentDescriptions;
|
2022-02-24 22:01:37 +00:00
|
|
|
|
uint32_t colorAttachmentCount;
|
|
|
|
|
uint8_t hasDepthStencilAttachment;
|
|
|
|
|
Refresh_TextureFormat depthStencilFormat;
|
|
|
|
|
} Refresh_GraphicsPipelineAttachmentInfo;
|
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef struct Refresh_GraphicsPipelineCreateInfo
|
2020-12-16 22:53:34 +00:00
|
|
|
|
{
|
2022-03-02 19:22:52 +00:00
|
|
|
|
Refresh_GraphicsShaderInfo vertexShaderInfo;
|
|
|
|
|
Refresh_GraphicsShaderInfo fragmentShaderInfo;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_VertexInputState vertexInputState;
|
2021-01-14 05:06:20 +00:00
|
|
|
|
Refresh_PrimitiveType primitiveType;
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_RasterizerState rasterizerState;
|
|
|
|
|
Refresh_MultisampleState multisampleState;
|
|
|
|
|
Refresh_DepthStencilState depthStencilState;
|
2022-02-24 22:01:37 +00:00
|
|
|
|
Refresh_GraphicsPipelineAttachmentInfo attachmentInfo;
|
2022-03-02 19:10:28 +00:00
|
|
|
|
float blendConstants[4];
|
2021-01-05 23:00:51 +00:00
|
|
|
|
} Refresh_GraphicsPipelineCreateInfo;
|
|
|
|
|
|
2022-02-24 22:01:37 +00:00
|
|
|
|
/* Render pass structures */
|
|
|
|
|
|
|
|
|
|
typedef struct Refresh_ColorAttachmentInfo
|
|
|
|
|
{
|
2022-03-02 06:33:57 +00:00
|
|
|
|
Refresh_Texture *texture; /* We can't use TextureSlice because render passes take a single rectangle. */
|
|
|
|
|
uint32_t depth;
|
|
|
|
|
uint32_t layer;
|
|
|
|
|
uint32_t level;
|
|
|
|
|
Refresh_SampleCount sampleCount;
|
2022-02-24 22:01:37 +00:00
|
|
|
|
Refresh_Vec4 clearColor; /* Can be ignored by RenderPass */
|
|
|
|
|
Refresh_LoadOp loadOp;
|
|
|
|
|
Refresh_StoreOp storeOp;
|
|
|
|
|
} Refresh_ColorAttachmentInfo;
|
|
|
|
|
|
|
|
|
|
typedef struct Refresh_DepthStencilAttachmentInfo
|
2020-12-16 21:28:06 +00:00
|
|
|
|
{
|
2022-03-02 06:33:57 +00:00
|
|
|
|
Refresh_Texture *texture; /* We can't use TextureSlice because render passes take a single rectangle. */
|
|
|
|
|
uint32_t depth;
|
|
|
|
|
uint32_t layer;
|
|
|
|
|
uint32_t level;
|
|
|
|
|
Refresh_DepthStencilValue depthStencilClearValue; /* Can be ignored by RenderPass */
|
2022-02-24 22:01:37 +00:00
|
|
|
|
Refresh_LoadOp loadOp;
|
|
|
|
|
Refresh_StoreOp storeOp;
|
|
|
|
|
Refresh_LoadOp stencilLoadOp;
|
|
|
|
|
Refresh_StoreOp stencilStoreOp;
|
|
|
|
|
} Refresh_DepthStencilAttachmentInfo;
|
2020-12-16 21:28:06 +00:00
|
|
|
|
|
2020-12-15 23:00:46 +00:00
|
|
|
|
/* Functions */
|
|
|
|
|
|
2020-12-17 02:38:22 +00:00
|
|
|
|
/* Logging */
|
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
typedef void (REFRESHCALL * Refresh_LogFunc)(const char *msg);
|
2020-12-17 02:38:22 +00:00
|
|
|
|
|
2021-01-06 00:07:42 +00:00
|
|
|
|
/* Reroutes Refresh's logging to custom logging functions.
|
|
|
|
|
*
|
|
|
|
|
* info: Basic logs that might be useful to have stored for support.
|
|
|
|
|
* warn: Something went wrong, but it's really just annoying, not fatal.
|
|
|
|
|
* error: You better have this stored somewhere because it's crashing now!
|
|
|
|
|
*/
|
|
|
|
|
REFRESHAPI void Refresh_HookLogFunctions(
|
|
|
|
|
Refresh_LogFunc info,
|
|
|
|
|
Refresh_LogFunc warn,
|
|
|
|
|
Refresh_LogFunc error
|
|
|
|
|
);
|
|
|
|
|
|
2022-09-29 21:11:25 +00:00
|
|
|
|
/* Backend selection */
|
|
|
|
|
|
|
|
|
|
/* Select the graphics API backend that Refresh should use.
|
|
|
|
|
*
|
|
|
|
|
* Note that Refresh is not required to select your preferred backend
|
|
|
|
|
* if it detects an incompatibility.
|
|
|
|
|
*
|
|
|
|
|
* Returns the backend that will actually be used, and fills in a window flag bitmask.
|
|
|
|
|
* This bitmask should be used to create all windows that the device claims.
|
|
|
|
|
*
|
|
|
|
|
* preferredBackend: The preferred backend that Refresh should select.
|
|
|
|
|
* flags: A pointer to a bitflag value that will be filled in with required SDL_WindowFlags masks.
|
|
|
|
|
*/
|
|
|
|
|
REFRESHAPI Refresh_Backend Refresh_SelectBackend(Refresh_Backend preferredBackend, uint32_t *flags);
|
|
|
|
|
|
2020-12-16 23:33:09 +00:00
|
|
|
|
/* Device */
|
|
|
|
|
|
|
|
|
|
/* Create a rendering context for use on the calling thread.
|
2022-09-29 21:11:25 +00:00
|
|
|
|
* You MUST have called Refresh_SelectDriver prior to calling this function.
|
2020-12-16 23:33:09 +00:00
|
|
|
|
*
|
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(
|
2020-12-17 03:28:02 +00:00
|
|
|
|
uint8_t debugMode
|
2020-12-16 23:33:09 +00:00
|
|
|
|
);
|
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
/* Destroys a rendering context previously returned by Refresh_CreateDevice. */
|
|
|
|
|
REFRESHAPI void Refresh_DestroyDevice(Refresh_Device *device);
|
2020-12-16 23:33:09 +00:00
|
|
|
|
|
2020-12-16 02:29:26 +00:00
|
|
|
|
/* Drawing */
|
|
|
|
|
|
2020-12-20 09:29:15 +00:00
|
|
|
|
/* Draws data from vertex/index buffers with instancing enabled.
|
2020-12-16 02:29:26 +00:00
|
|
|
|
*
|
2022-08-25 19:21:49 +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,
|
2020-12-29 03:32:49 +00:00
|
|
|
|
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
|
|
|
|
*
|
2022-08-25 19:21:49 +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,
|
2020-12-29 03:32:49 +00:00
|
|
|
|
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
|
|
|
|
*
|
2022-08-25 19:21:49 +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,
|
2020-12-29 03:32:49 +00:00
|
|
|
|
uint32_t primitiveCount,
|
|
|
|
|
uint32_t vertexParamOffset,
|
|
|
|
|
uint32_t fragmentParamOffset
|
2020-12-16 02:29:26 +00:00
|
|
|
|
);
|
|
|
|
|
|
2022-08-25 19:21:49 +00:00
|
|
|
|
/* Similar to Refresh_DrawPrimitives, but draw parameters are set from a buffer.
|
|
|
|
|
*
|
|
|
|
|
* buffer: A buffer containing draw parameters.
|
|
|
|
|
* offsetInBytes: The offset to start reading from the draw buffer.
|
|
|
|
|
* drawCount: The number of draw parameter sets that should be read from the draw buffer.
|
|
|
|
|
* stride: The byte stride between sets of draw parameters.
|
|
|
|
|
* vertexParamOffset: The offset of the vertex shader param data.
|
|
|
|
|
* fragmentParamOffset: The offset of the fragment shader param data.
|
|
|
|
|
*/
|
|
|
|
|
REFRESHAPI void Refresh_DrawPrimitivesIndirect(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Buffer *buffer,
|
|
|
|
|
uint32_t offsetInBytes,
|
|
|
|
|
uint32_t drawCount,
|
|
|
|
|
uint32_t stride,
|
|
|
|
|
uint32_t vertexParamOffset,
|
|
|
|
|
uint32_t fragmentParamOffset
|
|
|
|
|
);
|
|
|
|
|
|
2020-12-30 01:31:39 +00:00
|
|
|
|
/* Dispatches work compute items.
|
|
|
|
|
*
|
2020-12-31 04:39:47 +00:00
|
|
|
|
* groupCountX: Number of local workgroups to dispatch in the X dimension.
|
|
|
|
|
* groupCountY: Number of local workgroups to dispatch in the Y dimension.
|
|
|
|
|
* groupCountZ: Number of local workgroups to dispatch in the Z dimension.
|
|
|
|
|
* computeParamOffset: The offset of the compute shader param data.
|
2020-12-30 01:31:39 +00:00
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_DispatchCompute(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2020-12-30 01:31:39 +00:00
|
|
|
|
uint32_t groupCountX,
|
|
|
|
|
uint32_t groupCountY,
|
2020-12-31 04:39:47 +00:00
|
|
|
|
uint32_t groupCountZ,
|
|
|
|
|
uint32_t computeParamOffset
|
2020-12-30 01:31:39 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 20:47:54 +00:00
|
|
|
|
/* State Creation */
|
2020-12-16 20:11:43 +00:00
|
|
|
|
|
2020-12-29 22:52:24 +00:00
|
|
|
|
/* Returns an allocated ComputePipeline* object. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI Refresh_ComputePipeline* Refresh_CreateComputePipeline(
|
|
|
|
|
Refresh_Device *device,
|
2022-03-02 19:22:52 +00:00
|
|
|
|
Refresh_ComputeShaderInfo *computeShaderInfo
|
2020-12-29 22:52:24 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Returns an allocated GraphicsPipeline* object. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI Refresh_GraphicsPipeline* Refresh_CreateGraphicsPipeline(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_GraphicsPipelineCreateInfo *pipelineCreateInfo
|
2020-12-16 20:11:43 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 21:49:10 +00:00
|
|
|
|
/* Returns an allocated Sampler* object. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI Refresh_Sampler* Refresh_CreateSampler(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_SamplerStateCreateInfo *samplerStateCreateInfo
|
2020-12-16 20:47:54 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 22:59:14 +00:00
|
|
|
|
/* Returns an allocated ShaderModule* object. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI Refresh_ShaderModule* Refresh_CreateShaderModule(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
|
2020-12-16 22:59:14 +00:00
|
|
|
|
);
|
|
|
|
|
|
2021-01-14 09:52:45 +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.
|
|
|
|
|
*/
|
2021-01-14 09:52:45 +00:00
|
|
|
|
REFRESHAPI Refresh_Texture* Refresh_CreateTexture(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2021-01-14 09:52:45 +00:00
|
|
|
|
Refresh_TextureCreateInfo *textureCreateInfo
|
2020-12-18 22:35:33 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-31 04:39:47 +00:00
|
|
|
|
/* Creates a buffer.
|
2020-12-16 22:02:03 +00:00
|
|
|
|
*
|
2020-12-31 04:39:47 +00:00
|
|
|
|
* usageFlags: Specifies how the buffer will be used.
|
|
|
|
|
* sizeInBytes: The length of the buffer.
|
2020-12-16 22:02:03 +00:00
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI Refresh_Buffer* Refresh_CreateBuffer(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_BufferUsageFlags usageFlags,
|
2020-12-16 22:53:34 +00:00
|
|
|
|
uint32_t sizeInBytes
|
2020-12-16 22:02:03 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 22:53:34 +00:00
|
|
|
|
/* Setters */
|
|
|
|
|
|
2021-01-03 22:37:02 +00:00
|
|
|
|
/* Uploads image data to a texture object.
|
2020-12-16 22:02:03 +00:00
|
|
|
|
*
|
2021-01-03 22:37:02 +00:00
|
|
|
|
* textureSlice: The texture slice to be updated.
|
|
|
|
|
* data: A pointer to the image data.
|
|
|
|
|
* dataLengthInBytes: The size of the image data.
|
2020-12-16 22:02:03 +00:00
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_SetTextureData(
|
|
|
|
|
Refresh_Device *driverData,
|
2021-11-15 04:36:26 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_TextureSlice *textureSlice,
|
2020-12-16 22:53:34 +00:00
|
|
|
|
void *data,
|
|
|
|
|
uint32_t dataLengthInBytes
|
2020-12-16 22:02:03 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-17 00:27:14 +00:00
|
|
|
|
/* Uploads YUV image data to three R8 texture objects.
|
2020-12-16 22:53:34 +00:00
|
|
|
|
*
|
|
|
|
|
* y: The texture storing the Y data.
|
|
|
|
|
* u: The texture storing the U (Cb) data.
|
|
|
|
|
* v: The texture storing the V (Cr) data.
|
|
|
|
|
* yWidth: The width of the Y plane.
|
|
|
|
|
* yHeight: The height of the Y plane.
|
|
|
|
|
* uvWidth: The width of the U/V planes.
|
|
|
|
|
* uvHeight: The height of the U/V planes.
|
|
|
|
|
* data: A pointer to the raw YUV image data.
|
|
|
|
|
* dataLength: The size of the image data in bytes.
|
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_SetTextureDataYUV(
|
|
|
|
|
Refresh_Device *driverData,
|
2021-11-15 04:36:26 +00:00
|
|
|
|
Refresh_CommandBuffer* commandBuffer,
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Texture *y,
|
|
|
|
|
Refresh_Texture *u,
|
|
|
|
|
Refresh_Texture *v,
|
2020-12-16 22:53:34 +00:00
|
|
|
|
uint32_t yWidth,
|
|
|
|
|
uint32_t yHeight,
|
|
|
|
|
uint32_t uvWidth,
|
|
|
|
|
uint32_t uvHeight,
|
|
|
|
|
void* data,
|
|
|
|
|
uint32_t dataLength
|
|
|
|
|
);
|
|
|
|
|
|
2021-01-03 21:01:29 +00:00
|
|
|
|
/* Performs an asynchronous texture-to-texture copy.
|
|
|
|
|
*
|
|
|
|
|
* sourceTextureSlice: The texture slice from which to copy.
|
|
|
|
|
* destinationTextureSlice: The texture slice to copy to.
|
|
|
|
|
* filter: The filter that will be used if the copy requires scaling.
|
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_CopyTextureToTexture(
|
|
|
|
|
Refresh_Device *driverData,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_TextureSlice *sourceTextureSlice,
|
|
|
|
|
Refresh_TextureSlice *destinationTextureSlice,
|
|
|
|
|
Refresh_Filter filter
|
2021-01-03 21:01:29 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Asynchronously copies image data from a texture slice into a buffer.
|
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
|
|
|
|
* The buffer will not contain correct data until the command buffer
|
|
|
|
|
* is submitted and completed.
|
|
|
|
|
*
|
|
|
|
|
* textureSlice: The texture object being copied.
|
|
|
|
|
* buffer: The buffer being filled with the image data.
|
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_CopyTextureToBuffer(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_TextureSlice *textureSlice,
|
|
|
|
|
Refresh_Buffer *buffer
|
2021-01-03 21:01:29 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-31 04:39:47 +00:00
|
|
|
|
/* Sets a region of the buffer with client data.
|
2020-12-20 07:35:30 +00:00
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
|
|
|
|
* Calling this function on a buffer after the buffer
|
2020-12-31 04:39:47 +00:00
|
|
|
|
* has been bound without calling Submit first is an error.
|
2020-12-16 22:53:34 +00:00
|
|
|
|
*
|
2020-12-31 04:39:47 +00:00
|
|
|
|
* buffer: The vertex buffer to be updated.
|
2020-12-16 22:53:34 +00:00
|
|
|
|
* offsetInBytes: The starting offset of the buffer to write into.
|
2020-12-31 04:39:47 +00:00
|
|
|
|
* data: The client data to write into the buffer.
|
|
|
|
|
* dataLength: The length of data from the client buffer to write.
|
2020-12-16 22:53:34 +00:00
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_SetBufferData(
|
|
|
|
|
Refresh_Device *device,
|
2022-01-13 23:08:08 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Buffer *buffer,
|
2020-12-16 22:53:34 +00:00
|
|
|
|
uint32_t offsetInBytes,
|
|
|
|
|
void* data,
|
|
|
|
|
uint32_t dataLength
|
|
|
|
|
);
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2020-12-29 03:32:49 +00:00
|
|
|
|
/* Pushes vertex shader params to the device.
|
|
|
|
|
* Returns a starting offset value to be used with draw calls.
|
2020-12-17 00:27:14 +00:00
|
|
|
|
*
|
2020-12-23 21:11:09 +00:00
|
|
|
|
* NOTE:
|
|
|
|
|
* A pipeline must be bound.
|
|
|
|
|
* Will use the block size of the currently bound vertex shader.
|
|
|
|
|
*
|
2020-12-17 00:27:14 +00:00
|
|
|
|
* data: The client data to write into the buffer.
|
2021-02-03 00:37:01 +00:00
|
|
|
|
* dataLengthInBytes: The length of the data to write.
|
2020-12-17 00:27:14 +00:00
|
|
|
|
*/
|
2021-02-01 05:17:27 +00:00
|
|
|
|
REFRESHAPI uint32_t Refresh_PushVertexShaderUniforms(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-01-12 22:41:10 +00:00
|
|
|
|
Refresh_CommandBuffer * commandBuffer,
|
2020-12-20 09:33:32 +00:00
|
|
|
|
void *data,
|
2021-02-03 00:37:01 +00:00
|
|
|
|
uint32_t dataLengthInBytes
|
2020-12-20 09:33:32 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-29 03:32:49 +00:00
|
|
|
|
/* Pushes fragment shader params to the device.
|
|
|
|
|
* Returns a starting offset value to be used with draw calls.
|
2020-12-20 09:33:32 +00:00
|
|
|
|
*
|
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.
|
|
|
|
|
*
|
2020-12-20 09:33:32 +00:00
|
|
|
|
* data: The client data to write into the buffer.
|
2021-02-03 00:37:01 +00:00
|
|
|
|
* dataLengthInBytes: The length of the data to write.
|
2020-12-20 09:33:32 +00:00
|
|
|
|
*/
|
2021-02-01 05:17:27 +00:00
|
|
|
|
REFRESHAPI uint32_t Refresh_PushFragmentShaderUniforms(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-01-12 22:41:10 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2020-12-17 00:27:14 +00:00
|
|
|
|
void *data,
|
2021-02-03 00:37:01 +00:00
|
|
|
|
uint32_t dataLengthInBytes
|
2020-12-17 00:27:14 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-31 04:39:47 +00:00
|
|
|
|
/* Pushes compute shader params to the device.
|
|
|
|
|
* Returns a starting offset value to be used with draw calls.
|
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
|
|
|
|
* A compute pipeline must be bound.
|
|
|
|
|
* Will use the block size of the currently bound compute shader.
|
|
|
|
|
*
|
2021-02-03 00:37:01 +00:00
|
|
|
|
* data: The client data to write into the buffer.
|
|
|
|
|
* dataLengthInBytes: The length of the data to write.
|
2020-12-31 04:39:47 +00:00
|
|
|
|
*/
|
2021-02-01 05:17:27 +00:00
|
|
|
|
REFRESHAPI uint32_t Refresh_PushComputeShaderUniforms(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-01-12 22:41:10 +00:00
|
|
|
|
Refresh_CommandBuffer * commandBuffer,
|
2020-12-31 04:39:47 +00:00
|
|
|
|
void *data,
|
2021-02-03 00:37:01 +00:00
|
|
|
|
uint32_t dataLengthInBytes
|
2020-12-31 04:39:47 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 22:53:34 +00:00
|
|
|
|
/* Getters */
|
|
|
|
|
|
2021-01-03 01:00:52 +00:00
|
|
|
|
/* Synchronously copies data from a buffer to a pointer.
|
|
|
|
|
* You probably want to wait for a sync point to call this.
|
|
|
|
|
*
|
|
|
|
|
* buffer: The buffer to copy data from.
|
|
|
|
|
* data: The pointer to copy data to.
|
|
|
|
|
* dataLengthInBytes: The length of data to copy.
|
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_GetBufferData(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Buffer *buffer,
|
2021-01-03 01:00:52 +00:00
|
|
|
|
void *data,
|
|
|
|
|
uint32_t dataLengthInBytes
|
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 22:53:34 +00:00
|
|
|
|
/* Disposal */
|
|
|
|
|
|
|
|
|
|
/* Sends a texture to be destroyed by the renderer. Note that we call it
|
2021-01-06 01:02:36 +00:00
|
|
|
|
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
|
2020-12-16 22:53:34 +00:00
|
|
|
|
* this is not called from the main thread (for example, if a garbage collector
|
|
|
|
|
* deletes the resource instead of the programmer).
|
|
|
|
|
*
|
2021-01-05 23:00:51 +00:00
|
|
|
|
* texture: The Refresh_Texture to be destroyed.
|
2020-12-16 22:53:34 +00:00
|
|
|
|
*/
|
2021-01-06 01:02:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_QueueDestroyTexture(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Texture *texture
|
2020-12-16 22:53:34 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 23:15:42 +00:00
|
|
|
|
/* Sends a sampler to be destroyed by the renderer. Note that we call it
|
2021-01-06 01:02:36 +00:00
|
|
|
|
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
|
2020-12-16 23:15:42 +00:00
|
|
|
|
* this is not called from the main thread (for example, if a garbage collector
|
|
|
|
|
* deletes the resource instead of the programmer).
|
|
|
|
|
*
|
2021-01-05 23:00:51 +00:00
|
|
|
|
* texture: The Refresh_Sampler to be destroyed.
|
2020-12-16 23:15:42 +00:00
|
|
|
|
*/
|
2021-01-06 01:02:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_QueueDestroySampler(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Sampler *sampler
|
2020-12-16 23:15:42 +00:00
|
|
|
|
);
|
|
|
|
|
|
2021-01-03 04:56:40 +00:00
|
|
|
|
/* Sends a buffer to be destroyed by the renderer. Note that we call it
|
2021-01-06 01:02:36 +00:00
|
|
|
|
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
|
2020-12-16 23:15:42 +00:00
|
|
|
|
* this is not called from the main thread (for example, if a garbage collector
|
|
|
|
|
* deletes the resource instead of the programmer).
|
|
|
|
|
*
|
2021-01-05 23:00:51 +00:00
|
|
|
|
* buffer: The Refresh_Buffer to be destroyed.
|
2020-12-16 23:15:42 +00:00
|
|
|
|
*/
|
2021-01-06 01:02:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_QueueDestroyBuffer(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Buffer *buffer
|
2020-12-16 23:15:42 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Sends a shader module to be destroyed by the renderer. Note that we call it
|
2021-01-06 01:02:36 +00:00
|
|
|
|
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
|
2020-12-16 22:53:34 +00:00
|
|
|
|
* this is not called from the main thread (for example, if a garbage collector
|
|
|
|
|
* deletes the resource instead of the programmer).
|
|
|
|
|
*
|
2021-01-05 23:00:51 +00:00
|
|
|
|
* shaderModule: The Refresh_ShaderModule to be destroyed.
|
2020-12-16 22:53:34 +00:00
|
|
|
|
*/
|
2021-01-06 01:02:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_QueueDestroyShaderModule(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_ShaderModule *shaderModule
|
2020-12-16 22:53:34 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-29 22:52:24 +00:00
|
|
|
|
/* Sends a compute pipeline to be destroyed by the renderer. Note that we call it
|
2021-01-06 01:02:36 +00:00
|
|
|
|
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
|
2020-12-29 22:52:24 +00:00
|
|
|
|
* this is not called from the main thread (for example, if a garbage collector
|
|
|
|
|
* deletes the resource instead of the programmer).
|
|
|
|
|
*
|
2021-01-05 23:00:51 +00:00
|
|
|
|
* computePipeline: The Refresh_ComputePipeline to be destroyed.
|
2020-12-29 22:52:24 +00:00
|
|
|
|
*/
|
2021-01-06 01:02:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_QueueDestroyComputePipeline(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_ComputePipeline *computePipeline
|
2020-12-29 22:52:24 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 23:15:42 +00:00
|
|
|
|
/* Sends a graphics pipeline to be destroyed by the renderer. Note that we call it
|
2021-01-06 01:02:36 +00:00
|
|
|
|
* "QueueDestroy" because it may not be immediately destroyed by the renderer if
|
2020-12-16 23:15:42 +00:00
|
|
|
|
* this is not called from the main thread (for example, if a garbage collector
|
|
|
|
|
* deletes the resource instead of the programmer).
|
|
|
|
|
*
|
2021-01-05 23:00:51 +00:00
|
|
|
|
* graphicsPipeline: The Refresh_GraphicsPipeline to be destroyed.
|
2020-12-16 23:15:42 +00:00
|
|
|
|
*/
|
2021-01-06 01:02:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_QueueDestroyGraphicsPipeline(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_GraphicsPipeline *graphicsPipeline
|
2020-12-16 22:59:14 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-16 22:53:34 +00:00
|
|
|
|
/* Graphics State */
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2020-12-16 21:28:06 +00:00
|
|
|
|
/* Begins a render pass.
|
2022-03-04 20:30:33 +00:00
|
|
|
|
* This will also set a default viewport and scissor state.
|
2020-12-16 21:28:06 +00:00
|
|
|
|
*
|
2022-02-24 22:01:37 +00:00
|
|
|
|
* colorAttachmentInfos:
|
|
|
|
|
* A pointer to an array of Refresh_ColorAttachmentInfo structures
|
|
|
|
|
* that contains render targets and clear values. May be NULL.
|
|
|
|
|
* colorAttachmentCount: The amount of structs in the above array.
|
|
|
|
|
* depthStencilAttachmentInfo: The depth/stencil render target and clear value. May be NULL.
|
2020-12-16 21:28:06 +00:00
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_BeginRenderPass(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2022-02-24 22:01:37 +00:00
|
|
|
|
Refresh_ColorAttachmentInfo *colorAttachmentInfos,
|
|
|
|
|
uint32_t colorAttachmentCount,
|
|
|
|
|
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo
|
2020-12-16 21:28:06 +00:00
|
|
|
|
);
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2020-12-16 21:28:06 +00:00
|
|
|
|
/* Ends the current render pass. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_EndRenderPass(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
2020-12-16 21:28:06 +00:00
|
|
|
|
);
|
2020-12-16 20:47:54 +00:00
|
|
|
|
|
2020-12-30 01:31:39 +00:00
|
|
|
|
/* Binds a graphics pipeline to the graphics bind point. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_BindGraphicsPipeline(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_GraphicsPipeline *graphicsPipeline
|
2020-12-16 22:53:34 +00:00
|
|
|
|
);
|
|
|
|
|
|
2022-03-04 20:30:33 +00:00
|
|
|
|
/* Sets the current viewport state. */
|
2022-03-04 20:47:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_SetViewport(
|
2022-03-04 20:30:33 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Viewport *viewport
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Sets the current scissor state. */
|
2022-03-04 20:47:36 +00:00
|
|
|
|
REFRESHAPI void Refresh_SetScissor(
|
2022-03-04 20:30:33 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Rect *scissor
|
|
|
|
|
);
|
|
|
|
|
|
2020-12-21 23:44:43 +00:00
|
|
|
|
/* Binds vertex buffers for use with subsequent draw calls. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_BindVertexBuffers(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2020-12-20 07:31:55 +00:00
|
|
|
|
uint32_t firstBinding,
|
|
|
|
|
uint32_t bindingCount,
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Buffer **pBuffers,
|
2020-12-20 07:31:55 +00:00
|
|
|
|
uint64_t *pOffsets
|
|
|
|
|
);
|
|
|
|
|
|
2020-12-21 23:44:43 +00:00
|
|
|
|
/* Binds an index buffer for use with subsequent draw calls. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_BindIndexBuffer(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Buffer *buffer,
|
2020-12-20 07:31:55 +00:00
|
|
|
|
uint64_t offset,
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_IndexElementSize indexElementSize
|
2020-12-20 07:31:55 +00:00
|
|
|
|
);
|
|
|
|
|
|
2021-01-06 01:00:06 +00:00
|
|
|
|
/* Sets textures/samplers for use with the currently bound vertex shader.
|
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
|
|
|
|
* The length of the passed arrays must be equal to the number
|
|
|
|
|
* of sampler bindings specified by the pipeline.
|
|
|
|
|
*
|
|
|
|
|
* textures: A pointer to an array of textures.
|
|
|
|
|
* samplers: A pointer to an array of samplers.
|
|
|
|
|
*/
|
|
|
|
|
REFRESHAPI void Refresh_BindVertexSamplers(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Texture **pTextures,
|
|
|
|
|
Refresh_Sampler **pSamplers
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Sets textures/samplers for use with the currently bound fragment shader.
|
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
|
|
|
|
* The length of the passed arrays must be equal to the number
|
|
|
|
|
* of sampler bindings specified by the pipeline.
|
|
|
|
|
*
|
|
|
|
|
* textures: A pointer to an array of textures.
|
|
|
|
|
* samplers: A pointer to an array of samplers.
|
|
|
|
|
*/
|
|
|
|
|
REFRESHAPI void Refresh_BindFragmentSamplers(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Texture **pTextures,
|
|
|
|
|
Refresh_Sampler **pSamplers
|
|
|
|
|
);
|
|
|
|
|
|
2020-12-30 01:31:39 +00:00
|
|
|
|
/* Binds a compute pipeline to the compute bind point. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_BindComputePipeline(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_ComputePipeline *computePipeline
|
2020-12-30 01:31:39 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Binds buffers for use with the currently bound compute pipeline.
|
|
|
|
|
*
|
|
|
|
|
* pBuffers: An array of buffers to bind.
|
|
|
|
|
* Length must be equal to the number of buffers
|
|
|
|
|
* specified by the compute pipeline.
|
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_BindComputeBuffers(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Buffer **pBuffers
|
2020-12-30 01:31:39 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Binds textures for use with the currently bound compute pipeline.
|
|
|
|
|
*
|
|
|
|
|
* pTextures: An array of textures to bind.
|
|
|
|
|
* Length must be equal to the number of buffers
|
|
|
|
|
* specified by the compute pipeline.
|
|
|
|
|
*/
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_BindComputeTextures(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_Texture **pTextures
|
2020-12-30 01:31:39 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-21 23:44:43 +00:00
|
|
|
|
/* Submission/Presentation */
|
2020-12-17 04:19:11 +00:00
|
|
|
|
|
2022-09-29 21:11:25 +00:00
|
|
|
|
/* Claims a window, creating a swapchain structure for it.
|
|
|
|
|
* This function MUST be called before any swapchain functions
|
|
|
|
|
* are called using the window.
|
|
|
|
|
*
|
|
|
|
|
* Returns 0 on swapchain creation failure.
|
|
|
|
|
*/
|
|
|
|
|
REFRESHAPI uint8_t Refresh_ClaimWindow(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
void *windowHandle,
|
|
|
|
|
Refresh_PresentMode presentMode
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Unclaims a window, destroying the swapchain structure for it.
|
|
|
|
|
* It is good practice to call this when a window is closed to
|
|
|
|
|
* prevent memory bloat, but windows are automatically unclaimed
|
|
|
|
|
* by DestroyDevice.
|
|
|
|
|
*/
|
|
|
|
|
REFRESHAPI void Refresh_UnclaimWindow(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
void *windowHandle
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Changes the present mode of the swapchain for the given window. */
|
|
|
|
|
REFRESHAPI void Refresh_SetSwapchainPresentMode(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
void *windowHandle,
|
|
|
|
|
Refresh_PresentMode presentMode
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* Returns the format of the swapchain for the given window. */
|
|
|
|
|
REFRESHAPI Refresh_TextureFormat Refresh_GetSwapchainFormat(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
void *windowHandle
|
|
|
|
|
);
|
|
|
|
|
|
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
|
|
|
|
|
);
|
|
|
|
|
|
2022-03-02 06:33:57 +00:00
|
|
|
|
/* Acquires a texture to use for presentation.
|
|
|
|
|
* May return NULL under certain conditions.
|
2022-03-10 18:21:49 +00:00
|
|
|
|
* If NULL, the user must ensure to not use the texture.
|
2022-03-02 06:33:57 +00:00
|
|
|
|
* Once a swapchain texture is acquired,
|
|
|
|
|
* it will automatically be presented on command buffer submission.
|
2020-12-21 23:44:43 +00:00
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
2022-03-02 06:33:57 +00:00
|
|
|
|
* It is not recommended to hold a reference to this texture long term.
|
2022-03-10 18:21:49 +00:00
|
|
|
|
*
|
|
|
|
|
* pWidth: A pointer to a uint32 that will be filled with the texture width.
|
|
|
|
|
* pHeight: A pointer to a uint32 that will be filled with the texture height.
|
2020-12-21 23:44:43 +00:00
|
|
|
|
*/
|
2022-03-02 06:33:57 +00:00
|
|
|
|
REFRESHAPI Refresh_Texture* Refresh_AcquireSwapchainTexture(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2022-03-10 18:21:49 +00:00
|
|
|
|
void *windowHandle,
|
|
|
|
|
uint32_t *pWidth,
|
|
|
|
|
uint32_t *pHeight
|
2022-03-02 06:33:57 +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
|
|
|
|
);
|
|
|
|
|
|
2022-03-02 06:33:57 +00:00
|
|
|
|
/* Waits for all submissions to complete. */
|
2021-01-05 23:00:51 +00:00
|
|
|
|
REFRESHAPI void Refresh_Wait(
|
|
|
|
|
Refresh_Device *device
|
2021-01-03 05:07:51 +00:00
|
|
|
|
);
|
|
|
|
|
|
2020-12-15 23:00:46 +00:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
|
|
#endif /* REFRESH_H */
|
|
|
|
|
|
|
|
|
|
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
|