gpu: make macro's function-like using do-while-0
This commit is contained in:
committed by
Anonymous Maarten
parent
fb71b44231
commit
e4215a04d9
@@ -55,26 +55,32 @@
|
|||||||
|
|
||||||
// Macros
|
// Macros
|
||||||
|
|
||||||
#define SET_ERROR(fmt, msg) \
|
#define SET_ERROR(fmt, msg) \
|
||||||
if (renderer->debug_mode) { \
|
do { \
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
if (renderer->debug_mode) { \
|
||||||
} \
|
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
||||||
SDL_SetError(fmt, msg);
|
} \
|
||||||
|
SDL_SetError(fmt, msg); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SET_ERROR_AND_RETURN(fmt, msg, ret) \
|
#define SET_ERROR_AND_RETURN(fmt, msg, ret) \
|
||||||
if (renderer->debug_mode) { \
|
do { \
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
if (renderer->debug_mode) { \
|
||||||
} \
|
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
||||||
SDL_SetError(fmt, msg); \
|
} \
|
||||||
return ret; \
|
SDL_SetError(fmt, msg); \
|
||||||
|
return ret; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SET_STRING_ERROR_AND_RETURN(msg, ret) SET_ERROR_AND_RETURN("%s", msg, ret)
|
#define SET_STRING_ERROR_AND_RETURN(msg, ret) SET_ERROR_AND_RETURN("%s", msg, ret)
|
||||||
|
|
||||||
#define CHECK_D3D12_ERROR_AND_RETURN(msg, ret) \
|
#define CHECK_D3D12_ERROR_AND_RETURN(msg, ret) \
|
||||||
if (FAILED(res)) { \
|
do { \
|
||||||
D3D12_INTERNAL_SetError(renderer, msg, res); \
|
if (FAILED(res)) { \
|
||||||
return ret; \
|
D3D12_INTERNAL_SetError(renderer, msg, res); \
|
||||||
}
|
return (ret); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
// Defines
|
// Defines
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@@ -2543,7 +2549,7 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
|
|||||||
|
|
||||||
if (rootSignature == NULL) {
|
if (rootSignature == NULL) {
|
||||||
SDL_free(bytecode);
|
SDL_free(bytecode);
|
||||||
SET_STRING_ERROR_AND_RETURN("Could not create root signature!", NULL)
|
SET_STRING_ERROR_AND_RETURN("Could not create root signature!", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_COMPUTE_PIPELINE_STATE_DESC pipelineDesc;
|
D3D12_COMPUTE_PIPELINE_STATE_DESC pipelineDesc;
|
||||||
@@ -3353,7 +3359,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer(
|
|||||||
}
|
}
|
||||||
heapFlags = D3D12_HEAP_FLAG_NONE;
|
heapFlags = D3D12_HEAP_FLAG_NONE;
|
||||||
} else {
|
} else {
|
||||||
SET_STRING_ERROR_AND_RETURN("Unrecognized buffer type!", NULL)
|
SET_STRING_ERROR_AND_RETURN("Unrecognized buffer type!", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||||
@@ -6190,7 +6196,7 @@ static bool D3D12_SupportsSwapchainComposition(
|
|||||||
|
|
||||||
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Must claim window before querying swapchain composition support!", false)
|
SET_STRING_ERROR_AND_RETURN("Must claim window before querying swapchain composition support!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the color space support if necessary
|
// Check the color space support if necessary
|
||||||
@@ -6482,7 +6488,7 @@ static bool D3D12_INTERNAL_ResizeSwapchain(
|
|||||||
0, // use client window height
|
0, // use client window height
|
||||||
DXGI_FORMAT_UNKNOWN, // Keep the old format
|
DXGI_FORMAT_UNKNOWN, // Keep the old format
|
||||||
renderer->supportsTearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
renderer->supportsTearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Could not resize swapchain buffers", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Could not resize swapchain buffers", false);
|
||||||
|
|
||||||
// Create texture object for the swapchain
|
// Create texture object for the swapchain
|
||||||
for (Uint32 i = 0; i < windowData->swapchainTextureCount; i += 1) {
|
for (Uint32 i = 0; i < windowData->swapchainTextureCount; i += 1) {
|
||||||
@@ -6498,7 +6504,7 @@ static bool D3D12_INTERNAL_ResizeSwapchain(
|
|||||||
|
|
||||||
DXGI_SWAP_CHAIN_DESC1 swapchainDesc;
|
DXGI_SWAP_CHAIN_DESC1 swapchainDesc;
|
||||||
IDXGISwapChain3_GetDesc1(windowData->swapchain, &swapchainDesc);
|
IDXGISwapChain3_GetDesc1(windowData->swapchain, &swapchainDesc);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Failed to retrieve swapchain descriptor!", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Failed to retrieve swapchain descriptor!", false);
|
||||||
|
|
||||||
windowData->width = swapchainDesc.Width;
|
windowData->width = swapchainDesc.Width;
|
||||||
windowData->height = swapchainDesc.Height;
|
windowData->height = swapchainDesc.Height;
|
||||||
@@ -6646,7 +6652,7 @@ static bool D3D12_INTERNAL_CreateSwapchain(
|
|||||||
}
|
}
|
||||||
|
|
||||||
IDXGISwapChain3_GetDesc1(swapchain3, &swapchainDesc);
|
IDXGISwapChain3_GetDesc1(swapchain3, &swapchainDesc);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Failed to retrieve swapchain descriptor!", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Failed to retrieve swapchain descriptor!", false);
|
||||||
|
|
||||||
// Initialize the swapchain data
|
// Initialize the swapchain data
|
||||||
windowData->swapchain = swapchain3;
|
windowData->swapchain = swapchain3;
|
||||||
@@ -6726,10 +6732,10 @@ static bool D3D12_ClaimWindow(
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
SDL_free(windowData);
|
SDL_free(windowData);
|
||||||
SET_STRING_ERROR_AND_RETURN("Could not create swapchain, failed to claim window!", false)
|
SET_STRING_ERROR_AND_RETURN("Could not create swapchain, failed to claim window!", false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SET_STRING_ERROR_AND_RETURN("Window already claimed", false)
|
SET_STRING_ERROR_AND_RETURN("Window already claimed", false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6742,8 +6748,7 @@ static void D3D12_ReleaseWindow(
|
|||||||
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_ERROR("Window already unclaimed!")
|
SET_STRING_ERROR_AND_RETURN("Window already unclaimed!", );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_Wait(driverData);
|
D3D12_Wait(driverData);
|
||||||
@@ -6784,15 +6789,15 @@ static bool D3D12_SetSwapchainParameters(
|
|||||||
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Cannot set swapchain parameters on unclaimed window!", false)
|
SET_STRING_ERROR_AND_RETURN("Cannot set swapchain parameters on unclaimed window!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!D3D12_SupportsSwapchainComposition(driverData, window, swapchainComposition)) {
|
if (!D3D12_SupportsSwapchainComposition(driverData, window, swapchainComposition)) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Swapchain composition not supported!", false)
|
SET_STRING_ERROR_AND_RETURN("Swapchain composition not supported!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!D3D12_SupportsPresentMode(driverData, window, presentMode)) {
|
if (!D3D12_SupportsPresentMode(driverData, window, presentMode)) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Present mode not supported!", false)
|
SET_STRING_ERROR_AND_RETURN("Present mode not supported!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -6859,7 +6864,7 @@ static SDL_GPUTextureFormat D3D12_GetSwapchainTextureFormat(
|
|||||||
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
D3D12WindowData *windowData = D3D12_INTERNAL_FetchWindowData(window);
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Cannot get swapchain format, window has not been claimed!", SDL_GPU_TEXTUREFORMAT_INVALID)
|
SET_STRING_ERROR_AND_RETURN("Cannot get swapchain format, window has not been claimed!", SDL_GPU_TEXTUREFORMAT_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return windowData->textureContainers[windowData->frameCounter].header.info.format;
|
return windowData->textureContainers[windowData->frameCounter].header.info.format;
|
||||||
@@ -6918,7 +6923,7 @@ static bool D3D12_INTERNAL_AllocateCommandBuffer(
|
|||||||
|
|
||||||
commandBuffer = (D3D12CommandBuffer *)SDL_calloc(1, sizeof(D3D12CommandBuffer));
|
commandBuffer = (D3D12CommandBuffer *)SDL_calloc(1, sizeof(D3D12CommandBuffer));
|
||||||
if (!commandBuffer) {
|
if (!commandBuffer) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Failed to create ID3D12CommandList. Out of Memory", false)
|
SET_STRING_ERROR_AND_RETURN("Failed to create ID3D12CommandList. Out of Memory", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ID3D12Device_CreateCommandAllocator(
|
res = ID3D12Device_CreateCommandAllocator(
|
||||||
@@ -7004,7 +7009,7 @@ static bool D3D12_INTERNAL_AllocateCommandBuffer(
|
|||||||
(!commandBuffer->usedUniformBuffers) ||
|
(!commandBuffer->usedUniformBuffers) ||
|
||||||
(!commandBuffer->textureDownloads)) {
|
(!commandBuffer->textureDownloads)) {
|
||||||
D3D12_INTERNAL_DestroyCommandBuffer(commandBuffer);
|
D3D12_INTERNAL_DestroyCommandBuffer(commandBuffer);
|
||||||
SET_STRING_ERROR_AND_RETURN("Failed to create ID3D12CommandList. Out of Memory", false)
|
SET_STRING_ERROR_AND_RETURN("Failed to create ID3D12CommandList. Out of Memory", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12CommandBuffer **resizedAvailableCommandBuffers = (D3D12CommandBuffer **)SDL_realloc(
|
D3D12CommandBuffer **resizedAvailableCommandBuffers = (D3D12CommandBuffer **)SDL_realloc(
|
||||||
@@ -7013,7 +7018,7 @@ static bool D3D12_INTERNAL_AllocateCommandBuffer(
|
|||||||
|
|
||||||
if (!resizedAvailableCommandBuffers) {
|
if (!resizedAvailableCommandBuffers) {
|
||||||
D3D12_INTERNAL_DestroyCommandBuffer(commandBuffer);
|
D3D12_INTERNAL_DestroyCommandBuffer(commandBuffer);
|
||||||
SET_STRING_ERROR_AND_RETURN("Failed to create ID3D12CommandList. Out of Memory", false)
|
SET_STRING_ERROR_AND_RETURN("Failed to create ID3D12CommandList. Out of Memory", false);
|
||||||
}
|
}
|
||||||
// Add to inactive command buffer array
|
// Add to inactive command buffer array
|
||||||
renderer->availableCommandBufferCapacity += 1;
|
renderer->availableCommandBufferCapacity += 1;
|
||||||
@@ -7142,7 +7147,7 @@ static bool D3D12_AcquireSwapchainTexture(
|
|||||||
|
|
||||||
windowData = D3D12_INTERNAL_FetchWindowData(window);
|
windowData = D3D12_INTERNAL_FetchWindowData(window);
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Cannot acquire swapchain texture from an unclaimed window!", false)
|
SET_STRING_ERROR_AND_RETURN("Cannot acquire swapchain texture from an unclaimed window!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowData->needsSwapchainRecreate) {
|
if (windowData->needsSwapchainRecreate) {
|
||||||
@@ -7308,7 +7313,7 @@ static bool D3D12_INTERNAL_CopyTextureDownload(
|
|||||||
NULL,
|
NULL,
|
||||||
(void **)&sourcePtr);
|
(void **)&sourcePtr);
|
||||||
|
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Failed to map temporary buffer", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Failed to map temporary buffer", false);
|
||||||
|
|
||||||
res = ID3D12Resource_Map(
|
res = ID3D12Resource_Map(
|
||||||
download->destinationBuffer->handle,
|
download->destinationBuffer->handle,
|
||||||
@@ -7316,7 +7321,7 @@ static bool D3D12_INTERNAL_CopyTextureDownload(
|
|||||||
NULL,
|
NULL,
|
||||||
(void **)&destPtr);
|
(void **)&destPtr);
|
||||||
|
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Failed to map destination buffer", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Failed to map destination buffer", false);
|
||||||
|
|
||||||
for (Uint32 sliceIndex = 0; sliceIndex < download->depth; sliceIndex += 1) {
|
for (Uint32 sliceIndex = 0; sliceIndex < download->depth; sliceIndex += 1) {
|
||||||
for (Uint32 rowIndex = 0; rowIndex < download->height; rowIndex += 1) {
|
for (Uint32 rowIndex = 0; rowIndex < download->height; rowIndex += 1) {
|
||||||
@@ -7365,13 +7370,13 @@ static bool D3D12_INTERNAL_CleanCommandBuffer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = ID3D12CommandAllocator_Reset(commandBuffer->commandAllocator);
|
res = ID3D12CommandAllocator_Reset(commandBuffer->commandAllocator);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Could not reset command allocator", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Could not reset command allocator", false);
|
||||||
|
|
||||||
res = ID3D12GraphicsCommandList_Reset(
|
res = ID3D12GraphicsCommandList_Reset(
|
||||||
commandBuffer->graphicsCommandList,
|
commandBuffer->graphicsCommandList,
|
||||||
commandBuffer->commandAllocator,
|
commandBuffer->commandAllocator,
|
||||||
NULL);
|
NULL);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Could not reset command list", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Could not reset command list", false);
|
||||||
|
|
||||||
// Return descriptor heaps to pool
|
// Return descriptor heaps to pool
|
||||||
D3D12_INTERNAL_ReturnDescriptorHeapToPool(
|
D3D12_INTERNAL_ReturnDescriptorHeapToPool(
|
||||||
@@ -7521,7 +7526,7 @@ static bool D3D12_Submit(
|
|||||||
(void **)&commandLists[0]);
|
(void **)&commandLists[0]);
|
||||||
if (FAILED(res)) {
|
if (FAILED(res)) {
|
||||||
SDL_UnlockMutex(renderer->submitLock);
|
SDL_UnlockMutex(renderer->submitLock);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Failed to convert command list!", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Failed to convert command list!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit the command list to the queue
|
// Submit the command list to the queue
|
||||||
@@ -7690,12 +7695,12 @@ static bool D3D12_Wait(
|
|||||||
fence->handle,
|
fence->handle,
|
||||||
D3D12_FENCE_SIGNAL_VALUE,
|
D3D12_FENCE_SIGNAL_VALUE,
|
||||||
fence->event);
|
fence->event);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Setting fence event failed", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Setting fence event failed", false);
|
||||||
|
|
||||||
DWORD waitResult = WaitForSingleObject(fence->event, INFINITE);
|
DWORD waitResult = WaitForSingleObject(fence->event, INFINITE);
|
||||||
if (waitResult == WAIT_FAILED) {
|
if (waitResult == WAIT_FAILED) {
|
||||||
SDL_UnlockMutex(renderer->submitLock);
|
SDL_UnlockMutex(renderer->submitLock);
|
||||||
SET_STRING_ERROR_AND_RETURN("Wait failed", false) // TODO: is there a better way to report this?
|
SET_STRING_ERROR_AND_RETURN("Wait failed", false); // TODO: is there a better way to report this?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7738,7 +7743,7 @@ static bool D3D12_WaitForFences(
|
|||||||
fence->handle,
|
fence->handle,
|
||||||
D3D12_FENCE_SIGNAL_VALUE,
|
D3D12_FENCE_SIGNAL_VALUE,
|
||||||
fence->event);
|
fence->event);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Setting fence event failed", false)
|
CHECK_D3D12_ERROR_AND_RETURN("Setting fence event failed", false);
|
||||||
|
|
||||||
events[i] = fence->event;
|
events[i] = fence->event;
|
||||||
}
|
}
|
||||||
@@ -7751,7 +7756,7 @@ static bool D3D12_WaitForFences(
|
|||||||
|
|
||||||
if (waitResult == WAIT_FAILED) {
|
if (waitResult == WAIT_FAILED) {
|
||||||
SDL_UnlockMutex(renderer->submitLock);
|
SDL_UnlockMutex(renderer->submitLock);
|
||||||
SET_STRING_ERROR_AND_RETURN("Wait failed", false) // TODO: is there a better way to report this?
|
SET_STRING_ERROR_AND_RETURN("Wait failed", false); // TODO: is there a better way to report this?
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
@@ -8379,7 +8384,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
|||||||
CREATE_DXGI_FACTORY1_FUNC);
|
CREATE_DXGI_FACTORY1_FUNC);
|
||||||
if (CreateDXGIFactoryFunc == NULL) {
|
if (CreateDXGIFactoryFunc == NULL) {
|
||||||
D3D12_INTERNAL_DestroyRenderer(renderer);
|
D3D12_INTERNAL_DestroyRenderer(renderer);
|
||||||
SET_STRING_ERROR_AND_RETURN("Could not load function: " CREATE_DXGI_FACTORY1_FUNC, NULL)
|
SET_STRING_ERROR_AND_RETURN("Could not load function: " CREATE_DXGI_FACTORY1_FUNC, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the DXGI factory
|
// Create the DXGI factory
|
||||||
@@ -8481,7 +8486,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
|||||||
"D3D12XboxCreateDevice");
|
"D3D12XboxCreateDevice");
|
||||||
if (D3D12XboxCreateDeviceFunc == NULL) {
|
if (D3D12XboxCreateDeviceFunc == NULL) {
|
||||||
D3D12_INTERNAL_DestroyRenderer(renderer);
|
D3D12_INTERNAL_DestroyRenderer(renderer);
|
||||||
SET_STRING_ERROR_AND_RETURN("Could not load function: D3D12XboxCreateDevice", NULL)
|
SET_STRING_ERROR_AND_RETURN("Could not load function: D3D12XboxCreateDevice", NULL);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
D3D12CreateDeviceFunc = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(
|
D3D12CreateDeviceFunc = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(
|
||||||
@@ -8489,7 +8494,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
|||||||
D3D12_CREATE_DEVICE_FUNC);
|
D3D12_CREATE_DEVICE_FUNC);
|
||||||
if (D3D12CreateDeviceFunc == NULL) {
|
if (D3D12CreateDeviceFunc == NULL) {
|
||||||
D3D12_INTERNAL_DestroyRenderer(renderer);
|
D3D12_INTERNAL_DestroyRenderer(renderer);
|
||||||
SET_STRING_ERROR_AND_RETURN("Could not load function: " D3D12_CREATE_DEVICE_FUNC, NULL)
|
SET_STRING_ERROR_AND_RETURN("Could not load function: " D3D12_CREATE_DEVICE_FUNC, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -8498,7 +8503,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
|||||||
D3D12_SERIALIZE_ROOT_SIGNATURE_FUNC);
|
D3D12_SERIALIZE_ROOT_SIGNATURE_FUNC);
|
||||||
if (renderer->D3D12SerializeRootSignature_func == NULL) {
|
if (renderer->D3D12SerializeRootSignature_func == NULL) {
|
||||||
D3D12_INTERNAL_DestroyRenderer(renderer);
|
D3D12_INTERNAL_DestroyRenderer(renderer);
|
||||||
SET_STRING_ERROR_AND_RETURN("Could not load function: " D3D12_SERIALIZE_ROOT_SIGNATURE_FUNC, NULL)
|
SET_STRING_ERROR_AND_RETURN("Could not load function: " D3D12_SERIALIZE_ROOT_SIGNATURE_FUNC, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the D3D12 debug layer, if applicable
|
// Initialize the D3D12 debug layer, if applicable
|
||||||
@@ -8655,7 +8660,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
|||||||
(void **)&renderer->indirectDrawCommandSignature);
|
(void **)&renderer->indirectDrawCommandSignature);
|
||||||
if (FAILED(res)) {
|
if (FAILED(res)) {
|
||||||
D3D12_INTERNAL_DestroyRenderer(renderer);
|
D3D12_INTERNAL_DestroyRenderer(renderer);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Could not create indirect draw command signature", NULL)
|
CHECK_D3D12_ERROR_AND_RETURN("Could not create indirect draw command signature", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
indirectArgumentDesc.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED;
|
indirectArgumentDesc.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED;
|
||||||
@@ -8670,7 +8675,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
|||||||
(void **)&renderer->indirectIndexedDrawCommandSignature);
|
(void **)&renderer->indirectIndexedDrawCommandSignature);
|
||||||
if (FAILED(res)) {
|
if (FAILED(res)) {
|
||||||
D3D12_INTERNAL_DestroyRenderer(renderer);
|
D3D12_INTERNAL_DestroyRenderer(renderer);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Could not create indirect indexed draw command signature", NULL)
|
CHECK_D3D12_ERROR_AND_RETURN("Could not create indirect indexed draw command signature", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
indirectArgumentDesc.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH;
|
indirectArgumentDesc.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH;
|
||||||
@@ -8685,7 +8690,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
|||||||
(void **)&renderer->indirectDispatchCommandSignature);
|
(void **)&renderer->indirectDispatchCommandSignature);
|
||||||
if (FAILED(res)) {
|
if (FAILED(res)) {
|
||||||
D3D12_INTERNAL_DestroyRenderer(renderer);
|
D3D12_INTERNAL_DestroyRenderer(renderer);
|
||||||
CHECK_D3D12_ERROR_AND_RETURN("Could not create indirect dispatch command signature", NULL)
|
CHECK_D3D12_ERROR_AND_RETURN("Could not create indirect dispatch command signature", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize pools
|
// Initialize pools
|
||||||
|
|||||||
@@ -34,31 +34,35 @@
|
|||||||
#define WINDOW_PROPERTY_DATA "SDL_GPUMetalWindowPropertyData"
|
#define WINDOW_PROPERTY_DATA "SDL_GPUMetalWindowPropertyData"
|
||||||
#define SDL_GPU_SHADERSTAGE_COMPUTE 2
|
#define SDL_GPU_SHADERSTAGE_COMPUTE 2
|
||||||
|
|
||||||
#define TRACK_RESOURCE(resource, type, array, count, capacity) \
|
#define TRACK_RESOURCE(resource, type, array, count, capacity) \
|
||||||
Uint32 i; \
|
do { \
|
||||||
\
|
Uint32 i; \
|
||||||
for (i = 0; i < commandBuffer->count; i += 1) { \
|
\
|
||||||
if (commandBuffer->array[i] == resource) { \
|
for (i = 0; i < commandBuffer->count; i += 1) { \
|
||||||
return; \
|
if (commandBuffer->array[i] == (resource)) { \
|
||||||
} \
|
return; \
|
||||||
} \
|
} \
|
||||||
\
|
} \
|
||||||
if (commandBuffer->count == commandBuffer->capacity) { \
|
\
|
||||||
commandBuffer->capacity += 1; \
|
if (commandBuffer->count == commandBuffer->capacity) { \
|
||||||
commandBuffer->array = SDL_realloc( \
|
commandBuffer->capacity += 1; \
|
||||||
commandBuffer->array, \
|
commandBuffer->array = SDL_realloc( \
|
||||||
commandBuffer->capacity * sizeof(type)); \
|
commandBuffer->array, \
|
||||||
} \
|
commandBuffer->capacity * sizeof(type)); \
|
||||||
commandBuffer->array[commandBuffer->count] = resource; \
|
} \
|
||||||
commandBuffer->count += 1; \
|
commandBuffer->array[commandBuffer->count] = (resource); \
|
||||||
SDL_AtomicIncRef(&resource->referenceCount);
|
commandBuffer->count += 1; \
|
||||||
|
SDL_AtomicIncRef(&(resource)->referenceCount); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SET_ERROR_AND_RETURN(fmt, msg, ret) \
|
#define SET_ERROR_AND_RETURN(fmt, msg, ret) \
|
||||||
if (renderer->debugMode) { \
|
do { \
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
if (renderer->debugMode) { \
|
||||||
} \
|
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
||||||
SDL_SetError(fmt, msg); \
|
} \
|
||||||
return ret; \
|
SDL_SetError(fmt, msg); \
|
||||||
|
return ret; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SET_STRING_ERROR_AND_RETURN(msg, ret) SET_ERROR_AND_RETURN("%s", msg, ret)
|
#define SET_STRING_ERROR_AND_RETURN(msg, ret) SET_ERROR_AND_RETURN("%s", msg, ret)
|
||||||
|
|
||||||
@@ -3624,7 +3628,7 @@ static bool METAL_ClaimWindow(
|
|||||||
SET_STRING_ERROR_AND_RETURN("Could not create swapchain, failed to claim window", false);
|
SET_STRING_ERROR_AND_RETURN("Could not create swapchain, failed to claim window", false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SET_ERROR_AND_RETURN("Window already claimed!", false)
|
SET_ERROR_AND_RETURN("%s", "Window already claimed!", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,23 +86,27 @@ typedef struct VulkanExtensions
|
|||||||
#define NULL_RENDER_PASS (SDL_GPURenderPass *)0
|
#define NULL_RENDER_PASS (SDL_GPURenderPass *)0
|
||||||
|
|
||||||
#define EXPAND_ELEMENTS_IF_NEEDED(arr, initialValue, type) \
|
#define EXPAND_ELEMENTS_IF_NEEDED(arr, initialValue, type) \
|
||||||
if (arr->count == arr->capacity) { \
|
do { \
|
||||||
if (arr->capacity == 0) { \
|
if (arr->count == arr->capacity) { \
|
||||||
arr->capacity = initialValue; \
|
if (arr->capacity == 0) { \
|
||||||
} else { \
|
arr->capacity = initialValue; \
|
||||||
arr->capacity *= 2; \
|
} else { \
|
||||||
|
arr->capacity *= 2; \
|
||||||
|
} \
|
||||||
|
arr->elements = (type *)SDL_realloc( \
|
||||||
|
arr->elements, \
|
||||||
|
arr->capacity * sizeof(type)); \
|
||||||
} \
|
} \
|
||||||
arr->elements = (type *)SDL_realloc( \
|
} while (0)
|
||||||
arr->elements, \
|
|
||||||
arr->capacity * sizeof(type)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define MOVE_ARRAY_CONTENTS_AND_RESET(i, dstArr, dstCount, srcArr, srcCount) \
|
#define MOVE_ARRAY_CONTENTS_AND_RESET(i, dstArr, dstCount, srcArr, srcCount) \
|
||||||
for (i = 0; i < srcCount; i += 1) { \
|
do { \
|
||||||
dstArr[i] = srcArr[i]; \
|
for ((i) = 0; (i) < (srcCount); (i) += 1) { \
|
||||||
} \
|
(dstArr)[i] = (srcArr)[i]; \
|
||||||
dstCount = srcCount; \
|
} \
|
||||||
srcCount = 0;
|
(dstCount) = (srcCount); \
|
||||||
|
(srcCount) = 0; \
|
||||||
|
while (0)
|
||||||
|
|
||||||
// Conversions
|
// Conversions
|
||||||
|
|
||||||
@@ -1250,23 +1254,27 @@ static inline const char *VkErrorMessages(VkResult code)
|
|||||||
#undef ERR_TO_STR
|
#undef ERR_TO_STR
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SET_ERROR_AND_RETURN(fmt, msg, ret) \
|
#define SET_ERROR_AND_RETURN(fmt, msg, ret) \
|
||||||
if (renderer->debugMode) { \
|
do { \
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
if (renderer->debugMode) { \
|
||||||
} \
|
SDL_LogError(SDL_LOG_CATEGORY_GPU, fmt, msg); \
|
||||||
SDL_SetError(fmt, msg); \
|
} \
|
||||||
return ret; \
|
SDL_SetError((fmt), (msg)); \
|
||||||
|
return ret; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define SET_STRING_ERROR_AND_RETURN(msg, ret) SET_ERROR_AND_RETURN("%s", msg, ret)
|
#define SET_STRING_ERROR_AND_RETURN(msg, ret) SET_ERROR_AND_RETURN("%s", msg, ret)
|
||||||
|
|
||||||
#define CHECK_VULKAN_ERROR_AND_RETURN(res, fn, ret) \
|
#define CHECK_VULKAN_ERROR_AND_RETURN(res, fn, ret) \
|
||||||
if (res != VK_SUCCESS) { \
|
do { \
|
||||||
if (renderer->debugMode) { \
|
if ((res) != VK_SUCCESS) { \
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_GPU, "%s %s", #fn, VkErrorMessages(res)); \
|
if (renderer->debugMode) { \
|
||||||
} \
|
SDL_LogError(SDL_LOG_CATEGORY_GPU, "%s %s", #fn, VkErrorMessages(res)); \
|
||||||
SDL_SetError("%s %s", #fn, VkErrorMessages(res)); \
|
} \
|
||||||
return ret; \
|
SDL_SetError("%s %s", #fn, VkErrorMessages(res)); \
|
||||||
}
|
return (ret); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
|
|
||||||
@@ -1846,7 +1854,7 @@ static Uint8 VULKAN_INTERNAL_AllocateMemory(
|
|||||||
VK_WHOLE_SIZE,
|
VK_WHOLE_SIZE,
|
||||||
0,
|
0,
|
||||||
(void **)&allocation->mapPointer);
|
(void **)&allocation->mapPointer);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkMapMemory, 0)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkMapMemory, 0);
|
||||||
} else {
|
} else {
|
||||||
allocation->mapPointer = NULL;
|
allocation->mapPointer = NULL;
|
||||||
}
|
}
|
||||||
@@ -1879,7 +1887,7 @@ static Uint8 VULKAN_INTERNAL_BindBufferMemory(
|
|||||||
|
|
||||||
SDL_UnlockMutex(usedRegion->allocation->memoryLock);
|
SDL_UnlockMutex(usedRegion->allocation->memoryLock);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkBindBufferMemory, 0)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkBindBufferMemory, 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -1902,7 +1910,7 @@ static Uint8 VULKAN_INTERNAL_BindImageMemory(
|
|||||||
|
|
||||||
SDL_UnlockMutex(usedRegion->allocation->memoryLock);
|
SDL_UnlockMutex(usedRegion->allocation->memoryLock);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkBindImageMemory, 0)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkBindImageMemory, 0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -3598,7 +3606,7 @@ static bool VULKAN_INTERNAL_AllocateDescriptorSets(
|
|||||||
|
|
||||||
SDL_stack_free(descriptorSetLayouts);
|
SDL_stack_free(descriptorSetLayouts);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkAllocateDescriptorSets, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkAllocateDescriptorSets, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3671,7 +3679,7 @@ static bool VULKAN_INTERNAL_AllocateDescriptorsFromPool(
|
|||||||
NULL,
|
NULL,
|
||||||
&pool);
|
&pool);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateDescriptorPool, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateDescriptorPool, false);
|
||||||
|
|
||||||
descriptorSetPool->poolCount += 1;
|
descriptorSetPool->poolCount += 1;
|
||||||
descriptorSetPool->descriptorPools = SDL_realloc(
|
descriptorSetPool->descriptorPools = SDL_realloc(
|
||||||
@@ -3810,7 +3818,7 @@ static DescriptorSetLayout *VULKAN_INTERNAL_FetchDescriptorSetLayout(
|
|||||||
NULL,
|
NULL,
|
||||||
&descriptorSetLayout);
|
&descriptorSetLayout);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateDescriptorSetLayout, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateDescriptorSetLayout, NULL);
|
||||||
|
|
||||||
layout = SDL_malloc(sizeof(DescriptorSetLayout));
|
layout = SDL_malloc(sizeof(DescriptorSetLayout));
|
||||||
layout->descriptorSetLayout = descriptorSetLayout;
|
layout->descriptorSetLayout = descriptorSetLayout;
|
||||||
@@ -3938,7 +3946,7 @@ static VulkanGraphicsPipelineResourceLayout *VULKAN_INTERNAL_FetchGraphicsPipeli
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
VULKAN_INTERNAL_DestroyGraphicsPipelineResourceLayout(renderer, pipelineResourceLayout);
|
VULKAN_INTERNAL_DestroyGraphicsPipelineResourceLayout(renderer, pipelineResourceLayout);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreatePipelineLayout, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreatePipelineLayout, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsPipelineResourceLayoutHashTableKey *allocedKey = SDL_malloc(sizeof(GraphicsPipelineResourceLayoutHashTableKey));
|
GraphicsPipelineResourceLayoutHashTableKey *allocedKey = SDL_malloc(sizeof(GraphicsPipelineResourceLayoutHashTableKey));
|
||||||
@@ -4039,7 +4047,7 @@ static VulkanComputePipelineResourceLayout *VULKAN_INTERNAL_FetchComputePipeline
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
VULKAN_INTERNAL_DestroyComputePipelineResourceLayout(renderer, pipelineResourceLayout);
|
VULKAN_INTERNAL_DestroyComputePipelineResourceLayout(renderer, pipelineResourceLayout);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreatePipelineLayout, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreatePipelineLayout, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputePipelineResourceLayoutHashTableKey *allocedKey = SDL_malloc(sizeof(ComputePipelineResourceLayoutHashTableKey));
|
ComputePipelineResourceLayoutHashTableKey *allocedKey = SDL_malloc(sizeof(ComputePipelineResourceLayoutHashTableKey));
|
||||||
@@ -4121,7 +4129,7 @@ static VulkanBuffer *VULKAN_INTERNAL_CreateBuffer(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
SDL_free(buffer);
|
SDL_free(buffer);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateBuffer, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateBuffer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bindResult = VULKAN_INTERNAL_BindMemoryForBuffer(
|
bindResult = VULKAN_INTERNAL_BindMemoryForBuffer(
|
||||||
@@ -4244,7 +4252,7 @@ static bool VULKAN_INTERNAL_CreateRenderTargetView(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
*pView = (VkImageView)VK_NULL_HANDLE;
|
*pView = (VkImageView)VK_NULL_HANDLE;
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateImageView, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateImageView, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -4284,7 +4292,7 @@ static bool VULKAN_INTERNAL_CreateSubresourceView(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
*pView = (VkImageView)VK_NULL_HANDLE;
|
*pView = (VkImageView)VK_NULL_HANDLE;
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateImageView, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateImageView, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -4312,7 +4320,7 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
outputDetails->presentModesLength = 0;
|
outputDetails->presentModesLength = 0;
|
||||||
|
|
||||||
if (!supportsPresent) {
|
if (!supportsPresent) {
|
||||||
SET_STRING_ERROR_AND_RETURN("This surface does not support presenting!", false)
|
SET_STRING_ERROR_AND_RETURN("This surface does not support presenting!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the device surface queries
|
// Run the device surface queries
|
||||||
@@ -4320,7 +4328,7 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
physicalDevice,
|
physicalDevice,
|
||||||
surface,
|
surface,
|
||||||
&outputDetails->capabilities);
|
&outputDetails->capabilities);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceCapabilitiesKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceCapabilitiesKHR, false);
|
||||||
|
|
||||||
if (!(outputDetails->capabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR)) {
|
if (!(outputDetails->capabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR)) {
|
||||||
SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "Opaque presentation unsupported! Expect weird transparency bugs!");
|
SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "Opaque presentation unsupported! Expect weird transparency bugs!");
|
||||||
@@ -4331,13 +4339,13 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
surface,
|
surface,
|
||||||
&outputDetails->formatsLength,
|
&outputDetails->formatsLength,
|
||||||
NULL);
|
NULL);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false);
|
||||||
result = renderer->vkGetPhysicalDeviceSurfacePresentModesKHR(
|
result = renderer->vkGetPhysicalDeviceSurfacePresentModesKHR(
|
||||||
physicalDevice,
|
physicalDevice,
|
||||||
surface,
|
surface,
|
||||||
&outputDetails->presentModesLength,
|
&outputDetails->presentModesLength,
|
||||||
NULL);
|
NULL);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false);
|
||||||
|
|
||||||
// Generate the arrays, if applicable
|
// Generate the arrays, if applicable
|
||||||
|
|
||||||
@@ -4357,7 +4365,7 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
outputDetails->formats);
|
outputDetails->formats);
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
SDL_free(outputDetails->formats);
|
SDL_free(outputDetails->formats);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4379,7 +4387,7 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
SDL_free(outputDetails->formats);
|
SDL_free(outputDetails->formats);
|
||||||
SDL_free(outputDetails->presentModes);
|
SDL_free(outputDetails->presentModes);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4619,7 +4627,7 @@ static Uint32 VULKAN_INTERNAL_CreateSwapchain(
|
|||||||
windowData->surface,
|
windowData->surface,
|
||||||
NULL);
|
NULL);
|
||||||
windowData->surface = VK_NULL_HANDLE;
|
windowData->surface = VK_NULL_HANDLE;
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSwapchainKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSwapchainKHR, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
vulkanResult = renderer->vkGetSwapchainImagesKHR(
|
vulkanResult = renderer->vkGetSwapchainImagesKHR(
|
||||||
@@ -4627,7 +4635,7 @@ static Uint32 VULKAN_INTERNAL_CreateSwapchain(
|
|||||||
windowData->swapchain,
|
windowData->swapchain,
|
||||||
&windowData->imageCount,
|
&windowData->imageCount,
|
||||||
NULL);
|
NULL);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkGetSwapchainImagesKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkGetSwapchainImagesKHR, false);
|
||||||
|
|
||||||
windowData->textureContainers = SDL_malloc(
|
windowData->textureContainers = SDL_malloc(
|
||||||
sizeof(VulkanTextureContainer) * windowData->imageCount);
|
sizeof(VulkanTextureContainer) * windowData->imageCount);
|
||||||
@@ -4653,7 +4661,7 @@ static Uint32 VULKAN_INTERNAL_CreateSwapchain(
|
|||||||
windowData->swapchain,
|
windowData->swapchain,
|
||||||
&windowData->imageCount,
|
&windowData->imageCount,
|
||||||
swapchainImages);
|
swapchainImages);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkGetSwapchainImagesKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkGetSwapchainImagesKHR, false);
|
||||||
|
|
||||||
for (i = 0; i < windowData->imageCount; i += 1) {
|
for (i = 0; i < windowData->imageCount; i += 1) {
|
||||||
|
|
||||||
@@ -4737,7 +4745,7 @@ static Uint32 VULKAN_INTERNAL_CreateSwapchain(
|
|||||||
NULL);
|
NULL);
|
||||||
windowData->surface = VK_NULL_HANDLE;
|
windowData->surface = VK_NULL_HANDLE;
|
||||||
windowData->swapchain = VK_NULL_HANDLE;
|
windowData->swapchain = VK_NULL_HANDLE;
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSemaphore, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSemaphore, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer->vkCreateSemaphore(
|
renderer->vkCreateSemaphore(
|
||||||
@@ -4757,7 +4765,7 @@ static Uint32 VULKAN_INTERNAL_CreateSwapchain(
|
|||||||
NULL);
|
NULL);
|
||||||
windowData->surface = VK_NULL_HANDLE;
|
windowData->surface = VK_NULL_HANDLE;
|
||||||
windowData->swapchain = VK_NULL_HANDLE;
|
windowData->swapchain = VK_NULL_HANDLE;
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSemaphore, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSemaphore, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
windowData->inFlightFences[i] = NULL;
|
windowData->inFlightFences[i] = NULL;
|
||||||
@@ -4786,7 +4794,7 @@ static bool VULKAN_INTERNAL_BeginCommandBuffer(
|
|||||||
commandBuffer->commandBuffer,
|
commandBuffer->commandBuffer,
|
||||||
&beginInfo);
|
&beginInfo);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkBeginCommandBuffer, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkBeginCommandBuffer, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4798,7 +4806,7 @@ static bool VULKAN_INTERNAL_EndCommandBuffer(
|
|||||||
VkResult result = renderer->vkEndCommandBuffer(
|
VkResult result = renderer->vkEndCommandBuffer(
|
||||||
commandBuffer->commandBuffer);
|
commandBuffer->commandBuffer);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkEndCommandBuffer, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkEndCommandBuffer, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5615,7 +5623,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
VULKAN_INTERNAL_DestroyTexture(renderer, texture);
|
VULKAN_INTERNAL_DestroyTexture(renderer, texture);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateImage, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateImage, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bindResult = VULKAN_INTERNAL_BindMemoryForImage(
|
bindResult = VULKAN_INTERNAL_BindMemoryForImage(
|
||||||
@@ -5630,7 +5638,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture(
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
VULKAN_INTERNAL_DestroyTexture(renderer, texture);
|
VULKAN_INTERNAL_DestroyTexture(renderer, texture);
|
||||||
SET_STRING_ERROR_AND_RETURN("Unable to bind memory for texture!", NULL)
|
SET_STRING_ERROR_AND_RETURN("Unable to bind memory for texture!", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
texture->usedRegion->vulkanTexture = texture; // lol
|
texture->usedRegion->vulkanTexture = texture; // lol
|
||||||
@@ -5669,7 +5677,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
VULKAN_INTERNAL_DestroyTexture(renderer, texture);
|
VULKAN_INTERNAL_DestroyTexture(renderer, texture);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, "vkCreateImageView", NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, "vkCreateImageView", NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6130,7 +6138,7 @@ static VkRenderPass VULKAN_INTERNAL_CreateTransientRenderPass(
|
|||||||
NULL,
|
NULL,
|
||||||
&renderPass);
|
&renderPass);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkCreateRenderPass, VK_NULL_HANDLE)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkCreateRenderPass, VK_NULL_HANDLE);
|
||||||
|
|
||||||
return renderPass;
|
return renderPass;
|
||||||
}
|
}
|
||||||
@@ -6461,7 +6469,7 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
SDL_free(graphicsPipeline);
|
SDL_free(graphicsPipeline);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateGraphicsPipelines, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateGraphicsPipelines, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetAtomicInt(&graphicsPipeline->referenceCount, 0);
|
SDL_SetAtomicInt(&graphicsPipeline->referenceCount, 0);
|
||||||
@@ -6481,7 +6489,7 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline(
|
|||||||
VulkanComputePipeline *vulkanComputePipeline;
|
VulkanComputePipeline *vulkanComputePipeline;
|
||||||
|
|
||||||
if (createinfo->format != SDL_GPU_SHADERFORMAT_SPIRV) {
|
if (createinfo->format != SDL_GPU_SHADERFORMAT_SPIRV) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Incompatible shader format for Vulkan!", NULL)
|
SET_STRING_ERROR_AND_RETURN("Incompatible shader format for Vulkan!", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
vulkanComputePipeline = SDL_malloc(sizeof(VulkanComputePipeline));
|
vulkanComputePipeline = SDL_malloc(sizeof(VulkanComputePipeline));
|
||||||
@@ -6499,7 +6507,7 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
SDL_free(vulkanComputePipeline);
|
SDL_free(vulkanComputePipeline);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateShaderModule, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateShaderModule, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
pipelineShaderStageCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
pipelineShaderStageCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
|
||||||
@@ -6541,7 +6549,7 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
VULKAN_INTERNAL_DestroyComputePipeline(renderer, vulkanComputePipeline);
|
VULKAN_INTERNAL_DestroyComputePipeline(renderer, vulkanComputePipeline);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateComputePipeline, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateComputePipeline, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6586,7 +6594,7 @@ static SDL_GPUSampler *VULKAN_CreateSampler(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
SDL_free(vulkanSampler);
|
SDL_free(vulkanSampler);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSampler, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateSampler, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetAtomicInt(&vulkanSampler->referenceCount, 0);
|
SDL_SetAtomicInt(&vulkanSampler->referenceCount, 0);
|
||||||
@@ -6619,7 +6627,7 @@ static SDL_GPUShader *VULKAN_CreateShader(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
SDL_free(vulkanShader);
|
SDL_free(vulkanShader);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateShaderModule, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateShaderModule, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
entryPointNameLength = SDL_strlen(createinfo->entrypoint) + 1;
|
entryPointNameLength = SDL_strlen(createinfo->entrypoint) + 1;
|
||||||
@@ -7172,7 +7180,7 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer(
|
|||||||
SDL_UnlockMutex(renderer->framebufferFetchLock);
|
SDL_UnlockMutex(renderer->framebufferFetchLock);
|
||||||
} else {
|
} else {
|
||||||
SDL_free(vulkanFramebuffer);
|
SDL_free(vulkanFramebuffer);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkCreateFramebuffer, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkCreateFramebuffer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vulkanFramebuffer;
|
return vulkanFramebuffer;
|
||||||
@@ -9097,7 +9105,7 @@ static bool VULKAN_INTERNAL_AllocateCommandBuffer(
|
|||||||
&allocateInfo,
|
&allocateInfo,
|
||||||
&commandBufferHandle);
|
&commandBufferHandle);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkAllocateCommandBuffers, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkAllocateCommandBuffers, false);
|
||||||
|
|
||||||
commandBuffer = SDL_malloc(sizeof(VulkanCommandBuffer));
|
commandBuffer = SDL_malloc(sizeof(VulkanCommandBuffer));
|
||||||
commandBuffer->renderer = renderer;
|
commandBuffer->renderer = renderer;
|
||||||
@@ -9225,7 +9233,7 @@ static VulkanCommandPool *VULKAN_INTERNAL_FetchCommandPool(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
SDL_free(vulkanCommandPool);
|
SDL_free(vulkanCommandPool);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateCommandPool, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateCommandPool, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9367,7 +9375,7 @@ static SDL_GPUCommandBuffer *VULKAN_AcquireCommandBuffer(
|
|||||||
commandBuffer->commandBuffer,
|
commandBuffer->commandBuffer,
|
||||||
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
|
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkResetCommandBuffer, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkResetCommandBuffer, NULL);
|
||||||
|
|
||||||
if (!VULKAN_INTERNAL_BeginCommandBuffer(renderer, commandBuffer)) {
|
if (!VULKAN_INTERNAL_BeginCommandBuffer(renderer, commandBuffer)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -9392,7 +9400,7 @@ static bool VULKAN_QueryFence(
|
|||||||
} else if (result == VK_NOT_READY) {
|
} else if (result == VK_NOT_READY) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
SET_ERROR_AND_RETURN("vkGetFenceStatus: %s", VkErrorMessages(result), false)
|
SET_ERROR_AND_RETURN("vkGetFenceStatus: %s", VkErrorMessages(result), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9459,7 +9467,7 @@ static bool VULKAN_SupportsSwapchainComposition(
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Must claim window before querying swapchain composition support!", false)
|
SET_STRING_ERROR_AND_RETURN("Must claim window before querying swapchain composition support!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
surface = windowData->surface;
|
surface = windowData->surface;
|
||||||
@@ -9504,7 +9512,7 @@ static bool VULKAN_SupportsPresentMode(
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Must claim window before querying present mode support!", false)
|
SET_STRING_ERROR_AND_RETURN("Must claim window before querying present mode support!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
surface = windowData->surface;
|
surface = windowData->surface;
|
||||||
@@ -9577,7 +9585,7 @@ static bool VULKAN_ClaimWindow(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SET_STRING_ERROR_AND_RETURN("Window already claimed!", false)
|
SET_STRING_ERROR_AND_RETURN("Window already claimed!", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9672,7 +9680,7 @@ static bool VULKAN_AcquireSwapchainTexture(
|
|||||||
|
|
||||||
windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Cannot acquire a swapchain texture from an unclaimed window!", false)
|
SET_STRING_ERROR_AND_RETURN("Cannot acquire a swapchain texture from an unclaimed window!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If window data marked as needing swapchain recreate, try to recreate
|
// If window data marked as needing swapchain recreate, try to recreate
|
||||||
@@ -9843,7 +9851,7 @@ static SDL_GPUTextureFormat VULKAN_GetSwapchainTextureFormat(
|
|||||||
WindowData *windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
WindowData *windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Cannot get swapchain format, window has not been claimed!", SDL_GPU_TEXTUREFORMAT_INVALID)
|
SET_STRING_ERROR_AND_RETURN("Cannot get swapchain format, window has not been claimed!", SDL_GPU_TEXTUREFORMAT_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SwapchainCompositionToSDLFormat(
|
return SwapchainCompositionToSDLFormat(
|
||||||
@@ -9861,15 +9869,15 @@ static bool VULKAN_SetSwapchainParameters(
|
|||||||
WindowData *windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
WindowData *windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Cannot set swapchain parameters on unclaimed window!", false)
|
SET_STRING_ERROR_AND_RETURN("Cannot set swapchain parameters on unclaimed window!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VULKAN_SupportsSwapchainComposition(driverData, window, swapchainComposition)) {
|
if (!VULKAN_SupportsSwapchainComposition(driverData, window, swapchainComposition)) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Swapchain composition not supported!", false)
|
SET_STRING_ERROR_AND_RETURN("Swapchain composition not supported!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VULKAN_SupportsPresentMode(driverData, window, presentMode)) {
|
if (!VULKAN_SupportsPresentMode(driverData, window, presentMode)) {
|
||||||
SET_STRING_ERROR_AND_RETURN("Present mode not supported!", false)
|
SET_STRING_ERROR_AND_RETURN("Present mode not supported!", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
windowData->presentMode = presentMode;
|
windowData->presentMode = presentMode;
|
||||||
@@ -9932,7 +9940,7 @@ static VulkanFenceHandle *VULKAN_INTERNAL_AcquireFenceFromPool(
|
|||||||
NULL,
|
NULL,
|
||||||
&fence);
|
&fence);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateFence, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateFence, NULL);
|
||||||
|
|
||||||
handle = SDL_malloc(sizeof(VulkanFenceHandle));
|
handle = SDL_malloc(sizeof(VulkanFenceHandle));
|
||||||
handle->fence = fence;
|
handle->fence = fence;
|
||||||
@@ -9952,7 +9960,7 @@ static VulkanFenceHandle *VULKAN_INTERNAL_AcquireFenceFromPool(
|
|||||||
|
|
||||||
SDL_UnlockMutex(renderer->fencePool.lock);
|
SDL_UnlockMutex(renderer->fencePool.lock);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkResetFences, NULL)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkResetFences, NULL);
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@@ -10168,7 +10176,7 @@ static bool VULKAN_WaitForFences(
|
|||||||
waitAll,
|
waitAll,
|
||||||
SDL_MAX_UINT64);
|
SDL_MAX_UINT64);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkWaitForFences, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkWaitForFences, false);
|
||||||
|
|
||||||
SDL_stack_free(vkFences);
|
SDL_stack_free(vkFences);
|
||||||
|
|
||||||
@@ -10204,7 +10212,7 @@ static bool VULKAN_Wait(
|
|||||||
|
|
||||||
result = renderer->vkDeviceWaitIdle(renderer->logicalDevice);
|
result = renderer->vkDeviceWaitIdle(renderer->logicalDevice);
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkDeviceWaitIdle, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkDeviceWaitIdle, false);
|
||||||
|
|
||||||
SDL_LockMutex(renderer->submitLock);
|
SDL_LockMutex(renderer->submitLock);
|
||||||
|
|
||||||
@@ -10317,7 +10325,7 @@ static bool VULKAN_Submit(
|
|||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
SDL_UnlockMutex(renderer->submitLock);
|
SDL_UnlockMutex(renderer->submitLock);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkQueueSubmit, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkQueueSubmit, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Present, if applicable
|
// Present, if applicable
|
||||||
@@ -10356,7 +10364,7 @@ static bool VULKAN_Submit(
|
|||||||
SDL_UnlockMutex(renderer->submitLock);
|
SDL_UnlockMutex(renderer->submitLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(presentResult, vkQueuePresentKHR, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(presentResult, vkQueuePresentKHR, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
presentData->windowData->frameCounter =
|
presentData->windowData->frameCounter =
|
||||||
@@ -10432,7 +10440,7 @@ static bool VULKAN_Cancel(
|
|||||||
result = renderer->vkResetCommandBuffer(
|
result = renderer->vkResetCommandBuffer(
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
|
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkResetCommandBuffer, false)
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkResetCommandBuffer, false);
|
||||||
|
|
||||||
vulkanCommandBuffer->autoReleaseFence = false;
|
vulkanCommandBuffer->autoReleaseFence = false;
|
||||||
SDL_LockMutex(renderer->submitLock);
|
SDL_LockMutex(renderer->submitLock);
|
||||||
@@ -10930,7 +10938,7 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer)
|
|||||||
&renderer->supportsDebugUtils,
|
&renderer->supportsDebugUtils,
|
||||||
&renderer->supportsColorspace)) {
|
&renderer->supportsColorspace)) {
|
||||||
SDL_stack_free((char *)instanceExtensionNames);
|
SDL_stack_free((char *)instanceExtensionNames);
|
||||||
SET_STRING_ERROR_AND_RETURN("Required Vulkan instance extensions not supported", false)
|
SET_STRING_ERROR_AND_RETURN("Required Vulkan instance extensions not supported", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderer->supportsDebugUtils) {
|
if (renderer->supportsDebugUtils) {
|
||||||
@@ -10975,7 +10983,7 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer)
|
|||||||
SDL_stack_free((char *)instanceExtensionNames);
|
SDL_stack_free((char *)instanceExtensionNames);
|
||||||
|
|
||||||
if (vulkanResult != VK_SUCCESS) {
|
if (vulkanResult != VK_SUCCESS) {
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateInstance, 0)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateInstance, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -11129,7 +11137,7 @@ static Uint8 VULKAN_INTERNAL_DeterminePhysicalDevice(VulkanRenderer *renderer)
|
|||||||
renderer->instance,
|
renderer->instance,
|
||||||
&physicalDeviceCount,
|
&physicalDeviceCount,
|
||||||
NULL);
|
NULL);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkEnumeratePhysicalDevices, 0)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkEnumeratePhysicalDevices, 0);
|
||||||
|
|
||||||
if (physicalDeviceCount == 0) {
|
if (physicalDeviceCount == 0) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Failed to find any GPUs with Vulkan support");
|
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "Failed to find any GPUs with Vulkan support");
|
||||||
@@ -11329,7 +11337,7 @@ static Uint8 VULKAN_INTERNAL_CreateLogicalDevice(
|
|||||||
NULL,
|
NULL,
|
||||||
&renderer->logicalDevice);
|
&renderer->logicalDevice);
|
||||||
SDL_stack_free((void *)deviceExtensions);
|
SDL_stack_free((void *)deviceExtensions);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateDevice, 0)
|
CHECK_VULKAN_ERROR_AND_RETURN(vulkanResult, vkCreateDevice, 0);
|
||||||
|
|
||||||
// Load vkDevice entry points
|
// Load vkDevice entry points
|
||||||
|
|
||||||
@@ -11454,7 +11462,7 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
|
|||||||
if (!VULKAN_INTERNAL_PrepareVulkan(renderer)) {
|
if (!VULKAN_INTERNAL_PrepareVulkan(renderer)) {
|
||||||
SDL_free(renderer);
|
SDL_free(renderer);
|
||||||
SDL_Vulkan_UnloadLibrary();
|
SDL_Vulkan_UnloadLibrary();
|
||||||
SET_STRING_ERROR_AND_RETURN("Failed to initialize Vulkan!", NULL)
|
SET_STRING_ERROR_AND_RETURN("Failed to initialize Vulkan!", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "SDL_GPU Driver: Vulkan");
|
SDL_LogInfo(SDL_LOG_CATEGORY_GPU, "SDL_GPU Driver: Vulkan");
|
||||||
@@ -11482,7 +11490,7 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
|
|||||||
renderer)) {
|
renderer)) {
|
||||||
SDL_free(renderer);
|
SDL_free(renderer);
|
||||||
SDL_Vulkan_UnloadLibrary();
|
SDL_Vulkan_UnloadLibrary();
|
||||||
SET_STRING_ERROR_AND_RETURN("Failed to create logical device!", NULL)
|
SET_STRING_ERROR_AND_RETURN("Failed to create logical device!", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: just move this into this function
|
// FIXME: just move this into this function
|
||||||
|
|||||||
Reference in New Issue
Block a user