From adaee9eafc06c538787e56ff29950bf8d010bf65 Mon Sep 17 00:00:00 2001 From: Ben Kyd Date: Fri, 1 Dec 2023 20:37:43 +0000 Subject: [PATCH] PIPELINE ISSUE FIXED --- .vims | 23 +++++---- .vscode/settings.json | 77 ------------------------------ DAP Breakpoints | 1 + .vscode/launch.json => launch.json | 9 ++-- src/graphics/device.cpp | 23 +++++---- src/graphics/pipeline.cpp | 17 +++---- src/graphics/shader.cpp | 19 +++++--- 7 files changed, 51 insertions(+), 118 deletions(-) delete mode 100644 .vscode/settings.json create mode 100644 DAP Breakpoints rename .vscode/launch.json => launch.json (69%) diff --git a/.vims b/.vims index 398897b..285054a 100644 --- a/.vims +++ b/.vims @@ -43,7 +43,7 @@ badd +2 src/scene/scene.hpp badd +240 src/scene/camera.cpp badd +59 libhart/scene/camera.hpp badd +30 src/graphics.hpp -badd +70 src/gui/gui.hpp +badd +43 src/gui/gui.hpp badd +130 src/window.cpp badd +111 src/thirdparty/imgui/imgui_impl_vulkan.cpp badd +66 ~/dprog/active/inferno-hart/src/thirdparty/imgui/imgui_impl_vulkan.h @@ -75,9 +75,9 @@ set winminwidth=0 set winwidth=1 exe 'vert 1resize ' . ((&columns * 91 + 191) / 383) exe 'vert 2resize ' . ((&columns * 173 + 191) / 383) -exe '3resize ' . ((&lines * 20 + 33) / 67) +exe '3resize ' . ((&lines * 24 + 39) / 79) exe 'vert 3resize ' . ((&columns * 117 + 191) / 383) -exe '4resize ' . ((&lines * 43 + 33) / 67) +exe '4resize ' . ((&lines * 51 + 39) / 79) exe 'vert 4resize ' . ((&columns * 117 + 191) / 383) argglobal balt src/window.cpp @@ -91,12 +91,12 @@ setlocal fdn=20 setlocal fen silent! normal! zE let &fdl = &fdl -let s:l = 81 - ((61 * winheight(0) + 32) / 64) +let s:l = 5 - ((4 * winheight(0) + 38) / 76) if s:l < 1 | let s:l = 1 | endif keepjumps exe s:l normal! zt -keepjumps 81 -normal! 0 +keepjumps 5 +normal! 030| wincmd w argglobal if bufexists(fnamemodify("src/graphics/pipeline.cpp", ":p")) | buffer src/graphics/pipeline.cpp | else | edit src/graphics/pipeline.cpp | endif @@ -114,7 +114,7 @@ setlocal fdn=20 setlocal fen silent! normal! zE let &fdl = &fdl -let s:l = 34 - ((33 * winheight(0) + 32) / 64) +let s:l = 34 - ((33 * winheight(0) + 38) / 76) if s:l < 1 | let s:l = 1 | endif keepjumps exe s:l normal! zt @@ -137,7 +137,7 @@ setlocal fdn=20 setlocal fen silent! normal! zE let &fdl = &fdl -let s:l = 53 - ((17 * winheight(0) + 10) / 20) +let s:l = 53 - ((20 * winheight(0) + 12) / 24) if s:l < 1 | let s:l = 1 | endif keepjumps exe s:l normal! zt @@ -160,19 +160,18 @@ setlocal fdn=20 setlocal fen silent! normal! zE let &fdl = &fdl -let s:l = 18 - ((17 * winheight(0) + 21) / 43) +let s:l = 18 - ((17 * winheight(0) + 25) / 51) if s:l < 1 | let s:l = 1 | endif keepjumps exe s:l normal! zt keepjumps 18 normal! 047| wincmd w -2wincmd w exe 'vert 1resize ' . ((&columns * 91 + 191) / 383) exe 'vert 2resize ' . ((&columns * 173 + 191) / 383) -exe '3resize ' . ((&lines * 20 + 33) / 67) +exe '3resize ' . ((&lines * 24 + 39) / 79) exe 'vert 3resize ' . ((&columns * 117 + 191) / 383) -exe '4resize ' . ((&lines * 43 + 33) / 67) +exe '4resize ' . ((&lines * 51 + 39) / 79) exe 'vert 4resize ' . ((&columns * 117 + 191) / 383) tabnext 1 if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal' diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 34c4b6f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "files.associations": { - "string": "cpp", - "vector": "cpp", - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "compare": "cpp", - "concepts": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "forward_list": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "numbers": "cpp", - "ostream": "cpp", - "semaphore": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "stop_token": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "cfenv": "cpp", - "cinttypes": "cpp", - "typeindex": "cpp", - "typeinfo": "cpp", - "valarray": "cpp", - "variant": "cpp", - "complex": "cpp", - "hash_map": "cpp", - "filesystem": "cpp" - }, - "cmake.configureOnOpen": false -} \ No newline at end of file diff --git a/DAP Breakpoints b/DAP Breakpoints new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/DAP Breakpoints @@ -0,0 +1 @@ + diff --git a/.vscode/launch.json b/launch.json similarity index 69% rename from .vscode/launch.json rename to launch.json index 8b9c9b0..7c3cc44 100644 --- a/.vscode/launch.json +++ b/launch.json @@ -1,7 +1,4 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { @@ -19,9 +16,9 @@ "setupCommands": [ { "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", + "text": "-enable-pretty-printing" } - ], + ] } ] -} \ No newline at end of file +} diff --git a/src/graphics/device.cpp b/src/graphics/device.cpp index b2f3b47..087e0b8 100644 --- a/src/graphics/device.cpp +++ b/src/graphics/device.cpp @@ -56,6 +56,7 @@ void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& create createInfo.pfnUserCallback = debugCallback; } +#ifdef VALIDATION_LAYERS_ENABLED bool checkValidationLayerSupport() { uint32_t layerCount; @@ -81,6 +82,7 @@ bool checkValidationLayerSupport() return true; } +#endif std::vector getRequiredExtensions() { @@ -91,10 +93,10 @@ std::vector getRequiredExtensions() std::vector extensions( glfwExtensions, glfwExtensions + glfwExtensionCount); - if constexpr (VALIDATION_LAYERS_ENABLED) { +#ifdef VALIDATION_LAYERS_ENABLED yolo::info("Validation layers enabled"); extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); - } +#endif yolo::info("Requested instance extensions:"); for (const auto& extension : extensions) { @@ -213,20 +215,22 @@ void device_cleanup(GraphicsDevice* device) { vkDestroyDevice(device->VulkanDevice, nullptr); - if constexpr (VALIDATION_LAYERS_ENABLED) { + #ifdef VALIDATION_LAYERS_ENABLED destroyDebugUtilsMessengerEXT( device->VulkanInstance, device->VulkanDebugMessenger, nullptr); - } - + #endif vkDestroySurfaceKHR(device->VulkanInstance, device->VulkanSurface, nullptr); vkDestroyInstance(device->VulkanInstance, nullptr); } void device_create_vulkan_instance(GraphicsDevice* device) { - if (VALIDATION_LAYERS_ENABLED && !checkValidationLayerSupport()) { + + #ifdef VALIDATION_LAYERS_ENABLED + if (!checkValidationLayerSupport()) { yolo::error("validation layers requested, but not available!"); } + #endif VkApplicationInfo appInfo {}; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; @@ -265,10 +269,10 @@ void device_create_vulkan_instance(GraphicsDevice* device) void device_vulkan_debugger(GraphicsDevice* device) { - if constexpr (!VALIDATION_LAYERS_ENABLED) { + #ifndef VALIDATION_LAYERS_ENABLED yolo::warn("Validation layers disabled"); return; - } +#endif VkDebugUtilsMessengerCreateInfoEXT createInfo; populateDebugMessengerCreateInfo(createInfo); @@ -361,7 +365,8 @@ void device_create_vulkan_logical_device(GraphicsDevice* device) #ifdef VALIDATION_LAYERS_ENABLED createInfo.enabledLayerCount = static_cast(VALIDATION_LAYERS.size()); createInfo.ppEnabledLayerNames = VALIDATION_LAYERS.data(); -#elif +#endif +#ifndef VALIDATION_LAYERS_ENABLED createInfo.enabledLayerCount = 0; #endif diff --git a/src/graphics/pipeline.cpp b/src/graphics/pipeline.cpp index a1433e1..464cb73 100644 --- a/src/graphics/pipeline.cpp +++ b/src/graphics/pipeline.cpp @@ -44,6 +44,7 @@ Pipeline* pipeline_create(GraphicsDevice* device, SwapChain* swap, Shader* shade scene::get_vert_attribute_descriptions()); VkPipelineVertexInputStateCreateInfo vertexInputInfo {}; + vertexInputInfo.pNext = nullptr; vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertexInputInfo.vertexBindingDescriptionCount = 1; vertexInputInfo.vertexAttributeDescriptionCount @@ -80,14 +81,14 @@ Pipeline* pipeline_create(GraphicsDevice* device, SwapChain* swap, Shader* shade colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; // Alpha blending basically - colorBlendAttachment.blendEnable = VK_FALSE; - // colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; - // colorBlendAttachment.dstColorBlendFactor - // = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - // colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; - // colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; - // colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; - // colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD; + colorBlendAttachment.blendEnable = VK_TRUE; + colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; + colorBlendAttachment.dstColorBlendFactor + = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; + colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD; VkPipelineColorBlendStateCreateInfo colorBlending {}; colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; diff --git a/src/graphics/shader.cpp b/src/graphics/shader.cpp index fe1ce57..4ca3640 100644 --- a/src/graphics/shader.cpp +++ b/src/graphics/shader.cpp @@ -55,7 +55,7 @@ void shader_load(Shader* shader, std::filesystem::path path) VkShaderModuleCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; createInfo.codeSize = vertexLoadedShaderCode.size(); - createInfo.pCode = reinterpret_cast(vertexLoadedShaderCode.data()); + createInfo.pCode = (uint32_t*)(vertexLoadedShaderCode.data()); if (vkCreateShaderModule( shader->Device->VulkanDevice, &createInfo, nullptr, &shader->VertexShader) @@ -63,17 +63,22 @@ void shader_load(Shader* shader, std::filesystem::path path) yolo::error("failed to create shader module"); } + memset(&shader->ShaderStages, 0, + SHADER_STAGES * sizeof(VkPipelineShaderStageCreateInfo)); + shader->ShaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shader->ShaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; shader->ShaderStages[0].module = shader->VertexShader; shader->ShaderStages[0].pName = "main"; - VkShaderModuleCreateInfo createInfo2 = {}; + shader->ShaderStages[0].pSpecializationInfo = nullptr; // Optional + shader->ShaderStages[0].flags = 0; // Optional + shader->ShaderStages[0].pNext = nullptr; // Optional std::string fragmentLoadedShaderCode = textFromFile(fragmentShaderPath); + VkShaderModuleCreateInfo createInfo2 = {}; createInfo2.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; createInfo2.codeSize = fragmentLoadedShaderCode.size(); - createInfo2.pCode - = reinterpret_cast(fragmentLoadedShaderCode.data()); + createInfo2.pCode = (uint32_t*)(fragmentLoadedShaderCode.data()); if (vkCreateShaderModule( shader->Device->VulkanDevice, &createInfo2, nullptr, &shader->FragmentShader) @@ -85,6 +90,9 @@ void shader_load(Shader* shader, std::filesystem::path path) shader->ShaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; shader->ShaderStages[1].module = shader->FragmentShader; shader->ShaderStages[1].pName = "main"; + shader->ShaderStages[0].pSpecializationInfo = nullptr; // Optional + shader->ShaderStages[0].flags = 0; // Optional + shader->ShaderStages[0].pNext = nullptr; // Optional } void shader_update_state(Shader* shader, VkCommandBuffer commandBuffer, @@ -165,9 +173,8 @@ void shader_build(Shader* shader) yolo::error("failed to allocate descriptor sets!"); } - shader->GraphicsPipeline = pipeline_create(shader->Device, shader->GraphicsSwapchain, - shader, layouts.size(), layouts.data()); + shader, layouts.size(), layouts.data()); shader->GlobalUniformBuffer = uniform_buffer_create(shader->Device, true); }