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 */
|
|
|
|
|
|
2022-08-14 20:45:24 +00:00
|
|
|
|
#ifdef REFRESH_DRIVER_VULKAN
|
2022-10-04 17:02:53 +00:00
|
|
|
|
#define VULKAN_DRIVER &VulkanDriver
|
|
|
|
|
#else
|
|
|
|
|
#define VULKAN_DRIVER NULL
|
2022-08-14 20:45:24 +00:00
|
|
|
|
#endif
|
2022-10-04 17:02:53 +00:00
|
|
|
|
|
2023-09-23 01:44:20 +00:00
|
|
|
|
#ifdef REFRESH_DRIVER_D3D11
|
|
|
|
|
#define D3D11_DRIVER &D3D11Driver
|
|
|
|
|
#else
|
|
|
|
|
#define D3D11_DRIVER NULL
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-08-14 20:45:24 +00:00
|
|
|
|
#ifdef REFRESH_DRIVER_PS5
|
2022-10-04 17:02:53 +00:00
|
|
|
|
#define PS5_DRIVER &PS5Driver
|
|
|
|
|
#else
|
|
|
|
|
#define PS5_DRIVER NULL
|
2022-08-14 20:45:24 +00:00
|
|
|
|
#endif
|
2022-10-04 17:02:53 +00:00
|
|
|
|
|
|
|
|
|
static const Refresh_Driver *backends[] = {
|
|
|
|
|
NULL,
|
|
|
|
|
VULKAN_DRIVER,
|
2023-09-30 01:52:14 +00:00
|
|
|
|
D3D11_DRIVER,
|
2022-10-04 17:02:53 +00:00
|
|
|
|
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 */
|
|
|
|
|
|
2022-09-29 21:11:25 +00:00
|
|
|
|
static Refresh_Backend selectedBackend = REFRESH_BACKEND_INVALID;
|
|
|
|
|
|
|
|
|
|
Refresh_Backend Refresh_SelectBackend(Refresh_Backend preferredBackend, uint32_t *flags)
|
|
|
|
|
{
|
2022-10-04 17:02:53 +00:00
|
|
|
|
uint32_t i;
|
2022-09-29 21:11:25 +00:00
|
|
|
|
|
|
|
|
|
if (preferredBackend != REFRESH_BACKEND_DONTCARE)
|
|
|
|
|
{
|
2022-10-04 17:02:53 +00:00
|
|
|
|
if (backends[preferredBackend] == NULL)
|
|
|
|
|
{
|
|
|
|
|
Refresh_LogWarn("Preferred backend was not compiled into this binary! Attempting to fall back!");
|
|
|
|
|
}
|
|
|
|
|
else if (backends[preferredBackend]->PrepareDriver(flags))
|
2022-09-29 21:11:25 +00:00
|
|
|
|
{
|
|
|
|
|
selectedBackend = preferredBackend;
|
|
|
|
|
return selectedBackend;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Iterate until we find an appropriate backend. */
|
|
|
|
|
|
2022-10-04 17:02:53 +00:00
|
|
|
|
for (i = 1; i < SDL_arraysize(backends); i += 1)
|
2022-09-29 21:11:25 +00:00
|
|
|
|
{
|
2022-10-04 17:02:53 +00:00
|
|
|
|
if (i != preferredBackend && backends[i] != NULL && backends[i]->PrepareDriver(flags))
|
2022-09-29 21:11:25 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
) {
|
2022-09-29 21:11:25 +00:00
|
|
|
|
if (selectedBackend == REFRESH_BACKEND_INVALID)
|
2022-02-25 21:42:11 +00:00
|
|
|
|
{
|
2022-09-29 21:11:25 +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
|
|
|
|
|
2022-09-29 21:11:25 +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
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
/* State Creation */
|
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
|
|
|
|
) {
|
2024-02-11 06:07:01 +00:00
|
|
|
|
Refresh_Driver_ShaderModuleCreateInfo driverSpecificCreateInfo = { 0, NULL, 0 };
|
2023-01-20 23:19:12 +00:00
|
|
|
|
uint8_t *bytes;
|
|
|
|
|
uint32_t i, size;
|
|
|
|
|
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN_NULL(device);
|
2023-01-20 23:19:12 +00:00
|
|
|
|
|
|
|
|
|
/* verify the magic number in the shader blob header */
|
|
|
|
|
bytes = (uint8_t*) shaderModuleCreateInfo->byteCode;
|
|
|
|
|
if (bytes[0] != 'R' || bytes[1] != 'F' || bytes[2] != 'S' || bytes[3] != 'H')
|
|
|
|
|
{
|
2024-02-11 06:07:01 +00:00
|
|
|
|
Refresh_LogError("Cannot parse malformed Refresh shader blob: Incorrect magic number");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get the type of shader */
|
|
|
|
|
driverSpecificCreateInfo.type = (Refresh_Driver_ShaderType) *((uint32_t*) &bytes[4]);
|
|
|
|
|
if ( driverSpecificCreateInfo.type < 0 ||
|
|
|
|
|
driverSpecificCreateInfo.type > REFRESH_DRIVER_SHADERTYPE_COMPUTE )
|
|
|
|
|
{
|
|
|
|
|
Refresh_LogError(
|
|
|
|
|
"Cannot parse malformed Refresh shader blob: Unknown shader type (%d)",
|
|
|
|
|
driverSpecificCreateInfo.type
|
|
|
|
|
);
|
2023-01-20 23:19:12 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* find the code for the selected backend */
|
2024-02-11 06:07:01 +00:00
|
|
|
|
i = 8;
|
2023-01-20 23:19:12 +00:00
|
|
|
|
while (i < shaderModuleCreateInfo->codeSize)
|
|
|
|
|
{
|
|
|
|
|
size = *((uint32_t*) &bytes[i + 1]);
|
|
|
|
|
|
|
|
|
|
if (bytes[i] == (uint8_t) selectedBackend)
|
|
|
|
|
{
|
|
|
|
|
driverSpecificCreateInfo.codeSize = size;
|
|
|
|
|
driverSpecificCreateInfo.byteCode = (uint32_t*) &bytes[i + 1 + sizeof(uint32_t)];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* skip over the backend byte, the blob size, and the blob */
|
|
|
|
|
i += 1 + sizeof(uint32_t) + size;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* verify the shader blob supports the selected backend */
|
|
|
|
|
if (driverSpecificCreateInfo.byteCode == NULL)
|
|
|
|
|
{
|
|
|
|
|
Refresh_LogError(
|
|
|
|
|
"Cannot create shader module that does not contain shader code for the selected backend! "
|
|
|
|
|
"Recompile your shader and enable this backend."
|
|
|
|
|
);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-25 21:42:11 +00:00
|
|
|
|
return device->CreateShaderModule(
|
|
|
|
|
device->driverData,
|
2023-01-20 23:19:12 +00:00
|
|
|
|
&driverSpecificCreateInfo
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-14 09:52:45 +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
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_GpuBuffer* Refresh_CreateGpuBuffer(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
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);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
return device->CreateGpuBuffer(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
usageFlags,
|
|
|
|
|
sizeInBytes
|
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 17:42:31 +00:00
|
|
|
|
Refresh_TransferBuffer* Refresh_CreateTransferBuffer(
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-22 18:34:48 +00:00
|
|
|
|
uint32_t sizeInBytes
|
2024-02-12 08:04:02 +00:00
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN_NULL(device);
|
2024-02-23 17:42:31 +00:00
|
|
|
|
return device->CreateTransferBuffer(
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->driverData,
|
2024-02-22 18:34:48 +00:00
|
|
|
|
sizeInBytes
|
2024-02-12 08:04:02 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Disposal */
|
|
|
|
|
|
|
|
|
|
void Refresh_QueueDestroyTexture(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Texture *texture
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->QueueDestroyTexture(
|
|
|
|
|
device->driverData,
|
|
|
|
|
texture
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_QueueDestroySampler(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Sampler *sampler
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->QueueDestroySampler(
|
|
|
|
|
device->driverData,
|
|
|
|
|
sampler
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_QueueDestroyGpuBuffer(
|
|
|
|
|
Refresh_Device *device,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
Refresh_GpuBuffer *gpuBuffer
|
2024-02-12 08:04:02 +00:00
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->QueueDestroyGpuBuffer(
|
|
|
|
|
device->driverData,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
gpuBuffer
|
2024-02-12 08:04:02 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 17:42:31 +00:00
|
|
|
|
void Refresh_QueueDestroyTransferBuffer(
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
Refresh_TransferBuffer *transferBuffer
|
2024-02-12 08:04:02 +00:00
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
2024-02-23 17:42:31 +00:00
|
|
|
|
device->QueueDestroyTransferBuffer(
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->driverData,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
transferBuffer
|
2024-02-12 08:04:02 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_QueueDestroyShaderModule(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_ShaderModule *shaderModule
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->QueueDestroyShaderModule(
|
|
|
|
|
device->driverData,
|
|
|
|
|
shaderModule
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_QueueDestroyComputePipeline(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_ComputePipeline *computePipeline
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->QueueDestroyComputePipeline(
|
|
|
|
|
device->driverData,
|
|
|
|
|
computePipeline
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_QueueDestroyGraphicsPipeline(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_GraphicsPipeline *graphicsPipeline
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->QueueDestroyGraphicsPipeline(
|
|
|
|
|
device->driverData,
|
|
|
|
|
graphicsPipeline
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Render Pass */
|
|
|
|
|
|
|
|
|
|
void Refresh_BeginRenderPass(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_ColorAttachmentInfo *colorAttachmentInfos,
|
|
|
|
|
uint32_t colorAttachmentCount,
|
|
|
|
|
Refresh_DepthStencilAttachmentInfo *depthStencilAttachmentInfo
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BeginRenderPass(
|
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
|
|
|
|
colorAttachmentInfos,
|
|
|
|
|
colorAttachmentCount,
|
|
|
|
|
depthStencilAttachmentInfo
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_BindGraphicsPipeline(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
Refresh_GraphicsPipeline *graphicsPipeline
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BindGraphicsPipeline(
|
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
|
|
|
|
graphicsPipeline
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_BindVertexBuffers(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
uint32_t firstBinding,
|
|
|
|
|
uint32_t bindingCount,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_BufferBinding *pBindings
|
2024-02-12 08:04:02 +00:00
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BindVertexBuffers(
|
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
|
|
|
|
firstBinding,
|
|
|
|
|
bindingCount,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
pBindings
|
2024-02-12 08:04:02 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_BindIndexBuffer(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_BufferBinding *pBinding,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_IndexElementSize indexElementSize
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BindIndexBuffer(
|
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
pBinding,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
indexElementSize
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_BindVertexSamplers(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TextureSamplerBinding *pBindings
|
2024-02-12 08:04:02 +00:00
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BindVertexSamplers(
|
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
pBindings
|
2024-02-12 08:04:02 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_BindFragmentSamplers(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TextureSamplerBinding *pBindings
|
2024-02-12 08:04:02 +00:00
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BindFragmentSamplers(
|
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
pBindings
|
2024-02-12 08:04:02 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-17 01:54:58 +00:00
|
|
|
|
void 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,
|
|
|
|
|
uint32_t dataLengthInBytes
|
|
|
|
|
) {
|
2024-02-17 01:54:58 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->PushVertexShaderUniforms(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
|
|
|
|
data,
|
|
|
|
|
dataLengthInBytes
|
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-17 01:54:58 +00:00
|
|
|
|
void Refresh_PushFragmentShaderUniforms(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
void *data,
|
|
|
|
|
uint32_t dataLengthInBytes
|
|
|
|
|
) {
|
2024-02-17 01:54:58 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->PushFragmentShaderUniforms(
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
|
|
|
|
data,
|
|
|
|
|
dataLengthInBytes
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_DrawInstancedPrimitives(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
uint32_t baseVertex,
|
|
|
|
|
uint32_t startIndex,
|
|
|
|
|
uint32_t primitiveCount,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
uint32_t instanceCount
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->DrawInstancedPrimitives(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
baseVertex,
|
|
|
|
|
startIndex,
|
|
|
|
|
primitiveCount,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
instanceCount
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_DrawIndexedPrimitives(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
uint32_t baseVertex,
|
|
|
|
|
uint32_t startIndex,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
uint32_t primitiveCount
|
2021-01-03 21:01:29 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->DrawIndexedPrimitives(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
baseVertex,
|
|
|
|
|
startIndex,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
primitiveCount
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2021-01-03 21:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_DrawPrimitives(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
uint32_t vertexStart,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
uint32_t primitiveCount
|
2021-01-03 21:01:29 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->DrawPrimitives(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
vertexStart,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
primitiveCount
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2021-01-03 21:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_DrawPrimitivesIndirect(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
Refresh_GpuBuffer *gpuBuffer,
|
2020-12-17 01:08:44 +00:00
|
|
|
|
uint32_t offsetInBytes,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
uint32_t drawCount,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
uint32_t stride
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->DrawPrimitivesIndirect(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
gpuBuffer,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
offsetInBytes,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
drawCount,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
stride
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_EndRenderPass(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2024-02-12 08:04:02 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->EndRenderPass(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
commandBuffer
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-20 09:33:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
/* Compute Pass */
|
|
|
|
|
|
|
|
|
|
void Refresh_BeginComputePass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
2020-12-20 09:33:32 +00:00
|
|
|
|
) {
|
2024-02-12 08:04:02 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BeginComputePass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_BindComputePipeline(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_ComputePipeline *computePipeline
|
2020-12-31 04:39:47 +00:00
|
|
|
|
) {
|
2024-02-12 08:04:02 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->BindComputePipeline(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
computePipeline
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-31 04:39:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_BindComputeBuffers(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_ComputeBufferBinding *pBindings
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->BindComputeBuffers(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
pBindings
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_BindComputeTextures(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_ComputeTextureBinding *pBindings
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->BindComputeTextures(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
pBindings
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-17 01:54:58 +00:00
|
|
|
|
void Refresh_PushComputeShaderUniforms(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
void *data,
|
|
|
|
|
uint32_t dataLengthInBytes
|
2021-01-03 01:00:52 +00:00
|
|
|
|
) {
|
2024-02-17 01:54:58 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->PushComputeShaderUniforms(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
commandBuffer,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
data,
|
|
|
|
|
dataLengthInBytes
|
|
|
|
|
);
|
2021-01-03 01:00:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_DispatchCompute(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
|
|
|
|
uint32_t groupCountX,
|
|
|
|
|
uint32_t groupCountY,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
uint32_t groupCountZ
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->DispatchCompute(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
commandBuffer,
|
|
|
|
|
groupCountX,
|
|
|
|
|
groupCountY,
|
2024-02-17 01:54:58 +00:00
|
|
|
|
groupCountZ
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_EndComputePass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->EndComputePass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-23 17:42:31 +00:00
|
|
|
|
/* TransferBuffer Set/Get */
|
2024-02-18 04:21:52 +00:00
|
|
|
|
|
2024-03-02 09:09:49 +00:00
|
|
|
|
void Refresh_SetTransferData(
|
2024-02-18 04:21:52 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
void* data,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
Refresh_TransferBuffer *transferBuffer,
|
2024-02-18 04:21:52 +00:00
|
|
|
|
Refresh_BufferCopy *copyParams,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TransferOptions transferOption
|
2024-02-18 04:21:52 +00:00
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
2024-03-02 09:09:49 +00:00
|
|
|
|
device->SetTransferData(
|
2024-02-18 04:21:52 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
data,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
transferBuffer,
|
2024-02-18 04:21:52 +00:00
|
|
|
|
copyParams,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
transferOption
|
2024-02-18 04:21:52 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-02 09:09:49 +00:00
|
|
|
|
void Refresh_GetTransferData(
|
2024-02-18 04:21:52 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
Refresh_TransferBuffer *transferBuffer,
|
2024-02-18 04:21:52 +00:00
|
|
|
|
void* data,
|
|
|
|
|
Refresh_BufferCopy *copyParams
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
2024-03-02 09:09:49 +00:00
|
|
|
|
device->GetTransferData(
|
2024-02-18 04:21:52 +00:00
|
|
|
|
device->driverData,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
transferBuffer,
|
2024-02-18 04:21:52 +00:00
|
|
|
|
data,
|
|
|
|
|
copyParams
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
/* Copy Pass */
|
|
|
|
|
|
|
|
|
|
void Refresh_BeginCopyPass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->BeginCopyPass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_UploadToTexture(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-02-24 22:01:37 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
Refresh_TransferBuffer *transferBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TextureRegion *textureRegion,
|
|
|
|
|
Refresh_BufferImageCopy *copyParams,
|
|
|
|
|
Refresh_WriteOptions writeOption
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->UploadToTexture(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
transferBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
textureRegion,
|
|
|
|
|
copyParams,
|
|
|
|
|
writeOption
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_UploadToBuffer(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
Refresh_TransferBuffer *transferBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_GpuBuffer *gpuBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_BufferCopy *copyParams,
|
|
|
|
|
Refresh_WriteOptions writeOption
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->UploadToBuffer(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
commandBuffer,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
transferBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
gpuBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
copyParams,
|
|
|
|
|
writeOption
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_DownloadFromTexture(
|
2022-03-04 20:30:33 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TextureRegion *textureRegion,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
Refresh_TransferBuffer *transferBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_BufferImageCopy *copyParams,
|
|
|
|
|
Refresh_TransferOptions transferOption
|
2022-03-04 20:30:33 +00:00
|
|
|
|
) {
|
2024-02-12 08:04:02 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->DownloadFromTexture(
|
2022-03-04 20:30:33 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
textureRegion,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
transferBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
copyParams,
|
|
|
|
|
transferOption
|
2022-03-04 20:30:33 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_DownloadFromBuffer(
|
2022-03-04 20:30:33 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_GpuBuffer *gpuBuffer,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
Refresh_TransferBuffer *transferBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_BufferCopy *copyParams,
|
|
|
|
|
Refresh_TransferOptions transferOption
|
2022-03-04 20:30:33 +00:00
|
|
|
|
) {
|
2024-02-12 08:04:02 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->DownloadFromBuffer(
|
2022-03-04 20:30:33 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
gpuBuffer,
|
2024-02-23 17:42:31 +00:00
|
|
|
|
transferBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
copyParams,
|
|
|
|
|
transferOption
|
2022-03-04 20:30:33 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_CopyTextureToTexture(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TextureRegion *source,
|
|
|
|
|
Refresh_TextureRegion *destination,
|
|
|
|
|
Refresh_WriteOptions writeOption
|
2020-12-17 01:08:44 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->CopyTextureToTexture(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
source,
|
|
|
|
|
destination,
|
|
|
|
|
writeOption
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 01:08:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_CopyTextureToBuffer(
|
2021-01-05 23:00:51 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TextureRegion *textureRegion,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
Refresh_GpuBuffer *gpuBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_BufferImageCopy *copyParameters,
|
|
|
|
|
Refresh_WriteOptions writeOption
|
2020-12-20 07:41:03 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->CopyTextureToBuffer(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
textureRegion,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
gpuBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
copyParameters,
|
|
|
|
|
writeOption
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-20 07:41:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_CopyBufferToTexture(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
Refresh_GpuBuffer *gpuBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_TextureRegion *textureRegion,
|
|
|
|
|
Refresh_BufferImageCopy *copyParams,
|
|
|
|
|
Refresh_WriteOptions writeOption
|
2020-12-20 07:41:03 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->CopyBufferToTexture(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-23 17:50:48 +00:00
|
|
|
|
gpuBuffer,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
textureRegion,
|
|
|
|
|
copyParams,
|
|
|
|
|
writeOption
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-20 07:41:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_CopyBufferToBuffer(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_GpuBuffer *source,
|
|
|
|
|
Refresh_GpuBuffer *destination,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
Refresh_BufferCopy *copyParams,
|
|
|
|
|
Refresh_WriteOptions writeOption
|
2020-12-30 01:31:39 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->CopyBufferToBuffer(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
source,
|
|
|
|
|
destination,
|
2024-03-02 09:09:49 +00:00
|
|
|
|
copyParams,
|
|
|
|
|
writeOption
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-30 01:31:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_GenerateMipmaps(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_Texture *texture
|
2020-12-30 01:31:39 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->GenerateMipmaps(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
texture
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-30 01:31:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_EndCopyPass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
2020-12-30 01:31:39 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
2024-02-12 08:04:02 +00:00
|
|
|
|
device->EndCopyPass(
|
2024-02-16 00:48:26 +00:00
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-30 01:31:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
/* Submission/Presentation */
|
|
|
|
|
|
2022-09-29 21:11:25 +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
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
void Refresh_SetSwapchainPresentMode(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
2022-03-10 18:21:49 +00:00
|
|
|
|
void *windowHandle,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_PresentMode presentMode
|
2020-12-17 04:19:11 +00:00
|
|
|
|
) {
|
2024-02-12 08:04:02 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->SetSwapchainPresentMode(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
device->driverData,
|
2022-03-10 18:21:49 +00:00
|
|
|
|
windowHandle,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
presentMode
|
2022-03-02 06:33:57 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Refresh_TextureFormat Refresh_GetSwapchainFormat(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
void *windowHandle
|
|
|
|
|
) {
|
|
|
|
|
if (device == NULL) { return 0; }
|
|
|
|
|
return device->GetSwapchainFormat(
|
|
|
|
|
device->driverData,
|
2022-02-09 01:16:11 +00:00
|
|
|
|
windowHandle
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
2020-12-17 04:19:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
|
|
|
|
|
Refresh_Device *device
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN_NULL(device);
|
|
|
|
|
return device->AcquireCommandBuffer(
|
|
|
|
|
device->driverData
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Refresh_Texture* Refresh_AcquireSwapchainTexture(
|
2022-09-29 21:11:25 +00:00
|
|
|
|
Refresh_Device *device,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer,
|
2022-09-29 21:11:25 +00:00
|
|
|
|
void *windowHandle,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
uint32_t *pWidth,
|
|
|
|
|
uint32_t *pHeight
|
2022-09-29 21:11:25 +00:00
|
|
|
|
) {
|
2024-02-12 08:04:02 +00:00
|
|
|
|
NULL_RETURN_NULL(device);
|
|
|
|
|
return device->AcquireSwapchainTexture(
|
2022-09-29 21:11:25 +00:00
|
|
|
|
device->driverData,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
commandBuffer,
|
2022-09-29 21:11:25 +00:00
|
|
|
|
windowHandle,
|
2024-02-12 08:04:02 +00:00
|
|
|
|
pWidth,
|
|
|
|
|
pHeight
|
2022-09-29 21:11:25 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-05 23:00:51 +00:00
|
|
|
|
void Refresh_Submit(
|
2022-02-25 21:42:11 +00:00
|
|
|
|
Refresh_Device *device,
|
2023-09-19 06:11:20 +00:00
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
2020-12-21 23:44:43 +00:00
|
|
|
|
) {
|
2022-02-25 21:42:11 +00:00
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->Submit(
|
|
|
|
|
device->driverData,
|
2023-09-19 06:11:20 +00:00
|
|
|
|
commandBuffer
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Refresh_Fence* Refresh_SubmitAndAcquireFence(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_CommandBuffer *commandBuffer
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN_NULL(device);
|
|
|
|
|
return device->SubmitAndAcquireFence(
|
|
|
|
|
device->driverData,
|
|
|
|
|
commandBuffer
|
2022-02-25 21:42:11 +00:00
|
|
|
|
);
|
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
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 06:11:20 +00:00
|
|
|
|
void Refresh_WaitForFences(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
uint8_t waitAll,
|
|
|
|
|
uint32_t fenceCount,
|
|
|
|
|
Refresh_Fence **pFences
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->WaitForFences(
|
|
|
|
|
device->driverData,
|
|
|
|
|
waitAll,
|
|
|
|
|
fenceCount,
|
|
|
|
|
pFences
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Refresh_QueryFence(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Fence *fence
|
|
|
|
|
) {
|
2024-02-11 06:07:01 +00:00
|
|
|
|
if (device == NULL) { return 0; }
|
2023-09-19 06:11:20 +00:00
|
|
|
|
|
|
|
|
|
return device->QueryFence(
|
|
|
|
|
device->driverData,
|
|
|
|
|
fence
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Refresh_ReleaseFence(
|
|
|
|
|
Refresh_Device *device,
|
|
|
|
|
Refresh_Fence *fence
|
|
|
|
|
) {
|
|
|
|
|
NULL_RETURN(device);
|
|
|
|
|
device->ReleaseFence(
|
|
|
|
|
device->driverData,
|
|
|
|
|
fence
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-17 01:08:44 +00:00
|
|
|
|
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
|