Compare commits

..

2 Commits

Author SHA1 Message Date
cosmonaut bb948846c0 memory fixes 2022-02-18 22:22:45 -08:00
cosmonaut 209b4ae6dd start rework of submission flow 2022-02-18 19:05:18 -08:00
9 changed files with 4281 additions and 5490 deletions

View File

@ -1,13 +0,0 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
[*.{c,h}]
charset = utf-8-bom
max_line_length = 100

View File

@ -7,8 +7,8 @@ project(Refresh C)
option(BUILD_SHARED_LIBS "Build shared library" ON) option(BUILD_SHARED_LIBS "Build shared library" ON)
# Version # Version
SET(LIB_MAJOR_VERSION "1") SET(LIB_MAJOR_VERSION "0")
SET(LIB_MINOR_VERSION "5") SET(LIB_MINOR_VERSION "1")
SET(LIB_REVISION "0") SET(LIB_REVISION "0")
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}") SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")

View File

@ -1,4 +1,4 @@
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities /* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
* *
* Copyright (c) 2020 Evan Hemsley * Copyright (c) 2020 Evan Hemsley
* *
@ -52,27 +52,16 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* Version API */
#define REFRESH_MAJOR_VERSION 1
#define REFRESH_MINOR_VERSION 5
#define REFRESH_PATCH_VERSION 0
#define REFRESH_COMPILED_VERSION ( \
(REFRESH_MAJOR_VERSION * 100 * 100) + \
(REFRESH_MINOR_VERSION * 100) + \
(REFRESH_PATCH_VERSION) \
)
REFRESHAPI uint32_t Refresh_LinkedVersion(void);
/* Type Declarations */ /* Type Declarations */
typedef struct Refresh_Device Refresh_Device; typedef struct Refresh_Device Refresh_Device;
typedef struct Refresh_Buffer Refresh_Buffer; typedef struct Refresh_Buffer Refresh_Buffer;
typedef struct Refresh_Texture Refresh_Texture; typedef struct Refresh_Texture Refresh_Texture;
typedef struct Refresh_Sampler Refresh_Sampler; typedef struct Refresh_Sampler Refresh_Sampler;
typedef struct Refresh_RenderTarget Refresh_RenderTarget;
typedef struct Refresh_Framebuffer Refresh_Framebuffer;
typedef struct Refresh_ShaderModule Refresh_ShaderModule; typedef struct Refresh_ShaderModule Refresh_ShaderModule;
typedef struct Refresh_RenderPass Refresh_RenderPass;
typedef struct Refresh_ComputePipeline Refresh_ComputePipeline; typedef struct Refresh_ComputePipeline Refresh_ComputePipeline;
typedef struct Refresh_GraphicsPipeline Refresh_GraphicsPipeline; typedef struct Refresh_GraphicsPipeline Refresh_GraphicsPipeline;
typedef struct Refresh_CommandBuffer Refresh_CommandBuffer; typedef struct Refresh_CommandBuffer Refresh_CommandBuffer;
@ -107,6 +96,15 @@ typedef enum Refresh_StoreOp
REFRESH_STOREOP_DONT_CARE REFRESH_STOREOP_DONT_CARE
} Refresh_StoreOp; } Refresh_StoreOp;
typedef enum Refresh_ClearOptionsBits
{
REFRESH_CLEAROPTIONS_COLOR = 0x00000001,
REFRESH_CLEAROPTIONS_DEPTH = 0x00000002,
REFRESH_CLEAROPTIONS_STENCIL = 0x00000004,
} Refresh_ClearOptionsBits;
typedef uint32_t Refresh_ClearOptions;
typedef enum Refresh_IndexElementSize typedef enum Refresh_IndexElementSize
{ {
REFRESH_INDEXELEMENTSIZE_16BIT, REFRESH_INDEXELEMENTSIZE_16BIT,
@ -117,14 +115,12 @@ typedef enum Refresh_TextureFormat
{ {
/* Color Formats */ /* Color Formats */
REFRESH_TEXTUREFORMAT_R8G8B8A8, REFRESH_TEXTUREFORMAT_R8G8B8A8,
REFRESH_TEXTUREFORMAT_B8G8R8A8,
REFRESH_TEXTUREFORMAT_R5G6B5, REFRESH_TEXTUREFORMAT_R5G6B5,
REFRESH_TEXTUREFORMAT_A1R5G5B5, REFRESH_TEXTUREFORMAT_A1R5G5B5,
REFRESH_TEXTUREFORMAT_B4G4R4A4, REFRESH_TEXTUREFORMAT_B4G4R4A4,
REFRESH_TEXTUREFORMAT_BC1, REFRESH_TEXTUREFORMAT_BC1,
REFRESH_TEXTUREFORMAT_BC2, REFRESH_TEXTUREFORMAT_BC2,
REFRESH_TEXTUREFORMAT_BC3, REFRESH_TEXTUREFORMAT_BC3,
REFRESH_TEXTUREFORMAT_BC7,
REFRESH_TEXTUREFORMAT_R8G8_SNORM, REFRESH_TEXTUREFORMAT_R8G8_SNORM,
REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM, REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM,
REFRESH_TEXTUREFORMAT_A2R10G10B10, REFRESH_TEXTUREFORMAT_A2R10G10B10,
@ -185,8 +181,7 @@ typedef uint32_t Refresh_BufferUsageFlags;
typedef enum Refresh_VertexElementFormat typedef enum Refresh_VertexElementFormat
{ {
REFRESH_VERTEXELEMENTFORMAT_UINT, REFRESH_VERTEXELEMENTFORMAT_SINGLE,
REFRESH_VERTEXELEMENTFORMAT_FLOAT,
REFRESH_VERTEXELEMENTFORMAT_VECTOR2, REFRESH_VERTEXELEMENTFORMAT_VECTOR2,
REFRESH_VERTEXELEMENTFORMAT_VECTOR3, REFRESH_VERTEXELEMENTFORMAT_VECTOR3,
REFRESH_VERTEXELEMENTFORMAT_VECTOR4, REFRESH_VERTEXELEMENTFORMAT_VECTOR4,
@ -209,14 +204,16 @@ typedef enum Refresh_VertexInputRate
typedef enum Refresh_FillMode typedef enum Refresh_FillMode
{ {
REFRESH_FILLMODE_FILL, REFRESH_FILLMODE_FILL,
REFRESH_FILLMODE_LINE REFRESH_FILLMODE_LINE,
REFRESH_FILLMODE_POINT
} Refresh_FillMode; } Refresh_FillMode;
typedef enum Refresh_CullMode typedef enum Refresh_CullMode
{ {
REFRESH_CULLMODE_NONE, REFRESH_CULLMODE_NONE,
REFRESH_CULLMODE_FRONT, REFRESH_CULLMODE_FRONT,
REFRESH_CULLMODE_BACK REFRESH_CULLMODE_BACK,
REFRESH_CULLMODE_FRONT_AND_BACK
} Refresh_CullMode; } Refresh_CullMode;
typedef enum Refresh_FrontFace typedef enum Refresh_FrontFace
@ -258,25 +255,47 @@ typedef enum Refresh_BlendOp
REFRESH_BLENDOP_MAX REFRESH_BLENDOP_MAX
} Refresh_BlendOp; } Refresh_BlendOp;
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;
typedef enum Refresh_BlendFactor typedef enum Refresh_BlendFactor
{ {
REFRESH_BLENDFACTOR_ZERO, REFRESH_BLENDFACTOR_ZERO = 0,
REFRESH_BLENDFACTOR_ONE, REFRESH_BLENDFACTOR_ONE = 1,
REFRESH_BLENDFACTOR_SRC_COLOR, REFRESH_BLENDFACTOR_SRC_COLOR = 2,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_COLOR, REFRESH_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 3,
REFRESH_BLENDFACTOR_DST_COLOR, REFRESH_BLENDFACTOR_DST_COLOR = 4,
REFRESH_BLENDFACTOR_ONE_MINUS_DST_COLOR, REFRESH_BLENDFACTOR_ONE_MINUS_DST_COLOR = 5,
REFRESH_BLENDFACTOR_SRC_ALPHA, REFRESH_BLENDFACTOR_SRC_ALPHA = 6,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, REFRESH_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 7,
REFRESH_BLENDFACTOR_DST_ALPHA, REFRESH_BLENDFACTOR_DST_ALPHA = 8,
REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA, REFRESH_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 9,
REFRESH_BLENDFACTOR_CONSTANT_COLOR, REFRESH_BLENDFACTOR_CONSTANT_COLOR = 10,
REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR, REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR = 11,
REFRESH_BLENDFACTOR_SRC_ALPHA_SATURATE, REFRESH_BLENDFACTOR_CONSTANT_ALPHA = 12,
REFRESH_BLENDFACTOR_SRC1_COLOR, REFRESH_BLENDFACTOR_ONE_MINUS_CONSTANT_ALPHA = 13,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_COLOR, REFRESH_BLENDFACTOR_SRC_ALPHA_SATURATE = 14,
REFRESH_BLENDFACTOR_SRC1_ALPHA, REFRESH_BLENDFACTOR_SRC1_COLOR = 15,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_ALPHA REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_COLOR = 16,
REFRESH_BLENDFACTOR_SRC1_ALPHA = 17,
REFRESH_BLENDFACTOR_ONE_MINUS_SRC1_ALPHA = 18
} Refresh_BlendFactor; } Refresh_BlendFactor;
typedef enum Refresh_ColorComponentFlagBits typedef enum Refresh_ColorComponentFlagBits
@ -289,10 +308,17 @@ typedef enum Refresh_ColorComponentFlagBits
typedef uint32_t Refresh_ColorComponentFlags; typedef uint32_t Refresh_ColorComponentFlags;
typedef enum Refresh_ShaderStageType
{
REFRESH_SHADERSTAGE_VERTEX,
REFRESH_SHADERSTAGE_FRAGMENT
} Refresh_ShaderStageType;
typedef enum Refresh_Filter typedef enum Refresh_Filter
{ {
REFRESH_FILTER_NEAREST, REFRESH_FILTER_NEAREST,
REFRESH_FILTER_LINEAR REFRESH_FILTER_LINEAR,
REFRESH_FILTER_CUBIC
} Refresh_Filter; } Refresh_Filter;
typedef enum Refresh_SamplerMipmapMode typedef enum Refresh_SamplerMipmapMode
@ -312,12 +338,12 @@ typedef enum Refresh_SamplerAddressMode
/* FIXME: we should probably make a library-level decision about color types */ /* FIXME: we should probably make a library-level decision about color types */
typedef enum Refresh_BorderColor typedef enum Refresh_BorderColor
{ {
REFRESH_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK, REFRESH_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK = 0,
REFRESH_BORDERCOLOR_INT_TRANSPARENT_BLACK, REFRESH_BORDERCOLOR_INT_TRANSPARENT_BLACK = 1,
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_BLACK, REFRESH_BORDERCOLOR_FLOAT_OPAQUE_BLACK = 2,
REFRESH_BORDERCOLOR_INT_OPAQUE_BLACK, REFRESH_BORDERCOLOR_INT_OPAQUE_BLACK = 3,
REFRESH_BORDERCOLOR_FLOAT_OPAQUE_WHITE, REFRESH_BORDERCOLOR_FLOAT_OPAQUE_WHITE = 4,
REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE = 5
} Refresh_BorderColor; } Refresh_BorderColor;
/* Structures */ /* Structures */
@ -423,7 +449,7 @@ typedef struct Refresh_StencilOpState
uint32_t reference; uint32_t reference;
} Refresh_StencilOpState; } Refresh_StencilOpState;
typedef struct Refresh_ColorAttachmentBlendState typedef struct Refresh_ColorTargetBlendState
{ {
uint8_t blendEnable; uint8_t blendEnable;
Refresh_BlendFactor srcColorBlendFactor; Refresh_BlendFactor srcColorBlendFactor;
@ -433,7 +459,7 @@ typedef struct Refresh_ColorAttachmentBlendState
Refresh_BlendFactor dstAlphaBlendFactor; Refresh_BlendFactor dstAlphaBlendFactor;
Refresh_BlendOp alphaBlendOp; Refresh_BlendOp alphaBlendOp;
Refresh_ColorComponentFlags colorWriteMask; Refresh_ColorComponentFlags colorWriteMask;
} Refresh_ColorAttachmentBlendState; } Refresh_ColorTargetBlendState;
typedef struct Refresh_ComputePipelineLayoutCreateInfo typedef struct Refresh_ComputePipelineLayoutCreateInfo
{ {
@ -441,6 +467,36 @@ typedef struct Refresh_ComputePipelineLayoutCreateInfo
uint32_t imageBindingCount; uint32_t imageBindingCount;
} Refresh_ComputePipelineLayoutCreateInfo; } Refresh_ComputePipelineLayoutCreateInfo;
typedef struct Refresh_GraphicsPipelineLayoutCreateInfo
{
uint32_t vertexSamplerBindingCount;
uint32_t fragmentSamplerBindingCount;
} Refresh_GraphicsPipelineLayoutCreateInfo;
typedef struct Refresh_ColorTargetDescription
{
Refresh_TextureFormat format;
Refresh_SampleCount multisampleCount;
Refresh_LoadOp loadOp;
Refresh_StoreOp storeOp;
} Refresh_ColorTargetDescription;
typedef struct Refresh_DepthStencilTargetDescription
{
Refresh_TextureFormat depthStencilFormat;
Refresh_LoadOp loadOp;
Refresh_StoreOp storeOp;
Refresh_LoadOp stencilLoadOp;
Refresh_StoreOp stencilStoreOp;
} Refresh_DepthStencilTargetDescription;
typedef struct Refresh_RenderPassCreateInfo
{
const Refresh_ColorTargetDescription *colorTargetDescriptions;
uint32_t colorTargetCount;
const Refresh_DepthStencilTargetDescription *depthTargetDescription; /* can be NULL */
} Refresh_RenderPassCreateInfo;
typedef struct Refresh_ShaderModuleCreateInfo typedef struct Refresh_ShaderModuleCreateInfo
{ {
size_t codeSize; size_t codeSize;
@ -461,22 +517,20 @@ typedef struct Refresh_TextureCreateInfo
/* Pipeline state structures */ /* Pipeline state structures */
typedef struct Refresh_GraphicsShaderInfo typedef struct Refresh_ShaderStageState
{ {
Refresh_ShaderModule *shaderModule; Refresh_ShaderModule *shaderModule;
const char* entryPointName; const char* entryPointName;
uint64_t uniformBufferSize; uint64_t uniformBufferSize;
uint32_t samplerBindingCount; } Refresh_ShaderStageState;
} Refresh_GraphicsShaderInfo;
typedef struct Refresh_ComputeShaderInfo typedef struct Refresh_ViewportState
{ {
Refresh_ShaderModule* shaderModule; const Refresh_Viewport *viewports;
const char* entryPointName; uint32_t viewportCount;
uint64_t uniformBufferSize; const Refresh_Rect *scissors;
uint32_t bufferBindingCount; uint32_t scissorCount;
uint32_t imageBindingCount; } Refresh_ViewportState;
} Refresh_ComputeShaderInfo;
typedef struct Refresh_RasterizerState typedef struct Refresh_RasterizerState
{ {
@ -488,6 +542,7 @@ typedef struct Refresh_RasterizerState
float depthBiasConstantFactor; float depthBiasConstantFactor;
float depthBiasClamp; float depthBiasClamp;
float depthBiasSlopeFactor; float depthBiasSlopeFactor;
float lineWidth;
} Refresh_RasterizerState; } Refresh_RasterizerState;
typedef struct Refresh_MultisampleState typedef struct Refresh_MultisampleState
@ -509,60 +564,111 @@ typedef struct Refresh_DepthStencilState
float maxDepthBounds; float maxDepthBounds;
} Refresh_DepthStencilState; } Refresh_DepthStencilState;
typedef struct Refresh_ColorAttachmentDescription typedef struct Refresh_ColorBlendState
{ {
Refresh_TextureFormat format; uint8_t logicOpEnable;
Refresh_SampleCount sampleCount; Refresh_LogicOp logicOp;
Refresh_ColorAttachmentBlendState blendState; const Refresh_ColorTargetBlendState *blendStates;
} Refresh_ColorAttachmentDescription; uint32_t blendStateCount;
float blendConstants[4];
} Refresh_ColorBlendState;
typedef struct Refresh_GraphicsPipelineAttachmentInfo typedef struct Refresh_ComputePipelineCreateInfo
{ {
Refresh_ColorAttachmentDescription *colorAttachmentDescriptions; Refresh_ShaderStageState computeShaderState;
uint32_t colorAttachmentCount; Refresh_ComputePipelineLayoutCreateInfo pipelineLayoutCreateInfo;
uint8_t hasDepthStencilAttachment; } Refresh_ComputePipelineCreateInfo;
Refresh_TextureFormat depthStencilFormat;
} Refresh_GraphicsPipelineAttachmentInfo;
typedef struct Refresh_GraphicsPipelineCreateInfo typedef struct Refresh_GraphicsPipelineCreateInfo
{ {
Refresh_GraphicsShaderInfo vertexShaderInfo; Refresh_ShaderStageState vertexShaderState;
Refresh_GraphicsShaderInfo fragmentShaderInfo; Refresh_ShaderStageState fragmentShaderState;
Refresh_VertexInputState vertexInputState; Refresh_VertexInputState vertexInputState;
Refresh_PrimitiveType primitiveType; Refresh_PrimitiveType primitiveType;
Refresh_ViewportState viewportState;
Refresh_RasterizerState rasterizerState; Refresh_RasterizerState rasterizerState;
Refresh_MultisampleState multisampleState; Refresh_MultisampleState multisampleState;
Refresh_DepthStencilState depthStencilState; Refresh_DepthStencilState depthStencilState;
Refresh_GraphicsPipelineAttachmentInfo attachmentInfo; Refresh_ColorBlendState colorBlendState;
float blendConstants[4]; Refresh_GraphicsPipelineLayoutCreateInfo pipelineLayoutCreateInfo;
Refresh_RenderPass *renderPass;
} Refresh_GraphicsPipelineCreateInfo; } Refresh_GraphicsPipelineCreateInfo;
/* Render pass structures */ typedef struct Refresh_FramebufferCreateInfo
typedef struct Refresh_ColorAttachmentInfo
{ {
Refresh_Texture *texture; /* We can't use TextureSlice because render passes take a single rectangle. */ Refresh_RenderPass *renderPass;
uint32_t depth; Refresh_RenderTarget **pColorTargets;
uint32_t layer; uint32_t colorTargetCount;
uint32_t level; Refresh_RenderTarget *pDepthStencilTarget;
Refresh_SampleCount sampleCount; uint32_t width;
Refresh_Vec4 clearColor; /* Can be ignored by RenderPass */ uint32_t height;
Refresh_LoadOp loadOp; } Refresh_FramebufferCreateInfo;
Refresh_StoreOp storeOp;
} Refresh_ColorAttachmentInfo;
typedef struct Refresh_DepthStencilAttachmentInfo /* Interop Structs */
typedef enum Refresh_SysRendererType
{ {
Refresh_Texture *texture; /* We can't use TextureSlice because render passes take a single rectangle. */ REFRESH_RENDERER_TYPE_VULKAN
uint32_t depth; } Refresh_SysRendererType;
uint32_t layer;
uint32_t level; typedef struct Refresh_SysRenderer
Refresh_DepthStencilValue depthStencilClearValue; /* Can be ignored by RenderPass */ {
Refresh_LoadOp loadOp; Refresh_SysRendererType rendererType;
Refresh_StoreOp storeOp;
Refresh_LoadOp stencilLoadOp; union
Refresh_StoreOp stencilStoreOp; {
} Refresh_DepthStencilAttachmentInfo; #if REFRESH_DRIVER_VULKAN
struct
{
void* instance;
void* physicalDevice;
void* logicalDevice;
uint32_t queueFamilyIndex;
} vulkan;
#endif /* REFRESH_DRIVER_VULKAN */
uint8_t filler[64];
} renderer;
} Refresh_SysRenderer;
typedef struct Refresh_TextureHandles
{
Refresh_SysRendererType rendererType;
union
{
#if REFRESH_DRIVER_VULKAN
#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
#define REFRESH_VULKAN_HANDLE_TYPE void*
#else
#define REFRESH_VULKAN_HANDLE_TYPE uint64_t
#endif
struct
{
REFRESH_VULKAN_HANDLE_TYPE image; /* VkImage */
REFRESH_VULKAN_HANDLE_TYPE view; /* VkImageView */
} vulkan;
#endif /* REFRESH_DRIVER_VULKAN */
uint8_t filler[64];
} texture;
} Refresh_TextureHandles;
/* 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 */ /* Functions */
@ -586,7 +692,8 @@ REFRESHAPI void Refresh_HookLogFunctions(
/* Create a rendering context for use on the calling thread. /* Create a rendering context for use on the calling thread.
* *
* presentationParameters: A window handle and presentation mode. * presentationParameters:
* If the windowHandle is NULL, Refresh will run in headless mode.
* debugMode: Enable debug mode properties. * debugMode: Enable debug mode properties.
*/ */
REFRESHAPI Refresh_Device* Refresh_CreateDevice( REFRESHAPI Refresh_Device* Refresh_CreateDevice(
@ -599,6 +706,30 @@ REFRESHAPI void Refresh_DestroyDevice(Refresh_Device *device);
/* Drawing */ /* Drawing */
/* Clears the targets of the currently bound framebuffer.
* If fewer colors are passed than the number of color targets in the
* framebuffer, this function will clear the first n color targets.
*
* NOTE:
* It is generally recommended to clear in BeginRenderPass
* rather than by calling this function unless necessary.
*
* clearRect: Area to clear.
* options: Bitflags to specify color/depth/stencil buffers for clearing.
* colors: An array of color values for the cleared color buffers.
* colorCount: The number of colors in the above array.
* depthStencil: Depth and stencil values for the cleared depth stencil buffer.
*/
REFRESHAPI void Refresh_Clear(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Vec4 *colors,
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
);
/* Draws data from vertex/index buffers with instancing enabled. /* Draws data from vertex/index buffers with instancing enabled.
* *
* baseVertex: The starting offset to read from the vertex buffer. * baseVertex: The starting offset to read from the vertex buffer.
@ -671,10 +802,16 @@ REFRESHAPI void Refresh_DispatchCompute(
/* State Creation */ /* State Creation */
/* Returns an allocated RenderPass* object. */
REFRESHAPI Refresh_RenderPass* Refresh_CreateRenderPass(
Refresh_Device *device,
Refresh_RenderPassCreateInfo *renderPassCreateInfo
);
/* Returns an allocated ComputePipeline* object. */ /* Returns an allocated ComputePipeline* object. */
REFRESHAPI Refresh_ComputePipeline* Refresh_CreateComputePipeline( REFRESHAPI Refresh_ComputePipeline* Refresh_CreateComputePipeline(
Refresh_Device *device, Refresh_Device *device,
Refresh_ComputeShaderInfo *computeShaderInfo Refresh_ComputePipelineCreateInfo *pipelineCreateInfo
); );
/* Returns an allocated GraphicsPipeline* object. */ /* Returns an allocated GraphicsPipeline* object. */
@ -689,6 +826,12 @@ REFRESHAPI Refresh_Sampler* Refresh_CreateSampler(
Refresh_SamplerStateCreateInfo *samplerStateCreateInfo Refresh_SamplerStateCreateInfo *samplerStateCreateInfo
); );
/* Returns an allocated Framebuffer* object. */
REFRESHAPI Refresh_Framebuffer* Refresh_CreateFramebuffer(
Refresh_Device *device,
Refresh_FramebufferCreateInfo *framebufferCreateInfo
);
/* Returns an allocated ShaderModule* object. */ /* Returns an allocated ShaderModule* object. */
REFRESHAPI Refresh_ShaderModule* Refresh_CreateShaderModule( REFRESHAPI Refresh_ShaderModule* Refresh_CreateShaderModule(
Refresh_Device *device, Refresh_Device *device,
@ -703,6 +846,17 @@ REFRESHAPI Refresh_Texture* Refresh_CreateTexture(
Refresh_TextureCreateInfo *textureCreateInfo Refresh_TextureCreateInfo *textureCreateInfo
); );
/* Creates a color target.
*
* textureSlice: The texture slice that the color target will resolve to.
* multisampleCount: The MSAA value for the color target.
*/
REFRESHAPI Refresh_RenderTarget* Refresh_CreateRenderTarget(
Refresh_Device *device,
Refresh_TextureSlice *textureSlice,
Refresh_SampleCount multisampleCount
);
/* Creates a buffer. /* Creates a buffer.
* *
* usageFlags: Specifies how the buffer will be used. * usageFlags: Specifies how the buffer will be used.
@ -884,6 +1038,7 @@ REFRESHAPI void Refresh_GetBufferData(
*/ */
REFRESHAPI void Refresh_QueueDestroyTexture( REFRESHAPI void Refresh_QueueDestroyTexture(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture *texture Refresh_Texture *texture
); );
@ -896,6 +1051,7 @@ REFRESHAPI void Refresh_QueueDestroyTexture(
*/ */
REFRESHAPI void Refresh_QueueDestroySampler( REFRESHAPI void Refresh_QueueDestroySampler(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Sampler *sampler Refresh_Sampler *sampler
); );
@ -908,9 +1064,36 @@ REFRESHAPI void Refresh_QueueDestroySampler(
*/ */
REFRESHAPI void Refresh_QueueDestroyBuffer( REFRESHAPI void Refresh_QueueDestroyBuffer(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer Refresh_Buffer *buffer
); );
/* Sends a color target to be destroyed by the renderer. Note that we call it
* "QueueDestroy" 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).
*
* renderTarget: The Refresh_ColorTarget to be destroyed.
*/
REFRESHAPI void Refresh_QueueDestroyRenderTarget(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_RenderTarget *renderTarget
);
/* Sends a framebuffer to be destroyed by the renderer. Note that we call it
* "QueueDestroy" 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).
*
* framebuffer: The Refresh_Framebuffer to be destroyed.
*/
REFRESHAPI void Refresh_QueueDestroyFramebuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Framebuffer *frameBuffer
);
/* Sends a shader module to be destroyed by the renderer. Note that we call it /* Sends a shader module to be destroyed by the renderer. Note that we call it
* "QueueDestroy" because it may not be immediately destroyed by the renderer if * "QueueDestroy" 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 * this is not called from the main thread (for example, if a garbage collector
@ -920,9 +1103,23 @@ REFRESHAPI void Refresh_QueueDestroyBuffer(
*/ */
REFRESHAPI void Refresh_QueueDestroyShaderModule( REFRESHAPI void Refresh_QueueDestroyShaderModule(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_ShaderModule *shaderModule Refresh_ShaderModule *shaderModule
); );
/* Sends a render pass to be destroyed by the renderer. Note that we call it
* "QueueDestroy" 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).
*
* renderPass: The Refresh_RenderPass to be destroyed.
*/
REFRESHAPI void Refresh_QueueDestroyRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_RenderPass *renderPass
);
/* Sends a compute pipeline to be destroyed by the renderer. Note that we call it /* Sends a compute pipeline to be destroyed by the renderer. Note that we call it
* "QueueDestroy" because it may not be immediately destroyed by the renderer if * "QueueDestroy" 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 * this is not called from the main thread (for example, if a garbage collector
@ -932,6 +1129,7 @@ REFRESHAPI void Refresh_QueueDestroyShaderModule(
*/ */
REFRESHAPI void Refresh_QueueDestroyComputePipeline( REFRESHAPI void Refresh_QueueDestroyComputePipeline(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_ComputePipeline *computePipeline Refresh_ComputePipeline *computePipeline
); );
@ -944,32 +1142,36 @@ REFRESHAPI void Refresh_QueueDestroyComputePipeline(
*/ */
REFRESHAPI void Refresh_QueueDestroyGraphicsPipeline( REFRESHAPI void Refresh_QueueDestroyGraphicsPipeline(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline Refresh_GraphicsPipeline *graphicsPipeline
); );
/* Graphics State */ /* Graphics State */
/* Begins a render pass. /* Begins a render pass.
* This will also set a default viewport and scissor state.
* *
* renderPass: The renderpass to begin.
* framebuffer: The framebuffer to bind for the render pass.
* renderArea: * renderArea:
* The area affected by the render pass. * The area affected by the render pass.
* All load, store and resolve operations are restricted * All load, store and resolve operations are restricted
* to the given rectangle. * to the given rectangle.
* If NULL, a sensible default will be chosen. * clearValues:
* colorAttachmentInfos: * A pointer to an array of Refresh_Color structures
* A pointer to an array of Refresh_ColorAttachmentInfo structures * that contains clear values for each color target in the
* that contains render targets and clear values. May be NULL. * framebuffer. May be NULL.
* colorAttachmentCount: The amount of structs in the above array. * clearCount: The amount of color structs in the above array.
* depthStencilAttachmentInfo: The depth/stencil render target and clear value. May be NULL. * depthStencilClearValue: The depth/stencil clear value. May be NULL.
*/ */
REFRESHAPI void Refresh_BeginRenderPass( REFRESHAPI void Refresh_BeginRenderPass(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
Refresh_RenderPass *renderPass,
Refresh_Framebuffer *framebuffer,
Refresh_Rect *renderArea, Refresh_Rect *renderArea,
Refresh_ColorAttachmentInfo *colorAttachmentInfos, Refresh_Vec4 *pColorClearValues,
uint32_t colorAttachmentCount, uint32_t colorClearCount,
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo Refresh_DepthStencilValue *depthStencilClearValue
); );
/* Ends the current render pass. */ /* Ends the current render pass. */
@ -985,20 +1187,6 @@ REFRESHAPI void Refresh_BindGraphicsPipeline(
Refresh_GraphicsPipeline *graphicsPipeline Refresh_GraphicsPipeline *graphicsPipeline
); );
/* Sets the current viewport state. */
REFRESHAPI void Refresh_SetViewport(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Viewport *viewport
);
/* Sets the current scissor state. */
REFRESHAPI void Refresh_SetScissor(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *scissor
);
/* Binds vertex buffers for use with subsequent draw calls. */ /* Binds vertex buffers for use with subsequent draw calls. */
REFRESHAPI void Refresh_BindVertexBuffers( REFRESHAPI void Refresh_BindVertexBuffers(
Refresh_Device *device, Refresh_Device *device,
@ -1102,29 +1290,23 @@ REFRESHAPI Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
uint8_t fixed uint8_t fixed
); );
/* Acquires a texture to use for presentation. /* Queues an image to be presented to a window.
* May return NULL under certain conditions. * The image will be presented upon the next Refresh_Submit call.
* If NULL, the user must ensure to not use the texture.
* Once a swapchain texture is acquired,
* it will automatically be presented on command buffer submission.
* *
* NOTE: * NOTE:
* It is not recommended to hold a reference to this texture long term. * It is an error to call this function in headless mode.
* *
* pWidth: A pointer to a uint32 that will be filled with the texture width. * textureSlice: The texture slice to present.
* pHeight: A pointer to a uint32 that will be filled with the texture height. * destinationRectangle: The region of the window to update. Can be NULL.
* filter: The filter to use if scaling is required.
* windowHandle: The window to present to.
*/ */
REFRESHAPI Refresh_Texture* Refresh_AcquireSwapchainTexture( REFRESHAPI void Refresh_QueuePresent(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
void *windowHandle, Refresh_TextureSlice *textureSlice,
uint32_t *pWidth, Refresh_Rect *destinationRectangle,
uint32_t *pHeight Refresh_Filter filter,
);
/* Returns the format of the swapchain for the given window. */
REFRESHAPI Refresh_TextureFormat Refresh_GetSwapchainFormat(
Refresh_Device *device,
void *windowHandle void *windowHandle
); );
@ -1135,7 +1317,7 @@ REFRESHAPI void Refresh_Submit(
Refresh_CommandBuffer **pCommandBuffers Refresh_CommandBuffer **pCommandBuffers
); );
/* Waits for all submissions to complete. */ /* Waits for the previous submission to complete. */
REFRESHAPI void Refresh_Wait( REFRESHAPI void Refresh_Wait(
Refresh_Device *device Refresh_Device *device
); );

View File

@ -68,19 +68,17 @@ REFRESHAPI void Refresh_Image_Free(uint8_t *mem);
/* Image Write API */ /* Image Write API */
/* Encodes 32-bit color data into PNG data. /* Encodes RGBA8 image data into PNG data.
* *
* filename: The filename that the image will be written to. * filename: The filename that the image will be written to.
* w: The width of the PNG data. * w: The width of the PNG data.
* h: The height of the PNG data. * h: The height of the PNG data.
* bgra: Whether the data is in BGRA8 format. Otherwise will assume RBGA8. * data: The raw RGBA8 image data.
* data: The raw color data.
*/ */
REFRESHAPI void Refresh_Image_SavePNG( REFRESHAPI void Refresh_Image_SavePNG(
char const *filename, char const *filename,
int32_t w, int32_t w,
int32_t h, int32_t h,
uint8_t bgra,
uint8_t *data uint8_t *data
); );

View File

@ -1,4 +1,4 @@
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities /* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
* *
* Copyright (c) 2020 Evan Hemsley * Copyright (c) 2020 Evan Hemsley
* *
@ -34,12 +34,7 @@
/* Drivers */ /* Drivers */
static const Refresh_Driver *drivers[] = { static const Refresh_Driver *drivers[] = {
#ifdef REFRESH_DRIVER_VULKAN
&VulkanDriver, &VulkanDriver,
#endif
#ifdef REFRESH_DRIVER_PS5
&PS5Driver,
#endif
NULL NULL
}; };
@ -152,6 +147,27 @@ void Refresh_DestroyDevice(Refresh_Device *device)
device->DestroyDevice(device); device->DestroyDevice(device);
} }
void Refresh_Clear(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Vec4 *colors,
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
) {
NULL_RETURN(device);
device->Clear(
device->driverData,
commandBuffer,
clearRect,
options,
colors,
colorCount,
depthStencil
);
}
void Refresh_DrawIndexedPrimitives( void Refresh_DrawIndexedPrimitives(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
@ -234,14 +250,25 @@ void Refresh_DispatchCompute(
); );
} }
Refresh_RenderPass* Refresh_CreateRenderPass(
Refresh_Device *device,
Refresh_RenderPassCreateInfo *renderPassCreateInfo
) {
NULL_RETURN_NULL(device);
return device->CreateRenderPass(
device->driverData,
renderPassCreateInfo
);
}
Refresh_ComputePipeline* Refresh_CreateComputePipeline( Refresh_ComputePipeline* Refresh_CreateComputePipeline(
Refresh_Device *device, Refresh_Device *device,
Refresh_ComputeShaderInfo *computeShaderInfo Refresh_ComputePipelineCreateInfo *pipelineCreateInfo
) { ) {
NULL_RETURN_NULL(device); NULL_RETURN_NULL(device);
return device->CreateComputePipeline( return device->CreateComputePipeline(
device->driverData, device->driverData,
computeShaderInfo pipelineCreateInfo
); );
} }
@ -267,6 +294,17 @@ Refresh_Sampler* Refresh_CreateSampler(
); );
} }
Refresh_Framebuffer* Refresh_CreateFramebuffer(
Refresh_Device *device,
Refresh_FramebufferCreateInfo *framebufferCreateInfo
) {
NULL_RETURN_NULL(device);
return device->CreateFramebuffer(
device->driverData,
framebufferCreateInfo
);
}
Refresh_ShaderModule* Refresh_CreateShaderModule( Refresh_ShaderModule* Refresh_CreateShaderModule(
Refresh_Device *device, Refresh_Device *device,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
@ -289,6 +327,19 @@ Refresh_Texture* Refresh_CreateTexture(
); );
} }
Refresh_RenderTarget* Refresh_CreateRenderTarget(
Refresh_Device *device,
Refresh_TextureSlice *textureSlice,
Refresh_SampleCount multisampleCount
) {
NULL_RETURN_NULL(device);
return device->CreateRenderTarget(
device->driverData,
textureSlice,
multisampleCount
);
}
Refresh_Buffer* Refresh_CreateBuffer( Refresh_Buffer* Refresh_CreateBuffer(
Refresh_Device *device, Refresh_Device *device,
Refresh_BufferUsageFlags usageFlags, Refresh_BufferUsageFlags usageFlags,
@ -491,66 +542,117 @@ void Refresh_GetBufferData(
void Refresh_QueueDestroyTexture( void Refresh_QueueDestroyTexture(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture *texture Refresh_Texture *texture
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->QueueDestroyTexture( device->QueueDestroyTexture(
device->driverData, device->driverData,
commandBuffer,
texture texture
); );
} }
void Refresh_QueueDestroySampler( void Refresh_QueueDestroySampler(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Sampler *sampler Refresh_Sampler *sampler
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->QueueDestroySampler( device->QueueDestroySampler(
device->driverData, device->driverData,
commandBuffer,
sampler sampler
); );
} }
void Refresh_QueueDestroyBuffer( void Refresh_QueueDestroyBuffer(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer Refresh_Buffer *buffer
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->QueueDestroyBuffer( device->QueueDestroyBuffer(
device->driverData, device->driverData,
commandBuffer,
buffer buffer
); );
} }
void Refresh_QueueDestroyRenderTarget(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_RenderTarget *renderTarget
) {
NULL_RETURN(device);
device->QueueDestroyRenderTarget(
device->driverData,
commandBuffer,
renderTarget
);
}
void Refresh_QueueDestroyFramebuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Framebuffer *frameBuffer
) {
NULL_RETURN(device);
device->QueueDestroyFramebuffer(
device->driverData,
commandBuffer,
frameBuffer
);
}
void Refresh_QueueDestroyShaderModule( void Refresh_QueueDestroyShaderModule(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_ShaderModule *shaderModule Refresh_ShaderModule *shaderModule
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->QueueDestroyShaderModule( device->QueueDestroyShaderModule(
device->driverData, device->driverData,
commandBuffer,
shaderModule shaderModule
); );
} }
void Refresh_QueueDestroyRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_RenderPass *renderPass
) {
NULL_RETURN(device);
device->QueueDestroyRenderPass(
device->driverData,
commandBuffer,
renderPass
);
}
void Refresh_QueueDestroyComputePipeline( void Refresh_QueueDestroyComputePipeline(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_ComputePipeline *computePipeline Refresh_ComputePipeline *computePipeline
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->QueueDestroyComputePipeline( device->QueueDestroyComputePipeline(
device->driverData, device->driverData,
commandBuffer,
computePipeline computePipeline
); );
} }
void Refresh_QueueDestroyGraphicsPipeline( void Refresh_QueueDestroyGraphicsPipeline(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline Refresh_GraphicsPipeline *graphicsPipeline
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->QueueDestroyGraphicsPipeline( device->QueueDestroyGraphicsPipeline(
device->driverData, device->driverData,
commandBuffer,
graphicsPipeline graphicsPipeline
); );
} }
@ -558,19 +660,23 @@ void Refresh_QueueDestroyGraphicsPipeline(
void Refresh_BeginRenderPass( void Refresh_BeginRenderPass(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
Refresh_RenderPass *renderPass,
Refresh_Framebuffer *framebuffer,
Refresh_Rect *renderArea, Refresh_Rect *renderArea,
Refresh_ColorAttachmentInfo *colorAttachmentInfos, Refresh_Vec4 *pColorClearValues,
uint32_t colorAttachmentCount, uint32_t colorClearCount,
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo Refresh_DepthStencilValue *depthStencilClearValue
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->BeginRenderPass( device->BeginRenderPass(
device->driverData, device->driverData,
commandBuffer, commandBuffer,
renderPass,
framebuffer,
renderArea, renderArea,
colorAttachmentInfos, pColorClearValues,
colorAttachmentCount, colorClearCount,
depthStencilAttachmentInfo depthStencilClearValue
); );
} }
@ -585,32 +691,6 @@ void Refresh_EndRenderPass(
); );
} }
void Refresh_SetViewport(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Viewport *viewport
) {
NULL_RETURN(device)
device->SetViewport(
device->driverData,
commandBuffer,
viewport
);
}
void Refresh_SetScissor(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *scissor
) {
NULL_RETURN(device)
device->SetScissor(
device->driverData,
commandBuffer,
scissor
);
}
void Refresh_BindGraphicsPipeline( void Refresh_BindGraphicsPipeline(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
@ -710,30 +790,21 @@ Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
); );
} }
Refresh_Texture* Refresh_AcquireSwapchainTexture( void Refresh_QueuePresent(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
void *windowHandle, Refresh_TextureSlice* textureSlice,
uint32_t *pWidth, Refresh_Rect *destinationRectangle,
uint32_t *pHeight Refresh_Filter filter,
) {
NULL_RETURN_NULL(device);
return device->AcquireSwapchainTexture(
device->driverData,
commandBuffer,
windowHandle,
pWidth,
pHeight
);
}
Refresh_TextureFormat Refresh_GetSwapchainFormat(
Refresh_Device *device,
void *windowHandle void *windowHandle
) { ) {
if (device == NULL) { return 0; } NULL_RETURN(device);
return device->GetSwapchainFormat( device->QueuePresent(
device->driverData, device->driverData,
commandBuffer,
textureSlice,
destinationRectangle,
filter,
windowHandle windowHandle
); );
} }

