Refresh/src/Refresh.c

868 lines
17 KiB
C
Raw Normal View History

2022-03-02 19:22:52 +00:00
/* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
2020-12-17 00:27:14 +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>
*
*/
#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 */
#ifdef REFRESH_DRIVER_VULKAN
#define VULKAN_DRIVER &VulkanDriver
#else
#define VULKAN_DRIVER NULL
#endif
#ifdef REFRESH_DRIVER_PS5
#define PS5_DRIVER &PS5Driver
#else
#define PS5_DRIVER NULL
#endif
static const Refresh_Driver *backends[] = {
NULL,
VULKAN_DRIVER,
PS5_DRIVER
2020-12-17 00:27:14 +00:00
};
2020-12-17 00:38:09 +00:00
2020-12-17 02:38:22 +00:00
/* Logging */
2021-01-05 23:00:51 +00:00
static void Refresh_Default_LogInfo(const char *msg)
2020-12-17 02:38:22 +00:00
{
SDL_LogInfo(
SDL_LOG_CATEGORY_APPLICATION,
"%s",
msg
);
}
2021-01-05 23:00:51 +00:00
static void Refresh_Default_LogWarn(const char *msg)
2020-12-17 02:38:22 +00:00
{
SDL_LogWarn(
SDL_LOG_CATEGORY_APPLICATION,
"%s",
msg
);
}
2021-01-05 23:00:51 +00:00
static void Refresh_Default_LogError(const char *msg)
2020-12-17 02:38:22 +00:00
{
SDL_LogError(
SDL_LOG_CATEGORY_APPLICATION,
"%s",
msg
);
}
2021-01-05 23:00:51 +00:00
static Refresh_LogFunc Refresh_LogInfoFunc = Refresh_Default_LogInfo;
static Refresh_LogFunc Refresh_LogWarnFunc = Refresh_Default_LogWarn;
static Refresh_LogFunc Refresh_LogErrorFunc = Refresh_Default_LogError;
2020-12-17 02:38:22 +00:00
#define MAX_MESSAGE_SIZE 1024
2021-01-05 23:00:51 +00:00
void Refresh_LogInfo(const char *fmt, ...)
2020-12-17 02:38:22 +00:00
{
char msg[MAX_MESSAGE_SIZE];
va_list ap;
va_start(ap, fmt);
SDL_vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
2021-01-05 23:00:51 +00:00
Refresh_LogInfoFunc(msg);
2020-12-17 02:38:22 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_LogWarn(const char *fmt, ...)
2020-12-17 02:38:22 +00:00
{
char msg[MAX_MESSAGE_SIZE];
va_list ap;
va_start(ap, fmt);
SDL_vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
2021-01-05 23:00:51 +00:00
Refresh_LogWarnFunc(msg);
2020-12-17 02:38:22 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_LogError(const char *fmt, ...)
2020-12-17 02:38:22 +00:00
{
char msg[MAX_MESSAGE_SIZE];
va_list ap;
va_start(ap, fmt);
SDL_vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
2021-01-05 23:00:51 +00:00
Refresh_LogErrorFunc(msg);
2020-12-17 02:38:22 +00:00
}
#undef MAX_MESSAGE_SIZE
2021-01-05 23:00:51 +00:00
void Refresh_HookLogFunctions(
Refresh_LogFunc info,
Refresh_LogFunc warn,
Refresh_LogFunc error
2020-12-17 02:38:22 +00:00
) {
2021-01-05 23:00:51 +00:00
Refresh_LogInfoFunc = info;
Refresh_LogWarnFunc = warn;
Refresh_LogErrorFunc = error;
2020-12-17 02:38:22 +00:00
}
2020-12-17 00:38:09 +00:00
/* Version API */
2021-01-05 23:00:51 +00:00
uint32_t Refresh_LinkedVersion(void)
2020-12-17 00:38:09 +00:00
{
return REFRESH_COMPILED_VERSION;
}
/* Driver Functions */
static Refresh_Backend selectedBackend = REFRESH_BACKEND_INVALID;
Refresh_Backend Refresh_SelectBackend(Refresh_Backend preferredBackend, uint32_t *flags)
{
uint32_t i;
if (preferredBackend != REFRESH_BACKEND_DONTCARE)
{
if (backends[preferredBackend] == NULL)
{
Refresh_LogWarn("Preferred backend was not compiled into this binary! Attempting to fall back!");
}
else if (backends[preferredBackend]->PrepareDriver(flags))
{
selectedBackend = preferredBackend;
return selectedBackend;
}
}
/* Iterate until we find an appropriate backend. */
for (i = 1; i < SDL_arraysize(backends); i += 1)
{
if (i != preferredBackend && backends[i] != NULL && backends[i]->PrepareDriver(flags))
{
selectedBackend = i;
return i;
}
}
if (backends[i] == NULL)
{
Refresh_LogError("No supported Refresh backend found!");
}
selectedBackend = REFRESH_BACKEND_INVALID;
return REFRESH_BACKEND_INVALID;
}
2020-12-17 00:38:09 +00:00
2021-01-05 23:00:51 +00:00
Refresh_Device* Refresh_CreateDevice(
2022-02-25 21:42:11 +00:00
uint8_t debugMode
2020-12-17 00:38:09 +00:00
) {
if (selectedBackend == REFRESH_BACKEND_INVALID)
2022-02-25 21:42:11 +00:00
{
Refresh_LogError("Invalid backend selection. Did you call Refresh_SelectBackend?");
2022-02-25 21:42:11 +00:00
return NULL;
}
2020-12-17 00:38:09 +00:00
return backends[selectedBackend]->CreateDevice(
2022-02-25 21:42:11 +00:00
debugMode
);
2020-12-17 00:38:09 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_DestroyDevice(Refresh_Device *device)
2020-12-17 00:38:09 +00:00
{
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->DestroyDevice(device);
2020-12-17 00:38:09 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_DrawIndexedPrimitives(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
2022-02-25 21:42:11 +00:00
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->DrawIndexedPrimitives(
device->driverData,
commandBuffer,
baseVertex,
startIndex,
primitiveCount,
vertexParamOffset,
fragmentParamOffset
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_DrawInstancedPrimitives(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount,
2022-02-25 21:42:11 +00:00
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->DrawInstancedPrimitives(
device->driverData,
commandBuffer,
baseVertex,
startIndex,
primitiveCount,
instanceCount,
vertexParamOffset,
fragmentParamOffset
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_DrawPrimitives(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t vertexStart,
uint32_t primitiveCount,
2022-02-25 21:42:11 +00:00
uint32_t vertexParamOffset,
uint32_t fragmentParamOffset
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->DrawPrimitives(
device->driverData,
commandBuffer,
vertexStart,
primitiveCount,
vertexParamOffset,
fragmentParamOffset
);
2020-12-17 01:08:44 +00:00
}
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
) {
NULL_RETURN(device);
device->DrawPrimitivesIndirect(
device->driverData,
commandBuffer,
buffer,
offsetInBytes,
drawCount,
stride,
vertexParamOffset,
fragmentParamOffset
);
}
2021-01-05 23:00:51 +00:00
void Refresh_DispatchCompute(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
uint32_t groupCountX,
uint32_t groupCountY,
uint32_t groupCountZ,
uint32_t computeParamOffset
) {
NULL_RETURN(device);
device->DispatchCompute(
device->driverData,
commandBuffer,
groupCountX,
groupCountY,
groupCountZ,
computeParamOffset
);
2020-12-30 01:31:39 +00:00
}
2021-01-05 23:00:51 +00:00
Refresh_ComputePipeline* Refresh_CreateComputePipeline(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
2022-03-02 19:22:52 +00:00
Refresh_ComputeShaderInfo *computeShaderInfo
2020-12-29 22:52:24 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN_NULL(device);
return device->CreateComputePipeline(
device->driverData,
2022-03-02 19:22:52 +00:00
computeShaderInfo
2022-02-25 21:42:11 +00:00
);
2020-12-29 22:52:24 +00:00
}
2021-01-05 23:00:51 +00:00
Refresh_GraphicsPipeline* Refresh_CreateGraphicsPipeline(
Refresh_Device *device,
Refresh_GraphicsPipelineCreateInfo *pipelineCreateInfo
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN_NULL(device);
return device->CreateGraphicsPipeline(
device->driverData,
pipelineCreateInfo
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
Refresh_Sampler* Refresh_CreateSampler(
Refresh_Device *device,
Refresh_SamplerStateCreateInfo *samplerStateCreateInfo
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN_NULL(device);
return device->CreateSampler(
device->driverData,
samplerStateCreateInfo
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
Refresh_ShaderModule* Refresh_CreateShaderModule(
Refresh_Device *device,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN_NULL(device);
return device->CreateShaderModule(
device->driverData,
shaderModuleCreateInfo
);
2020-12-17 01:08:44 +00:00
}
Refresh_Texture* Refresh_CreateTexture(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_TextureCreateInfo *textureCreateInfo
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN_NULL(device);
return device->CreateTexture(
device->driverData,
textureCreateInfo
);
2020-12-18 22:35:33 +00:00
}
2021-01-05 23:00:51 +00:00
Refresh_Buffer* Refresh_CreateBuffer(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_BufferUsageFlags usageFlags,
2020-12-17 01:08:44 +00:00
uint32_t sizeInBytes
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN_NULL(device);
return device->CreateBuffer(
device->driverData,
usageFlags,
sizeInBytes
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_SetTextureData(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_TextureSlice *textureSlice,
2020-12-17 01:08:44 +00:00
void *data,
uint32_t dataLengthInBytes
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->SetTextureData(
device->driverData,
commandBuffer,
textureSlice,
data,
dataLengthInBytes
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_SetTextureDataYUV(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer* commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_Texture *y,
Refresh_Texture *u,
Refresh_Texture *v,
2020-12-17 01:08:44 +00:00
uint32_t yWidth,
uint32_t yHeight,
uint32_t uvWidth,
uint32_t uvHeight,
void* data,
uint32_t dataLength
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->SetTextureDataYUV(
device->driverData,
commandBuffer,
y,
u,
v,
yWidth,
yHeight,
uvWidth,
uvHeight,
data,
dataLength
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_CopyTextureToTexture(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
2021-01-05 23:00:51 +00:00
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *sourceTextureSlice,
Refresh_TextureSlice *destinationTextureSlice,
Refresh_Filter filter
2021-01-03 21:01:29 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->CopyTextureToTexture(
device->driverData,
commandBuffer,
sourceTextureSlice,
destinationTextureSlice,
filter
);
2021-01-03 21:01:29 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_CopyTextureToBuffer(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *textureSlice,
Refresh_Buffer *buffer
2021-01-03 21:01:29 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->CopyTextureToBuffer(
device->driverData,
commandBuffer,
textureSlice,
buffer
);
2021-01-03 21:01:29 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_SetBufferData(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_Buffer *buffer,
2020-12-17 01:08:44 +00:00
uint32_t offsetInBytes,
void* data,
uint32_t dataLength
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->SetBufferData(
device->driverData,
commandBuffer,
buffer,
offsetInBytes,
data,
dataLength
);
2020-12-17 01:08:44 +00:00
}
uint32_t Refresh_PushVertexShaderUniforms(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
void *data,
2021-02-03 00:37:01 +00:00
uint32_t dataLengthInBytes
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
if (device == NULL) { return 0; }
return device->PushVertexShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
}
uint32_t Refresh_PushFragmentShaderUniforms(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
void *data,
2021-02-03 00:37:01 +00:00
uint32_t dataLengthInBytes
) {
2022-02-25 21:42:11 +00:00
if (device == NULL) { return 0; }
return device->PushFragmentShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
2020-12-17 01:08:44 +00:00
}
uint32_t Refresh_PushComputeShaderUniforms(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *data,
uint32_t dataLengthInBytes
2020-12-31 04:39:47 +00:00
) {
2022-02-25 21:42:11 +00:00
if (device == NULL) { return 0; }
return device->PushComputeShaderUniforms(
device->driverData,
commandBuffer,
data,
dataLengthInBytes
);
2020-12-31 04:39:47 +00:00
}
2021-01-06 01:00:06 +00:00
void Refresh_BindVertexSamplers(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindVertexSamplers(
device->driverData,
commandBuffer,
pTextures,
pSamplers
);
2020-12-17 01:08:44 +00:00
}
2021-01-06 01:00:06 +00:00
void Refresh_BindFragmentSamplers(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindFragmentSamplers(
device->driverData,
commandBuffer,
pTextures,
pSamplers
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_GetBufferData(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_Buffer *buffer,
void *data,
uint32_t dataLengthInBytes
2021-01-03 01:00:52 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->GetBufferData(
device->driverData,
buffer,
data,
dataLengthInBytes
);
2021-01-03 01:00:52 +00:00
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyTexture(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Texture *texture
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->QueueDestroyTexture(
device->driverData,
texture
);
2020-12-17 01:08:44 +00:00
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroySampler(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Sampler *sampler
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->QueueDestroySampler(
device->driverData,
sampler
);
2020-12-17 01:08:44 +00:00
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyBuffer(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Buffer *buffer
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->QueueDestroyBuffer(
device->driverData,
buffer
);
2020-12-17 01:08:44 +00:00
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyShaderModule(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_ShaderModule *shaderModule
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->QueueDestroyShaderModule(
device->driverData,
shaderModule
);
2020-12-17 01:08:44 +00:00
}
2021-01-06 01:02:36 +00:00
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
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->QueueDestroyComputePipeline(
device->driverData,
computePipeline
);
2020-12-29 22:52:24 +00:00
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyGraphicsPipeline(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_GraphicsPipeline *graphicsPipeline
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->QueueDestroyGraphicsPipeline(
device->driverData,
graphicsPipeline
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_BeginRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2021-01-27 04:27:42 +00:00
Refresh_Rect *renderArea,
Refresh_ColorAttachmentInfo *colorAttachmentInfos,
uint32_t colorAttachmentCount,
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BeginRenderPass(
device->driverData,
commandBuffer,
renderArea,
colorAttachmentInfos,
colorAttachmentCount,
depthStencilAttachmentInfo
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_EndRenderPass(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->EndRenderPass(
device->driverData,
commandBuffer
);
2020-12-17 01:08:44 +00:00
}
void Refresh_SetViewport(
2022-03-04 20:30:33 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Viewport *viewport
) {
NULL_RETURN(device)
device->SetViewport(
2022-03-04 20:30:33 +00:00
device->driverData,
commandBuffer,
viewport
);
}
void Refresh_SetScissor(
2022-03-04 20:30:33 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *scissor
) {
NULL_RETURN(device)
device->SetScissor(
2022-03-04 20:30:33 +00:00
device->driverData,
commandBuffer,
scissor
);
}
2021-01-05 23:00:51 +00:00
void Refresh_BindGraphicsPipeline(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2021-01-05 23:00:51 +00:00
Refresh_GraphicsPipeline *graphicsPipeline
2020-12-17 01:08:44 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindGraphicsPipeline(
device->driverData,
commandBuffer,
graphicsPipeline
);
2020-12-17 01:08:44 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_BindVertexBuffers(
Refresh_Device *device,
2022-02-25 21:42:11 +00:00
Refresh_CommandBuffer *commandBuffer,
2020-12-20 07:41:03 +00:00
uint32_t firstBinding,
uint32_t bindingCount,
2021-01-05 23:00:51 +00:00
Refresh_Buffer **pBuffers,
2020-12-20 07:41:03 +00:00
uint64_t *pOffsets
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindVertexBuffers(
device->driverData,
commandBuffer,
firstBinding,
bindingCount,
pBuffers,
pOffsets
);
2020-12-20 07:41:03 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_BindIndexBuffer(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer *buffer,
2020-12-20 07:41:03 +00:00
uint64_t offset,
2021-01-05 23:00:51 +00:00
Refresh_IndexElementSize indexElementSize
2020-12-20 07:41:03 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindIndexBuffer(
device->driverData,
commandBuffer,
buffer,
offset,
indexElementSize
);
2020-12-20 07:41:03 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_BindComputePipeline(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_ComputePipeline *computePipeline
2020-12-30 01:31:39 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindComputePipeline(
device->driverData,
commandBuffer,
computePipeline
);
2020-12-30 01:31:39 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_BindComputeBuffers(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer **pBuffers
2020-12-30 01:31:39 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindComputeBuffers(
device->driverData,
commandBuffer,
pBuffers
);
2020-12-30 01:31:39 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_BindComputeTextures(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures
2020-12-30 01:31:39 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->BindComputeTextures(
device->driverData,
commandBuffer,
pTextures
);
2020-12-30 01:31:39 +00:00
}
uint8_t Refresh_ClaimWindow(
Refresh_Device *device,
void *windowHandle,
Refresh_PresentMode presentMode
) {
if (device == NULL) { return 0; }
return device->ClaimWindow(
device->driverData,
windowHandle,
presentMode
);
}
void Refresh_UnclaimWindow(
Refresh_Device *device,
void *windowHandle
) {
NULL_RETURN(device);
device->UnclaimWindow(
device->driverData,
windowHandle
);
}
2021-01-05 23:00:51 +00:00
Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
uint8_t fixed
2021-01-02 06:07:15 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN_NULL(device);
return device->AcquireCommandBuffer(
device->driverData,
fixed
);
2021-01-02 06:07:15 +00:00
}
Refresh_Texture* Refresh_AcquireSwapchainTexture(
2022-02-25 21:42:11 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
void *windowHandle,
uint32_t *pWidth,
uint32_t *pHeight
2020-12-17 04:19:11 +00:00
) {
NULL_RETURN_NULL(device);
return device->AcquireSwapchainTexture(
2022-02-25 21:42:11 +00:00
device->driverData,
commandBuffer,
windowHandle,
pWidth,
pHeight
);
}
Refresh_TextureFormat Refresh_GetSwapchainFormat(
Refresh_Device *device,
void *windowHandle
) {
if (device == NULL) { return 0; }
return device->GetSwapchainFormat(
device->driverData,
windowHandle
2022-02-25 21:42:11 +00:00
);
2020-12-17 04:19:11 +00:00
}
void Refresh_SetSwapchainPresentMode(
Refresh_Device *device,
void *windowHandle,
Refresh_PresentMode presentMode
) {
NULL_RETURN(device);
device->SetSwapchainPresentMode(
device->driverData,
windowHandle,
presentMode
);
}
2021-01-05 23:00:51 +00:00
void Refresh_Submit(
2022-02-25 21:42:11 +00:00
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-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->Submit(
device->driverData,
commandBufferCount,
pCommandBuffers
);
2020-12-21 23:44:43 +00:00
}
2021-01-05 23:00:51 +00:00
void Refresh_Wait(
2022-02-25 21:42:11 +00:00
Refresh_Device *device
2021-01-03 05:07:51 +00:00
) {
2022-02-25 21:42:11 +00:00
NULL_RETURN(device);
device->Wait(
device->driverData
);
2021-01-03 05:07:51 +00:00
}
2020-12-17 01:08:44 +00:00
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */