├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── Readme.md ├── application ├── CMakeLists.txt ├── SpvCompiler.cpp ├── SpvCompiler.h ├── VApp.cpp └── VApp.h ├── cmake ├── attach_fg.cmake ├── compilers.cmake ├── download_spirvcross.cmake └── find_devenv.cmake ├── converter ├── CMakeLists.txt ├── Common.h ├── Generated │ ├── BuildRawVulkanCalls.h │ ├── IVulkanListener.h │ ├── ParseChunk.h │ ├── ParseChunkImpl.h │ ├── ParseChunkMap.h │ ├── ParseValue.h │ ├── ParseValueImpl.h │ ├── VkEnumToString.h │ ├── VkEnumToStringImpl.h │ ├── VkStructToString.h │ └── VkStructToStringImpl.h ├── RdCaptureReader.cpp ├── RdCaptureReader.h ├── Utils │ ├── BasicTypesConverter.h │ ├── NameSerializer.cpp │ └── NameSerializer.h ├── Vulkan │ ├── ResRemapper.cpp │ ├── ResRemapper.h │ ├── VulkanConverter.cpp │ ├── VulkanConverter.h │ └── VulkanFnToCpp.h └── main.cpp ├── external ├── CMakeLists.txt ├── FrameGraph │ ├── .gitignore │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── cmake │ │ ├── compiler_tests.cmake │ │ ├── compilers.cmake │ │ ├── download_glfw.cmake │ │ ├── download_glslang.cmake │ │ ├── download_sdl2.cmake │ │ ├── download_stdoptional.cmake │ │ ├── download_stdstringview.cmake │ │ ├── download_stdvariant.cmake │ │ ├── download_vk.cmake │ │ ├── download_vma.cmake │ │ ├── main.cpp │ │ └── project_template.cmake │ ├── extensions │ │ ├── framework │ │ │ ├── CMakeLists.txt │ │ │ ├── Vulkan │ │ │ │ ├── VulkanDevice.cpp │ │ │ │ ├── VulkanDevice.h │ │ │ │ ├── VulkanDeviceExt.cpp │ │ │ │ ├── VulkanDeviceExt.h │ │ │ │ ├── VulkanSurface.cpp │ │ │ │ ├── VulkanSurface.h │ │ │ │ ├── VulkanSwapchain.cpp │ │ │ │ └── VulkanSwapchain.h │ │ │ └── Window │ │ │ │ ├── IWindow.h │ │ │ │ ├── WindowGLFW.cpp │ │ │ │ ├── WindowGLFW.h │ │ │ │ ├── WindowSDL2.cpp │ │ │ │ ├── WindowSDL2.h │ │ │ │ ├── WindowSFML.cpp │ │ │ │ └── WindowSFML.h │ │ └── vulkan_loader │ │ │ ├── CMakeLists.txt │ │ │ ├── VulkanCheckError.cpp │ │ │ ├── VulkanCheckError.h │ │ │ ├── VulkanLoader.cpp │ │ │ ├── VulkanLoader.h │ │ │ ├── fn_vulkan_dev.h │ │ │ ├── fn_vulkan_inst.h │ │ │ └── fn_vulkan_lib.h │ ├── external │ │ └── CMakeLists.txt │ └── stl │ │ ├── Algorithms │ │ ├── ArrayUtils.h │ │ ├── Cast.h │ │ ├── EnumUtils.h │ │ ├── Hash.h │ │ ├── StringParser.cpp │ │ ├── StringParser.h │ │ └── StringUtils.h │ │ ├── CMakeLists.txt │ │ ├── Common.h │ │ ├── CompileTime │ │ ├── DefaultType.h │ │ ├── Hash.h │ │ ├── Math.h │ │ ├── TypeList.h │ │ ├── TypeTraits.h │ │ └── UMax.h │ │ ├── Config.h │ │ ├── Containers │ │ ├── ArrayView.h │ │ ├── FixedArray.h │ │ ├── FixedMap.h │ │ ├── Iterators.h │ │ ├── NtStringView.h │ │ ├── Optional.h │ │ ├── Ptr.h │ │ ├── Singleton.h │ │ ├── StaticString.h │ │ ├── StringView.h │ │ ├── StringViewFwd.h │ │ ├── StructView.h │ │ └── Union.h │ │ ├── Defines.h │ │ ├── Log │ │ ├── Log.cpp │ │ └── Log.h │ │ ├── Math │ │ ├── BitMath.h │ │ ├── Bytes.h │ │ ├── Color.h │ │ ├── Math.h │ │ └── Vec.h │ │ ├── Memory │ │ ├── LinearAllocator.h │ │ ├── MemUtils.h │ │ └── UntypedAllocator.h │ │ ├── Platforms │ │ └── WindowsHeader.h │ │ └── Stream │ │ ├── FileStream.cpp │ │ ├── FileStream.h │ │ ├── Stream.cpp │ │ └── Stream.h ├── RenderDoc │ ├── LICENSE.md │ ├── vk_common.h │ └── vk_resources.h ├── miniz │ ├── CMakeLists.txt │ ├── LICENSE │ ├── miniz.c │ ├── miniz.h │ ├── miniz_common.h │ ├── miniz_tdef.c │ ├── miniz_tdef.h │ ├── miniz_tinfl.c │ ├── miniz_tinfl.h │ ├── miniz_zip.c │ ├── miniz_zip.h │ └── readme.md └── rapidxml │ ├── license.txt │ ├── manual.html │ ├── rapidxml.hpp │ ├── rapidxml_iterators.hpp │ ├── rapidxml_print.hpp │ └── rapidxml_utils.hpp ├── generator ├── CMakeLists.txt ├── GenChunkParser.cpp ├── GenEnumToString.cpp ├── GenFormatHelpers.cpp ├── GenListenerInterface.cpp ├── GenRawVulkanCalls.cpp ├── GenStructToString.cpp ├── GenStructTypeHelpers.cpp ├── Generator.cpp ├── Generator.h ├── HeaderParser.cpp ├── MarkRequiredTypes.cpp ├── StringParser.cpp └── StringParser.h └── tests └── application ├── CMakeLists.txt └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /external/SPIRV-Cross 3 | /_output 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | 4 | # Windows MSVC x64 5 | - os: windows 6 | name: Win64 VC2017 7 | language: cpp 8 | before_install: 9 | - choco install python2 10 | - export PATH="/c/Python27:/c/Python27/Scripts:$PATH" 11 | script: 12 | - mkdir -p build 13 | - cd build 14 | - cmake -G "Visual Studio 15 2017 Win64" -T v141 .. 15 | - cmake --build . --config Release 16 | 17 | # Windows MSVC x64 Debug 18 | - os: windows 19 | name: Win64 VC2017 Debug 20 | language: cpp 21 | before_install: 22 | - choco install python2 23 | - export PATH="/c/Python27:/c/Python27/Scripts:$PATH" 24 | script: 25 | - mkdir -p build 26 | - cd build 27 | - cmake -G "Visual Studio 15 2017 Win64" -T v141 .. 28 | - cmake --build . --config Debug 29 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10.0 ) 2 | 3 | message( STATUS "==========================================================================\n" ) 4 | message( STATUS "project 'RDCtoVkCpp' generation started" ) 5 | 6 | project( "RDCtoVkCpp" LANGUAGES C CXX ) 7 | set_property( GLOBAL PROPERTY USE_FOLDERS ON ) 8 | message( STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION})" ) 9 | message( STATUS "Compiler name: ${DETECTED_COMPILER}" ) 10 | message( STATUS "target system: ${CMAKE_SYSTEM_NAME} (${CMAKE_SYSTEM_VERSION})" ) 11 | message( STATUS "host system: ${CMAKE_HOST_SYSTEM_NAME} (${CMAKE_HOST_SYSTEM_VERSION})" ) 12 | 13 | set( RDE_ENABLE_SPIRVCROSS ON CACHE BOOL "" ) 14 | set( RDE_ENABLE_SPIRVREFLECT OFF CACHE BOOL "" ) 15 | 16 | include( "cmake/compilers.cmake" ) 17 | add_subdirectory( "external" "external" ) 18 | add_subdirectory( "generator" ) 19 | add_subdirectory( "converter" ) 20 | add_subdirectory( "application" ) 21 | add_subdirectory( "tests/application" ) 22 | 23 | message( STATUS "project 'RDCtoVkCpp' generation ended" ) 24 | message( STATUS "\n==========================================================================" ) 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2020 Zhirnov Andrey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://img.shields.io/travis/azhirnov/RDCtoVkCpp/master.svg?logo=travis)](https://travis-ci.com/azhirnov/RDCtoVkCpp) 2 | 3 | Converts RenderDoc Vulkan capture to compilable and executable C++ code.
4 | Work in progress. 5 | 6 | 7 | ## How to use 8 | 1. Export RenderDoc capture to XML + ZIP. 9 | 2. Build RDCtoVkCpp or use prebuild binaries. 10 | 3. Run console application `RdConverter.exe` with ```-i path/to/exported/rdc.zip -o folder/name/for/cpp/code``` 11 | 12 | Other command line arguments: 13 | ``` 14 | -h, --help - show help 15 | --build - build project 16 | --configure - generate project 17 | --clean - clean output folder before converting 18 | --div-by-cmdbuf [bool] - group api calls by command buffers, default = true 19 | -i, --input [filename] - open RenderDoc capture, must be *.zip or *.zip.xml file 20 | -o, --output [folder] - save c++ code into output directory 21 | ``` 22 | Warning: console application and converted sources from capture is not portable! 23 | You should rebuild and run converter again on new environment or fix pathes to files. 24 | 25 | 26 | ## Features 27 | * Produces readable C++ code. 28 | * Code validation to fix unsignaled fences/semaphores/events and reset they before next frame. 29 | * Frame played in infinite loop. 30 | * Used resource debug name if possible. 31 | * SPIR-V decompiled to GLSL. 32 | * Resizable window. 33 | 34 | 35 | ## Tested on 36 | * [x] Doom (2016) 37 | * [ ] Wolfenstein 2 - incorrect rendering 38 | * [ ] X4 - incorrect rendering 39 | * [x] Dota 2 40 | * [ ] Rage 2 - incorrect rendering 41 | * [ ] RDR 2 - incorrect rendering 42 | * [ ] 3DMark api overhead test 43 | * [ ] No Man's Sky 44 | 45 | 46 | ## TODO 47 | * Immutable samplers 48 | * Measure frame time 49 | * Portability (remap queue family and memory types) 50 | * Upload multisampled image 51 | * Sparse memory 52 | * 2nd plane formats 53 | * Fix validation errors. 54 | 55 | 56 | ## Building 57 | Requires C++17 and CMake 3.10+ 58 | 59 | Dependencies:
60 | [FrameGraph](https://github.com/azhirnov/FrameGraph) - only stl and vulkan helpers.
61 | [VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) - required.
62 | [glfw](https://github.com/glfw/glfw) or [SDL2](https://www.libsdl.org) - required.
63 | [glslang](https://github.com/KhronosGroup/glslang) - compile glsl to spirv.
64 | [SPIRV-Cross](https://github.com/KhronosGroup/SPIRV-Cross) - converts spirv to glsl.
65 | [rapidxml](https://github.com/dwd/rapidxml) - for RDC parsing.
66 | [miniz](https://github.com/richgel999/miniz) - for RDC content loading.
67 | [RenderDoc](https://github.com/baldurk/renderdoc) - some code to generate parser.
68 | -------------------------------------------------------------------------------- /application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | file( GLOB_RECURSE SOURCES "*.*" ) 4 | add_library( "Application" STATIC ${SOURCES} ) 5 | source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ) 6 | 7 | target_link_libraries( "Application" PUBLIC "GLSLang-lib" ) 8 | target_link_libraries( "Application" PRIVATE "VMA-lib" ) 9 | target_link_libraries( "Application" PRIVATE "MiniZ" ) 10 | target_link_libraries( "Application" PUBLIC "STL" "VulkanLoader" "Framework" ) 11 | target_include_directories( "Application" PRIVATE "../external/RenderDoc" ) 12 | target_include_directories( "Application" PUBLIC "." ) 13 | -------------------------------------------------------------------------------- /application/SpvCompiler.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "SpvCompiler.h" 4 | #include "stl/Algorithms/StringUtils.h" 5 | 6 | // glslang includes 7 | #include "glslang/Include/revision.h" 8 | #include "glslang/MachineIndependent/localintermediate.h" 9 | #include "glslang/Include/intermediate.h" 10 | #include "SPIRV/doc.h" 11 | #include "SPIRV/disassemble.h" 12 | #include "SPIRV/GlslangToSpv.h" 13 | #include "SPIRV/GLSL.std.450.h" 14 | #include "StandAlone/ResourceLimits.cpp" 15 | 16 | using namespace glslang; 17 | 18 | namespace AppDetail 19 | { 20 | 21 | SpvCompiler::SpvCompiler () 22 | { 23 | glslang::InitializeProcess(); 24 | } 25 | 26 | SpvCompiler::~SpvCompiler () 27 | { 28 | glslang::FinalizeProcess(); 29 | } 30 | 31 | bool SpvCompiler::Compile (OUT Array& spirvData, 32 | const char * source, 33 | EShLanguage shaderType, 34 | EShTargetLanguageVersion spvVersion) const 35 | { 36 | EShMessages messages = EShMsgDefault; 37 | TProgram program; 38 | TShader shader { shaderType }; 39 | EshTargetClientVersion client_version = EShTargetVulkan_1_1; 40 | TBuiltInResource builtin_res = DefaultTBuiltInResource; 41 | char const* shader_src[] = { source }; 42 | 43 | shader.setStrings( shader_src, int(CountOf(shader_src)) ); 44 | shader.setEntryPoint( "main" ); 45 | shader.setEnvInput( EShSourceGlsl, shaderType, EShClientVulkan, 110 ); 46 | shader.setEnvClient( EShClientVulkan, client_version ); 47 | shader.setEnvTarget( EshTargetSpv, spvVersion ); 48 | 49 | shader.setAutoMapLocations( false ); 50 | shader.setAutoMapBindings( false ); 51 | 52 | if ( not shader.parse( &builtin_res, 460, ECoreProfile, false, true, messages ) ) 53 | { 54 | FG_LOGI( shader.getInfoLog() ); 55 | return false; 56 | } 57 | 58 | program.addShader( &shader ); 59 | 60 | if ( not program.link( messages ) ) 61 | { 62 | FG_LOGI( program.getInfoLog() ); 63 | return false; 64 | } 65 | 66 | const TIntermediate* intermediate = program.getIntermediate( shader.getStage() ); 67 | if ( not intermediate ) 68 | return false; 69 | 70 | SpvOptions spv_options; 71 | spv::SpvBuildLogger logger; 72 | 73 | spv_options.generateDebugInfo = true; 74 | spv_options.disableOptimizer = true; 75 | spv_options.optimizeSize = false; 76 | 77 | spirvData.clear(); 78 | GlslangToSpv( *intermediate, OUT spirvData, &logger, &spv_options ); 79 | 80 | if ( spirvData.empty() ) 81 | return false; 82 | 83 | return true; 84 | } 85 | 86 | } // AppDetail 87 | -------------------------------------------------------------------------------- /application/SpvCompiler.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "framework/Vulkan/VulkanDevice.h" 6 | #include "stl/Algorithms/ArrayUtils.h" 7 | 8 | // glslang includes 9 | #include "glslang/Public/ShaderLang.h" 10 | 11 | namespace AppDetail 12 | { 13 | using namespace FGC; 14 | 15 | 16 | class SpvCompiler 17 | { 18 | public: 19 | SpvCompiler (); 20 | ~SpvCompiler (); 21 | 22 | bool Compile (OUT Array& spirvData, 23 | const char * source, 24 | EShLanguage shaderType, 25 | glslang::EShTargetLanguageVersion spvVersion = glslang::EShTargetSpv_1_3) const; 26 | }; 27 | 28 | } // AppDetail 29 | -------------------------------------------------------------------------------- /cmake/attach_fg.cmake: -------------------------------------------------------------------------------- 1 | # find and attach FrameGraph 2 | 3 | set( RDE_FRAMEGRAPH_PATH "${RDE_EXTERNALS_PATH}/FrameGraph" CACHE PATH "Path to FrameGraph library" ) 4 | message( STATUS "RDE_FRAMEGRAPH_PATH: ${RDE_FRAMEGRAPH_PATH}" ) 5 | 6 | if (NOT EXISTS "${RDE_FRAMEGRAPH_PATH}/CMakeLists.txt") 7 | message( FATAL_ERROR "RDE_FRAMEGRAPH_PATH with \"${RDE_FRAMEGRAPH_PATH}\" doesn't contains correct path to FrameGraph source!" ) 8 | endif () 9 | 10 | add_subdirectory( "${RDE_FRAMEGRAPH_PATH}" "build-FrameGraph" ) 11 | 12 | set_property( TARGET "STL" PROPERTY FOLDER "External" ) 13 | set_property( TARGET "VulkanLoader" PROPERTY FOLDER "External" ) 14 | set_property( TARGET "Framework" PROPERTY FOLDER "External" ) 15 | 16 | if (${FG_ENABLE_GLFW}) 17 | set_property( TARGET "uninstall" PROPERTY FOLDER "External" ) 18 | endif () 19 | 20 | set( RDE_CONVERTER_LIBRARIES "${RDE_CONVERTER_LIBRARIES}" "STL" "VulkanLoader" ) 21 | set( RDE_ENGINE_LIBRARIES "${RDE_ENGINE_LIBRARIES}" "STL" "VulkanLoader" "Framework" ) 22 | 23 | 24 | set( RDE_ENGINE_DEFINES "${RDE_ENGINE_DEFINES}" "RDE_FRAMEGRAPH_PATH=\"${RDE_FRAMEGRAPH_PATH}\"" "RDE_FRAMEGRAPH_EXTERNAL_PATH=\"${RDE_FRAMEGRAPH_PATH}/extensions\"" ) 25 | -------------------------------------------------------------------------------- /cmake/download_spirvcross.cmake: -------------------------------------------------------------------------------- 1 | # download and install SPIRV-Cross 2 | 3 | if (${RDE_ENABLE_SPIRVCROSS}) 4 | set( RDE_EXTERNAL_SPIRVCROSS_PATH "" CACHE PATH "path to SPIRV-Cross source" ) 5 | set( SPIRVCROSS_INSTALL_DIR "${RDE_EXTERNAL_INSTALL_DIR}/SPIRV-Cross" CACHE INTERNAL "" FORCE ) 6 | 7 | # reset to default 8 | if (NOT EXISTS "${RDE_EXTERNAL_SPIRVCROSS_PATH}/include/spirv_cross") 9 | message( STATUS "SPIRV-Cross is not found in \"${RDE_EXTERNAL_SPIRVCROSS_PATH}\"" ) 10 | set( RDE_EXTERNAL_SPIRVCROSS_PATH "${RDE_EXTERNALS_PATH}/SPIRV-Cross" CACHE PATH "" FORCE ) 11 | set( RDE_SPIRVCROSS_REPOSITORY "https://github.com/KhronosGroup/SPIRV-Cross.git" ) 12 | else () 13 | set( RDE_SPIRVCROSS_REPOSITORY "" ) 14 | endif () 15 | 16 | 17 | ExternalProject_Add( "External.SPIRV-Cross" 18 | LIST_SEPARATOR "${RDE_LIST_SEPARATOR}" 19 | # download 20 | GIT_REPOSITORY ${RDE_SPIRVCROSS_REPOSITORY} 21 | GIT_TAG master 22 | EXCLUDE_FROM_ALL 1 23 | LOG_DOWNLOAD 1 24 | # update 25 | PATCH_COMMAND "" 26 | UPDATE_DISCONNECTED 1 27 | # configure 28 | SOURCE_DIR "${RDE_EXTERNAL_SPIRVCROSS_PATH}" 29 | CMAKE_GENERATOR "${CMAKE_GENERATOR}" 30 | CMAKE_GENERATOR_PLATFORM "${CMAKE_GENERATOR_PLATFORM}" 31 | CMAKE_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}" 32 | CMAKE_ARGS "-DCMAKE_CONFIGURATION_TYPES=${RDE_EXTERNAL_CONFIGURATION_TYPES}" 33 | "-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}" 34 | "-DCMAKE_DEBUG_POSTFIX=d" 35 | "-DCMAKE_RELEASE_POSTFIX=" 36 | "-DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON" 37 | "-DCMAKE_INSTALL_PREFIX=${SPIRVCROSS_INSTALL_DIR}" 38 | ${RDE_BUILD_TARGET_FLAGS} 39 | LOG_CONFIGURE 1 40 | # build 41 | BINARY_DIR "${CMAKE_BINARY_DIR}/build2-SPIRV-Cross" 42 | BUILD_COMMAND "${CMAKE_COMMAND}" 43 | --build . 44 | --target ALL_BUILD 45 | --config $ 46 | LOG_BUILD 1 47 | # install 48 | INSTALL_DIR "${SPIRVCROSS_INSTALL_DIR}" 49 | LOG_INSTALL 1 50 | # test 51 | TEST_COMMAND "" 52 | ) 53 | 54 | set_property( TARGET "External.SPIRV-Cross" PROPERTY FOLDER "External" ) 55 | 56 | 57 | add_library( "SPIRV-Cross-lib" INTERFACE ) 58 | set_property( TARGET "SPIRV-Cross-lib" PROPERTY INTERFACE_LINK_LIBRARIES 59 | $<$: "${SPIRVCROSS_INSTALL_DIR}/lib/spirv-cross-core${CMAKE_STATIC_LIBRARY_SUFFIX}" > 60 | $<$: "${SPIRVCROSS_INSTALL_DIR}/lib/spirv-cross-glsl${CMAKE_STATIC_LIBRARY_SUFFIX}" > 61 | $<$: "${SPIRVCROSS_INSTALL_DIR}/lib/spirv-cross-cored${CMAKE_STATIC_LIBRARY_SUFFIX}" > 62 | $<$: "${SPIRVCROSS_INSTALL_DIR}/lib/spirv-cross-glsld${CMAKE_STATIC_LIBRARY_SUFFIX}" >) 63 | target_include_directories( "SPIRV-Cross-lib" INTERFACE "${SPIRVCROSS_INSTALL_DIR}/include" ) 64 | target_compile_definitions( "SPIRV-Cross-lib" INTERFACE "RDE_ENABLE_SPIRVCROSS" ) 65 | add_dependencies( "SPIRV-Cross-lib" "External.SPIRV-Cross" ) 66 | 67 | endif () 68 | -------------------------------------------------------------------------------- /cmake/find_devenv.cmake: -------------------------------------------------------------------------------- 1 | # search for visual studio devenv.exe 2 | 3 | if (WIN32) 4 | set( VS_VERSIONS "2019/Community" "2019/Professional" "2019/Enterprise" 5 | "2017/Community" "2017/Professional" "2017/Enterprise" 6 | "2015/Community" "2015/Professional" "2015/Enterprise" ) 7 | 8 | foreach( VER ${VS_VERSIONS} ) 9 | if (EXISTS "C:/Program Files (x86)/Microsoft Visual Studio/${VER}/Common7/IDE/devenv.exe") 10 | set( RDE_VS_DEVENV_EXE "C:/Program Files (x86)/Microsoft Visual Studio/${VER}/Common7/IDE/devenv.exe" CACHE INTERNAL "" FORCE ) 11 | break() 12 | endif () 13 | endforeach () 14 | 15 | if (RDE_VS_DEVENV_EXE) 16 | message( STATUS "Found VS compiler in '${RDE_VS_DEVENV_EXE}'" ) 17 | endif () 18 | endif () 19 | -------------------------------------------------------------------------------- /converter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | file( GLOB_RECURSE SOURCES "*.*" ) 4 | add_executable( "RdConverter" ${SOURCES} ) 5 | source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ) 6 | target_link_libraries( "RdConverter" PUBLIC "ProjectTemplate" ) 7 | target_include_directories( "RdConverter" PUBLIC ".." ) 8 | set_property( TARGET "RdConverter" PROPERTY FOLDER "" ) 9 | 10 | target_include_directories( "RdConverter" PUBLIC "${RDE_FRAMEGRAPH_PATH}/external/Vulkan-Headers/include" ) 11 | target_include_directories( "RdConverter" PUBLIC "${RDE_EXTERNALS_PATH}/rapidxml" ) 12 | target_include_directories( "RdConverter" PUBLIC ".." "." ) 13 | target_link_libraries( "RdConverter" PUBLIC "STL" ) 14 | target_link_libraries( "RdConverter" PUBLIC "SPIRV-Cross-lib" ) 15 | target_link_libraries( "RdConverter" PUBLIC "MiniZ" ) 16 | 17 | target_compile_definitions( "RdConverter" PUBLIC "RDE_SOURCE_PATH=\"${CMAKE_CURRENT_SOURCE_DIR}/..\"" ) 18 | target_compile_definitions( "RdConverter" PUBLIC "RDE_FRAMEGRAPH_PATH=\"${RDE_FRAMEGRAPH_PATH}\"" ) 19 | target_compile_definitions( "RdConverter" PUBLIC "RDE_VS_DEVENV_EXE=\"${RDE_VS_DEVENV_EXE}\"" ) 20 | 21 | if (MSVC) 22 | set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "RdConverter" ) 23 | target_compile_options( "RdConverter" PUBLIC $<$: /bigobj > ) 24 | endif () 25 | -------------------------------------------------------------------------------- /converter/Common.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | #include "stl/Stream/FileStream.h" 7 | #include "stl/Algorithms/StringUtils.h" 8 | 9 | #define VK_NO_PROTOTYPES 10 | #include "vulkan/vulkan.h" 11 | 12 | #include 13 | 14 | namespace RDE 15 | { 16 | using namespace FGC; 17 | namespace FS = std::filesystem; 18 | 19 | using EResourceType = VkObjectType; 20 | using VkResourceID = uint64_t; 21 | //enum VkResourceID : uint64_t {}; // TODO 22 | 23 | enum class ContentID : uint 24 | { 25 | Unknown = ~0u 26 | }; 27 | 28 | 29 | struct ImageLayouts 30 | { 31 | struct ImageRegionState 32 | { 33 | uint dstQueueFamilyIndex; 34 | VkImageSubresourceRange subresourceRange; 35 | VkImageLayout oldLayout; 36 | VkImageLayout newLayout; 37 | }; 38 | 39 | VkResourceID imageId; 40 | uint queueFamilyIndex; 41 | Array subresourceStates; 42 | uint layerCount; 43 | uint levelCount; 44 | uint sampleCount; 45 | VkExtent3D extent; 46 | VkFormat format; 47 | }; 48 | 49 | 50 | } // RDE 51 | -------------------------------------------------------------------------------- /converter/Utils/BasicTypesConverter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "Common.h" 6 | #include 7 | 8 | namespace RDE 9 | { 10 | 11 | // 12 | // Float/Int Value 13 | // 14 | 15 | struct FIValue 16 | { 17 | union { 18 | float f; 19 | int i; 20 | uint u; 21 | }; 22 | 23 | FIValue () : i{0} {} 24 | FIValue (float val) : f{val} {} 25 | FIValue (int val) : i{val} {} 26 | FIValue (uint val) : u{val} {} 27 | }; 28 | 29 | 30 | /* 31 | ================================================= 32 | BoolToString 33 | ================================================= 34 | */ 35 | ND_ inline String BoolToString (VkBool32 value) 36 | { 37 | return value ? "true" : "false"; 38 | } 39 | 40 | /* 41 | ================================================= 42 | HexToString 43 | ================================================= 44 | */ 45 | template 46 | ND_ inline String HexToString (const T &value) 47 | { 48 | auto ivalue = BitCast< NearUInt >( value ); 49 | 50 | std::stringstream str; 51 | str << "0x" << std::hex << ivalue; 52 | 53 | if constexpr ( IsSameTypes< T, uint32_t > or (IsPointer and sizeof(T) == sizeof(uint32_t)) ) 54 | str << 'u'; 55 | else if constexpr ( IsSameTypes< T, uint64_t > or (IsPointer and sizeof(T) == sizeof(uint64_t)) ) 56 | str << "ull"; 57 | else if constexpr ( IsSameTypes< T, int64_t > ) 58 | str << "ll"; 59 | 60 | return str.str(); 61 | } 62 | 63 | /* 64 | ================================================= 65 | IntToString 66 | ================================================= 67 | */ 68 | template 69 | ND_ inline EnableIf, String> IntToString (const T &value) 70 | { 71 | String str = ToString( value ); 72 | 73 | if constexpr ( IsSameTypes< T, uint32_t > ) 74 | str << 'u'; 75 | else if constexpr ( IsSameTypes< T, uint64_t > ) 76 | str << "ull"; 77 | else if constexpr ( IsSameTypes< T, int64_t > ) 78 | str << "ll"; 79 | 80 | return str; 81 | } 82 | 83 | /* 84 | ================================================= 85 | FloatToString 86 | ================================================= 87 | */ 88 | ND_ inline String FloatToString (float value) 89 | { 90 | if ( std::isnan( value )) 91 | FG_LOGD( "Converting NaN to string" ); 92 | 93 | return ToString( value ) << 'f'; 94 | } 95 | 96 | ND_ inline String DoubleToString (double value) 97 | { 98 | if ( std::isnan( value )) 99 | FG_LOGD( "Converting NaN to string" ); 100 | 101 | return ToString( value ); 102 | } 103 | 104 | /* 105 | ================================================= 106 | WCharToString 107 | ================================================= 108 | */ 109 | # ifdef VULKAN_WIN32_H_ 110 | ND_ inline String WCharToString (LPCWSTR str) 111 | { 112 | STATIC_ASSERT( sizeof(str[0]) == 2 ); // 2 bytes in wchar 113 | 114 | std::wstring_view ws{str}; 115 | String result = "L\""; 116 | char buf[] = "\\x0000"; 117 | 118 | for (auto& w : ws) 119 | { 120 | buf[2] = char((w >> 12) & 0xF); 121 | buf[3] = char((w >> 8) & 0xF); 122 | buf[4] = char((w >> 4) & 0xF); 123 | buf[5] = char((w) & 0xF); 124 | 125 | result << buf; 126 | } 127 | result << "\""; 128 | 129 | return result; 130 | } 131 | # endif 132 | 133 | /* 134 | ================================================= 135 | EnumToString 136 | ================================================= 137 | */ 138 | template 139 | ND_ inline String EnumToString (const T &value) 140 | { 141 | return ToString( BitCast>( value )); 142 | } 143 | 144 | /* 145 | ================================================= 146 | VoidToFIValueString 147 | ================================================= 148 | */ 149 | ND_ inline String VoidToFIValueString (const void *data, size_t offset) 150 | { 151 | FIValue value; 152 | memcpy( &value, static_cast(data) + offset, sizeof(value) ); 153 | 154 | String fstr = FloatToString( value.f ); 155 | String ustr = HexToString( value.u ); 156 | 157 | if ( not std::isfinite( value.f ) or fstr.length() > ustr.length()+4 ) 158 | return ustr; 159 | else 160 | return fstr; 161 | } 162 | 163 | /* 164 | ================================================= 165 | ConvertToCStyleString 166 | ================================================= 167 | */ 168 | ND_ inline String ConvertToCStyleString (StringView str) 169 | { 170 | String result; 171 | result.reserve( str.length() + 10 ); 172 | 173 | for (const char c : str) 174 | { 175 | switch ( c ) { 176 | case '\\' : result << '\\' << '\\'; break; 177 | case '"' : result << '\\' << '\"'; break; 178 | default : result << c; break; 179 | } 180 | } 181 | 182 | return result; 183 | } 184 | 185 | 186 | } // RDE 187 | -------------------------------------------------------------------------------- /converter/Utils/NameSerializer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "NameSerializer.h" 4 | 5 | namespace RDE 6 | { 7 | 8 | /* 9 | ================================================= 10 | Get 11 | ================================================= 12 | */ 13 | String NameSerializer::Get (const void *ptr) const 14 | { 15 | if ( ptr == null ) 16 | return "null"; 17 | 18 | auto iter = _usedNames.find( ptr ); 19 | if ( iter != _usedNames.end() ) 20 | return iter->second; 21 | 22 | //ASSERT(false); 23 | return "null"; 24 | } 25 | 26 | /* 27 | ================================================= 28 | GetPtr 29 | ================================================= 30 | */ 31 | String NameSerializer::GetPtr (const void *ptr) const 32 | { 33 | if ( ptr == null ) 34 | return "null"; 35 | 36 | auto iter = _usedNames.find( ptr ); 37 | if ( iter != _usedNames.end() ) 38 | return "&"s << iter->second; 39 | 40 | //ASSERT(false); 41 | return "null"; 42 | } 43 | 44 | /* 45 | ================================================= 46 | MakeUnique 47 | ================================================= 48 | */ 49 | String NameSerializer::MakeUnique (const void *ptr, String &&var0, String &&var1, String &&var2) 50 | { 51 | ASSERT( _usedNames.count(ptr) == 0 ); 52 | ASSERT( ptr ); 53 | ASSERT( not var0.empty() ); 54 | //ASSERT( var0.length() > var1.length() ); 55 | ASSERT( var1.length() >= var2.length() ); 56 | 57 | uint matches = 0; 58 | 59 | _MakeUnique( INOUT var0, OUT matches ); 60 | 61 | // TODO 62 | //_MakeUnique( INOUT var1, OUT matches ); 63 | //_MakeUnique( INOUT var2, OUT matches ); 64 | 65 | _usedNames.insert({ ptr, var0 }); 66 | _unique.insert( var0 ); 67 | 68 | return var0; 69 | } 70 | 71 | /* 72 | ================================================= 73 | ReserveName 74 | ================================================= 75 | */ 76 | bool NameSerializer::ReserveName (String &&name) 77 | { 78 | CHECK_ERR( _unique.insert( std::move(name) ).second ); 79 | return true; 80 | } 81 | 82 | /* 83 | ================================================= 84 | _MakeUnique 85 | ================================================= 86 | */ 87 | inline void NameSerializer::_MakeUnique (INOUT String &name, OUT uint &matches) const 88 | { 89 | matches = 0; 90 | 91 | if ( _unique.find( name ) == _unique.end() ) 92 | return; 93 | 94 | // validate name 95 | DEBUG_ONLY( 96 | for (auto& c : name) { 97 | ASSERT( (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (c == '_') or (&c != name.data() and c >= '0' and c <= '9') ); 98 | }) 99 | 100 | const size_t len = name.length(); 101 | 102 | for (matches = 1; matches < 1000; ++matches) 103 | { 104 | name.resize( len ); 105 | name << "_" << ToString(matches); 106 | 107 | if ( _unique.find( name ) == _unique.end() ) 108 | return; 109 | } 110 | } 111 | 112 | /* 113 | ================================================= 114 | Clear 115 | ================================================= 116 | */ 117 | void NameSerializer::Clear () 118 | { 119 | _usedNames.clear(); 120 | _unique.clear(); 121 | } 122 | 123 | 124 | } // RDE 125 | -------------------------------------------------------------------------------- /converter/Utils/NameSerializer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "Common.h" 6 | 7 | namespace RDE 8 | { 9 | 10 | // 11 | // Name Serializer 12 | // 13 | 14 | class NameSerializer 15 | { 16 | // types 17 | private: 18 | using NameMap_t = HashMap< const void*, String >; 19 | using UniqueNames_t = HashSet< String >; 20 | 21 | 22 | // variables 23 | private: 24 | NameMap_t _usedNames; 25 | UniqueNames_t _unique; 26 | 27 | 28 | // methods 29 | public: 30 | NameSerializer () {} 31 | NameSerializer (NameSerializer &&) = default; 32 | NameSerializer (const NameSerializer &) = delete; 33 | 34 | ND_ String Get (const void *ptr) const; 35 | ND_ String GetPtr (const void *ptr) const; 36 | 37 | ND_ String MakeUnique (const void *ptr, String &&var0, String &&var1 = Default, String &&var2 = Default); 38 | 39 | void Clear (); 40 | 41 | bool ReserveName (String &&name); 42 | 43 | 44 | private: 45 | void _MakeUnique (INOUT String &name, OUT uint &matches) const; 46 | }; 47 | 48 | 49 | } // RDE 50 | -------------------------------------------------------------------------------- /converter/Vulkan/ResRemapper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "Common.h" 6 | 7 | namespace RDE 8 | { 9 | 10 | // 11 | // Resource Remapper 12 | // 13 | 14 | struct ResRemapper 15 | { 16 | // types 17 | private: 18 | struct ResInfo 19 | { 20 | String name; 21 | String dbgName; 22 | uint firstChunk = UMax; 23 | mutable uint lastChunk = 0; 24 | uint64_t uniqueIndex = UMax; 25 | bool destroyed = true; 26 | }; 27 | using ResourceMap_t = HashMap< VkResourceID, Deque >; 28 | 29 | struct ResType 30 | { 31 | ResourceMap_t map; 32 | uint counter = 0; 33 | }; 34 | using Resources_t = HashMap< EResourceType, ResType >; 35 | 36 | using UniqueNames_t = HashSet< String >; 37 | 38 | 39 | // variables 40 | private: 41 | Resources_t _resources; 42 | uint _currentChunkIndex; 43 | UniqueNames_t _uniqueDbgNames; 44 | 45 | 46 | // methods 47 | public: 48 | ResRemapper (); 49 | 50 | bool CreateResource (EResourceType type, VkResourceID id, uint chunkIndex); 51 | bool DestroyResource (EResourceType type, VkResourceID id, uint chunkIndex); 52 | bool SetDebugName (EResourceType type, VkResourceID id, uint chunkIndex, StringView name); 53 | bool SetDebugName (VkResourceID id, uint chunkIndex, StringView name); 54 | 55 | ND_ uint64_t GetResourceUID (EResourceType type, VkResourceID id, uint chunkIndex) const; 56 | ND_ String GetResource (EResourceType type, VkResourceID id, bool edit = false) const; 57 | ND_ String GetResourceName (EResourceType type, VkResourceID id) const; 58 | 59 | ND_ bool IsResourceAlive (EResourceType type, VkResourceID id, uint chunkIndex) const; 60 | ND_ uint64_t GetAliveResourceUID (EResourceType type, VkResourceID id) const; 61 | ND_ String GetAliveResource (EResourceType type, VkResourceID id, bool edit = false) const; 62 | ND_ uint2 GetResourceLiveRange (EResourceType type, VkResourceID id, uint chunkIndex) const; 63 | 64 | void SetCurrentPos (uint chunkIndex) 65 | { 66 | _currentChunkIndex = chunkIndex; 67 | } 68 | 69 | template 70 | ND_ String operator () (EResourceType type, const T &resourceId, bool edit = false) const 71 | { 72 | STATIC_ASSERT( IsPointer or IsSameTypes ); 73 | 74 | return GetResource( type, VkResourceID(resourceId), edit ); 75 | } 76 | 77 | void ReplaceNames (INOUT String &str) const; 78 | void GetResourceIDs (StringView indent, OUT String &str) const; 79 | 80 | ND_ String GetResourceCount () const; 81 | }; 82 | 83 | 84 | } // RDE 85 | -------------------------------------------------------------------------------- /converter/Vulkan/VulkanConverter.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "Common.h" 6 | #include "Generated/IVulkanListener.h" 7 | 8 | namespace RDE 9 | { 10 | struct ConverterConfig 11 | { 12 | bool divideByCmdBuffers = true; 13 | bool compile = false; 14 | bool configure = false; 15 | bool cleanOutputFolder = false; 16 | }; 17 | 18 | 19 | // 20 | // Vulkan Converter 21 | // 22 | 23 | class VulkanConverter 24 | { 25 | // variables 26 | private: 27 | SharedPtr< IVulkanListener > _listener; 28 | 29 | const FS::path _outFolder; 30 | 31 | 32 | // methods 33 | public: 34 | explicit VulkanConverter (const FS::path &folder, const ConverterConfig &cfg); 35 | 36 | void Flush (); 37 | 38 | ND_ SharedPtr GetListener () const { return _listener; } 39 | }; 40 | 41 | 42 | } // RDE 43 | -------------------------------------------------------------------------------- /converter/Vulkan/VulkanFnToCpp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "Common.h" 6 | #include "Generated/IVulkanListener.h" 7 | 8 | namespace RDE 9 | { 10 | 11 | // 12 | // Convert to Raw Vulkan API 13 | // 14 | 15 | class VulkanFnToCpp : public IVulkanListener 16 | { 17 | // variables 18 | protected: 19 | const StringView indent = "\t\t"; 20 | String result; 21 | String before; 22 | NameSerializer nameSer; 23 | ResRemapper remapper; 24 | 25 | 26 | // methods 27 | protected: 28 | VulkanFnToCpp () {} 29 | 30 | virtual void FlushCommandBuffer (VkCommandBuffer) = 0; 31 | virtual void FlushQueue (VkQueue) = 0; 32 | virtual void FlushGlobal () = 0; 33 | 34 | # include "Generated/BuildRawVulkanCalls.h" 35 | }; 36 | 37 | 38 | } // RDE 39 | -------------------------------------------------------------------------------- /converter/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "RdCaptureReader.h" 4 | #include "Vulkan/VulkanConverter.h" 5 | #include 6 | 7 | 8 | using namespace RDE; 9 | 10 | static const char s_Help[] = R"#( 11 | -i [filename] - open RenderDoc capture, must be *.zip or *.zip.xml file 12 | --input [filename] 13 | 14 | -o [folder] - save c++ code into output directory 15 | --output [folder] 16 | 17 | --div-by-cmdbuf [bool] - (optional) group api calls by command buffers, default = true 18 | 19 | --build - (optional) generate project and build, default = false 20 | 21 | --configure - (optional) generate project without building, default = false 22 | 23 | --clean - (optional) clean output folder before converting 24 | )#"; 25 | 26 | int main (int argc, const char** argv) 27 | { 28 | String input; 29 | String output; 30 | ConverterConfig cfg; 31 | 32 | // parse arguments 33 | for (int i = 1; i < argc; ++i) 34 | { 35 | StringView curr = argv[i]; 36 | 37 | // 'open RDC' command 38 | if ( curr == "-i" or curr == "--input" ) 39 | { 40 | if ( i+1 >= argc ) 41 | { 42 | std::cout << "'--input' requires file or folder name" << std::endl; 43 | return -1; 44 | } 45 | 46 | input = argv[++i]; 47 | continue; 48 | } 49 | 50 | // 'set output directory' command 51 | if ( curr == "-o" or curr == "--output" ) 52 | { 53 | if ( i+1 >= argc ) 54 | { 55 | std::cout << "'--output' requires folder name" << std::endl; 56 | return -1; 57 | } 58 | 59 | output = argv[++i]; 60 | continue; 61 | } 62 | 63 | // show help 64 | if ( curr == "-h" or curr == "--help" ) 65 | { 66 | std::cout << s_Help << std::endl; 67 | return 0; 68 | } 69 | 70 | if ( curr == "--div-by-cmdbuf" ) 71 | { 72 | if ( i+1 >= argc ) 73 | { 74 | std::cout << "--div-by-cmdbuf requires bool parameter" << std::endl; 75 | return -1; 76 | } 77 | 78 | ++i; 79 | cfg.divideByCmdBuffers = (argv[i] == "true"s or argv[i] == "TRUE"s); 80 | continue; 81 | } 82 | 83 | if ( curr == "--build" ) 84 | { 85 | cfg.compile = true; 86 | continue; 87 | } 88 | 89 | if ( curr == "--configure" ) 90 | { 91 | cfg.configure = true; 92 | continue; 93 | } 94 | 95 | if ( curr == "--clean" ) 96 | { 97 | cfg.cleanOutputFolder = true; 98 | continue; 99 | } 100 | 101 | std::cout << "unknown command: '" << curr << "', see help with command -h or --help" << std::endl; 102 | return -1; 103 | } 104 | 105 | // validate 106 | FS::path input_p {input}; 107 | FS::path output_p {output}; 108 | 109 | if ( not FS::exists( input_p )) 110 | { 111 | if ( not input_p.extension().empty() ) 112 | { 113 | std::cout << "can't open input: '" << input << "'" << std::endl; 114 | return -1; 115 | } 116 | 117 | // try use extension .zip / .zip.xml 118 | if ( not FS::exists( input_p.replace_extension( "zip" )) ) 119 | { 120 | if ( not FS::exists( input_p.replace_extension( "zip.xml" )) ) 121 | { 122 | std::cout << "can't open input: '" << input << "'" << std::endl; 123 | return -1; 124 | } 125 | } 126 | } 127 | 128 | if ( FS::exists( output_p )) 129 | { 130 | if ( not FS::is_directory( output_p )) 131 | { 132 | std::cout << "output: '" << output << "' must be directory name" << std::endl; 133 | return -1; 134 | } 135 | } 136 | else 137 | { 138 | if ( not FS::create_directories( output_p )) 139 | { 140 | std::cout << "can't create directory: '" << output << "'" << std::endl; 141 | return -1; 142 | } 143 | 144 | std::cout << "created directoty: '" << output << "'" << std::endl; 145 | } 146 | 147 | if ( cfg.compile and cfg.configure ) 148 | { 149 | std::cout << "'configure' command ignored because used 'build' command" << std::endl; 150 | cfg.configure = false; 151 | } 152 | 153 | 154 | VulkanConverter vk_conv{ output_p, cfg }; 155 | RdCaptureReader reader; 156 | 157 | reader.AddListener( vk_conv.GetListener() ); 158 | 159 | CHECK_ERR( reader.OpenCapture( input_p.replace_extension("") ), -1 ); 160 | 161 | return 0; 162 | } 163 | -------------------------------------------------------------------------------- /external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # download and install all external dependencies 2 | 3 | cmake_policy( SET CMP0022 NEW ) 4 | cmake_minimum_required (VERSION 3.6.0) 5 | 6 | include( ExternalProject ) 7 | 8 | set( RDE_EXTERNALS_PATH "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Path to external projects sources" ) 9 | set( RDE_EXTERNAL_INSTALL_DIR "${CMAKE_BINARY_DIR}/install" ) 10 | message( STATUS "RDE_EXTERNALS_PATH: ${RDE_EXTERNALS_PATH}" ) 11 | 12 | # configure 13 | set( RDE_LIST_SEPARATOR "|" ) 14 | string( REPLACE ";" "${RDE_LIST_SEPARATOR}" RDE_EXTERNAL_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" ) 15 | set( RDE_BUILD_TARGET_FLAGS "" ) 16 | 17 | foreach ( CONFIG ${CMAKE_CONFIGURATION_TYPES} ) 18 | string( TOUPPER ${CONFIG} OUT_CONFIG ) 19 | 20 | set( RDE_BUILD_TARGET_FLAGS 21 | "${RDE_BUILD_TARGET_FLAGS}" 22 | "-DCMAKE_C_FLAGS_${OUT_CONFIG}=${CMAKE_C_FLAGS_${OUT_CONFIG}}" 23 | "-DCMAKE_CXX_FLAGS_${OUT_CONFIG}=${CMAKE_CXX_FLAGS_${OUT_CONFIG}}" 24 | "-DCMAKE_EXE_LINKER_FLAGS_${OUT_CONFIG}=${CMAKE_EXE_LINKER_FLAGS_${OUT_CONFIG}}" 25 | "-DCMAKE_STATIC_LINKER_FLAGS_${OUT_CONFIG}=${CMAKE_STATIC_LINKER_FLAGS_${OUT_CONFIG}}" 26 | "-DCMAKE_SHARED_LINKER_FLAGS_${OUT_CONFIG}=${CMAKE_SHARED_LINKER_FLAGS_${OUT_CONFIG}}" 27 | ) 28 | endforeach () 29 | 30 | include( "${CMAKE_SOURCE_DIR}/cmake/attach_fg.cmake" ) 31 | include( "${CMAKE_SOURCE_DIR}/cmake/find_devenv.cmake" ) 32 | include( "${CMAKE_SOURCE_DIR}/cmake/download_spirvcross.cmake" ) 33 | 34 | add_subdirectory( "miniz" "miniz" ) 35 | -------------------------------------------------------------------------------- /external/FrameGraph/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /external/glfw 3 | /external/glslang 4 | /external/lodepng 5 | /external/SDL2 6 | /external/Vulkan-Headers 7 | /external/VulkanMemoryAllocator 8 | /external/SFML 9 | /external/assimp 10 | /external/foonathan_memory 11 | /external/imgui 12 | /external/glm 13 | /external/DevIL 14 | /external/FreeImage 15 | /external/AngelScript 16 | /external/optional 17 | /external/variant 18 | /tests/framegraph/Graphs 19 | /samples/_data 20 | *.user 21 | *.glsl_dbg 22 | -------------------------------------------------------------------------------- /external/FrameGraph/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | message( STATUS "==========================================================================\n" ) 4 | message( STATUS "project 'FrameGraph' generation started" ) 5 | 6 | project( "FrameGraph" LANGUAGES C CXX ) 7 | set_property( GLOBAL PROPERTY USE_FOLDERS ON ) 8 | message( STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION})" ) 9 | message( STATUS "target system: ${CMAKE_SYSTEM_NAME} (${CMAKE_SYSTEM_VERSION})" ) 10 | message( STATUS "host system: ${CMAKE_HOST_SYSTEM_NAME} (${CMAKE_HOST_SYSTEM_VERSION})" ) 11 | 12 | set( FG_ENABLE_SIMPLE_COMPILER_OPTIONS OFF CACHE BOOL "use simplified compiler settings if you have problem with it" ) 13 | set( FG_EXTERNALS_USE_STABLE_VERSIONS ON CACHE BOOL "use last stable version instead of master branch" ) 14 | 15 | set( FG_ENABLE_GLFW ON CACHE BOOL "use glfw (optional, required for tests)" ) 16 | set( FG_ENABLE_SDL2 OFF CACHE BOOL "use SDL2 (optional, required for tests)" ) 17 | set( FG_ENABLE_GLSLANG ON CACHE BOOL "use glslang (optional, required for glsl compilation)" ) 18 | set( FG_ENABLE_VMA ON CACHE BOOL "use Vulkan Memory Allocator (required)" ) 19 | 20 | set( CMAKE_DEBUG_POSTFIX "d" ) 21 | set( CMAKE_RELEASE_POSTFIX "" ) 22 | set( CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "installation directory" ) 23 | set( MAIN_BINARY_DIR "${CMAKE_BINARY_DIR}/bin" CACHE INTERNAL "" FORCE ) 24 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${MAIN_BINARY_DIR}" ) 25 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${MAIN_BINARY_DIR}" ) 26 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MAIN_BINARY_DIR}" ) 27 | 28 | if (${FG_ENABLE_SIMPLE_COMPILER_OPTIONS}) 29 | include( "cmake/compilers_minimal.cmake" ) 30 | else() 31 | include( "cmake/compilers.cmake" ) 32 | endif() 33 | include( "cmake/compiler_tests.cmake" ) 34 | 35 | add_subdirectory( "external" ) 36 | include( "cmake/project_template.cmake" ) 37 | add_subdirectory( "stl" ) 38 | add_subdirectory( "extensions/vulkan_loader" ) 39 | add_subdirectory( "extensions/framework" ) 40 | 41 | message( STATUS "project 'FrameGraph' generation ended" ) 42 | message( STATUS "\n==========================================================================" ) 43 | -------------------------------------------------------------------------------- /external/FrameGraph/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018-2019, Zhirnov Andrey 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /external/FrameGraph/README.md: -------------------------------------------------------------------------------- 1 | # FrameGraph 2 | 3 | FrameGraph simplifies prototyping on Vulkan and can be used as a base layer for the graphics engine. 4 | FrameGraph designed for maximum performance but not at the expense of usability. API developed as simple as possible, it hides all synchronizations, memory allocations and all this boilerplate code that is needed to get Vulkan work. Builtin validations together with Vulkan validation layers allow you to quickly find and fix errors. 5 | 6 | ## Features 7 | * multithreaded command buffer building and submission. 8 | * simple API, hides memory allocation, host<->device transfers, synchronizations. 9 | * glsl debugging. 10 | * supports RTX extensions. 11 | * supports async compute and async transfer queues. 12 | 13 | 14 | ## Documentation 15 | * [Introduction](docs/Introduction.md) 16 | * [Multithreading](docs/Multithreading.md) 17 | * [Performance](docs/Performance.md) 18 | * [Ray tracing](docs/RayTracing.md) 19 | * [Porting from OpenGL](docs/Porting-from-OpenGL.md) 20 | * [Porting from Vulkan](docs/Porting-from-Vulkan.md) 21 | * [Extensions overview](extensions/Readme.md) 22 | * [Shader debugging](docs/Shader-debugging.md) 23 | * [Graph visualization](docs/Graph-visualization.md) 24 | * [Roadmap](docs/Roadmap.md) 25 | 26 | 27 | ## Suported Platforms 28 | * Windows (with MSVC 2017) 29 | * Linux (with GCC 8.2) 30 | 31 | 32 | ## Building 33 | Generate project with CMake and build.
34 | Required C++17 standard support. 35 | 36 | CMake version 3.11 and greater will download all dependencies during configuration time.
37 | If it didn't, manualy download dependencies into 'external' directory or in cmake specify `FG_EXTERNAL_***` pathes for each dependency. 38 | 39 | Dependencies:
40 | [Vulkan-headers](https://github.com/KhronosGroup/Vulkan-Headers) or [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) - required.
41 | [VulkanMemoryAllocator](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) - required.
42 | [glfw](https://github.com/glfw/glfw) or [SDL2](https://www.libsdl.org) or [SFML](https://github.com/SFML/SFML) - required for framework and some tests.
43 | [glslang](https://github.com/KhronosGroup/glslang) - required for glsl compiler.
44 | [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools), [SPIRV-Headers](https://github.com/KhronosGroup/SPIRV-Headers) and Python - optional, for spirv optimization.
45 | [lodepng](https://github.com/lvandeve/lodepng) - optional.
46 | [graphviz](https://www.graphviz.org/) - (optional) for graph visualization.
47 | [Assimp](https://github.com/assimp/assimp) - (optional) for Scene extension.
48 | [DevIL](http://openil.sourceforge.net/) - (optional) for Scene extension.
49 | [FreeImage](http://freeimage.sourceforge.net/) - (optional) for Scene extension.
50 | [imgui](https://github.com/ocornut/imgui) - (optional) for UI extension.
51 | 52 | 53 | ## References 54 | 1. [FrameGraph in Frostbite](https://www.gdcvault.com/play/1024612/FrameGraph-Extensible-Rendering-Architecture-in).
55 | 2. [Handles vs pointers](https://floooh.github.io/2018/06/17/handles-vs-pointers.html)
56 | 3. [Porting engine to vulkan](https://gpuopen.com/presentation-porting-engine-to-vulkan-dx12/).
57 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/compiler_tests.cmake: -------------------------------------------------------------------------------- 1 | include( CheckCXXSourceCompiles ) 2 | 3 | if ( ${COMPILER_MSVC} ) 4 | set( CMAKE_REQUIRED_FLAGS "/std:c++latest" ) 5 | else() 6 | set( CMAKE_REQUIRED_FLAGS "-std=c++17" ) 7 | endif () 8 | 9 | message( STATUS "Run compiler tests with flags: ${CMAKE_REQUIRED_FLAGS}" ) 10 | 11 | set( FG_COMPILER_DEFINITIONS "" ) 12 | set( FG_LINK_LIBRARIES "" ) 13 | 14 | #------------------------------------------------------------------------------ 15 | check_cxx_source_compiles( 16 | "#include 17 | int main () { 18 | std::string_view str{\"1234\"}; 19 | return 0; 20 | }" 21 | STD_STRINGVIEW_SUPPORTED ) 22 | 23 | if (STD_STRINGVIEW_SUPPORTED) 24 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_STD_STRINGVIEW" ) 25 | set( STD_STRINGVIEW_SUPPORTED ON CACHE INTERNAL "" FORCE ) 26 | else() 27 | set( STD_STRINGVIEW_SUPPORTED OFF CACHE INTERNAL "" FORCE ) 28 | endif () 29 | 30 | #------------------------------------------------------------------------------ 31 | check_cxx_source_compiles( 32 | "#include 33 | int main () { 34 | std::optional opt; 35 | return opt.has_value() ? 0 : 1; 36 | }" 37 | STD_OPTIONAL_SUPPORTED ) 38 | 39 | if (STD_OPTIONAL_SUPPORTED) 40 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_STD_OPTIONAL" ) 41 | set( STD_OPTIONAL_SUPPORTED ON CACHE INTERNAL "" FORCE ) 42 | else() 43 | set( STD_OPTIONAL_SUPPORTED OFF CACHE INTERNAL "" FORCE ) 44 | endif () 45 | 46 | #------------------------------------------------------------------------------ 47 | check_cxx_source_compiles( 48 | "#include 49 | int main () { 50 | std::variant var; 51 | var = 1.0f; 52 | return 0; 53 | }" 54 | STD_VARIANT_SUPPORTED ) 55 | 56 | if (STD_VARIANT_SUPPORTED) 57 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_STD_VARIANT" ) 58 | set( STD_VARIANT_SUPPORTED ON CACHE INTERNAL "" FORCE ) 59 | else() 60 | set( STD_VARIANT_SUPPORTED OFF CACHE INTERNAL "" FORCE ) 61 | endif () 62 | 63 | #------------------------------------------------------------------------------ 64 | check_cxx_source_compiles( 65 | "#include 66 | namespace fs = std::filesystem; 67 | int main () { 68 | return 0; 69 | }" 70 | STD_FILESYSTEM_SUPPORTED ) 71 | 72 | if (STD_FILESYSTEM_SUPPORTED) 73 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_STD_FILESYSTEM" ) 74 | 75 | if (${COMPILER_CLANG} OR ${COMPILER_CLANG_APPLE} OR ${COMPILER_CLANG_ANDROID} OR ${COMPILER_GCC}) 76 | set( FG_LINK_LIBRARIES "${FG_LINK_LIBRARIES}" "stdc++fs" ) 77 | endif() 78 | set( STD_FILESYSTEM_SUPPORTED ON CACHE INTERNAL "" FORCE ) 79 | else() 80 | set( STD_FILESYSTEM_SUPPORTED OFF CACHE INTERNAL "" FORCE ) 81 | endif () 82 | 83 | #------------------------------------------------------------------------------ 84 | check_cxx_source_compiles( 85 | "#include 86 | static constexpr size_t Align = std::hardware_destructive_interference_size; 87 | int main () { 88 | return 0; 89 | }" 90 | STD_CACHELINESIZE_SUPPORTED ) 91 | 92 | if (STD_CACHELINESIZE_SUPPORTED) 93 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_CACHE_LINE=std::hardware_destructive_interference_size" ) 94 | else () 95 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_CACHE_LINE=64" ) # TODO 96 | endif () 97 | 98 | #------------------------------------------------------------------------------ 99 | check_cxx_source_compiles( 100 | "#include 101 | int main () { 102 | std::barrier temp; 103 | return 0; 104 | }" 105 | STD_BARRIER_SUPPORTED ) 106 | 107 | if (STD_BARRIER_SUPPORTED) 108 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_STD_BARRIER" ) 109 | endif () 110 | 111 | #------------------------------------------------------------------------------ 112 | check_cxx_source_compiles( 113 | "#include 114 | int main () { 115 | char buffer[128] = {}; 116 | (void)(std::_Hash_array_representation( reinterpret_cast(buffer), std::size(buffer) )); 117 | return 0; 118 | }" 119 | HAS_HASHFN_HashArrayRepresentation ) 120 | 121 | if (HAS_HASHFN_HashArrayRepresentation) 122 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_HAS_HASHFN_HashArrayRepresentation" ) 123 | endif () 124 | 125 | #------------------------------------------------------------------------------ 126 | check_cxx_source_compiles( 127 | "#include 128 | int main () { 129 | char buffer[128] = {}; 130 | (void)(std::__murmur2_or_cityhash()( buffer, std::size(buffer) )); 131 | return 0; 132 | }" 133 | HAS_HASHFN_Murmur2OrCityhash ) 134 | 135 | if (HAS_HASHFN_Murmur2OrCityhash) 136 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_HAS_HASHFN_Murmur2OrCityhash" ) 137 | endif () 138 | 139 | #------------------------------------------------------------------------------ 140 | check_cxx_source_compiles( 141 | "#include 142 | int main () { 143 | char buffer[128] = {}; 144 | (void)(std::_Hash_bytes( buffer, std::size(buffer), 0 )); 145 | return 0; 146 | }" 147 | HAS_HASHFN_HashBytes ) 148 | 149 | if (HAS_HASHFN_HashBytes) 150 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" "FG_HAS_HASHFN_HashBytes" ) 151 | endif () 152 | 153 | #------------------------------------------------------------------------------ 154 | 155 | set( CMAKE_REQUIRED_FLAGS "" ) 156 | set( FG_COMPILER_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" CACHE INTERNAL "" FORCE ) 157 | set( FG_LINK_LIBRARIES "${FG_LINK_LIBRARIES}" CACHE INTERNAL "" FORCE ) 158 | 159 | #message( STATUS "Supported features = ${CMAKE_CXX_COMPILE_FEATURES}" ) 160 | 161 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/download_glfw.cmake: -------------------------------------------------------------------------------- 1 | # find or download GLFW 2 | 3 | if (${FG_ENABLE_GLFW}) 4 | set( FG_EXTERNAL_GLFW_PATH "" CACHE PATH "path to glfw source" ) 5 | mark_as_advanced( FG_EXTERNAL_GLFW_PATH ) 6 | 7 | # reset to default 8 | if (NOT EXISTS "${FG_EXTERNAL_GLFW_PATH}/include/GLFW/glfw3.h" ) 9 | message( STATUS "glfw is not found in \"${FG_EXTERNAL_GLFW_PATH}\"" ) 10 | set( FG_EXTERNAL_GLFW_PATH "${FG_EXTERNALS_PATH}/glfw" CACHE PATH "" FORCE ) 11 | else () 12 | message( STATUS "glfw found in \"${FG_EXTERNAL_GLFW_PATH}\"" ) 13 | endif () 14 | 15 | # select version 16 | if (${FG_EXTERNALS_USE_STABLE_VERSIONS}) 17 | set( GLWF_TAG "3.2.1" ) 18 | else () 19 | set( GLWF_TAG "master" ) 20 | endif () 21 | 22 | # download 23 | if (NOT EXISTS "${FG_EXTERNAL_GLFW_PATH}" AND NOT CMAKE_VERSION VERSION_LESS 3.11.0) 24 | FetchContent_Declare( ExternalGLFW 25 | GIT_REPOSITORY https://github.com/glfw/glfw.git 26 | GIT_TAG ${GLWF_TAG} 27 | SOURCE_DIR "${FG_EXTERNAL_GLFW_PATH}" 28 | ) 29 | 30 | FetchContent_GetProperties( ExternalGLFW ) 31 | if (NOT ExternalGLFW_POPULATED) 32 | message( STATUS "downloading glfw" ) 33 | FetchContent_Populate( ExternalGLFW ) 34 | endif () 35 | endif () 36 | 37 | set( GLFW_INSTALL ON CACHE BOOL "glfw option" ) 38 | set( GLFW_BUILD_TESTS OFF CACHE BOOL "glfw option" ) 39 | set( GLFW_BUILD_EXAMPLES OFF CACHE BOOL "glfw option" ) 40 | set( GLFW_BUILD_DOCS OFF CACHE BOOL "glfw option" ) 41 | set( USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "glfw option" ) 42 | 43 | add_subdirectory( "${FG_EXTERNAL_GLFW_PATH}" "glfw" ) 44 | set_property( TARGET "glfw" PROPERTY FOLDER "External" ) 45 | 46 | if (TARGET uninstall) 47 | set_property( TARGET "uninstall" PROPERTY FOLDER "External" ) 48 | endif () 49 | 50 | mark_as_advanced( GLFW_INSTALL GLFW_BUILD_TESTS GLFW_BUILD_EXAMPLES GLFW_BUILD_DOCS GLFW_DOCUMENT_INTERNALS ) 51 | mark_as_advanced( GLFW_USE_HYBRID_HPG GLFW_VULKAN_STATIC USE_MSVC_RUNTIME_LIBRARY_DLL ) 52 | 53 | add_library( "GLFW-lib" INTERFACE ) 54 | set_property( TARGET "GLFW-lib" PROPERTY INTERFACE_LINK_LIBRARIES "glfw" ) 55 | target_include_directories( "GLFW-lib" INTERFACE "${FG_EXTERNAL_GLFW_PATH}/include" ) 56 | target_compile_definitions( "GLFW-lib" INTERFACE "FG_ENABLE_GLFW" ) 57 | endif () 58 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/download_sdl2.cmake: -------------------------------------------------------------------------------- 1 | # find or download SDL2 2 | 3 | if (${FG_ENABLE_SDL2}) 4 | set( FG_EXTERNAL_SDL2_PATH "" CACHE PATH "path to SDL2 source" ) 5 | mark_as_advanced( FG_EXTERNAL_SDL2_PATH ) 6 | 7 | # reset to default 8 | if (NOT EXISTS "${FG_EXTERNAL_SDL2_PATH}/include/SDL.h") 9 | message( STATUS "SDL2 is not found in \"${FG_EXTERNAL_SDL2_PATH}\"" ) 10 | set( FG_EXTERNAL_SDL2_PATH "${FG_EXTERNALS_PATH}/SDL2" CACHE PATH "" FORCE ) 11 | else () 12 | message( STATUS "SDL2 found in \"${FG_EXTERNAL_SDL2_PATH}\"" ) 13 | endif () 14 | 15 | # download 16 | if (NOT EXISTS "${FG_EXTERNAL_SDL2_PATH}" AND NOT CMAKE_VERSION VERSION_LESS 3.11.0) 17 | FetchContent_Declare( ExternalSDL2 18 | URL https://www.libsdl.org/release/SDL2-2.0.8.zip 19 | SOURCE_DIR "${FG_EXTERNAL_SDL2_PATH}" 20 | ) 21 | 22 | FetchContent_GetProperties( ExternalSDL2 ) 23 | if (NOT ExternalSDL2_POPULATED) 24 | message( STATUS "downloading SDL2" ) 25 | FetchContent_Populate( ExternalSDL2 ) 26 | endif () 27 | endif () 28 | 29 | set( SDL_SHARED OFF CACHE BOOL "SDL2 option" FORCE ) 30 | set( SDL_STATIC ON CACHE BOOL "SDL2 option" FORCE ) 31 | set( SDL_AUDIO OFF CACHE BOOL "SDL2 option" FORCE ) 32 | set( SDL_RENDER OFF CACHE BOOL "SDL2 option" FORCE ) 33 | set( SDL_TEST OFF CACHE BOOL "SDL2 option" FORCE ) 34 | set( DIRECTX OFF CACHE BOOL "SDL2 option" FORCE ) 35 | set( RENDER_D3D OFF CACHE BOOL "SDL2 option" FORCE ) 36 | 37 | add_subdirectory( "${FG_EXTERNAL_SDL2_PATH}" "SDL2" ) 38 | 39 | if (TARGET SDL2main) 40 | set_property( TARGET "SDL2main" PROPERTY FOLDER "External" ) 41 | endif () 42 | 43 | if (TARGET uninstall) 44 | set_property( TARGET "uninstall" PROPERTY FOLDER "External" ) 45 | endif () 46 | 47 | mark_as_advanced( 3DNOW ALSA ALTIVEC ARTS ASSEMBLY ASSERTIONS CLOCK_GETTIME DIRECTX 48 | DISKAUDIO DUMMYAUDIO ESD FORCE_STATIC_VCRT FUSIONSOUND GCC_ATOMICS 49 | INPUT_TSLIB JACK LIBC LIBSAMPLERATE MMX NAS NAS_SHARED OSS PTHREADS 50 | PULSEAUDIO RENDER_D3D RPATH SNDIO SSE SSE2 SSE3 SSEMATH WINDRES 51 | VIDEO_COCOA VIDEO_DIRECTFB VIDEO_DUMMY VIDEO_KMSDRM VIDEO_MIR VIDEO_OPENGL 52 | VIDEO_OPENGLES VIDEO_RPI VIDEO_VIVANTE VIDEO_VULKAN VIDEO_WAYLAND VIDEO_X11 ) 53 | mark_as_advanced( SDL_ATOMIC SDL_AUDIO SDL_CPUINFO SDL_DLOPEN SDL_EVENTS SDL_FILE 54 | SDL_FILESYSTEM SDL_HAPTIC SDL_JOYSTICK SDL_LOADSO SDL_POWER SDL_RENDER 55 | SDL_SHARED SDL_STATIC SDL_STATIC_PIC SDL_TEST SDL_THREADS SDL_TIMERS SDL_VIDEO ) 56 | 57 | add_library( "SDL2-lib" INTERFACE ) 58 | 59 | if (${SDL_SHARED}) 60 | set_property( TARGET "SDL2" PROPERTY FOLDER "External" ) 61 | set_property( TARGET "SDL2-lib" PROPERTY INTERFACE_LINK_LIBRARIES "SDL2" ) 62 | endif () 63 | 64 | if (${SDL_STATIC}) 65 | set_property( TARGET "SDL2-static" PROPERTY FOLDER "External" ) 66 | set_property( TARGET "SDL2-lib" PROPERTY INTERFACE_LINK_LIBRARIES "SDL2-static" ) 67 | endif () 68 | 69 | target_include_directories( "SDL2-lib" INTERFACE "${FG_EXTERNAL_SDL2_PATH}/include" ) 70 | target_compile_definitions( "SDL2-lib" INTERFACE "FG_ENABLE_SDL2" ) 71 | endif () -------------------------------------------------------------------------------- /external/FrameGraph/cmake/download_stdoptional.cmake: -------------------------------------------------------------------------------- 1 | # find or download std::optional implementation 2 | 3 | if (NOT ${STD_OPTIONAL_SUPPORTED}) 4 | set( FG_EXTERNAL_STDOPTIONAL_PATH "" CACHE PATH "path to std::optional source" ) 5 | mark_as_advanced( FG_EXTERNAL_STDOPTIONAL_PATH ) 6 | 7 | # reset to default 8 | if (NOT EXISTS "${FG_EXTERNAL_STDOPTIONAL_PATH}/optional.hpp") 9 | message( STATUS "std::optional is not found in \"${FG_EXTERNAL_STDOPTIONAL_PATH}\"" ) 10 | set( FG_EXTERNAL_STDOPTIONAL_PATH "${FG_EXTERNALS_PATH}/optional" CACHE PATH "" FORCE ) 11 | else () 12 | message( STATUS "std::optional found in \"${FG_EXTERNAL_STDOPTIONAL_PATH}\"" ) 13 | endif () 14 | 15 | # download 16 | if (NOT EXISTS "${FG_EXTERNAL_STDOPTIONAL_PATH}" AND NOT CMAKE_VERSION VERSION_LESS 3.11.0) 17 | FetchContent_Declare( ExternalStdOpt 18 | GIT_REPOSITORY https://github.com/akrzemi1/Optional.git 19 | SOURCE_DIR "${FG_EXTERNAL_STDOPTIONAL_PATH}" 20 | GIT_TAG master 21 | ) 22 | 23 | FetchContent_GetProperties( ExternalStdOpt ) 24 | if (NOT ExternalStdOpt_POPULATED) 25 | message( STATUS "downloading std::optional" ) 26 | FetchContent_Populate( ExternalStdOpt ) 27 | endif () 28 | endif () 29 | 30 | add_library( "StdOptional-lib" INTERFACE ) 31 | target_include_directories( "StdOptional-lib" INTERFACE "${FG_EXTERNAL_STDOPTIONAL_PATH}" ) 32 | target_compile_definitions( "StdOptional-lib" INTERFACE "FG_ENABLE_OPTIONAL" ) 33 | endif () 34 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/download_stdstringview.cmake: -------------------------------------------------------------------------------- 1 | # find or download std::string_view implementation 2 | 3 | if (NOT ${STD_STRINGVIEW_SUPPORTED}) 4 | set( FG_EXTERNAL_STDSTRINGVIEW_PATH "" CACHE PATH "path to std::string_view source" ) 5 | mark_as_advanced( FG_EXTERNAL_STDSTRINGVIEW_PATH ) 6 | 7 | # reset to default 8 | if (NOT EXISTS "${FG_EXTERNAL_STDSTRINGVIEW_PATH}/include/nonstd/string_view.hpp") 9 | message( STATUS "std::string_view is not found in \"${FG_EXTERNAL_STDSTRINGVIEW_PATH}\"" ) 10 | set( FG_EXTERNAL_STDSTRINGVIEW_PATH "${FG_EXTERNALS_PATH}/string_view" CACHE PATH "" FORCE ) 11 | else () 12 | message( STATUS "std::string_view found in \"${FG_EXTERNAL_STDSTRINGVIEW_PATH}\"" ) 13 | endif () 14 | 15 | # download 16 | if (NOT EXISTS "${FG_EXTERNAL_STDSTRINGVIEW_PATH}" AND NOT CMAKE_VERSION VERSION_LESS 3.11.0) 17 | FetchContent_Declare( ExternalStdStrView 18 | GIT_REPOSITORY https://github.com/martinmoene/string-view-lite.git 19 | SOURCE_DIR "${FG_EXTERNAL_STDSTRINGVIEW_PATH}" 20 | GIT_TAG master 21 | ) 22 | 23 | FetchContent_GetProperties( ExternalStdStrView ) 24 | if (NOT ExternalStdStrView_POPULATED) 25 | message( STATUS "downloading std::string_view" ) 26 | FetchContent_Populate( ExternalStdStrView ) 27 | endif () 28 | endif () 29 | 30 | add_library( "StdStringView-lib" INTERFACE ) 31 | target_include_directories( "StdStringView-lib" INTERFACE "${FG_EXTERNAL_STDSTRINGVIEW_PATH}/include" ) 32 | target_compile_definitions( "StdStringView-lib" INTERFACE "FG_ENABLE_STRINGVIEW" ) 33 | endif () 34 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/download_stdvariant.cmake: -------------------------------------------------------------------------------- 1 | # find or download std::variant implementation 2 | 3 | if (NOT ${STD_VARIANT_SUPPORTED}) 4 | set( FG_EXTERNAL_STDVARIANT_PATH "" CACHE PATH "path to std::variant source" ) 5 | mark_as_advanced( FG_EXTERNAL_STDVARIANT_PATH ) 6 | 7 | # reset to default 8 | if (NOT EXISTS "${FG_EXTERNAL_STDVARIANT_PATH}/include/mpark/variant.hpp") 9 | message( STATUS "std::variant is not found in \"${FG_EXTERNAL_STDVARIANT_PATH}\"" ) 10 | set( FG_EXTERNAL_STDVARIANT_PATH "${FG_EXTERNALS_PATH}/variant" CACHE PATH "" FORCE ) 11 | else () 12 | message( STATUS "std::variant found in \"${FG_EXTERNAL_STDVARIANT_PATH}\"" ) 13 | endif () 14 | 15 | # download 16 | if (NOT EXISTS "${FG_EXTERNAL_STDVARIANT_PATH}" AND NOT CMAKE_VERSION VERSION_LESS 3.11.0) 17 | FetchContent_Declare( ExternalStdVar 18 | GIT_REPOSITORY https://github.com/mpark/variant.git 19 | SOURCE_DIR "${FG_EXTERNAL_STDVARIANT_PATH}" 20 | GIT_TAG master 21 | ) 22 | 23 | FetchContent_GetProperties( ExternalStdVar ) 24 | if (NOT ExternalStdVar_POPULATED) 25 | message( STATUS "downloading std::variant" ) 26 | FetchContent_Populate( ExternalStdVar ) 27 | endif () 28 | endif () 29 | 30 | add_library( "StdVariant-lib" INTERFACE ) 31 | target_include_directories( "StdVariant-lib" INTERFACE "${FG_EXTERNAL_STDVARIANT_PATH}/include" ) 32 | target_compile_definitions( "StdVariant-lib" INTERFACE "FG_ENABLE_VARIANT" ) 33 | endif () 34 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/download_vk.cmake: -------------------------------------------------------------------------------- 1 | # Find or download Vulkan headers 2 | 3 | if (NOT CMAKE_VERSION VERSION_LESS 3.7.0) 4 | # find_package( Vulkan ) 5 | endif () 6 | 7 | 8 | if (NOT Vulkan_FOUND) 9 | if (EXISTS "${FG_EXTERNALS_PATH}/vulkan/vulkan_core.h") 10 | set( Vulkan_INCLUDE_DIRS "${FG_EXTERNALS_PATH}" ) 11 | set( Vulkan_FOUND TRUE ) 12 | 13 | elseif (EXISTS "${FG_EXTERNALS_PATH}/vulkan/include/vulkan/vulkan_core.h") 14 | set( Vulkan_INCLUDE_DIRS "${FG_EXTERNALS_PATH}/vulkan/include" ) 15 | set( Vulkan_FOUND TRUE ) 16 | 17 | elseif (EXISTS "${FG_EXTERNALS_PATH}/Vulkan-Headers/include/vulkan/vulkan_core.h") 18 | set( Vulkan_INCLUDE_DIRS "${FG_EXTERNALS_PATH}/Vulkan-Headers/include" ) 19 | set( Vulkan_FOUND TRUE ) 20 | endif () 21 | endif () 22 | 23 | # select version 24 | if (${FG_EXTERNALS_USE_STABLE_VERSIONS}) 25 | set( VULKAN_HEADERS_TAG "v1.1.121" ) 26 | else () 27 | set( VULKAN_HEADERS_TAG "master" ) 28 | endif () 29 | 30 | # download 31 | if (NOT Vulkan_FOUND AND NOT CMAKE_VERSION VERSION_LESS 3.11.0) 32 | FetchContent_Declare( ExternalVulkanHeaders 33 | GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git 34 | GIT_TAG ${VULKAN_HEADERS_TAG} 35 | SOURCE_DIR "${FG_EXTERNALS_PATH}/Vulkan-Headers" 36 | ) 37 | 38 | FetchContent_GetProperties( ExternalVulkanHeaders ) 39 | if (NOT ExternalVulkanHeaders_POPULATED) 40 | message( STATUS "downloading Vulkan-Headers" ) 41 | FetchContent_Populate( ExternalVulkanHeaders ) 42 | endif () 43 | 44 | set( Vulkan_INCLUDE_DIRS "${FG_EXTERNALS_PATH}/Vulkan-Headers/include" ) 45 | set( Vulkan_FOUND TRUE ) 46 | endif () 47 | 48 | 49 | if (NOT Vulkan_FOUND) 50 | message( FATAL_ERROR "Vulkan headers is not found! Install VulkanSDK or download from https://github.com/KhronosGroup/Vulkan-Headers" ) 51 | endif () 52 | 53 | set( FG_VULKAN_DEFINITIONS "FG_ENABLE_VULKAN" ) 54 | 55 | if (FALSE) 56 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 57 | set( FG_VULKAN_DEFINITIONS "${FG_VULKAN_DEFINITIONS}" "VK_USE_PLATFORM_XCB_KHR=1" "VK_USE_PLATFORM_XLIB_KHR=1" ) # TODO 58 | 59 | elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Android") 60 | set( FG_VULKAN_DEFINITIONS "${FG_VULKAN_DEFINITIONS}" "-VK_USE_PLATFORM_ANDROID_KHR=1" ) 61 | 62 | elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") 63 | set( FG_VULKAN_DEFINITIONS "${FG_VULKAN_DEFINITIONS}" "VK_USE_PLATFORM_MACOS_MVK=1" ) 64 | 65 | elseif (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") 66 | set( FG_VULKAN_DEFINITIONS "${FG_VULKAN_DEFINITIONS}" "VK_USE_PLATFORM_IOS_MVK=1" ) 67 | 68 | elseif (WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 69 | set( FG_VULKAN_DEFINITIONS "${FG_VULKAN_DEFINITIONS}" "VK_USE_PLATFORM_WIN32_KHR=1" ) 70 | set( FG_VULKAN_DEFINITIONS "${FG_VULKAN_DEFINITIONS}" "NOMINMAX" "NOMCX" "NOIME" "NOSERVICE" "WIN32_LEAN_AND_MEAN" ) 71 | endif () 72 | endif () 73 | 74 | 75 | add_library( "Vulkan-lib" INTERFACE ) 76 | target_include_directories( "Vulkan-lib" INTERFACE "${Vulkan_INCLUDE_DIRS}" ) 77 | target_compile_definitions( "Vulkan-lib" INTERFACE "${FG_VULKAN_DEFINITIONS}" ) 78 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/download_vma.cmake: -------------------------------------------------------------------------------- 1 | # find or download Vulkan Memory Allocator 2 | 3 | if (${FG_ENABLE_VMA}) 4 | set( FG_EXTERNAL_VMA_PATH "" CACHE PATH "path to VulkanMemoryAllocator source" ) 5 | mark_as_advanced( FG_EXTERNAL_VMA_PATH ) 6 | 7 | # reset to default 8 | if (NOT EXISTS "${FG_EXTERNAL_VMA_PATH}/src/vk_mem_alloc.h") 9 | message( STATUS "VulkanMemoryAllocator is not found in \"${FG_EXTERNAL_VMA_PATH}\"" ) 10 | set( FG_EXTERNAL_VMA_PATH "${FG_EXTERNALS_PATH}/VulkanMemoryAllocator" CACHE PATH "" FORCE ) 11 | else () 12 | message( STATUS "VulkanMemoryAllocator found in \"${FG_EXTERNAL_VMA_PATH}\"" ) 13 | endif () 14 | 15 | # select version 16 | if (${FG_EXTERNALS_USE_STABLE_VERSIONS}) 17 | set( VMA_TAG "v2.2.0" ) 18 | else () 19 | set( VMA_TAG "master" ) 20 | endif () 21 | 22 | # download 23 | if (NOT EXISTS "${FG_EXTERNAL_VMA_PATH}" AND NOT CMAKE_VERSION VERSION_LESS 3.11.0) 24 | FetchContent_Declare( ExternalVMA 25 | GIT_REPOSITORY https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git 26 | SOURCE_DIR "${FG_EXTERNAL_VMA_PATH}" 27 | GIT_TAG ${VMA_TAG} 28 | ) 29 | 30 | FetchContent_GetProperties( ExternalVMA ) 31 | if (NOT ExternalVMA_POPULATED) 32 | message( STATUS "downloading VulkanMemoryAllocator" ) 33 | FetchContent_Populate( ExternalVMA ) 34 | endif () 35 | endif () 36 | 37 | add_library( "VMA-lib" INTERFACE ) 38 | target_include_directories( "VMA-lib" INTERFACE "${FG_EXTERNAL_VMA_PATH}/src" ) 39 | target_compile_definitions( "VMA-lib" INTERFACE "FG_ENABLE_VULKAN_MEMORY_ALLOCATOR" ) 40 | endif () 41 | -------------------------------------------------------------------------------- /external/FrameGraph/cmake/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/azhirnov/RDCtoVkCpp/4470fa7e2a9dba42beaf7a5317339257ec38e9ae/external/FrameGraph/cmake/main.cpp -------------------------------------------------------------------------------- /external/FrameGraph/cmake/project_template.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | set( CMAKE_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ) 4 | file( GLOB_RECURSE CMAKE_SOURCES "${CMAKE_FOLDER}/*.*" ) 5 | 6 | add_library( "ProjectTemplate" STATIC EXCLUDE_FROM_ALL ${CMAKE_SOURCES} ) 7 | set_property( TARGET "ProjectTemplate" PROPERTY FOLDER "Utils" ) 8 | source_group( TREE "${CMAKE_FOLDER}/.." FILES ${CMAKE_SOURCES} ) 9 | 10 | target_compile_definitions( "ProjectTemplate" PUBLIC ${FG_COMPILER_DEFINITIONS} ) 11 | target_link_libraries( "ProjectTemplate" PUBLIC "${FG_LINK_LIBRARIES}" ) 12 | 13 | # Debug 14 | if (PROJECTS_SHARED_CXX_FLAGS_DEBUG) 15 | target_compile_options( "ProjectTemplate" PUBLIC $<$: ${PROJECTS_SHARED_CXX_FLAGS_DEBUG}> ) 16 | endif() 17 | if (PROJECTS_SHARED_DEFINES_DEBUG) 18 | target_compile_definitions( "ProjectTemplate" PUBLIC $<$: ${PROJECTS_SHARED_DEFINES_DEBUG}> ) 19 | endif() 20 | if (PROJECTS_SHARED_LINKER_FLAGS_DEBUG) 21 | set_target_properties( "ProjectTemplate" PROPERTIES LINK_FLAGS_DEBUG ${PROJECTS_SHARED_LINKER_FLAGS_DEBUG} ) 22 | endif() 23 | 24 | # Release 25 | if (PROJECTS_SHARED_CXX_FLAGS_RELEASE) 26 | target_compile_options( "ProjectTemplate" PUBLIC $<$: ${PROJECTS_SHARED_CXX_FLAGS_RELEASE}> ) 27 | endif() 28 | if (PROJECTS_SHARED_DEFINES_RELEASE) 29 | target_compile_definitions( "ProjectTemplate" PUBLIC $<$: ${PROJECTS_SHARED_DEFINES_RELEASE}> ) 30 | endif() 31 | if (PROJECTS_SHARED_LINKER_FLAGS_RELEASE) 32 | set_target_properties( "ProjectTemplate" PROPERTIES LINK_FLAGS_RELEASE ${PROJECTS_SHARED_LINKER_FLAGS_RELEASE} ) 33 | endif() 34 | 35 | # Profile 36 | if (PROJECTS_SHARED_DEFINES_PROFILE) 37 | target_compile_definitions( "ProjectTemplate" PUBLIC $<$: ${PROJECTS_SHARED_DEFINES_PROFILE}> ) 38 | endif() 39 | if (PROJECTS_SHARED_LINKER_FLAGS_PROFILE) 40 | set_target_properties( "ProjectTemplate" PROPERTIES LINK_FLAGS_PROFILE ${PROJECTS_SHARED_LINKER_FLAGS_PROFILE} ) 41 | endif() 42 | if (PROJECTS_SHARED_CXX_FLAGS_PROFILE) 43 | target_compile_options( "ProjectTemplate" PUBLIC $<$: ${PROJECTS_SHARED_CXX_FLAGS_PROFILE}> ) 44 | endif() 45 | 46 | set_target_properties( "ProjectTemplate" PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES ) 47 | target_compile_features( "ProjectTemplate" PUBLIC cxx_std_17 ) 48 | 49 | if (FG_CI_BUILD) 50 | target_compile_definitions( "ProjectTemplate" PUBLIC "FG_CI_BUILD" ) 51 | endif() 52 | 53 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | file( GLOB_RECURSE SOURCES "*.*" ) 4 | add_library( "Framework" STATIC ${SOURCES} ) 5 | source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ) 6 | target_include_directories( "Framework" PUBLIC ".." ) 7 | set_property( TARGET "Framework" PROPERTY FOLDER "Extensions" ) 8 | 9 | target_link_libraries( "Framework" PUBLIC "VulkanLoader" ) 10 | 11 | if (${FG_ENABLE_GLFW}) 12 | target_link_libraries( "Framework" PUBLIC "GLFW-lib" ) 13 | endif() 14 | if (${FG_ENABLE_SDL2}) 15 | target_link_libraries( "Framework" PUBLIC "SDL2-lib" ) 16 | endif() 17 | 18 | install( TARGETS "Framework" ARCHIVE DESTINATION "lib" ) 19 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/Vulkan/VulkanSurface.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "VulkanSurface.h" 4 | #include "stl/Algorithms/Cast.h" 5 | 6 | #if defined(PLATFORM_WINDOWS) && !defined(VK_USE_PLATFORM_WIN32_KHR) 7 | # include "stl/Platforms/WindowsHeader.h" 8 | # define VK_USE_PLATFORM_WIN32_KHR 1 9 | # include 10 | #endif 11 | 12 | namespace FGC 13 | { 14 | 15 | /* 16 | ================================================= 17 | GetRequiredExtensions 18 | ================================================= 19 | */ 20 | Array VulkanSurface::GetRequiredExtensions () 21 | { 22 | Array ext; 23 | 24 | # if defined(VK_USE_PLATFORM_ANDROID_KHR) and VK_USE_PLATFORM_ANDROID_KHR 25 | ext.push_back( VK_KHR_ANDROID_SURFACE_EXTENSION_NAME ); 26 | # endif 27 | 28 | # if defined(VK_USE_PLATFORM_IOS_MVK) and VK_USE_PLATFORM_IOS_MVK 29 | ext.push_back( VK_MVK_IOS_SURFACE_EXTENSION_NAME ); 30 | # endif 31 | 32 | # if defined(VK_USE_PLATFORM_MACOS_MVK) and VK_USE_PLATFORM_MACOS_MVK 33 | ext.push_back( VK_MVK_MACOS_SURFACE_EXTENSION_NAME ); 34 | # endif 35 | 36 | # if defined(VK_USE_PLATFORM_WIN32_KHR) and VK_USE_PLATFORM_WIN32_KHR 37 | ext.push_back( VK_KHR_WIN32_SURFACE_EXTENSION_NAME ); 38 | # endif 39 | 40 | # if defined(VK_USE_PLATFORM_MIR_KHR) and VK_USE_PLATFORM_MIR_KHR 41 | ext.push_back( VK_KHR_MIR_SURFACE_EXTENSION_NAME ); 42 | # endif 43 | 44 | # if defined(VK_USE_PLATFORM_XCB_KHR) and VK_USE_PLATFORM_XCB_KHR 45 | ext.push_back( VK_KHR_XCB_SURFACE_EXTENSION_NAME ); 46 | # endif 47 | 48 | # if defined(VK_USE_PLATFORM_XLIB_KHR) and VK_USE_PLATFORM_XLIB_KHR 49 | ext.push_back( VK_KHR_XLIB_SURFACE_EXTENSION_NAME ); 50 | # endif 51 | 52 | # if defined(VK_USE_PLATFORM_XLIB_XRANDR_EXT) and VK_USE_PLATFORM_XLIB_XRANDR_EXT 53 | ext.push_back( VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME ); 54 | # endif 55 | 56 | # if defined(VK_USE_PLATFORM_WAYLAND_KHR) and VK_USE_PLATFORM_WAYLAND_KHR 57 | ext.push_back( VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME ); 58 | # endif 59 | 60 | return ext; 61 | } 62 | 63 | 64 | # if defined(VK_USE_PLATFORM_WIN32_KHR) and VK_USE_PLATFORM_WIN32_KHR 65 | /* 66 | ================================================= 67 | CreateWin32Surface 68 | ================================================= 69 | */ 70 | VkSurfaceKHR VulkanSurface::CreateWin32Surface (VkInstance instance, void* hinstance, void* hwnd) 71 | { 72 | CHECK_ERR( instance and hinstance and hwnd ); 73 | 74 | VkSurfaceKHR surface; 75 | VkWin32SurfaceCreateInfoKHR surface_info = {}; 76 | 77 | surface_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; 78 | surface_info.hinstance = HINSTANCE(hinstance); 79 | surface_info.hwnd = HWND(hwnd); 80 | 81 | PFN_vkCreateWin32SurfaceKHR fpCreateWin32SurfaceKHR = BitCast( vkGetInstanceProcAddr( instance, "vkCreateWin32SurfaceKHR" )); 82 | CHECK_ERR( fpCreateWin32SurfaceKHR ); 83 | 84 | VK_CHECK( fpCreateWin32SurfaceKHR( instance, &surface_info, null, OUT &surface )); 85 | return surface; 86 | } 87 | # endif 88 | 89 | 90 | # if defined(VK_USE_PLATFORM_ANDROID_KHR) and VK_USE_PLATFORM_ANDROID_KHR 91 | /* 92 | ================================================= 93 | CreateAndroidSurface 94 | ================================================= 95 | */ 96 | VkSurfaceKHR VulkanSurface::CreateAndroidSurface (VkInstance instance, void* window) 97 | { 98 | CHECK_ERR( instance and window ); 99 | 100 | VkSurfaceKHR surface; 101 | VkAndroidSurfaceCreateInfoKHR surface_info = {}; 102 | 103 | surface_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; 104 | surface_info.flags = 0; 105 | surface_info.window = Cast(window); 106 | 107 | PFN_vkCreateAndroidSurfaceKHR fpCreateAndroidSurfaceKHR = BitCast( vkGetInstanceProcAddr( instance, "vkCreateAndroidSurfaceKHR" )); 108 | CHECK_ERR( fpCreateAndroidSurfaceKHR ); 109 | 110 | VK_CHECK( fpCreateAndroidSurfaceKHR( instance, &surface_info, null, OUT &surface )); 111 | return surface; 112 | } 113 | # endif 114 | 115 | } // FGC 116 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/Vulkan/VulkanSurface.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "framework/Vulkan/VulkanDevice.h" 6 | 7 | namespace FGC 8 | { 9 | 10 | // 11 | // Vulkan Surface Helper 12 | // 13 | 14 | class VulkanSurface final 15 | { 16 | public: 17 | VulkanSurface () = delete; 18 | ~VulkanSurface () = delete; 19 | 20 | ND_ static Array GetRequiredExtensions (); 21 | 22 | // Windows 23 | # if defined(PLATFORM_WINDOWS) 24 | ND_ static VkSurfaceKHR CreateWin32Surface (VkInstance instance, void* hinstance, void* hwnd); 25 | # endif 26 | 27 | // Android 28 | # if defined(PLATFORM_ANDROID) 29 | ND_ static VkSurfaceKHR CreateAndroidSurface (VkInstance instance, void* window); 30 | # endif 31 | }; 32 | 33 | } // FGC 34 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/Window/IWindow.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Math/Vec.h" 6 | #include "stl/Containers/FixedArray.h" 7 | #include "stl/Containers/NtStringView.h" 8 | #include "stl/Memory/MemUtils.h" 9 | #include "vulkan_loader/VulkanLoader.h" 10 | #include "vulkan_loader/VulkanCheckError.h" 11 | 12 | namespace FGC 13 | { 14 | 15 | // 16 | // Window Event Listener interface 17 | // 18 | 19 | class IWindowEventListener 20 | { 21 | // types 22 | public: 23 | enum class EKeyAction { 24 | Up, // signle event when key up 25 | Down, // single event when key down 26 | Pressed, // continiously event until key is pressed 27 | }; 28 | 29 | // interface 30 | public: 31 | virtual void OnResize (const uint2 &size) = 0; 32 | virtual void OnRefresh () = 0; 33 | virtual void OnDestroy () = 0; 34 | virtual void OnUpdate () = 0; 35 | virtual void OnKey (StringView key, EKeyAction action) = 0; 36 | virtual void OnMouseMove (const float2 &pos) = 0; 37 | }; 38 | 39 | 40 | 41 | // 42 | // Vulkan Surface interface 43 | // 44 | 45 | class IVulkanSurface 46 | { 47 | public: 48 | virtual ~IVulkanSurface () {} 49 | ND_ virtual ArrayView GetRequiredExtensions () const = 0; 50 | ND_ virtual VkSurfaceKHR Create (VkInstance inst) const = 0; 51 | }; 52 | 53 | 54 | 55 | // 56 | // Window interface 57 | // 58 | 59 | class IWindow 60 | { 61 | // types 62 | protected: 63 | using EKeyAction = IWindowEventListener::EKeyAction; 64 | 65 | // interface 66 | public: 67 | virtual ~IWindow () {} 68 | virtual bool Create (uint2 size, NtStringView title) = 0; 69 | virtual void AddListener (IWindowEventListener *listener) = 0; 70 | virtual void RemoveListener (IWindowEventListener *listener) = 0; 71 | virtual bool Update () = 0; 72 | virtual void Quit () = 0; 73 | virtual void Destroy () = 0; 74 | virtual void SetTitle (NtStringView value) = 0; 75 | virtual void SetSize (const uint2 &value) = 0; 76 | virtual void SetPosition (const int2 &value) = 0; 77 | 78 | ND_ virtual uint2 GetSize () const = 0; 79 | 80 | ND_ virtual UniquePtr GetVulkanSurface () const = 0; 81 | }; 82 | 83 | 84 | using WindowPtr = UniquePtr< IWindow >; 85 | 86 | } // FGC 87 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/Window/WindowGLFW.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "framework/Window/IWindow.h" 6 | 7 | #ifdef FG_ENABLE_GLFW 8 | # include "GLFW/glfw3.h" 9 | 10 | namespace FGC 11 | { 12 | 13 | // 14 | // GLFW Window 15 | // 16 | 17 | class WindowGLFW final : public IWindow 18 | { 19 | // types 20 | private: 21 | struct VulkanSurface final : public IVulkanSurface 22 | { 23 | private: 24 | GLFWwindow * _window; 25 | 26 | public: 27 | explicit VulkanSurface (GLFWwindow *wnd) : _window{wnd} {} 28 | 29 | ND_ ArrayView GetRequiredExtensions () const override; 30 | ND_ VkSurfaceKHR Create (VkInstance inst) const override; 31 | }; 32 | 33 | using Listeners_t = HashSet< IWindowEventListener *>; 34 | 35 | using ActiveKeys_t = Array>; 36 | 37 | 38 | // variables 39 | private: 40 | GLFWwindow * _window; 41 | Listeners_t _listeners; 42 | ActiveKeys_t _activeKeys; 43 | 44 | 45 | // methods 46 | public: 47 | WindowGLFW (); 48 | ~WindowGLFW () override; 49 | 50 | bool Create (uint2 size, NtStringView title) override; 51 | void AddListener (IWindowEventListener *listener) override; 52 | void RemoveListener (IWindowEventListener *listener) override; 53 | bool Update () override; 54 | void Quit () override; 55 | void Destroy () override; 56 | 57 | void SetTitle (NtStringView value) override; 58 | void SetSize (const uint2 &value) override; 59 | void SetPosition (const int2 &value) override; 60 | 61 | uint2 GetSize () const override; 62 | 63 | UniquePtr GetVulkanSurface () const override; 64 | 65 | 66 | private: 67 | static void _GLFW_ErrorCallback (int code, const char* msg); 68 | static void _GLFW_RefreshCallback (GLFWwindow* wnd); 69 | static void _GLFW_ResizeCallback (GLFWwindow* wnd, int w, int h); 70 | static void _GLFW_KeyCallback (GLFWwindow* wnd, int key, int, int, int); 71 | static void _GLFW_MouseButtonCallback (GLFWwindow* wnd, int button, int action, int mods); 72 | static void _GLFW_CursorPosCallback (GLFWwindow* wnd, double xpos, double ypos); 73 | static void _GLFW_MouseWheelCallback (GLFWwindow* wnd, double dx, double dy); 74 | 75 | void _OnKeyEvent (int key, int action); 76 | 77 | ND_ static StringView _MapKey (int key); 78 | }; 79 | 80 | 81 | } // FGC 82 | 83 | #endif // FG_ENABLE_GLFW 84 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/Window/WindowSDL2.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "framework/Window/IWindow.h" 6 | 7 | #ifdef FG_ENABLE_SDL2 8 | # ifdef COMPILER_MSVC 9 | # pragma warning (push) 10 | # pragma warning (disable: 4005) // macros redefinition 11 | # pragma warning (disable: 4668) // '...' is not defined as a preprocessor macro 12 | # endif 13 | 14 | # define SDL_MAIN_HANDLED 15 | # include "SDL.h" 16 | 17 | # ifdef COMPILER_MSVC 18 | # pragma warning (pop) 19 | # endif 20 | 21 | 22 | namespace FGC 23 | { 24 | 25 | // 26 | // SDL2 Window 27 | // 28 | 29 | class WindowSDL2 final : public IWindow 30 | { 31 | // types 32 | private: 33 | struct VulkanSurface final : public IVulkanSurface 34 | { 35 | private: 36 | SDL_Window * _window; 37 | Array _extensions; 38 | 39 | public: 40 | explicit VulkanSurface (SDL_Window *wnd); 41 | 42 | ND_ ArrayView GetRequiredExtensions () const override { return _extensions; } 43 | ND_ VkSurfaceKHR Create (VkInstance inst) const override; 44 | }; 45 | 46 | using Listeners_t = HashSet< IWindowEventListener *>; 47 | using KeyStates_t = StaticArray< EKeyAction, SDL_NUM_SCANCODES+10 >; 48 | 49 | using ActiveKeys_t = Array>; 50 | 51 | 52 | // variables 53 | private: 54 | SDL_Window * _window; 55 | uint _wndID; 56 | Listeners_t _listeners; 57 | KeyStates_t _keyStates; 58 | ActiveKeys_t _activeKeys; 59 | 60 | 61 | // methods 62 | public: 63 | WindowSDL2 (); 64 | ~WindowSDL2 () override; 65 | 66 | bool Create (uint2 size, NtStringView title) override; 67 | void AddListener (IWindowEventListener *listener) override; 68 | void RemoveListener (IWindowEventListener *listener) override; 69 | bool Update () override; 70 | void Quit () override; 71 | void Destroy () override; 72 | 73 | void SetTitle (NtStringView value) override; 74 | void SetSize (const uint2 &value) override; 75 | void SetPosition (const int2 &value) override; 76 | 77 | uint2 GetSize () const override; 78 | 79 | UniquePtr GetVulkanSurface () const override; 80 | 81 | private: 82 | static StringView _MapKey (SDL_Scancode code); 83 | }; 84 | 85 | 86 | } // FGC 87 | 88 | #endif // FG_ENABLE_SDL2 89 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/Window/WindowSFML.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "WindowSFML.h" 4 | #include "framework/Vulkan/VulkanSurface.h" 5 | 6 | #ifdef FG_ENABLE_SFML 7 | 8 | namespace FGC 9 | { 10 | 11 | /* 12 | ================================================= 13 | constructor 14 | ================================================= 15 | */ 16 | WindowSFML::WindowSFML () 17 | { 18 | } 19 | 20 | /* 21 | ================================================= 22 | destructor 23 | ================================================= 24 | */ 25 | WindowSFML::~WindowSFML () 26 | { 27 | Destroy(); 28 | } 29 | 30 | /* 31 | ================================================= 32 | Create 33 | ================================================= 34 | */ 35 | bool WindowSFML::Create (uint2 size, StringView title) 36 | { 37 | CHECK_ERR( not _window.isOpen() ); 38 | 39 | _window.create( sf::VideoMode(size.x, size.y), String(title), sf::Style::Titlebar | sf::Style::Resize | sf::Style::Close ); 40 | CHECK_ERR( _window.isOpen() ); 41 | 42 | return true; 43 | } 44 | 45 | /* 46 | ================================================= 47 | AddListener 48 | ================================================= 49 | */ 50 | void WindowSFML::AddListener (IWindowEventListener *listener) 51 | { 52 | ASSERT( listener ); 53 | _listeners.insert( listener ); 54 | } 55 | 56 | /* 57 | ================================================= 58 | RemoveListener 59 | ================================================= 60 | */ 61 | void WindowSFML::RemoveListener (IWindowEventListener *listener) 62 | { 63 | ASSERT( listener ); 64 | _listeners.erase( listener ); 65 | } 66 | 67 | /* 68 | ================================================= 69 | Update 70 | ================================================= 71 | */ 72 | bool WindowSFML::Update () 73 | { 74 | if ( not _window.isOpen() ) 75 | return false; 76 | 77 | sf::Event event; 78 | while ( _window.pollEvent( OUT event ) ) 79 | { 80 | if ( event.type == sf::Event::Closed ) { 81 | Quit(); 82 | } 83 | } 84 | 85 | for (auto& listener : _listeners) { 86 | listener->OnUpdate(); 87 | } 88 | return true; 89 | } 90 | 91 | /* 92 | ================================================= 93 | Quit 94 | ================================================= 95 | */ 96 | void WindowSFML::Quit () 97 | { 98 | Destroy(); 99 | } 100 | 101 | /* 102 | ================================================= 103 | Destroy 104 | ================================================= 105 | */ 106 | void WindowSFML::Destroy () 107 | { 108 | Listeners_t listeners; 109 | std::swap( listeners, _listeners ); 110 | 111 | for (auto& listener : listeners) { 112 | listener->OnDestroy(); 113 | } 114 | 115 | _window.close(); 116 | } 117 | 118 | /* 119 | ================================================= 120 | SetTitle 121 | ================================================= 122 | */ 123 | void WindowSFML::SetTitle (StringView value) 124 | { 125 | CHECK_ERR( _window.isOpen(), void() ); 126 | 127 | _window.setTitle( String(value) ); 128 | } 129 | 130 | /* 131 | ================================================= 132 | SetSize 133 | ================================================= 134 | */ 135 | void WindowSFML::SetSize (const uint2 &value) 136 | { 137 | CHECK_ERR( _window.isOpen(), void() ); 138 | 139 | _window.setSize({ int(value.x), int(value.y) }); 140 | } 141 | 142 | /* 143 | ================================================= 144 | SetPosition 145 | ================================================= 146 | */ 147 | void WindowSFML::SetPosition (const int2 &value) 148 | { 149 | CHECK_ERR( _window.isOpen(), void() ); 150 | 151 | _window.setPosition({ value.x, value.y }); 152 | } 153 | 154 | /* 155 | ================================================= 156 | GetSize 157 | ================================================= 158 | */ 159 | uint2 WindowSFML::GetSize () const 160 | { 161 | CHECK_ERR( _window.isOpen() ); 162 | 163 | auto size = _window.getSize(); 164 | return uint2{ size.x, size.y }; 165 | } 166 | 167 | /* 168 | ================================================= 169 | GetVulkanSurface 170 | ================================================= 171 | */ 172 | UniquePtr WindowSFML::GetVulkanSurface () const 173 | { 174 | return UniquePtr{new VulkanSurface( &_window )}; 175 | } 176 | 177 | } // FGC 178 | //----------------------------------------------------------------------------- 179 | 180 | 181 | # if defined(PLATFORM_WINDOWS) or defined(VK_USE_PLATFORM_WIN32_KHR) 182 | # include "stl/Platforms/WindowsHeader.h" 183 | # endif 184 | 185 | namespace FGC 186 | { 187 | /* 188 | ================================================= 189 | VulkanSurface 190 | ================================================= 191 | */ 192 | WindowSFML::VulkanSurface::VulkanSurface (const sf::Window *wnd) : 193 | _window{wnd}, _extensions{FGC::VulkanSurface::GetRequiredExtensions()} 194 | {} 195 | 196 | /* 197 | ================================================= 198 | Create 199 | ================================================= 200 | */ 201 | VkSurfaceKHR WindowSFML::VulkanSurface::Create (VkInstance instance) const 202 | { 203 | # if defined(PLATFORM_WINDOWS) or defined(VK_USE_PLATFORM_WIN32_KHR) 204 | return FGC::VulkanSurface::CreateWin32Surface( instance, ::GetModuleHandle(LPCSTR(null)), _window->getSystemHandle() ); 205 | # endif 206 | } 207 | 208 | 209 | } // FGC 210 | 211 | #endif // FG_ENABLE_SFML 212 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/framework/Window/WindowSFML.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "framework/Window/IWindow.h" 6 | 7 | #ifdef FG_ENABLE_SFML 8 | # include 9 | 10 | namespace FGC 11 | { 12 | 13 | // 14 | // Window SFML 15 | // 16 | 17 | class WindowSFML final : public IWindow 18 | { 19 | // types 20 | private: 21 | struct VulkanSurface final : public IVulkanSurface 22 | { 23 | private: 24 | const sf::Window * _window; 25 | Array _extensions; 26 | 27 | public: 28 | explicit VulkanSurface (const sf::Window *wnd); 29 | 30 | ND_ ArrayView GetRequiredExtensions () const override { return _extensions; } 31 | ND_ VkSurfaceKHR Create (VkInstance inst) const override; 32 | }; 33 | 34 | using Listeners_t = HashSet< IWindowEventListener *>; 35 | 36 | 37 | // variables 38 | private: 39 | sf::Window _window; 40 | Listeners_t _listeners; 41 | 42 | 43 | // methods 44 | public: 45 | WindowSFML (); 46 | ~WindowSFML (); 47 | 48 | bool Create (uint2 size, StringView title) override; 49 | void AddListener (IWindowEventListener *listener) override; 50 | void RemoveListener (IWindowEventListener *listener) override; 51 | bool Update () override; 52 | void Quit () override; 53 | void Destroy () override; 54 | 55 | void SetTitle (StringView value) override; 56 | void SetSize (const uint2 &value) override; 57 | void SetPosition (const int2 &value) override; 58 | 59 | uint2 GetSize () const override; 60 | 61 | UniquePtr GetVulkanSurface () const override; 62 | }; 63 | 64 | 65 | } // FGC 66 | 67 | #endif // FG_ENABLE_SFML 68 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/vulkan_loader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | file( GLOB_RECURSE SOURCES "*.*" ) 4 | add_library( "VulkanLoader" STATIC ${SOURCES} ) 5 | source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ) 6 | target_include_directories( "VulkanLoader" PUBLIC ".." ) 7 | set_property( TARGET "VulkanLoader" PROPERTY FOLDER "Extensions" ) 8 | target_link_libraries( "VulkanLoader" PUBLIC "STL" ) 9 | target_link_libraries( "VulkanLoader" PUBLIC "Vulkan-lib" ) 10 | install( TARGETS "VulkanLoader" ARCHIVE DESTINATION "lib" ) 11 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/vulkan_loader/VulkanCheckError.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "stl/Algorithms/StringUtils.h" 4 | 5 | # define VK_NO_PROTOTYPES 6 | # include 7 | 8 | namespace FGC 9 | { 10 | 11 | /* 12 | ================================================= 13 | __vk_CheckErrors 14 | ================================================= 15 | */ 16 | bool __vk_CheckErrors (VkResult errCode, const char *vkcall, const char *func, const char *file, int line) 17 | { 18 | if ( errCode == VK_SUCCESS ) 19 | return true; 20 | 21 | #define VK1_CASE_ERR( _code_ ) \ 22 | case _code_ : msg += FG_PRIVATE_TOSTRING( _code_ ); break; 23 | 24 | String msg( "Vulkan error: " ); 25 | 26 | BEGIN_ENUM_CHECKS(); 27 | switch ( errCode ) 28 | { 29 | VK1_CASE_ERR( VK_NOT_READY ) 30 | VK1_CASE_ERR( VK_TIMEOUT ) 31 | VK1_CASE_ERR( VK_EVENT_SET ) 32 | VK1_CASE_ERR( VK_EVENT_RESET ) 33 | VK1_CASE_ERR( VK_INCOMPLETE ) 34 | VK1_CASE_ERR( VK_ERROR_OUT_OF_HOST_MEMORY ) 35 | VK1_CASE_ERR( VK_ERROR_OUT_OF_DEVICE_MEMORY ) 36 | VK1_CASE_ERR( VK_ERROR_INITIALIZATION_FAILED ) 37 | VK1_CASE_ERR( VK_ERROR_DEVICE_LOST ) 38 | VK1_CASE_ERR( VK_ERROR_MEMORY_MAP_FAILED ) 39 | VK1_CASE_ERR( VK_ERROR_LAYER_NOT_PRESENT ) 40 | VK1_CASE_ERR( VK_ERROR_EXTENSION_NOT_PRESENT ) 41 | VK1_CASE_ERR( VK_ERROR_FEATURE_NOT_PRESENT ) 42 | VK1_CASE_ERR( VK_ERROR_INCOMPATIBLE_DRIVER ) 43 | VK1_CASE_ERR( VK_ERROR_TOO_MANY_OBJECTS ) 44 | VK1_CASE_ERR( VK_ERROR_FORMAT_NOT_SUPPORTED ) 45 | VK1_CASE_ERR( VK_ERROR_FRAGMENTED_POOL ) 46 | VK1_CASE_ERR( VK_ERROR_SURFACE_LOST_KHR ) 47 | VK1_CASE_ERR( VK_ERROR_NATIVE_WINDOW_IN_USE_KHR ) 48 | VK1_CASE_ERR( VK_SUBOPTIMAL_KHR ) 49 | VK1_CASE_ERR( VK_ERROR_OUT_OF_DATE_KHR ) 50 | VK1_CASE_ERR( VK_ERROR_INCOMPATIBLE_DISPLAY_KHR ) 51 | VK1_CASE_ERR( VK_ERROR_VALIDATION_FAILED_EXT ) 52 | VK1_CASE_ERR( VK_ERROR_INVALID_SHADER_NV ) 53 | VK1_CASE_ERR( VK_ERROR_OUT_OF_POOL_MEMORY ) 54 | VK1_CASE_ERR( VK_ERROR_INVALID_EXTERNAL_HANDLE ) 55 | VK1_CASE_ERR( VK_ERROR_FRAGMENTATION_EXT ) 56 | VK1_CASE_ERR( VK_ERROR_NOT_PERMITTED_EXT ) 57 | VK1_CASE_ERR( VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT ) 58 | VK1_CASE_ERR( VK_ERROR_INVALID_DEVICE_ADDRESS_EXT ) 59 | VK1_CASE_ERR( VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT ) 60 | case VK_SUCCESS : 61 | case VK_RESULT_RANGE_SIZE : 62 | case VK_RESULT_MAX_ENUM : 63 | default : msg = msg + "unknown (" + ToString(int(errCode)) + ')'; break; 64 | } 65 | END_ENUM_CHECKS(); 66 | #undef VK1_CASE_ERR 67 | 68 | msg = msg + ", in " + vkcall + ", function: " + func; 69 | 70 | FG_LOGE( msg, file, line ); 71 | return false; 72 | } 73 | 74 | } // FGC 75 | -------------------------------------------------------------------------------- /external/FrameGraph/extensions/vulkan_loader/VulkanCheckError.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | 6 | #if 0 //ndef FG_DEBUG 7 | # define VK_CALL( ... ) { (void)(__VA_ARGS__); } 8 | # define VK_CHECK( ... ) { if ((__VA_ARGS__) != VK_SUCCESS) return false; } 9 | 10 | #else 11 | # define VK_CALL( ... ) \ 12 | { \ 13 | const ::VkResult __vk_err__ = (__VA_ARGS__); \ 14 | ::FGC::__vk_CheckErrors( __vk_err__, FG_PRIVATE_TOSTRING( __VA_ARGS__ ), FG_FUNCTION_NAME, __FILE__, __LINE__ ); \ 15 | } 16 | 17 | # define FG_PRIVATE_VK_CALL_R( _func_, _ret_, ... ) \ 18 | { \ 19 | const ::VkResult __vk_err__ = (_func_); \ 20 | if ( not ::FGC::__vk_CheckErrors( __vk_err__, FG_PRIVATE_TOSTRING( _func_ ), FG_FUNCTION_NAME, __FILE__, __LINE__ ) ) \ 21 | return _ret_; \ 22 | } 23 | 24 | # define VK_CHECK( ... ) \ 25 | FG_PRIVATE_VK_CALL_R( FG_PRIVATE_GETARG_0( __VA_ARGS__ ), FG_PRIVATE_GETARG_1( __VA_ARGS__, ::FGC::Default ) ) 26 | #endif 27 | 28 | 29 | namespace FGC 30 | { 31 | 32 | bool __vk_CheckErrors (VkResult errCode, const char *vkcall, const char *func, const char *file, int line); 33 | 34 | } // FGC 35 | -------------------------------------------------------------------------------- /external/FrameGraph/external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.6.0) 2 | 3 | set( FG_GLOBAL_DEFINITIONS "${FG_COMPILER_DEFINITIONS}" ) 4 | set( FG_EXTERNALS_PATH "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Path to external projects sources" ) 5 | set( FG_EXTERNALS_INSTALL_PATH "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Path to install external projects libraries" ) 6 | #message( STATUS "FG_EXTERNALS_PATH: ${FG_EXTERNALS_PATH}" ) 7 | #message( STATUS "FG_EXTERNALS_INSTALL_PATH: ${FG_EXTERNALS_INSTALL_PATH}" ) 8 | 9 | 10 | # prepare for FetchContent 11 | if (NOT CMAKE_VERSION VERSION_LESS 3.11.0) 12 | include(FetchContent) 13 | #set( FETCHCONTENT_FULLY_DISCONNECTED ON CACHE BOOL "don't download externals" ) 14 | set( FETCHCONTENT_UPDATES_DISCONNECTED ON CACHE BOOL "don't update externals" ) 15 | endif () 16 | 17 | 18 | # prepare for external projects 19 | if (TRUE) 20 | include( ExternalProject ) 21 | 22 | set( FG_LIST_SEPARATOR "|" ) 23 | string( REPLACE ";" "${FG_LIST_SEPARATOR}" FG_EXTERNAL_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" ) 24 | set( FG_BUILD_TARGET_FLAGS "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" 25 | "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" ) 26 | 27 | foreach ( CONFIG ${CMAKE_CONFIGURATION_TYPES} ) 28 | string( TOUPPER ${CONFIG} OUT_CONFIG ) 29 | 30 | set( FG_BUILD_TARGET_FLAGS 31 | "${FG_BUILD_TARGET_FLAGS}" 32 | "-DCMAKE_C_FLAGS_${OUT_CONFIG}=${CMAKE_C_FLAGS_${OUT_CONFIG}}" 33 | "-DCMAKE_CXX_FLAGS_${OUT_CONFIG}=${CMAKE_CXX_FLAGS_${OUT_CONFIG}}" 34 | "-DCMAKE_EXE_LINKER_FLAGS_${OUT_CONFIG}=${CMAKE_EXE_LINKER_FLAGS_${OUT_CONFIG}}" 35 | "-DCMAKE_STATIC_LINKER_FLAGS_${OUT_CONFIG}=${CMAKE_STATIC_LINKER_FLAGS_${OUT_CONFIG}}" 36 | "-DCMAKE_SHARED_LINKER_FLAGS_${OUT_CONFIG}=${CMAKE_SHARED_LINKER_FLAGS_${OUT_CONFIG}}" 37 | ) 38 | endforeach () 39 | endif () 40 | 41 | 42 | set( CMAKE_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/../cmake" ) 43 | 44 | include( "${CMAKE_FOLDER}/download_stdoptional.cmake" ) 45 | include( "${CMAKE_FOLDER}/download_stdvariant.cmake" ) 46 | include( "${CMAKE_FOLDER}/download_vk.cmake" ) 47 | include( "${CMAKE_FOLDER}/download_sdl2.cmake" ) 48 | include( "${CMAKE_FOLDER}/download_glfw.cmake" ) 49 | include( "${CMAKE_FOLDER}/download_glslang.cmake" ) 50 | include( "${CMAKE_FOLDER}/download_vma.cmake" ) 51 | 52 | 53 | set( FG_GLOBAL_DEFINITIONS "${FG_GLOBAL_DEFINITIONS}" CACHE INTERNAL "" FORCE ) 54 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Algorithms/Cast.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | #include "stl/Containers/Ptr.h" 7 | #include "stl/Math/BitMath.h" 8 | 9 | namespace FGC 10 | { 11 | 12 | /* 13 | ================================================= 14 | Cast 15 | ================================================= 16 | */ 17 | template 18 | ND_ forceinline SharedPtr Cast (const SharedPtr &other) 19 | { 20 | return std::static_pointer_cast( other ); 21 | } 22 | 23 | /* 24 | ================================================= 25 | DynCast 26 | ================================================= 27 | */ 28 | template 29 | ND_ forceinline SharedPtr DynCast (const SharedPtr &other) 30 | { 31 | return std::dynamic_pointer_cast( other ); 32 | } 33 | 34 | /* 35 | ================================================= 36 | CheckPointerAlignment 37 | ================================================= 38 | */ 39 | template 40 | ND_ forceinline bool CheckPointerAlignment (T const* ptr) 41 | { 42 | if constexpr( not std::is_void_v ) 43 | { 44 | constexpr size_t align = alignof(R); 45 | 46 | STATIC_ASSERT( IsPowerOfTwo( align ), "Align must be power of 2" ); 47 | 48 | return (sizeof(R) < align) or not (size_t(ptr) & (align-1)); 49 | } 50 | else 51 | { 52 | FG_UNUSED( ptr ); 53 | return true; 54 | } 55 | } 56 | 57 | /* 58 | ================================================= 59 | Cast 60 | ================================================= 61 | */ 62 | template 63 | ND_ forceinline constexpr R const volatile* Cast (T const volatile* value) 64 | { 65 | ASSERT( CheckPointerAlignment( value )); 66 | return static_cast< R const volatile *>( static_cast< void const volatile *>(value) ); 67 | } 68 | 69 | template 70 | ND_ forceinline constexpr R volatile* Cast (T volatile* value) 71 | { 72 | ASSERT( CheckPointerAlignment( value )); 73 | return static_cast< R volatile *>( static_cast< void volatile *>(value) ); 74 | } 75 | 76 | template 77 | ND_ forceinline constexpr R const* Cast (T const* value) 78 | { 79 | ASSERT( CheckPointerAlignment( value )); 80 | return static_cast< R const *>( static_cast< void const *>(value) ); 81 | } 82 | 83 | template 84 | ND_ forceinline constexpr R* Cast (T* value) 85 | { 86 | ASSERT( CheckPointerAlignment( value )); 87 | return static_cast< R *>( static_cast< void *>(value) ); 88 | } 89 | 90 | template 91 | ND_ forceinline constexpr Ptr Cast (Ptr value) 92 | { 93 | return Cast( value.operator->() ); 94 | } 95 | 96 | template 97 | ND_ forceinline constexpr Ptr Cast (Ptr value) 98 | { 99 | return Cast( value.operator->() ); 100 | } 101 | 102 | /* 103 | ================================================= 104 | DynCast 105 | ================================================= 106 | */ 107 | template 108 | ND_ forceinline constexpr R const* DynCast (T const* value) 109 | { 110 | return dynamic_cast< R const *>( value ); 111 | } 112 | 113 | template 114 | ND_ forceinline constexpr R* DynCast (T* value) 115 | { 116 | return dynamic_cast< R *>( value ); 117 | } 118 | 119 | template 120 | ND_ forceinline constexpr Ptr DynCast (Ptr value) 121 | { 122 | return DynCast( value.operator->() ); 123 | } 124 | 125 | template 126 | ND_ forceinline constexpr Ptr DynCast (Ptr value) 127 | { 128 | return DynCast( value.operator->() ); 129 | } 130 | 131 | /* 132 | ================================================= 133 | MakeShared 134 | ================================================= 135 | */ 136 | template 137 | ND_ forceinline SharedPtr MakeShared (Types&&... args) 138 | { 139 | return std::make_shared( std::forward( args )... ); 140 | } 141 | 142 | /* 143 | ================================================= 144 | MakeUnique 145 | ================================================= 146 | */ 147 | template 148 | ND_ forceinline UniquePtr MakeUnique (Types&&... args) 149 | { 150 | return std::make_unique( std::forward( args )... ); 151 | } 152 | 153 | /* 154 | ================================================= 155 | BitCast 156 | ================================================= 157 | */ 158 | template 159 | ND_ inline constexpr To BitCast (const From& src) 160 | { 161 | STATIC_ASSERT( sizeof(To) == sizeof(From), "must be same size!" ); 162 | STATIC_ASSERT( alignof(To) == alignof(From), "must be same align!" ); 163 | //STATIC_ASSERT( std::is_trivially_copyable::value and std::is_trivial::value, "must be trivial types!" ); 164 | 165 | To dst; 166 | std::memcpy( OUT &dst, &src, sizeof(To) ); 167 | return dst; 168 | } 169 | 170 | 171 | } // FGC 172 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Algorithms/EnumUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | 7 | namespace FGC 8 | { 9 | 10 | template 11 | using NearInt = Conditional< (sizeof(T) <= sizeof(int32_t)), int32_t, int64_t >; 12 | 13 | template 14 | using NearUInt = Conditional< (sizeof(T) <= sizeof(uint32_t)), uint32_t, uint64_t >; 15 | 16 | /* 17 | ================================================= 18 | EnumToUInt 19 | ================================================= 20 | */ 21 | template 22 | ND_ forceinline constexpr NearUInt EnumToUInt (const T &value) 23 | { 24 | STATIC_ASSERT( IsScalarOrEnum ); 25 | STATIC_ASSERT( sizeof(value) <= sizeof(NearUInt) ); 26 | 27 | return NearUInt( value ); 28 | } 29 | 30 | /* 31 | ================================================= 32 | EnumToInt 33 | ================================================= 34 | */ 35 | template 36 | ND_ forceinline constexpr NearInt EnumToInt (const T &value) 37 | { 38 | STATIC_ASSERT( IsScalarOrEnum ); 39 | STATIC_ASSERT( sizeof(value) <= sizeof(NearInt) ); 40 | 41 | return NearInt( value ); 42 | } 43 | 44 | /* 45 | ================================================= 46 | EnumEq 47 | ---- 48 | returns 'true' if 'lhs' has ALL bits that presented in 'rhs' 49 | ================================================= 50 | */ 51 | template 52 | ND_ forceinline constexpr bool EnumEq (const T1& lhs, const T2& rhs) 53 | { 54 | STATIC_ASSERT( IsScalarOrEnum< T1 > ); 55 | STATIC_ASSERT( IsScalarOrEnum< T2 > ); 56 | ASSERT( rhs != T2(0) ); 57 | 58 | return ( EnumToUInt(lhs) & EnumToUInt(rhs) ) == EnumToUInt(rhs); 59 | } 60 | 61 | /* 62 | ================================================= 63 | EnumAny 64 | ---- 65 | returns 'true' if 'lhs' has ANY bit that presented in 'rhs' 66 | ================================================= 67 | */ 68 | template 69 | ND_ forceinline constexpr bool EnumAny (const T1& lhs, const T2& rhs) 70 | { 71 | STATIC_ASSERT( IsScalarOrEnum< T1 > ); 72 | STATIC_ASSERT( IsScalarOrEnum< T2 > ); 73 | ASSERT( rhs != T2(0) ); 74 | 75 | return !!( EnumToUInt(lhs) & EnumToUInt(rhs) ); 76 | } 77 | 78 | } // FGC 79 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Algorithms/Hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include 6 | #include "stl/Log/Log.h" 7 | #include "stl/CompileTime/TypeTraits.h" 8 | 9 | namespace FGC 10 | { 11 | 12 | // 13 | // Hash Value 14 | // 15 | 16 | struct HashVal 17 | { 18 | // variables 19 | private: 20 | size_t _value = 0; 21 | 22 | // methods 23 | public: 24 | constexpr HashVal () {} 25 | explicit constexpr HashVal (size_t val) : _value{val} {} 26 | 27 | ND_ constexpr bool operator == (const HashVal &rhs) const { return _value == rhs._value; } 28 | ND_ constexpr bool operator != (const HashVal &rhs) const { return not (*this == rhs); } 29 | ND_ constexpr bool operator > (const HashVal &rhs) const { return _value > rhs._value; } 30 | ND_ constexpr bool operator < (const HashVal &rhs) const { return _value < rhs._value; } 31 | 32 | constexpr HashVal& operator << (const HashVal &rhs) 33 | { 34 | const size_t mask = (sizeof(_value)*8 - 1); 35 | size_t val = rhs._value; 36 | size_t shift = 8; 37 | 38 | shift &= mask; 39 | _value ^= (val << shift) | (val >> ( ~(shift-1) & mask )); // TODO: add constant 40 | 41 | return *this; 42 | } 43 | 44 | ND_ constexpr const HashVal operator + (const HashVal &rhs) const 45 | { 46 | return HashVal(*this) << rhs; 47 | } 48 | 49 | ND_ explicit constexpr operator size_t () const { return _value; } 50 | }; 51 | //----------------------------------------------------------------------------- 52 | 53 | 54 | 55 | /* 56 | ================================================= 57 | HashOf 58 | ================================================= 59 | */ 60 | template 61 | ND_ forceinline EnableIf, HashVal> HashOf (const T &value) 62 | { 63 | return HashVal( std::hash()( value )); 64 | } 65 | 66 | /* 67 | ================================================= 68 | HashOf (float) 69 | ================================================= 70 | */ 71 | ND_ forceinline HashVal HashOf (const float &value, uint32_t ignoreMantissaBits = (23-10)) 72 | { 73 | ASSERT( ignoreMantissaBits < 23 ); 74 | uint32_t dst; 75 | std::memcpy( OUT &dst, &value, sizeof(dst) ); 76 | dst &= ~((1 << ignoreMantissaBits)-1); 77 | return HashVal( std::hash()( dst )); 78 | } 79 | 80 | /* 81 | ================================================= 82 | HashOf (double) 83 | ================================================= 84 | */ 85 | ND_ forceinline HashVal HashOf (const double &value, uint32_t ignoreMantissaBits = (52-10)) 86 | { 87 | ASSERT( ignoreMantissaBits < 52 ); 88 | uint64_t dst; 89 | std::memcpy( OUT &dst, &value, sizeof(dst) ); 90 | dst &= ~((1 << ignoreMantissaBits)-1); 91 | return HashVal( std::hash()( dst )); 92 | } 93 | 94 | /* 95 | ================================================= 96 | HashOf (buffer) 97 | ---- 98 | use private api to calculate hash of buffer 99 | ================================================= 100 | */ 101 | ND_ forceinline HashVal HashOf (const void *ptr, size_t sizeInBytes) 102 | { 103 | ASSERT( ptr and sizeInBytes ); 104 | 105 | # if defined(FG_HAS_HASHFN_HashArrayRepresentation) 106 | return HashVal{std::_Hash_array_representation( static_cast(ptr), sizeInBytes )}; 107 | 108 | #elif defined(FG_HAS_HASHFN_Murmur2OrCityhash) 109 | return HashVal{std::__murmur2_or_cityhash()( ptr, sizeInBytes )}; 110 | 111 | #elif defined(FG_HAS_HASHFN_HashBytes) 112 | return HashVal{std::_Hash_bytes( ptr, sizeInBytes, 0 )}; 113 | 114 | #else 115 | FG_COMPILATION_MESSAGE( "used fallback hash function" ) 116 | const uint8_t* buf = static_cast(ptr); 117 | HashVal result; 118 | for (size_t i = 0; i < sizeInBytes; ++i) { 119 | result << HashVal{buf[i]}; 120 | } 121 | return result; 122 | #endif 123 | } 124 | 125 | } // FGC 126 | 127 | 128 | namespace std 129 | { 130 | template 131 | struct hash< std::pair > 132 | { 133 | ND_ size_t operator () (const std::pair &value) const 134 | { 135 | return size_t(FGC::HashOf( value.first ) + FGC::HashOf( value.second )); 136 | } 137 | }; 138 | 139 | } // std 140 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Algorithms/StringParser.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Algorithms/StringUtils.h" 6 | 7 | namespace FGC 8 | { 9 | 10 | // 11 | // String Parser 12 | // 13 | 14 | struct StringParser final 15 | { 16 | public: 17 | static void ToEndOfLine (StringView str, INOUT size_t &pos); 18 | static void ToBeginOfLine (StringView str, INOUT size_t &pos); 19 | static void ToNextLine (StringView str, INOUT size_t &pos); 20 | static void ToPrevLine (StringView str, INOUT size_t &pos); 21 | 22 | ND_ static bool IsBeginOfLine (StringView str, size_t pos); 23 | ND_ static bool IsEndOfLine (StringView str, size_t pos); 24 | 25 | ND_ static size_t CalculateNumberOfLines (StringView str); 26 | 27 | static bool MoveToLine (StringView str, INOUT size_t &pos, size_t lineNumber); 28 | 29 | static void ReadCurrLine (StringView str, INOUT size_t &pos, OUT StringView &result); 30 | static void ReadLineToEnd (StringView str, INOUT size_t &pos, OUT StringView &result); 31 | 32 | static bool ReadTo (StringView str, StringView endSymbol, INOUT size_t &pos, OUT StringView &result); 33 | 34 | static bool ReadString (StringView str, INOUT size_t &pos, OUT StringView &result); 35 | }; 36 | 37 | 38 | } // FGC 39 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | file( GLOB_RECURSE SOURCES "*.*" ) 4 | add_library( "STL" STATIC ${SOURCES} ) 5 | source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ) 6 | target_link_libraries( "STL" "ProjectTemplate" ) 7 | target_include_directories( "STL" PUBLIC ".." ) 8 | set_property( TARGET "STL" PROPERTY FOLDER "" ) 9 | 10 | if (UNIX) 11 | target_link_libraries( "STL" "dl;pthread" ) 12 | target_compile_definitions( "STL" PUBLIC _LARGEFILE_SOURCE ) 13 | target_compile_definitions( "STL" PUBLIC _LARGE_FILES ) 14 | target_compile_definitions( "STL" PUBLIC _FILE_OFFSET_BITS=64 ) 15 | endif() 16 | 17 | install( TARGETS "STL" ARCHIVE DESTINATION "lib" ) 18 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Common.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | /* 3 | Frame Graph Core library 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "stl/Defines.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include // shared_ptr, weak_ptr, unique_ptr 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "stl/Log/Log.h" 24 | #include "stl/Algorithms/Hash.h" 25 | #include "stl/CompileTime/TypeTraits.h" 26 | #include "stl/CompileTime/UMax.h" 27 | #include "stl/CompileTime/DefaultType.h" 28 | 29 | 30 | namespace FGC 31 | { 32 | using uint = uint32_t; 33 | 34 | using String = std::string; 35 | template using BasicString = std::basic_string< T >; 36 | 37 | template using Array = std::vector< T >; 38 | 39 | template using UniquePtr = std::unique_ptr< T >; 40 | 41 | template using SharedPtr = std::shared_ptr< T >; 42 | template using WeakPtr = std::weak_ptr< T >; 43 | 44 | template using Deque = std::deque< T >; 45 | 46 | template using BitSet = std::bitset< N >; 47 | 48 | template using Tuple = std::tuple< T... >; 49 | 50 | 51 | template 53 | using StaticArray = std::array< T, ArraySize >; 54 | 55 | 56 | template 58 | using Pair = std::pair< FirstT, SecondT >; 59 | 60 | 61 | template > 63 | using HashSet = std::unordered_set< T, Hasher >; 64 | 65 | 66 | template > 69 | using HashMap = std::unordered_map< Key, Value, Hasher >; 70 | 71 | 72 | # ifdef FG_OPTIMAL_MEMORY_ORDER 73 | static constexpr std::memory_order memory_order_acquire = std::memory_order_acquire; 74 | static constexpr std::memory_order memory_order_release = std::memory_order_release; 75 | static constexpr std::memory_order memory_order_acq_rel = std::memory_order_acq_rel; 76 | static constexpr std::memory_order memory_order_relaxed = std::memory_order_relaxed; 77 | # else 78 | static constexpr std::memory_order memory_order_acquire = std::memory_order_seq_cst; 79 | static constexpr std::memory_order memory_order_release = std::memory_order_seq_cst; 80 | static constexpr std::memory_order memory_order_acq_rel = std::memory_order_seq_cst; 81 | static constexpr std::memory_order memory_order_relaxed = std::memory_order_seq_cst; 82 | # endif // FG_OPTIMAL_MEMORY_ORDER 83 | 84 | 85 | } // FGC 86 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/CompileTime/DefaultType.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | 6 | namespace FGC 7 | { 8 | namespace _fgc_hidden_ 9 | { 10 | template 11 | struct _IsEnumWithUnknown2 { 12 | static const bool value = false; 13 | }; 14 | 15 | template 16 | struct _IsEnumWithUnknown2< T, true > { 17 | static const bool value = true; //Detect_Unknown::value; 18 | }; 19 | 20 | template 21 | static constexpr bool _IsEnumWithUnknown = _IsEnumWithUnknown2< T, IsEnum >::value; 22 | 23 | 24 | template 25 | struct _GetDefaultValueForUninitialized2 {}; 26 | 27 | template 28 | struct _GetDefaultValueForUninitialized2< T, 0 > { 29 | static T Get () { return T(); } 30 | }; 31 | 32 | template 33 | struct _GetDefaultValueForUninitialized2< T, /*int, float, pointer*/2 > { 34 | static T Get () { return T(0); } 35 | }; 36 | 37 | template 38 | struct _GetDefaultValueForUninitialized2< T, /*enum*/1 > { 39 | static T Get () { return T::Unknown; } 40 | }; 41 | 42 | 43 | template 44 | struct _GetDefaultValueForUninitialized 45 | { 46 | static constexpr int GetIndex () 47 | { 48 | return _IsEnumWithUnknown ? 1 : 49 | std::is_floating_point::value or 50 | std::is_integral::value or 51 | std::is_pointer::value or 52 | std::is_enum::value ? 2 : 53 | 0; 54 | } 55 | 56 | static constexpr T GetDefault () 57 | { 58 | return _GetDefaultValueForUninitialized2< T, GetIndex() >::Get(); 59 | } 60 | }; 61 | 62 | 63 | struct DefaultType final 64 | { 65 | constexpr DefaultType () 66 | {} 67 | 68 | template 69 | ND_ constexpr operator T () const 70 | { 71 | return _GetDefaultValueForUninitialized::GetDefault(); 72 | } 73 | 74 | template 75 | ND_ friend constexpr bool operator == (const T& lhs, const DefaultType &) 76 | { 77 | return lhs == _GetDefaultValueForUninitialized::GetDefault(); 78 | } 79 | 80 | template 81 | ND_ friend constexpr bool operator != (const T& lhs, const DefaultType &rhs) 82 | { 83 | return not (lhs == rhs); 84 | } 85 | }; 86 | 87 | } // _fgc_hidden_ 88 | 89 | 90 | static constexpr _fgc_hidden_::DefaultType Default = {}; 91 | 92 | } // FGC 93 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/CompileTime/Hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | 7 | namespace FGC 8 | { 9 | namespace _fgc_hidden_ 10 | { 11 | // from https://stackoverflow.com/questions/2111667/compile-time-string-hashing 12 | static constexpr uint crc_table[256] = { 13 | 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 14 | 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 15 | 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 16 | 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 17 | 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 18 | 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 19 | 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 20 | 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 21 | 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 22 | 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 23 | 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 24 | 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 25 | 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 26 | 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 27 | 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 28 | 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 29 | 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 30 | 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 31 | 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 32 | 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 33 | 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 34 | 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 35 | 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 36 | 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 37 | 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 38 | 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 39 | 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 40 | 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 41 | 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 42 | 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 43 | 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 44 | 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 45 | 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 46 | 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 47 | 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 48 | 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 49 | 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 50 | 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 51 | 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 52 | 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 53 | 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 54 | 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 55 | 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d 56 | }; 57 | 58 | ND_ forceinline constexpr uint crc32_hash (char const *str, size_t len, uint prev_crc) 59 | { 60 | return (*str and len) ? 61 | crc32_hash( str+1, len-1, (prev_crc >> 8) ^ crc_table[(prev_crc ^ *str) & 0xFF] ) : 62 | (prev_crc ^ 0xFFFFFFFF); 63 | } 64 | 65 | } // _fgc_hidden_ 66 | 67 | 68 | /* 69 | ================================================= 70 | CT_Hash (string) 71 | ================================================= 72 | */ 73 | ND_ inline constexpr HashVal CT_Hash (const char *str, size_t len, uint seed) 74 | { 75 | return HashVal{_fgc_hidden_::crc32_hash( str, len, seed )}; 76 | } 77 | 78 | 79 | } // FGC 80 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/CompileTime/Math.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | #include "stl/CompileTime/TypeTraits.h" 7 | 8 | namespace FGC 9 | { 10 | 11 | /* 12 | ================================================= 13 | CT_IntLog2 14 | ================================================= 15 | */ 16 | namespace _fgc_hidden_ 17 | { 18 | template 19 | struct _IntLog2 { 20 | static const int value = int((X >> Bit) != 0) + _IntLog2::value; 21 | }; 22 | 23 | template 24 | struct _IntLog2< T, X, 0 > { 25 | static const int value = 0; 26 | }; 27 | 28 | } // _fgc_hidden_ 29 | 30 | template 31 | static constexpr int CT_IntLog2 = (X ? _fgc_hidden_::_IntLog2< decltype(X), X, sizeof(X)*8-1 >::value : -1); 32 | 33 | 34 | /* 35 | ================================================= 36 | CT_Pow 37 | ================================================= 38 | */ 39 | template 40 | inline constexpr T CT_Pow (const T &base) 41 | { 42 | STATIC_ASSERT( IsInteger and IsInteger and Power >= 0 ); 43 | 44 | if constexpr( Power == 0 ) 45 | { 46 | FG_UNUSED( base ); 47 | return 1; 48 | } 49 | else 50 | return CT_Pow( base ) * base; 51 | } 52 | 53 | 54 | } // FGC 55 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/CompileTime/TypeList.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | 7 | namespace FGC 8 | { 9 | namespace _fgc_hidden_ 10 | { 11 | 12 | template 13 | struct TL_GetIndex; 14 | 15 | template 16 | struct TL_GetIndex< Type, I, std::tuple<> > 17 | { 18 | inline static constexpr size_t value = UMax; 19 | }; 20 | 21 | template 22 | struct TL_GetIndex< Type, I, std::tuple > 23 | { 24 | inline static constexpr size_t value = Conditional< IsSameTypes, 25 | std::integral_constant, TL_GetIndex< Type, I+1, std::tuple > >::value; 26 | }; 27 | 28 | } // _fgc_hidden_ 29 | 30 | 31 | // 32 | // Type List 33 | // 34 | 35 | template 36 | struct TypeList 37 | { 38 | public: 39 | template 40 | inline static constexpr size_t Index = _fgc_hidden_::TL_GetIndex< T, 0, std::tuple >::value; 41 | 42 | inline static constexpr size_t Count = std::tuple_size< std::tuple >::value; 43 | 44 | template 45 | inline static constexpr bool HasType = (Index != UMax); 46 | 47 | template 48 | using Get = typename std::tuple_element>::type; 49 | 50 | template 51 | using GetT = std::tuple_element>; 52 | 53 | struct Front { using type = Get<0>; }; 54 | struct Back { using type = Get; }; 55 | 56 | template 57 | static constexpr void Visit (FN&& fn) { return _Visit<0>( std::forward(fn) ); } 58 | 59 | private: 60 | template 61 | static constexpr void _Visit (FN&& fn) 62 | { 63 | if constexpr( I < Count ) 64 | { 65 | using T = Get; 66 | fn.template operator()(); 67 | _Visit< I+1 >( std::forward(fn) ); 68 | } 69 | FG_UNUSED( fn ); 70 | } 71 | }; 72 | 73 | 74 | template 75 | struct TypeList< std::tuple > final : TypeList< Types... > 76 | {}; 77 | 78 | 79 | } // FGC 80 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/CompileTime/TypeTraits.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | 8 | namespace FGC 9 | { 10 | 11 | template 12 | static constexpr bool IsFloatPoint = std::is_floating_point::value; 13 | 14 | template 15 | static constexpr bool IsInteger = std::is_integral::value; 16 | 17 | template 18 | static constexpr bool IsSignedInteger = std::is_integral::value && std::is_signed::value; 19 | 20 | template 21 | static constexpr bool IsUnsignedInteger = std::is_integral::value && std::is_unsigned::value; 22 | 23 | template 24 | static constexpr bool IsStaticArray = std::is_array::value; 25 | 26 | template 27 | static constexpr bool IsScalar = std::is_scalar::value; 28 | 29 | template 30 | static constexpr bool IsEnum = std::is_enum::value; 31 | 32 | template 33 | static constexpr bool IsScalarOrEnum = std::is_scalar::value or std::is_enum::value; 34 | 35 | template 36 | static constexpr bool IsPOD = std::is_pod::value; 37 | 38 | template 39 | static constexpr bool IsPointer = std::is_pointer::value; 40 | 41 | template 42 | static constexpr bool IsClass = std::is_class::value; 43 | 44 | template 45 | static constexpr bool IsUnion = std::is_union::value; 46 | 47 | template 48 | static constexpr bool IsConst = std::is_const::value; 49 | 50 | template 51 | static constexpr bool IsSameTypes = std::is_same::value; 52 | 53 | 54 | template 55 | using EnableIf = std::enable_if_t< Test, Type >; 56 | 57 | template 58 | using DisableIf = std::enable_if_t< !Test, Type >; 59 | 60 | 61 | template 62 | using Conditional = std::conditional_t< Test, IfTrue, IfFalse >; 63 | 64 | 65 | template 66 | using ToUnsignedInteger = Conditional< sizeof(T) == sizeof(uint64_t), uint64_t, 67 | Conditional< sizeof(T) == sizeof(uint32_t), uint32_t, 68 | Conditional< sizeof(T) == sizeof(uint16_t), uint16_t, 69 | Conditional< sizeof(T) == sizeof(uint8_t), uint8_t, 70 | void >>>>; 71 | 72 | template 73 | using ToSignedInteger = Conditional< sizeof(T) == sizeof(int64_t), int64_t, 74 | Conditional< sizeof(T) == sizeof(int32_t), int32_t, 75 | Conditional< sizeof(T) == sizeof(int16_t), int16_t, 76 | Conditional< sizeof(T) == sizeof(int8_t), int8_t, 77 | void >>>>; 78 | 79 | } // FGC 80 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/CompileTime/UMax.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | /* 3 | UMax constant is maximum value of unsigned integer type. 4 | */ 5 | 6 | #pragma once 7 | 8 | namespace FGC 9 | { 10 | namespace _fgc_hidden_ 11 | { 12 | struct _UMax 13 | { 14 | template 15 | ND_ constexpr operator const T () const 16 | { 17 | STATIC_ASSERT( T(~T(0)) > T(0) ); 18 | return T(~T(0)); 19 | } 20 | 21 | template 22 | ND_ friend constexpr bool operator == (const T& left, const _UMax &right) 23 | { 24 | return T(right) == left; 25 | } 26 | 27 | template 28 | ND_ friend constexpr bool operator != (const T& left, const _UMax &right) 29 | { 30 | return T(right) != left; 31 | } 32 | }; 33 | 34 | } // _fgc_hidden_ 35 | 36 | 37 | static constexpr _fgc_hidden_::_UMax UMax {}; 38 | 39 | } // FGC 40 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Config.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | 6 | #ifdef FG_DEBUG 7 | # define FG_ENABLE_DATA_RACE_CHECK 8 | #else 9 | //# define FG_OPTIMAL_MEMORY_ORDER 10 | #endif 11 | 12 | 13 | #define FG_FAST_HASH 0 14 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/ArrayView.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Math/Math.h" 6 | 7 | namespace FGC 8 | { 9 | 10 | // 11 | // Array View 12 | // 13 | 14 | template 15 | struct ArrayView 16 | { 17 | // types 18 | public: 19 | using value_type = T; 20 | using iterator = T *; 21 | using const_iterator = T const *; 22 | 23 | 24 | // variables 25 | private: 26 | union { 27 | T const * _array; 28 | T const (*_dbgView)[400]; // debug viewer, don't use this field! 29 | }; 30 | size_t _count = 0; 31 | 32 | 33 | // methods 34 | public: 35 | ArrayView () : _array{null} {} 36 | 37 | ArrayView (T const* ptr, size_t count) : _array{ptr}, _count{count} 38 | { 39 | ASSERT( (_count == 0) or (_array != null) ); 40 | } 41 | 42 | ArrayView (std::initializer_list list) : _array{list.begin()}, _count{list.size()} {} 43 | 44 | template 45 | ArrayView (const std::vector &vec) : _array{vec.data()}, _count{vec.size()} 46 | { 47 | ASSERT( (_count == 0) or (_array != null) ); 48 | } 49 | 50 | template 51 | ArrayView (const StaticArray &arr) : _array{arr.data()}, _count{arr.size()} {} 52 | 53 | template 54 | ArrayView (const T (&arr)[S]) : _array{arr}, _count{S} {} 55 | 56 | ND_ explicit operator Array () const { return Array{ begin(), end() }; } 57 | 58 | ND_ size_t size () const { return _count; } 59 | ND_ bool empty () const { return _count == 0; } 60 | ND_ T const * data () const { return _array; } 61 | 62 | ND_ T const & operator [] (size_t i) const { ASSERT( i < _count ); return _array[i]; } 63 | 64 | ND_ const_iterator begin () const { return _array; } 65 | ND_ const_iterator end () const { return _array + _count; } 66 | 67 | ND_ T const& front () const { ASSERT( _count > 0 ); return _array[0]; } 68 | ND_ T const& back () const { ASSERT( _count > 0 ); return _array[_count-1]; } 69 | 70 | 71 | ND_ bool operator == (ArrayView rhs) const 72 | { 73 | if ( size() != rhs.size() ) 74 | return false; 75 | 76 | for (size_t i = 0; i < size(); ++i) { 77 | if ( not (_array[i] == rhs[i]) ) 78 | return false; 79 | } 80 | return true; 81 | } 82 | 83 | ND_ bool operator > (ArrayView rhs) const 84 | { 85 | if ( size() != rhs.size() ) 86 | return size() > rhs.size(); 87 | 88 | for (size_t i = 0; i < size(); ++i) 89 | { 90 | if ( _array[i] != rhs[i] ) 91 | return _array[i] > rhs[i]; 92 | } 93 | return true; 94 | } 95 | 96 | ND_ bool operator != (ArrayView rhs) const { return not (*this == rhs); } 97 | ND_ bool operator < (ArrayView rhs) const { return (rhs > *this); } 98 | ND_ bool operator >= (ArrayView rhs) const { return not (*this < rhs); } 99 | ND_ bool operator <= (ArrayView rhs) const { return not (*this > rhs); } 100 | 101 | 102 | ND_ ArrayView section (size_t first, size_t count) const 103 | { 104 | return first < size() ? 105 | ArrayView{ data() + first, Min(size() - first, count) } : 106 | ArrayView{}; 107 | } 108 | }; 109 | 110 | 111 | } // FGC 112 | 113 | 114 | namespace std 115 | { 116 | template 117 | struct hash< FGC::ArrayView > 118 | { 119 | ND_ size_t operator () (const FGC::ArrayView &value) const 120 | { 121 | if constexpr ( FG_FAST_HASH and FGC::IsPOD ) 122 | { 123 | return size_t(FGC::HashOf( value.data(), value.size() * sizeof(T) )); 124 | } 125 | else 126 | { 127 | FGC::HashVal result = FGC::HashOf( value.size() ); 128 | 129 | for (auto& item : value) { 130 | result << FGC::HashOf( item ); 131 | } 132 | return size_t(result); 133 | } 134 | } 135 | }; 136 | 137 | 138 | template 139 | struct hash< vector > 140 | { 141 | ND_ size_t operator () (const vector &value) const 142 | { 143 | return size_t(FGC::HashOf( FGC::ArrayView{ value } )); 144 | } 145 | }; 146 | 147 | 148 | template 149 | struct hash< array > 150 | { 151 | ND_ size_t operator () (const array &value) const 152 | { 153 | return size_t(FGC::HashOf( FGC::ArrayView{ value } )); 154 | } 155 | }; 156 | 157 | } // std 158 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/Iterators.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | 7 | namespace FGC 8 | { 9 | namespace _fgc_hidden_ 10 | { 11 | template 12 | struct _ReverseWrapper 13 | { 14 | T & container; 15 | 16 | ND_ auto begin () { return std::rbegin(container); } 17 | ND_ auto end () { return std::rend(container); } 18 | }; 19 | 20 | } // _fgc_hidden_ 21 | 22 | /* 23 | ================================================= 24 | Reverse 25 | ================================================= 26 | */ 27 | template 28 | ND_ _fgc_hidden_::_ReverseWrapper Reverse (Container &&arr) 29 | { 30 | return { arr }; 31 | } 32 | 33 | 34 | } // FGC 35 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/NtStringView.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | /* 3 | This string_view type guaranties that contains non-null pointer to null-terminated string (C-style string). 4 | Use NtStringView only as function argument. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "stl/Containers/StringView.h" 10 | #include "stl/Memory/MemUtils.h" 11 | #include "stl/Memory/UntypedAllocator.h" 12 | 13 | namespace FGC 14 | { 15 | 16 | // 17 | // Null-terminated String View 18 | // 19 | 20 | template 21 | struct NtBasicStringView 22 | { 23 | // types 24 | public: 25 | using Value_t = T; 26 | using Self = NtBasicStringView< T >; 27 | using Allocator_t = UntypedAllocator; 28 | 29 | private: 30 | static constexpr T NullChar = T(0); 31 | 32 | 33 | // variables 34 | private: 35 | T const * _data; 36 | size_t _length; 37 | T _buffer [32]; 38 | bool _isAllocated = false; 39 | 40 | 41 | // methods 42 | public: 43 | NtBasicStringView (); 44 | NtBasicStringView (Self &&other); 45 | NtBasicStringView (const Self &other); 46 | NtBasicStringView (BasicStringView str); 47 | NtBasicStringView (const std::basic_string &str); 48 | NtBasicStringView (const T* str); 49 | NtBasicStringView (const T* str, size_t length); 50 | ~NtBasicStringView (); 51 | 52 | // TODO: why they ignored by compiler ? 53 | Self& operator = (Self &&) = delete; 54 | Self& operator = (const Self &) = delete; 55 | Self& operator = (BasicStringView) = delete; 56 | Self& operator = (const std::basic_string &) = delete; 57 | Self& operator = (const T*) = delete; 58 | 59 | explicit operator StringView () const { return StringView{ _data, _length }; } 60 | 61 | ND_ T const* c_str () const { return _data; } 62 | ND_ size_t size () const { return _length; } 63 | ND_ size_t length () const { return _length; } 64 | ND_ bool empty () const { return _length == 0; } 65 | 66 | private: 67 | bool _Validate (); 68 | bool _IsStatic () const { return _data == &_buffer[0]; } 69 | }; 70 | 71 | 72 | using NtStringView = NtBasicStringView< char >; 73 | 74 | 75 | 76 | template 77 | inline NtBasicStringView::NtBasicStringView () : 78 | _data{ _buffer }, _length{ 0 }, _buffer{ 0 } 79 | {} 80 | 81 | template 82 | inline NtBasicStringView::NtBasicStringView (BasicStringView str) : 83 | _data{ str.data() }, _length{ str.size() } 84 | { 85 | _Validate(); 86 | } 87 | 88 | template 89 | inline NtBasicStringView::NtBasicStringView (const std::basic_string &str) : 90 | _data{ str.data() }, _length{ str.size() } 91 | { 92 | _Validate(); 93 | } 94 | 95 | template 96 | inline NtBasicStringView::NtBasicStringView (const Self &other) : 97 | _data{ other._data }, _length{ other._length } 98 | { 99 | if ( other._IsStatic() ) 100 | { 101 | _data = _buffer; 102 | std::memcpy( _buffer, other._buffer, sizeof(_buffer) ); 103 | } 104 | else 105 | _Validate(); 106 | } 107 | 108 | template 109 | inline NtBasicStringView::NtBasicStringView (Self &&other) : 110 | _data{ other._data }, _length{ other._length }, _isAllocated{ other._isAllocated } 111 | { 112 | if ( other._IsStatic() ) 113 | { 114 | _data = _buffer; 115 | std::memcpy( _buffer, other._buffer, sizeof(_buffer) ); 116 | } 117 | other._isAllocated = false; 118 | } 119 | 120 | template 121 | inline NtBasicStringView::NtBasicStringView (const T* str) : 122 | _data{ str }, _length{ str ? strlen(str) : 0 } 123 | { 124 | _Validate(); 125 | } 126 | 127 | template 128 | inline NtBasicStringView::NtBasicStringView (const T* str, size_t length) : 129 | _data{ str }, _length{ length } 130 | { 131 | _Validate(); 132 | } 133 | 134 | template 135 | inline NtBasicStringView::~NtBasicStringView () 136 | { 137 | if ( _isAllocated ) 138 | Allocator_t::Deallocate( const_cast(_data), SizeOf * (_length+1) ); 139 | } 140 | 141 | template 142 | inline bool NtBasicStringView::_Validate () 143 | { 144 | if ( not _data ) 145 | { 146 | _buffer[0] = 0; 147 | _data = _buffer; 148 | _length = 0; 149 | return false; 150 | } 151 | 152 | if ( _data[_length] == NullChar ) 153 | return false; 154 | 155 | T * new_data; 156 | BytesU size = SizeOf * (_length+1); 157 | 158 | if ( size > sizeof(_buffer) ) 159 | { 160 | _isAllocated= true; 161 | new_data = Cast( Allocator_t::Allocate( size )); 162 | } 163 | else 164 | new_data = _buffer; 165 | 166 | memcpy( OUT new_data, _data, size_t(size) ); 167 | new_data[_length] = NullChar; 168 | _data = new_data; 169 | 170 | return true; 171 | } 172 | 173 | } // FGC 174 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/Optional.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #ifdef FG_STD_OPTIONAL 6 | 7 | # include 8 | 9 | namespace FGC 10 | { 11 | template using Optional = std::optional< T >; 12 | 13 | } // FGC 14 | 15 | 16 | #elif defined(FG_ENABLE_OPTIONAL) 17 | 18 | # include "external/optional/optional.hpp" 19 | 20 | namespace FGC 21 | { 22 | template using Optional = std::experimental::optional< T >; 23 | 24 | } // FGC 25 | 26 | #else 27 | 28 | # error Optional is not supported! 29 | 30 | #endif // FG_STD_OPTIONAL 31 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/Ptr.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Common.h" 6 | 7 | namespace FGC 8 | { 9 | 10 | // 11 | // Raw Pointer Wrapper 12 | // 13 | 14 | template 15 | struct Ptr 16 | { 17 | // variables 18 | private: 19 | T * _value = null; 20 | 21 | // methods 22 | public: 23 | Ptr () {} 24 | Ptr (T *ptr) : _value{ptr} {} 25 | 26 | template 27 | Ptr (const Ptr &other) : _value{static_cast( (B*)other )} {} 28 | 29 | ND_ T * operator -> () const { ASSERT( _value ); return _value; } 30 | ND_ T & operator * () const { ASSERT( _value ); return *_value; } 31 | ND_ T * get () const { return _value; } 32 | 33 | ND_ explicit operator T * () const { return _value; } 34 | 35 | ND_ operator Ptr () const { return _value; } 36 | 37 | template 38 | ND_ explicit operator B () const { return static_cast( _value ); } 39 | 40 | ND_ explicit operator bool () const { return _value != null; } 41 | 42 | ND_ bool operator == (const Ptr &rhs) const { return _value == rhs._value; } 43 | ND_ bool operator != (const Ptr &rhs) const { return not (*this == rhs); } 44 | }; 45 | 46 | } // FGC 47 | 48 | 49 | namespace std 50 | { 51 | 52 | template 53 | struct hash< FGC::Ptr > { 54 | ND_ size_t operator () (const FGC::Ptr &value) const { 55 | return hash()( value.operator->() ); 56 | } 57 | }; 58 | 59 | } // std 60 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/Singleton.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Memory/MemUtils.h" 6 | 7 | namespace FGC 8 | { 9 | 10 | /* 11 | ================================================= 12 | Singleton 13 | ================================================= 14 | */ 15 | template 16 | ND_ inline static T* Singleton () 17 | { 18 | static T inst; 19 | return AddressOf( inst ); 20 | } 21 | 22 | } // FGC 23 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/StaticString.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Math/Math.h" 6 | #include "stl/Containers/StringView.h" 7 | 8 | namespace FGC 9 | { 10 | 11 | // 12 | // Static String 13 | // 14 | 15 | template 16 | struct TStaticString 17 | { 18 | // type 19 | public: 20 | using value_type = CharT; 21 | using iterator = CharT *; 22 | using const_iterator = CharT const *; 23 | using View_t = BasicStringView< CharT >; 24 | using Self = TStaticString< CharT, StringSize >; 25 | 26 | 27 | // variables 28 | private: 29 | CharT _array [StringSize] = {}; 30 | size_t _length = 0; 31 | 32 | 33 | // methods 34 | public: 35 | constexpr TStaticString () 36 | { 37 | DEBUG_ONLY( memset( _array, 0, sizeof(_array) )); 38 | } 39 | 40 | TStaticString (const View_t &view) : TStaticString{ view.data(), view.length() } 41 | {} 42 | 43 | constexpr TStaticString (const CharT *str) 44 | { 45 | for (; str[_length] and _length < StringSize; ++_length) { 46 | _array[_length] = str[_length]; 47 | } 48 | _array[_length] = CharT(0); 49 | } 50 | 51 | constexpr TStaticString (const CharT *str, size_t length) 52 | { 53 | ASSERT( length < StringSize ); 54 | 55 | for (; _length < length and _length < StringSize; ++_length) { 56 | _array[_length] = str[_length]; 57 | } 58 | _array[_length] = CharT(0); 59 | } 60 | 61 | 62 | ND_ constexpr operator View_t () const { return View_t{ _array, length() }; } 63 | 64 | ND_ constexpr size_t size () const { return _length; } 65 | ND_ constexpr size_t length () const { return size(); } 66 | ND_ static constexpr size_t capacity () { return StringSize; } 67 | ND_ constexpr bool empty () const { return _length == 0; } 68 | ND_ constexpr CharT const * c_str () const { return _array; } 69 | ND_ constexpr CharT const * data () const { return _array; } 70 | ND_ CharT * data () { return _array; } 71 | 72 | ND_ constexpr CharT & operator [] (size_t i) { ASSERT( i < _length ); return _array[i]; } 73 | ND_ constexpr CharT const & operator [] (size_t i) const { ASSERT( i < _length ); return _array[i]; } 74 | 75 | ND_ bool operator == (const View_t &rhs) const { return View_t(*this) == rhs; } 76 | ND_ bool operator != (const View_t &rhs) const { return not (*this == rhs); } 77 | ND_ bool operator > (const View_t &rhs) const { return View_t(*this) > rhs; } 78 | ND_ bool operator < (const View_t &rhs) const { return View_t(*this) < rhs; } 79 | 80 | ND_ iterator begin () { return &_array[0]; } 81 | ND_ const_iterator begin () const { return &_array[0]; } 82 | ND_ iterator end () { return &_array[_length]; } 83 | ND_ const_iterator end () const { return &_array[_length]; } 84 | 85 | 86 | void clear () 87 | { 88 | _array[0] = CharT(0); 89 | _length = 0; 90 | } 91 | 92 | void resize (size_t newSize) 93 | { 94 | ASSERT( newSize < capacity() ); 95 | 96 | newSize = Min( newSize, capacity()-1 ); 97 | 98 | if ( newSize > _length ) 99 | { 100 | memset( &_array[_length], 0, _length - newSize ); 101 | } 102 | 103 | _length = newSize; 104 | } 105 | }; 106 | 107 | 108 | template 109 | using StaticString = TStaticString< char, StringSize >; 110 | 111 | } // FGC 112 | 113 | 114 | namespace std 115 | { 116 | 117 | template 118 | struct hash< FGC::TStaticString< CharT, StringSize > > 119 | { 120 | ND_ size_t operator () (const FGC::TStaticString &value) const 121 | { 122 | return hash< FGC::BasicStringView >()( value ); 123 | } 124 | }; 125 | 126 | } // std 127 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/StringView.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #ifdef FG_STD_STRINGVIEW 6 | # include 7 | 8 | namespace FGC 9 | { 10 | using StringView = std::string_view; 11 | template using BasicStringView = std::basic_string_view; 12 | } 13 | 14 | #elif defined(FG_ENABLE_STRINGVIEW) 15 | 16 | # include "external/string_view/include/nonstd/string_view.hpp" 17 | 18 | namespace FGC 19 | { 20 | using StringView = nonstd::string_view; 21 | template using BasicStringView = nonstd::basic_string_view; 22 | } 23 | 24 | #else 25 | 26 | # error String view is not supported! 27 | 28 | #endif // FG_STD_STRINGVIEW 29 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/StringViewFwd.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #ifdef FG_STD_STRINGVIEW 6 | # include 7 | 8 | namespace FGC 9 | { 10 | using StringView = std::string_view; 11 | template using BasicStringView = std::basic_string_view; 12 | } 13 | 14 | #else 15 | 16 | namespace FGC 17 | { 18 | template struct BasicStringView; 19 | 20 | using StringView = BasicStringView; 21 | } 22 | 23 | #endif // FG_STD_STRINGVIEW 24 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/StructView.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Math/Math.h" 6 | #include "stl/Math/Bytes.h" 7 | #include "stl/Containers/ArrayView.h" 8 | 9 | namespace FGC 10 | { 11 | 12 | // 13 | // Structure View 14 | // 15 | 16 | template 17 | struct StructView 18 | { 19 | // types 20 | public: 21 | using Self = StructView< T >; 22 | 23 | struct const_iterator 24 | { 25 | Self const& _ref; 26 | size_t _index = 0; 27 | 28 | const_iterator (const Self &ref, size_t idx) : _ref{ref}, _index{idx} {} 29 | 30 | const_iterator& operator ++ () { ++_index; return *this; } 31 | 32 | ND_ T const& operator * () const { return _ref[_index]; } 33 | ND_ bool operator == (const const_iterator &rhs) const { return &_ref == &rhs._ref and _index == rhs._index; } 34 | ND_ bool operator != (const const_iterator &rhs) const { return not (*this == rhs); } 35 | }; 36 | 37 | 38 | private: 39 | static constexpr uint DBG_VIEW_COUNT = 400; 40 | 41 | struct _IViewer 42 | { 43 | virtual ~_IViewer () {} 44 | }; 45 | 46 | 47 | template 48 | struct _ViewerWithPaddingUnaligned final : _IViewer 49 | { 50 | // types 51 | #pragma pack (push, 1) 52 | struct Element { 53 | T value; 54 | uint8_t _padding [Padding]; 55 | }; 56 | #pragma pack (pop) 57 | using ElementsPtr_t = Element const (*) [DBG_VIEW_COUNT]; 58 | 59 | // variables 60 | ElementsPtr_t const elements; 61 | 62 | // methods 63 | explicit _ViewerWithPaddingUnaligned (const void *ptr) : elements{ BitCast(ptr) } 64 | { STATIC_ASSERT( sizeof(Element) == sizeof(St) ); } 65 | }; 66 | 67 | 68 | template 69 | struct _ViewerWithPadding final : _IViewer 70 | { 71 | // types 72 | struct Element { 73 | T value; 74 | uint8_t _padding [Padding]; 75 | }; 76 | using ElementsPtr_t = Element const (*) [DBG_VIEW_COUNT]; 77 | 78 | // variables 79 | ElementsPtr_t const elements; 80 | 81 | // methods 82 | explicit _ViewerWithPadding (const void *ptr) : elements{ BitCast(ptr) } 83 | { STATIC_ASSERT( sizeof(Element) == sizeof(St) ); } 84 | }; 85 | 86 | 87 | template 88 | struct _ViewerImpl final : _IViewer 89 | { 90 | // types 91 | using ElementsPtr_t = T const (*) [DBG_VIEW_COUNT]; 92 | 93 | // variables 94 | ElementsPtr_t const elements; 95 | 96 | // methods 97 | explicit _ViewerImpl (const void *ptr) : elements{ BitCast(ptr) } {} 98 | }; 99 | 100 | 101 | // variables 102 | private: 103 | void const * _array = null; 104 | size_t _count = 0; 105 | uint _stride = 0; 106 | 107 | DEBUG_ONLY( 108 | _IViewer* _dbgView = null; 109 | ) 110 | 111 | 112 | // methods 113 | public: 114 | StructView () 115 | {} 116 | 117 | StructView (ArrayView arr) : 118 | _array{ arr.data() }, _count{ arr.size() }, _stride{ sizeof(T) } 119 | { 120 | DEBUG_ONLY( _dbgView = _CreateView( _array )); 121 | } 122 | 123 | StructView (Self &&other) : 124 | _array{other._array}, _count{other._count}, _stride{other._stride} 125 | { 126 | DEBUG_ONLY( std::swap( _dbgView, other._dbgView )); 127 | } 128 | 129 | template 130 | StructView (ArrayView arr, T (Class::*member)) : 131 | _array{ arr.data() + OffsetOf(member) }, _count{ arr.size() }, _stride{ sizeof(Class) } 132 | { 133 | DEBUG_ONLY( _dbgView = _CreateView( _array )); 134 | } 135 | 136 | StructView (const void *ptr, size_t count, uint stride) : 137 | _array{ptr}, _count{count}, _stride{stride} 138 | {} 139 | 140 | ~StructView () 141 | { 142 | DEBUG_ONLY( delete _dbgView ); 143 | } 144 | 145 | 146 | ND_ size_t size () const { return _count; } 147 | ND_ bool empty () const { return _count == 0; } 148 | ND_ T const & operator [] (size_t i) const { ASSERT(i < _count); return *static_cast(_array + BytesU(i * _stride)); } 149 | 150 | ND_ T const& front () const { return operator[] (0); } 151 | ND_ T const& back () const { return operator[] (_count-1); } 152 | 153 | ND_ const_iterator begin () const { return const_iterator{ *this, 0 }; } 154 | ND_ const_iterator end () const { return const_iterator{ *this, _count }; } 155 | 156 | 157 | ND_ bool operator == (StructView rhs) const 158 | { 159 | if ( size() != rhs.size() ) 160 | return false; 161 | 162 | for (size_t i = 0; i < size(); ++i) { 163 | if ( not ((*this)[i] == rhs[i]) ) 164 | return false; 165 | } 166 | return true; 167 | } 168 | 169 | ND_ StructView section (size_t first, size_t count) const 170 | { 171 | return first < size() ? 172 | StructView{ _array + BytesU(first * _stride), Min(size() - first, count) } : 173 | StructView{}; 174 | } 175 | 176 | 177 | private: 178 | template 179 | ND_ static _IViewer* _CreateView (const void *ptr) 180 | { 181 | STATIC_ASSERT( Stride >= sizeof(T) ); 182 | const size_t padding = Stride - sizeof(T); 183 | 184 | if constexpr ( padding == 0 ) 185 | return new _ViewerImpl< Class >{ ptr }; 186 | else 187 | if constexpr ( padding % alignof(T) == 0 ) 188 | return new _ViewerWithPadding< Class, padding >{ ptr }; 189 | else 190 | return new _ViewerWithPaddingUnaligned< Class, padding >{ ptr }; 191 | } 192 | }; 193 | 194 | 195 | } // FGC 196 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Containers/Union.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/CompileTime/TypeList.h" 6 | 7 | namespace FGC 8 | { 9 | namespace _fgc_hidden_ 10 | { 11 | template struct overloaded final : Types... { using Types::operator()...; }; 12 | 13 | template overloaded (Types...) -> overloaded; 14 | } 15 | } // FGC 16 | 17 | 18 | #ifdef FG_STD_VARIANT 19 | 20 | # include 21 | 22 | namespace FGC 23 | { 24 | template using Union = std::variant< Types... >; 25 | using NullUnion = std::monostate; 26 | 27 | template constexpr std::in_place_type_t InPlaceIndex {}; 28 | 29 | template 30 | struct TypeList< std::variant > final : TypeList< Types... > 31 | {}; 32 | 33 | /* 34 | ================================================= 35 | Visit 36 | ================================================= 37 | */ 38 | template 39 | forceinline constexpr decltype(auto) Visit (Union &un, Funcs&&... fn) 40 | { 41 | using namespace _fgc_hidden_; 42 | return std::visit( overloaded{ std::forward(fn)... }, un ); 43 | } 44 | 45 | template 46 | forceinline constexpr decltype(auto) Visit (const Union &un, Funcs&&... fn) 47 | { 48 | using namespace _fgc_hidden_; 49 | return std::visit( overloaded{ std::forward(fn)... }, un ); 50 | } 51 | 52 | /* 53 | ================================================= 54 | UnionGet 55 | ================================================= 56 | */ 57 | template 58 | ND_ forceinline constexpr T& UnionGet (Union &un) 59 | { 60 | return std::get( un ); 61 | } 62 | 63 | template 64 | ND_ forceinline constexpr T const& UnionGet (const Union &un) 65 | { 66 | return std::get( un ); 67 | } 68 | 69 | template 70 | ND_ forceinline constexpr T* UnionGetIf (Union *un) 71 | { 72 | return std::get_if( un ); 73 | } 74 | 75 | template 76 | ND_ forceinline constexpr T const* UnionGetIf (const Union *un) 77 | { 78 | return std::get_if( un ); 79 | } 80 | 81 | template 82 | ND_ forceinline constexpr bool HoldsAlternative (const Union &un) 83 | { 84 | return std::holds_alternative( un ); 85 | } 86 | 87 | } // FGC 88 | 89 | 90 | #elif defined(FG_ENABLE_VARIANT) 91 | 92 | # include "external/variant/include/mpark/variant.hpp" 93 | 94 | namespace FGC 95 | { 96 | template using Union = mpark::variant< Types... >; 97 | using NullUnion = mpark::monostate; 98 | 99 | template constexpr mpark::in_place_type_t InPlaceIndex {}; 100 | 101 | 102 | template 103 | struct TypeList< mpark::variant > final : TypeList< Types... > 104 | {}; 105 | 106 | /* 107 | ================================================= 108 | Visit 109 | ================================================= 110 | */ 111 | template 112 | forceinline constexpr decltype(auto) Visit (Union &un, Funcs&&... fn) 113 | { 114 | using namespace _fgc_hidden_; 115 | return mpark::visit( overloaded{ std::forward(fn)... }, un ); 116 | } 117 | 118 | template 119 | forceinline constexpr decltype(auto) Visit (const Union &un, Funcs&&... fn) 120 | { 121 | using namespace _fgc_hidden_; 122 | return mpark::visit( overloaded{ std::forward(fn)... }, un ); 123 | } 124 | 125 | /* 126 | ================================================= 127 | UnionGet 128 | ================================================= 129 | */ 130 | template 131 | ND_ forceinline constexpr T& UnionGet (Union &un) 132 | { 133 | return mpark::get( un ); 134 | } 135 | 136 | template 137 | ND_ forceinline constexpr T const& UnionGet (const Union &un) 138 | { 139 | return mpark::get( un ); 140 | } 141 | 142 | template 143 | ND_ forceinline constexpr T* UnionGetIf (Union *un) 144 | { 145 | return mpark::get_if( un ); 146 | } 147 | 148 | template 149 | ND_ forceinline constexpr T const* UnionGetIf (const Union *un) 150 | { 151 | return mpark::get_if( un ); 152 | } 153 | 154 | template 155 | ND_ forceinline constexpr bool HoldsAlternative (const Union &un) 156 | { 157 | return mpark::holds_alternative( un ); 158 | } 159 | 160 | } // FGC 161 | 162 | #else 163 | 164 | # error Variant is not supported! 165 | 166 | #endif // FG_STD_VARIANT 167 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Log/Log.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Defines.h" 6 | #include "stl/Containers/StringView.h" 7 | 8 | namespace FGC 9 | { 10 | 11 | 12 | // 13 | // Logger 14 | // 15 | 16 | struct Logger 17 | { 18 | enum class EResult { 19 | Continue, 20 | Break, 21 | Abort, 22 | }; 23 | 24 | static EResult Info (const char *msg, const char *func, const char *file, int line); 25 | static EResult Info (const StringView &msg, const StringView &func, const StringView &file, int line); 26 | 27 | static EResult Error (const char *msg, const char *func, const char *file, int line); 28 | static EResult Error (const StringView &msg, const StringView &func, const StringView &file, int line); 29 | }; 30 | 31 | } // FGC 32 | 33 | 34 | #define FG_PRIVATE_LOGX( _level_, _msg_, _file_, _line_ ) \ 35 | BEGIN_ENUM_CHECKS() \ 36 | {switch ( ::FGC::Logger::_level_( (_msg_), (FG_FUNCTION_NAME), (_file_), (_line_) ) ) \ 37 | { \ 38 | case ::FGC::Logger::EResult::Continue : break; \ 39 | case ::FGC::Logger::EResult::Break : FG_PRIVATE_BREAK_POINT(); break; \ 40 | case ::FGC::Logger::EResult::Abort : FG_PRIVATE_EXIT(); break; \ 41 | }} \ 42 | END_ENUM_CHECKS() 43 | 44 | #define FG_PRIVATE_LOGI( _msg_, _file_, _line_ ) FG_PRIVATE_LOGX( Info, (_msg_), (_file_), (_line_) ) 45 | #define FG_PRIVATE_LOGE( _msg_, _file_, _line_ ) FG_PRIVATE_LOGX( Error, (_msg_), (_file_), (_line_) ) 46 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Math/BitMath.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "stl/Algorithms/EnumUtils.h" 4 | 5 | #ifdef COMPILER_MSVC 6 | # include 7 | # pragma intrinsic( _BitScanForward, _BitScanReverse ) 8 | # if PLATFORM_BITS == 64 9 | # pragma intrinsic( _BitScanForward64, _BitScanReverse64 ) 10 | # endif 11 | #endif 12 | 13 | namespace FGC 14 | { 15 | 16 | /* 17 | ================================================= 18 | IsPowerOfTwo 19 | ================================================= 20 | */ 21 | template 22 | ND_ forceinline constexpr bool IsPowerOfTwo (const T &x) 23 | { 24 | return (x != 0) & ((x & (x - T(1))) == T(0)); 25 | } 26 | 27 | /* 28 | ================================================= 29 | IntLog2 / GetPowerOfTwo / BitScanReverse 30 | ================================================= 31 | */ 32 | template 33 | ND_ forceinline int IntLog2 (const T& x) 34 | { 35 | constexpr int INVALID_INDEX = std::numeric_limits::min(); 36 | 37 | #ifdef COMPILER_MSVC 38 | unsigned long index; 39 | 40 | if constexpr ( sizeof(x) > sizeof(uint) ) 41 | return _BitScanReverse64( OUT &index, x ) ? index : INVALID_INDEX; 42 | else 43 | return _BitScanReverse( OUT &index, x ) ? index : INVALID_INDEX; 44 | 45 | #elif defined(COMPILER_GCC) or defined(COMPILER_CLANG) 46 | if constexpr ( sizeof(x) > sizeof(uint) ) 47 | return x ? (sizeof(x)*8)-1 - __builtin_clzll( x ) : INVALID_INDEX; 48 | else 49 | return x ? (sizeof(x)*8)-1 - __builtin_clz( x ) : INVALID_INDEX; 50 | 51 | #else 52 | //return std::ilogb( x ); 53 | #endif 54 | } 55 | 56 | template 57 | ND_ forceinline int BitScanReverse (const T& x) 58 | { 59 | return IntLog2( x ); 60 | } 61 | 62 | /* 63 | ================================================= 64 | BitScanForward 65 | ================================================= 66 | */ 67 | template 68 | ND_ forceinline int BitScanForward (const T& x) 69 | { 70 | #ifdef COMPILER_MSVC 71 | constexpr int INVALID_INDEX = std::numeric_limits::min(); 72 | unsigned long index; 73 | 74 | if constexpr ( sizeof(x) > sizeof(uint) ) 75 | return _BitScanForward64( OUT &index, x ) ? index : INVALID_INDEX; 76 | else 77 | return _BitScanForward( OUT &index, x ) ? index : INVALID_INDEX; 78 | 79 | #elif defined(COMPILER_GCC) or defined(COMPILER_CLANG) 80 | if constexpr ( sizeof(x) > sizeof(uint) ) 81 | return __builtin_ffsll( x ) - 1; 82 | else 83 | return __builtin_ffs( x ) - 1; 84 | 85 | #else 86 | #error add BitScanForward implementation 87 | #endif 88 | } 89 | 90 | /* 91 | ================================================= 92 | BitCount 93 | ================================================= 94 | */ 95 | template 96 | ND_ forceinline size_t BitCount (const T& x) 97 | { 98 | STATIC_ASSERT( IsUnsignedInteger ); 99 | 100 | if constexpr( sizeof(x) == 8 ) 101 | return std::bitset<64>{ x }.count(); 102 | else 103 | if constexpr( sizeof(x) <= 4 ) 104 | return std::bitset<32>{ x }.count(); 105 | } 106 | 107 | 108 | } // FGC 109 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Memory/MemUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Math/Bytes.h" 6 | #include "stl/CompileTime/TypeTraits.h" 7 | 8 | namespace FGC 9 | { 10 | 11 | /* 12 | ================================================= 13 | AddressOf 14 | ================================================= 15 | */ 16 | template 17 | ND_ forceinline decltype(auto) AddressOf (T &value) 18 | { 19 | return std::addressof( value ); 20 | } 21 | 22 | /* 23 | ================================================= 24 | PlacementNew 25 | ================================================= 26 | */ 27 | template 28 | forceinline T * PlacementNew (OUT void *ptr, Types&&... args) 29 | { 30 | ASSERT( CheckPointerAlignment( ptr ) ); 31 | return ( new(ptr) T{ std::forward(args)... } ); 32 | } 33 | 34 | /* 35 | ================================================= 36 | MemCopy 37 | ================================================= 38 | */ 39 | template 40 | forceinline void MemCopy (T1 &dst, const T2 &src) 41 | { 42 | STATIC_ASSERT( sizeof(dst) >= sizeof(src) ); 43 | //STATIC_ASSERT( std::is_trivial_v and std::is_trivial_v ); // TODO 44 | STATIC_ASSERT( not IsConst ); 45 | 46 | std::memcpy( &dst, &src, sizeof(src) ); 47 | } 48 | 49 | forceinline void MemCopy (void *dst, BytesU dstSize, const void *src, BytesU srcSize) 50 | { 51 | ASSERT( srcSize <= dstSize ); 52 | ASSERT( dst and src ); 53 | 54 | std::memcpy( dst, src, size_t(std::min(srcSize, dstSize)) ); 55 | } 56 | 57 | /* 58 | ================================================= 59 | AllocOnStack 60 | ================================================= 61 | * 62 | ND_ forceinline void* AllocOnStack (BytesU size) 63 | { 64 | #ifdef PLATFORM_WINDOWS 65 | return _alloca( size_t(size) ); 66 | #else 67 | return alloca( size_t(size) ); 68 | #endif 69 | }*/ 70 | 71 | 72 | } // FGC 73 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Memory/UntypedAllocator.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Memory/MemUtils.h" 6 | 7 | namespace FGC 8 | { 9 | 10 | template 11 | struct StdAllocator; 12 | 13 | 14 | // 15 | // Untyped Default Allocator 16 | // 17 | 18 | struct UntypedAllocator 19 | { 20 | // types 21 | template using StdAllocator_t = StdAllocator; 22 | 23 | // methods 24 | ND_ FG_ALLOCATOR static void* Allocate (BytesU size) 25 | { 26 | return ::operator new ( size_t(size), std::nothrow_t{} ); 27 | } 28 | 29 | static void Deallocate (void *ptr) 30 | { 31 | ::operator delete ( ptr, std::nothrow_t() ); 32 | } 33 | 34 | static void Deallocate (void *ptr, BytesU size) 35 | { 36 | ::operator delete ( ptr, size_t(size) ); 37 | } 38 | 39 | ND_ bool operator == (const UntypedAllocator &) const 40 | { 41 | return true; 42 | } 43 | }; 44 | 45 | 46 | 47 | // 48 | // Untyped Aligned Allocator 49 | // 50 | 51 | struct UntypedAlignedAllocator 52 | { 53 | // types 54 | template using StdAllocator_t = StdAllocator; 55 | 56 | // methods 57 | ND_ FG_ALLOCATOR static void* Allocate (BytesU size, BytesU align) 58 | { 59 | return ::operator new ( size_t(size), std::align_val_t(size_t(align)), std::nothrow_t{} ); 60 | } 61 | 62 | static void Deallocate (void *ptr, BytesU align) 63 | { 64 | ::operator delete ( ptr, std::align_val_t(size_t(align)), std::nothrow_t() ); 65 | } 66 | 67 | static void Deallocate (void *ptr, BytesU size, BytesU align) 68 | { 69 | ::operator delete ( ptr, size_t(size), std::align_val_t(size_t(align)) ); 70 | } 71 | 72 | ND_ bool operator == (const UntypedAlignedAllocator &) const 73 | { 74 | return true; 75 | } 76 | }; 77 | 78 | 79 | 80 | // 81 | // STD Allocator 82 | // 83 | 84 | template 85 | struct StdAllocator final : std::allocator 86 | { 87 | StdAllocator () {} 88 | StdAllocator (const UntypedAllocator &) {} 89 | StdAllocator (const UntypedAlignedAllocator &) {} 90 | }; 91 | 92 | 93 | } // FGC 94 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Platforms/WindowsHeader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #ifdef PLATFORM_WINDOWS 6 | 7 | # define NOMINMAX 8 | # define NOMCX 9 | # define NOIME 10 | # define NOSERVICE 11 | # define WIN32_LEAN_AND_MEAN 12 | 13 | # ifdef COMPILER_MSVC 14 | # pragma warning (push) 15 | # pragma warning (disable: 4668) 16 | # include 17 | # pragma warning (pop) 18 | 19 | # else 20 | # include 21 | # endif 22 | 23 | 24 | #undef DeleteFile 25 | #undef CreateWindow 26 | #undef CreateDirectory 27 | #undef CreateEvent 28 | 29 | #endif // PLATFORM_WINDOWS 30 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Stream/FileStream.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Stream/Stream.h" 6 | #include 7 | 8 | #ifdef FG_STD_FILESYSTEM 9 | # include 10 | #endif 11 | 12 | namespace FGC 13 | { 14 | 15 | // 16 | // Read-only File Stream 17 | // 18 | 19 | class FileRStream final : public RStream 20 | { 21 | // variables 22 | private: 23 | FILE* _file = null; 24 | BytesU _fileSize; 25 | BytesU _position; 26 | 27 | 28 | // methods 29 | public: 30 | FileRStream () {} 31 | FileRStream (StringView filename); 32 | FileRStream (const char *filename); 33 | FileRStream (const String &filename); 34 | #ifdef FG_STD_FILESYSTEM 35 | FileRStream (const std::filesystem::path &path); 36 | #endif 37 | ~FileRStream (); 38 | 39 | bool IsOpen () const override { return _file != null; } 40 | BytesU Position () const override { return _position; } 41 | BytesU Size () const override { return _fileSize; } 42 | 43 | bool SeekSet (BytesU pos) override; 44 | BytesU Read2 (OUT void *buffer, BytesU size) override; 45 | 46 | private: 47 | ND_ BytesU _GetSize () const; 48 | }; 49 | 50 | 51 | 52 | // 53 | // Write-only File Stream 54 | // 55 | 56 | class FileWStream final : public WStream 57 | { 58 | // variables 59 | private: 60 | FILE* _file = null; 61 | 62 | 63 | // methods 64 | public: 65 | FileWStream () {} 66 | FileWStream (StringView filename); 67 | FileWStream (const char *filename); 68 | FileWStream (const String &filename); 69 | #ifdef FG_STD_FILESYSTEM 70 | FileWStream (const std::filesystem::path &path); 71 | #endif 72 | ~FileWStream (); 73 | 74 | bool IsOpen () const override { return _file != null; } 75 | BytesU Position () const override; 76 | BytesU Size () const override; 77 | 78 | BytesU Write2 (const void *buffer, BytesU size) override; 79 | void Flush () override; 80 | }; 81 | 82 | } // FGC 83 | 84 | 85 | // check definitions 86 | #if defined (COMPILER_MSVC) or defined (COMPILER_CLANG) 87 | 88 | # ifdef _FILE_OFFSET_BITS 89 | # if _FILE_OFFSET_BITS == 64 90 | # pragma detect_mismatch( "_FILE_OFFSET_BITS", "64" ) 91 | # else 92 | # pragma detect_mismatch( "_FILE_OFFSET_BITS", "32" ) 93 | # endif 94 | # endif 95 | 96 | # ifdef FG_STD_FILESYSTEM 97 | # pragma detect_mismatch( "FG_STD_FILESYSTEM", "1" ) 98 | # else 99 | # pragma detect_mismatch( "FG_STD_FILESYSTEM", "0" ) 100 | # endif 101 | 102 | #endif // COMPILER_MSVC or COMPILER_CLANG 103 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Stream/Stream.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "stl/Stream/Stream.h" 4 | #include "stl/Algorithms/StringUtils.h" 5 | 6 | 7 | namespace FGC 8 | { 9 | 10 | /* 11 | ================================================= 12 | Read 13 | ================================================= 14 | */ 15 | bool RStream::Read (void *buffer, BytesU size) 16 | { 17 | return Read2( buffer, size ) == size; 18 | } 19 | 20 | /* 21 | ================================================= 22 | Read 23 | ================================================= 24 | */ 25 | bool RStream::Read (size_t length, OUT String &str) 26 | { 27 | str.resize( length ); 28 | 29 | BytesU expected_size = BytesU::SizeOf(str[0]) * str.length(); 30 | BytesU current_size = Read2( str.data(), expected_size ); 31 | 32 | str.resize( size_t(current_size / sizeof(str[0])) ); 33 | 34 | return str.length() == length; 35 | } 36 | 37 | /* 38 | ================================================= 39 | Read 40 | ================================================= 41 | */ 42 | bool RStream::Read (size_t count, OUT Array &buf) 43 | { 44 | buf.resize( count ); 45 | 46 | BytesU expected_size = BytesU::SizeOf(buf[0]) * buf.size(); 47 | BytesU current_size = Read2( buf.data(), expected_size ); 48 | 49 | buf.resize( size_t(current_size / sizeof(buf[0])) ); 50 | 51 | return buf.size() == count; 52 | } 53 | //----------------------------------------------------------------------------- 54 | 55 | 56 | 57 | /* 58 | ================================================= 59 | Write 60 | ================================================= 61 | */ 62 | bool WStream::Write (const void *buffer, BytesU size) 63 | { 64 | return Write2( buffer, size ) == size; 65 | } 66 | 67 | /* 68 | ================================================= 69 | Write 70 | ================================================= 71 | */ 72 | bool WStream::Write (StringView str) 73 | { 74 | if ( str.empty() ) 75 | return true; 76 | 77 | BytesU size = SizeOf * str.length(); 78 | 79 | return Write2( str.data(), size ) == size; 80 | } 81 | 82 | /* 83 | ================================================= 84 | Write 85 | ================================================= 86 | */ 87 | bool WStream::Write (ArrayView buf) 88 | { 89 | const BytesU size = BytesU::SizeOf(buf[0]) * buf.size(); 90 | 91 | return Write2( buf.data(), size ) == size; 92 | } 93 | 94 | } // FGC 95 | -------------------------------------------------------------------------------- /external/FrameGraph/stl/Stream/Stream.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Containers/ArrayView.h" 6 | #include "stl/Containers/StringView.h" 7 | #include "stl/Math/Bytes.h" 8 | #include "stl/Memory/MemUtils.h" 9 | 10 | namespace FGC 11 | { 12 | 13 | // 14 | // Read-only Stream 15 | // 16 | 17 | class RStream : public std::enable_shared_from_this< RStream > 18 | { 19 | public: 20 | RStream () {} 21 | 22 | RStream (const RStream &) = delete; 23 | RStream (RStream &&) = delete; 24 | virtual ~RStream () {} 25 | 26 | RStream& operator = (const RStream &) = delete; 27 | RStream& operator = (RStream &&) = delete; 28 | 29 | ND_ virtual bool IsOpen () const = 0; 30 | ND_ virtual BytesU Position () const = 0; 31 | ND_ virtual BytesU Size () const = 0; 32 | ND_ BytesU RemainingSize () const { return Size() - Position(); } 33 | 34 | virtual bool SeekSet (BytesU pos) = 0; 35 | ND_ virtual BytesU Read2 (OUT void *buffer, BytesU size) = 0; 36 | 37 | bool Read (OUT void *buffer, BytesU size); 38 | bool Read (size_t length, OUT String &str); 39 | bool Read (size_t count, OUT Array &buf); 40 | 41 | 42 | template 43 | EnableIf, bool> Read (OUT T &data) 44 | { 45 | return Read2( AddressOf(data), BytesU::SizeOf(data) ) == BytesU::SizeOf(data); 46 | } 47 | 48 | template 49 | EnableIf, bool> Read (size_t count, OUT Array &arr) 50 | { 51 | arr.resize( count ); 52 | 53 | BytesU size = BytesU::SizeOf(arr[0]) * arr.size(); 54 | 55 | return Read2( arr.data(), size ) == size; 56 | } 57 | }; 58 | 59 | 60 | 61 | // 62 | // Write-only Stream 63 | // 64 | 65 | class WStream : public std::enable_shared_from_this< WStream > 66 | { 67 | public: 68 | WStream () {} 69 | 70 | WStream (const WStream &) = delete; 71 | WStream (WStream &&) = delete; 72 | virtual ~WStream () {} 73 | 74 | WStream& operator = (const WStream &) = delete; 75 | WStream& operator = (WStream &&) = delete; 76 | 77 | ND_ virtual bool IsOpen () const = 0; 78 | ND_ virtual BytesU Position () const = 0; 79 | ND_ virtual BytesU Size () const = 0; 80 | 81 | ND_ virtual BytesU Write2 (const void *buffer, BytesU size) = 0; 82 | virtual void Flush () = 0; 83 | 84 | bool Write (const void *buffer, BytesU size); 85 | bool Write (StringView str); 86 | bool Write (ArrayView buf); 87 | 88 | template 89 | EnableIf, bool> Write (const T &data) 90 | { 91 | return Write2( AddressOf(data), BytesU::SizeOf(data) ) == BytesU::SizeOf(data); 92 | } 93 | }; 94 | 95 | 96 | } // FGC 97 | 98 | -------------------------------------------------------------------------------- /external/RenderDoc/LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2019 Baldur Karlsson 4 | 5 | Copyright (c) 2014 Crytek 6 | 7 | Copyright (c) 1998-2018 [Third party code and tools](docs/credits_acknowledgements.rst) 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /external/miniz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.6.0) 2 | 3 | project( "MiniZ" LANGUAGES C ) 4 | 5 | add_library( "MiniZ" STATIC 6 | "miniz.c" 7 | "miniz.h" 8 | "miniz_common.h" 9 | "miniz_tdef.c" 10 | "miniz_tdef.h" 11 | "miniz_tinfl.c" 12 | "miniz_tinfl.h" 13 | "miniz_zip.c" 14 | "miniz_zip.h" 15 | ) 16 | 17 | target_include_directories( "MiniZ" PUBLIC "." ) 18 | set_property( TARGET "MiniZ" PROPERTY FOLDER "External" ) 19 | -------------------------------------------------------------------------------- /external/miniz/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013-2014 RAD Game Tools and Valve Software 2 | Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC 3 | 4 | All Rights Reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /external/miniz/miniz_common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /* ------------------- Types and macros */ 8 | typedef unsigned char mz_uint8; 9 | typedef signed short mz_int16; 10 | typedef unsigned short mz_uint16; 11 | typedef unsigned int mz_uint32; 12 | typedef unsigned int mz_uint; 13 | typedef int64_t mz_int64; 14 | typedef uint64_t mz_uint64; 15 | typedef int mz_bool; 16 | 17 | #define MZ_FALSE (0) 18 | #define MZ_TRUE (1) 19 | 20 | /* Works around MSVC's spammy "warning C4127: conditional expression is constant" message. */ 21 | #ifdef _MSC_VER 22 | #define MZ_MACRO_END while (0, 0) 23 | #else 24 | #define MZ_MACRO_END while (0) 25 | #endif 26 | 27 | #ifdef MINIZ_NO_STDIO 28 | #define MZ_FILE void * 29 | #else 30 | #include 31 | #define MZ_FILE FILE 32 | #endif /* #ifdef MINIZ_NO_STDIO */ 33 | 34 | #ifdef MINIZ_NO_TIME 35 | typedef struct mz_dummy_time_t_tag 36 | { 37 | int m_dummy; 38 | } mz_dummy_time_t; 39 | #define MZ_TIME_T mz_dummy_time_t 40 | #else 41 | #define MZ_TIME_T time_t 42 | #endif 43 | 44 | #define MZ_ASSERT(x) assert(x) 45 | 46 | #ifdef MINIZ_NO_MALLOC 47 | #define MZ_MALLOC(x) NULL 48 | #define MZ_FREE(x) (void)x, ((void)0) 49 | #define MZ_REALLOC(p, x) NULL 50 | #else 51 | #define MZ_MALLOC(x) malloc(x) 52 | #define MZ_FREE(x) free(x) 53 | #define MZ_REALLOC(p, x) realloc(p, x) 54 | #endif 55 | 56 | #define MZ_MAX(a, b) (((a) > (b)) ? (a) : (b)) 57 | #define MZ_MIN(a, b) (((a) < (b)) ? (a) : (b)) 58 | #define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj)) 59 | 60 | #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN 61 | #define MZ_READ_LE16(p) *((const mz_uint16 *)(p)) 62 | #define MZ_READ_LE32(p) *((const mz_uint32 *)(p)) 63 | #else 64 | #define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U)) 65 | #define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U)) 66 | #endif 67 | 68 | #define MZ_READ_LE64(p) (((mz_uint64)MZ_READ_LE32(p)) | (((mz_uint64)MZ_READ_LE32((const mz_uint8 *)(p) + sizeof(mz_uint32))) << 32U)) 69 | 70 | #ifdef _MSC_VER 71 | #define MZ_FORCEINLINE __forceinline 72 | #elif defined(__GNUC__) 73 | #define MZ_FORCEINLINE __inline__ __attribute__((__always_inline__)) 74 | #else 75 | #define MZ_FORCEINLINE inline 76 | #endif 77 | 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | 82 | extern void *miniz_def_alloc_func(void *opaque, size_t items, size_t size); 83 | extern void miniz_def_free_func(void *opaque, void *address); 84 | extern void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size); 85 | 86 | #define MZ_UINT16_MAX (0xFFFFU) 87 | #define MZ_UINT32_MAX (0xFFFFFFFFU) 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /external/miniz/readme.md: -------------------------------------------------------------------------------- 1 | ## Miniz 2 | 3 | Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format specification standards. It supports the most commonly used functions exported by the zlib library, but is a completely independent implementation so zlib's licensing requirements do not apply. Miniz also contains simple to use functions for writing .PNG format image files and reading/writing/appending .ZIP format archives. Miniz's compression speed has been tuned to be comparable to zlib's, and it also has a specialized real-time compressor function designed to compare well against fastlz/minilzo. 4 | 5 | ## Usage 6 | 7 | Please use the files from the [releases page](https://github.com/richgel999/miniz/releases) in your projects. Do not use the git checkout directly! The different source and header files are [amalgamated](https://www.sqlite.org/amalgamation.html) into one `miniz.c`/`miniz.h` pair in a build step (`amalgamate.sh`). Include `miniz.c` and `miniz.h` in your project to use Miniz. 8 | 9 | ## Features 10 | 11 | * MIT licensed 12 | * A portable, single source and header file library written in plain C. Tested with GCC, clang and Visual Studio. 13 | * Easily tuned and trimmed down by defines 14 | * A drop-in replacement for zlib's most used API's (tested in several open source projects that use zlib, such as libpng and libzip). 15 | * Fills a single threaded performance vs. compression ratio gap between several popular real-time compressors and zlib. For example, at level 1, miniz.c compresses around 5-9% better than minilzo, but is approx. 35% slower. At levels 2-9, miniz.c is designed to compare favorably against zlib's ratio and speed. See the miniz performance comparison page for example timings. 16 | * Not a block based compressor: miniz.c fully supports stream based processing using a coroutine-style implementation. The zlib-style API functions can be called a single byte at a time if that's all you've got. 17 | * Easy to use. The low-level compressor (tdefl) and decompressor (tinfl) have simple state structs which can be saved/restored as needed with simple memcpy's. The low-level codec API's don't use the heap in any way. 18 | * Entire inflater (including optional zlib header parsing and Adler-32 checking) is implemented in a single function as a coroutine, which is separately available in a small (~550 line) source file: miniz_tinfl.c 19 | * A fairly complete (but totally optional) set of .ZIP archive manipulation and extraction API's. The archive functionality is intended to solve common problems encountered in embedded, mobile, or game development situations. (The archive API's are purposely just powerful enough to write an entire archiver given a bit of additional higher-level logic.) 20 | 21 | ## Known Problems 22 | 23 | * No support for encrypted archives. Not sure how useful this stuff is in practice. 24 | * Minimal documentation. The assumption is that the user is already familiar with the basic zlib API. I need to write an API wiki - for now I've tried to place key comments before each enum/API, and I've included 6 examples that demonstrate how to use the module's major features. 25 | 26 | ## Special Thanks 27 | 28 | Thanks to Alex Evans for the PNG writer function. Also, thanks to Paul Holden and Thorsten Scheuermann for feedback and testing, Matt Pritchard for all his encouragement, and Sean Barrett's various public domain libraries for inspiration (and encouraging me to write miniz.c in C, which was much more enjoyable and less painful than I thought it would be considering I've been programming in C++ for so long). 29 | 30 | Thanks to Bruce Dawson for reporting a problem with the level_and_flags archive API parameter (which is fixed in v1.12) and general feedback, and Janez Zemva for indirectly encouraging me into writing more examples. 31 | 32 | ## Patents 33 | 34 | I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described [here](http://www.gzip.org/zlib/rfc-deflate.html#algorithm). Also see the [gzip FAQ](http://www.gzip.org/#faq11). In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too. 35 | 36 | 37 | [![Build Status](https://travis-ci.org/uroni/miniz.svg?branch=master)](https://travis-ci.org/uroni/miniz) -------------------------------------------------------------------------------- /external/rapidxml/license.txt: -------------------------------------------------------------------------------- 1 | Use of this software is granted under one of the following two licenses, 2 | to be chosen freely by the user. 3 | 4 | 1. Boost Software License - Version 1.0 - August 17th, 2003 5 | =============================================================================== 6 | 7 | Copyright (c) 2006, 2007 Marcin Kalicinski 8 | 9 | Permission is hereby granted, free of charge, to any person or organization 10 | obtaining a copy of the software and accompanying documentation covered by 11 | this license (the "Software") to use, reproduce, display, distribute, 12 | execute, and transmit the Software, and to prepare derivative works of the 13 | Software, and to permit third-parties to whom the Software is furnished to 14 | do so, all subject to the following: 15 | 16 | The copyright notices in the Software and this entire statement, including 17 | the above license grant, this restriction and the following disclaimer, 18 | must be included in all copies of the Software, in whole or in part, and 19 | all derivative works of the Software, unless such copies or derivative 20 | works are solely in the form of machine-executable object code generated by 21 | a source language processor. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 26 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 27 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 28 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | DEALINGS IN THE SOFTWARE. 30 | 31 | 2. The MIT License 32 | =============================================================================== 33 | 34 | Copyright (c) 2006, 2007 Marcin Kalicinski 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a copy 37 | of this software and associated documentation files (the "Software"), to deal 38 | in the Software without restriction, including without limitation the rights 39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 40 | of the Software, and to permit persons to whom the Software is furnished to do so, 41 | subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included in all 44 | copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 52 | IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /external/rapidxml/rapidxml_iterators.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDXML_ITERATORS_HPP_INCLUDED 2 | #define RAPIDXML_ITERATORS_HPP_INCLUDED 3 | 4 | // Copyright (C) 2006, 2009 Marcin Kalicinski 5 | // Version 1.13 6 | // Revision $DateTime: 2009/05/13 01:46:17 $ 7 | //! \file rapidxml_iterators.hpp This file contains rapidxml iterators 8 | 9 | #include "rapidxml.hpp" 10 | 11 | namespace rapidxml 12 | { 13 | 14 | //! Iterator of child nodes of xml_node 15 | template 16 | class node_iterator 17 | { 18 | 19 | public: 20 | 21 | typedef typename xml_node value_type; 22 | typedef typename xml_node &reference; 23 | typedef typename xml_node *pointer; 24 | typedef std::ptrdiff_t difference_type; 25 | typedef std::bidirectional_iterator_tag iterator_category; 26 | 27 | node_iterator() 28 | : m_node(0) 29 | { 30 | } 31 | 32 | node_iterator(xml_node *node) 33 | : m_node(node->first_node()) 34 | { 35 | } 36 | 37 | reference operator *() const 38 | { 39 | assert(m_node); 40 | return *m_node; 41 | } 42 | 43 | pointer operator->() const 44 | { 45 | assert(m_node); 46 | return m_node; 47 | } 48 | 49 | node_iterator& operator++() 50 | { 51 | assert(m_node); 52 | m_node = m_node->next_sibling(); 53 | return *this; 54 | } 55 | 56 | node_iterator operator++(int) 57 | { 58 | node_iterator tmp = *this; 59 | ++this; 60 | return tmp; 61 | } 62 | 63 | node_iterator& operator--() 64 | { 65 | assert(m_node && m_node->previous_sibling()); 66 | m_node = m_node->previous_sibling(); 67 | return *this; 68 | } 69 | 70 | node_iterator operator--(int) 71 | { 72 | node_iterator tmp = *this; 73 | ++this; 74 | return tmp; 75 | } 76 | 77 | bool operator ==(const node_iterator &rhs) 78 | { 79 | return m_node == rhs.m_node; 80 | } 81 | 82 | bool operator !=(const node_iterator &rhs) 83 | { 84 | return m_node != rhs.m_node; 85 | } 86 | 87 | private: 88 | 89 | xml_node *m_node; 90 | 91 | }; 92 | 93 | //! Iterator of child attributes of xml_node 94 | template 95 | class attribute_iterator 96 | { 97 | 98 | public: 99 | 100 | typedef typename xml_attribute value_type; 101 | typedef typename xml_attribute &reference; 102 | typedef typename xml_attribute *pointer; 103 | typedef std::ptrdiff_t difference_type; 104 | typedef std::bidirectional_iterator_tag iterator_category; 105 | 106 | attribute_iterator() 107 | : m_attribute(0) 108 | { 109 | } 110 | 111 | attribute_iterator(xml_node *node) 112 | : m_attribute(node->first_attribute()) 113 | { 114 | } 115 | 116 | reference operator *() const 117 | { 118 | assert(m_attribute); 119 | return *m_attribute; 120 | } 121 | 122 | pointer operator->() const 123 | { 124 | assert(m_attribute); 125 | return m_attribute; 126 | } 127 | 128 | attribute_iterator& operator++() 129 | { 130 | assert(m_attribute); 131 | m_attribute = m_attribute->next_attribute(); 132 | return *this; 133 | } 134 | 135 | attribute_iterator operator++(int) 136 | { 137 | attribute_iterator tmp = *this; 138 | ++this; 139 | return tmp; 140 | } 141 | 142 | attribute_iterator& operator--() 143 | { 144 | assert(m_attribute && m_attribute->previous_attribute()); 145 | m_attribute = m_attribute->previous_attribute(); 146 | return *this; 147 | } 148 | 149 | attribute_iterator operator--(int) 150 | { 151 | attribute_iterator tmp = *this; 152 | ++this; 153 | return tmp; 154 | } 155 | 156 | bool operator ==(const attribute_iterator &rhs) 157 | { 158 | return m_attribute == rhs.m_attribute; 159 | } 160 | 161 | bool operator !=(const attribute_iterator &rhs) 162 | { 163 | return m_attribute != rhs.m_attribute; 164 | } 165 | 166 | private: 167 | 168 | xml_attribute *m_attribute; 169 | 170 | }; 171 | 172 | } 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /external/rapidxml/rapidxml_utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDXML_UTILS_HPP_INCLUDED 2 | #define RAPIDXML_UTILS_HPP_INCLUDED 3 | 4 | // Copyright (C) 2006, 2009 Marcin Kalicinski 5 | // Version 1.13 6 | // Revision $DateTime: 2009/05/13 01:46:17 $ 7 | //! \file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful 8 | //! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective. 9 | 10 | #include "rapidxml.hpp" 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace rapidxml 17 | { 18 | 19 | //! Represents data loaded from a file 20 | template 21 | class file 22 | { 23 | 24 | public: 25 | 26 | //! Loads file into the memory. Data will be automatically destroyed by the destructor. 27 | //! \param filename Filename to load. 28 | file(const char *filename) 29 | { 30 | using namespace std; 31 | 32 | // Open stream 33 | basic_ifstream stream(filename, ios::binary); 34 | if (!stream) 35 | throw runtime_error(string("cannot open file ") + filename); 36 | stream.unsetf(ios::skipws); 37 | 38 | // Determine stream size 39 | stream.seekg(0, ios::end); 40 | size_t size = stream.tellg(); 41 | stream.seekg(0); 42 | 43 | // Load data and add terminating 0 44 | m_data.resize(size + 1); 45 | stream.read(&m_data.front(), static_cast(size)); 46 | m_data[size] = 0; 47 | } 48 | 49 | //! Loads file into the memory. Data will be automatically destroyed by the destructor 50 | //! \param stream Stream to load from 51 | file(std::basic_istream &stream) 52 | { 53 | using namespace std; 54 | 55 | // Load data and add terminating 0 56 | stream.unsetf(ios::skipws); 57 | m_data.assign(istreambuf_iterator(stream), istreambuf_iterator()); 58 | if (stream.fail() || stream.bad()) 59 | throw runtime_error("error reading stream"); 60 | m_data.push_back(0); 61 | } 62 | 63 | //! Gets file data. 64 | //! \return Pointer to data of file. 65 | Ch *data() 66 | { 67 | return &m_data.front(); 68 | } 69 | 70 | //! Gets file data. 71 | //! \return Pointer to data of file. 72 | const Ch *data() const 73 | { 74 | return &m_data.front(); 75 | } 76 | 77 | //! Gets file data size. 78 | //! \return Size of file data, in characters. 79 | std::size_t size() const 80 | { 81 | return m_data.size(); 82 | } 83 | 84 | private: 85 | 86 | std::vector m_data; // File data 87 | 88 | }; 89 | 90 | //! Counts children of node. Time complexity is O(n). 91 | //! \return Number of children of node 92 | template 93 | inline std::size_t count_children(xml_node *node) 94 | { 95 | xml_node *child = node->first_node(); 96 | std::size_t count = 0; 97 | while (child) 98 | { 99 | ++count; 100 | child = child->next_sibling(); 101 | } 102 | return count; 103 | } 104 | 105 | //! Counts attributes of node. Time complexity is O(n). 106 | //! \return Number of attributes of node 107 | template 108 | inline std::size_t count_attributes(xml_node *node) 109 | { 110 | xml_attribute *attr = node->first_attribute(); 111 | std::size_t count = 0; 112 | while (attr) 113 | { 114 | ++count; 115 | attr = attr->next_attribute(); 116 | } 117 | return count; 118 | } 119 | 120 | } 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /generator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | file( GLOB_RECURSE SOURCES "*.*" ) 4 | add_executable( "Generator" ${SOURCES} ) 5 | source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ) 6 | target_link_libraries( "Generator" "STL" ) 7 | target_include_directories( "Generator" PUBLIC ".." ) 8 | set_property( TARGET "Generator" PROPERTY FOLDER "" ) 9 | target_include_directories( "Generator" PRIVATE "${RDE_FRAMEGRAPH_PATH}/external/Vulkan-Headers/include" ) 10 | -------------------------------------------------------------------------------- /generator/GenEnumToString.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "Generator.h" 4 | 5 | namespace RDE 6 | { 7 | 8 | /* 9 | ================================================= 10 | _SkipSpecialCases 11 | ================================================= 12 | */ 13 | ND_ static bool _SkipSpecialCases (StringView enumName, StringView fieldName) 14 | { 15 | return (enumName == "VkDescriptorUpdateTemplateType" and fieldName == "VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_RANGE_SIZE") or 16 | (enumName == "VkShaderStageFlagBits" and fieldName == "VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM") or 17 | (enumName == "VkValidationCacheHeaderVersionEXT" and fieldName == "VK_VALIDATION_CACHE_HEADER_VERSION_RANGE_SIZE_EXT") or 18 | (enumName == "VkSamplerAddressMode" and fieldName == "VK_SAMPLER_ADDRESS_MODE_RANGE_SIZE") or 19 | (enumName == "VkPipelineCacheHeaderVersion" and fieldName == "VK_PIPELINE_CACHE_HEADER_VERSION_RANGE_SIZE"); 20 | } 21 | 22 | /* 23 | ================================================= 24 | GenEnumToString 25 | ================================================= 26 | */ 27 | bool Generator::GenEnumToString (const FS::path &headerFile, const FS::path &sourceFile) const 28 | { 29 | String header = "// auto-generated file\n\n"; 30 | String str = "// auto-generated file\n\n#pragma warning (push)\n#pragma warning (disable: 4100)\n\n"; 31 | 32 | for (auto& info : _enums) 33 | { 34 | if ( not info.data.required ) 35 | continue; 36 | 37 | if ( info.data.fileIndex > 0 ) { 38 | header << "#ifdef "s << _fileData[info.data.fileIndex].macro << "\n"; 39 | str << "#ifdef "s << _fileData[info.data.fileIndex].macro << "\n"; 40 | } 41 | 42 | header << "\tND_ String Serialize_" << info.data.name << " (" << info.data.name << ");\n"; 43 | 44 | str << "\tND_ String Serialize_" << info.data.name << " (" << info.data.name << " value)\n" 45 | << "\t{\n" 46 | << "\t BEGIN_ENUM_CHECKS();\n" 47 | << "\t switch ( value )\n" 48 | << "\t {\n"; 49 | 50 | for (auto& field : info.data.fields) 51 | { 52 | if ( _SkipSpecialCases( info.data.name, field.name ) ) 53 | continue; 54 | 55 | if ( HasSubString( field.name, "_MAX_ENUM" ) or HasSubString( field.name, "_RANGE_SIZE" ) ) 56 | { 57 | str << "\t\t\tcase " << field.name << " : break;\n"; 58 | } 59 | else 60 | { 61 | if ( not _IsNumber( field.value ) ) 62 | continue; // skip aliases 63 | 64 | str << "\t\t\tcase " << field.name << " : return \"" << field.name << "\";\n"; 65 | } 66 | } 67 | 68 | str << "\t }\n" 69 | << "\t END_ENUM_CHECKS();\n" 70 | << "\t RETURN_ERR( \"unsupported value: \"s << EnumToString( value ), \"\" );\n" 71 | << "\t}\n"; 72 | 73 | if ( info.data.fileIndex > 0 ) { 74 | header << "#endif\n"; 75 | str << "#endif\n"; 76 | } 77 | str << '\n'; 78 | } 79 | 80 | 81 | for (auto& info : _bitfields) 82 | { 83 | if ( not info.data.required ) 84 | continue; 85 | 86 | if ( info.data.fileIndex > 0 ) { 87 | header << "#ifdef "s << _fileData[info.data.fileIndex].macro << "\n"; 88 | str << "#ifdef "s << _fileData[info.data.fileIndex].macro << "\n"; 89 | } 90 | 91 | header << "\tND_ String Serialize_" << info.data.name << " (" << info.data.name << ");\n"; 92 | 93 | auto iter = _enums.find( SearchableEnum{info.data.enumName} ); 94 | if ( iter == _enums.end() ) 95 | { 96 | str << "\tND_ String Serialize_" << info.data.name << " (" << info.data.name << " bits)\n" 97 | << "\t{\n" 98 | << "\t CHECK( bits == 0 );\n" 99 | << "\t return \"0\";\n" 100 | << "\t}\n"; 101 | 102 | if ( info.data.fileIndex > 0 ) { 103 | header << "#endif\n"; 104 | str << "#endif\n"; 105 | } 106 | str << '\n'; 107 | continue; 108 | } 109 | 110 | 111 | // find _MAX_ENUM or _END_RANGE 112 | StringView max_enum; 113 | 114 | for (auto& field : iter->data.fields) 115 | { 116 | if ( HasSubString( field.name, "_MAX_ENUM" ) or HasSubString( field.name, "_END_RANGE" ) ) 117 | { 118 | max_enum = field.name; 119 | break; 120 | } 121 | } 122 | CHECK_ERR( not max_enum.empty() ); 123 | 124 | 125 | str << "\tND_ String Serialize_" << info.data.name << " (" << info.data.name << " bits)\n" 126 | << "\t{\n" 127 | << "\t if ( bits == 0 )\n" 128 | << "\t return \"0\";\n" 129 | << "\t String result;\n" 130 | << "\t for (" << info.data.name << " t = 1; t < " << max_enum << "; t <<= 1)\n" 131 | << "\t {\n" 132 | << "\t if ( not EnumEq( bits, t ) )\n" 133 | << "\t continue;\n\n" 134 | << "\t if ( not result.empty() )\n" 135 | << "\t result << \" | \";\n\n" 136 | << "\t result << Serialize_" << info.data.enumName << "( " << info.data.enumName << "(t) );\n" 137 | << "\t }\n" 138 | << "\t return result;\n" 139 | << "\t}\n"; 140 | 141 | if ( info.data.fileIndex > 0 ) { 142 | header << "#endif\n"; 143 | str << "#endif\n"; 144 | } 145 | str << '\n'; 146 | } 147 | 148 | str << "#pragma warning (pop)\n\n"; 149 | 150 | // store header to file 151 | { 152 | FileWStream file{ headerFile }; 153 | CHECK_ERR( file.IsOpen() ); 154 | CHECK_ERR( file.Write( StringView(header) )); 155 | } 156 | // store source to file 157 | { 158 | FileWStream file{ sourceFile }; 159 | CHECK_ERR( file.IsOpen() ); 160 | CHECK_ERR( file.Write( StringView(str) )); 161 | } 162 | return true; 163 | } 164 | 165 | } // RDE 166 | -------------------------------------------------------------------------------- /generator/GenFormatHelpers.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "Generator.h" 4 | 5 | namespace RDE 6 | { 7 | 8 | /* 9 | ================================================= 10 | GenFormatHelpers 11 | ================================================= 12 | */ 13 | bool Generator::GenFormatHelpers (const FS::path &output) const 14 | { 15 | String str; 16 | 17 | str << "// auto-generated file\n\n" 18 | << "enum class EClearValueType : uint32_t {\n" 19 | << " Int,\n" 20 | << " UInt,\n" 21 | << " Float,\n" 22 | << " Depth,\n" 23 | << " DepthStencil,\n" 24 | << " Unknown = ~0u,\n" 25 | << "};\n\n" 26 | << "ND_ EClearValueType VkFormatToClearValueType (VkFormat value)\n{\n" 27 | << " switch ( value )\n\t{\n"; 28 | 29 | auto iter = _enums.find( SearchableEnum{"VkFormat"} ); 30 | CHECK_ERR( iter != _enums.end() ); 31 | 32 | for (auto& field : iter->data.fields) 33 | { 34 | if ( _IsWord( field.value ) ) 35 | continue; 36 | 37 | if ( field.name == "VK_FORMAT_UNDEFINED" or 38 | field.name == "VK_FORMAT_RANGE_SIZE" or 39 | field.name == "VK_FORMAT_MAX_ENUM" ) 40 | continue; 41 | 42 | str << "\t\tcase " << field.name << " : return EClearValueType::"; 43 | 44 | if ( HasSubString( field.name, "_D16_" ) or HasSubString( field.name, "_D24_" ) or HasSubString( field.name, "_D32_" ) ) 45 | { 46 | if ( HasSubString( field.name, "_S8_" ) ) 47 | str << "DepthStencil"; 48 | else 49 | str << "Depth"; 50 | } 51 | else 52 | if ( HasSubString( field.name, "_UNORM" ) or HasSubString( field.name, "_SNORM" ) or 53 | HasSubString( field.name, "_USCALED" ) or HasSubString( field.name, "_SSCALED" ) or 54 | HasSubString( field.name, "_SFLOAT" ) or HasSubString( field.name, "_UFLOAT" ) or 55 | HasSubString( field.name, "_SRGB" ) ) 56 | { 57 | str << "Float"; 58 | } 59 | else 60 | if ( HasSubString( field.name, "_SINT" ) ) 61 | { 62 | str << "Int"; 63 | } 64 | else 65 | if ( HasSubString( field.name, "_UINT" ) ) 66 | { 67 | str << "UInt"; 68 | } 69 | else 70 | { 71 | str << "Unknown"; 72 | CHECK(false); // unknown type 73 | } 74 | 75 | str << ";\n"; 76 | } 77 | 78 | str << " }\n" 79 | << " RETURN_ERR( \"unknown format type!\" );\n" 80 | << "}\n\n"; 81 | 82 | 83 | // store to file 84 | FileWStream file{ output }; 85 | CHECK_ERR( file.IsOpen() ); 86 | CHECK_ERR( file.Write( StringView(str) )); 87 | 88 | return true; 89 | } 90 | 91 | } // RDE 92 | -------------------------------------------------------------------------------- /generator/GenListenerInterface.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "Generator.h" 4 | 5 | namespace RDE 6 | { 7 | 8 | /* 9 | ================================================= 10 | GenListenerInterface 11 | ================================================= 12 | */ 13 | bool Generator::GenListenerInterface (const FS::path &output) const 14 | { 15 | String str = R"#(// auto-generated file 16 | 17 | #pragma once 18 | 19 | #pragma warning (push) 20 | #pragma warning (disable: 4100) 21 | 22 | namespace RDE 23 | { 24 | 25 | class IVulkanListener : public std::enable_shared_from_this 26 | { 27 | public: 28 | virtual void InitialImageContent (uint chunkIndex, uint64_t threadID, uint64_t timestamp, VkImage imageId, 29 | bool isSparse, BytesU contentSize, ContentID contentId) {} 30 | 31 | virtual void InitialMemoryContent (uint chunkIndex, uint64_t threadID, uint64_t timestamp, VkDeviceMemory memId, 32 | bool isSparse, BytesU contentSize, ContentID contentId) {} 33 | 34 | virtual void InitialDescriptorSetContent (uint chunkIndex, uint64_t threadID, uint64_t timestamp, ArrayView slots) {} 35 | 36 | virtual void OnOpenCapture (const FS::path &filename) {} 37 | 38 | virtual void BeginningOfCapture (uint chunkIndex, uint64_t threadID, uint64_t timestamp, ArrayView imageLayouts) {} 39 | 40 | virtual void EndOfCapture (uint chunkIndex, uint64_t threadID, uint64_t timestamp, VkResourceID presentedImage) {} 41 | 42 | virtual void EnumeratePhysicalDevices (uint chunkIndex, uint64_t threadID, uint64_t timestamp, VkInstance instance, uint32_t PhysicalDeviceIndex, VkPhysicalDevice PhysicalDevice, 43 | uint32_t memIdxMap[VK_MAX_MEMORY_TYPES], const VkPhysicalDeviceProperties &physProps, 44 | const VkPhysicalDeviceMemoryProperties &memProps, const VkPhysicalDeviceFeatures &physFeatures, 45 | uint32_t queueCount, VkQueueFamilyProperties queueProps[]) {} 46 | 47 | virtual void FlushMappedMemoryRanges (uint chunkIndex, uint64_t threadID, uint64_t timestamp, VkDevice device, uint32_t memoryRangeCount, 48 | const VkMappedMemoryRange * pMemoryRanges, BytesU mappedDataSize, ContentID mappedData) {} 49 | 50 | virtual void DebugMarkerSetObjectNameEXT (uint chunkIndex, uint64_t threadID, uint64_t timestamp, VkResourceID resId, StringView name) {} 51 | 52 | virtual void UpdateDescriptorSetWithTemplate (uint chunkIndex, uint64_t threadID, uint64_t timestamp, VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void * pData) {} 53 | 54 | )#"; 55 | 56 | for (auto& packet : _packetIDs) 57 | { 58 | if ( packet.vkFunc.empty() ) 59 | continue; 60 | 61 | if ( _skipFuncs.count( packet.vkFunc )) 62 | continue; 63 | 64 | str << "\t\tvirtual void " << packet.vkFunc.substr( 2 ) << " (uint chunkIndex, uint64_t threadID, uint64_t timestamp, "; 65 | 66 | auto fn_iter = _funcs.find( SearchableFunc{packet.vkFunc} ); 67 | CHECK_ERR( fn_iter != _funcs.end() ); 68 | 69 | for (auto& arg : fn_iter->data.args) 70 | { 71 | str << (&arg == fn_iter->data.args.data() ? "" : ", "); 72 | 73 | for (size_t i = 0; i < arg.type.size(); ++i) 74 | { 75 | const auto& type = arg.type[i]; 76 | 77 | if ( type == "[" ) 78 | { 79 | CHECK_ERR( arg.type.size() == i+3 and arg.type[i+2] == "]" ); 80 | 81 | str << arg.name << type << arg.type[i+1] << arg.type[i+2]; 82 | break; 83 | } 84 | 85 | str << type << ' '; 86 | 87 | if ( i+1 == arg.type.size() ) 88 | str << arg.name; 89 | } 90 | } 91 | 92 | str << ") {}\n"; 93 | } 94 | 95 | str << R"#( 96 | }; 97 | 98 | } // RDE 99 | #pragma warning (pop) 100 | )#"; 101 | 102 | 103 | // store to file 104 | FileWStream wfile{ output }; 105 | CHECK_ERR( wfile.IsOpen() ); 106 | CHECK_ERR( wfile.Write( str )); 107 | 108 | return true; 109 | } 110 | 111 | } // RDE 112 | -------------------------------------------------------------------------------- /generator/GenStructTypeHelpers.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "Generator.h" 4 | 5 | namespace RDE 6 | { 7 | 8 | /* 9 | ================================================= 10 | _HasSType 11 | ================================================= 12 | */ 13 | bool Generator::_HasSType (const VkStructInfo &st) 14 | { 15 | const size_t cnt = Min( 2, st.fields.size() ); 16 | 17 | for (size_t i = 0; i < cnt; ++i) 18 | { 19 | if ( st.fields[i].name == "sType" ) 20 | return true; 21 | } 22 | return false; 23 | } 24 | 25 | /* 26 | ================================================= 27 | GenStructTypeHelpers 28 | ================================================= 29 | */ 30 | bool Generator::GenStructTypeHelpers (const FS::path &output) const 31 | { 32 | String str; 33 | String str1, str2; 34 | 35 | str << "// auto-generated file\n\n" 36 | << "template struct TypeToEnum;\n" 37 | << "template struct EnumToType;\n\n"; 38 | 39 | auto st_types = _enums.find( SearchableEnum{"VkStructureType"} ); 40 | CHECK_ERR( st_types != _enums.end() ); 41 | 42 | Array enum_fields = st_types->data.fields; 43 | 44 | for (auto& info : _structs) 45 | { 46 | const bool has_stype = _HasSType( info.data ); 47 | 48 | if ( not has_stype or 49 | info.data.name == "VkBaseInStructure" or 50 | info.data.name == "VkBaseOutStructure" ) 51 | continue; 52 | 53 | StringView enum_name = _FindStructTypeEnum( info.data.name, INOUT enum_fields ); 54 | 55 | if ( info.data.fileIndex > 0 ) 56 | { 57 | str1 << "#ifdef "s << _fileData[info.data.fileIndex].macro << "\n"; 58 | str2 << "#ifdef "s << _fileData[info.data.fileIndex].macro << "\n"; 59 | } 60 | 61 | str1 << "template <> struct TypeToEnum< " << info.data.name << " > { static constexpr VkStructureType value = " << enum_name << "; };\n"; 62 | str2 << "template <> struct EnumToType< " << enum_name << " > { using type = " << info.data.name << "; };\n"; 63 | 64 | if ( info.data.fileIndex > 0 ) 65 | { 66 | str1 << "#endif // "s << _fileData[info.data.fileIndex].macro << "\n"; 67 | str2 << "#endif // "s << _fileData[info.data.fileIndex].macro << "\n"; 68 | } 69 | } 70 | 71 | str << str1 << "\n\n" << str2; 72 | 73 | 74 | // store to file 75 | FileWStream file{ output }; 76 | CHECK_ERR( file.IsOpen() ); 77 | CHECK_ERR( file.Write( StringView(str) )); 78 | 79 | return true; 80 | } 81 | 82 | } // RDE 83 | -------------------------------------------------------------------------------- /generator/Generator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "Generator.h" 4 | 5 | /* 6 | ================================================= 7 | main 8 | ================================================= 9 | */ 10 | int main (int argc, const char** argv) 11 | { 12 | using namespace RDE; 13 | 14 | CHECK_ERR( argv > 0 ); 15 | 16 | StringView vulkan_headers; 17 | StringView rd_vkchunk; 18 | StringView output; 19 | 20 | for (int i = 1; i < argc; ++i) 21 | { 22 | StringView key = argv[i]; 23 | StringView value; 24 | 25 | if ( ++i < argc ) 26 | value = argv[i]; 27 | 28 | if ( key == "-vulkan" ) 29 | vulkan_headers = value; 30 | else 31 | if ( key == "-vkchunk" ) 32 | rd_vkchunk = value; 33 | else 34 | if ( key == "-output" ) 35 | output = value; 36 | else 37 | RETURN_ERR( "unsupported command arg: "s << key, 1 ); 38 | } 39 | 40 | // temp 41 | #if 1 42 | vulkan_headers = R"(C:\Projects\RdcExport\external\FrameGraph\external\Vulkan-Headers\include\vulkan)"; 43 | rd_vkchunk = R"(C:\Projects\RdcExport\external\RenderDoc\vk_common.h)"; 44 | output = R"(C:\Projects\RdcExport\converter\Generated)"; 45 | #endif 46 | 47 | 48 | Generator generator; 49 | 50 | CHECK_ERR( generator.ParseVkHeaders( vulkan_headers ), -1 ); 51 | CHECK_ERR( generator.ParseVkChunks( rd_vkchunk ), -2 ); 52 | CHECK_ERR( generator.BuildBasicTypeMap(), -3 ); 53 | CHECK_ERR( generator.BuildResourceTypeMap(), -4 ); 54 | CHECK_ERR( generator.BuildFuncArgCountOfMap(), -5 ); 55 | CHECK_ERR( generator.BuildStructFieldCountOfMap(), -6 ); 56 | CHECK_ERR( generator.BuildFuncArgDestructorMap(), -7 ); 57 | CHECK_ERR( generator.SetFunctionsScope(), -8 ); 58 | CHECK_ERR( generator.BuildSkipPacketsMap(), -9 ); 59 | 60 | CHECK_ERR( generator.MarkRequiredTypesForSerializing() ); 61 | CHECK_ERR( generator.GenEnumToString( FS::path(output).append( "VkEnumToString.h" ), FS::path(output).append( "VkEnumToStringImpl.h" )), -16 ); 62 | CHECK_ERR( generator.GenStructToString( FS::path(output).append( "VkStructToString.h" ), FS::path(output).append( "VkStructToStringImpl.h" )), -17 ); 63 | 64 | CHECK_ERR( generator.GenListenerInterface( FS::path(output).append("IVulkanListener.h") ), -18 ); 65 | CHECK_ERR( generator.GenChunkParser( FS::path(output).append("ParseChunk.h"), 66 | FS::path(output).append("ParseChunkImpl.h"), 67 | FS::path(output).append("ParseChunkMap.h") ), -19 ); 68 | CHECK_ERR( generator.GenValueParser( FS::path(output).append("ParseValue.h"), 69 | FS::path(output).append("ParseValueImpl.h") ), -20 ); 70 | CHECK_ERR( generator.GenRawVulkanCalls( FS::path{output}.append("BuildRawVulkanCalls.h") ), -21 ); 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /generator/MarkRequiredTypes.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "Generator.h" 4 | 5 | namespace RDE 6 | { 7 | 8 | /* 9 | ================================================= 10 | BuildSkipPacketsMap 11 | ================================================= 12 | */ 13 | bool Generator::BuildSkipPacketsMap () 14 | { 15 | _alwaysSerialize = { 16 | "VkDedicatedAllocationImageCreateInfoNV", 17 | "VkDedicatedAllocationBufferCreateInfoNV", 18 | "VkDedicatedAllocationMemoryAllocateInfoNV" 19 | }; 20 | 21 | _skipFuncs = { 22 | "vkFlushMappedMemoryRanges", 23 | "vkDebugMarkerSetObjectNameEXT", 24 | "vkUpdateDescriptorSetWithTemplate" 25 | }; 26 | 27 | return true; 28 | } 29 | 30 | /* 31 | ================================================= 32 | _MarkRequiredTypes_ProcessVar 33 | ================================================= 34 | */ 35 | bool Generator::_MarkRequiredTypes_ProcessVar (ArrayView types, bool forSerialization) const 36 | { 37 | for (auto& type : types) 38 | { 39 | auto struct_info = _structs.find( SearchableStruct{type} ); 40 | if ( struct_info != _structs.end() ) 41 | { 42 | if ( struct_info->data.required ) 43 | return false; 44 | 45 | // may be not required, but dependencies may be used for custom serialization 46 | struct_info->data.required = (not forSerialization or _neverSerialize.find( struct_info->data.name ) == _neverSerialize.end()); 47 | 48 | for (auto& field : struct_info->data.fields) 49 | { 50 | _MarkRequiredTypes_ProcessVar( field.type, forSerialization ); 51 | } 52 | return true; 53 | } 54 | 55 | auto enum_info = _enums.find( SearchableEnum{type} ); 56 | if ( enum_info != _enums.end() ) 57 | { 58 | if ( enum_info->data.required ) 59 | return false; 60 | 61 | enum_info->data.required = true; 62 | return true; 63 | } 64 | 65 | auto bitfield_info = _bitfields.find( SearchableBitfield{type} ); 66 | if ( bitfield_info != _bitfields.end() ) 67 | { 68 | if ( bitfield_info->data.required ) 69 | return false; 70 | 71 | bitfield_info->data.required = true; 72 | 73 | enum_info = _enums.find( SearchableEnum{bitfield_info->data.enumName} ); 74 | if ( enum_info != _enums.end() ) 75 | { 76 | enum_info->data.required = true; 77 | } 78 | return true; 79 | } 80 | } 81 | return false; 82 | } 83 | 84 | /* 85 | ================================================= 86 | _MarkRequiredTypes 87 | ================================================= 88 | */ 89 | bool Generator::_MarkRequiredTypes (bool forSerialization) const 90 | { 91 | const auto GetInitialState = [forSerialization, this] (StringView name) { 92 | return forSerialization and 93 | _alwaysSerialize.find( name ) != _alwaysSerialize.end() and 94 | _neverSerialize.find( name ) == _neverSerialize.end(); 95 | }; 96 | 97 | // reset all 98 | for (auto& en : _enums) { 99 | en.data.required = false; 100 | } 101 | for (auto& bf : _bitfields) { 102 | bf.data.required = false; 103 | } 104 | for (auto& st : _structs) { 105 | st.data.required = false; 106 | } 107 | 108 | 109 | // refresh all 110 | for (auto& en : _enums) 111 | { 112 | en.data.required |= GetInitialState( en.data.name ); 113 | } 114 | 115 | for (auto& bf : _bitfields) 116 | { 117 | bf.data.required |= GetInitialState( bf.data.name ); 118 | 119 | auto enum_info = _enums.find( SearchableEnum{bf.data.enumName} ); 120 | 121 | if ( bf.data.required and enum_info != _enums.end() ) 122 | enum_info->data.required = true; 123 | } 124 | 125 | for (auto& st : _structs) 126 | { 127 | st.data.required |= (_HasSType( st.data ) and (not forSerialization or _neverSerialize.find( st.data.name ) == _neverSerialize.end())) or 128 | GetInitialState( st.data.name ); 129 | 130 | if ( st.data.required ) { 131 | for (auto& field : st.data.fields) { 132 | _MarkRequiredTypes_ProcessVar( field.type, forSerialization ); 133 | } 134 | } 135 | } 136 | 137 | for (auto& func : _funcs) 138 | { 139 | func.data.required = GetInitialState( func.data.name ); 140 | 141 | if ( func.data.required ) { 142 | for (auto& arg : func.data.args) { 143 | _MarkRequiredTypes_ProcessVar( arg.type, forSerialization ); 144 | } 145 | } 146 | } 147 | 148 | 149 | for (auto& packet : _packetIDs) 150 | { 151 | if ( packet.vkFunc.empty() ) 152 | continue; 153 | 154 | auto func_info = _funcs.find( SearchableFunc{packet.vkFunc} ); 155 | CHECK_ERR( func_info != _funcs.end() ); 156 | 157 | if ( not func_info->data.required ) 158 | { 159 | func_info->data.required = true; 160 | 161 | for (auto& arg : func_info->data.args) 162 | { 163 | _MarkRequiredTypes_ProcessVar( arg.type, forSerialization ); 164 | } 165 | } 166 | } 167 | 168 | return true; 169 | } 170 | 171 | /* 172 | ================================================= 173 | MarkRequiredTypesForSerializing 174 | ================================================= 175 | */ 176 | bool Generator::MarkRequiredTypesForSerializing () const 177 | { 178 | return _MarkRequiredTypes( true ); 179 | } 180 | 181 | } // RDE 182 | -------------------------------------------------------------------------------- /generator/StringParser.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #pragma once 4 | 5 | #include "stl/Containers/ArrayView.h" 6 | 7 | namespace RDE 8 | { 9 | using namespace FGC; 10 | 11 | 12 | // 13 | // String Parser 14 | // 15 | 16 | struct StringParser 17 | { 18 | static void ToEndOfLine (StringView str, INOUT size_t &pos); 19 | static void ToNextLine (StringView str, INOUT size_t &pos); 20 | static void ToBeginOfLine (StringView str, INOUT size_t &pos); 21 | 22 | static void DivideLines (StringView str, OUT Array &lines); 23 | static bool DivideString_CPP (StringView str, OUT Array &tokens); 24 | }; 25 | 26 | 27 | } // RDE 28 | -------------------------------------------------------------------------------- /tests/application/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 3.10 FATAL_ERROR ) 2 | 3 | file( GLOB_RECURSE SOURCES "*.*" ) 4 | add_executable( "Tests.Application" ${SOURCES} ) 5 | source_group( TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ) 6 | 7 | set_property( TARGET "Tests.Application" PROPERTY FOLDER "Tests" ) 8 | target_link_libraries( "Tests.Application" "Application" ) 9 | -------------------------------------------------------------------------------- /tests/application/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020, Zhirnov Andrey. For more information see 'LICENSE' 2 | 3 | #include "VApp.h" 4 | #include "stl/Math/Color.h" 5 | #include "stl/Algorithms/ArrayUtils.h" 6 | 7 | 8 | int main () 9 | { 10 | VApp app; 11 | 12 | app.AllocateResources( InstanceID(1) ); 13 | app.AllocateResources( PhysicalDeviceID(1) ); 14 | app.AllocateResources( DeviceID(1) ); 15 | app.AllocateResources( QueueID(1) ); 16 | app.AllocateResources( ImageID(1) ); 17 | app.AllocateResources( SemaphoreID(1) ); 18 | app.AllocateResources( CommandPoolID(1) ); 19 | app.AllocateResources( CommandBufferID(1) ); 20 | 21 | 22 | CHECK_ERR( app.CreateWindow( 1024, 768, "Player" )); 23 | 24 | std::vector queues = { 25 | { 0, VkDeviceQueueCreateFlags(0), VkQueueFlags(VK_QUEUE_GRAPHICS_BIT), 0.0f } 26 | }; 27 | CHECK_ERR( app.CreateDevice( InstanceID(0), PhysicalDeviceID(0), DeviceID(0), "", VK_VERSION_1_1, queues, 28 | {"VK_LAYER_LUNARG_standard_validation"}, 29 | {VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_DEBUG_UTILS_EXTENSION_NAME}, 30 | {} 31 | )); 32 | CHECK_ERR( app.CreateSwapchain() ); 33 | 34 | CHECK_ERR( app.MapQueueID( 0, QueueID(0) )); 35 | 36 | 37 | // create semaphores 38 | { 39 | VkSemaphoreCreateInfo info = {}; 40 | info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; 41 | 42 | VK_CHECK( app.vkCreateSemaphore( app.GetResource(DeviceID(0)), &info, null, OUT &app.EditResource(SemaphoreID(0)) )); 43 | } 44 | 45 | // create command buffer 46 | { 47 | VkCommandPoolCreateInfo pool_info = {}; 48 | pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; 49 | pool_info.queueFamilyIndex = app.GetQueueFamilyIndex( QueueID(0) ); 50 | VK_CHECK( app.vkCreateCommandPool( app.GetResource(DeviceID(0)), &pool_info, null, OUT &app.EditResource(CommandPoolID(0)) )); 51 | 52 | VkCommandBufferAllocateInfo cmd_info = {}; 53 | cmd_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; 54 | cmd_info.commandBufferCount = 1; 55 | cmd_info.commandPool = app.GetResource(CommandPoolID(0)); 56 | cmd_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; 57 | VK_CHECK( app.vkAllocateCommandBuffers( app.GetResource(DeviceID(0)), &cmd_info, OUT &app.EditResource(CommandBufferID(0)) )); 58 | } 59 | 60 | CHECK_ERR( app.CreateSwapchainImage( ImageID(0), uint2(1024, 768), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT )); 61 | 62 | auto act = app.BeginFrame(); 63 | CHECK_ERR( act == EAppAction::None ); 64 | 65 | // build command buffer 66 | { 67 | VkCommandBufferBeginInfo begin_info = {}; 68 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; 69 | begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; 70 | VK_CALL( app.vkBeginCommandBuffer( app.GetResource(CommandBufferID(0)), &begin_info )); 71 | 72 | 73 | // image layout undefined to transfer optimal 74 | VkImageMemoryBarrier barrier = {}; 75 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; 76 | barrier.image = app.GetResource(ImageID(0)); 77 | barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; 78 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; 79 | barrier.srcAccessMask = 0; 80 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; 81 | barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; 82 | barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; 83 | barrier.subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }; 84 | 85 | app.vkCmdPipelineBarrier( app.GetResource(CommandBufferID(0)), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 86 | 0, null, 0, null, 1, &barrier ); 87 | 88 | 89 | // clear image 90 | RGBA32f color { HSVColor{ 0.3f } }; 91 | VkClearColorValue clear_value {{ color.r, color.g, color.b, color.a }}; 92 | 93 | VkImageSubresourceRange range; 94 | range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; 95 | range.baseArrayLayer = 0; 96 | range.layerCount = 1; 97 | range.baseMipLevel = 0; 98 | range.levelCount = 1; 99 | 100 | app.vkCmdClearColorImage( app.GetResource(CommandBufferID(0)), app.GetResource(ImageID(0)), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_value, 1, &range ); 101 | 102 | 103 | // image layout transfer optimal to present source 104 | barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; 105 | barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; 106 | barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; 107 | barrier.dstAccessMask = 0; 108 | 109 | app.vkCmdPipelineBarrier( app.GetResource(CommandBufferID(0)), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 110 | 0, null, 0, null, 1, &barrier ); 111 | 112 | 113 | VK_CALL( app.vkEndCommandBuffer( app.GetResource(CommandBufferID(0)) )); 114 | } 115 | 116 | 117 | // submit commands 118 | { 119 | VkSemaphore signal_semaphores[] = { app.GetResource(SemaphoreID(0)) }; 120 | VkCommandBuffer commands[] = { app.GetResource(CommandBufferID(0)) }; 121 | VkSubmitInfo submit_info = {}; 122 | 123 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; 124 | submit_info.commandBufferCount = uint(CountOf(commands)); 125 | submit_info.pCommandBuffers = commands; 126 | submit_info.signalSemaphoreCount = uint(CountOf(signal_semaphores)); 127 | submit_info.pSignalSemaphores = signal_semaphores; 128 | 129 | VK_CHECK( app.vkQueueSubmit( app.GetResource(QueueID(0)), 1, &submit_info, VK_NULL_HANDLE )); 130 | } 131 | 132 | CHECK_ERR( app.EndFrame( EQueueFamily(0) )); 133 | 134 | app.Destroy(); 135 | 136 | return 0; 137 | } 138 | --------------------------------------------------------------------------------