View File

@ -1,4 +1,4 @@
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities /* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
* *
* Copyright (c) 2020 Evan Hemsley * Copyright (c) 2020 Evan Hemsley
* *
@ -36,15 +36,9 @@
/* Logging */ /* Logging */
#ifdef __cplusplus extern void Refresh_LogInfo(const char *fmt, ...);
extern "C" { extern void Refresh_LogWarn(const char *fmt, ...);
#endif extern void Refresh_LogError(const char *fmt, ...);
void Refresh_LogInfo(const char *fmt, ...);
void Refresh_LogWarn(const char *fmt, ...);
void Refresh_LogError(const char *fmt, ...);
#ifdef __cplusplus
}
#endif
/* Internal Helper Utilities */ /* Internal Helper Utilities */
@ -57,7 +51,6 @@ static inline uint32_t Texture_GetFormatSize(
return 8; return 8;
case REFRESH_TEXTUREFORMAT_BC2: case REFRESH_TEXTUREFORMAT_BC2:
case REFRESH_TEXTUREFORMAT_BC3: case REFRESH_TEXTUREFORMAT_BC3:
case REFRESH_TEXTUREFORMAT_BC7:
return 16; return 16;
case REFRESH_TEXTUREFORMAT_R8: case REFRESH_TEXTUREFORMAT_R8:
return 1; return 1;
@ -124,8 +117,7 @@ static inline uint32_t BytesPerRow(
if ( format == REFRESH_TEXTUREFORMAT_BC1 || if ( format == REFRESH_TEXTUREFORMAT_BC1 ||
format == REFRESH_TEXTUREFORMAT_BC2 || format == REFRESH_TEXTUREFORMAT_BC2 ||
format == REFRESH_TEXTUREFORMAT_BC3 || format == REFRESH_TEXTUREFORMAT_BC3 )
format == REFRESH_TEXTUREFORMAT_BC7 )
{ {
blocksPerRow = (width + 3) / 4; blocksPerRow = (width + 3) / 4;
} }
@ -143,8 +135,7 @@ static inline int32_t BytesPerImage(
if ( format == REFRESH_TEXTUREFORMAT_BC1 || if ( format == REFRESH_TEXTUREFORMAT_BC1 ||
format == REFRESH_TEXTUREFORMAT_BC2 || format == REFRESH_TEXTUREFORMAT_BC2 ||
format == REFRESH_TEXTUREFORMAT_BC3 || format == REFRESH_TEXTUREFORMAT_BC3 )
format == REFRESH_TEXTUREFORMAT_BC7 )
{ {
blocksPerRow = (width + 3) / 4; blocksPerRow = (width + 3) / 4;
blocksPerColumn = (height + 3) / 4; blocksPerColumn = (height + 3) / 4;
@ -163,7 +154,6 @@ static inline int32_t BytesPerImage(
#define MAX_BUFFER_BINDINGS 16 #define MAX_BUFFER_BINDINGS 16
#define MAX_COLOR_TARGET_BINDINGS 4 #define MAX_COLOR_TARGET_BINDINGS 4
#define MAX_PRESENT_COUNT 16
/* Refresh_Device Definition */ /* Refresh_Device Definition */
@ -177,6 +167,16 @@ struct Refresh_Device
/* Drawing */ /* Drawing */
void (*Clear)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Vec4 *colors,
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
);
void (*DrawInstancedPrimitives)( void (*DrawInstancedPrimitives)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
@ -218,9 +218,14 @@ struct Refresh_Device
/* State Creation */ /* State Creation */
Refresh_RenderPass* (*CreateRenderPass)(
Refresh_Renderer *driverData,
Refresh_RenderPassCreateInfo *renderPassCreateInfo
);
Refresh_ComputePipeline* (*CreateComputePipeline)( Refresh_ComputePipeline* (*CreateComputePipeline)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_ComputeShaderInfo *computeShaderInfo Refresh_ComputePipelineCreateInfo *pipelineCreateInfo
); );
Refresh_GraphicsPipeline* (*CreateGraphicsPipeline)( Refresh_GraphicsPipeline* (*CreateGraphicsPipeline)(
@ -233,6 +238,11 @@ struct Refresh_Device
Refresh_SamplerStateCreateInfo *samplerStateCreateInfo Refresh_SamplerStateCreateInfo *samplerStateCreateInfo
); );
Refresh_Framebuffer* (*CreateFramebuffer)(
Refresh_Renderer *driverData,
Refresh_FramebufferCreateInfo *framebufferCreateInfo
);
Refresh_ShaderModule* (*CreateShaderModule)( Refresh_ShaderModule* (*CreateShaderModule)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
@ -243,6 +253,12 @@ struct Refresh_Device
Refresh_TextureCreateInfo *textureCreateInfo Refresh_TextureCreateInfo *textureCreateInfo
); );
Refresh_RenderTarget* (*CreateRenderTarget)(
Refresh_Renderer *driverData,
Refresh_TextureSlice *textureSlice,
Refresh_SampleCount multisampleCount
);
Refresh_Buffer* (*CreateBuffer)( Refresh_Buffer* (*CreateBuffer)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_BufferUsageFlags usageFlags, Refresh_BufferUsageFlags usageFlags,
@ -345,31 +361,55 @@ struct Refresh_Device
void(*QueueDestroyTexture)( void(*QueueDestroyTexture)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture *texture Refresh_Texture *texture
); );
void(*QueueDestroySampler)( void(*QueueDestroySampler)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Sampler *sampler Refresh_Sampler *sampler
); );
void(*QueueDestroyBuffer)( void(*QueueDestroyBuffer)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer Refresh_Buffer *buffer
); );
void(*QueueDestroyRenderTarget)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_RenderTarget *renderTarget
);
void(*QueueDestroyFramebuffer)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Framebuffer *frameBuffer
);
void(*QueueDestroyShaderModule)( void(*QueueDestroyShaderModule)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_ShaderModule *shaderModule Refresh_ShaderModule *shaderModule
); );
void(*QueueDestroyRenderPass)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_RenderPass *renderPass
);
void(*QueueDestroyComputePipeline)( void(*QueueDestroyComputePipeline)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_ComputePipeline *computePipeline Refresh_ComputePipeline *computePipeline
); );
void(*QueueDestroyGraphicsPipeline)( void(*QueueDestroyGraphicsPipeline)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline Refresh_GraphicsPipeline *graphicsPipeline
); );
@ -378,10 +418,12 @@ struct Refresh_Device
void(*BeginRenderPass)( void(*BeginRenderPass)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
Refresh_RenderPass *renderPass,
Refresh_Framebuffer *framebuffer,
Refresh_Rect *renderArea, Refresh_Rect *renderArea,
Refresh_ColorAttachmentInfo *colorAttachmentInfos, Refresh_Vec4 *pColorClearValues,
uint32_t colorAttachmentCount, uint32_t colorClearCount,
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo Refresh_DepthStencilValue *depthStencilClearValue
); );
void(*EndRenderPass)( void(*EndRenderPass)(
@ -389,18 +431,6 @@ struct Refresh_Device
Refresh_CommandBuffer *commandBuffer Refresh_CommandBuffer *commandBuffer
); );
void(*SetViewport)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Viewport *viewport
);
void(*SetScissor)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *scissor
);
void(*BindGraphicsPipeline)( void(*BindGraphicsPipeline)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
@ -447,16 +477,12 @@ struct Refresh_Device
uint8_t fixed uint8_t fixed
); );
Refresh_Texture* (*AcquireSwapchainTexture)( void(*QueuePresent)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
void *windowHandle, Refresh_TextureSlice *textureSlice,
uint32_t *pWidth, Refresh_Rect *destinationRectangle,
uint32_t *pHeight Refresh_Filter filter,
);
Refresh_TextureFormat (*GetSwapchainFormat)(
Refresh_Renderer *driverData,
void *windowHandle void *windowHandle
); );
@ -478,15 +504,19 @@ struct Refresh_Device
result->func = name##_##func; result->func = name##_##func;
#define ASSIGN_DRIVER(name) \ #define ASSIGN_DRIVER(name) \
ASSIGN_DRIVER_FUNC(DestroyDevice, name) \ ASSIGN_DRIVER_FUNC(DestroyDevice, name) \
ASSIGN_DRIVER_FUNC(Clear, name) \
ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \
ASSIGN_DRIVER_FUNC(DispatchCompute, name) \ ASSIGN_DRIVER_FUNC(DispatchCompute, name) \
ASSIGN_DRIVER_FUNC(CreateRenderPass, name) \
ASSIGN_DRIVER_FUNC(CreateComputePipeline, name) \ ASSIGN_DRIVER_FUNC(CreateComputePipeline, name) \
ASSIGN_DRIVER_FUNC(CreateGraphicsPipeline, name) \ ASSIGN_DRIVER_FUNC(CreateGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(CreateSampler, name) \ ASSIGN_DRIVER_FUNC(CreateSampler, name) \
ASSIGN_DRIVER_FUNC(CreateFramebuffer, name) \
ASSIGN_DRIVER_FUNC(CreateShaderModule, name) \ ASSIGN_DRIVER_FUNC(CreateShaderModule, name) \
ASSIGN_DRIVER_FUNC(CreateTexture, name) \ ASSIGN_DRIVER_FUNC(CreateTexture, name) \
ASSIGN_DRIVER_FUNC(CreateRenderTarget, name) \
ASSIGN_DRIVER_FUNC(CreateBuffer, name) \ ASSIGN_DRIVER_FUNC(CreateBuffer, name) \
ASSIGN_DRIVER_FUNC(SetTextureData, name) \ ASSIGN_DRIVER_FUNC(SetTextureData, name) \
ASSIGN_DRIVER_FUNC(SetTextureDataYUV, name) \ ASSIGN_DRIVER_FUNC(SetTextureDataYUV, name) \
@ -502,13 +532,14 @@ struct Refresh_Device
ASSIGN_DRIVER_FUNC(QueueDestroyTexture, name) \ ASSIGN_DRIVER_FUNC(QueueDestroyTexture, name) \
ASSIGN_DRIVER_FUNC(QueueDestroySampler, name) \ ASSIGN_DRIVER_FUNC(QueueDestroySampler, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyBuffer, name) \ ASSIGN_DRIVER_FUNC(QueueDestroyBuffer, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyRenderTarget, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyFramebuffer, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyShaderModule, name) \ ASSIGN_DRIVER_FUNC(QueueDestroyShaderModule, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyRenderPass, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyComputePipeline, name) \ ASSIGN_DRIVER_FUNC(QueueDestroyComputePipeline, name) \
ASSIGN_DRIVER_FUNC(QueueDestroyGraphicsPipeline, name) \ ASSIGN_DRIVER_FUNC(QueueDestroyGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(BeginRenderPass, name) \ ASSIGN_DRIVER_FUNC(BeginRenderPass, name) \
ASSIGN_DRIVER_FUNC(EndRenderPass, name) \ ASSIGN_DRIVER_FUNC(EndRenderPass, name) \
ASSIGN_DRIVER_FUNC(SetViewport, name) \
ASSIGN_DRIVER_FUNC(SetScissor, name) \
ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \ ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(BindVertexBuffers, name) \ ASSIGN_DRIVER_FUNC(BindVertexBuffers, name) \
ASSIGN_DRIVER_FUNC(BindIndexBuffer, name) \ ASSIGN_DRIVER_FUNC(BindIndexBuffer, name) \
@ -516,8 +547,7 @@ struct Refresh_Device
ASSIGN_DRIVER_FUNC(BindComputeBuffers, name) \ ASSIGN_DRIVER_FUNC(BindComputeBuffers, name) \
ASSIGN_DRIVER_FUNC(BindComputeTextures, name) \ ASSIGN_DRIVER_FUNC(BindComputeTextures, name) \
ASSIGN_DRIVER_FUNC(AcquireCommandBuffer, name) \ ASSIGN_DRIVER_FUNC(AcquireCommandBuffer, name) \
ASSIGN_DRIVER_FUNC(AcquireSwapchainTexture, name) \ ASSIGN_DRIVER_FUNC(QueuePresent, name) \
ASSIGN_DRIVER_FUNC(GetSwapchainFormat, name) \
ASSIGN_DRIVER_FUNC(Submit, name) \ ASSIGN_DRIVER_FUNC(Submit, name) \
ASSIGN_DRIVER_FUNC(Wait, name) ASSIGN_DRIVER_FUNC(Wait, name)
@ -531,7 +561,6 @@ typedef struct Refresh_Driver
} Refresh_Driver; } Refresh_Driver;
extern Refresh_Driver VulkanDriver; extern Refresh_Driver VulkanDriver;
extern Refresh_Driver PS5Driver;
#endif /* REFRESH_DRIVER_H */ #endif /* REFRESH_DRIVER_H */

View File

@ -1,629 +0,0 @@
/* 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>
*
*/
#if REFRESH_DRIVER_TEMPLATE
#include "Refresh_Driver.h"
#include <SDL.h>
#define NOT_IMPLEMENTED SDL_assert(0 && "Not implemented!");
/* Conversions */
static TEMPLATE_SURFACE_FORMAT_TYPE RefreshToTEMPLATE_SurfaceFormat[] =
{
0, /* R8G8B8A8 */
0, /* B8G8R8A8 */
0, /* R5G6B5 */
0, /* A1R5G5B5 */
0, /* B4G4R4A4 */
0, /* BC1 */
0, /* BC3 */
0, /* BC5 */
0, /* R8G8_SNORM */
0, /* R8G8B8A8_SNORM */
0, /* A2R10G10B10 */
0, /* R16G16 */
0, /* R16G16B16A16 */
0, /* R8 */
0, /* R32_SFLOAT */
0, /* R32G32_SFLOAT */
0, /* R32G32B32A32_SFLOAT */
0, /* R16_SFLOAT */
0, /* R16G16_SFLOAT */
0, /* R16G16B16A16_SFLOAT */
0, /* D16 */
0, /* D32 */
0, /* D16S8 */
0 /* D32S8 */
};
static TEMPLATE_VERTEX_FORMAT_TYPE RefreshToTEMPLATE_VertexFormat[] =
{
0, /* SINGLE */
0, /* VECTOR2 */
0, /* VECTOR3 */
0, /* VECTOR4 */
0, /* COLOR */
0, /* BYTE4 */
0, /* SHORT2 */
0, /* SHORT4 */
0, /* NORMALIZEDSHORT2 */
0, /* NORMALIZEDSHORT4 */
0, /* HALFVECTOR2 */
0 /* HALFVECTOR4 */
};
static TEMPLATE_INDEX_TYPE RefreshToTEMPLATE_IndexType[] =
{
0, /* 16BIT */
0 /* 32BIT */
};
static TEMPLATE_PRIMITIVE_TYPE RefreshToTEMPLATE_PrimitiveType[] =
{
0, /* POINTLIST */
0, /* LINELIST */
0, /* LINESTRIP */
0, /* TRIANGLELIST */
0 /* TRIANGLESTRIP */
};
static TEMPLATE_POLYGON_MODE_TYPE RefreshToTEMPLATE_PolygonMode[] =
{
0, /* FILL */
0, /* LINE */
};
static TEMPLATE_CULL_MODE_TYPE RefreshToTEMPLATE_CullMode[] =
{
0, /* NONE */
0, /* FRONT */
0, /* BACK */
};
static TEMPLATE_FRONT_FACE_TYPE RefreshToTEMPLATE_FrontFace[] =
{
0, /* COUNTER_CLOCKWISE */
0 /* CLOCKWISE */
};
static TEMPLATE_BLEND_FACTOR_TYPE RefreshToTEMPLATE_BlendFactor[] =
{
0, /* ZERO */
0, /* ONE */
0, /* SRC_COLOR */
0, /* ONE_MINUS_SRC_COLOR */
0, /* DST_COLOR */
0, /* ONE_MINUS_DST_COLOR */
0, /* SRC_ALPHA */
0, /* ONE_MINUS_SRC_ALPHA */
0, /* DST_ALPHA */
0, /* ONE_MINUS_DST_ALPHA */
0, /* CONSTANT_COLOR */
0, /* ONE_MINUS_CONSTANT_COLOR */
0, /* SRC_ALPHA_SATURATE */
0, /* SRC1_COLOR */
0, /* ONE_MINUS_SRC1_COLOR */
0, /* SRC1_ALPHA */
0 /* ONE_MINUS_SRC1_ALPHA */
};
static TEMPLATE_BLEND_OP_TYPE RefreshToTEMPLATE_BlendOp[] =
{
0, /* ADD */
0, /* SUBTRACT */
0, /* REVERSE_SUBTRACT */
0, /* MIN */
0 /* MAX */
};
static TEMPLATE_COMPARE_OP_TYPE RefreshToTEMPLATE_CompareOp[] =
{
0, /* NEVER */
0, /* LESS */
0, /* EQUAL */
0, /* LESS_OR_EQUAL */
0, /* GREATER */
0, /* NOT_EQUAL */
0, /* GREATER_OR_EQUAL */
0 /* ALWAYS */
};
static TEMPLATE_STENCIL_OP_TYPE RefreshToTEMPLATE_StencilOp[] =
{
0, /* KEEP */
0, /* ZERO */
0, /* REPLACE */
0, /* INCREMENT_AND_CLAMP */
0, /* DECREMENT_AND_CLAMP */
0, /* INVERT */
0, /* INCREMENT_AND_WRAP */
0 /* DECREMENT_AND_WRAP */
};
static TEMPLATE_ATTACHMENT_LOAD_OP_TYPE RefreshToTEMPLATE_LoadOp[] =
{
0, /* LOAD */
0, /* CLEAR */
0 /* DONT_CARE */
};
static TEMPLATE_ATTACHMENT_STORE_OP_TYPE RefreshToTEMPLATE_StoreOp[] =
{
0, /* STORE */
0 /* DONT_CARE */
};
static TEMPLATE_SAMPLE_COUNT_TYPE RefreshToTEMPLATE_SampleCount[] =
{
0, /* 1 */
0, /* 2 */
0, /* 4 */
0, /* 8 */
0, /* 16 */
0, /* 32 */
0 /* 64 */
};
static TEMPLATE_VERTEX_INPUT_RATE_TYPE RefreshToTEMPLATE_VertexInputRate[] =
{
0, /* VERTEX */
0 /* INSTANCE */
};
static TEMPLATE_FILTER_TYPE RefreshToTEMPLATE_Filter[] =
{
0, /* NEAREST */
0, /* LINEAR */
};
static TEMPLATE_SAMPLER_MIPMAP_MODE_TYPE RefreshToTEMPLATE_SamplerMipmapMode[] =
{
0, /* NEAREST */
0 /* LINEAR */
};
static TEMPLATE_SAMPLER_ADDRESS_MODE_TYPE RefreshToTEMPLATE_SamplerAddressMode[] =
{
0, /* REPEAT */
0, /* MIRRORED_REPEAT */
0, /* CLAMP_TO_EDGE */
0 /* CLAMP_TO_BORDER */
};
static TEMPLATE_BORDER_COLOR_TYPE RefreshToTEMPLATE_BorderColor[] =
{
0, /* FLOAT_TRANSPARENT_BLACK */
0, /* INT_TRANSPARENT_BLACK */
0, /* FLOAT_OPAQUE_BLACK */
0, /* INT_OPAQUE_BLACK */
0, /* FLOAT_OPAQUE_WHITE */
0 /* INT_OPAQUE_WHITE */
};
/* Quit */
static void TEMPLATE_DestroyDevice(
Refresh_Device *device
) {
NOT_IMPLEMENTED
}
/* Drawing */
static void TEMPLATE_DrawInstancedPrimitives(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_DrawIndexedPrimitives(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_DrawPrimitives(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t vertexStart,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_DispatchCompute(
Refresh_Renderer *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t groupCountX,
uint32_t groupCountY,
uint32_t groupCountZ,
uint32_t computeParamOffset
) {
NOT_IMPLEMENTED
}
/* State Creation */
static Refresh_ComputePipeline* TEMPLATE_CreateComputePipeline(
Refresh_Renderer *driverData,
Refresh_ComputeShaderInfo *computeShaderInfo
) {
NOT_IMPLEMENTED
}
static Refresh_GraphicsPipeline* TEMPLATE_CreateGraphicsPipeline(
Refresh_Renderer *driverData,
Refresh_GraphicsPipelineCreateInfo *pipelineCreateInfo
) {
NOT_IMPLEMENTED
}
static Refresh_Sampler* TEMPLATE_CreateSampler(
Refresh_Renderer *driverData,
Refresh_SamplerStateCreateInfo *samplerStateCreateInfo
) {
NOT_IMPLEMENTED
}
static Refresh_ShaderModule* TEMPLATE_CreateShaderModule(
Refresh_Renderer *driverData,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
) {
NOT_IMPLEMENTED
}
static Refresh_Texture* TEMPLATE_CreateTexture(
Refresh_Renderer *driverData,
Refresh_TextureCreateInfo *textureCreateInfo
) {
NOT_IMPLEMENTED
}
static Refresh_Buffer* TEMPLATE_CreateBuffer(
Refresh_Renderer *driverData,
Refresh_BufferUsageFlags usageFlags,
uint32_t sizeInBytes
) {
NOT_IMPLEMENTED
}
/* Setters */
static void TEMPLATE_SetTextureData(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
void *data,
uint32_t dataLengthInBytes
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_SetTextureDataYUV(
Refresh_Renderer *driverData,
Refresh_CommandBuffer* commandBuffer,
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
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_CopyTextureToTexture(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *sourceTextureSlice,
Refresh_TextureSlice *destinationTextureSlice,
Refresh_Filter filter
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_CopyTextureToBuffer(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
Refresh_Buffer *buffer
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_SetBufferData(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint32_t offsetInBytes,
void* data,
uint32_t dataLength
) {
NOT_IMPLEMENTED
}
static uint32_t TEMPLATE_PushVertexShaderUniforms(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
NOT_IMPLEMENTED
}
static uint32_t TEMPLATE_PushFragmentShaderUniforms(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
NOT_IMPLEMENTED
}
static uint32_t TEMPLATE_PushComputeShaderUniforms(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindVertexSamplers(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindFragmentSamplers(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
) {
NOT_IMPLEMENTED
}
/* Getters */
static void TEMPLATE_GetBufferData(
Refresh_Renderer *driverData,
Refresh_Buffer *buffer,
void *data,
uint32_t dataLengthInBytes
) {
NOT_IMPLEMENTED
}
/* Disposal */
static void TEMPLATE_QueueDestroyTexture(
Refresh_Renderer *driverData,
Refresh_Texture *texture
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_QueueDestroySampler(
Refresh_Renderer *driverData,
Refresh_Sampler *sampler
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_QueueDestroyBuffer(
Refresh_Renderer *driverData,
Refresh_Buffer *buffer
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_QueueDestroyShaderModule(
Refresh_Renderer *driverData,
Refresh_ShaderModule *shaderModule
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_QueueDestroyComputePipeline(
Refresh_Renderer *driverData,
Refresh_ComputePipeline *computePipeline
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_QueueDestroyGraphicsPipeline(
Refresh_Renderer *driverData,
Refresh_GraphicsPipeline *graphicsPipeline
) {
NOT_IMPLEMENTED
}
/* Graphics State */
static void TEMPLATE_BeginRenderPass(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *renderArea,
Refresh_ColorAttachmentInfo *colorAttachmentInfos,
uint32_t colorAttachmentCount,
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_EndRenderPass(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindGraphicsPipeline(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_SetViewport(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Viewport *viewport
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_SetScissor(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *scissor
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindVertexBuffers(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
uint32_t firstBinding,
uint32_t bindingCount,
Refresh_Buffer **pBuffers,
uint64_t *pOffsets
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindIndexBuffer(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
uint64_t offset,
Refresh_IndexElementSize indexElementSize
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindComputePipeline(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_ComputePipeline *computePipeline
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindComputeBuffers(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer **pBuffers
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_BindComputeTextures(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures
) {
NOT_IMPLEMENTED
}
static Refresh_CommandBuffer* TEMPLATE_AcquireCommandBuffer(
Refresh_Renderer *driverData,
uint8_t fixed
) {
NOT_IMPLEMENTED
}
Refresh_Texture* TEMPLATE_AcquireSwapchainTexture(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
void *windowHandle,
uint32_t *pWidth,
uint32_t *pHeight
) {
NOT_IMPLEMENTED
}
Refresh_TextureFormat TEMPLATE_GetSwapchainFormat(
Refresh_Renderer *driverData,
void *windowHandle
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_Submit(
Refresh_Renderer *driverData,
uint32_t commandBufferCount,
Refresh_CommandBuffer **pCommandBuffers
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_Wait(
Refresh_Renderer *driverData
) {
NOT_IMPLEMENTED
}
static Refresh_Device* TEMPLATE_CreateDevice(
Refresh_PresentationParameters *presentationParameters,
uint8_t debugMode
) {
NOT_IMPLEMENTED
}
Refresh_Driver TEMPLATEDriver = {
"TEMPLATE",
TEMPLATE_CreateDevice
};
#endif //REFRESH_DRIVER_TEMPLATE

File diff suppressed because it is too large Load Diff

View File

@ -209,32 +209,9 @@ void Refresh_Image_SavePNG(
const char *filename, const char *filename,
int32_t w, int32_t w,
int32_t h, int32_t h,
uint8_t bgra,
uint8_t *data uint8_t *data
) { ) {
uint32_t i;
uint8_t *bgraData;
if (bgra)
{
bgraData = SDL_malloc(w * h * 4);
for (i = 0; i < w * h * 4; i += 4)
{
bgraData[i] = data[i + 2];
bgraData[i + 1] = data[i + 1];
bgraData[i + 2] = data[i];
bgraData[i + 3] = data[i + 3];
}
stbi_write_png(filename, w, h, 4, bgraData, w * 4);
SDL_free(bgraData);
}
else
{
stbi_write_png(filename, w, h, 4, data, w * 4); stbi_write_png(filename, w, h, 4, data, w * 4);
} }
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ /* vim: set noexpandtab shiftwidth=8 tabstop=8: */