├── .gitmodules ├── _config.yml ├── docs ├── images │ └── VSGlogo.png ├── README.md └── CONTRIBUTING.md ├── src └── vsg │ ├── vsgConfig.cmake.in │ ├── ui │ ├── RecordEvents.cpp │ ├── CollectEvents.cpp │ ├── ScrollWheelEvent.cpp │ ├── ShiftEventTime.cpp │ ├── TouchEvent.cpp │ ├── UIEvent.cpp │ ├── KeyEvent.cpp │ └── PointerEvent.cpp │ ├── maths │ └── common.cpp │ ├── utils │ ├── CommandLine.cpp │ └── Instrumentation.cpp │ ├── commands │ ├── SetLineWidth.cpp │ ├── CopyImage.cpp │ ├── BlitImage.cpp │ ├── CopyImageToBuffer.cpp │ ├── SetScissor.cpp │ ├── ResolveImage.cpp │ ├── SetViewport.cpp │ ├── NextSubPass.cpp │ ├── SetDepthBias.cpp │ ├── Dispatch.cpp │ ├── ClearImage.cpp │ ├── SetPrimitiveTopology.cpp │ ├── EndQuery.cpp │ ├── Draw.cpp │ └── BeginQuery.cpp │ ├── vk │ ├── Surface.cpp │ └── Semaphore.cpp │ ├── lighting │ ├── AmbientLight.cpp │ ├── HardShadows.cpp │ ├── PercentageCloserSoftShadows.cpp │ ├── ShadowSettings.cpp │ └── SoftShadows.cpp │ ├── nodes │ ├── Node.cpp │ ├── Transform.cpp │ ├── CullGroup.cpp │ └── Group.cpp │ ├── animation │ └── FindAnimations.cpp │ ├── core │ ├── Objects.cpp │ ├── MipmapLayout.cpp │ ├── Version.cpp │ └── Allocator.cpp │ ├── app │ └── WindowAdapter.cpp │ ├── io │ ├── Output.cpp │ └── Input.cpp │ ├── state │ └── StateCommand.cpp │ ├── raytracing │ └── RayTracingShaderGroup.cpp │ └── platform │ └── ios │ └── iOS_ViewController.mm ├── cmake ├── uninstall.cmake ├── FindVulkan.cmake └── header_license_preamble.txt ├── include └── vsg │ ├── platform │ └── ios │ │ └── iOS_ViewController.h │ ├── core │ ├── Mask.h │ ├── Exception.h │ ├── Export.h │ └── contains.h │ ├── io │ ├── write.h │ ├── json.h │ └── spirv.h │ ├── animation │ └── FindAnimations.h │ ├── commands │ ├── Command.h │ ├── SetLineWidth.h │ ├── CopyImage.h │ ├── ResolveImage.h │ ├── SetScissor.h │ ├── SetViewport.h │ ├── BlitImage.h │ ├── EndQuery.h │ ├── CopyImageViewToWindow.h │ ├── CopyImageToBuffer.h │ ├── NextSubPass.h │ ├── SetDepthBias.h │ ├── SetPrimitiveTopology.h │ ├── BeginQuery.h │ ├── ResetQueryPool.h │ ├── ClearAttachments.h │ ├── WriteTimestamp.h │ ├── Dispatch.h │ ├── CopyQueryPoolResults.h │ └── DrawIndirect.h │ ├── app │ └── Presentation.h │ ├── ui │ ├── CollectEvents.h │ ├── RecordEvents.h │ ├── ShiftEventTime.h │ ├── FrameStamp.h │ ├── UIEvent.h │ └── ScrollWheelEvent.h │ ├── nodes │ ├── Compilable.h │ ├── CullGroup.h │ ├── CoordinateFrame.h │ └── Node.h │ ├── vk │ └── Slots.h │ ├── text │ ├── TextTechnique.h │ └── TextLayout.h │ ├── lighting │ ├── HardShadows.h │ ├── SoftShadows.h │ ├── AmbientLight.h │ ├── ShadowSettings.h │ ├── PercentageCloserSoftShadows.h │ └── PointLight.h │ ├── meshshaders │ ├── DrawMeshTasks.h │ ├── DrawMeshTasksIndirectCount.h │ └── DrawMeshTasksIndirect.h │ ├── raytracing │ ├── TraceRays.h │ └── BottomLevelAccelerationStructure.h │ ├── utils │ └── ShaderCompiler.h │ ├── state │ └── PushConstants.h │ ├── maths │ └── numbers.h │ └── threading │ ├── Affinity.h │ └── ActivityStatus.h ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── workflows │ ├── build-docs.yml │ ├── ci-android.yml │ └── ci.yml └── PULL_REQUEST_TEMPLATE.md ├── LICENSE.md └── .gitignore /.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-leap-day 2 | -------------------------------------------------------------------------------- /docs/images/VSGlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsg-dev/VulkanSceneGraph/HEAD/docs/images/VSGlogo.png -------------------------------------------------------------------------------- /src/vsg/vsgConfig.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | 3 | find_package(Vulkan @Vulkan_MIN_VERSION@ REQUIRED) 4 | find_dependency(Threads) 5 | @FIND_DEPENDENCY_glslang@ 6 | if (@VSG_SUPPORTS_ShaderOptimizer@) 7 | find_dependency(SPIRV-Tools-opt) 8 | endif() 9 | @FIND_DEPENDENCY_WINDOWING@ 10 | 11 | include("${CMAKE_CURRENT_LIST_DIR}/vsgTargets.cmake") 12 | include("${CMAKE_CURRENT_LIST_DIR}/vsgMacros.cmake") 13 | -------------------------------------------------------------------------------- /cmake/uninstall.cmake: -------------------------------------------------------------------------------- 1 | if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") 2 | 3 | file(READ "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt" files) 4 | string(REGEX REPLACE "\n" ";" files "${files}") 5 | 6 | foreach(file ${files}) 7 | if(EXISTS "${file}") 8 | message(STATUS "Uninstalling \"${file}\"") 9 | file(REMOVE_RECURSE ${file}) 10 | endif() 11 | endforeach() 12 | 13 | else() 14 | message(FATAL_ERROR "Cannot find install manifest: \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\"") 15 | endif() 16 | -------------------------------------------------------------------------------- /include/vsg/platform/ios/iOS_ViewController.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | #include 5 | #include 6 | 7 | #pragma mark - 8 | #pragma mark vsg_iOS_View 9 | @interface vsg_iOS_View : UIView 10 | @end 11 | 12 | 13 | #pragma mark - 14 | #pragma mark vsg_iOS_ViewController 15 | @interface vsg_iOS_ViewController : UIViewController 16 | @property vsg::ref_ptr vsgWindow; 17 | - (instancetype)initWithTraits:(vsg::ref_ptr)traits andVsgViewer:(vsg::ref_ptr) vsgViewer; 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/workflows/build-docs.yml: -------------------------------------------------------------------------------- 1 | name: build-docs 2 | on: 3 | workflow_dispatch: 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v2 9 | - name: Install Doxygen 10 | run: sudo apt install doxygen graphviz 11 | - name: Install Vulkan 12 | uses: humbletim/install-vulkan-sdk@v1.1.1 13 | with: 14 | version: latest 15 | - name: Configure VulkanSceneGraph 16 | run: cmake -S . -B . -DCMAKE_BUILD_TYPE=Release 17 | - name: Build Documentation 18 | run: make -j 2 docs 19 | - name: Publish Docs 20 | uses: actions/upload-artifact@v1 21 | with: 22 | name: VSG Documentation 23 | path: html 24 | -------------------------------------------------------------------------------- /cmake/FindVulkan.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # wrapper for finding a specific minimum Vulkan version 3 | # 4 | 5 | if(Vulkan_FIND_REQUIRED) 6 | set(OPTIONS REQUIRED) 7 | endif() 8 | 9 | # force using cmake provided module path 10 | set(_SAVE_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) 11 | unset(CMAKE_MODULE_PATH) 12 | 13 | # 14 | # For cmake versions < 3.23, the included FindVulkan.cmake 15 | # module has no version support. 16 | # 17 | if(CMAKE_VERSION VERSION_LESS "3.23") 18 | find_package(Vulkan ${Vulkan_FIND_VERSION} ${OPTIONS} QUIET) 19 | if(Vulkan_FIND_VERSION) 20 | message(STATUS "Using Vulkan version check embedded in vsg") 21 | vsg_check_min_vulkan_header_version(${Vulkan_FIND_VERSION}) 22 | endif() 23 | else() 24 | find_package(Vulkan ${Vulkan_FIND_VERSION} ${OPTIONS}) 25 | endif() 26 | 27 | # restore cmake module path 28 | set(CMAKE_MODULE_PATH ${_SAVE_CMAKE_MODULE_PATH}) 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. iOS] 25 | - Browser [e.g. chrome, safari] 26 | - Version [e.g. 22] 27 | 28 | **Smartphone (please complete the following information):** 29 | - Device: [e.g. iPhone6] 30 | - OS: [e.g. iOS8.1] 31 | - Browser [e.g. stock browser, safari] 32 | - Version [e.g. 22] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Resources within VulkanSceneGraph repo 2 | 3 | * [Project Code of Conduct](CODE_OF_CONDUCT.md) 4 | * [Contribution to VulkanSceneGraph Project](CONTRIBUTING.md) 5 | 6 | # Useful 3rd party links to information on Vulkan 7 | 8 | * [Introduction to Vulkan | Algorithms for Real-Time Rendering Lecture, Summer Term 2020](https://www.youtube.com/watch?v=isbMMIwmZes) 9 | * [Vulkanised-2021 presentations](https://www.khronos.org/events/vulkanised-2021) 10 | * Vulkan Synchronization: 11 | - [Guide to Vulkan Synchronization](https://www.lunarg.com/news-insights/white-papers/guide-to-vulkan-synchronization-validation/) 12 | - [Synchronization2 Validation](https://www.lunarg.com/news-insights/white-papers/vulkan-synchronization2-validation/) 13 | * Building a Vulkan Layer in Symbiose Within the Vulkan Ecosystem: 14 | - Whitepaper: https://www.lunarg.com/wp-content/uploads/2021/09/Vulkan-Layer-Symbiosis-within-the-Vulkan-Ecosystem.pdf 15 | - Whitepaper: https://www.lunarg.com/wp-content/uploads/2021/09/Enhanced-Devsim-15Sept2021.pdf 16 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /cmake/header_license_preamble.txt: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | -------------------------------------------------------------------------------- /.github/workflows/ci-android.yml: -------------------------------------------------------------------------------- 1 | name: CI Android 2 | on: 3 | push: 4 | pull_request: 5 | env: 6 | BuildDocEnabled: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} 7 | CMakeVersion: 3.10.x 8 | jobs: 9 | build: 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | matrix: 13 | os: [ubuntu-latest] 14 | android-platform: [24, latest] 15 | android-abi: [armeabi-v7a, arm64-v8a] 16 | build-shared: [ON] 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: Setup cmake 21 | uses: jwlawson/actions-setup-cmake@v1.12 22 | with: 23 | cmake-version: ${{ env.CMakeVersion }} 24 | - name: Setup NDK 25 | uses: nttld/setup-ndk@v1 26 | with: 27 | ndk-version: r23c 28 | - name: Build and Install VSG 29 | shell: bash 30 | run: | 31 | cmake . -DCMAKE_TOOLCHAIN_FILE=$(dirname $(which ndk-build))/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{matrix.android-abi}} -DANDROID_PLATFORM=${{matrix.android-platform}} -DBUILD_SHARED_LIBS=${{matrix.build-shared}} -DCMAKE_INSTALL_PREFIX=./install 32 | cmake --build . --target install --config Release 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | 3 | lib/ 4 | bin/ 5 | build/ 6 | 7 | # local clone of gslang 8 | src/glslang 9 | 10 | # Autogenerated files 11 | include/vsg/core/Version.h 12 | 13 | CMakeDoxyfile.in 14 | CMakeDoxygenDefaults.cmake 15 | Doxyfile.docs 16 | docs/ExplorationPhase/3rdPartyResources.md.backup 17 | vsgConfigVersion.cmake 18 | vsgConfig.cmake 19 | Doxyfile.docs-vsg 20 | 21 | html 22 | 23 | *.pc 24 | *.conf 25 | *.backup 26 | cmake_uninstall.cmake 27 | CMakeCache.txt 28 | CMakeFiles 29 | CMakeScripts 30 | Makefile 31 | cmake_install.cmake 32 | install_manifest.txt 33 | *.ninja 34 | .ninja_log 35 | .ninja_deps 36 | .cmake/ 37 | compile_commands.json 38 | 39 | 40 | # Compiled Object files 41 | *.slo 42 | *.lo 43 | *.o 44 | *.obj 45 | 46 | # Precompiled Headers 47 | *.gch 48 | *.pch 49 | 50 | # Compiled Dynamic libraries 51 | *.so 52 | *.dylib 53 | *.dll 54 | 55 | # Fortran module files 56 | *.mod 57 | 58 | # Compiled Static libraries 59 | *.lai 60 | *.la 61 | *.a 62 | *.lib 63 | 64 | # Executables 65 | *.exe 66 | *.out 67 | *.app 68 | 69 | # Visual Studio files 70 | *.sln 71 | *.vcxproj 72 | *.vcxproj.filters 73 | *.vcxproj.user 74 | .vs/ 75 | x64/ 76 | src/vsg/vsg.dir/ 77 | 78 | #xcode 79 | DerivedData/ 80 | *.build 81 | *.xcodeproj 82 | 83 | #glslang automatically generated files 84 | include/glslang 85 | src/vsg/CHANGES.md 86 | 87 | -------------------------------------------------------------------------------- /src/vsg/ui/RecordEvents.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void RecordEvents::apply(vsg::UIEvent& event) 18 | { 19 | events->addChild(vsg::ref_ptr(&event)); 20 | } 21 | -------------------------------------------------------------------------------- /include/vsg/core/Mask.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | using Mask = uint64_t; 21 | constexpr Mask MASK_OFF = 0ul; 22 | constexpr Mask MASK_ALL = ~MASK_OFF; 23 | 24 | } // namespace vsg 25 | -------------------------------------------------------------------------------- /src/vsg/maths/common.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | 4 | Copyright(c) 2024 Robert Osfield 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | 12 | */ 13 | 14 | #include 15 | 16 | #include 17 | 18 | uint32_t vsg::native_long_double_bits() 19 | { 20 | if (LDBL_MANT_DIG == DBL_MANT_DIG) return 64; 21 | return LDBL_MANT_DIG <= 64 ? 80 : 128; 22 | } 23 | -------------------------------------------------------------------------------- /src/vsg/ui/CollectEvents.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void CollectEvents::apply(vsg::Object& object) 18 | { 19 | object.traverse(*this); 20 | } 21 | 22 | void CollectEvents::apply(vsg::UIEvent& event) 23 | { 24 | events.push_back(vsg::ref_ptr(&event)); 25 | } 26 | -------------------------------------------------------------------------------- /src/vsg/utils/CommandLine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | CommandLine::CommandLine(int* argc, char** argv) : 18 | _argc(argc), 19 | _argv(argv) 20 | { 21 | } 22 | 23 | bool CommandLine::read(Options* options) 24 | { 25 | return (options != nullptr) && options->readOptions(*this); 26 | } 27 | -------------------------------------------------------------------------------- /src/vsg/commands/SetLineWidth.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | SetLineWidth::SetLineWidth(float in_lineWidth) : 19 | lineWidth(in_lineWidth) 20 | { 21 | } 22 | 23 | void SetLineWidth::record(CommandBuffer& commandBuffer) const 24 | { 25 | vkCmdSetLineWidth(commandBuffer, lineWidth); 26 | } 27 | -------------------------------------------------------------------------------- /include/vsg/io/write.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /** convenience method for writing objects to file.*/ 23 | extern VSG_DECLSPEC bool write(ref_ptr object, const Path& filename, ref_ptr options = {}); 24 | 25 | } // namespace vsg 26 | -------------------------------------------------------------------------------- /src/vsg/ui/ScrollWheelEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void ScrollWheelEvent::read(Input& input) 18 | { 19 | WindowEvent::read(input); 20 | 21 | input.read("delta", delta); 22 | } 23 | 24 | void ScrollWheelEvent::write(Output& output) const 25 | { 26 | WindowEvent::write(output); 27 | 28 | output.write("delta", delta); 29 | } 30 | -------------------------------------------------------------------------------- /src/vsg/ui/ShiftEventTime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | ShiftEventTime::ShiftEventTime(vsg::clock::time_point::duration in_delta) : 18 | delta(in_delta) 19 | { 20 | } 21 | 22 | void ShiftEventTime::apply(vsg::Object& object) 23 | { 24 | object.traverse(*this); 25 | } 26 | 27 | void ShiftEventTime::apply(vsg::UIEvent& event) 28 | { 29 | event.time += delta; 30 | } 31 | -------------------------------------------------------------------------------- /include/vsg/core/Exception.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// Exception object that can be thrown from VSG code, such as failed Vulkan calls where the result value will be the VkResult value 21 | /// returned from failed Vulkan call. 22 | struct Exception 23 | { 24 | std::string message; 25 | int result = 0; 26 | }; 27 | 28 | } // namespace vsg 29 | -------------------------------------------------------------------------------- /src/vsg/vk/Surface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | Surface::Surface(VkSurfaceKHR surface, Instance* instance) : 19 | _surface(surface), 20 | _instance(instance) 21 | { 22 | } 23 | 24 | Surface::~Surface() 25 | { 26 | if (_surface) 27 | { 28 | vkDestroySurfaceKHR(*_instance, _surface, _instance->getAllocationCallbacks()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Pull Request Template 2 | 3 | ## Description 4 | 5 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. 6 | 7 | Fixes # (issue) 8 | 9 | ## Type of change 10 | 11 | Please delete options that are not relevant. 12 | 13 | - [ ] Bug fix (non-breaking change which fixes an issue) 14 | - [ ] New feature (non-breaking change which adds functionality) 15 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 16 | - [ ] This change requires a documentation update 17 | 18 | ## How Has This Been Tested? 19 | 20 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration 21 | 22 | - [ ] Test A 23 | - [ ] Test B 24 | 25 | **Test Configuration**: 26 | * Firmware version: 27 | * Hardware: 28 | * Toolchain: 29 | * SDK: 30 | 31 | ## Checklist: 32 | 33 | - [ ] My code follows the style guidelines of this project 34 | - [ ] I have performed a self-review of my own code 35 | - [ ] I have commented my code, particularly in hard-to-understand areas 36 | - [ ] I have made corresponding changes to the documentation 37 | - [ ] My changes generate no new warnings 38 | - [ ] I have added tests that prove my fix is effective or that my feature works 39 | - [ ] New and existing unit tests pass locally with my changes 40 | - [ ] Any dependent changes have been merged and published in downstream modules 41 | -------------------------------------------------------------------------------- /src/vsg/ui/TouchEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void TouchEvent::read(Input& input) 18 | { 19 | UIEvent::read(input); 20 | 21 | input.read("x", x); 22 | input.read("y", y); 23 | input.read("id", id); 24 | } 25 | 26 | void TouchEvent::write(Output& output) const 27 | { 28 | UIEvent::write(output); 29 | 30 | output.write("x", x); 31 | output.write("y", y); 32 | output.write("id", id); 33 | } 34 | -------------------------------------------------------------------------------- /src/vsg/lighting/AmbientLight.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2024 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | AmbientLight::AmbientLight() 18 | { 19 | } 20 | 21 | AmbientLight::AmbientLight(const AmbientLight& rhs, const CopyOp& copyop) : 22 | Inherit(rhs, copyop) 23 | { 24 | } 25 | 26 | void AmbientLight::read(Input& input) 27 | { 28 | Light::read(input); 29 | } 30 | 31 | void AmbientLight::write(Output& output) const 32 | { 33 | Light::write(output); 34 | } 35 | -------------------------------------------------------------------------------- /src/vsg/nodes/Node.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | Node::Node() 19 | { 20 | } 21 | 22 | Node::Node(const Node& rhs, const CopyOp& copyop) : 23 | Inherit(rhs, copyop) 24 | { 25 | } 26 | 27 | Node::~Node() 28 | { 29 | } 30 | 31 | void* Node::operator new(std::size_t count) 32 | { 33 | return vsg::allocate(count, vsg::ALLOCATOR_AFFINITY_NODES); 34 | } 35 | 36 | void Node::operator delete(void* ptr) 37 | { 38 | vsg::deallocate(ptr); 39 | } 40 | -------------------------------------------------------------------------------- /src/vsg/commands/CopyImage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | CopyImage::CopyImage() 19 | { 20 | } 21 | 22 | void CopyImage::record(CommandBuffer& commandBuffer) const 23 | { 24 | vkCmdCopyImage( 25 | commandBuffer, 26 | srcImage->vk(commandBuffer.deviceID), 27 | srcImageLayout, 28 | dstImage->vk(commandBuffer.deviceID), 29 | dstImageLayout, 30 | static_cast(regions.size()), 31 | regions.data()); 32 | } 33 | -------------------------------------------------------------------------------- /src/vsg/animation/FindAnimations.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2024 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace vsg; 19 | 20 | void FindAnimations::apply(Object& object) 21 | { 22 | object.traverse(*this); 23 | } 24 | 25 | void FindAnimations::apply(Animation& animation) 26 | { 27 | animations.emplace_back(&animation); 28 | } 29 | 30 | void FindAnimations::apply(AnimationGroup& node) 31 | { 32 | animationGroups.emplace_back(&node); 33 | node.traverse(*this); 34 | } 35 | -------------------------------------------------------------------------------- /src/vsg/commands/BlitImage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2020 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | BlitImage::BlitImage() 19 | { 20 | } 21 | 22 | void BlitImage::record(CommandBuffer& commandBuffer) const 23 | { 24 | vkCmdBlitImage( 25 | commandBuffer, 26 | srcImage->vk(commandBuffer.deviceID), 27 | srcImageLayout, 28 | dstImage->vk(commandBuffer.deviceID), 29 | dstImageLayout, 30 | static_cast(regions.size()), 31 | regions.data(), 32 | filter); 33 | } 34 | -------------------------------------------------------------------------------- /src/vsg/commands/CopyImageToBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2020 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | CopyImageToBuffer::CopyImageToBuffer() 19 | { 20 | } 21 | 22 | void CopyImageToBuffer::record(CommandBuffer& commandBuffer) const 23 | { 24 | vkCmdCopyImageToBuffer( 25 | commandBuffer, 26 | srcImage->vk(commandBuffer.deviceID), 27 | srcImageLayout, 28 | dstBuffer->vk(commandBuffer.deviceID), 29 | static_cast(regions.size()), 30 | regions.data()); 31 | } 32 | -------------------------------------------------------------------------------- /include/vsg/animation/FindAnimations.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | class VSG_DECLSPEC FindAnimations : public Inherit 21 | { 22 | public: 23 | Animations animations; 24 | AnimationGroups animationGroups; 25 | 26 | void apply(Object& object) override; 27 | void apply(Animation& animation) override; 28 | void apply(AnimationGroup& node) override; 29 | }; 30 | VSG_type_name(vsg::FindAnimations); 31 | 32 | } // namespace vsg 33 | -------------------------------------------------------------------------------- /src/vsg/commands/SetScissor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | SetScissor::SetScissor() : 19 | firstScissor(0) 20 | { 21 | } 22 | 23 | SetScissor::SetScissor(uint32_t in_firstScissor, const Scissors& in_scissors) : 24 | firstScissor(in_firstScissor), 25 | scissors(in_scissors) 26 | { 27 | } 28 | 29 | void SetScissor::record(CommandBuffer& commandBuffer) const 30 | { 31 | vkCmdSetScissor(commandBuffer, firstScissor, static_cast(scissors.size()), scissors.data()); 32 | } 33 | -------------------------------------------------------------------------------- /src/vsg/core/Objects.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace vsg; 18 | 19 | Objects::Objects(size_t numChildren) : 20 | children(numChildren) 21 | { 22 | } 23 | 24 | Objects::~Objects() 25 | { 26 | } 27 | 28 | void Objects::read(Input& input) 29 | { 30 | Object::read(input); 31 | 32 | input.readObjects("children", children); 33 | } 34 | 35 | void Objects::write(Output& output) const 36 | { 37 | Object::write(output); 38 | 39 | output.writeObjects("children", children); 40 | } 41 | -------------------------------------------------------------------------------- /src/vsg/commands/ResolveImage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2022 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | ResolveImage::ResolveImage() 19 | { 20 | } 21 | 22 | void ResolveImage::record(CommandBuffer& commandBuffer) const 23 | { 24 | vkCmdResolveImage(commandBuffer, 25 | srcImage->vk(commandBuffer.deviceID), srcImageLayout, 26 | dstImage->vk(commandBuffer.deviceID), dstImageLayout, 27 | static_cast(regions.size()), regions.empty() ? nullptr : regions.data()); 28 | } 29 | -------------------------------------------------------------------------------- /src/vsg/commands/SetViewport.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | SetViewport::SetViewport() : 19 | firstViewport(0) 20 | { 21 | } 22 | 23 | SetViewport::SetViewport(uint32_t in_firstViewport, const Viewports& in_viewports) : 24 | firstViewport(in_firstViewport), 25 | viewports(in_viewports) 26 | { 27 | } 28 | 29 | void SetViewport::record(CommandBuffer& commandBuffer) const 30 | { 31 | vkCmdSetViewport(commandBuffer, firstViewport, static_cast(viewports.size()), viewports.data()); 32 | } 33 | -------------------------------------------------------------------------------- /docs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | Developers can help contribute to the VSG through testing, reporting issues, bug fixing, feature development and creation of tutorials and documentation. 3 | 4 | ## Report a bug 5 | 6 | Please use the Issue tracker on github. We provide two templates, a bug report template and a feature request template to help guide what type of information is useful to us. 7 | 8 | ## Bug fixes 9 | 10 | If you have made a bug fix please make a pull request on github. With the PR please use a descriptive but short title line, followed by a paragraph explaining the bug and changes, with references to the github Issue if one has been raised for it. 11 | 12 | ## Feature request 13 | 14 | If you wish to make a feature request, this can be done via our github Issue tracker. Please be prepared to step forward to help with this feature development, or help fund others to do this feature development. If features are not aligned well with the projects scope and goals then these requests will be closed and a path forward for developing this as a 3rd party development will be suggested. 15 | 16 | ## Feature development 17 | 18 | If you have refined existing features or added new features please a make pull request. 19 | 20 | ## In source documentation 21 | 22 | In source documentation can be provided in the form of markdown (.MD) files to be found in the docs/ directory, or as doxygen style comments within the header files. Please use a pull request. 23 | 24 | ## 3rd Party tutorials, documentation, libraries and program 25 | 26 | If you have written documentation, tutorials, libraries or programs and wish to inform developers then please consider adding details about them to the docs/3rdParty files and generating a pull request. 27 | -------------------------------------------------------------------------------- /include/vsg/core/Export.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #if defined(_MSC_VER) 16 | # pragma warning(disable : 4251) 17 | #endif 18 | 19 | #if defined(WIN32) 20 | # if defined(vsg_EXPORTS) 21 | # define VSG_DECLSPEC __declspec(dllexport) 22 | # elif defined(VSG_SHARED_LIBRARY) 23 | # define VSG_DECLSPEC __declspec(dllimport) 24 | # else 25 | # define VSG_DECLSPEC 26 | # endif 27 | #else 28 | # if defined(VSG_SHARED_LIBRARY) || defined(VSG_EXPORTS) 29 | # define VSG_DECLSPEC __attribute__((visibility("default"))) 30 | # else 31 | # define VSG_DECLSPEC 32 | # endif 33 | #endif 34 | -------------------------------------------------------------------------------- /include/vsg/commands/Command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | class CommandBuffer; 20 | 21 | /// Command base class for encapsulating vkCmd* calls and associated settings. 22 | class VSG_DECLSPEC Command : public Inherit 23 | { 24 | public: 25 | Command() {} 26 | Command(const Command& rhs, const CopyOp& copyop = {}) : 27 | Inherit(rhs, copyop) {} 28 | 29 | virtual void record(CommandBuffer& commandBuffer) const = 0; 30 | }; 31 | VSG_type_name(vsg::Command); 32 | 33 | } // namespace vsg 34 | -------------------------------------------------------------------------------- /include/vsg/app/Presentation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// Presentation provides support for presenting swapchains associated with windows. 21 | class Presentation : public Inherit 22 | { 23 | public: 24 | VkResult present(); 25 | 26 | Windows windows; 27 | Semaphores waitSemaphores; // taken from RecordAndSubmitTasks.signalSemaphores 28 | 29 | ref_ptr queue; // assign in application for GraphicsQueue from device 30 | }; 31 | VSG_type_name(vsg::Presentation); 32 | 33 | } // namespace vsg 34 | -------------------------------------------------------------------------------- /src/vsg/commands/NextSubPass.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | NextSubPass::~NextSubPass() 19 | { 20 | } 21 | 22 | void NextSubPass::read(Input& input) 23 | { 24 | Command::read(input); 25 | 26 | input.readValue("contents", contents); 27 | } 28 | 29 | void NextSubPass::write(Output& output) const 30 | { 31 | Command::write(output); 32 | 33 | output.writeValue("contents", contents); 34 | } 35 | 36 | void NextSubPass::record(CommandBuffer& commandBuffer) const 37 | { 38 | vkCmdNextSubpass(commandBuffer, contents); 39 | } 40 | -------------------------------------------------------------------------------- /src/vsg/core/MipmapLayout.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace vsg; 18 | 19 | MipmapLayout::MipmapLayout() 20 | { 21 | } 22 | 23 | MipmapLayout::MipmapLayout(std::size_t size) : 24 | mipmaps(size) 25 | { 26 | } 27 | 28 | MipmapLayout::~MipmapLayout() 29 | { 30 | } 31 | 32 | void MipmapLayout::read(Input& input) 33 | { 34 | Object::read(input); 35 | 36 | input.readValues("mipmaps", mipmaps); 37 | } 38 | 39 | void MipmapLayout::write(Output& output) const 40 | { 41 | Object::write(output); 42 | 43 | output.writeValues("mipmaps", mipmaps); 44 | } 45 | -------------------------------------------------------------------------------- /include/vsg/ui/CollectEvents.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// CollectEvents is a visitor that collects ui events into a list of events. 23 | class VSG_DECLSPEC CollectEvents : public vsg::Inherit 24 | { 25 | public: 26 | std::list> events; 27 | 28 | void apply(vsg::Object& object) override; 29 | void apply(vsg::UIEvent& event) override; 30 | }; 31 | VSG_type_name(vsg::CollectEvents); 32 | 33 | } // namespace vsg 34 | -------------------------------------------------------------------------------- /include/vsg/commands/SetLineWidth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2021 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// SetLineWidth command encapsulates vkCmdSetLineWidth functionality, associated with dynamic updating of a GraphicsPipeline's RasterizationState::lineWidth 21 | class VSG_DECLSPEC SetLineWidth : public Inherit 22 | { 23 | public: 24 | explicit SetLineWidth(float in_lineWidth = 0.0f); 25 | 26 | float lineWidth = 0.0f; 27 | 28 | void record(CommandBuffer& commandBuffer) const override; 29 | }; 30 | VSG_type_name(vsg::SetLineWidth); 31 | 32 | } // namespace vsg 33 | -------------------------------------------------------------------------------- /src/vsg/lighting/HardShadows.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2024 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | HardShadows::HardShadows(uint32_t in_shadowMaps) : 18 | Inherit(in_shadowMaps) 19 | { 20 | } 21 | 22 | HardShadows::HardShadows(const HardShadows& rhs, const CopyOp& copyop) : 23 | Inherit(rhs, copyop) 24 | { 25 | } 26 | 27 | int HardShadows::compare(const Object& rhs_object) const 28 | { 29 | return ShadowSettings::compare(rhs_object); 30 | } 31 | 32 | void HardShadows::read(Input& input) 33 | { 34 | ShadowSettings::read(input); 35 | } 36 | 37 | void HardShadows::write(Output& output) const 38 | { 39 | ShadowSettings::write(output); 40 | } 41 | -------------------------------------------------------------------------------- /include/vsg/nodes/Compilable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | class Context; 20 | 21 | /// Base class for encapsulating nodes that have Vulkan objects associated with them that will need compiling during the compile traversal 22 | class VSG_DECLSPEC Compilable : public Inherit 23 | { 24 | public: 25 | Compilable() {} 26 | Compilable(const Compilable& rhs, const CopyOp& copyop = {}) : 27 | Inherit(rhs, copyop) {} 28 | 29 | virtual void compile(Context& /*context*/) {}; 30 | }; 31 | VSG_type_name(vsg::Compilable); 32 | 33 | } // namespace vsg 34 | -------------------------------------------------------------------------------- /src/vsg/ui/UIEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void UIEvent::read(Input& input) 18 | { 19 | Object::read(input); 20 | 21 | uint64_t time_since_epoch; 22 | input.readValue("time", time_since_epoch); 23 | time = clock::time_point(clock::time_point::duration(time_since_epoch)); 24 | 25 | input.read("handled", handled); 26 | } 27 | 28 | void UIEvent::write(Output& output) const 29 | { 30 | Object::write(output); 31 | 32 | uint64_t time_since_epoch = time.time_since_epoch().count(); 33 | output.writeValue("time", time_since_epoch); 34 | 35 | output.write("handled", handled); 36 | } 37 | -------------------------------------------------------------------------------- /src/vsg/utils/Instrumentation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2023 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace vsg; 18 | 19 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 20 | // 21 | // Instrumentation base class 22 | // 23 | Instrumentation::Instrumentation() 24 | { 25 | } 26 | 27 | Instrumentation::~Instrumentation() 28 | { 29 | } 30 | 31 | ref_ptr vsg::shareOrDuplicateForThreadSafety(ref_ptr instrumentation) 32 | { 33 | return instrumentation ? instrumentation->shareOrDuplicateForThreadSafety() : instrumentation; 34 | } 35 | -------------------------------------------------------------------------------- /src/vsg/commands/SetDepthBias.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | SetDepthBias::SetDepthBias() 19 | { 20 | } 21 | 22 | SetDepthBias::SetDepthBias(float in_depthBiasConstantFactor, float in_depthBiasClamp, float in_depthBiasSlopeFactor) : 23 | depthBiasConstantFactor(in_depthBiasConstantFactor), 24 | depthBiasClamp(in_depthBiasClamp), 25 | depthBiasSlopeFactor(in_depthBiasSlopeFactor) 26 | { 27 | } 28 | 29 | void SetDepthBias::record(CommandBuffer& commandBuffer) const 30 | { 31 | vkCmdSetDepthBias(commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor); 32 | } 33 | -------------------------------------------------------------------------------- /include/vsg/vk/Slots.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2025 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// max slot values used for general state and view state related State::stateStacks 21 | struct Slots 22 | { 23 | uint32_t state = 0; 24 | uint32_t view = 0; 25 | 26 | /// return maximum of the state and view slot numbers 27 | uint32_t max() const 28 | { 29 | return view > state ? view : state; 30 | } 31 | 32 | void merge(const Slots& rhs) 33 | { 34 | if (rhs.state > state) state = rhs.state; 35 | if (rhs.view > view) view = rhs.view; 36 | } 37 | }; 38 | 39 | } // namespace vsg 40 | -------------------------------------------------------------------------------- /include/vsg/text/TextTechnique.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2020 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | // forward declare Text 21 | class Text; 22 | 23 | // base class for implementation of rendering backend for Text 24 | class VSG_DECLSPEC TextTechnique : public Inherit 25 | { 26 | public: 27 | virtual void setup(Text* text, uint32_t minimumAllocation = 0, ref_ptr options = {}) = 0; 28 | virtual void setup(TextGroup* text, uint32_t minimumAllocation = 0, ref_ptr options = {}) = 0; 29 | virtual dbox extents() const = 0; 30 | }; 31 | VSG_type_name(vsg::TextTechnique); 32 | 33 | } // namespace vsg 34 | -------------------------------------------------------------------------------- /include/vsg/commands/CopyImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2019 Thomas Hogarth 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// CopyImage command encapsulates vkCmdCopyImage and associated settings 22 | class VSG_DECLSPEC CopyImage : public Inherit 23 | { 24 | public: 25 | CopyImage(); 26 | 27 | ref_ptr srcImage; 28 | VkImageLayout srcImageLayout; 29 | ref_ptr dstImage; 30 | VkImageLayout dstImageLayout; 31 | std::vector regions; 32 | 33 | void record(CommandBuffer& commandBuffer) const override; 34 | }; 35 | VSG_type_name(vsg::CopyImage); 36 | 37 | } // namespace vsg 38 | -------------------------------------------------------------------------------- /include/vsg/commands/ResolveImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// ResolveImage command encapsulates vkCmdResolveImage functionality 22 | class VSG_DECLSPEC ResolveImage : public Inherit 23 | { 24 | public: 25 | ResolveImage(); 26 | 27 | ref_ptr srcImage; 28 | VkImageLayout srcImageLayout; 29 | ref_ptr dstImage; 30 | VkImageLayout dstImageLayout; 31 | std::vector regions; 32 | 33 | void record(CommandBuffer& commandBuffer) const override; 34 | }; 35 | VSG_type_name(vsg::ResolveImage); 36 | 37 | } // namespace vsg 38 | -------------------------------------------------------------------------------- /src/vsg/app/WindowAdapter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | WindowAdapter::WindowAdapter(vsg::ref_ptr surface, vsg::ref_ptr traits) : 18 | Inherit(traits) 19 | { 20 | if (surface) 21 | { 22 | _surface = surface; 23 | _instance = surface->getInstance(); 24 | } 25 | if (traits) 26 | { 27 | _extent2D.width = traits->width; 28 | _extent2D.height = traits->height; 29 | } 30 | } 31 | 32 | void WindowAdapter::updateExtents(uint32_t width, uint32_t height) 33 | { 34 | _extent2D.width = width; 35 | _extent2D.height = height; 36 | } 37 | 38 | void WindowAdapter::resize() 39 | { 40 | buildSwapchain(); 41 | } 42 | -------------------------------------------------------------------------------- /src/vsg/commands/Dispatch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void Dispatch::read(Input& input) 18 | { 19 | Command::read(input); 20 | 21 | input.read("groupCountX", groupCountX); 22 | input.read("groupCountY", groupCountY); 23 | input.read("groupCountZ", groupCountZ); 24 | } 25 | 26 | void Dispatch::write(Output& output) const 27 | { 28 | Command::write(output); 29 | 30 | output.write("groupCountX", groupCountX); 31 | output.write("groupCountY", groupCountY); 32 | output.write("groupCountZ", groupCountZ); 33 | } 34 | 35 | void Dispatch::record(CommandBuffer& commandBuffer) const 36 | { 37 | vkCmdDispatch(commandBuffer, groupCountX, groupCountY, groupCountZ); 38 | } 39 | -------------------------------------------------------------------------------- /src/vsg/ui/KeyEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void KeyEvent::read(Input& input) 18 | { 19 | UIEvent::read(input); 20 | 21 | input.readValue("keyBase", keyBase); 22 | input.readValue("keyModified", keyModified); 23 | input.readValue("keyModifier", keyModifier); 24 | input.read("repeatCount", repeatCount); 25 | } 26 | 27 | void KeyEvent::write(Output& output) const 28 | { 29 | UIEvent::write(output); 30 | 31 | output.writeValue("keyBase", keyBase); 32 | output.writeValue("keyModified", keyModified); 33 | output.writeValue("keyModifier", keyModifier); 34 | output.write("repeatCount", repeatCount); 35 | } 36 | -------------------------------------------------------------------------------- /include/vsg/commands/SetScissor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2021 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// SetScissor command encapsulates vkCmdSetScissor functionality, associated with dynamic updating of a GraphicsPipeline's ViewportState 22 | class VSG_DECLSPEC SetScissor : public Inherit 23 | { 24 | public: 25 | SetScissor(); 26 | SetScissor(uint32_t in_firstScissor, const Scissors& in_scissors); 27 | 28 | uint32_t firstScissor = 0; 29 | Scissors scissors; 30 | 31 | void record(CommandBuffer& commandBuffer) const override; 32 | }; 33 | VSG_type_name(vsg::SetScissor); 34 | 35 | } // namespace vsg 36 | -------------------------------------------------------------------------------- /include/vsg/commands/SetViewport.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2021 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// SetViewport command encapsulates vkCmdSetViewport call, associated with dynamic updating of a GraphicsPipeline's ViewportState 22 | class VSG_DECLSPEC SetViewport : public Inherit 23 | { 24 | public: 25 | SetViewport(); 26 | SetViewport(uint32_t in_firstViewport, const Viewports& in_viewports); 27 | 28 | uint32_t firstViewport = 0; 29 | Viewports viewports; 30 | 31 | void record(CommandBuffer& commandBuffer) const override; 32 | }; 33 | VSG_type_name(vsg::SetViewport); 34 | 35 | } // namespace vsg 36 | -------------------------------------------------------------------------------- /src/vsg/io/Output.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | Output::Output() : 19 | version{vsgGetVersion()} 20 | { 21 | objectIDMap[nullptr] = 0; 22 | } 23 | 24 | Output::Output(ref_ptr in_options) : 25 | Output() 26 | { 27 | options = in_options; 28 | } 29 | 30 | Output::~Output() 31 | { 32 | } 33 | 34 | bool Output::version_less(uint32_t major, uint32_t minor, uint32_t patch, uint32_t soversion) const 35 | { 36 | return version < VsgVersion{major, minor, patch, soversion}; 37 | } 38 | 39 | bool Output::version_greater_equal(uint32_t major, uint32_t minor, uint32_t patch, uint32_t soversion) const 40 | { 41 | return !version_less(major, minor, patch, soversion); 42 | } 43 | -------------------------------------------------------------------------------- /include/vsg/commands/BlitImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2020 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// BlitImage command encapsulates vkCmdBlitImage functionality and associated settings 22 | class VSG_DECLSPEC BlitImage : public Inherit 23 | { 24 | public: 25 | BlitImage(); 26 | 27 | ref_ptr srcImage; 28 | VkImageLayout srcImageLayout; 29 | ref_ptr dstImage; 30 | VkImageLayout dstImageLayout; 31 | std::vector regions; 32 | VkFilter filter; 33 | 34 | void record(CommandBuffer& commandBuffer) const override; 35 | }; 36 | VSG_type_name(vsg::BlitImage); 37 | 38 | } // namespace vsg 39 | -------------------------------------------------------------------------------- /include/vsg/lighting/HardShadows.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | class VSG_DECLSPEC HardShadows : public Inherit 21 | { 22 | public: 23 | explicit HardShadows(uint32_t in_shadowMaps = 1); 24 | HardShadows(const HardShadows& rhs, const CopyOp& copyop = {}); 25 | 26 | public: 27 | ref_ptr clone(const CopyOp& copyop = {}) const override { return HardShadows::create(*this, copyop); } 28 | int compare(const Object& rhs) const override; 29 | 30 | void read(Input& input) override; 31 | void write(Output& output) const override; 32 | }; 33 | VSG_type_name(vsg::HardShadows); 34 | 35 | } // namespace vsg 36 | -------------------------------------------------------------------------------- /include/vsg/commands/EndQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | /// encapsulation of vkCmdEndQuery 21 | class VSG_DECLSPEC EndQuery : public Inherit 22 | { 23 | public: 24 | EndQuery(); 25 | EndQuery(ref_ptr pool, uint32_t in_query); 26 | 27 | ref_ptr queryPool; 28 | uint32_t query; 29 | 30 | void read(Input& input) override; 31 | void write(Output& output) const override; 32 | 33 | void compile(Context& context) override; 34 | void record(CommandBuffer& commandBuffer) const override; 35 | }; 36 | VSG_type_name(vsg::EndQuery); 37 | 38 | } // namespace vsg 39 | -------------------------------------------------------------------------------- /src/vsg/core/Version.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | extern "C" 16 | { 17 | 18 | VsgVersion vsgGetVersion() 19 | { 20 | VsgVersion version{}; 21 | version.major = VSG_VERSION_MAJOR; 22 | version.minor = VSG_VERSION_MINOR; 23 | version.patch = VSG_VERSION_PATCH; 24 | version.soversion = VSG_SOVERSION; 25 | return version; 26 | } 27 | 28 | const char* vsgGetVersionString() 29 | { 30 | return VSG_VERSION_STRING; 31 | } 32 | 33 | const char* vsgGetSOVersionString() 34 | { 35 | return VSG_SOVERSION_STRING; 36 | } 37 | 38 | int vsgBuiltAsSharedLibrary() 39 | { 40 | #ifdef vsg_EXPORTS 41 | return 1; 42 | #else 43 | return 0; 44 | #endif 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/vsg/io/Input.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | Input::Input(ref_ptr in_objectFactory, ref_ptr in_options) : 19 | objectFactory(in_objectFactory), 20 | options(in_options), 21 | version{vsgGetVersion()} 22 | { 23 | objectIDMap[0] = nullptr; 24 | } 25 | 26 | Input::~Input() 27 | { 28 | } 29 | 30 | bool Input::version_less(uint32_t major, uint32_t minor, uint32_t patch, uint32_t soversion) const 31 | { 32 | return version < VsgVersion{major, minor, patch, soversion}; 33 | } 34 | 35 | bool Input::version_greater_equal(uint32_t major, uint32_t minor, uint32_t patch, uint32_t soversion) const 36 | { 37 | return !version_less(major, minor, patch, soversion); 38 | } 39 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | pull_request: 5 | env: 6 | BuildDocEnabled: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} 7 | jobs: 8 | build: 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | os: [ubuntu-latest, macos-latest, windows-latest] 13 | vulkan-version: [1.3.268.0] 14 | build-shared: [OFF] 15 | include: 16 | - build-shared: ON 17 | os: windows-latest 18 | vulkan-version: 1.3.268.0 19 | continue-on-error: ${{ matrix.vulkan-version == 'latest' }} 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Setup cmake 24 | uses: jwlawson/actions-setup-cmake@v1.12 25 | with: 26 | cmake-version: ${{ env.CMakeVersion }} 27 | - name: Install Vulkan SDK 28 | uses: humbletim/install-vulkan-sdk@c2aa128094d42ba02959a660f03e0a4e012192f9 29 | with: 30 | version: ${{ matrix.vulkan-version }} 31 | cache: true 32 | - name: Add MSBuild to PATH 33 | uses: microsoft/setup-msbuild@v2 34 | if: startsWith(matrix.os, 'windows') 35 | - name: Build and Install VSG 36 | shell: bash 37 | run: | 38 | if [ "$RUNNER_OS" == "Windows" ]; then 39 | cmake . -DBUILD_SHARED_LIBS=${{matrix.build-shared}} -A x64 40 | cmake --build . 41 | elif [ "$RUNNER_OS" == "Linux" ]; then 42 | sudo apt-get -qq update 43 | sudo apt-get -qq install libxcb1-dev 44 | cmake . -DBUILD_SHARED_LIBS=${{matrix.build-shared}} 45 | make -j 3 && sudo make install 46 | elif [ "$RUNNER_OS" == "macOS" ]; then 47 | cmake . -DBUILD_SHARED_LIBS=${{matrix.build-shared}} 48 | make -j 4 && sudo make install 49 | else 50 | echo "$RUNNER_OS not supported" 51 | exit 1 52 | fi 53 | -------------------------------------------------------------------------------- /include/vsg/ui/RecordEvents.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace vsg 21 | { 22 | 23 | /// RecordEvents is an event recording class that can be assigned to a viewer as an event handler. 24 | /// Can be used in conjunction with vsg::PlayEvents to replay recorded events. 25 | /// See vsginput example to see how it's used. 26 | class VSG_DECLSPEC RecordEvents : public vsg::Inherit 27 | { 28 | public: 29 | vsg::ref_ptr events = vsg::Objects::create(); 30 | 31 | void apply(vsg::UIEvent& event) override; 32 | }; 33 | VSG_type_name(vsg::RecordEvents); 34 | 35 | } // namespace vsg 36 | -------------------------------------------------------------------------------- /include/vsg/commands/CopyImageViewToWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// CopyImageViewToWindow command copies a source ImageView to a Window's current imageView. 22 | class VSG_DECLSPEC CopyImageViewToWindow : public Inherit 23 | { 24 | public: 25 | ref_ptr srcImageView; 26 | ref_ptr window; 27 | 28 | CopyImageViewToWindow(ref_ptr in_srcImageView, ref_ptr in_window) : 29 | srcImageView(in_srcImageView), 30 | window(in_window) {} 31 | 32 | void record(CommandBuffer& commandBuffer) const override; 33 | }; 34 | VSG_type_name(vsg::CopyImageViewToWindow); 35 | 36 | } // namespace vsg 37 | -------------------------------------------------------------------------------- /src/vsg/lighting/PercentageCloserSoftShadows.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2024 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | PercentageCloserSoftShadows::PercentageCloserSoftShadows(uint32_t in_shadowMaps) : 18 | Inherit(in_shadowMaps) 19 | { 20 | } 21 | 22 | PercentageCloserSoftShadows::PercentageCloserSoftShadows(const PercentageCloserSoftShadows& rhs, const CopyOp& copyop) : 23 | Inherit(rhs, copyop) 24 | { 25 | } 26 | 27 | int PercentageCloserSoftShadows::compare(const Object& rhs_object) const 28 | { 29 | return ShadowSettings::compare(rhs_object); 30 | } 31 | 32 | void PercentageCloserSoftShadows::read(Input& input) 33 | { 34 | ShadowSettings::read(input); 35 | } 36 | 37 | void PercentageCloserSoftShadows::write(Output& output) const 38 | { 39 | ShadowSettings::write(output); 40 | } 41 | -------------------------------------------------------------------------------- /include/vsg/commands/CopyImageToBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2020 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// CopyImageToBuffer commands encapsulates vkCmdCopyImageToBuffer and associated settings 23 | class VSG_DECLSPEC CopyImageToBuffer : public Inherit 24 | { 25 | public: 26 | CopyImageToBuffer(); 27 | 28 | void record(CommandBuffer& commandBuffer) const override; 29 | 30 | using Regions = std::vector; 31 | 32 | ref_ptr srcImage; 33 | VkImageLayout srcImageLayout; 34 | ref_ptr dstBuffer; 35 | Regions regions; 36 | }; 37 | VSG_type_name(vsg::CopyImageToBuffer); 38 | 39 | } // namespace vsg 40 | -------------------------------------------------------------------------------- /src/vsg/commands/ClearImage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | void ClearColorImage::record(CommandBuffer& commandBuffer) const 19 | { 20 | vkCmdClearColorImage(commandBuffer, 21 | image->vk(commandBuffer.deviceID), 22 | imageLayout, &color, 23 | static_cast(ranges.size()), ranges.data()); 24 | } 25 | 26 | void ClearDepthStencilImage::record(CommandBuffer& commandBuffer) const 27 | { 28 | vkCmdClearDepthStencilImage(commandBuffer, 29 | image->vk(commandBuffer.deviceID), 30 | imageLayout, &depthStencil, 31 | static_cast(ranges.size()), ranges.data()); 32 | } 33 | -------------------------------------------------------------------------------- /include/vsg/ui/ShiftEventTime.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// ShiftEventTime is a visitor for modifying the UIEvent::time values by a specified delta. 23 | /// Used by PlayEvents to replace recorded events with a different time point. 24 | class VSG_DECLSPEC ShiftEventTime : public vsg::Inherit 25 | { 26 | public: 27 | explicit ShiftEventTime(vsg::clock::time_point::duration in_delta); 28 | 29 | vsg::clock::time_point::duration delta; 30 | 31 | void apply(vsg::Object& object) override; 32 | void apply(vsg::UIEvent& event) override; 33 | }; 34 | VSG_type_name(vsg::ShiftEventTime); 35 | 36 | } // namespace vsg 37 | -------------------------------------------------------------------------------- /include/vsg/commands/NextSubPass.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// NextSubPass command encapsulates vkCmdNextSubpass call and settings. 21 | class VSG_DECLSPEC NextSubPass : public Inherit 22 | { 23 | public: 24 | explicit NextSubPass(VkSubpassContents in_contents = VK_SUBPASS_CONTENTS_INLINE) : 25 | contents(in_contents) {} 26 | 27 | void read(Input& input) override; 28 | void write(Output& output) const override; 29 | 30 | void record(CommandBuffer& commandBuffer) const override; 31 | 32 | VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE; 33 | 34 | protected: 35 | virtual ~NextSubPass(); 36 | }; 37 | VSG_type_name(vsg::NextSubPass); 38 | 39 | } // namespace vsg 40 | -------------------------------------------------------------------------------- /include/vsg/commands/SetDepthBias.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2021 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// SetDepthBias command encapsulates vkCmdSetDepthBias functionality, associated with dynamic updating of a GraphicsPipeline's RasterizationState::depthBias* values. 21 | class VSG_DECLSPEC SetDepthBias : public Inherit 22 | { 23 | public: 24 | SetDepthBias(); 25 | SetDepthBias(float in_depthBiasConstantFactor, float in_depthBiasClamp, float in_depthBiasSlopeFactor); 26 | 27 | float depthBiasConstantFactor = 1.0f; 28 | float depthBiasClamp = 0.0f; 29 | float depthBiasSlopeFactor = 1.0f; 30 | 31 | void record(CommandBuffer& commandBuffer) const override; 32 | }; 33 | VSG_type_name(vsg::SetDepthBias); 34 | 35 | } // namespace vsg 36 | -------------------------------------------------------------------------------- /include/vsg/lighting/SoftShadows.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | class VSG_DECLSPEC SoftShadows : public Inherit 21 | { 22 | public: 23 | explicit SoftShadows(uint32_t in_shadowMaps = 1, float in_penumbraRadius = 0.05f); 24 | SoftShadows(const SoftShadows& rhs, const CopyOp& copyop = {}); 25 | 26 | float penumbraRadius = 0.05f; 27 | 28 | public: 29 | ref_ptr clone(const CopyOp& copyop = {}) const override { return SoftShadows::create(*this, copyop); } 30 | int compare(const Object& rhs) const override; 31 | 32 | void read(Input& input) override; 33 | void write(Output& output) const override; 34 | }; 35 | VSG_type_name(vsg::SoftShadows); 36 | 37 | } // namespace vsg 38 | -------------------------------------------------------------------------------- /src/vsg/state/StateCommand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | StateCommand::StateCommand(const StateCommand& rhs, const CopyOp& copyop) : 19 | Inherit(rhs, copyop), 20 | slot(rhs.slot) 21 | { 22 | } 23 | 24 | void StateCommand::read(Input& input) 25 | { 26 | Command::read(input); 27 | 28 | input.read("slot", slot); 29 | } 30 | 31 | int StateCommand::compare(const Object& rhs_object) const 32 | { 33 | int result = Object::compare(rhs_object); 34 | if (result != 0) return result; 35 | 36 | const auto& rhs = static_cast(rhs_object); 37 | return compare_value(slot, rhs.slot); 38 | } 39 | 40 | void StateCommand::write(Output& output) const 41 | { 42 | Command::write(output); 43 | 44 | output.write("slot", slot); 45 | } 46 | -------------------------------------------------------------------------------- /include/vsg/ui/FrameStamp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// FrameStamp represents the time and frame count of a specific frame. 21 | class VSG_DECLSPEC FrameStamp : public Inherit 22 | { 23 | public: 24 | FrameStamp() {} 25 | 26 | FrameStamp(time_point in_time, uint64_t in_frameCount, double in_simulationTime) : 27 | time(in_time), 28 | frameCount(in_frameCount), 29 | simulationTime(in_simulationTime) {} 30 | 31 | time_point time = {}; 32 | uint64_t frameCount = 0; 33 | double simulationTime = 0.0; 34 | 35 | void read(Input& input) override; 36 | void write(Output& output) const override; 37 | }; 38 | VSG_type_name(vsg::FrameStamp); 39 | 40 | } // namespace vsg 41 | -------------------------------------------------------------------------------- /include/vsg/lighting/AmbientLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// AmbientLight represents an ambient light source 23 | class VSG_DECLSPEC AmbientLight : public Inherit 24 | { 25 | public: 26 | AmbientLight(); 27 | AmbientLight(const AmbientLight& rhs, const CopyOp& copyop = {}); 28 | 29 | public: 30 | ref_ptr clone(const CopyOp& copyop = {}) const override { return AmbientLight::create(*this, copyop); } 31 | 32 | void read(Input& input) override; 33 | void write(Output& output) const override; 34 | 35 | protected: 36 | virtual ~AmbientLight() {} 37 | }; 38 | VSG_type_name(vsg::AmbientLight); 39 | 40 | } // namespace vsg 41 | -------------------------------------------------------------------------------- /include/vsg/meshshaders/DrawMeshTasks.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2019 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | // DrawMeshTasks command encapsulates vkCmdDrawMeshTasksEXT call and associated parameters. 21 | class VSG_DECLSPEC DrawMeshTasks : public Inherit 22 | { 23 | public: 24 | DrawMeshTasks(); 25 | 26 | DrawMeshTasks(uint32_t in_groupCountX, uint32_t in_groupCountY, uint32_t in_groupCountZ); 27 | 28 | void read(Input& input) override; 29 | void write(Output& output) const override; 30 | 31 | void record(CommandBuffer& commandBuffer) const override; 32 | 33 | uint32_t groupCountX = 0; 34 | uint32_t groupCountY = 0; 35 | uint32_t groupCountZ = 0; 36 | }; 37 | VSG_type_name(vsg::DrawMeshTasks); 38 | 39 | } // namespace vsg 40 | -------------------------------------------------------------------------------- /include/vsg/raytracing/TraceRays.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2019 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// TraceRays command encapsulates vkCmdTraceRaysKHR call and associated settings. 22 | class VSG_DECLSPEC TraceRays : public Inherit 23 | { 24 | public: 25 | TraceRays(); 26 | 27 | void record(CommandBuffer& commandBuffer) const override; 28 | 29 | ref_ptr raygen; 30 | ref_ptr missShader; 31 | ref_ptr hitShader; 32 | ref_ptr callableShader; 33 | 34 | uint32_t width = 0; 35 | uint32_t height = 0; 36 | uint32_t depth = 0; 37 | }; 38 | VSG_type_name(vsg::TraceRays); 39 | 40 | } // namespace vsg 41 | -------------------------------------------------------------------------------- /include/vsg/raytracing/BottomLevelAccelerationStructure.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2019 Thomas Hogarth 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// BottomLevelAccelerationStructure encapsulates bottom level acceleration structure. 22 | class VSG_DECLSPEC BottomLevelAccelerationStructure : public Inherit 23 | { 24 | public: 25 | explicit BottomLevelAccelerationStructure(Device* device); 26 | 27 | void compile(Context& context) override; 28 | 29 | AccelerationGeometries geometries; 30 | 31 | protected: 32 | // compiled data 33 | std::vector _vkGeometries; 34 | }; 35 | VSG_type_name(vsg::BottomLevelAccelerationStructure); 36 | 37 | } // namespace vsg 38 | -------------------------------------------------------------------------------- /include/vsg/utils/ShaderCompiler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace vsg 9 | { 10 | 11 | /// ShaderCompiler integrates with GLSLang to provide shader compilation from GLSL shaders to SPIRV shaders usable by Vulkan. 12 | /// To be able to compile GLSL the VulkanSceneGraph has to be compiled against GLSLang, you can check whether shader compilation 13 | /// is supported via the VSG_SUPPORTS_ShaderCompiler #define provided in include/core/Version.h, if the value is 1 then shader compilation 14 | /// is supported. You can also check the ShaderCompiler::supported() method. 15 | class VSG_DECLSPEC ShaderCompiler : public Inherit 16 | { 17 | public: 18 | ShaderCompiler(); 19 | virtual ~ShaderCompiler(); 20 | 21 | /// return true if shader compilation is supported by this build of VulkanSceneGraph 22 | /// you can also use the VSG_SUPPORTS_ShaderCompiler define provided by include/vsg/core/Version.h 23 | bool supported() const; 24 | 25 | // default ShaderCompileSettings 26 | ref_ptr defaults; 27 | 28 | bool compile(ShaderStages& shaders, const std::vector& defines = {}, ref_ptr options = {}); 29 | bool compile(ref_ptr shaderStage, const std::vector& defines = {}, ref_ptr options = {}); 30 | 31 | std::string combineSourceAndDefines(const std::string& source, const std::vector& defines); 32 | 33 | void apply(Node& node) override; 34 | void apply(BindGraphicsPipeline& bgp) override; 35 | void apply(BindComputePipeline& bgp) override; 36 | void apply(BindRayTracingPipeline& bgp) override; 37 | 38 | protected: 39 | bool _initialized = false; 40 | }; 41 | VSG_type_name(vsg::ShaderCompiler); 42 | 43 | } // namespace vsg 44 | -------------------------------------------------------------------------------- /include/vsg/lighting/ShadowSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | class VSG_DECLSPEC ShadowSettings : public Inherit 21 | { 22 | public: 23 | explicit ShadowSettings(uint32_t shadowMaps = 1); 24 | ShadowSettings(const ShadowSettings& rhs, const CopyOp& copyop = {}); 25 | 26 | uint32_t shadowMapCount = 1; 27 | 28 | public: 29 | ref_ptr clone(const CopyOp& copyop = {}) const override { return ShadowSettings::create(*this, copyop); } 30 | int compare(const Object& rhs) const override; 31 | 32 | void read(Input& input) override; 33 | void write(Output& output) const override; 34 | 35 | protected: 36 | virtual ~ShadowSettings() {} 37 | }; 38 | VSG_type_name(vsg::ShadowSettings); 39 | 40 | } // namespace vsg 41 | -------------------------------------------------------------------------------- /include/vsg/lighting/PercentageCloserSoftShadows.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | class VSG_DECLSPEC PercentageCloserSoftShadows : public Inherit 21 | { 22 | public: 23 | explicit PercentageCloserSoftShadows(uint32_t in_shadowMaps = 1); 24 | PercentageCloserSoftShadows(const PercentageCloserSoftShadows& rhs, const CopyOp& copyop = {}); 25 | 26 | public: 27 | ref_ptr clone(const CopyOp& copyop = {}) const override { return PercentageCloserSoftShadows::create(*this, copyop); } 28 | int compare(const Object& rhs) const override; 29 | 30 | void read(Input& input) override; 31 | void write(Output& output) const override; 32 | }; 33 | VSG_type_name(vsg::PercentageCloserSoftShadows); 34 | 35 | } // namespace vsg 36 | -------------------------------------------------------------------------------- /include/vsg/commands/SetPrimitiveTopology.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// SetPrimitiveTopology command encapsulates vkCmdSetPrimitiveTopology functionality, associated with dynamic updating of a GraphicsPipeline's InputAssemblyState::topology 21 | class VSG_DECLSPEC SetPrimitiveTopology : public Inherit 22 | { 23 | public: 24 | explicit SetPrimitiveTopology(VkPrimitiveTopology in_topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); 25 | 26 | VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; 27 | 28 | void read(Input& input) override; 29 | void write(Output& output) const override; 30 | 31 | void record(CommandBuffer& commandBuffer) const override; 32 | }; 33 | VSG_type_name(vsg::SetPrimitiveTopology); 34 | 35 | } // namespace vsg 36 | -------------------------------------------------------------------------------- /include/vsg/commands/BeginQuery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | /// BeginQuery command encapsulates vkCmdBeginQuery call and associated functionality. 21 | class VSG_DECLSPEC BeginQuery : public Inherit 22 | { 23 | public: 24 | BeginQuery(); 25 | BeginQuery(ref_ptr pool, uint32_t in_query, VkQueryControlFlags in_flags); 26 | 27 | ref_ptr queryPool; 28 | uint32_t query; 29 | VkQueryControlFlags flags; 30 | 31 | void read(Input& input) override; 32 | void write(Output& output) const override; 33 | 34 | void compile(Context& context) override; 35 | void record(CommandBuffer& commandBuffer) const override; 36 | }; 37 | VSG_type_name(vsg::BeginQuery); 38 | 39 | } // namespace vsg 40 | -------------------------------------------------------------------------------- /include/vsg/core/contains.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// return true if set container contains value 23 | template 24 | bool contains(const T& value, const std::set& container) 25 | { 26 | return container.count(value) != 0; 27 | } 28 | 29 | /// return true if vector container contains value 30 | template 31 | bool contains(const T& value, const std::vector& container) 32 | { 33 | return std::find(container.begin(), container.end(), value) != container.end(); 34 | } 35 | 36 | /// return true if list of arguments contains value 37 | template 38 | bool contains(const T& value, const Args&... args) 39 | { 40 | return ((value == args) || ...); 41 | } 42 | } // namespace vsg 43 | -------------------------------------------------------------------------------- /src/vsg/nodes/Transform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace vsg; 18 | 19 | Transform::Transform() 20 | { 21 | } 22 | 23 | Transform::Transform(const Transform& rhs, const CopyOp& copyop) : 24 | Inherit(rhs, copyop), 25 | subgraphRequiresLocalFrustum(rhs.subgraphRequiresLocalFrustum) 26 | { 27 | } 28 | 29 | int Transform::compare(const Object& rhs_object) const 30 | { 31 | int result = Group::compare(rhs_object); 32 | if (result != 0) return result; 33 | 34 | const auto& rhs = static_cast(rhs_object); 35 | return compare_value(subgraphRequiresLocalFrustum, rhs.subgraphRequiresLocalFrustum); 36 | } 37 | 38 | void Transform::read(Input& input) 39 | { 40 | Group::read(input); 41 | } 42 | 43 | void Transform::write(Output& output) const 44 | { 45 | Group::write(output); 46 | } 47 | -------------------------------------------------------------------------------- /include/vsg/ui/UIEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace vsg 21 | { 22 | 23 | using clock = std::chrono::steady_clock; 24 | using time_point = clock::time_point; 25 | 26 | /// UIEvent is a base class for user interface events 27 | class VSG_DECLSPEC UIEvent : public Inherit 28 | { 29 | public: 30 | UIEvent() {} 31 | 32 | explicit UIEvent(time_point in_time) : 33 | time(in_time) {} 34 | 35 | time_point time = {}; 36 | bool handled = false; 37 | 38 | void read(Input& input) override; 39 | void write(Output& output) const override; 40 | }; 41 | VSG_type_name(vsg::UIEvent); 42 | 43 | using UIEvents = std::list>; 44 | using EventHandlers = std::list>; 45 | } // namespace vsg 46 | -------------------------------------------------------------------------------- /include/vsg/commands/ResetQueryPool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Josef Stumpfegger & Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// ResetQueryPool command encapsulates vkCmdResetQueryPool functionality. 22 | class VSG_DECLSPEC ResetQueryPool : public Inherit 23 | { 24 | public: 25 | ResetQueryPool(); 26 | explicit ResetQueryPool(ref_ptr pool); 27 | 28 | ref_ptr queryPool; 29 | uint32_t firstQuery = 0; 30 | uint32_t queryCount = 0; 31 | 32 | void read(Input& input) override; 33 | void write(Output& output) const override; 34 | 35 | void compile(Context& context) override; 36 | 37 | void record(CommandBuffer& commandBuffer) const override; 38 | }; 39 | VSG_type_name(vsg::ResetQueryPool); 40 | 41 | } // namespace vsg 42 | -------------------------------------------------------------------------------- /src/vsg/vk/Semaphore.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | Semaphore::Semaphore(Device* device, VkPipelineStageFlags pipelineStageFlags, void* pNextCreateInfo) : 19 | _pipelineStageFlags(pipelineStageFlags), 20 | _device(device) 21 | { 22 | VkSemaphoreCreateInfo semaphoreInfo = {}; 23 | semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; 24 | semaphoreInfo.pNext = pNextCreateInfo; 25 | 26 | VkResult result = vkCreateSemaphore(*device, &semaphoreInfo, _device->getAllocationCallbacks(), &_semaphore); 27 | if (result != VK_SUCCESS) 28 | { 29 | throw Exception{"Error: Failed to create semaphore.", result}; 30 | } 31 | } 32 | 33 | Semaphore::~Semaphore() 34 | { 35 | if (_semaphore) 36 | { 37 | vkDestroySemaphore(*_device, _semaphore, _device->getAllocationCallbacks()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/vsg/commands/SetPrimitiveTopology.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2024 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | SetPrimitiveTopology::SetPrimitiveTopology(VkPrimitiveTopology in_topology) : 19 | topology(in_topology) 20 | { 21 | } 22 | 23 | void SetPrimitiveTopology::read(Input& input) 24 | { 25 | Command::read(input); 26 | 27 | input.readValue("topology", topology); 28 | } 29 | 30 | void SetPrimitiveTopology::write(Output& output) const 31 | { 32 | Command::write(output); 33 | 34 | output.writeValue("topology", topology); 35 | } 36 | 37 | void SetPrimitiveTopology::record(CommandBuffer& commandBuffer) const 38 | { 39 | auto extensions = commandBuffer.getDevice()->getExtensions(); 40 | if (!extensions->vkCmdSetPrimitiveTopology) return; 41 | 42 | extensions->vkCmdSetPrimitiveTopology(commandBuffer, topology); 43 | } 44 | -------------------------------------------------------------------------------- /include/vsg/ui/ScrollWheelEvent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// ScrollWheelEvent represents a scroll wheel event. 21 | class VSG_DECLSPEC ScrollWheelEvent : public Inherit 22 | { 23 | public: 24 | ScrollWheelEvent() {} 25 | 26 | ScrollWheelEvent(Window* in_window, time_point in_time, const vec3& in_delta) : 27 | Inherit(in_window, in_time), 28 | delta(in_delta) {} 29 | 30 | /// scroll left delta.x < 0.0, scroll right delta.x > 0.0 31 | /// scroll up delta.y > 0.0, scroll down delta.y < 0.0 32 | /// scroll out delta.z > 0.0, scroll in delta.z < 0.0 33 | vec3 delta; 34 | 35 | void read(Input& input) override; 36 | void write(Output& output) const override; 37 | }; 38 | VSG_type_name(vsg::ScrollWheelEvent); 39 | 40 | } // namespace vsg 41 | -------------------------------------------------------------------------------- /src/vsg/commands/EndQuery.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2022 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | EndQuery::EndQuery() 18 | { 19 | } 20 | 21 | EndQuery::EndQuery(ref_ptr pool, uint32_t in_query) : 22 | queryPool(pool), 23 | query(in_query) 24 | { 25 | } 26 | 27 | void EndQuery::read(Input& input) 28 | { 29 | Command::read(input); 30 | 31 | input.readObject("queryPool", queryPool); 32 | input.read("query", query); 33 | } 34 | 35 | void EndQuery::write(Output& output) const 36 | { 37 | Command::write(output); 38 | 39 | output.writeObject("queryPool", queryPool); 40 | output.write("query", query); 41 | } 42 | 43 | void EndQuery::compile(Context& context) 44 | { 45 | if (queryPool) queryPool->compile(context); 46 | } 47 | 48 | void EndQuery::record(CommandBuffer& commandBuffer) const 49 | { 50 | if (!queryPool) return; 51 | vkCmdEndQuery(commandBuffer, *queryPool, query); 52 | } 53 | -------------------------------------------------------------------------------- /include/vsg/commands/ClearAttachments.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2019 Thomas Hogarth 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// ClearAttachments command encapsulates vkCmdClearAttachments functionality and associated settings. 21 | class VSG_DECLSPEC ClearAttachments : public Inherit 22 | { 23 | public: 24 | using Attachments = std::vector; 25 | using Rects = std::vector; 26 | 27 | ClearAttachments(); 28 | ClearAttachments(const Attachments& in_attachments, const Rects& in_rects); 29 | 30 | Attachments attachments; 31 | Rects rects; 32 | 33 | public: 34 | void read(Input& input) override; 35 | void write(Output& output) const override; 36 | 37 | void record(CommandBuffer& commandBuffer) const override; 38 | }; 39 | VSG_type_name(vsg::ClearAttachments); 40 | 41 | } // namespace vsg 42 | -------------------------------------------------------------------------------- /include/vsg/nodes/CullGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// CullNode that enables view frustum culling on a list of children. 22 | class VSG_DECLSPEC CullGroup : public Inherit 23 | { 24 | public: 25 | CullGroup(); 26 | CullGroup(const CullGroup& rhs, const CopyOp& copyop = {}); 27 | explicit CullGroup(const dsphere& bound); 28 | 29 | dsphere bound; 30 | 31 | public: 32 | ref_ptr clone(const CopyOp& copyop = {}) const override { return CullGroup::create(*this, copyop); } 33 | int compare(const Object& rhs) const override; 34 | 35 | void read(Input& input) override; 36 | void write(Output& output) const override; 37 | 38 | protected: 39 | virtual ~CullGroup(); 40 | }; 41 | VSG_type_name(vsg::CullGroup); 42 | 43 | } // namespace vsg 44 | -------------------------------------------------------------------------------- /include/vsg/commands/WriteTimestamp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Josef Stumpfegger & Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | /// WriteTimestamp command encapsulates vkCmdWriteTimestamp call and settings passed to it. 21 | class VSG_DECLSPEC WriteTimestamp : public Inherit 22 | { 23 | public: 24 | WriteTimestamp(); 25 | WriteTimestamp(VkPipelineStageFlagBits stage, ref_ptr pool, uint32_t query); 26 | 27 | VkPipelineStageFlagBits pipelineStage; 28 | ref_ptr queryPool; 29 | uint32_t query; 30 | 31 | void read(Input& input) override; 32 | void write(Output& output) const override; 33 | 34 | void compile(Context& context) override; 35 | void record(CommandBuffer& commandBuffer) const override; 36 | }; 37 | VSG_type_name(vsg::WriteTimestamp); 38 | 39 | } // namespace vsg 40 | -------------------------------------------------------------------------------- /include/vsg/io/json.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2025 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | the Software, and to permit persons to whom the Software is furnished to do so, 12 | subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shimages be included in images 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace vsg 31 | { 32 | 33 | /// json ReaderWriter 34 | class VSG_DECLSPEC json : public Inherit 35 | { 36 | public: 37 | json(); 38 | 39 | ref_ptr read(const Path&, ref_ptr) const override; 40 | ref_ptr read(std::istream&, ref_ptr) const override; 41 | ref_ptr read(const uint8_t* ptr, size_t size, ref_ptr options = {}) const override; 42 | 43 | ref_ptr _read(std::istream&, ref_ptr) const; 44 | 45 | bool supportedExtension(const Path& ext) const; 46 | 47 | bool getFeatures(Features& features) const override; 48 | }; 49 | VSG_type_name(vsg::json); 50 | 51 | } // namespace vsg 52 | -------------------------------------------------------------------------------- /include/vsg/state/PushConstants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// PushConstants state command encapsulates vkCmdPushConstants functionality 23 | class VSG_DECLSPEC PushConstants : public Inherit 24 | { 25 | public: 26 | PushConstants(); 27 | PushConstants(VkShaderStageFlags in_shaderFlags, uint32_t in_offset, Data* in_data); 28 | 29 | VkShaderStageFlags stageFlags = 0; 30 | uint32_t offset = 0; 31 | ref_ptr data; 32 | 33 | void record(CommandBuffer& commandBuffer) const override; 34 | 35 | public: 36 | void read(Input& input) override; 37 | void write(Output& output) const override; 38 | 39 | protected: 40 | virtual ~PushConstants(); 41 | }; 42 | VSG_type_name(vsg::PushConstants); 43 | 44 | } // namespace vsg 45 | -------------------------------------------------------------------------------- /include/vsg/io/spirv.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2021 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | the Software, and to permit persons to whom the Software is furnished to do so, 12 | subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | 30 | namespace vsg 31 | { 32 | 33 | /// ReaderWriter for reading and writing spirv shader files. 34 | class VSG_DECLSPEC spirv : public Inherit 35 | { 36 | public: 37 | spirv(); 38 | 39 | ref_ptr read(const Path& filename, ref_ptr options = {}) const override; 40 | 41 | ref_ptr read(std::istream& fin, ref_ptr options = {}) const override; 42 | ref_ptr read(const uint8_t* ptr, size_t size, ref_ptr = {}) const override; 43 | 44 | bool write(const Object* object, const Path& filename, ref_ptr options = {}) const override; 45 | 46 | bool getFeatures(Features& features) const override; 47 | }; 48 | VSG_type_name(vsg::spirv); 49 | 50 | } // namespace vsg 51 | -------------------------------------------------------------------------------- /src/vsg/core/Allocator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2022 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | using namespace vsg; 23 | 24 | std::unique_ptr& Allocator::instance() 25 | { 26 | static std::unique_ptr s_allocator(new IntrusiveAllocator()); 27 | return s_allocator; 28 | } 29 | 30 | //////////////////////////////////////////////////////////////////////////////////////////////////// 31 | // 32 | // vsg::allocate and vsg::deallocate convenience functions that map to using the OriginalBlockAllocator singleton. 33 | // 34 | void* vsg::allocate(std::size_t size, AllocatorAffinity allocatorAffinity) 35 | { 36 | return Allocator::instance()->allocate(size, allocatorAffinity); 37 | } 38 | 39 | void vsg::deallocate(void* ptr, std::size_t size) 40 | { 41 | Allocator::instance()->deallocate(ptr, size); 42 | } 43 | -------------------------------------------------------------------------------- /include/vsg/maths/numbers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | template 20 | struct numbers 21 | { 22 | static constexpr T zero() { return static_cast(0.0); } 23 | static constexpr T half() { return static_cast(0.5); } 24 | static constexpr T one() { return static_cast(1.0); } 25 | static constexpr T two() { return static_cast(2.0); } 26 | static constexpr T three() { return static_cast(3.0); } 27 | 28 | static constexpr T minus_one() { return static_cast(-1.0); } 29 | 30 | static constexpr T epsilon() { return std::numeric_limits::epsilon(); } 31 | 32 | static constexpr T PI() { return static_cast(3.14159265358979323846); } 33 | static constexpr T degrees_to_radians() { return PI() / static_cast(180.0); } 34 | static constexpr T radians_to_degrees() { return static_cast(180.0) / PI(); } 35 | }; 36 | 37 | } // namespace vsg 38 | -------------------------------------------------------------------------------- /src/vsg/lighting/ShadowSettings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2022 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | ShadowSettings::ShadowSettings(uint32_t in_shadowMapCount) : 19 | shadowMapCount(in_shadowMapCount) 20 | { 21 | } 22 | 23 | ShadowSettings::ShadowSettings(const ShadowSettings& rhs, const CopyOp& copyop) : 24 | Inherit(rhs, copyop), 25 | shadowMapCount(rhs.shadowMapCount) 26 | { 27 | } 28 | 29 | int ShadowSettings::compare(const Object& rhs_object) const 30 | { 31 | int result = Object::compare(rhs_object); 32 | if (result != 0) return result; 33 | 34 | const auto& rhs = static_cast(rhs_object); 35 | return compare_value(shadowMapCount, rhs.shadowMapCount); 36 | } 37 | 38 | void ShadowSettings::read(Input& input) 39 | { 40 | input.read("shadowMapCount", shadowMapCount); 41 | } 42 | 43 | void ShadowSettings::write(Output& output) const 44 | { 45 | output.write("shadowMapCount", shadowMapCount); 46 | } 47 | -------------------------------------------------------------------------------- /include/vsg/commands/Dispatch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /** Dispatch command encapsulates vkCmdDispatch, used for dispatching a Compute pipeline.*/ 22 | class VSG_DECLSPEC Dispatch : public Inherit 23 | { 24 | public: 25 | Dispatch() {} 26 | 27 | Dispatch(uint32_t in_groupCountX, uint32_t in_groupCountY, uint32_t in_groupCountZ) : 28 | groupCountX(in_groupCountX), 29 | groupCountY(in_groupCountY), 30 | groupCountZ(in_groupCountZ) {} 31 | 32 | void read(Input& input) override; 33 | void write(Output& output) const override; 34 | 35 | void record(CommandBuffer& commandBuffer) const override; 36 | 37 | uint32_t groupCountX = 0; 38 | uint32_t groupCountY = 0; 39 | uint32_t groupCountZ = 0; 40 | }; 41 | VSG_type_name(vsg::Dispatch); 42 | 43 | } // namespace vsg 44 | -------------------------------------------------------------------------------- /include/vsg/nodes/CoordinateFrame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// CoordinateFrame provides support for astronomically large coordinates 21 | class VSG_DECLSPEC CoordinateFrame : public Inherit 22 | { 23 | public: 24 | CoordinateFrame(); 25 | CoordinateFrame(const CoordinateFrame& rhs, const CopyOp& copyop = {}); 26 | 27 | std::string name; 28 | dvec3 origin; 29 | dquat rotation; 30 | 31 | dmat4 transform(const dmat4& mv) const override; 32 | 33 | public: 34 | ref_ptr clone(const CopyOp& copyop = {}) const override { return CoordinateFrame::create(*this, copyop); } 35 | int compare(const Object& rhs) const override; 36 | 37 | void read(Input& input) override; 38 | void write(Output& output) const override; 39 | 40 | protected: 41 | }; 42 | VSG_type_name(vsg::CoordinateFrame); 43 | 44 | } // namespace vsg 45 | -------------------------------------------------------------------------------- /src/vsg/nodes/CullGroup.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | CullGroup::CullGroup() 19 | { 20 | } 21 | 22 | CullGroup::CullGroup(const CullGroup& rhs, const CopyOp& copyop) : 23 | Inherit(rhs, copyop), 24 | bound(rhs.bound) 25 | { 26 | } 27 | 28 | CullGroup::CullGroup(const dsphere& in_bound) : 29 | bound(in_bound) 30 | { 31 | } 32 | 33 | CullGroup::~CullGroup() 34 | { 35 | } 36 | 37 | int CullGroup::compare(const Object& rhs_object) const 38 | { 39 | int result = Group::compare(rhs_object); 40 | if (result != 0) return result; 41 | 42 | const auto& rhs = static_cast(rhs_object); 43 | return compare_value(bound, rhs.bound); 44 | } 45 | 46 | void CullGroup::read(Input& input) 47 | { 48 | Group::read(input); 49 | 50 | input.read("bound", bound); 51 | } 52 | 53 | void CullGroup::write(Output& output) const 54 | { 55 | Group::write(output); 56 | 57 | output.write("bound", bound); 58 | } 59 | -------------------------------------------------------------------------------- /src/vsg/commands/Draw.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | using namespace vsg; 17 | 18 | int Draw::compare(const Object& rhs_object) const 19 | { 20 | int result = Object::compare(rhs_object); 21 | if (result != 0) return result; 22 | 23 | const auto& rhs = static_cast(rhs_object); 24 | return compare_region(vertexCount, firstInstance, rhs.vertexCount); 25 | } 26 | 27 | void Draw::read(Input& input) 28 | { 29 | Command::read(input); 30 | 31 | input.read("vertexCount", vertexCount); 32 | input.read("instanceCount", instanceCount); 33 | input.read("firstVertex", firstVertex); 34 | input.read("firstInstance", firstInstance); 35 | } 36 | 37 | void Draw::write(Output& output) const 38 | { 39 | Command::write(output); 40 | 41 | output.write("vertexCount", vertexCount); 42 | output.write("instanceCount", instanceCount); 43 | output.write("firstVertex", firstVertex); 44 | output.write("firstInstance", firstInstance); 45 | } 46 | -------------------------------------------------------------------------------- /include/vsg/commands/CopyQueryPoolResults.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2022 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | /// CopyQueryPoolResults commands encapsulates vkCmdCopyQueryPoolResults and associated settings 22 | class VSG_DECLSPEC CopyQueryPoolResults : public Inherit 23 | { 24 | public: 25 | CopyQueryPoolResults(); 26 | 27 | ref_ptr queryPool; 28 | uint32_t firstQuery = 0; 29 | uint32_t queryCount = 0; 30 | ref_ptr dest; 31 | VkDeviceSize stride = 4; 32 | VkQueryResultFlags flags = 0; 33 | 34 | void read(Input& input) override; 35 | void write(Output& output) const override; 36 | 37 | void compile(Context& context) override; 38 | void record(CommandBuffer& commandBuffer) const override; 39 | }; 40 | VSG_type_name(vsg::CopyQueryPoolResults); 41 | 42 | } // namespace vsg 43 | -------------------------------------------------------------------------------- /include/vsg/threading/Affinity.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2020 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #pragma once 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace vsg 21 | { 22 | 23 | /// Affinity struct provides a set of cpu ids that a thread can be set to have affinity to. 24 | struct Affinity 25 | { 26 | Affinity() {} 27 | 28 | explicit Affinity(uint32_t cpu, uint32_t num = 1) 29 | { 30 | for (uint32_t i = 0; i < num; ++i) cpus.insert(cpu + i); 31 | } 32 | 33 | std::set cpus; 34 | 35 | operator bool() const { return !cpus.empty(); } 36 | }; 37 | 38 | /// Set the CPU affinity of specified std::thread 39 | extern VSG_DECLSPEC void setAffinity(std::thread& thread, const Affinity& affinity); 40 | 41 | /// Set the CPU affinity of current thread 42 | /// Note, under Linux the CPU affinity of thread is inherited by any threads that it creates 43 | extern VSG_DECLSPEC void setAffinity(const Affinity& affinity); 44 | 45 | } // namespace vsg 46 | -------------------------------------------------------------------------------- /src/vsg/nodes/Group.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2018 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace vsg; 19 | 20 | Group::Group(size_t numChildren) : 21 | children(numChildren) 22 | { 23 | } 24 | 25 | Group::Group(const Group& rhs, const CopyOp& copyop) : 26 | Inherit(rhs, copyop), 27 | children(copyop(rhs.children)) 28 | { 29 | } 30 | 31 | Group::~Group() 32 | { 33 | } 34 | 35 | int Group::compare(const Object& rhs_object) const 36 | { 37 | int result = Object::compare(rhs_object); 38 | if (result != 0) return result; 39 | 40 | const auto& rhs = static_cast(rhs_object); 41 | return compare_pointer_container(children, rhs.children); 42 | } 43 | 44 | void Group::read(Input& input) 45 | { 46 | Node::read(input); 47 | 48 | input.readObjects("children", children); 49 | } 50 | 51 | void Group::write(Output& output) const 52 | { 53 | Node::write(output); 54 | 55 | output.writeObjects("children", children); 56 | } 57 | -------------------------------------------------------------------------------- /include/vsg/lighting/PointLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2024 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// PointLight represents a local point light source where all light radiants event from the light position. 23 | class VSG_DECLSPEC PointLight : public Inherit 24 | { 25 | public: 26 | PointLight(); 27 | PointLight(const PointLight& rhs, const CopyOp& copyop = {}); 28 | 29 | dvec3 position = dvec3(0.0, 0.0, 0.0); 30 | double radius = 0.0f; 31 | 32 | public: 33 | ref_ptr clone(const CopyOp& copyop = {}) const override { return PointLight::create(*this, copyop); } 34 | int compare(const Object& rhs) const override; 35 | 36 | void read(Input& input) override; 37 | void write(Output& output) const override; 38 | 39 | protected: 40 | virtual ~PointLight() {} 41 | }; 42 | VSG_type_name(vsg::PointLight); 43 | 44 | } // namespace vsg 45 | -------------------------------------------------------------------------------- /include/vsg/text/TextLayout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2020 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | struct TextQuad 22 | { 23 | vec3 vertices[4]; 24 | vec2 texcoords[4]; 25 | vec4 colors[4]; 26 | vec4 outlineColors[4]; 27 | float outlineWidths[4]; 28 | vec3 normal; 29 | vec4 centerAndAutoScaleDistance; // only used when billboarding 30 | }; 31 | 32 | using TextQuads = std::vector; 33 | 34 | class VSG_DECLSPEC TextLayout : public Inherit 35 | { 36 | public: 37 | virtual bool requiresBillboard() const { return false; } 38 | virtual void layout(const Data* text, const Font& font, TextQuads& texQuads) = 0; 39 | virtual vec2 alignment(const Data* text, const Font& font) const = 0; 40 | virtual dbox extents(const Data* text, const Font& font) const = 0; 41 | }; 42 | VSG_type_name(vsg::TextLayout); 43 | 44 | } // namespace vsg 45 | -------------------------------------------------------------------------------- /include/vsg/threading/ActivityStatus.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | 17 | namespace vsg 18 | { 19 | 20 | /// ActivityStatus provides atomic management of whether threads watching this ActivityStatus object should be active or safely exit 21 | class ActivityStatus : public Inherit 22 | { 23 | public: 24 | explicit ActivityStatus(bool active = true) : 25 | _active(active) {} 26 | 27 | void set(bool flag) noexcept { _active.exchange(flag); } 28 | 29 | /// return true if the caller should continue with current activity or false if they should be canceled 30 | bool active() const noexcept { return _active; } 31 | 32 | /// return true if the caller should cancel current activity 33 | bool cancel() const noexcept { return !_active; } 34 | 35 | protected: 36 | virtual ~ActivityStatus() {} 37 | 38 | std::atomic_bool _active; 39 | }; 40 | VSG_type_name(vsg::ActivityStatus) 41 | 42 | } // namespace vsg 43 | -------------------------------------------------------------------------------- /include/vsg/nodes/Node.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// Node base class used for internal nodes within the scene graph. 22 | /// Specializes new/delete so that nodes are automatically allocated alongside of other nodes via vsg::Allocator's MEMORY_NODES_OBJECTS affinity. 23 | class VSG_DECLSPEC Node : public Inherit 24 | { 25 | public: 26 | Node(); 27 | Node(const Node& rhs, const CopyOp& copyop = {}); 28 | 29 | ref_ptr clone(const CopyOp& copyop = {}) const override { return Node::create(*this, copyop); } 30 | 31 | /// provide new and delete to enable custom memory management via the vsg::Allocator singleton, using the MEMORY_NODES_OBJECTS 32 | static void* operator new(std::size_t count); 33 | static void operator delete(void* ptr); 34 | 35 | protected: 36 | virtual ~Node(); 37 | }; 38 | VSG_type_name(vsg::Node); 39 | 40 | } // namespace vsg 41 | -------------------------------------------------------------------------------- /include/vsg/commands/DrawIndirect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2018 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace vsg 20 | { 21 | 22 | /// DrawIndirect command encapsulates vkCmdDrawIndirect call and associated settings. 23 | class VSG_DECLSPEC DrawIndirect : public Inherit 24 | { 25 | public: 26 | DrawIndirect(); 27 | 28 | DrawIndirect(ref_ptr data, uint32_t in_drawCount, uint32_t in_stride); 29 | 30 | DrawIndirect(ref_ptr in_buffer, VkDeviceSize in_offset, uint32_t in_drawCount, uint32_t in_stride); 31 | 32 | void read(Input& input) override; 33 | void write(Output& output) const override; 34 | 35 | void compile(Context& context) override; 36 | void record(CommandBuffer& commandBuffer) const override; 37 | 38 | ref_ptr bufferInfo; 39 | uint32_t drawCount = 0; 40 | uint32_t stride = 0; 41 | }; 42 | VSG_type_name(vsg::DrawIndirect); 43 | 44 | } // namespace vsg 45 | -------------------------------------------------------------------------------- /src/vsg/lighting/SoftShadows.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2024 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | SoftShadows::SoftShadows(uint32_t in_shadowMaps, float in_penumbraRadius) : 18 | Inherit(in_shadowMaps), 19 | penumbraRadius(in_penumbraRadius) 20 | { 21 | } 22 | 23 | SoftShadows::SoftShadows(const SoftShadows& rhs, const CopyOp& copyop) : 24 | Inherit(rhs, copyop), 25 | penumbraRadius(rhs.penumbraRadius) 26 | { 27 | } 28 | 29 | int SoftShadows::compare(const Object& rhs_object) const 30 | { 31 | int result = ShadowSettings::compare(rhs_object); 32 | if (result != 0) return result; 33 | 34 | const auto& rhs = static_cast(rhs_object); 35 | return compare_value(penumbraRadius, rhs.penumbraRadius); 36 | } 37 | 38 | void SoftShadows::read(Input& input) 39 | { 40 | ShadowSettings::read(input); 41 | 42 | input.read("penumbraRadius", penumbraRadius); 43 | } 44 | 45 | void SoftShadows::write(Output& output) const 46 | { 47 | ShadowSettings::write(output); 48 | 49 | output.write("penumbraRadius", penumbraRadius); 50 | } 51 | -------------------------------------------------------------------------------- /src/vsg/raytracing/RayTracingShaderGroup.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2019 Thomas Hogarth 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | //////////////////////////////////////////////////////////////////////// 18 | // 19 | // RayTracingShaderGroup 20 | // 21 | RayTracingShaderGroup::RayTracingShaderGroup() 22 | { 23 | } 24 | 25 | RayTracingShaderGroup::~RayTracingShaderGroup() 26 | { 27 | } 28 | 29 | void RayTracingShaderGroup::read(Input& input) 30 | { 31 | Object::read(input); 32 | } 33 | 34 | void RayTracingShaderGroup::write(Output& output) const 35 | { 36 | Object::write(output); 37 | } 38 | 39 | void RayTracingShaderGroup::applyTo(VkRayTracingShaderGroupCreateInfoKHR& shaderGroupInfo) const 40 | { 41 | shaderGroupInfo.sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_KHR; 42 | shaderGroupInfo.pNext = nullptr; 43 | shaderGroupInfo.type = type; 44 | shaderGroupInfo.generalShader = generalShader; 45 | shaderGroupInfo.closestHitShader = closestHitShader; 46 | shaderGroupInfo.anyHitShader = anyHitShader; 47 | shaderGroupInfo.intersectionShader = intersectionShader; 48 | } 49 | -------------------------------------------------------------------------------- /src/vsg/platform/ios/iOS_ViewController.mm: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #pragma mark - 6 | #pragma mark vsg_iOS_ViewController 7 | 8 | @implementation vsg_iOS_ViewController { 9 | vsg::ref_ptr _traits; 10 | vsg::ref_ptr _vsgViewer; 11 | } 12 | 13 | - (instancetype)initWithTraits:(vsg::ref_ptr)traits andVsgViewer:(vsg::ref_ptr) vsgViewer 14 | { 15 | self = [super init]; 16 | _traits = traits; 17 | _vsgViewer = vsgViewer; 18 | return self; 19 | } 20 | 21 | - (void)loadView 22 | { 23 | // We need to create a vsgView because doing so we ensure it has a CAMetalLayer 24 | // otherwise it will make a view with a CALayer which is not compatible with MoltenVK. 25 | // Also, very important to give it a size or it won't let access to any CAMetalDrawable 26 | // which will cause a massive hang in the device forcing it to be rebooted in order 27 | // to regain control of it. 28 | CGRect frame; 29 | frame.origin.x = _traits->x; 30 | frame.origin.y = _traits->y; 31 | frame.size.width = _traits->width <= 0 ? 1 : _traits->width; 32 | frame.size.height = _traits->height <= 0 ? 1 : _traits->height; 33 | vsg_iOS_View* view = [[vsg_iOS_View alloc] initWithFrame:frame]; 34 | self.view = view; 35 | 36 | } 37 | 38 | -(void) dealloc { 39 | _traits = nullptr; 40 | _vsgViewer = nullptr; 41 | _vsgWindow = nullptr; 42 | } 43 | 44 | 45 | -(void) viewDidLoad { 46 | [super viewDidLoad]; 47 | 48 | self.view.contentScaleFactor = UIScreen.mainScreen.nativeScale; 49 | } 50 | 51 | 52 | // Allow device rotation to resize the swapchain 53 | -(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { 54 | [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 55 | // TODO implement this 56 | } 57 | 58 | @end 59 | 60 | 61 | #pragma mark - 62 | #pragma mark vsg_iOS_View 63 | 64 | @implementation vsg_iOS_View 65 | 66 | /** Returns a Metal-compatible layer (required by Vulkan/MoltenVK. */ 67 | +(Class) layerClass { return [CAMetalLayer class]; } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /src/vsg/ui/PointerEvent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2021 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | void PointerEvent::read(Input& input) 18 | { 19 | UIEvent::read(input); 20 | 21 | input.read("x", x); 22 | input.read("y", y); 23 | input.readValue("mask", mask); 24 | } 25 | 26 | void PointerEvent::write(Output& output) const 27 | { 28 | UIEvent::write(output); 29 | 30 | output.write("x", x); 31 | output.write("y", y); 32 | output.writeValue("mask", mask); 33 | } 34 | 35 | void ButtonPressEvent::read(Input& input) 36 | { 37 | PointerEvent::read(input); 38 | 39 | input.read("button", button); 40 | } 41 | 42 | void ButtonPressEvent::write(Output& output) const 43 | { 44 | PointerEvent::write(output); 45 | 46 | output.write("button", button); 47 | } 48 | 49 | void ButtonReleaseEvent::read(Input& input) 50 | { 51 | PointerEvent::read(input); 52 | 53 | input.read("button", button); 54 | } 55 | 56 | void ButtonReleaseEvent::write(Output& output) const 57 | { 58 | PointerEvent::write(output); 59 | 60 | output.write("button", button); 61 | } 62 | -------------------------------------------------------------------------------- /src/vsg/commands/BeginQuery.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright(c) 2022 Robert Osfield 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | 11 | */ 12 | 13 | #include 14 | 15 | using namespace vsg; 16 | 17 | BeginQuery::BeginQuery() 18 | { 19 | } 20 | 21 | BeginQuery::BeginQuery(ref_ptr pool, uint32_t in_query, VkQueryControlFlags in_flags) : 22 | queryPool(pool), 23 | query(in_query), 24 | flags(in_flags) 25 | { 26 | } 27 | 28 | void BeginQuery::read(Input& input) 29 | { 30 | Command::read(input); 31 | 32 | input.readObject("queryPool", queryPool); 33 | input.read("query", query); 34 | input.readValue("flags", flags); 35 | } 36 | 37 | void BeginQuery::write(Output& output) const 38 | { 39 | Command::write(output); 40 | 41 | output.writeObject("queryPool", queryPool); 42 | output.write("query", query); 43 | output.writeValue("flags", flags); 44 | } 45 | 46 | void BeginQuery::compile(Context& context) 47 | { 48 | if (queryPool) queryPool->compile(context); 49 | } 50 | 51 | void BeginQuery::record(CommandBuffer& commandBuffer) const 52 | { 53 | if (!queryPool) return; 54 | vkCmdBeginQuery(commandBuffer, *queryPool, query, flags); 55 | } 56 | -------------------------------------------------------------------------------- /include/vsg/meshshaders/DrawMeshTasksIndirectCount.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2019 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// DrawMeshTasksIndirectCount command encapsulates vkCmdDrawMeshTasksIndirectCountEXT call and associated parameters. 22 | class VSG_DECLSPEC DrawMeshTasksIndirectCount : public Inherit 23 | { 24 | public: 25 | DrawMeshTasksIndirectCount(); 26 | 27 | DrawMeshTasksIndirectCount(ref_ptr in_bufferData, ref_ptr in_countBufferData, uint32_t in_maxDrawCount, uint32_t in_stride); 28 | 29 | void read(Input& input) override; 30 | void write(Output& output) const override; 31 | 32 | void compile(Context& context) override; 33 | void record(CommandBuffer& commandBuffer) const override; 34 | 35 | ref_ptr drawParameters; 36 | ref_ptr drawCount; 37 | uint32_t maxDrawCount = 0; 38 | uint32_t stride = 0; 39 | }; 40 | VSG_type_name(vsg::DrawMeshTasksIndirectCount); 41 | 42 | } // namespace vsg 43 | -------------------------------------------------------------------------------- /include/vsg/meshshaders/DrawMeshTasksIndirect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* 4 | 5 | Copyright(c) 2019 Robert Osfield 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | namespace vsg 19 | { 20 | 21 | /// DrawMeshTasksIndirect command encapsulates vkCmdDrawMeshTasksIndirectEXT call and associated parameters 22 | class VSG_DECLSPEC DrawMeshTasksIndirect : public Inherit 23 | { 24 | public: 25 | DrawMeshTasksIndirect(); 26 | 27 | DrawMeshTasksIndirect(ref_ptr data, uint32_t in_drawCount, uint32_t in_stride); 28 | 29 | DrawMeshTasksIndirect(ref_ptr in_buffer, VkDeviceSize in_offset, uint32_t in_drawCount, uint32_t in_stride); 30 | 31 | void read(Input& input) override; 32 | void write(Output& output) const override; 33 | 34 | void compile(Context& context) override; 35 | void record(CommandBuffer& commandBuffer) const override; 36 | 37 | ref_ptr drawParameters; 38 | uint32_t drawCount = 0; 39 | uint32_t stride = 0; 40 | }; 41 | VSG_type_name(vsg::DrawMeshTasksIndirect); 42 | 43 | } // namespace vsg 44 | --------------------------------------------------------------------------------