From f66f325faa37b5d0bba25ecc747d279ede6dcc8a Mon Sep 17 00:00:00 2001 From: Robear Selwans Date: Mon, 7 Jul 2025 16:44:22 +0300 Subject: [PATCH] Started using ev_log Signed-off-by: Robear Selwans --- evk/evkAllocator.c | 12 ++++++------ evk/evkCommon.h | 4 +++- evk/evkShader.c | 4 ++-- main.c | 15 ++++++++------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/evk/evkAllocator.c b/evk/evkAllocator.c index 6f99372..15fb4f9 100644 --- a/evk/evkAllocator.c +++ b/evk/evkAllocator.c @@ -8,11 +8,11 @@ // PFN_vkAllocationFunction void* evkAllocationFunctionCallback(void* pUserData, size_t allocationSize, size_t allocationAlignment, VkSystemAllocationScope allocationScope) { - /* puts("evkAllocationFunctionCallback"); */ + ev_log_trace("evkAllocationFunctionCallback"); // void* alloc = _aligned_malloc(allocationSize, allocationAlignment); // if(alloc == NULL) { - puts("Allocation Failed"); + ev_log_error("Allocation Failed"); } // return alloc; return NULL; @@ -21,7 +21,7 @@ void* evkAllocationFunctionCallback(void* pUserData, size_t allocationSize, size // PFN_vkReallocationFunction void* evkReallocationFunctionCallback(void* pUserData, void* pOriginal, size_t allocationSize, size_t allocationAlignment, VkSystemAllocationScope allocationScope) { - /* puts("evkReallocationFunctionCallback"); */ + ev_log_trace("evkReallocationFunctionCallback"); // return _aligned_realloc(pOriginal, allocationSize, allocationAlignment); return NULL; } @@ -29,20 +29,20 @@ void* evkReallocationFunctionCallback(void* pUserData, void* pOriginal, size_t a // PFN_vkFreeFucntion void evkFreeFunctionCallback(void* pUserData, void* pMemory) { - /* puts("evkFreeFunctionCallback"); */ + ev_log_trace("evkFreeFunctionCallback"); // _aligned_free(pMemory); } // PFN_vkInternalAllocaitonNotification void evkInternalAllocationCallback(void* pUserData, size_t allocationSize, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope) { - puts("evkInternalAllocationCallback"); + ev_log_trace("evkInternalAllocationCallback"); } // PFN_vkInternalFreeNotification void evkInternalFreeCallback(void* pUserData, size_t allocationSize, VkInternalAllocationType allocationType, VkSystemAllocationScope allocationScope) { - puts("evkInternalFreeCallback"); + ev_log_trace("evkInternalFreeCallback"); } TYPEDATA_GEN( diff --git a/evk/evkCommon.h b/evk/evkCommon.h index b22392b..45cdb7b 100644 --- a/evk/evkCommon.h +++ b/evk/evkCommon.h @@ -10,6 +10,8 @@ #define EV_VEC_SHORTNAMES #include +#include + #include "evkConstants.h" #include "evkTypes.h" @@ -89,6 +91,6 @@ static inline const char* VkResultStrings(VkResult res) { #define EVK_ASSERT(fn) do { \ VkResult __vk_assert_result_internal = fn; \ if(__vk_assert_result_internal != VK_SUCCESS) { \ - printf("[VulkanError] `%s` returned error code %d ('%s')\n", EV_STRINGIZE(fn), __vk_assert_result_internal, VkResultStrings(__vk_assert_result_internal));\ + ev_log_error("[VulkanError] `%s` returned error code %d ('%s')", EV_STRINGIZE(fn), __vk_assert_result_internal, VkResultStrings(__vk_assert_result_internal));\ } \ } while (0) diff --git a/evk/evkShader.c b/evk/evkShader.c index 18dcb6c..597a4f9 100644 --- a/evk/evkShader.c +++ b/evk/evkShader.c @@ -117,10 +117,10 @@ evkShader evkInitShaderFromFile(evkDevice device, evkShaderCompiler compiler, ev u32 errorCount = shaderc_result_get_num_errors(compilation_result); u32 warnCount = shaderc_result_get_num_warnings(compilation_result); - printf("[[evkShader]] %s Compilation Status: %d ( %d Errors, %d Warnings )\n", shaderPath, status, errorCount, warnCount); + ev_log_info("[[evkShader]] %s Compilation Status: %d ( %d Errors, %d Warnings )", shaderPath, status, errorCount, warnCount); if(errorCount + warnCount > 0) { - printf("Errors:\n%s\n", shaderc_result_get_error_message(compilation_result)); + ev_log_error("Errors:\n%s", shaderc_result_get_error_message(compilation_result)); } evkShader shader = evkInitShaderFromBytes(device, (u8*)shaderc_result_get_bytes(compilation_result), shaderc_result_get_length(compilation_result)); diff --git a/main.c b/main.c index e85c300..184d9c0 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,7 @@ #include #include #include +#include #define GLFW_INCLUDE_NONE #include @@ -30,10 +31,10 @@ int main(void) if(instance.vk == EV_INVALID(VkInstance)) { - puts("Instance creation failed."); + ev_log_error("Instance creation failed."); goto InstanceCreationFailed; } - puts("Instance was created successfully."); + ev_log_info("Instance was created successfully."); evkDevice device = evkCreateDevice((evkDeviceCreateInfo) { .instance = instance, @@ -58,17 +59,17 @@ int main(void) if(device.vk == EV_INVALID(VkDevice)) { - puts("Couldn't create a VkDevice"); + ev_log_error("Couldn't create a VkDevice"); goto DeviceCreationFailed; } + ev_log_info("Logical Device created successfully."); - puts("Logical Device created successfully."); VkQueue graphicsQueue; vkGetDeviceQueue(device.vk, device.queueFamilies[VK_QUEUE_GRAPHICS_BIT].familyIndex, 0, &graphicsQueue); if (!glfwInit()) { - puts("GLFW Initialization failed."); + ev_log_error("GLFW Initialization failed."); goto GLFWInitFailed; } @@ -76,7 +77,7 @@ int main(void) GLFWwindow* window = glfwCreateWindow(1024,1024, "evk", NULL, NULL); if(!window) { - puts("Window Creation Failed."); + ev_log_error("Window Creation Failed."); goto WindowCreationFailed; } @@ -84,8 +85,8 @@ int main(void) VkResult err = glfwCreateWindowSurface(instance.vk, window, NULL, &surface); if (err) { + ev_log_error("Surface creation failed."); goto VKSurfaceCreationFailed; - puts("Surface creation failed."); } evkGPUAllocator allocator = evkGPUCreateAllocator(device);