Got the program to run and almost run without leaks
This commit is contained in:
parent
e59126b873
commit
fc9768f859
2 changed files with 19 additions and 15 deletions
|
|
@ -30,16 +30,16 @@ file(GLOB_RECURSE HEADER_FILES
|
||||||
${CMAKE_SOURCE_DIR}/src/*.h)
|
${CMAKE_SOURCE_DIR}/src/*.h)
|
||||||
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
|
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
|
||||||
|
|
||||||
## Error on memory address issues in debug mode
|
# Error on memory address issues in debug mode
|
||||||
#if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
# set(
|
set(
|
||||||
# CMAKE_C_FLAGS
|
CMAKE_C_FLAGS
|
||||||
# "${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address"
|
"${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address"
|
||||||
# )
|
)
|
||||||
# target_link_options(${PROJECT_NAME}
|
target_link_options(${PROJECT_NAME}
|
||||||
# BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address
|
BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address
|
||||||
# )
|
)
|
||||||
#endif()
|
endif()
|
||||||
|
|
||||||
# Link Libraries
|
# Link Libraries
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
|
|
||||||
14
src/main.c
14
src/main.c
|
|
@ -183,16 +183,17 @@ void createInstance(Application *app) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This currently leaks memory :(
|
||||||
VkResult result = vkCreateInstance(&createInfo, NULL, &app->instance);
|
VkResult result = vkCreateInstance(&createInfo, NULL, &app->instance);
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
fprintf(stderr, "Failed to create vulkan instance\n");
|
fprintf(stderr, "Failed to create vulkan instance\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Instance Extentions Available:\n");
|
//printf("Instance Extentions Available:\n");
|
||||||
for (uint i = 0; i < extensionCount; i++) {
|
//for (uint i = 0; i < extensionCount; i++) {
|
||||||
printf("\t%s\n", extensions[i].extensionName);
|
// printf("\t%s\n", extensions[i].extensionName);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initWindow(Application *app) {
|
void initWindow(Application *app) {
|
||||||
|
|
@ -334,7 +335,7 @@ SwapChainSupportDetails querySwapchainSupport(VkPhysicalDevice device,
|
||||||
&details.numPresentModes, NULL);
|
&details.numPresentModes, NULL);
|
||||||
if (details.numPresentModes > 0) {
|
if (details.numPresentModes > 0) {
|
||||||
details.presentModes =
|
details.presentModes =
|
||||||
malloc(details.numFormats * sizeof(VkPresentModeKHR));
|
malloc(details.numPresentModes * sizeof(VkPresentModeKHR));
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR(
|
vkGetPhysicalDeviceSurfacePresentModesKHR(
|
||||||
device, *surface, &details.numPresentModes, details.presentModes);
|
device, *surface, &details.numPresentModes, details.presentModes);
|
||||||
}
|
}
|
||||||
|
|
@ -578,6 +579,9 @@ void createSwapChain(Application *app) {
|
||||||
|
|
||||||
app->swapChainImageFormat = surfaceFormat.format;
|
app->swapChainImageFormat = surfaceFormat.format;
|
||||||
app->swapChainExtent = extent;
|
app->swapChainExtent = extent;
|
||||||
|
|
||||||
|
free(swapChainSupport.presentModes);
|
||||||
|
free(swapChainSupport.formats);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createImageViews(Application *app) {
|
void createImageViews(Application *app) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue