Refresh/src/Refresh.c

899 lines
19 KiB
C
Raw Normal View History

2020-12-17 00:27:14 +00:00
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
*
* Copyright (c) 2020 Evan Hemsley
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
* Evan "cosmonaut" Hemsley <evan@moonside.games>
*
*/
#include "Refresh_Driver.h"
#include <SDL.h>
2020-12-17 01:08:44 +00:00
#define NULL_RETURN(name) if (name == NULL) { return; }
2020-12-17 02:38:22 +00:00
#define NULL_RETURN_NULL(name) if (name == NULL) { return NULL; }
2020-12-17 01:08:44 +00:00
2020-12-17 00:27:14 +00:00
/* Drivers */
static const REFRESH_Driver *drivers[] = {
&VulkanDriver,
NULL
};
2020-12-17 00:38:09 +00:00
2020-12-17 02:38:22 +00:00
/* Logging */
static void REFRESH_Default_LogInfo(const char *msg)
{
SDL_LogInfo(
SDL_LOG_CATEGORY_APPLICATION,
"%s",
msg
);
}
static void REFRESH_Default_LogWarn(const char *msg)
{
SDL_LogWarn(
SDL_LOG_CATEGORY_APPLICATION,
"%s",
msg
);
}
static void REFRESH_Default_LogError(const char *msg)
{
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"%s",
msg
);
}
static REFRESH_LogFunc REFRESH_LogInfoFunc = REFRESH_Default_LogInfo;
static REFRESH_LogFunc REFRESH_LogWarnFunc = REFRESH_Default_LogWarn;
static REFRESH_LogFunc REFRESH_LogErrorFunc = REFRESH_Default_LogError;
#define MAX_MESSAGE_SIZE 1024
void REFRESH_LogInfo(const char *fmt, ...)
{
char msg[MAX_MESSAGE_SIZE];
va_list ap;
va_start(ap, fmt);
SDL_vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
REFRESH_LogInfoFunc(msg);
}
void REFRESH_LogWarn(const char *fmt, ...)
{
char msg[MAX_MESSAGE_SIZE];
va_list ap;
va_start(ap, fmt);
SDL_vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
REFRESH_LogWarnFunc(msg);
}
void REFRESH_LogError(const char *fmt, ...)
{
char msg[MAX_MESSAGE_SIZE];
va_list ap;
va_start(ap, fmt);
SDL_vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
REFRESH_LogErrorFunc(msg);
}
#undef MAX_MESSAGE_SIZE
void REFRESH_HookLogFunctions(
REFRESH_LogFunc info,
REFRESH_LogFunc warn,
REFRESH_LogFunc error
) {
REFRESH_LogInfoFunc = info;
REFRESH_LogWarnFunc = warn;
REFRESH_LogErrorFunc = error;
}
2020-12-17 00:38:09 +00:00
/* Version API */
uint32_t REFRESH_LinkedVersion(void)
{
return REFRESH_COMPILED_VERSION;
}
/* Driver Functions */
2020-12-22 01:59:08 +00:00
static int32_t selectedDriver = 0;
2020-12-17 00:38:09 +00:00
REFRESH_Device* REFRESH_CreateDevice(
2020-12-22 00:18:21 +00:00
REFRESH_PresentationParameters *presentationParameters,
2020-12-17 03:28:02 +00:00
uint8_t debugMode
2020-12-17 00:38:09 +00:00
) {
if (selectedDriver < 0)
{
return NULL;
}
2020-12-17 03:28:02 +00:00
return drivers[selectedDriver]->CreateDevice(
2020-12-22 00:18:21 +00:00
presentationParameters,
2020-12-17 03:28:02 +00:00
debugMode
);
2020-12-17 00:38:09 +00:00
}
void REFRESH_DestroyDevice(REFRESH_Device *device)
{
2020-12-17 01:08:44 +00:00
NULL_RETURN(device);
2020-12-17 00:38:09 +00:00
device->DestroyDevice(device);
}
void REFRESH_Clear(
2021-01-02 21:31:17 +00:00
REFRESH_Device *device,
REFRESH_CommandBuffer *commandBuffer,
2020-12-29 06:19:46 +00:00
REFRESH_Rect *clearRect,
2020-12-17 00:38:09 +00:00
REFRESH_ClearOptions options,
2020-12-29 06:19:46 +00:00
REFRESH_Color *colors,
uint32_t colorCount,
2020-12-17 00:38:09 +00:00
float depth,
int32_t stencil
) {
2020-12-17 01:08:44 +00:00
NULL_RETURN(device);
2020-12-29 06:19:46 +00:00
device->Clear(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-29 06:19:46 +00:00
clearRect,
options,
colors,
colorCount,
depth,
stencil
);
2020-12-17 00:38:09 +00:00
}
2020-12-17 01:08:44 +00:00
void REFRESH_DrawIndexedPrimitives(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t minVertexIndex,
uint32_t numVertices,
uint32_t startIndex,
uint32_t primitiveCount,
REFRESH_Buffer *indices,
REFRESH_IndexElementSize indexElementSize,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
device->DrawIndexedPrimitives(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
baseVertex,
minVertexIndex,
numVertices,
startIndex,
primitiveCount,
indices,
indexElementSize,
vertexParamOffset,
fragmentParamOffset
2020-12-17 01:08:44 +00:00
);
}
void REFRESH_DrawInstancedPrimitives(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t minVertexIndex,
uint32_t numVertices,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount,
REFRESH_Buffer *indices,
REFRESH_IndexElementSize indexElementSize,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
device->DrawInstancedPrimitives(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
baseVertex,
minVertexIndex,
numVertices,
startIndex,
primitiveCount,
instanceCount,
indices,
indexElementSize,
vertexParamOffset,
fragmentParamOffset
2020-12-17 01:08:44 +00:00
);
}
void REFRESH_DrawPrimitives(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t vertexStart,
uint32_t primitiveCount,
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
device->DrawPrimitives(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
vertexStart,
primitiveCount,
vertexParamOffset,
fragmentParamOffset
2020-12-17 01:08:44 +00:00
);
}
2020-12-30 01:31:39 +00:00
void REFRESH_DispatchCompute(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
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
) {
NULL_RETURN(device);
device->DispatchCompute(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-30 01:31:39 +00:00
groupCountX,
groupCountY,
2020-12-31 04:39:47 +00:00
groupCountZ,
computeParamOffset
2020-12-30 01:31:39 +00:00
);
}
2020-12-17 01:08:44 +00:00
REFRESH_RenderPass* REFRESH_CreateRenderPass(
REFRESH_Device *device,
REFRESH_RenderPassCreateInfo *renderPassCreateInfo
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateRenderPass(
2020-12-17 01:08:44 +00:00
device->driverData,
renderPassCreateInfo
);
}
2020-12-29 22:52:24 +00:00
REFRESH_ComputePipeline* REFRESH_CreateComputePipeline(
REFRESH_Device *device,
REFRESH_ComputePipelineCreateInfo *pipelineCreateInfo
) {
NULL_RETURN_NULL(device);
return device->CreateComputePipeline(
device->driverData,
pipelineCreateInfo
);
}
2020-12-17 01:08:44 +00:00
REFRESH_GraphicsPipeline* REFRESH_CreateGraphicsPipeline(
REFRESH_Device *device,
REFRESH_GraphicsPipelineCreateInfo *pipelineCreateInfo
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateGraphicsPipeline(
2020-12-17 01:08:44 +00:00
device->driverData,
pipelineCreateInfo
);
}
REFRESH_Sampler* REFRESH_CreateSampler(
REFRESH_Device *device,
REFRESH_SamplerStateCreateInfo *samplerStateCreateInfo
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateSampler(
2020-12-17 01:08:44 +00:00
device->driverData,
samplerStateCreateInfo
);
}
REFRESH_Framebuffer* REFRESH_CreateFramebuffer(
REFRESH_Device *device,
REFRESH_FramebufferCreateInfo *framebufferCreateInfo
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateFramebuffer(
2020-12-17 01:08:44 +00:00
device->driverData,
framebufferCreateInfo
);
}
REFRESH_ShaderModule* REFRESH_CreateShaderModule(
REFRESH_Device *device,
REFRESH_ShaderModuleCreateInfo *shaderModuleCreateInfo
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateShaderModule(
2020-12-17 01:08:44 +00:00
device->driverData,
shaderModuleCreateInfo
);
}
REFRESH_Texture* REFRESH_CreateTexture2D(
REFRESH_Device *device,
REFRESH_SurfaceFormat format,
uint32_t width,
uint32_t height,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
REFRESH_TextureUsageFlags usageFlags
2020-12-17 01:08:44 +00:00
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateTexture2D(
2020-12-17 01:08:44 +00:00
device->driverData,
format,
width,
height,
2020-12-18 22:35:33 +00:00
levelCount,
usageFlags
2020-12-17 01:08:44 +00:00
);
}
REFRESH_Texture* REFRESH_CreateTexture3D(
REFRESH_Device *device,
REFRESH_SurfaceFormat format,
uint32_t width,
uint32_t height,
uint32_t depth,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
REFRESH_TextureUsageFlags usageFlags
2020-12-17 01:08:44 +00:00
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateTexture3D(
2020-12-17 01:08:44 +00:00
device->driverData,
format,
width,
height,
depth,
2020-12-18 22:35:33 +00:00
levelCount,
usageFlags
2020-12-17 01:08:44 +00:00
);
}
REFRESH_Texture* REFRESH_CreateTextureCube(
REFRESH_Device *device,
REFRESH_SurfaceFormat format,
uint32_t size,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
REFRESH_TextureUsageFlags usageFlags
2020-12-17 01:08:44 +00:00
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
return device->CreateTextureCube(
2020-12-17 01:08:44 +00:00
device->driverData,
format,
size,
2020-12-18 22:35:33 +00:00
levelCount,
usageFlags
2020-12-18 22:35:33 +00:00
);
}
2020-12-21 23:50:12 +00:00
REFRESH_ColorTarget* REFRESH_CreateColorTarget(
2020-12-17 01:08:44 +00:00
REFRESH_Device *device,
2020-12-21 23:44:43 +00:00
REFRESH_SampleCount multisampleCount,
REFRESH_TextureSlice *textureSlice
2020-12-17 01:08:44 +00:00
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
2020-12-21 23:50:12 +00:00
return device->CreateColorTarget(
2020-12-17 01:08:44 +00:00
device->driverData,
multisampleCount,
2020-12-19 00:39:03 +00:00
textureSlice
2020-12-17 01:08:44 +00:00
);
}
2020-12-21 23:50:12 +00:00
REFRESH_DepthStencilTarget* REFRESH_CreateDepthStencilTarget(
2020-12-17 01:08:44 +00:00
REFRESH_Device *device,
uint32_t width,
uint32_t height,
2020-12-19 00:39:03 +00:00
REFRESH_DepthFormat format
2020-12-17 01:08:44 +00:00
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
2020-12-21 23:50:12 +00:00
return device->CreateDepthStencilTarget(
2020-12-17 01:08:44 +00:00
device->driverData,
width,
height,
2020-12-19 00:39:03 +00:00
format
2020-12-17 01:08:44 +00:00
);
}
2020-12-31 04:39:47 +00:00
REFRESH_Buffer* REFRESH_CreateBuffer(
2020-12-17 01:08:44 +00:00
REFRESH_Device *device,
2020-12-31 04:39:47 +00:00
REFRESH_BufferUsageFlags usageFlags,
2020-12-17 01:08:44 +00:00
uint32_t sizeInBytes
) {
2020-12-17 02:38:22 +00:00
NULL_RETURN_NULL(device);
2020-12-31 04:39:47 +00:00
return device->CreateBuffer(
2020-12-17 01:08:44 +00:00
device->driverData,
2020-12-31 04:39:47 +00:00
usageFlags,
2020-12-17 01:08:44 +00:00
sizeInBytes
);
}
2021-01-03 22:37:02 +00:00
void REFRESH_SetTextureData(
REFRESH_Device *device,
REFRESH_TextureSlice *textureSlice,
2020-12-17 01:08:44 +00:00
void *data,
uint32_t dataLengthInBytes
) {
NULL_RETURN(device);
2021-01-03 22:37:02 +00:00
device->SetTextureData(
2020-12-17 01:08:44 +00:00
device->driverData,
2021-01-03 22:37:02 +00:00
textureSlice,
2020-12-17 01:08:44 +00:00
data,
dataLengthInBytes
);
}
void REFRESH_SetTextureDataYUV(
REFRESH_Device *device,
REFRESH_Texture *y,
REFRESH_Texture *u,
REFRESH_Texture *v,
uint32_t yWidth,
uint32_t yHeight,
uint32_t uvWidth,
uint32_t uvHeight,
void* data,
uint32_t dataLength
) {
NULL_RETURN(device);
device->SetTextureDataYUV(
device->driverData,
y,
u,
v,
yWidth,
yHeight,
uvWidth,
uvHeight,
data,
dataLength
);
}
2021-01-03 21:01:29 +00:00
void REFRESH_CopyTextureToTexture(
REFRESH_Device *device,
2021-01-03 22:37:02 +00:00
REFRESH_CommandBuffer *commandBuffer,
REFRESH_TextureSlice *sourceTextureSlice,
2021-01-03 21:01:29 +00:00
REFRESH_TextureSlice *destinationTextureSlice,
2021-01-03 22:37:02 +00:00
REFRESH_Filter filter
2021-01-03 21:01:29 +00:00
) {
NULL_RETURN(device);
device->CopyTextureToTexture(
device->driverData,
commandBuffer,
sourceTextureSlice,
destinationTextureSlice,
filter
);
}
void REFRESH_CopyTextureToBuffer(
REFRESH_Device *device,
2021-01-03 22:37:02 +00:00
REFRESH_CommandBuffer *commandBuffer,
2021-01-03 21:01:29 +00:00
REFRESH_TextureSlice *textureSlice,
2021-01-03 22:37:02 +00:00
REFRESH_Buffer *buffer
2021-01-03 21:01:29 +00:00
) {
NULL_RETURN(device);
device->CopyTextureToBuffer(
device->driverData,
commandBuffer,
textureSlice,
buffer
);
}
2020-12-31 04:39:47 +00:00
void REFRESH_SetBufferData(
2020-12-17 01:08:44 +00:00
REFRESH_Device *device,
REFRESH_Buffer *buffer,
uint32_t offsetInBytes,
void* data,
uint32_t dataLength
) {
NULL_RETURN(device);
2020-12-31 04:39:47 +00:00
device->SetBufferData(
2020-12-17 01:08:44 +00:00
device->driverData,
buffer,
offsetInBytes,
data,
dataLength
);
}
uint32_t REFRESH_PushVertexShaderParams(
2020-12-17 01:08:44 +00:00
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
void *data,
2020-12-23 21:11:09 +00:00
uint32_t elementCount
2020-12-17 01:08:44 +00:00
) {
if (device == NULL) { return 0; }
return device->PushVertexShaderParams(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
data,
2020-12-23 21:11:09 +00:00
elementCount
);
}
uint32_t REFRESH_PushFragmentShaderParams(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
void *data,
2020-12-23 21:11:09 +00:00
uint32_t elementCount
) {
if (device == NULL) { return 0; }
return device->PushFragmentShaderParams(
2020-12-17 01:08:44 +00:00
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
data,
2020-12-23 21:11:09 +00:00
elementCount
2020-12-17 01:08:44 +00:00
);
}
2020-12-31 04:39:47 +00:00
uint32_t REFRESH_PushComputeShaderParams(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-31 04:39:47 +00:00
void *data,
uint32_t elementCount
) {
if (device == NULL) { return 0; }
return device->PushComputeShaderParams(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-31 04:39:47 +00:00
data,
elementCount
);
}
2020-12-17 01:08:44 +00:00
void REFRESH_SetVertexSamplers(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-19 05:35:21 +00:00
REFRESH_Texture **pTextures,
REFRESH_Sampler **pSamplers
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
device->SetVertexSamplers(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
pTextures,
2020-12-19 05:35:21 +00:00
pSamplers
2020-12-17 01:08:44 +00:00
);
}
void REFRESH_SetFragmentSamplers(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-19 05:35:21 +00:00
REFRESH_Texture **pTextures,
REFRESH_Sampler **pSamplers
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
device->SetFragmentSamplers(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
pTextures,
2020-12-19 05:35:21 +00:00
pSamplers
2020-12-17 01:08:44 +00:00
);
}
2021-01-03 01:00:52 +00:00
void REFRESH_GetBufferData(
REFRESH_Device *device,
REFRESH_Buffer *buffer,
void *data,
uint32_t dataLengthInBytes
) {
NULL_RETURN(device);
device->GetBufferData(
device->driverData,
buffer,
data,
dataLengthInBytes
);
}
2020-12-17 01:08:44 +00:00
void REFRESH_AddDisposeTexture(
REFRESH_Device *device,
REFRESH_Texture *texture
) {
NULL_RETURN(device);
device->AddDisposeTexture(
device->driverData,
texture
);
}
void REFRESH_AddDisposeSampler(
REFRESH_Device *device,
REFRESH_Sampler *sampler
) {
NULL_RETURN(device);
device->AddDisposeSampler(
device->driverData,
sampler
);
}
void REFRESH_AddDisposeBuffer(
2020-12-17 01:08:44 +00:00
REFRESH_Device *device,
REFRESH_Buffer *buffer
) {
NULL_RETURN(device);
device->AddDisposeBuffer(
2020-12-17 01:08:44 +00:00
device->driverData,
buffer
);
}
void REFRESH_AddDisposeColorTarget(
REFRESH_Device *device,
REFRESH_ColorTarget *colorTarget
) {
NULL_RETURN(device);
device->AddDisposeColorTarget(
device->driverData,
colorTarget
);
}
void REFRESH_AddDisposeDepthStencilTarget(
REFRESH_Device *device,
REFRESH_DepthStencilTarget *depthStencilTarget
) {
NULL_RETURN(device);
device->AddDisposeDepthStencilTarget(
device->driverData,
depthStencilTarget
);
}
void REFRESH_AddDisposeFramebuffer(
REFRESH_Device *device,
REFRESH_Framebuffer *frameBuffer
) {
NULL_RETURN(device);
device->AddDisposeFramebuffer(
device->driverData,
frameBuffer
);
}
void REFRESH_AddDisposeShaderModule(
REFRESH_Device *device,
REFRESH_ShaderModule *shaderModule
) {
NULL_RETURN(device);
device->AddDisposeShaderModule(
device->driverData,
shaderModule
);
}
void REFRESH_AddDisposeRenderPass(
REFRESH_Device *device,
REFRESH_RenderPass *renderPass
) {
NULL_RETURN(device);
device->AddDisposeRenderPass(
device->driverData,
renderPass
);
}
2020-12-29 22:52:24 +00:00
void REFRESH_AddDisposeComputePipeline(
REFRESH_Device *device,
REFRESH_ComputePipeline *computePipeline
) {
NULL_RETURN(device);
device->AddDisposeComputePipeline(
device->driverData,
computePipeline
);
}
2020-12-17 01:08:44 +00:00
void REFRESH_AddDisposeGraphicsPipeline(
REFRESH_Device *device,
REFRESH_GraphicsPipeline *graphicsPipeline
) {
NULL_RETURN(device);
device->AddDisposeGraphicsPipeline(
device->driverData,
graphicsPipeline
);
}
void REFRESH_BeginRenderPass(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
REFRESH_RenderPass *renderPass,
REFRESH_Framebuffer *framebuffer,
REFRESH_Rect renderArea,
2020-12-20 08:05:12 +00:00
REFRESH_Color *pColorClearValues,
uint32_t colorClearCount,
REFRESH_DepthStencilValue *depthStencilClearValue
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
device->BeginRenderPass(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
renderPass,
framebuffer,
renderArea,
2020-12-20 08:05:12 +00:00
pColorClearValues,
colorClearCount,
depthStencilClearValue
2020-12-17 01:08:44 +00:00
);
}
void REFRESH_EndRenderPass(
2021-01-02 21:31:17 +00:00
REFRESH_Device *device,
REFRESH_CommandBuffer *commandBuffer
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
2021-01-02 21:31:17 +00:00
device->EndRenderPass(
device->driverData,
commandBuffer
);
2020-12-17 01:08:44 +00:00
}
void REFRESH_BindGraphicsPipeline(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
REFRESH_GraphicsPipeline *graphicsPipeline
) {
NULL_RETURN(device);
device->BindGraphicsPipeline(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-17 01:08:44 +00:00
graphicsPipeline
);
}
2020-12-20 07:41:03 +00:00
void REFRESH_BindVertexBuffers(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-20 07:41:03 +00:00
uint32_t firstBinding,
uint32_t bindingCount,
REFRESH_Buffer **pBuffers,
uint64_t *pOffsets
) {
NULL_RETURN(device);
device->BindVertexBuffers(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-20 07:41:03 +00:00
firstBinding,
bindingCount,
pBuffers,
pOffsets
);
}
void REFRESH_BindIndexBuffer(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-20 07:41:03 +00:00
REFRESH_Buffer *buffer,
uint64_t offset,
REFRESH_IndexElementSize indexElementSize
) {
NULL_RETURN(device);
device->BindIndexBuffer(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-20 07:41:03 +00:00
buffer,
offset,
indexElementSize
);
}
2020-12-30 01:31:39 +00:00
void REFRESH_BindComputePipeline(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-30 01:31:39 +00:00
REFRESH_ComputePipeline *computePipeline
) {
NULL_RETURN(device);
device->BindComputePipeline(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-30 01:31:39 +00:00
computePipeline
);
}
void REFRESH_BindComputeBuffers(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-30 01:31:39 +00:00
REFRESH_Buffer **pBuffers
) {
NULL_RETURN(device);
device->BindComputeBuffers(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-30 01:31:39 +00:00
pBuffers
);
}
void REFRESH_BindComputeTextures(
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
2020-12-30 01:31:39 +00:00
REFRESH_Texture **pTextures
) {
NULL_RETURN(device);
device->BindComputeTextures(
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
2020-12-30 01:31:39 +00:00
pTextures
);
}
2021-01-02 06:07:15 +00:00
REFRESH_CommandBuffer* REFRESH_AcquireCommandBuffer(
REFRESH_Device *device,
uint8_t fixed
) {
NULL_RETURN_NULL(device);
return device->AcquireCommandBuffer(
device->driverData,
fixed
);
}
void REFRESH_QueuePresent(
2020-12-17 04:19:11 +00:00
REFRESH_Device *device,
2021-01-02 21:31:17 +00:00
REFRESH_CommandBuffer *commandBuffer,
REFRESH_TextureSlice* textureSlice,
2021-01-03 21:01:29 +00:00
REFRESH_Rect *destinationRectangle,
REFRESH_Filter filter
2020-12-17 04:19:11 +00:00
) {
NULL_RETURN(device);
device->QueuePresent(
2020-12-17 04:19:11 +00:00
device->driverData,
2021-01-02 21:31:17 +00:00
commandBuffer,
textureSlice,
2021-01-03 21:01:29 +00:00
destinationRectangle,
filter
2020-12-17 04:19:11 +00:00
);
}
2020-12-21 23:44:43 +00:00
void REFRESH_Submit(
2021-01-02 21:31:17 +00:00
REFRESH_Device *device,
REFRESH_CommandBuffer **pCommandBuffers,
uint32_t commandBufferCount
2020-12-21 23:44:43 +00:00
) {
NULL_RETURN(device);
device->Submit(
2021-01-02 21:31:17 +00:00
device->driverData,
pCommandBuffers,
commandBufferCount
2020-12-21 23:44:43 +00:00
);
}
2021-01-03 05:07:51 +00:00
void REFRESH_Wait(
REFRESH_Device *device
) {
NULL_RETURN(device);
device->Wait(
device->driverData
);
}
2020-12-17 01:08:44 +00:00
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */