diff --git a/.idea/QtSettings.xml b/.idea/QtSettings.xml index a5b87f0..78911ca 100644 --- a/.idea/QtSettings.xml +++ b/.idea/QtSettings.xml @@ -7,16 +7,8 @@ - - - - - - - diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 784fca1..a10d569 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -5,24 +5,20 @@ pkg_check_modules(GLFW REQUIRED IMPORTED_TARGET glfw3) pkg_check_modules(ASSIMP REQUIRED IMPORTED_TARGET assimp) pkg_check_modules(SPDLOG REQUIRED IMPORTED_TARGET spdlog) -find_path(FreeImage_INCLUDE_DIR FreeImage.h HINTS ${FreeImage_ROOT}) -find_library(FreeImage_LIBRARY NAMES FreeImage HINTS ${FreeImage_ROOT}) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FreeImage DEFAULT_MSG FreeImage_INCLUDE_DIR FreeImage_LIBRARY) - -set(HEADERS Window.h ShaderModule.h ShaderProgram.h Monitor.h Buffer.h Mesh.h Util.h Renderer.h Vixen.h Framebuffer.h RenderPass.h Material.h Entity.h - Camera.h) -set(SOURCES Window.cpp Buffer.cpp Blending.h - Camera.cpp) +set( + SOURCES + Window.cpp + Buffer.cpp + Camera.cpp +) link_libraries( PkgConfig::GLM PkgConfig::GLFW PkgConfig::ASSIMP PkgConfig::SPDLOG - FreeImage ) -add_library(Vixen SHARED ${SOURCES} ${HEADERS}) +add_library(Vixen SHARED ${SOURCES}) if (ENABLE_VULKAN) add_subdirectory(vk) diff --git a/engine/vk/CMakeLists.txt b/engine/vk/CMakeLists.txt index bea89bd..eac0622 100644 --- a/engine/vk/CMakeLists.txt +++ b/engine/vk/CMakeLists.txt @@ -1,12 +1,8 @@ project("Vixen Engine Vk") find_package(Vulkan 1.3 REQUIRED) -find_package(spirv_cross_core CONFIG REQUIRED) -find_package(spirv_cross_glsl CONFIG REQUIRED) -find_package(spirv_cross_reflect CONFIG REQUIRED) -find_package(spirv_cross_cpp CONFIG REQUIRED) -find_package(glslang CONFIG REQUIRED) -#pkg_check_modules(glslang REQUIRED IMPORTED_TARGET glslang) + +find_package(spirv_cross_reflect REQUIRED) FetchContent_Declare( vma @@ -65,17 +61,6 @@ target_link_libraries( Vulkan::Headers volk GPUOpen::VulkanMemoryAllocator -# glslang::OSDependent - glslang::glslang -# glslang::MachineIndependent -# glslang::GenericCodeGen -# glslang::OGLCompiler -# glslang::glslangValidator -# glslang::spirv-remap - glslang::glslang-default-resource-limits -# glslang::SPVRemapper - glslang::SPIRV -# glslang::HLSL spirv-cross-core spirv-cross-glsl spirv-cross-reflect @@ -84,6 +69,33 @@ target_link_libraries( target_compile_definitions(VkVixen PUBLIC -DVK_NO_PROTOTYPES) +find_package(glslang QUIET) +if (${glslang_FOUND}) + target_link_libraries( + VKVixen + PUBLIC + # glslang::OSDependent + glslang::glslang + # glslang::MachineIndependent + # glslang::GenericCodeGen + # glslang::OGLCompiler + # glslang::glslangValidator + # glslang::spirv-remap + glslang::glslang-default-resource-limits + # glslang::SPVRemapper + glslang::SPIRV + # glslang::HLSL + ) +else () + pkg_check_modules(glslang REQUIRED IMPORTED_TARGET glslang) + target_link_libraries( + VkVixen + PUBLIC + PkgConfig::glslang + PkgConfig::SPIRV + ) +endif () + if (ENABLE_TESTS) add_executable(vktest test/main.cpp) target_link_libraries(vktest PUBLIC Vixen VkVixen) diff --git a/engine/vk/Instance.cpp b/engine/vk/Instance.cpp index 5e92c07..2c0637a 100644 --- a/engine/vk/Instance.cpp +++ b/engine/vk/Instance.cpp @@ -17,7 +17,7 @@ namespace Vixen::Vk { appInfo.apiVersion = VK_API_VERSION_1_3; std::vector extensions(requiredExtensions); - extensions.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME); +// extensions.emplace_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME); std::vector layers{}; #ifdef DEBUG @@ -36,7 +36,7 @@ namespace Vixen::Vk { instanceInfo.ppEnabledExtensionNames = extensions.data(); instanceInfo.enabledLayerCount = layers.size(); instanceInfo.ppEnabledLayerNames = layers.data(); - instanceInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR; +// instanceInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR; spdlog::info( "Creating new Vulkan instance for app \"{} ({})\" with extensions [{}] and layers [{}]", @@ -61,8 +61,8 @@ namespace Vixen::Vk { VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT; debugInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | - VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT | - VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT; + VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; +// VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT; debugInfo.pfnUserCallback = vkDebugCallback; vkCreateDebugUtilsMessengerEXT(instance, &debugInfo, nullptr, &debugMessenger); diff --git a/engine/vk/VkShaderModule.h b/engine/vk/VkShaderModule.h index f2b1ff8..6536a82 100644 --- a/engine/vk/VkShaderModule.h +++ b/engine/vk/VkShaderModule.h @@ -7,12 +7,13 @@ #endif #include -#include +#include #include #include #include #include #include +#include #include "../ShaderModule.h" #include "Vulkan.h" #include "Device.h" @@ -123,12 +124,6 @@ namespace Vixen::Vk { case glslang::EbtRayQuery: size = 0; break; - case glslang::EbtHitObjectNV: - size = 0; - break; - case glslang::EbtCoopmat: - size = 0; - break; case glslang::EbtSpirvType: size = 0; break; @@ -138,6 +133,9 @@ namespace Vixen::Vk { case glslang::EbtNumTypes: size = 0; break; + default: + size = 0; + break; } if (type->isVector()) @@ -195,9 +193,6 @@ namespace Vixen::Vk { shader.setEnvInput(glslang::EShSourceGlsl, s, glslang::EShClientVulkan, VIXEN_VK_SPIRV_VERSION); shader.setEnvClient(glslang::EShClientVulkan, glslang::EShTargetVulkan_1_3); shader.setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_6); -#ifdef DEBUG - shader.setDebugInfo(true); -#endif shader.setAutoMapLocations(true); shader.setEntryPoint(entrypoint.c_str()); @@ -206,29 +201,30 @@ namespace Vixen::Vk { auto messages = (EShMessages) (EShMsgSpvRules | EShMsgVulkanRules); glslang::TShader::ForbidIncluder includer; - if (!shader.parse(GetDefaultResources(), VIXEN_VK_SPIRV_VERSION, false, messages)) + const auto &limits = TBuiltInResource(); + if (!shader.parse(&limits, VIXEN_VK_SPIRV_VERSION, false, messages)) error("Failed to parse shader; {}", shader.getInfoLog()); program.addShader(&shader); if (!program.link(messages)) error("Failed to link shader program; {}", shader.getInfoLog()); - glslang::SpvOptions options{ + glslang::SpvOptions options; + #ifdef DEBUG - .generateDebugInfo = true, - .stripDebugInfo = false, - .disableOptimizer = true, - .optimizeSize = false, - .disassemble = true, + options.generateDebugInfo = true; + options.stripDebugInfo = false; + options.disableOptimizer = true; + options.optimizeSize = false; + options.disassemble = true; #else - .generateDebugInfo = false, - .stripDebugInfo = true, - .disableOptimizer = false, - .optimizeSize = true, - .disassemble = false, + options.generateDebugInfo = false; + options.stripDebugInfo = true; + options.disableOptimizer = false; + options.optimizeSize = true; + options.disassemble = false; #endif - .validate = true, - }; + options.validate = true; spv::SpvBuildLogger logger; glslang::GlslangToSpv(*program.getIntermediate(s), binary, &logger, &options); @@ -248,13 +244,12 @@ namespace Vixen::Vk { uint32_t location = c.get_decoration(uniformBuffer.id, spv::DecorationLocation); - uniformBuffers.push_back({ - .binding = binding, - .location = location, - .size = 0, - .offset = 0, - }); + .binding = binding, + .location = location, + .size = 0, + .offset = 0, + }); } if (!logger.getAllMessages().empty()) diff --git a/engine/vk/VkShaderProgram.h b/engine/vk/VkShaderProgram.h index 44a6cbb..54e89a8 100644 --- a/engine/vk/VkShaderProgram.h +++ b/engine/vk/VkShaderProgram.h @@ -6,7 +6,6 @@ #include #include #include -#include #include #include "../ShaderProgram.h" #include "VkShaderModule.h" diff --git a/engine/vk/test/main.cpp b/engine/vk/test/main.cpp index 74f8d53..ea17185 100644 --- a/engine/vk/test/main.cpp +++ b/engine/vk/test/main.cpp @@ -71,8 +71,8 @@ int main() { auto buffer = Vixen::Vk::VkBuffer::stage( vixen.device, - Vixen::Vk::Buffer::Usage::VERTEX | - Vixen::Vk::Buffer::Usage::INDEX, + Vixen::Buffer::Usage::VERTEX | + Vixen::Buffer::Usage::INDEX, vertices.size() * sizeof(Vertex) + indices.size() * sizeof(uint32_t), [&vertices, &indices](auto data) {