Started using ev_log

Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
2025-07-07 16:44:22 +03:00
parent 3889bedbcd
commit f66f325faa
4 changed files with 19 additions and 16 deletions

View File

@@ -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(

View File

@@ -10,6 +10,8 @@
#define EV_VEC_SHORTNAMES
#include <ev_vec.h>
#include <ev_log.h>
#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)

View File

@@ -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));

15
main.c
View File

@@ -1,6 +1,7 @@
#include <evk/evk.h>
#include <ev_numeric.h>
#include <ev_helpers.h>
#include <ev_log.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
@@ -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);