Refresh/src/Refresh.c

916 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 */
2021-01-05 23:00:51 +00:00
static const Refresh_Driver *drivers[] = {
2020-12-17 00:27:14 +00:00
&VulkanDriver,
NULL
};
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 */
2020-12-22 01:59:08 +00:00
static int32_t selectedDriver = 0;
2020-12-17 00:38:09 +00:00
2021-01-05 23:00:51 +00:00
Refresh_Device* Refresh_CreateDevice(
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
}
2021-01-14 01:37:54 +00:00
Refresh_Device* Refresh_CreateDeviceUsingExternal(
Refresh_SysRenderer *sysRenderer,
uint8_t debugMode
) {
if (selectedDriver < 0)
{
return NULL;
}
if (sysRenderer == NULL)
{
return NULL;
}
return drivers[selectedDriver]->CreateDeviceUsingExternal(
sysRenderer,
debugMode
);
}
2021-01-05 23:00:51 +00:00
void Refresh_DestroyDevice(Refresh_Device *device)
2020-12-17 00:38:09 +00:00
{
2020-12-17 01:08:44 +00:00
NULL_RETURN(device);
2020-12-17 00:38:09 +00:00
device->DestroyDevice(device);
}
2021-01-05 23:00:51 +00:00
void Refresh_Clear(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Color *colors,
2020-12-29 06:19:46 +00:00
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
2021-01-05 23:00:51 +00:00
void Refresh_DrawIndexedPrimitives(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
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,
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,
Refresh_CommandBuffer *commandBuffer,
2020-12-17 01:08:44 +00:00
uint32_t baseVertex,
uint32_t startIndex,
uint32_t primitiveCount,
uint32_t instanceCount,
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,
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,
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_DispatchCompute(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
2020-12-30 01:31:39 +00:00
uint32_t groupCountX,
uint32_t groupCountY,
2020-12-31 04:39:47 +00:00
uint32_t groupCountZ,
uint32_t computeParamOffset
2020-12-30 01:31:39 +00:00
) {
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_RenderPass* Refresh_CreateRenderPass(
Refresh_Device *device,
Refresh_RenderPassCreateInfo *renderPassCreateInfo
2020-12-17 01:08:44 +00:00
) {
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_ComputePipeline* Refresh_CreateComputePipeline(
Refresh_Device *device,
Refresh_ComputePipelineCreateInfo *pipelineCreateInfo
2020-12-29 22:52:24 +00:00
) {
NULL_RETURN_NULL(device);
return device->CreateComputePipeline(
device->driverData,
pipelineCreateInfo
);
}
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
) {
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
);
}
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
) {
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_Framebuffer* Refresh_CreateFramebuffer(
Refresh_Device *device,
Refresh_FramebufferCreateInfo *framebufferCreateInfo
2020-12-17 01:08:44 +00:00
) {
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
);
}
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
) {
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_Texture* Refresh_CreateTexture2D(
Refresh_Device *device,
Refresh_ColorFormat format,
2020-12-17 01:08:44 +00:00
uint32_t width,
uint32_t height,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
2021-01-05 23:00:51 +00:00
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_Texture* Refresh_CreateTexture3D(
Refresh_Device *device,
Refresh_ColorFormat format,
2020-12-17 01:08:44 +00:00
uint32_t width,
uint32_t height,
uint32_t depth,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
2021-01-05 23:00:51 +00:00
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_Texture* Refresh_CreateTextureCube(
Refresh_Device *device,
Refresh_ColorFormat format,
2020-12-17 01:08:44 +00:00
uint32_t size,
2020-12-18 22:35:33 +00:00
uint32_t levelCount,
2021-01-05 23:00:51 +00:00
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_ColorTarget* Refresh_CreateColorTarget(
Refresh_Device *device,
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
);
}
2021-01-05 23:00:51 +00:00
Refresh_DepthStencilTarget* Refresh_CreateDepthStencilTarget(
Refresh_Device *device,
2020-12-17 01:08:44 +00:00
uint32_t width,
uint32_t height,
2021-01-05 23:00:51 +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
);
}
2021-01-05 23:00:51 +00:00
Refresh_Buffer* Refresh_CreateBuffer(
Refresh_Device *device,
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-05 23:00:51 +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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_SetTextureDataYUV(
Refresh_Device *device,
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
) {
NULL_RETURN(device);
device->SetTextureDataYUV(
device->driverData,
y,
u,
v,
yWidth,
yHeight,
uvWidth,
uvHeight,
data,
dataLength
);
}
2021-01-05 23:00:51 +00:00
void Refresh_CopyTextureToTexture(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice *sourceTextureSlice,
Refresh_TextureSlice *destinationTextureSlice,
Refresh_Filter filter
2021-01-03 21:01:29 +00:00
) {
NULL_RETURN(device);
device->CopyTextureToTexture(
device->driverData,
commandBuffer,
sourceTextureSlice,
destinationTextureSlice,
filter
);
}
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
) {
NULL_RETURN(device);
device->CopyTextureToBuffer(
device->driverData,
commandBuffer,
textureSlice,
buffer
);
}
2021-01-05 23:00:51 +00:00
void Refresh_SetBufferData(
Refresh_Device *device,
Refresh_Buffer *buffer,
2020-12-17 01:08:44 +00:00
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
);
}
2021-01-05 23:00:51 +00:00
uint32_t Refresh_PushVertexShaderParams(
Refresh_Device *device,
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
);
}
2021-01-05 23:00:51 +00:00
uint32_t Refresh_PushFragmentShaderParams(
Refresh_Device *device,
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
);
}
2021-01-05 23:00:51 +00:00
uint32_t Refresh_PushComputeShaderParams(
Refresh_Device *device,
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
);
}
2021-01-06 01:00:06 +00:00
void Refresh_BindVertexSamplers(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
2021-01-06 01:00:06 +00:00
device->BindVertexSamplers(
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
pTextures,
2020-12-19 05:35:21 +00:00
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,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures,
Refresh_Sampler **pSamplers
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
2021-01-06 01:00:06 +00:00
device->BindFragmentSamplers(
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
pTextures,
2020-12-19 05:35:21 +00:00
pSamplers
2020-12-17 01:08:44 +00:00
);
}
2021-01-05 23:00:51 +00:00
void Refresh_GetBufferData(
Refresh_Device *device,
Refresh_Buffer *buffer,
2021-01-03 01:00:52 +00:00
void *data,
uint32_t dataLengthInBytes
) {
NULL_RETURN(device);
device->GetBufferData(
device->driverData,
buffer,
data,
dataLengthInBytes
);
}
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
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyTexture(
2020-12-17 01:08:44 +00:00
device->driverData,
texture
);
}
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
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroySampler(
2020-12-17 01:08:44 +00:00
device->driverData,
sampler
);
}
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
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyBuffer(
2020-12-17 01:08:44 +00:00
device->driverData,
buffer
);
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyColorTarget(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_ColorTarget *colorTarget
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyColorTarget(
2020-12-17 01:08:44 +00:00
device->driverData,
colorTarget
);
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyDepthStencilTarget(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_DepthStencilTarget *depthStencilTarget
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyDepthStencilTarget(
2020-12-17 01:08:44 +00:00
device->driverData,
depthStencilTarget
);
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyFramebuffer(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_Framebuffer *frameBuffer
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyFramebuffer(
2020-12-17 01:08:44 +00:00
device->driverData,
frameBuffer
);
}
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
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyShaderModule(
2020-12-17 01:08:44 +00:00
device->driverData,
shaderModule
);
}
2021-01-06 01:02:36 +00:00
void Refresh_QueueDestroyRenderPass(
2021-01-05 23:00:51 +00:00
Refresh_Device *device,
Refresh_RenderPass *renderPass
2020-12-17 01:08:44 +00:00
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyRenderPass(
2020-12-17 01:08:44 +00:00
device->driverData,
renderPass
);
}
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
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyComputePipeline(
2020-12-29 22:52:24 +00:00
device->driverData,
computePipeline
);
}
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
) {
NULL_RETURN(device);
2021-01-06 01:02:36 +00:00
device->QueueDestroyGraphicsPipeline(
2020-12-17 01:08:44 +00:00
device->driverData,
graphicsPipeline
);
}
2021-01-05 23:00:51 +00:00
void Refresh_BeginRenderPass(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_RenderPass *renderPass,
Refresh_Framebuffer *framebuffer,
Refresh_Rect renderArea,
Refresh_Color *pColorClearValues,
2020-12-20 08:05:12 +00:00
uint32_t colorClearCount,
2021-01-05 23:00:51 +00:00
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_EndRenderPass(
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
}
2021-01-05 23:00:51 +00:00
void Refresh_BindGraphicsPipeline(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_GraphicsPipeline *graphicsPipeline
2020-12-17 01:08:44 +00:00
) {
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_BindVertexBuffers(
Refresh_Device *device,
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
) {
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_BindIndexBuffer(
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
) {
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_BindComputePipeline(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_ComputePipeline *computePipeline
2020-12-30 01:31:39 +00:00
) {
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_BindComputeBuffers(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Buffer **pBuffers
2020-12-30 01:31:39 +00:00
) {
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_BindComputeTextures(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Texture **pTextures
2020-12-30 01:31:39 +00:00
) {
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-05 23:00:51 +00:00
Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
Refresh_Device *device,
2021-01-02 06:07:15 +00:00
uint8_t fixed
) {
NULL_RETURN_NULL(device);
return device->AcquireCommandBuffer(
device->driverData,
fixed
);
}
2021-01-05 23:00:51 +00:00
void Refresh_QueuePresent(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_TextureSlice* textureSlice,
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
);
}
2021-01-05 23:00:51 +00:00
void Refresh_Submit(
Refresh_Device *device,
2021-01-03 22:57:46 +00:00
uint32_t commandBufferCount,
2021-01-05 23:00:51 +00:00
Refresh_CommandBuffer **pCommandBuffers
2020-12-21 23:44:43 +00:00
) {
NULL_RETURN(device);
device->Submit(
2021-01-02 21:31:17 +00:00
device->driverData,
2021-01-03 22:57:46 +00:00
commandBufferCount,
pCommandBuffers
2020-12-21 23:44:43 +00:00
);
}
2021-01-05 23:00:51 +00:00
void Refresh_Wait(
Refresh_Device *device
2021-01-03 05:07:51 +00:00
) {
NULL_RETURN(device);
device->Wait(
device->driverData
);
}
2021-01-14 01:37:54 +00:00
void Refresh_GetTextureHandles(
Refresh_Device* device,
Refresh_Texture* texture,
Refresh_TextureHandles *handles
) {
NULL_RETURN(device);
2021-01-14 02:02:45 +00:00
device->GetTextureHandles(
2021-01-14 01:37:54 +00:00
device->driverData,
texture,
handles
);
}
2020-12-17 01:08:44 +00:00
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */