From eb244447cc45b2fb3e22e0ae0279ebc9fe3f37b5 Mon Sep 17 00:00:00 2001 From: Greg Wells Date: Fri, 30 May 2025 13:41:11 -0400 Subject: [PATCH] flip the viewport in vulkan so that top is on the top --- .../vulkan/src/commands/commands/vulkan_commands.c | 8 ++++---- .../vulkan/src/output_device/vulkan_output_device.c | 4 ++-- .../graphics_pipeline/vulkan_graphics_pipeline.c | 2 +- src/core/gryphn_platform_functions.h | 2 ++ src/core/instance/init/gryphn_init.c | 1 + src/core/output_device/gryphn_output_device.c | 3 +++ src/core/output_device/gryphn_output_device.h | 3 +-- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/rendering_api/vulkan/src/commands/commands/vulkan_commands.c b/rendering_api/vulkan/src/commands/commands/vulkan_commands.c index a11ded7..82c1753 100644 --- a/rendering_api/vulkan/src/commands/commands/vulkan_commands.c +++ b/rendering_api/vulkan/src/commands/commands/vulkan_commands.c @@ -22,10 +22,10 @@ void gnCommandBeginRenderPassFn(struct gnCommandBuffer_t* buffer, struct gnRende .framebuffer = passInfo.framebuffer->framebuffer->framebuffer, .renderArea = { .extent = { passInfo.size.x, passInfo.size.y }, - .offset = { passInfo.offset.x, passInfo.offset.x } + .offset = { passInfo.offset.x, passInfo.offset.y } }, .clearValueCount = passInfo.clearValueCount, - .pClearValues = values + .pClearValues = values, }; vkCmdBeginRenderPass(buffer->commandBuffer->buffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE); @@ -39,9 +39,9 @@ void gnCommandBindGraphicsPipelineFn(struct gnCommandBuffer_t* buffer, struct gn void gnCommandSetViewportFn(struct gnCommandBuffer_t* buffer, struct gnViewport_t viewport) { VkViewport vkViewport = { .x = viewport.position.x, - .y = viewport.position.y, + .y = viewport.size.y, .width = viewport.size.x, - .height = viewport.size.y, + .height = -viewport.size.y, .minDepth = viewport.minDepth, .maxDepth = viewport.maxDepth }; diff --git a/rendering_api/vulkan/src/output_device/vulkan_output_device.c b/rendering_api/vulkan/src/output_device/vulkan_output_device.c index 2fef92a..eecda24 100644 --- a/rendering_api/vulkan/src/output_device/vulkan_output_device.c +++ b/rendering_api/vulkan/src/output_device/vulkan_output_device.c @@ -65,10 +65,10 @@ gnReturnCode gnCreateOutputDeviceFn(gnOutputDevice* outputDevice, gnInstance* in } void gnWaitForDeviceFn(const gnOutputDevice* device) { - // vkDeviceWaitIdle(device->outputDevice->device); + vkDeviceWaitIdle(device->outputDevice->device); } void gnDestroyOutputDeviceFn(gnOutputDevice* device) { - // vkDestroyCommandPool(device.outputDevice->device, device.outputDevice->commandPool, nullptr); vkDestroyDevice(device->outputDevice->device, NULL); + free(device->outputDevice); } diff --git a/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c b/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c index 6452846..687ffee 100644 --- a/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c +++ b/rendering_api/vulkan/src/pipelines/graphics_pipeline/vulkan_graphics_pipeline.c @@ -113,7 +113,7 @@ gnReturnCode gnCreateGraphicsPipelineFn(struct gnGraphicsPipeline_t* graphicsPip .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, .polygonMode = vkGryphnPolygonMode(info.fillMode), .lineWidth = 1.0f, - .frontFace = ( info.cullMode.direction == GN_DIRECTION_CLOCK_WISE ) ? VK_FRONT_FACE_CLOCKWISE : VK_FRONT_FACE_COUNTER_CLOCKWISE, + .frontFace = ( info.cullMode.direction == GN_DIRECTION_CLOCK_WISE ) ? VK_FRONT_FACE_COUNTER_CLOCKWISE : VK_FRONT_FACE_CLOCKWISE, .cullMode = vkGryphnCullMode(info.cullMode.face), .depthBiasEnable = VK_FALSE, .depthBiasConstantFactor = 0.0f, diff --git a/src/core/gryphn_platform_functions.h b/src/core/gryphn_platform_functions.h index cb91dbb..e654bd9 100644 --- a/src/core/gryphn_platform_functions.h +++ b/src/core/gryphn_platform_functions.h @@ -89,6 +89,8 @@ typedef struct gnDeviceFunctions_t { gnReturnCode (*_gnSubmit)(struct gnOutputDevice_t* device, struct gnSubmitInfo_t submit); gnReturnCode (*_gnPresent)(struct gnOutputDevice_t* device, struct gnPresentInfo_t info); + + void (*_gnWaitForDevice)(struct gnOutputDevice_t* device); } gnDeviceFunctions; typedef struct gnCommandFunctions_t { diff --git a/src/core/instance/init/gryphn_init.c b/src/core/instance/init/gryphn_init.c index 719d679..47e9778 100644 --- a/src/core/instance/init/gryphn_init.c +++ b/src/core/instance/init/gryphn_init.c @@ -91,6 +91,7 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti gnLoadDLLFunction(lib, functions->_gnDestroyFence, "gnDestroyFenceFn"); gnLoadDLLFunction(lib, functions->_gnSubmit, "gnSubmitFn"); gnLoadDLLFunction(lib, functions->_gnPresent, "gnPresentFn"); + gnLoadDLLFunction(lib, functions->_gnWaitForDevice, "gnWaitForDeviceFn"); } void gnLoadCommandFunctions(struct gnDynamicLibrary_t* lib, struct gnCommandFunctions_t* functions) { diff --git a/src/core/output_device/gryphn_output_device.c b/src/core/output_device/gryphn_output_device.c index 5c89024..6626511 100644 --- a/src/core/output_device/gryphn_output_device.c +++ b/src/core/output_device/gryphn_output_device.c @@ -17,6 +17,9 @@ gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* inst outputDevice->deviceInfo = deviceInfo; return instance->functions->_gnCreateOutputDevoce(outputDevice, instance, deviceInfo); } +void gnWaitForDevice(gnOutputDevice *device) { + device->deviceFunctions->_gnWaitForDevice(device); +} void gnDestroyOutputDevice(gnOutputDevice* device) { device->instance->functions->_gnDestroyOutputDevice(device); } diff --git a/src/core/output_device/gryphn_output_device.h b/src/core/output_device/gryphn_output_device.h index 32d25b6..a5873b3 100644 --- a/src/core/output_device/gryphn_output_device.h +++ b/src/core/output_device/gryphn_output_device.h @@ -26,6 +26,5 @@ typedef struct gnOutputDevice_t { } gnOutputDevice; gnReturnCode gnCreateOutputDevice(gnOutputDevice* outputDevice, gnInstance* instance, struct gnOutputDeviceInfo_t deviceInfo); +void gnWaitForDevice(gnOutputDevice* device); void gnDestroyOutputDevice(gnOutputDevice* device); - -// inline void (*gnWaitForDevice)(const gnOutputDevice& device);