├── .gitignore ├── LICENSE.md ├── README.md └── modules ├── pw_vulkan ├── descriptor │ ├── pw_VulkanDescriptor.h │ └── pw_VulkanDescriptorSetPool.h ├── memory │ ├── pw_VulkanMemory.h │ ├── pw_VulkanMemoryBuffer.h │ ├── pw_VulkanMemoryImage.h │ ├── pw_VulkanMemoryPool.h │ └── pw_VulkanMemoryRange.h ├── native │ ├── pw_Vulkan_android.h │ ├── pw_Vulkan_ios.h │ ├── pw_Vulkan_linux_X11.h │ ├── pw_Vulkan_osx.h │ └── pw_Vulkan_win32.h ├── pw_vulkan.cpp ├── pw_vulkan.h ├── utils │ ├── pw_Macros.h │ ├── pw_VulkanBufferTransfer.h │ ├── pw_VulkanCommandSequence.h │ ├── pw_VulkanComputePipeline.h │ ├── pw_VulkanConversion.h │ ├── pw_VulkanGraphicsPipeline.h │ └── pw_VulkanImageTransfer.h └── vulkan │ ├── pw_Definitions.cpp │ ├── pw_Definitions.h │ ├── pw_VulkanBuffer.h │ ├── pw_VulkanBufferView.h │ ├── pw_VulkanCommandBuffer.cpp │ ├── pw_VulkanCommandBuffer.h │ ├── pw_VulkanCommandPool.h │ ├── pw_VulkanDebugUtilsMessenger.cpp │ ├── pw_VulkanDebugUtilsMessenger.h │ ├── pw_VulkanDescriptorPool.h │ ├── pw_VulkanDescriptorSet.h │ ├── pw_VulkanDescriptorSetLayout.h │ ├── pw_VulkanDevice.cpp │ ├── pw_VulkanDevice.h │ ├── pw_VulkanDeviceMemory.h │ ├── pw_VulkanFence.h │ ├── pw_VulkanFramebuffer.h │ ├── pw_VulkanImage.h │ ├── pw_VulkanImageView.h │ ├── pw_VulkanInstance.cpp │ ├── pw_VulkanInstance.h │ ├── pw_VulkanNativeSurface.h │ ├── pw_VulkanPhysicalDevice.cpp │ ├── pw_VulkanPhysicalDevice.h │ ├── pw_VulkanPipeline.h │ ├── pw_VulkanPipelineLayout.h │ ├── pw_VulkanRenderPass.h │ ├── pw_VulkanSampler.h │ ├── pw_VulkanSemaphore.h │ ├── pw_VulkanShaderModule.h │ ├── pw_VulkanSurface.cpp │ ├── pw_VulkanSurface.h │ ├── pw_VulkanSwapchain.cpp │ └── pw_VulkanSwapchain.h └── pw_vulkan_graphics ├── contexts ├── caches │ ├── pw_CachedImages.cpp │ ├── pw_CachedMemory.cpp │ ├── pw_CachedPipelines.cpp │ ├── pw_CachedRenderPasses.cpp │ └── pw_CachedShaders.cpp ├── pw_DeviceState.cpp ├── pw_FrameState.cpp ├── pw_OverlayState.cpp ├── pw_RenderContext.cpp ├── pw_VulkanContext.cpp ├── pw_VulkanContext.h ├── pw_VulkanGraphicsContext.cpp ├── pw_VulkanRenderer.cpp ├── renderer │ ├── pw_RenderBase.cpp │ ├── pw_RenderFrame.cpp │ ├── pw_RenderHelpers.cpp │ └── pw_RenderLayer.cpp ├── shaders │ ├── pw_ImageProgram.cpp │ ├── pw_LinearGradientProgram.cpp │ ├── pw_OverlayProgram.cpp │ ├── pw_ProgramHelpers.cpp │ ├── pw_RadialGradientProgram.cpp │ ├── pw_SolidColourProgram.cpp │ └── pw_TiledImageProgram.cpp └── spv │ ├── Basic.vert │ ├── Basic.vert.spv │ ├── Image.frag │ ├── Image.frag.spv │ ├── Image.vert │ ├── Image.vert.spv │ ├── LinearGradient.vert │ ├── LinearGradient.vert.spv │ ├── LinearGradient1.frag │ ├── LinearGradient1.frag.spv │ ├── LinearGradient2.frag │ ├── LinearGradient2.frag.spv │ ├── Overlay.frag │ ├── Overlay.frag.spv │ ├── Overlay.vert │ ├── Overlay.vert.spv │ ├── RadialGradient.frag │ ├── RadialGradient.frag.spv │ ├── RadialGradient.vert │ ├── RadialGradient.vert.spv │ ├── SolidColour.frag │ ├── SolidColour.frag.spv │ ├── SolidColour.vert │ ├── SolidColour.vert.spv │ ├── TiledImage.frag │ ├── TiledImage.frag.spv │ ├── TiledImage.vert │ ├── TiledImage.vert.spv │ ├── pw_Basic_vert.cpp │ ├── pw_Image_frag.cpp │ ├── pw_Image_vert.cpp │ ├── pw_LinearGradient1_frag.cpp │ ├── pw_LinearGradient2_frag.cpp │ ├── pw_LinearGradient_vert.cpp │ ├── pw_Overlay_frag.cpp │ ├── pw_Overlay_vert.cpp │ ├── pw_RadialGradient_frag.cpp │ ├── pw_RadialGradient_vert.cpp │ ├── pw_SolidColour_frag.cpp │ ├── pw_SolidColour_vert.cpp │ ├── pw_TiledImage_frag.cpp │ └── pw_TiledImage_vert.cpp ├── pw_vulkan_graphics.cpp ├── pw_vulkan_graphics.h └── utils ├── pw_VulkanAppComponent.cpp ├── pw_VulkanAppComponent.h ├── pw_VulkanImageType.cpp ├── pw_VulkanImageType.h ├── pw_VulkanIndexBuffer.h ├── pw_VulkanTexture.h └── pw_VulkanUniform.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The Parawave Vulkan C++ Library 2 | 3 | The code and modules are provided under the terms of the ISC license https://opensource.org/licenses/ISC. 4 | 5 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 6 | 7 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /modules/pw_vulkan/descriptor/pw_VulkanDescriptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | class VulkanDescriptor final 33 | { 34 | private: 35 | VulkanDescriptor() = delete; 36 | 37 | public: 38 | VulkanDescriptor(VulkanDescriptorSetPool& pool_) : pool(pool_) 39 | { 40 | std::tie(block, descriptorSet) = pool.acquire(); 41 | jassert(block && descriptorSet); 42 | } 43 | 44 | ~VulkanDescriptor() 45 | { 46 | jassert(block && descriptorSet); 47 | block->dispose(descriptorSet); 48 | } 49 | 50 | const VulkanDescriptorSet& getDescriptorSet() const noexcept { return *descriptorSet; } 51 | 52 | void updateDescriptorSet(const vk::WriteDescriptorSet* descriptorWrites, uint32_t descriptorWriteCount, const vk::CopyDescriptorSet* descriptorCopies = nullptr, uint32_t descriptorCopyCount = 0) const noexcept 53 | { 54 | const auto& device = pool.getDevice(); 55 | jassert(device.getHandle()); 56 | 57 | device.getHandle().updateDescriptorSets(descriptorWriteCount, descriptorWrites, descriptorCopyCount, descriptorCopies); 58 | } 59 | 60 | private: 61 | VulkanDescriptorSetPool& pool; 62 | 63 | VulkanDescriptorSetPool::Block* block; 64 | const VulkanDescriptorSet* descriptorSet; 65 | 66 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanDescriptor) 67 | }; 68 | 69 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/memory/pw_VulkanMemoryRange.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | class VulkanMemory; 32 | 33 | //============================================================================== 34 | /** 35 | VulkanMemoryRange 36 | 37 | A range of memory in a Vulkan DeviceMemory allocation. 38 | */ 39 | class VulkanMemoryRange final 40 | { 41 | friend class VulkanMemory; 42 | 43 | public: 44 | VulkanMemoryRange() : memory(nullptr), memorySize(0), memoryOffset(0), free(false) {} 45 | 46 | explicit VulkanMemoryRange(const VulkanMemory& memory_, vk::DeviceSize memorySize_, vk::DeviceSize memoryOffset_ = 0, bool free_ = true) noexcept : 47 | memory(&memory_), memorySize(memorySize_), memoryOffset(memoryOffset_), free(free_) {} 48 | 49 | ~VulkanMemoryRange() = default; 50 | 51 | VulkanMemoryRange(const VulkanMemoryRange& other) noexcept : 52 | memory(other.memory), memorySize(other.memorySize), memoryOffset(other.memoryOffset), free(other.free) {} 53 | 54 | VulkanMemoryRange(VulkanMemoryRange&& other) noexcept : 55 | memory(nullptr), memorySize(0), memoryOffset(0), free(false) 56 | { 57 | *this = std::move(other); 58 | } 59 | 60 | VulkanMemoryRange& operator=(const VulkanMemoryRange& other) noexcept 61 | { 62 | if (this != &other) 63 | { 64 | memory = other.memory; 65 | memorySize = other.memorySize; 66 | memoryOffset = other.memoryOffset; 67 | 68 | free = other.free; 69 | } 70 | 71 | return *this; 72 | } 73 | 74 | VulkanMemoryRange& operator=(VulkanMemoryRange&& other) noexcept 75 | { 76 | if (this != &other) 77 | { 78 | memory = other.memory; 79 | memorySize = other.memorySize; 80 | memoryOffset = other.memoryOffset; 81 | 82 | free = other.free; 83 | 84 | other.memory = nullptr; 85 | other.memorySize = 0; 86 | other.memoryOffset = 0; 87 | 88 | other.free = false; 89 | } 90 | 91 | return *this; 92 | } 93 | 94 | bool operator==(const VulkanMemoryRange& other) const noexcept 95 | { 96 | if (memory == other.memory && getSize() == other.getSize() && 97 | getOffset() == other.getOffset() && isFree() == other.isFree()) 98 | return true; 99 | 100 | return false; 101 | } 102 | 103 | const VulkanMemory* getMemoryBlock() const noexcept { return memory; } 104 | 105 | vk::DeviceSize getSize() const noexcept { return memorySize; } 106 | 107 | vk::DeviceSize getOffset() const noexcept { return memoryOffset; } 108 | 109 | vk::DeviceSize getEnd() const noexcept { return getOffset() + getSize(); } 110 | 111 | bool isFree() const noexcept { return free; } 112 | 113 | bool isEmpty() const noexcept { return getSize() == vk::DeviceSize(0); } 114 | 115 | private: 116 | const VulkanMemory* memory; 117 | 118 | vk::DeviceSize memorySize; 119 | vk::DeviceSize memoryOffset; 120 | 121 | bool free; 122 | }; 123 | 124 | } // namespace parawave 125 | -------------------------------------------------------------------------------- /modules/pw_vulkan/native/pw_Vulkan_android.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | // implementation : pw_VulkanNativeSurface 33 | 34 | std::unique_ptr VulkanNativeSurface::create(VulkanNativeSurface::Target& surfaceTarget) 35 | { 36 | return {}; 37 | } 38 | 39 | } // namespace parawave 40 | -------------------------------------------------------------------------------- /modules/pw_vulkan/native/pw_Vulkan_ios.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | // implementation : pw_VulkanNativeSurface 33 | 34 | std::unique_ptr VulkanNativeSurface::create(VulkanNativeSurface::Target& surfaceTarget) 35 | { 36 | return {}; 37 | } 38 | 39 | } // namespace parawave 40 | -------------------------------------------------------------------------------- /modules/pw_vulkan/native/pw_Vulkan_linux_X11.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | // implementation : pw_VulkanNativeSurface 33 | 34 | std::unique_ptr VulkanNativeSurface::create(VulkanNativeSurface::Target& surfaceTarget) 35 | { 36 | return {}; 37 | } 38 | 39 | } // namespace parawave 40 | -------------------------------------------------------------------------------- /modules/pw_vulkan/native/pw_Vulkan_osx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | // implementation : pw_VulkanNativeSurface 33 | 34 | std::unique_ptr VulkanNativeSurface::create(VulkanNativeSurface::Target& surfaceTarget) 35 | { 36 | return {}; 37 | } 38 | 39 | } // namespace parawave 40 | -------------------------------------------------------------------------------- /modules/pw_vulkan/pw_vulkan.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #define JUCE_GUI_BASICS_INCLUDE_SCOPED_THREAD_DPI_AWARENESS_SETTER 1 27 | 28 | #include 29 | 30 | /******************************************************************************* 31 | pw_vulkan 32 | *******************************************************************************/ 33 | #include "pw_vulkan.h" 34 | 35 | #ifndef PW_VULKAN_PRINT_VALIDATION_LAYER_INFO 36 | #define PW_VULKAN_PRINT_VALIDATION_LAYER_INFO 0 37 | #endif 38 | 39 | #ifndef PW_VULKAN_PRINT_INSTANCE_EXTENSIONS_INFO 40 | #define PW_VULKAN_PRINT_INSTANCE_EXTENSIONS_INFO 0 41 | #endif 42 | 43 | #ifndef PW_VULKAN_PRINT_DEVICE_EXTENSIONS_INFO 44 | #define PW_VULKAN_PRINT_DEVICE_EXTENSIONS_INFO 0 45 | #endif 46 | 47 | #if(JUCE_DEBUG) 48 | #define PW_VULKAN_ENABLE_VALIDATION_LAYERS 1 49 | #define PW_VULKAN_USE_DEBUG_UTILS 1 50 | #endif 51 | 52 | #ifndef PW_VULKAN_ENABLE_VALIDATION_LAYERS 53 | #define PW_VULKAN_ENABLE_VALIDATION_LAYERS 0 54 | #endif 55 | 56 | #ifndef PW_VULKAN_USE_DEBUG_UTILS 57 | #define PW_VULKAN_USE_DEBUG_UTILS 0 58 | #endif 59 | 60 | //============================================================================== 61 | 62 | namespace parawave 63 | { 64 | 65 | } // namespace parawave 66 | 67 | //============================================================================== 68 | #include "vulkan/pw_Definitions.cpp" 69 | 70 | #if JUCE_WINDOWS 71 | #include "native/pw_Vulkan_win32.h" 72 | 73 | #elif JUCE_MAC || JUCE_IOS 74 | 75 | #if JUCE_MAC 76 | #include "native/pw_Vulkan_osx.h" 77 | #else 78 | #include "native/pw_Vulkan_ios.h" 79 | #endif 80 | 81 | #elif JUCE_LINUX 82 | #include "native/pw_Vulkan_linux_X11.h" 83 | 84 | #elif JUCE_ANDROID 85 | #include "native/pw_Vulkan_android.h" 86 | 87 | #endif 88 | 89 | //============================================================================== 90 | 91 | #include "vulkan/pw_VulkanInstance.cpp" 92 | #include "vulkan/pw_VulkanCommandBuffer.cpp" 93 | #include "vulkan/pw_VulkanDebugUtilsMessenger.cpp" 94 | #include "vulkan/pw_VulkanSurface.cpp" 95 | #include "vulkan/pw_VulkanPhysicalDevice.cpp" 96 | #include "vulkan/pw_VulkanDevice.cpp" 97 | #include "vulkan/pw_VulkanSwapchain.cpp" 98 | -------------------------------------------------------------------------------- /modules/pw_vulkan/utils/pw_Macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | #if (JUCE_DEBUG) 29 | 30 | //============================================================================== 31 | /** Platform-independent assertion macro. 32 | 33 | vk::Result result = ... 34 | PW_CHECK_VK_RESULT_SUCCESS(result, "Error because ..."); 35 | 36 | Is a short way of writing: 37 | 38 | if(result != vk::Result::eSuccess) 39 | { 40 | DBG("[Vulkan] Error because ..."); 41 | jassertfalse; 42 | } 43 | */ 44 | #define PW_CHECK_VK_RESULT_SUCCESS(result, textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (result != vk::Result::eSuccess) { DBG(juce::String("[Vulkan] ") << vk::to_string(result) << " : " << textToWrite); jassertfalse; }) 45 | 46 | #define PW_CHECK_VK_RESULT(expression, result, textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) { DBG(juce::String("[Vulkan] ") << vk::to_string(result) << " : " << textToWrite); jassertfalse; }) 47 | 48 | #else 49 | //============================================================================== 50 | // If debugging is disabled, these dummy debug and assertion macros are used.. 51 | 52 | #define PW_CHECK_VK_RESULT_SUCCESS(result, textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (juce::ignoreUnused(result);) 53 | 54 | #define PW_CHECK_VK_RESULT(expression, result, textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (juce::ignoreUnused(result);) 55 | 56 | #endif 57 | 58 | //============================================================================== 59 | #if (PW_SHOW_VERBOSE_DEBUG_MESSAGES == 1) 60 | #define PW_DBG_V(textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON ( DBG(juce::String("[Vulkan] ") << textToWrite); ) 61 | #else 62 | #define PW_DBG_V(textToWrite) 63 | #endif -------------------------------------------------------------------------------- /modules/pw_vulkan/utils/pw_VulkanBufferTransfer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanBufferTransfer 34 | 35 | Copy from host visible into device local memory (or vice versa). 36 | */ 37 | class VulkanBufferTransfer : public VulkanCommandSequence 38 | { 39 | public: 40 | VulkanBufferTransfer(const VulkanDevice& device_, const VulkanBuffer& buffer_, const VulkanBuffer& stagingBuffer_) : 41 | VulkanCommandSequence(device_), buffer(buffer_), stagingBuffer(stagingBuffer_) {} 42 | 43 | ~VulkanBufferTransfer() override = default; 44 | 45 | void writeToBuffer() 46 | { 47 | submit([&](const VulkanCommandBuffer& cb) 48 | { 49 | const auto copySize = std::min(buffer.getSize(), stagingBuffer.getSize()); 50 | 51 | const auto region = vk::BufferCopy() 52 | .setSrcOffset(0).setDstOffset(0).setSize(copySize); 53 | 54 | cb.copyBuffer(buffer, stagingBuffer, region); 55 | 56 | }, true); 57 | } 58 | 59 | private: 60 | const VulkanBuffer& buffer; 61 | const VulkanBuffer& stagingBuffer; 62 | 63 | private: 64 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanBufferTransfer) 65 | }; 66 | 67 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/utils/pw_VulkanComputePipeline.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | class VulkanComputePipeline final 33 | { 34 | public: 35 | struct CreateInfo : public vk::ComputePipelineCreateInfo 36 | { 37 | CreateInfo(const VulkanPipelineLayout& pipelineLayout) 38 | { 39 | setLayout(pipelineLayout.getHandle()); 40 | 41 | setBasePipelineHandle(nullptr); 42 | setBasePipelineIndex(0); 43 | } 44 | 45 | void setShaderStage(const VulkanShaderModule& computeShader) 46 | { 47 | jassert(computeShader.getHandle()); 48 | 49 | setStage(vk::PipelineShaderStageCreateInfo() 50 | .setStage(vk::ShaderStageFlagBits::eCompute) 51 | .setModule(computeShader.getHandle()) 52 | .setPName("main")); 53 | } 54 | }; 55 | }; 56 | 57 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_Definitions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | /******************************************************************************* 27 | VULKAN SDK 28 | *******************************************************************************/ 29 | 30 | /** Add Extra Library Search Path for Vulkan Libs to your Projucer project: 31 | e.g C:\VulkanSDK\1.2.154.1\Lib */ 32 | #if JUCE_WINDOWS 33 | #pragma comment (lib, "vulkan-1.lib") 34 | 35 | #elif JUCE_MAC || JUCE_IOS 36 | // TODO: ? 37 | 38 | #elif JUCE_LINUX 39 | // TODO: libvulkan.so ?? 40 | 41 | #elif JUCE_ANDROID 42 | // TODO: ? 43 | 44 | #endif 45 | 46 | /** Define the storage of the default dynamic dispatch loader. */ 47 | VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_Definitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | /******************************************************************************* 29 | VULKAN SDK 30 | *******************************************************************************/ 31 | 32 | /** Use the default dynamic dispatch loader */ 33 | #define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 34 | 35 | /** Use JUCE assertion instead of default */ 36 | #define VULKAN_HPP_ASSERT jassert 37 | 38 | /** Turn off assertions on result values */ 39 | #define VULKAN_HPP_ASSERT_ON_RESULT 40 | 41 | /** Use typesafe conversions */ 42 | #define VULKAN_HPP_TYPESAFE_CONVERSION 43 | 44 | /** Turn of exceptions */ 45 | #define VULKAN_HPP_NO_EXCEPTIONS 46 | 47 | /** Use forced inline attribute to mark all Vulkan functions as inline */ 48 | #define VULKAN_HPP_INLINE forcedinline 49 | 50 | /** Platform specific Khronos Extensions */ 51 | #if JUCE_WINDOWS 52 | #define VK_USE_PLATFORM_WIN32_KHR 53 | 54 | /** vulkan.hpp includes vulkan.h which unfortunately includes 55 | To avoid ambiguous symbols, especially juce::Rectangle, define NOGDI to avoid including these definitiosn. 56 | */ 57 | #define NOGDI 58 | #define WIN32_LEAN_AND_MEAN 59 | #define NOMINMAX 60 | 61 | #elif JUCE_MAC || JUCE_IOS 62 | 63 | #if JUCE_MAC 64 | #define VK_USE_PLATFORM_MACOS_MVK 65 | #else 66 | #define VK_USE_PLATFORM_IOS_MVK 67 | #endif 68 | 69 | // #define VK_USE_PLATFORM_METAL_EXT ? Is this necessary ? 70 | 71 | #elif JUCE_LINUX 72 | #define VK_USE_PLATFORM_XLIB_KHR 73 | 74 | #elif JUCE_ANDROID 75 | #define VK_USE_PLATFORM_ANDROID_KHR 76 | 77 | #endif 78 | 79 | JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused") 80 | 81 | /** Add Header Search Paths for Vulkan SDK to your Projucer project: 82 | e.g C:\VulkanSDK\1.2.162.1\Include */ 83 | #include 84 | 85 | /** Some examples include the SDK Platform. This doesn't seem to be necessary? */ 86 | //#include 87 | 88 | JUCE_END_IGNORE_WARNINGS_GCC_LIKE 89 | 90 | /** Undefine the usual min max macro madness after include of . */ 91 | #if JUCE_WINDOWS 92 | #undef ASSERT 93 | #undef WARNING 94 | #undef PRINTSYSERROR 95 | #undef DEBUGSTR 96 | #undef DBPRT0 97 | #undef DBPRT1 98 | #undef DBPRT2 99 | #undef DBPRT3 100 | #undef DBPRT4 101 | #undef DBPRT5 102 | #undef min 103 | #undef max 104 | #undef MIN 105 | #undef MAX 106 | #undef calloc 107 | #undef free 108 | #undef malloc 109 | #undef realloc 110 | #undef rad1 111 | #undef small 112 | #undef NEW 113 | #undef NEWVEC 114 | #undef VERIFY 115 | #undef VERIFY_IS 116 | #undef VERIFY_NOT 117 | #undef META_CREATE_FUNC 118 | #undef CLASS_CREATE_FUNC 119 | #undef SINGLE_CREATE_FUNC 120 | #undef _META_CLASS 121 | #undef _META_CLASS_IFACE 122 | #undef _META_CLASS_SINGLE 123 | #undef META_CLASS 124 | #undef META_CLASS_IFACE 125 | #undef META_CLASS_SINGLE 126 | #undef SINGLETON 127 | #undef OBJ_METHODS 128 | #undef QUERY_INTERFACE 129 | #undef LICENCE_UID 130 | #undef BEGIN_FACTORY 131 | #undef DEF_CLASS 132 | #undef DEF_CLASS1 133 | #undef DEF_CLASS2 134 | #undef DEF_CLASS_W 135 | #undef END_FACTORY 136 | #endif 137 | -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanBuffer 34 | 35 | Buffers represent linear arrays of data which are used for various purposes 36 | by binding them to a graphics or compute pipeline via descriptor sets or via 37 | certain commands, or by directly specifying them as parameters to certain 38 | commands. 39 | */ 40 | class VulkanBuffer final 41 | { 42 | private: 43 | VulkanBuffer() = delete; 44 | 45 | public: 46 | VulkanBuffer(const VulkanDevice& device_, const vk::BufferCreateInfo& createInfo) 47 | : device(device_), size(createInfo.size) 48 | { 49 | vk::Result result; 50 | 51 | jassert(device.getHandle()); 52 | std::tie(result, handle) = device.getHandle().createBufferUnique(createInfo).asTuple(); 53 | 54 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create buffer."); 55 | } 56 | 57 | VulkanBuffer(const VulkanDevice& device, vk::DeviceSize bufferSize, vk::BufferUsageFlags bufferUsage, vk::SharingMode sharingMode = vk::SharingMode::eExclusive) 58 | : VulkanBuffer(device, vk::BufferCreateInfo().setSize(bufferSize).setUsage(bufferUsage).setSharingMode(sharingMode)) {} 59 | 60 | ~VulkanBuffer() = default; 61 | 62 | const vk::Buffer& getHandle() const noexcept { return *handle; } 63 | 64 | vk::DeviceSize getSize() const noexcept { return size; } 65 | 66 | vk::MemoryRequirements getMemoryRequirements() const noexcept 67 | { 68 | jassert(getHandle() && device.getHandle()); 69 | return device.getHandle().getBufferMemoryRequirements(getHandle()); 70 | } 71 | 72 | private: 73 | const VulkanDevice& device; 74 | 75 | vk::UniqueBuffer handle; 76 | vk::DeviceSize size; 77 | 78 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanBuffer) 79 | }; 80 | 81 | } // namespace parawave#pragma once 82 | -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanBufferView.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanBufferView 34 | */ 35 | class VulkanBufferView final 36 | { 37 | public: 38 | struct CreateInfo : public vk::BufferViewCreateInfo 39 | { 40 | CreateInfo(const VulkanBuffer& buffer, const vk::Format& format) 41 | { 42 | setBuffer(buffer.getHandle()); 43 | setFormat(format); 44 | setOffset(0); 45 | setRange(buffer.getSize()); 46 | } 47 | }; 48 | 49 | public: 50 | VulkanBufferView(const VulkanDevice& device, const vk::BufferViewCreateInfo& createInfo) 51 | { 52 | vk::Result result; 53 | 54 | jassert(device.getHandle()); 55 | std::tie(result, handle) = device.getHandle().createBufferViewUnique(createInfo).asTuple(); 56 | 57 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create buffer view."); 58 | } 59 | 60 | VulkanBufferView(const VulkanDevice& device, const VulkanBuffer& buffer, const vk::Format& format = vk::Format::eUndefined) 61 | : VulkanBufferView(device, CreateInfo(buffer, format)) {} 62 | 63 | ~VulkanBufferView() = default; 64 | 65 | const vk::BufferView& getHandle() const noexcept { return *handle; } 66 | 67 | private: 68 | vk::UniqueBufferView handle; 69 | 70 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanBufferView) 71 | }; 72 | 73 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanCommandPool.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanCommandPool 34 | 35 | Command pools are opaque objects that command buffer memory is allocated 36 | from, and which allow the implementation to amortize the cost of resource 37 | creation across multiple command buffers. Command pools are externally 38 | synchronized, meaning that a command pool must not be used concurrently in 39 | multiple threads. That includes use via recording commands on any command 40 | buffers allocated from the pool, as well as operations that allocate, free, 41 | and reset command buffers or the pool itself. 42 | */ 43 | class VulkanCommandPool final 44 | { 45 | private: 46 | VulkanCommandPool() = delete; 47 | 48 | public: 49 | VulkanCommandPool(const VulkanDevice& device, const vk::CommandPoolCreateInfo& createInfo) 50 | { 51 | vk::Result result; 52 | 53 | jassert(device.getHandle()); 54 | std::tie(result, handle) = device.getHandle().createCommandPoolUnique(createInfo).asTuple(); 55 | 56 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create command pool."); 57 | } 58 | 59 | VulkanCommandPool(const VulkanDevice& device, uint32_t queueFamilyIndex, vk::CommandPoolCreateFlagBits flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer) 60 | : VulkanCommandPool(device, vk::CommandPoolCreateInfo().setQueueFamilyIndex(queueFamilyIndex).setFlags(flags)) {} 61 | 62 | ~VulkanCommandPool() = default; 63 | 64 | const vk::CommandPool& getHandle() const noexcept { return *handle; } 65 | 66 | private: 67 | vk::UniqueCommandPool handle; 68 | 69 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanCommandPool) 70 | }; 71 | 72 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanDebugUtilsMessenger.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan/vulkan/pw_VulkanDebugUtilsMessenger.h -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanDescriptorPool.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanDescriptorPool 34 | 35 | A descriptor pool maintains a pool of descriptors, from which descriptor 36 | sets are allocated. Descriptor pools are externally synchronized, meaning 37 | that the application must not allocate and/or free descriptor sets from the 38 | same pool in multiple threads simultaneously. 39 | */ 40 | class VulkanDescriptorPool final 41 | { 42 | private: 43 | VulkanDescriptorPool() = delete; 44 | 45 | public: 46 | VulkanDescriptorPool(const VulkanDevice& device, const vk::DescriptorPoolCreateInfo& createInfo) 47 | { 48 | vk::Result result; 49 | 50 | jassert(device.getHandle()); 51 | std::tie(result, handle) = device.getHandle().createDescriptorPoolUnique(createInfo).asTuple(); 52 | 53 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create descriptor pool."); 54 | } 55 | 56 | ~VulkanDescriptorPool() = default; 57 | 58 | const vk::DescriptorPool& getHandle() const noexcept { return *handle; } 59 | 60 | private: 61 | vk::UniqueDescriptorPool handle; 62 | 63 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanDescriptorPool) 64 | }; 65 | 66 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanDescriptorSet.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanDescriptorSet 34 | 35 | Descriptors are grouped together into descriptor set objects. A descriptor 36 | set object is an opaque object containing storage for a set of descriptors, 37 | where the types and number of descriptors is defined by a descriptor set 38 | layout. 39 | 40 | Descriptor sets are allocated from descriptor pool objects. 41 | */ 42 | class VulkanDescriptorSet final 43 | { 44 | private: 45 | VulkanDescriptorSet() = delete; 46 | 47 | public: 48 | VulkanDescriptorSet(const VulkanDevice& device, const vk::DescriptorSetAllocateInfo& allocateInfo) 49 | { 50 | auto resultValue = device.getHandle().allocateDescriptorSetsUnique(allocateInfo); 51 | 52 | PW_CHECK_VK_RESULT_SUCCESS(resultValue.result, "Couldn't create descriptor set."); 53 | 54 | if (resultValue.result == vk::Result::eSuccess) 55 | handle = std::move(resultValue.value[0]); 56 | } 57 | 58 | VulkanDescriptorSet(const VulkanDevice& device, const VulkanDescriptorPool& descriptorPool, const VulkanDescriptorSetLayout& descriptorSetLayout) 59 | : VulkanDescriptorSet(device, vk::DescriptorSetAllocateInfo() 60 | .setDescriptorPool(descriptorPool.getHandle()) 61 | .setDescriptorSetCount(1) 62 | .setPSetLayouts(&descriptorSetLayout.getHandle())) {} 63 | 64 | ~VulkanDescriptorSet() = default; 65 | 66 | const vk::DescriptorSet& getHandle() const noexcept { return *handle; } 67 | 68 | private: 69 | vk::UniqueDescriptorSet handle; 70 | 71 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanDescriptorSet) 72 | }; 73 | 74 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanDescriptorSetLayout.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanDescriptorSetLayout 34 | 35 | A descriptor set layout object is defined by an array of zero or more 36 | descriptor bindings. Each individual descriptor binding is specified by a 37 | descriptor type, a count (array size) of the number of descriptors in the 38 | binding, a set of shader stages that can access the binding, and (if using 39 | immutable samplers) an array of sampler descriptors. 40 | 41 | The layout is used both for determining the resources that need to be 42 | associated with the descriptor set, and determining the interface between 43 | shader stages and shader resources. 44 | */ 45 | class VulkanDescriptorSetLayout final 46 | { 47 | private: 48 | VulkanDescriptorSetLayout() = delete; 49 | 50 | public: 51 | VulkanDescriptorSetLayout(const VulkanDevice& device, const vk::DescriptorSetLayoutCreateInfo& createInfo) 52 | { 53 | vk::Result result; 54 | 55 | jassert(device.getHandle()); 56 | std::tie(result, handle) = device.getHandle().createDescriptorSetLayoutUnique(createInfo).asTuple(); 57 | 58 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create descriptor set layout."); 59 | } 60 | 61 | ~VulkanDescriptorSetLayout() = default; 62 | 63 | const vk::DescriptorSetLayout& getHandle() const noexcept { return *handle; } 64 | 65 | private: 66 | vk::UniqueDescriptorSetLayout handle; 67 | 68 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanDescriptorSetLayout) 69 | }; 70 | 71 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanDevice 34 | 35 | Vulkan separates the concept of physical and logical devices. 36 | A physical device usually represents a single complete implementation of 37 | Vulkan (excluding instance-level functionality) available to the host, of 38 | which there are a finite number. A logical device represents an instance of 39 | that implementation with its own state and resources independent of other 40 | logical devices. 41 | */ 42 | class VulkanDevice final 43 | { 44 | public: 45 | struct Queue final 46 | { 47 | const vk::Queue& getHandle() const noexcept { return handle; } 48 | 49 | vk::Result submit(const VulkanCommandBuffer& commandBuffer, vk::Fence fence = nullptr) const noexcept; 50 | 51 | vk::Result submit(const vk::SubmitInfo& submitInfo, vk::Fence fence = nullptr) const noexcept; 52 | 53 | vk::Result waitIdle() const noexcept; 54 | 55 | vk::Queue handle; 56 | }; 57 | 58 | private: 59 | VulkanDevice() = delete; 60 | 61 | public: 62 | VulkanDevice(const VulkanPhysicalDevice& physicalDevice, const vk::DeviceCreateInfo& createInfo); 63 | 64 | VulkanDevice(const VulkanPhysicalDevice& physicalDevice); 65 | 66 | ~VulkanDevice(); 67 | 68 | const vk::Device& getHandle() const noexcept { return *handle; } 69 | 70 | const VulkanPhysicalDevice& getPhysicalDevice() const noexcept { return physicalDevice; } 71 | 72 | const Queue& getGraphicsQueue() const noexcept; 73 | 74 | const VulkanCommandPool& getGraphicsCommandPool() const noexcept; 75 | 76 | bool hasAssociatedObject() const noexcept; 77 | 78 | juce::ReferenceCountedObject* getAssociatedObject(const char* name) const; 79 | 80 | void setAssociatedObject(const char* name, juce::ReferenceCountedObject* newObject); 81 | 82 | void clearAssociatedObjects(); 83 | 84 | void waitIdle() const noexcept 85 | { 86 | jassert(handle); 87 | const auto result = handle->waitIdle(); 88 | juce::ignoreUnused(result); 89 | } 90 | 91 | private: 92 | const VulkanPhysicalDevice& physicalDevice; 93 | 94 | vk::UniqueDevice handle; 95 | 96 | juce::OwnedArray queues; 97 | 98 | const Queue* graphicsQueue = nullptr; 99 | std::unique_ptr graphicsCommandPool; 100 | 101 | juce::StringArray associatedObjectNames; 102 | juce::ReferenceCountedArray associatedObjects; 103 | 104 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanDevice) 105 | }; 106 | 107 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanDeviceMemory.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanDeviceMemory 34 | 35 | Device memory is memory that is visible to the device — for example the 36 | contents of the image or buffer objects, which can be natively used by the 37 | device. 38 | 39 | Memory properties of a physical device describe the memory heaps and memory 40 | types available. 41 | */ 42 | class VulkanDeviceMemory final 43 | { 44 | private: 45 | VulkanDeviceMemory() = delete; 46 | 47 | public: 48 | VulkanDeviceMemory(const VulkanDevice& device, const vk::MemoryAllocateInfo& allocateInfo) 49 | { 50 | vk::Result result; 51 | 52 | jassert(device.getHandle()); 53 | std::tie(result, handle) = device.getHandle().allocateMemoryUnique(allocateInfo).asTuple(); 54 | 55 | PW_CHECK_VK_RESULT_SUCCESS(result, "Failed to allocate device memory."); 56 | } 57 | 58 | ~VulkanDeviceMemory() = default; 59 | 60 | const vk::DeviceMemory& getHandle() const noexcept { return *handle; } 61 | 62 | private: 63 | vk::UniqueDeviceMemory handle; 64 | 65 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanDeviceMemory) 66 | }; 67 | 68 | } // namespace parawave 69 | -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanFence.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanFence 34 | 35 | Fences are a synchronization primitive that can be used to insert a 36 | dependency from a queue to the host. Fences have two states - signaled and 37 | unsignaled. 38 | 39 | A fence can be signaled as part of the execution of a queue submission 40 | command. 41 | 42 | Fences can be unsignaled on the host with reset(). 43 | Fences can be waited on by the host with wait(). 44 | */ 45 | class VulkanFence final 46 | { 47 | private: 48 | VulkanFence() = delete; 49 | 50 | public: 51 | VulkanFence(const VulkanDevice& device_, const vk::FenceCreateInfo& createInfo) : device(device_) 52 | { 53 | vk::Result result; 54 | 55 | jassert(device.getHandle()); 56 | std::tie(result, handle) = device.getHandle().createFenceUnique(createInfo).asTuple(); 57 | 58 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create fence."); 59 | } 60 | 61 | VulkanFence(const VulkanDevice& device) 62 | : VulkanFence(device, vk::FenceCreateInfo().setFlags(vk::FenceCreateFlagBits::eSignaled)) {} 63 | 64 | ~VulkanFence() = default; 65 | 66 | const vk::Fence& getHandle() const noexcept { return *handle; } 67 | 68 | bool isSignaled() const noexcept 69 | { 70 | jassert(getHandle() && device.getHandle()); 71 | const auto result = device.getHandle().getFenceStatus(getHandle()); 72 | 73 | PW_CHECK_VK_RESULT(result == vk::Result::eSuccess || result == vk::Result::eNotReady, result, "Couldn't get fence status."); 74 | 75 | return result == vk::Result::eSuccess; 76 | } 77 | 78 | bool wait(juce::RelativeTime duration = juce::RelativeTime::seconds(1.0)) const noexcept 79 | { 80 | const auto timeout = static_cast(std::max(0, duration.inMilliseconds())) * 1000; // Nano Seconds 81 | 82 | jassert(getHandle() && device.getHandle()); 83 | const auto result = device.getHandle().waitForFences(1, &getHandle(), VK_TRUE, timeout); 84 | 85 | PW_CHECK_VK_RESULT(result == vk::Result::eSuccess || result == vk::Result::eTimeout, result, "Couldn't wait for fence."); 86 | 87 | return result == vk::Result::eSuccess; 88 | } 89 | 90 | /** Idles in a sleep loop with the specified duration until the fence wait completes. */ 91 | void waitIdle(juce::RelativeTime duration = juce::RelativeTime::milliseconds(10)) const noexcept 92 | { 93 | const auto halfDuration = static_cast(duration.seconds(duration.inSeconds() / 2.0).inMilliseconds()); 94 | 95 | while (! wait(duration)) 96 | juce::Thread::sleep(halfDuration); 97 | } 98 | 99 | bool reset() const noexcept 100 | { 101 | jassert(getHandle() && device.getHandle()); 102 | const auto result = device.getHandle().resetFences(1, &getHandle()); 103 | 104 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't reset fence."); 105 | 106 | return result == vk::Result::eSuccess; 107 | } 108 | 109 | private: 110 | const VulkanDevice& device; 111 | vk::UniqueFence handle; 112 | 113 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanFence) 114 | }; 115 | 116 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanFramebuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanFramebuffer 34 | 35 | Render passes operate in conjunction with framebuffers. Framebuffers 36 | represent a collection of specific memory attachments that a render pass 37 | instance uses. 38 | */ 39 | class VulkanFramebuffer final 40 | { 41 | private: 42 | VulkanFramebuffer() = delete; 43 | 44 | public: 45 | struct CreateInfo : public vk::FramebufferCreateInfo 46 | { 47 | CreateInfo(const VulkanRenderPass& renderPass, const VulkanImageView& imageView, uint32_t width, uint32_t height) 48 | { 49 | attachments[0] = imageView.getHandle(); 50 | 51 | setRenderPass(renderPass.getHandle()); 52 | setAttachments(attachments); 53 | setWidth(width); 54 | setHeight(height); 55 | setLayers(1); 56 | } 57 | 58 | std::array attachments; 59 | }; 60 | 61 | public: 62 | VulkanFramebuffer(const VulkanDevice& device, const vk::FramebufferCreateInfo& createInfo) 63 | { 64 | vk::Result result; 65 | 66 | jassert(device.getHandle()); 67 | std::tie(result, handle) = device.getHandle().createFramebufferUnique(createInfo).asTuple(); 68 | 69 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create framebuffer"); 70 | } 71 | 72 | VulkanFramebuffer(const VulkanDevice& device, const VulkanRenderPass& renderPass, const VulkanImageView& imageView, uint32_t width, uint32_t height) : 73 | VulkanFramebuffer(device, CreateInfo(renderPass, imageView, width, height)) {} 74 | 75 | ~VulkanFramebuffer() = default; 76 | 77 | const vk::Framebuffer& getHandle() const noexcept { return *handle; } 78 | 79 | private: 80 | vk::UniqueFramebuffer handle; 81 | 82 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanFramebuffer) 83 | }; 84 | 85 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanImageView.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanImageView 34 | 35 | Image objects are not directly accessed by pipeline shaders for reading or 36 | writing image data. Instead, image views representing contiguous ranges of 37 | the image subresources and containing additional metadata are used for that 38 | purpose. Views must be created on images of compatible types, and must 39 | represent a valid subset of image subresources. 40 | */ 41 | class VulkanImageView final 42 | { 43 | public: 44 | struct CreateInfo : public vk::ImageViewCreateInfo 45 | { 46 | CreateInfo(const vk::Image& image, const vk::Format& imageFormat) 47 | { 48 | vk::ComponentMapping componentMapping(vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA); 49 | vk::ImageSubresourceRange subResourceRange(vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1); 50 | 51 | setImage(image); 52 | setViewType(vk::ImageViewType::e2D); 53 | setFormat(imageFormat); 54 | setComponents(componentMapping); 55 | setSubresourceRange(subResourceRange); 56 | } 57 | }; 58 | 59 | public: 60 | VulkanImageView(const VulkanDevice& device, const vk::ImageViewCreateInfo& createInfo) 61 | { 62 | vk::Result result; 63 | 64 | jassert(device.getHandle()); 65 | std::tie(result, handle) = device.getHandle().createImageViewUnique(createInfo).asTuple(); 66 | 67 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create image view."); 68 | } 69 | 70 | VulkanImageView(const VulkanDevice& device, const VulkanImage& image) 71 | : VulkanImageView(device, CreateInfo(image.getHandle(), image.getFormat())) {} 72 | 73 | ~VulkanImageView() = default; 74 | 75 | const vk::ImageView& getHandle() const noexcept { return *handle; } 76 | 77 | private: 78 | vk::UniqueImageView handle; 79 | 80 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanImageView) 81 | }; 82 | 83 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanInstance.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanInstance 34 | 35 | There is no global state in Vulkan and all per-application state is stored 36 | in an instance object. Creating an instance object initializes the Vulkan 37 | library and allows the application to pass information about itself to the 38 | implementation. 39 | */ 40 | class VulkanInstance final 41 | { 42 | public: 43 | static constexpr auto apiVersion1_0 = static_cast(VK_API_VERSION_1_0); 44 | static constexpr auto apiVersion1_1 = static_cast(VK_API_VERSION_1_1); 45 | static constexpr auto apiVersion1_2 = static_cast(VK_API_VERSION_1_2); 46 | 47 | public: 48 | struct CreateInfo : public vk::InstanceCreateInfo 49 | { 50 | CreateInfo(uint32_t apiVersion); 51 | 52 | vk::ApplicationInfo applicationInfo; 53 | 54 | std::vector enabledLayers; 55 | std::vector enabledExtensions; 56 | 57 | vk::DebugUtilsMessengerCreateInfoEXT debugInfo; 58 | }; 59 | 60 | public: 61 | VulkanInstance(const vk::InstanceCreateInfo& createInfo); 62 | 63 | explicit VulkanInstance(uint32_t apiVersion) 64 | : VulkanInstance(CreateInfo(apiVersion)) {} 65 | 66 | VulkanInstance() : VulkanInstance(apiVersion1_0) {} 67 | 68 | ~VulkanInstance(); 69 | 70 | const vk::Instance& getHandle() const noexcept { return *handle; } 71 | 72 | uint32_t getVersion() const noexcept { return version; } 73 | 74 | juce::String getVersionString() const noexcept; 75 | 76 | const juce::OwnedArray& getPhysicalDevices() const noexcept { return physicalDevices; } 77 | 78 | private: 79 | void enumeratePhysicalDevices(); 80 | 81 | private: 82 | vk::UniqueInstance handle; 83 | 84 | juce::OwnedArray physicalDevices; 85 | 86 | std::unique_ptr debugUtilsMessenger; 87 | 88 | uint32_t version = 0; 89 | 90 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanInstance) 91 | }; 92 | 93 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanNativeSurface.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanNativeSurface 34 | 35 | This interface can be used to implement the platform specific creation and 36 | repaint management of VulkanSurface 37 | 38 | A valid extent and scale must be returned and position update and invalidation 39 | must trigger a repaint of the native surface. 40 | */ 41 | class VulkanNativeSurface 42 | { 43 | public: 44 | class Target 45 | { 46 | public: 47 | Target() = default; 48 | virtual ~Target() = default; 49 | 50 | /** The component the native surface is attached to. */ 51 | virtual juce::Component& getSurfaceComponent() = 0; 52 | 53 | /** This will immediately trigger the frame render code in the surface target. */ 54 | virtual void renderFrame() = 0; 55 | 56 | /** The rate of the native surface redraw in milliseconds. */ 57 | virtual uint32_t getRefreshRate() const = 0; 58 | }; 59 | 60 | private: 61 | VulkanNativeSurface() = delete; 62 | 63 | public: 64 | virtual ~VulkanNativeSurface() = default; 65 | 66 | /** A VulkanNativeSurface has a Target that requires a juce::Component, so it must be able to 67 | create a VulkanSurface from a VulkanPhysicalDevice. 68 | */ 69 | virtual std::unique_ptr createSurface(const VulkanPhysicalDevice& physicalDevice) const noexcept = 0; 70 | 71 | virtual vk::Extent2D getSurfaceExtent() const noexcept = 0; 72 | 73 | virtual double getSurfaceScale() const noexcept = 0; 74 | 75 | virtual void updateSurfacePosition(juce::Rectangle bounds) const noexcept = 0; 76 | 77 | virtual void invalidateSurface() noexcept = 0; 78 | 79 | //============================================================================== 80 | //** If a native surface target is provided, a NativeSurface is created. */ 81 | static std::unique_ptr create(VulkanNativeSurface::Target& surfaceTarget); 82 | 83 | protected: 84 | VulkanNativeSurface(Target& surfaceTarget) : target(surfaceTarget) { } 85 | 86 | Target& target; 87 | 88 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanNativeSurface) 89 | }; 90 | 91 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanPhysicalDevice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | VulkanPhysicalDevice::VulkanPhysicalDevice(const VulkanInstance& instance_, const vk::PhysicalDevice& handle_) 30 | : instance(instance_), handle(handle_), memoryProperties(handle.getMemoryProperties()) 31 | { 32 | // Device Properties 33 | { 34 | auto properties = handle.getProperties(); 35 | 36 | type = properties.deviceType; 37 | limits = properties.limits; 38 | 39 | name = properties.deviceName.operator std::string(); 40 | } 41 | 42 | // Show available memory heaps 43 | #if(JUCE_DEBUG == 1) 44 | { 45 | const auto heapCount = memoryProperties.memoryHeapCount; 46 | for (auto i = 0U; i < heapCount; ++i) 47 | { 48 | auto& heap = memoryProperties.memoryHeaps[i]; 49 | juce::ignoreUnused(heap); 50 | 51 | PW_DBG_V("Heap Size: " << juce::File::descriptionOfSizeInBytes(heap.size) << " Flags: " << vk::to_string(heap.flags)); 52 | } 53 | } 54 | #endif 55 | 56 | // Queue Family Properties 57 | { 58 | auto properties = handle.getQueueFamilyProperties(); 59 | 60 | auto index = 0U; 61 | 62 | for (const auto& p : properties) 63 | { 64 | QueueFamily family; 65 | 66 | family.index = index; 67 | family.count = p.queueCount; 68 | 69 | family.flags = p.queueFlags; 70 | 71 | queueFamilies.add(family); 72 | 73 | ++index; 74 | } 75 | } 76 | } 77 | 78 | bool VulkanPhysicalDevice::isSurfaceSupported(const vk::SurfaceKHR& surface) const noexcept 79 | { 80 | for (const auto& queueFamily : queueFamilies) 81 | { 82 | vk::Result result; 83 | uint32_t supportedValue; 84 | 85 | std::tie(result, supportedValue) = handle.getSurfaceSupportKHR(queueFamily.index, surface); 86 | 87 | if (result == vk::Result::eSuccess) 88 | { 89 | if (supportedValue == VK_TRUE) 90 | return true; 91 | } 92 | } 93 | 94 | return false; 95 | } 96 | 97 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanPhysicalDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanPhysicalDevice 34 | */ 35 | class VulkanPhysicalDevice final 36 | { 37 | public: 38 | struct QueueFamily final 39 | { 40 | bool isGraphicsQueue() const noexcept { return static_cast(flags & vk::QueueFlagBits::eGraphics); } 41 | 42 | bool isComputeQueue() const noexcept { return static_cast(flags & vk::QueueFlagBits::eCompute); } 43 | 44 | uint32_t index; 45 | uint32_t count; 46 | 47 | vk::QueueFlags flags; 48 | }; 49 | 50 | private: 51 | VulkanPhysicalDevice() = delete; 52 | 53 | public: 54 | explicit VulkanPhysicalDevice(const VulkanInstance& instance, const vk::PhysicalDevice& handle); 55 | 56 | ~VulkanPhysicalDevice() = default; 57 | 58 | const VulkanInstance& getInstance() const noexcept { return instance; } 59 | 60 | const vk::PhysicalDevice& getHandle() const noexcept { return handle; } 61 | 62 | const vk::PhysicalDeviceType& getType() const noexcept { return type; } 63 | 64 | const vk::PhysicalDeviceLimits& getLimits() const noexcept { return limits; } 65 | 66 | const vk::PhysicalDeviceMemoryProperties& getMemoryProperties() const noexcept { return memoryProperties; } 67 | 68 | juce::String getName() const { return name; } 69 | 70 | juce::String getDeviceTypeName() const { return vk::to_string(type); } 71 | 72 | bool isDiscreteGpu() const noexcept { return type == vk::PhysicalDeviceType::eDiscreteGpu; } 73 | 74 | bool isSurfaceSupported(const vk::SurfaceKHR& surface) const noexcept; 75 | 76 | const juce::Array& getQueueFamilies() const noexcept { return queueFamilies; } 77 | 78 | private: 79 | const VulkanInstance& instance; 80 | 81 | vk::PhysicalDevice handle; 82 | vk::PhysicalDeviceType type; 83 | vk::PhysicalDeviceLimits limits; 84 | vk::PhysicalDeviceMemoryProperties memoryProperties; 85 | 86 | juce::String name; 87 | 88 | juce::Array queueFamilies; 89 | 90 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanPhysicalDevice) 91 | }; 92 | 93 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanPipeline.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** Represents a Vulkan pipeline. */ 33 | class VulkanPipeline final 34 | { 35 | private: 36 | VulkanPipeline() = delete; 37 | 38 | public: 39 | /** Graphics pipelines consist of multiple shader stages, multiple 40 | fixed-function pipeline stages, and a pipeline layout. */ 41 | VulkanPipeline(const VulkanDevice& device, const vk::GraphicsPipelineCreateInfo& createInfo) 42 | { 43 | vk::Result result; 44 | 45 | jassert(device.getHandle()); 46 | std::tie(result, handle) = device.getHandle().createGraphicsPipelineUnique(nullptr, createInfo).asTuple(); 47 | 48 | PW_CHECK_VK_RESULT(result == vk::Result::eSuccess || result == vk::Result::ePipelineCompileRequiredEXT, result, "Couldn't create graphics pipeline."); 49 | 50 | if (result == vk::Result::ePipelineCompileRequiredEXT) 51 | { 52 | /** TODO : PipelineCompileRequiredEXT ? */ 53 | jassertfalse; 54 | } 55 | } 56 | //============================================================================== 57 | /** Compute pipelines consist of a single static compute shader stage and the 58 | pipeline layout. */ 59 | VulkanPipeline(const VulkanDevice& device, const vk::ComputePipelineCreateInfo& createInfo) 60 | { 61 | vk::Result result; 62 | 63 | jassert(device.getHandle()); 64 | std::tie(result, handle) = device.getHandle().createComputePipelineUnique(nullptr, createInfo).asTuple(); 65 | 66 | PW_CHECK_VK_RESULT(result == vk::Result::eSuccess || result == vk::Result::ePipelineCompileRequiredEXT, result, "Couldn't create compute pipeline."); 67 | 68 | if (result == vk::Result::ePipelineCompileRequiredEXT) 69 | { 70 | /** TODO : PipelineCompileRequiredEXT ? */ 71 | jassertfalse; 72 | } 73 | } 74 | 75 | ~VulkanPipeline() = default; 76 | 77 | const vk::Pipeline& getHandle() const noexcept { return *handle; } 78 | 79 | private: 80 | vk::UniquePipeline handle; 81 | 82 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanPipeline) 83 | }; 84 | 85 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanPipelineLayout.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanPipelineLayout 34 | 35 | Access to descriptor sets from a pipeline is accomplished through a pipeline 36 | layout. Zero or more descriptor set layouts and zero or more push constant 37 | ranges are combined to form a pipeline layout object describing the complete 38 | set of resources that can be accessed by a pipeline. The pipeline layout 39 | represents a sequence of descriptor sets with each having a specific layout. 40 | This sequence of layouts is used to determine the interface between shader 41 | stages and shader resources. Each pipeline is created using a pipeline 42 | layout. 43 | */ 44 | class VulkanPipelineLayout final 45 | { 46 | private: 47 | VulkanPipelineLayout() = delete; 48 | 49 | public: 50 | VulkanPipelineLayout(const VulkanDevice& device, const vk::PipelineLayoutCreateInfo& createInfo) 51 | { 52 | vk::Result result; 53 | 54 | jassert(device.getHandle()); 55 | std::tie(result, handle) = device.getHandle().createPipelineLayoutUnique(createInfo).asTuple(); 56 | 57 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create pipeline layout."); 58 | } 59 | 60 | ~VulkanPipelineLayout() = default; 61 | 62 | const vk::PipelineLayout& getHandle() const noexcept { return *handle; } 63 | 64 | private: 65 | vk::UniquePipelineLayout handle; 66 | 67 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanPipelineLayout) 68 | }; 69 | 70 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanRenderPass.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanRenderPass 34 | 35 | A render pass represents a collection of attachments, subpasses, and 36 | dependencies between the subpasses, and describes how the attachments are 37 | used over the course of the subpasses. The use of a render pass in a command 38 | buffer is a render pass instance. 39 | */ 40 | class VulkanRenderPass final 41 | { 42 | private: 43 | VulkanRenderPass(); 44 | 45 | public: 46 | VulkanRenderPass(const VulkanDevice& device, const vk::RenderPassCreateInfo& createInfo) 47 | { 48 | vk::Result result; 49 | 50 | jassert(device.getHandle()); 51 | std::tie(result, handle) = device.getHandle().createRenderPassUnique(createInfo).asTuple(); 52 | 53 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create render pass."); 54 | } 55 | 56 | ~VulkanRenderPass() = default; 57 | 58 | const vk::RenderPass& getHandle() const noexcept { return *handle; } 59 | 60 | private: 61 | vk::UniqueRenderPass handle; 62 | 63 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanRenderPass) 64 | }; 65 | 66 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanSampler.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanSampler 34 | 35 | objects represent the state of an image sampler which is used by the 36 | implementation to read image data and apply filtering and other 37 | transformations for the shader. 38 | */ 39 | class VulkanSampler 40 | { 41 | public: 42 | struct CreateInfo : public vk::SamplerCreateInfo 43 | { 44 | CreateInfo() 45 | { 46 | setMagFilter(vk::Filter::eLinear); 47 | setMinFilter(vk::Filter::eLinear); 48 | setMipmapMode(vk::SamplerMipmapMode::eLinear); 49 | setAddressModeU(vk::SamplerAddressMode::eClampToEdge); 50 | setAddressModeV(vk::SamplerAddressMode::eClampToEdge); 51 | setAddressModeW(vk::SamplerAddressMode::eClampToEdge); 52 | setMipLodBias(0.0f); 53 | setAnisotropyEnable(false); 54 | setMaxAnisotropy(1.0f); 55 | setCompareEnable(false); 56 | setCompareOp(vk::CompareOp::eNever); 57 | setMinLod(0.0f); 58 | setMaxLod(0.0f); 59 | setBorderColor(vk::BorderColor::eFloatTransparentBlack); 60 | setUnnormalizedCoordinates(false); 61 | } 62 | 63 | CreateInfo& setFilter(vk::Filter filter_) noexcept 64 | { 65 | setMagFilter(filter_); 66 | setMinFilter(filter_); 67 | return *this; 68 | } 69 | 70 | CreateInfo& setAddressMode(vk::SamplerAddressMode addressMode_) noexcept 71 | { 72 | setAddressModeU(addressMode_); 73 | setAddressModeV(addressMode_); 74 | setAddressModeW(addressMode_); 75 | return *this; 76 | } 77 | }; 78 | 79 | public: 80 | VulkanSampler(const VulkanDevice& device, const vk::SamplerCreateInfo& createInfo) 81 | { 82 | vk::Result result; 83 | 84 | jassert(device.getHandle()); 85 | std::tie(result, handle) = device.getHandle().createSamplerUnique(createInfo).asTuple(); 86 | 87 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create sampler."); 88 | } 89 | 90 | VulkanSampler(const VulkanDevice& device) 91 | : VulkanSampler(device, CreateInfo()) {} 92 | 93 | ~VulkanSampler() = default; 94 | 95 | const vk::Sampler& getHandle() const noexcept { return *handle; } 96 | 97 | private: 98 | vk::UniqueSampler handle; 99 | 100 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanSampler) 101 | }; 102 | 103 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanSemaphore.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanSemaphore 34 | 35 | Semaphores are a synchronization primitive that can be used to insert a 36 | dependency between queue operations or between a queue operation and the 37 | host. 38 | */ 39 | class VulkanSemaphore final 40 | { 41 | private: 42 | VulkanSemaphore() = delete; 43 | 44 | public: 45 | VulkanSemaphore(const VulkanDevice& device, const vk::SemaphoreCreateInfo& createInfo) 46 | { 47 | vk::Result result; 48 | 49 | jassert(device.getHandle()); 50 | std::tie(result, handle) = device.getHandle().createSemaphoreUnique(createInfo).asTuple(); 51 | 52 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create semaphore."); 53 | } 54 | 55 | VulkanSemaphore(const VulkanDevice& device) 56 | : VulkanSemaphore(device, vk::SemaphoreCreateInfo()) {} 57 | 58 | ~VulkanSemaphore() = default; 59 | 60 | const vk::Semaphore& getHandle() const noexcept { return *handle; } 61 | 62 | private: 63 | vk::UniqueSemaphore handle; 64 | 65 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanSemaphore) 66 | }; 67 | 68 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanShaderModule.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | A shader specifies programmable operations that execute for each vertex, 34 | control point, tessellated vertex, primitive, fragment, or workgroup in the 35 | corresponding stage(s) of the graphics and compute pipelines. 36 | 37 | Shader modules contain shader code and one or more entry points. Shaders 38 | are selected from a shader module by specifying an entry point as part of 39 | pipeline creation. The stages of a pipeline can use shaders that come from 40 | different modules. The shader code defining a shader module must be in the 41 | SPIR-V format 42 | */ 43 | class VulkanShaderModule final 44 | { 45 | private: 46 | VulkanShaderModule() = delete; 47 | 48 | public: 49 | VulkanShaderModule(const VulkanDevice& device, const vk::ShaderModuleCreateInfo& createInfo) 50 | { 51 | vk::Result result; 52 | 53 | jassert(device.getHandle()); 54 | std::tie(result, handle) = device.getHandle().createShaderModuleUnique(createInfo).asTuple(); 55 | 56 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't create shader module."); 57 | } 58 | 59 | VulkanShaderModule(const VulkanDevice& device, const uint32_t* spvData, size_t dataSize) 60 | : VulkanShaderModule(device, vk::ShaderModuleCreateInfo().setCodeSize(dataSize).setPCode(spvData)) {} 61 | 62 | VulkanShaderModule(const VulkanDevice& device, const juce::MemoryBlock& shaderSPV) 63 | : VulkanShaderModule(device, reinterpret_cast(shaderSPV.getData()), shaderSPV.getSize()) {} 64 | 65 | ~VulkanShaderModule() = default; 66 | 67 | const vk::ShaderModule& getHandle() const noexcept { return *handle; } 68 | 69 | private: 70 | vk::UniqueShaderModule handle; 71 | 72 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanShaderModule) 73 | }; 74 | 75 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanSurface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | VulkanSurface::VulkanSurface(const VulkanPhysicalDevice& physicalDevice_) 30 | : physicalDevice(physicalDevice_) {} 31 | 32 | VulkanSurface::~VulkanSurface() = default; 33 | 34 | void VulkanSurface::updateCapabilities() noexcept 35 | { 36 | jassert(physicalDevice.getHandle()); 37 | 38 | vk::Result result; 39 | 40 | // Surface Capabilities 41 | std::tie(result, capabilities) = physicalDevice.getHandle().getSurfaceCapabilitiesKHR(*handle); 42 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't get surface capabilities."); 43 | 44 | // Surface Formats 45 | std::tie(result, surfaceFormats) = physicalDevice.getHandle().getSurfaceFormatsKHR(*handle); 46 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't get surface formats."); 47 | 48 | // Surface Present Modes 49 | std::tie(result, presentModes) = physicalDevice.getHandle().getSurfacePresentModesKHR(*handle); 50 | PW_CHECK_VK_RESULT_SUCCESS(result, "Couldn't get surface present modes"); 51 | } 52 | 53 | bool VulkanSurface::isPresentModeSupported(vk::PresentModeKHR presentMode) const noexcept 54 | { 55 | for (const auto& availableMode : presentModes) 56 | { 57 | if (presentMode == availableMode) 58 | return true; 59 | } 60 | 61 | return false; 62 | } 63 | 64 | bool VulkanSurface::isFormatSupported(vk::Format format, vk::ColorSpaceKHR colorSpace) const noexcept 65 | { 66 | for (const auto& availableFormat : surfaceFormats) 67 | { 68 | if (format == availableFormat.format && colorSpace == availableFormat.colorSpace) 69 | return true; 70 | } 71 | 72 | return false; 73 | } 74 | 75 | vk::SurfaceFormatKHR VulkanSurface::getDefaultFormat() const noexcept 76 | { 77 | return !surfaceFormats.empty() ? surfaceFormats.front() : vk::SurfaceFormatKHR(); 78 | } 79 | 80 | vk::Extent2D VulkanSurface::getExtent() const noexcept 81 | { 82 | const auto safeWidth = std::max(capabilities.minImageExtent.width, std::min(capabilities.maxImageExtent.width, capabilities.currentExtent.width)); 83 | const auto safeHeight = std::max(capabilities.minImageExtent.height, std::min(capabilities.maxImageExtent.height, capabilities.currentExtent.height)); 84 | 85 | return vk::Extent2D(safeWidth, safeHeight); 86 | } 87 | 88 | vk::SurfaceTransformFlagBitsKHR VulkanSurface::getTransform() const noexcept 89 | { 90 | return capabilities.currentTransform; 91 | } 92 | 93 | juce::Range VulkanSurface::getImageCount() const noexcept 94 | { 95 | return juce::Range(capabilities.minImageCount, capabilities.maxImageCount); 96 | } 97 | 98 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanSurface.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanSurface 34 | 35 | Native platform surface or window objects are abstracted by surface objects, 36 | which are represented by vk::SurfaceKHR handles: 37 | */ 38 | class VulkanSurface 39 | { 40 | private: 41 | VulkanSurface() = delete; 42 | 43 | public: 44 | VulkanSurface(const VulkanPhysicalDevice& physicalDevice); 45 | virtual ~VulkanSurface(); 46 | 47 | const vk::SurfaceKHR& getHandle() const noexcept { return *handle; } 48 | 49 | bool isPresentModeSupported(vk::PresentModeKHR presentMode) const noexcept; 50 | 51 | bool isFormatSupported(vk::Format format, vk::ColorSpaceKHR colorSpace) const noexcept; 52 | 53 | vk::SurfaceFormatKHR getDefaultFormat() const noexcept ; 54 | 55 | vk::Extent2D getExtent() const noexcept; 56 | 57 | vk::SurfaceTransformFlagBitsKHR getTransform() const noexcept; 58 | 59 | juce::Range getImageCount() const noexcept; 60 | 61 | void updateCapabilities() noexcept; 62 | 63 | private: 64 | const VulkanPhysicalDevice& physicalDevice; 65 | 66 | protected: 67 | vk::UniqueSurfaceKHR handle; 68 | 69 | private: 70 | vk::SurfaceCapabilitiesKHR capabilities; 71 | 72 | std::vector surfaceFormats; 73 | std::vector presentModes; 74 | 75 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanSurface) 76 | }; 77 | 78 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan/vulkan/pw_VulkanSwapchain.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanSwapchain 34 | 35 | A swapchain object (a.k.a. swapchain) provides the ability to present 36 | rendering results to a surface. 37 | */ 38 | class VulkanSwapchain final 39 | { 40 | private: 41 | VulkanSwapchain() = delete; 42 | 43 | public: 44 | struct CreateInfo : public vk::SwapchainCreateInfoKHR 45 | { 46 | CreateInfo(const VulkanDevice& device, const VulkanSurface& surface, 47 | vk::Format preferredFormat, vk::ColorSpaceKHR preferredColorSpace, vk::PresentModeKHR preferredPresentModeconst, 48 | const VulkanSwapchain* oldSwapChain); 49 | 50 | bool isValid() const noexcept; 51 | }; 52 | 53 | public: 54 | VulkanSwapchain(const VulkanDevice& device, const VulkanSurface& surface, const vk::SwapchainCreateInfoKHR& createInfo); 55 | 56 | ~VulkanSwapchain(); 57 | 58 | const VulkanDevice& getDevice() const noexcept { return device; } 59 | 60 | const vk::SwapchainKHR& getHandle() const noexcept { return *handle; } 61 | 62 | const vk::Format& getImageFormat() const noexcept { return surfaceFormat.format; } 63 | 64 | const vk::ColorSpaceKHR& getColorSpace() const noexcept { return surfaceFormat.colorSpace; } 65 | 66 | const vk::PresentModeKHR& getPresentMode() const noexcept { return presentMode; } 67 | 68 | const vk::Extent2D& getExtent() const noexcept { return extent; } 69 | 70 | uint32_t getWidth() const noexcept { return extent.width; } 71 | 72 | uint32_t getHeight() const noexcept { return extent.height; } 73 | 74 | vk::Viewport getViewport() const noexcept; 75 | 76 | size_t getNumImages() const noexcept; 77 | 78 | vk::Image getImage(size_t index) const noexcept; 79 | 80 | vk::Result acquireNextImage(uint32_t& imageIndex, const VulkanSemaphore& signalSemaphore, juce::RelativeTime timeout = juce::RelativeTime::seconds(1.0)) const noexcept; 81 | 82 | vk::Result presentImage(uint32_t imageIndex, const VulkanSemaphore& waitSemaphore) const noexcept; 83 | 84 | private: 85 | void getSwapchainImages(); 86 | 87 | private: 88 | const VulkanDevice& device; 89 | 90 | vk::UniqueSwapchainKHR handle; 91 | 92 | vk::SurfaceFormatKHR surfaceFormat; 93 | vk::Extent2D extent; 94 | vk::SurfaceTransformFlagBitsKHR surfaceTransform; 95 | 96 | vk::PresentModeKHR presentMode; 97 | 98 | std::vector images; 99 | 100 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanSwapchain) 101 | }; 102 | 103 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/caches/pw_CachedPipelines.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | namespace 30 | { 31 | 32 | //============================================================================== 33 | struct CachedPipelines : public juce::ReferenceCountedObject 34 | { 35 | using Ptr = juce::ReferenceCountedObjectPtr; 36 | 37 | CachedPipelines(VulkanDevice& device, const CachedImages& images, const CachedRenderPasses& renderPasses) : 38 | singleImageSamplerLayout(images.getImageSamplerDescriptorPool().layout), 39 | solidColour(device, renderPasses.offscreen), 40 | linearGradient1(device, singleImageSamplerLayout, renderPasses.offscreen), 41 | linearGradient2(device, singleImageSamplerLayout, renderPasses.offscreen), 42 | radialGradient(device, singleImageSamplerLayout, renderPasses.offscreen), 43 | image(device, singleImageSamplerLayout, renderPasses.offscreen), 44 | tiledImage(device, singleImageSamplerLayout, renderPasses.offscreen), 45 | overlay(device, singleImageSamplerLayout, renderPasses.swapchain) 46 | {} 47 | 48 | static CachedPipelines* get(VulkanDevice& device, const CachedImages& images, const CachedRenderPasses& renderPasses) 49 | { 50 | static constexpr char objectID[] = "CachedPipelines"; 51 | auto pipelines = static_cast(device.getAssociatedObject (objectID)); 52 | if (pipelines == nullptr) 53 | { 54 | pipelines = new CachedPipelines(device, images, renderPasses); 55 | device.setAssociatedObject(objectID, pipelines); 56 | } 57 | 58 | return pipelines; 59 | } 60 | 61 | private: 62 | const VulkanDescriptorSetLayout& singleImageSamplerLayout; 63 | 64 | public: 65 | SolidColourProgram solidColour; 66 | LinearGradientProgram1 linearGradient1; 67 | LinearGradientProgram2 linearGradient2; 68 | RadialGradientProgram radialGradient; 69 | ImageProgram image; 70 | TiledImageProgram tiledImage; 71 | OverlayProgram overlay; 72 | }; 73 | 74 | } // namespace 75 | 76 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/pw_DeviceState.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | //============================================================================== 30 | class DeviceState 31 | { 32 | private: 33 | struct Cache 34 | { 35 | Cache(VulkanDevice& device_, vk::Format renderFormat) : device(device_) 36 | { 37 | memory = CachedMemory::get(device); 38 | shaders = CachedShaders::get(device); 39 | images = CachedImages::get(device, *memory); 40 | renderPasses = CachedRenderPasses::get(device, renderFormat); 41 | pipelines = CachedPipelines::get(device, *images, *renderPasses); 42 | } 43 | 44 | VulkanDevice& device; 45 | 46 | CachedMemory::Ptr memory; 47 | CachedShaders::Ptr shaders; 48 | CachedImages::Ptr images; 49 | CachedRenderPasses::Ptr renderPasses; 50 | CachedPipelines::Ptr pipelines; 51 | }; 52 | 53 | public: 54 | DeviceState(VulkanDevice& device_, vk::Format renderFormat = vk::Format::eUndefined) : 55 | cache(device_, renderFormat), 56 | device(device_), 57 | memory(*cache.memory), shaders(*cache.shaders), images(*cache.images), 58 | renderPasses(*cache.renderPasses), pipelines(*cache.pipelines) 59 | { } 60 | 61 | virtual ~DeviceState() 62 | { 63 | if(minimizeOnRelease) 64 | minimizeStorage(); 65 | } 66 | 67 | bool useMinimizeStorageOnRelease() const noexcept { return minimizeOnRelease; } 68 | 69 | void setMinimizeStorageOnRelease(bool newState) 70 | { 71 | minimizeOnRelease = newState; 72 | } 73 | 74 | VulkanDevice& getDevice() const noexcept { return cache.device; } 75 | 76 | void minimizeStorage(bool forceMinimize = false) 77 | { 78 | // If a new Device State is created or destroyed, it's a good chance to minimize 79 | // the memory used in previous allocations, e.g. the framebuffer storage. 80 | 81 | memory.minimizeStorage(forceMinimize); 82 | } 83 | 84 | private: 85 | Cache cache; 86 | 87 | public: 88 | const VulkanDevice& device; 89 | 90 | CachedMemory& memory; 91 | CachedShaders& shaders; 92 | CachedImages& images; 93 | 94 | const CachedRenderPasses& renderPasses; 95 | const CachedPipelines& pipelines; 96 | 97 | private: 98 | bool minimizeOnRelease = true; 99 | 100 | private: 101 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DeviceState) 102 | }; 103 | 104 | } // namespace parawave 105 | -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/pw_VulkanContext.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanContext 34 | */ 35 | class VulkanContext 36 | { 37 | public: 38 | VulkanContext(); 39 | ~VulkanContext(); 40 | 41 | bool isFullscreen() const noexcept; 42 | 43 | /** Resize the target component to fit the whole screen. 44 | Behind the scenes this uses the juce::Desktop::setKioskModeComponent() method. 45 | 46 | Because changing the window state during rendering could cause a swapchain recreation, 47 | we manage the kiosk mode swiching in the context to make sure it's not destroying any 48 | device resources that are still in use. 49 | */ 50 | void setFullscreen(bool useFullscreen); 51 | 52 | void setFormat(vk::Format preferredFormat); 53 | 54 | void setColourSpace(vk::ColorSpaceKHR preferredColorSpace); 55 | 56 | void setPresentMode(vk::PresentModeKHR preferredPresentMode); 57 | 58 | void setPhysicalDevice(const VulkanPhysicalDevice& physicalDevice); 59 | 60 | void setDefaultPhysicalDevice(const VulkanInstance& instance); 61 | 62 | void resetPhysicalDevice(); 63 | 64 | void attachTo(juce::Component&); 65 | 66 | void detach(); 67 | 68 | bool isAttached() const noexcept; 69 | 70 | VulkanDevice* getDevice() const noexcept; 71 | 72 | double getRenderingScale() const noexcept; 73 | 74 | juce::Component* getTargetComponent() const noexcept; 75 | 76 | static VulkanContext* getContextAttachedTo(juce::Component& component) noexcept; 77 | 78 | void triggerRepaint(); 79 | 80 | private: 81 | class CachedImage; 82 | class Attachment; 83 | 84 | std::unique_ptr device; 85 | std::unique_ptr attachment; 86 | 87 | vk::Format format = vk::Format::eB8G8R8A8Unorm; 88 | vk::ColorSpaceKHR colorSpace = vk::ColorSpaceKHR::eSrgbNonlinear; 89 | vk::PresentModeKHR presentMode = vk::PresentModeKHR::eMailbox; 90 | 91 | CachedImage* getCachedImage() const noexcept; 92 | 93 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanContext) 94 | }; 95 | 96 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/pw_VulkanRenderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanRenderer 34 | 35 | Acquire access to parts of the Vulkan LowLevelGraphicsContext 36 | implementation. 37 | 38 | This interface is not meant for public access! 39 | 40 | BUT ... It could be used in other modules to setup own graphics pipelines. 41 | 42 | void paint(juce::Graphics& g) 43 | { 44 | if(auto renderer = VulkanRenderer::get(g)) 45 | { 46 | ... setup custom render pipeline ... 47 | 48 | renderer->restoreRenderState(); 49 | } 50 | } 51 | */ 52 | class VulkanRenderer 53 | { 54 | public: 55 | VulkanRenderer() = default; 56 | virtual ~VulkanRenderer() = default; 57 | 58 | /** Get the associated device the renderer uses for its resources. */ 59 | virtual VulkanDevice& getDevice() noexcept = 0; 60 | 61 | /** Get the command buffer the current renderer is using.*/ 62 | virtual const VulkanCommandBuffer& getCommandBuffer() const noexcept = 0; 63 | 64 | /** Get the renderpass the current renderer is using.*/ 65 | virtual const VulkanRenderPass& getRenderPass() const noexcept = 0; 66 | 67 | /** Get the current render framebuffer bounds. */ 68 | virtual juce::Rectangle getRenderBounds() const noexcept = 0; 69 | 70 | /** Get the current render transform. */ 71 | virtual juce::AffineTransform getRenderTransform() const noexcept = 0; 72 | 73 | /** Get a shader module that was previously loaded with 'loadShaderModule' */ 74 | virtual const VulkanShaderModule* getShaderModule(const char* name) const = 0; 75 | 76 | /** Load a Vulkan SPIRV shader module from SPV bytecode (uint32). */ 77 | virtual void loadShaderModule(const char* name, const void* spvData, const int dataSize) = 0; 78 | 79 | virtual VulkanMemoryPool& getVertexMemoryPool() const noexcept = 0; 80 | 81 | virtual const VulkanDescriptorSetLayout& getTextureDescriptorLayout() const noexcept = 0; 82 | 83 | virtual const VulkanDescriptorSet& getTextureDescriptorSet(const VulkanTexture& texture, juce::Graphics::ResamplingQuality quality) const = 0; 84 | 85 | virtual VulkanTexture::Ptr getTextureFor(const juce::Image& image) const = 0; 86 | 87 | //============================================================================== 88 | class Listener 89 | { 90 | public: 91 | virtual ~Listener() = default; 92 | 93 | /** Gets called before the renderer is destroyed. */ 94 | virtual void rendererClosing(VulkanRenderer& target) = 0; 95 | }; 96 | 97 | virtual void addListener(Listener* listenerToAdd) = 0; 98 | virtual void removeListener(Listener* listenerToRemove) = 0; 99 | 100 | //============================================================================== 101 | 102 | virtual void restoreRenderState() = 0; 103 | 104 | /** If a VulkanContext is attached to a juce::Component, the Component::paint(juce::Graphics); will 105 | be called with a Vulkan LowLevelGraphicsContext. Use this method to get the corresponding 106 | VulkanRenderer and access the VulkanDevice to setup new render methods. */ 107 | static VulkanRenderer* get(const juce::Graphics& g) noexcept; 108 | }; 109 | 110 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/shaders/pw_ImageProgram.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | //============================================================================== 30 | struct ImagePushConstants 31 | { 32 | VulkanUniform::ScreenBounds screenBounds; 33 | float imageLimits[2]; 34 | VulkanUniform::Matrix matrix; 35 | 36 | void set2DBounds (const juce::Rectangle& bounds) 37 | { 38 | screenBounds.set(bounds); 39 | } 40 | 41 | void setMatrix (const juce::AffineTransform& trans, int imageWidth, int imageHeight, 42 | float fullWidthProportion, float fullHeightProportion, 43 | float targetX, float targetY, bool isForTiling, bool flipY = false) 44 | { 45 | auto t = trans.translated (-targetX, -targetY) 46 | .inverted().scaled (fullWidthProportion / (float) imageWidth, 47 | fullHeightProportion / (float) imageHeight); 48 | 49 | if(flipY) 50 | t = t.followedBy(juce::AffineTransform::verticalFlip(1.0f)); 51 | 52 | matrix.set(t); 53 | 54 | if (isForTiling) 55 | { 56 | fullWidthProportion -= 0.5f / (float) imageWidth; 57 | fullHeightProportion -= 0.5f / (float) imageHeight; 58 | } 59 | 60 | imageLimits[0] = fullWidthProportion; 61 | imageLimits[1] = fullHeightProportion; 62 | } 63 | }; 64 | 65 | //============================================================================== 66 | class ImageProgram 67 | { 68 | private: 69 | struct PipelineLayoutInfo : public vk::PipelineLayoutCreateInfo 70 | { 71 | PipelineLayoutInfo(const VulkanDescriptorSetLayout& descriptorSetLayout) 72 | { 73 | descriptorSetLayouts[0] = descriptorSetLayout.getHandle(); 74 | setSetLayouts(descriptorSetLayouts); 75 | 76 | setPushConstantRanges(pushConstantRanges); 77 | } 78 | 79 | std::array descriptorSetLayouts; 80 | 81 | std::array pushConstantRanges = 82 | { 83 | vk::PushConstantRange(vk::ShaderStageFlagBits::eVertex, 0, sizeof(ImagePushConstants)) 84 | }; 85 | }; 86 | 87 | struct PipelineInfo : public ProgramHelpers::GraphicsPipelineCreateInfo 88 | { 89 | PipelineInfo(VulkanDevice& device, const VulkanPipelineLayout& pipelineLayout, const VulkanRenderPass& renderPass) 90 | : ProgramHelpers::GraphicsPipelineCreateInfo(pipelineLayout, renderPass) 91 | { 92 | setShaders(device, "Image.vert", "Image.frag"); 93 | 94 | finish(); 95 | } 96 | }; 97 | 98 | public: 99 | ImageProgram(VulkanDevice& device, const VulkanDescriptorSetLayout& descriptorSetLayout, const VulkanRenderPass& renderPass) : 100 | pipelineLayout(device, PipelineLayoutInfo(descriptorSetLayout)), 101 | pipeline(device, PipelineInfo(device, pipelineLayout, renderPass)) { } 102 | 103 | const VulkanPipelineLayout pipelineLayout; 104 | const VulkanPipeline pipeline; 105 | 106 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ImageProgram) 107 | }; 108 | 109 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/shaders/pw_LinearGradientProgram.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | struct LinearGradientPushConstants 30 | { 31 | VulkanUniform::ScreenBounds screenBounds; 32 | float gradientInfo[4]; 33 | 34 | void set2DBounds (const juce::Rectangle& bounds) noexcept 35 | { 36 | screenBounds.set(bounds); 37 | } 38 | 39 | void setGradient(const juce::Point& position, float gradient, float length) noexcept 40 | { 41 | gradientInfo[0] = position.x; 42 | gradientInfo[1] = position.y; 43 | gradientInfo[2] = gradient; 44 | gradientInfo[3] = length; 45 | } 46 | }; 47 | 48 | //============================================================================== 49 | class LinearGradientProgram 50 | { 51 | protected: 52 | struct PipelineLayoutInfo : public vk::PipelineLayoutCreateInfo 53 | { 54 | PipelineLayoutInfo(const VulkanDescriptorSetLayout& descriptorSetLayout) 55 | { 56 | descriptorSetLayouts[0] = descriptorSetLayout.getHandle(); 57 | setSetLayouts(descriptorSetLayouts); 58 | 59 | setPushConstantRanges(pushConstantRanges); 60 | } 61 | 62 | std::array descriptorSetLayouts; 63 | 64 | std::array pushConstantRanges = 65 | { 66 | vk::PushConstantRange(vk::ShaderStageFlagBits::eAllGraphics, 0, sizeof(LinearGradientPushConstants)) 67 | }; 68 | }; 69 | 70 | struct PipelineInfo : public ProgramHelpers::GraphicsPipelineCreateInfo 71 | { 72 | PipelineInfo(VulkanDevice& device, const VulkanPipelineLayout& pipelineLayout, const VulkanRenderPass& renderPass, const char* fragName) 73 | : ProgramHelpers::GraphicsPipelineCreateInfo(pipelineLayout, renderPass) 74 | { 75 | setShaders(device, "LinearGradient.vert", fragName); 76 | finish(); 77 | } 78 | }; 79 | }; 80 | 81 | //============================================================================== 82 | class LinearGradientProgram1 : private LinearGradientProgram 83 | { 84 | public: 85 | LinearGradientProgram1(VulkanDevice& device, const VulkanDescriptorSetLayout& descriptorSetLayout, const VulkanRenderPass& renderPass) : 86 | pipelineLayout(device, PipelineLayoutInfo(descriptorSetLayout)), 87 | pipeline(device, PipelineInfo(device, pipelineLayout, renderPass, "LinearGradient1.frag")) { } 88 | 89 | const VulkanPipelineLayout pipelineLayout; 90 | const VulkanPipeline pipeline; 91 | 92 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LinearGradientProgram1) 93 | }; 94 | 95 | //============================================================================== 96 | class LinearGradientProgram2 : private LinearGradientProgram 97 | { 98 | public: 99 | LinearGradientProgram2(VulkanDevice& device, const VulkanDescriptorSetLayout& descriptorSetLayout, const VulkanRenderPass& renderPass) : 100 | pipelineLayout(device, PipelineLayoutInfo(descriptorSetLayout)), 101 | pipeline(device, PipelineInfo(device, pipelineLayout, renderPass, "LinearGradient2.frag")) { } 102 | 103 | const VulkanPipelineLayout pipelineLayout; 104 | const VulkanPipeline pipeline; 105 | 106 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LinearGradientProgram2) 107 | }; 108 | 109 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/shaders/pw_OverlayProgram.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | struct PixelVertex 30 | { 31 | int16_t x; 32 | int16_t y; 33 | }; 34 | 35 | //============================================================================== 36 | struct OverlayPushConstants 37 | { 38 | juce::Point screenSize; 39 | float textureBounds[4]; 40 | juce::Point vOffsetAndScale; 41 | 42 | void set(const float targetWidth, const float targetHeight, const juce::Rectangle& bounds, bool flipVertically) 43 | { 44 | screenSize.setXY(targetWidth, targetHeight); 45 | 46 | textureBounds[0] = bounds.getX(); 47 | textureBounds[1] = bounds.getY(); 48 | textureBounds[2] = bounds.getWidth(); 49 | textureBounds[3] = bounds.getHeight(); 50 | 51 | vOffsetAndScale.setXY(flipVertically ? 1.0f : 0.0f, flipVertically ? -1.0f : 1.0f); 52 | } 53 | }; 54 | 55 | //============================================================================== 56 | class OverlayProgram 57 | { 58 | private: 59 | struct PipelineLayoutInfo : vk::PipelineLayoutCreateInfo 60 | { 61 | PipelineLayoutInfo(const VulkanDescriptorSetLayout& descriptorSetLayout) 62 | { 63 | descriptorSetLayouts[0] = descriptorSetLayout.getHandle(); 64 | 65 | setSetLayouts(descriptorSetLayouts); 66 | setPushConstantRanges(pushConstantRanges); 67 | } 68 | 69 | std::array descriptorSetLayouts; 70 | 71 | std::array pushConstantRanges = 72 | { 73 | vk::PushConstantRange(vk::ShaderStageFlagBits::eVertex, 0, sizeof(OverlayPushConstants)) 74 | }; 75 | }; 76 | 77 | struct PipelineInfo : public ProgramHelpers::GraphicsPipelineCreateInfo 78 | { 79 | PipelineInfo(VulkanDevice& device, const VulkanPipelineLayout& pipelineLayout, const VulkanRenderPass& renderPass) 80 | : ProgramHelpers::GraphicsPipelineCreateInfo(pipelineLayout, renderPass) 81 | { 82 | setShaders(device, "Overlay.vert", "Overlay.frag"); 83 | 84 | vertexInputState 85 | .setVertexBindingDescriptions(bindings) 86 | .setVertexAttributeDescriptions(attributes); 87 | 88 | inputAssemblyState.setTopology(vk::PrimitiveTopology::eTriangleStrip); 89 | 90 | finish(); 91 | } 92 | 93 | std::array bindings 94 | { 95 | vk::VertexInputBindingDescription(0, sizeof(PixelVertex), vk::VertexInputRate::eVertex) 96 | }; 97 | 98 | std::array attributes 99 | { 100 | vk::VertexInputAttributeDescription(0, 0, vk::Format::eR16G16Sscaled, offsetof(PixelVertex, x)) 101 | }; 102 | }; 103 | 104 | public: 105 | OverlayProgram(VulkanDevice& device, const VulkanDescriptorSetLayout& descriptorSetLayout, const VulkanRenderPass& renderPass) : 106 | pipelineLayout(device, PipelineLayoutInfo(descriptorSetLayout)), 107 | pipeline(device, PipelineInfo(device, pipelineLayout, renderPass)) {} 108 | 109 | const VulkanPipelineLayout pipelineLayout; 110 | const VulkanPipeline pipeline; 111 | 112 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OverlayProgram) 113 | }; 114 | 115 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/shaders/pw_RadialGradientProgram.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | //============================================================================== 30 | struct RadialGradientPushConstants 31 | { 32 | VulkanUniform::ScreenBounds screenBounds; 33 | VulkanUniform::Matrix matrix; 34 | 35 | void set2DBounds (const juce::Rectangle& bounds) noexcept 36 | { 37 | screenBounds.set(bounds); 38 | } 39 | 40 | void setMatrix(const juce::Point& p1, const juce::Point& p2, const juce::Point& p3) noexcept 41 | { 42 | auto t = juce::AffineTransform::fromTargetPoints (p1, juce::Point(), 43 | p2, juce::Point (1.0f, 0.0f), 44 | p3, juce::Point (0.0f, 1.0f)); 45 | matrix.set(t); 46 | } 47 | }; 48 | 49 | //============================================================================== 50 | class RadialGradientProgram 51 | { 52 | private: 53 | struct PipelineLayoutInfo : public vk::PipelineLayoutCreateInfo 54 | { 55 | PipelineLayoutInfo(const VulkanDescriptorSetLayout& descriptorSetLayout) 56 | { 57 | descriptorSetLayouts[0] = descriptorSetLayout.getHandle(); 58 | setSetLayouts(descriptorSetLayouts); 59 | 60 | setPushConstantRanges(pushConstantRanges); 61 | } 62 | 63 | std::array descriptorSetLayouts; 64 | 65 | std::array pushConstantRanges = 66 | { 67 | vk::PushConstantRange(vk::ShaderStageFlagBits::eAllGraphics, 0, sizeof(RadialGradientPushConstants)) 68 | }; 69 | }; 70 | 71 | struct PipelineInfo : public ProgramHelpers::GraphicsPipelineCreateInfo 72 | { 73 | PipelineInfo(VulkanDevice& device, const VulkanPipelineLayout& pipelineLayout, const VulkanRenderPass& renderPass) 74 | : ProgramHelpers::GraphicsPipelineCreateInfo(pipelineLayout, renderPass) 75 | { 76 | setShaders(device, "RadialGradient.vert", "RadialGradient.frag"); 77 | finish(); 78 | } 79 | }; 80 | 81 | public: 82 | RadialGradientProgram(VulkanDevice& device, const VulkanDescriptorSetLayout& descriptorSetLayout, const VulkanRenderPass& renderPass) : 83 | pipelineLayout(device, PipelineLayoutInfo(descriptorSetLayout)), 84 | pipeline(device, PipelineInfo(device, pipelineLayout, renderPass)) { } 85 | 86 | const VulkanPipelineLayout pipelineLayout; 87 | const VulkanPipeline pipeline; 88 | 89 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (RadialGradientProgram) 90 | }; 91 | 92 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/shaders/pw_TiledImageProgram.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | //============================================================================== 30 | class TiledImageProgram 31 | { 32 | private: 33 | struct PipelineLayoutInfo : public vk::PipelineLayoutCreateInfo 34 | { 35 | PipelineLayoutInfo(const VulkanDescriptorSetLayout& descriptorSetLayout) 36 | { 37 | descriptorSetLayouts[0] = descriptorSetLayout.getHandle(); 38 | setSetLayouts(descriptorSetLayouts); 39 | 40 | setPushConstantRanges(pushConstantRanges); 41 | } 42 | 43 | std::array descriptorSetLayouts; 44 | 45 | std::array pushConstantRanges = 46 | { 47 | vk::PushConstantRange(vk::ShaderStageFlagBits::eAllGraphics, 0, sizeof(ImagePushConstants)) 48 | }; 49 | }; 50 | 51 | struct PipelineInfo : public ProgramHelpers::GraphicsPipelineCreateInfo 52 | { 53 | PipelineInfo(VulkanDevice& device, const VulkanPipelineLayout& pipelineLayout, const VulkanRenderPass& renderPass) 54 | : ProgramHelpers::GraphicsPipelineCreateInfo(pipelineLayout, renderPass) 55 | { 56 | setShaders(device, "TiledImage.vert", "TiledImage.frag"); 57 | 58 | finish(); 59 | } 60 | }; 61 | 62 | public: 63 | TiledImageProgram(VulkanDevice& device, const VulkanDescriptorSetLayout& descriptorSetLayout, const VulkanRenderPass& renderPass) : 64 | pipelineLayout(device, PipelineLayoutInfo(descriptorSetLayout)), 65 | pipeline(device, PipelineInfo(device, pipelineLayout, renderPass)) { } 66 | 67 | const VulkanPipelineLayout pipelineLayout; 68 | const VulkanPipeline pipeline; 69 | 70 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TiledImageProgram) 71 | }; 72 | 73 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Basic.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 position; 5 | layout(location = 1) in vec4 colour; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | } pc; 10 | 11 | layout(location = 0) out vec4 frontColour; 12 | layout(location = 1) out vec2 pixelPos; 13 | 14 | void main() { 15 | frontColour = colour; 16 | vec2 adjustedPos = position - pc.screenBounds.xy; 17 | pixelPos = adjustedPos; 18 | vec2 scaledPos = adjustedPos / pc.screenBounds.zw; 19 | gl_Position = vec4 (scaledPos.x - 1.0, 1.0 - scaledPos.y, 0, 1.0); 20 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Basic.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/Basic.vert.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Image.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec4 frontColour; 5 | layout(location = 1) in vec2 texturePos; 6 | 7 | layout(binding = 0) uniform sampler2D imageTexture; 8 | 9 | layout(location = 0) out vec4 outColour; 10 | 11 | void main() { 12 | outColour = frontColour.a * texture (imageTexture, texturePos); 13 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Image.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/Image.frag.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Image.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 position; 5 | layout(location = 1) in vec4 colour; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | vec2 imageLimits; 10 | float matrix[6]; 11 | } pc; 12 | 13 | layout(location = 0) out vec4 frontColour; 14 | layout(location = 1) out vec2 texturePos; 15 | 16 | void main() { 17 | frontColour = colour; 18 | 19 | vec2 adjustedPos = position - pc.screenBounds.xy; 20 | vec2 pixelPos = adjustedPos; 21 | 22 | mat2 transform = mat2 (pc.matrix[0], pc.matrix[3], pc.matrix[1], pc.matrix[4]); 23 | vec2 offset = vec2 (pc.matrix[2], pc.matrix[5]); 24 | 25 | texturePos = clamp(transform * pixelPos + offset, vec2 (0, 0), pc.imageLimits); 26 | 27 | vec2 scaledPos = adjustedPos / pc.screenBounds.zw; 28 | gl_Position = vec4 (scaledPos.x - 1.0, 1.0 - scaledPos.y, 0, 1.0); 29 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Image.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/Image.vert.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/LinearGradient.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 position; 5 | layout(location = 1) in vec4 colour; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | vec4 gradientInfo; 10 | } pc; 11 | 12 | layout(location = 0) out vec4 frontColour; 13 | layout(location = 1) out vec2 pixelPos; 14 | 15 | void main() { 16 | frontColour = colour; 17 | vec2 adjustedPos = position - pc.screenBounds.xy; 18 | pixelPos = adjustedPos; 19 | vec2 scaledPos = adjustedPos / pc.screenBounds.zw; 20 | gl_Position = vec4 (scaledPos.x - 1.0, 1.0 - scaledPos.y, 0, 1.0); 21 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/LinearGradient.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/LinearGradient.vert.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/LinearGradient1.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec4 frontColour; 5 | layout(location = 1) in vec2 pixelPos; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | vec4 gradientInfo; 10 | } pc; 11 | 12 | layout(binding = 0) uniform sampler2D gradientTexture; 13 | 14 | layout(location = 0) out vec4 outColour; 15 | 16 | void main() { 17 | float gradientPos = (pixelPos.y - (pc.gradientInfo.y + (pc.gradientInfo.z * (pixelPos.x - pc.gradientInfo.x)))) / pc.gradientInfo.w; 18 | outColour = (frontColour.a * texture (gradientTexture, vec2 (gradientPos, 0.5))); 19 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/LinearGradient1.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/LinearGradient1.frag.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/LinearGradient2.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec4 frontColour; 5 | layout(location = 1) in vec2 pixelPos; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | vec4 gradientInfo; 10 | } pc; 11 | 12 | layout(binding = 0) uniform sampler2D gradientTexture; 13 | 14 | layout(location = 0) out vec4 outColour; 15 | 16 | void main() { 17 | float gradientPos = (pixelPos.x - (pc.gradientInfo.x + (pc.gradientInfo.z * (pixelPos.y - pc.gradientInfo.y)))) / pc.gradientInfo.w; 18 | outColour = (frontColour.a * texture (gradientTexture, vec2 (gradientPos, 0.5))); 19 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/LinearGradient2.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/LinearGradient2.frag.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Overlay.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 texturePos; 5 | 6 | layout(binding = 0) uniform sampler2D imageTexture; 7 | 8 | layout(location = 0) out vec4 outColor; 9 | 10 | void main() { 11 | outColor = texture(imageTexture, texturePos); 12 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Overlay.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/Overlay.frag.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Overlay.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 inPosition; 5 | 6 | layout(push_constant) uniform PushConsts { 7 | vec2 screenSize; 8 | float textureBounds[4]; 9 | vec2 vOffsetAndScale; 10 | } pc; 11 | 12 | layout(location = 0) out vec2 texturePos; 13 | 14 | void main() { 15 | vec2 scaled = inPosition / (0.5 * pc.screenSize.xy); 16 | gl_Position = vec4 (scaled.x - 1.0, 1.0 - scaled.y, 0, 1.0); 17 | texturePos = (inPosition - vec2 (pc.textureBounds[0], pc.textureBounds[1])) / vec2 (pc.textureBounds[2], pc.textureBounds[3]); 18 | texturePos = vec2 (texturePos.x, pc.vOffsetAndScale.x + pc.vOffsetAndScale.y * texturePos.y); 19 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/Overlay.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/Overlay.vert.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/RadialGradient.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec4 frontColour; 5 | layout(location = 1) in vec2 pixelPos; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | float matrix[6]; 10 | } pc; 11 | 12 | layout(binding = 0) uniform sampler2D gradientTexture; 13 | 14 | layout(location = 0) out vec4 outColour; 15 | 16 | void main() { 17 | mat2 transform = mat2 (pc.matrix[0], pc.matrix[3], pc.matrix[1], pc.matrix[4]); 18 | vec2 offset = vec2 (pc.matrix[2], pc.matrix[5]); 19 | 20 | float gradientPos = length (transform * pixelPos + offset); 21 | outColour = (frontColour.a * texture (gradientTexture, vec2 (gradientPos, 0.5))); 22 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/RadialGradient.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/RadialGradient.frag.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/RadialGradient.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 position; 5 | layout(location = 1) in vec4 colour; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | float matrix[6]; 10 | } pc; 11 | 12 | layout(location = 0) out vec4 frontColour; 13 | layout(location = 1) out vec2 pixelPos; 14 | 15 | void main() { 16 | frontColour = colour; 17 | vec2 adjustedPos = position - pc.screenBounds.xy; 18 | pixelPos = adjustedPos; 19 | vec2 scaledPos = adjustedPos / pc.screenBounds.zw; 20 | gl_Position = vec4 (scaledPos.x - 1.0, 1.0 - scaledPos.y, 0, 1.0); 21 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/RadialGradient.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/RadialGradient.vert.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/SolidColour.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec4 frontColour; 5 | 6 | layout(location = 0) out vec4 outColour; 7 | 8 | void main() { outColour = frontColour; } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/SolidColour.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/SolidColour.frag.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/SolidColour.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 position; 5 | layout(location = 1) in vec4 colour; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | } pc; 10 | 11 | layout(location = 0) out vec4 frontColour; 12 | 13 | void main() { 14 | frontColour = colour; 15 | 16 | vec2 adjustedPos = position - pc.screenBounds.xy; 17 | vec2 scaledPos = adjustedPos / pc.screenBounds.zw; 18 | 19 | gl_Position = vec4 (scaledPos.x - 1.0, 1.0 - scaledPos.y, 0, 1.0); 20 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/SolidColour.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/SolidColour.vert.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/TiledImage.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec4 frontColour; 5 | layout(location = 1) in vec2 pixelPos; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | vec2 imageLimits; 10 | float matrix[6]; 11 | } pc; 12 | 13 | layout(binding = 0) uniform sampler2D imageTexture; 14 | 15 | layout(location = 0) out vec4 outColour; 16 | 17 | void main() { 18 | mat2 transform = mat2 (pc.matrix[0], pc.matrix[3], pc.matrix[1], pc.matrix[4]); 19 | vec2 offset = vec2 (pc.matrix[2], pc.matrix[5]); 20 | 21 | vec2 texturePos = mod (transform * pixelPos + offset, pc.imageLimits); 22 | outColour = frontColour.a * texture (imageTexture, texturePos); 23 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/TiledImage.frag.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/TiledImage.frag.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/TiledImage.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec2 position; 5 | layout(location = 1) in vec4 colour; 6 | 7 | layout(push_constant) uniform PushConsts { 8 | vec4 screenBounds; 9 | vec2 imageLimits; 10 | float matrix[6]; 11 | } pc; 12 | 13 | layout(location = 0) out vec4 frontColour; 14 | layout(location = 1) out vec2 pixelPos; 15 | 16 | void main() { 17 | frontColour = colour; 18 | vec2 adjustedPos = position - pc.screenBounds.xy; 19 | pixelPos = adjustedPos; 20 | vec2 scaledPos = adjustedPos / pc.screenBounds.zw; 21 | gl_Position = vec4 (scaledPos.x - 1.0, 1.0 - scaledPos.y, 0, 1.0); 22 | } -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/TiledImage.vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parawave/vulkan-cpp-library/59a24b43a494c8b99251d4daea650e0f57912eca/modules/pw_vulkan_graphics/contexts/spv/TiledImage.vert.spv -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_Basic_vert.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t vertBasic[] = {3,2,35,7,0,0,1,0,10,0,8,0,56,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,11,0,0,0,17,0,0,0,30,0,0,0,43,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0,4,0,9,0, 7 | 71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0,4,0,0,0, 8 | 109,97,105,110,0,0,0,0,5,0,5,0,9,0,0,0,102,114,111,110,116,67,111,108,111,117,114,0,5,0,4,0,11,0,0,0,99,111,108,111, 9 | 117,114,0,0,5,0,5,0,15,0,0,0,97,100,106,117,115,116,101,100,80,111,115,0,5,0,5,0,17,0,0,0,112,111,115,105,116,105,111,110, 10 | 0,0,0,0,5,0,5,0,19,0,0,0,80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,19,0,0,0,0,0,0,0,115,99,114,101, 11 | 101,110,66,111,117,110,100,115,0,0,0,0,5,0,3,0,21,0,0,0,112,99,0,0,5,0,5,0,30,0,0,0,112,105,120,101,108,80,111,115, 12 | 0,0,0,0,5,0,5,0,32,0,0,0,115,99,97,108,101,100,80,111,115,0,0,0,5,0,6,0,41,0,0,0,103,108,95,80,101,114,86,101, 13 | 114,116,101,120,0,0,0,0,6,0,6,0,41,0,0,0,0,0,0,0,103,108,95,80,111,115,105,116,105,111,110,0,6,0,7,0,41,0,0,0, 14 | 1,0,0,0,103,108,95,80,111,105,110,116,83,105,122,101,0,0,0,0,6,0,7,0,41,0,0,0,2,0,0,0,103,108,95,67,108,105,112,68, 15 | 105,115,116,97,110,99,101,0,6,0,7,0,41,0,0,0,3,0,0,0,103,108,95,67,117,108,108,68,105,115,116,97,110,99,101,0,5,0,3,0, 16 | 43,0,0,0,0,0,0,0,71,0,4,0,9,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,11,0,0,0,30,0,0,0,1,0,0,0, 17 | 71,0,4,0,17,0,0,0,30,0,0,0,0,0,0,0,72,0,5,0,19,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,71,0,3,0, 18 | 19,0,0,0,2,0,0,0,71,0,4,0,30,0,0,0,30,0,0,0,1,0,0,0,72,0,5,0,41,0,0,0,0,0,0,0,11,0,0,0, 19 | 0,0,0,0,72,0,5,0,41,0,0,0,1,0,0,0,11,0,0,0,1,0,0,0,72,0,5,0,41,0,0,0,2,0,0,0,11,0,0,0, 20 | 3,0,0,0,72,0,5,0,41,0,0,0,3,0,0,0,11,0,0,0,4,0,0,0,71,0,3,0,41,0,0,0,2,0,0,0,19,0,2,0, 21 | 2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0,6,0,0,0,32,0,0,0,23,0,4,0,7,0,0,0,6,0,0,0, 22 | 4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0,59,0,4,0,8,0,0,0,9,0,0,0,3,0,0,0,32,0,4,0, 23 | 10,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,10,0,0,0,11,0,0,0,1,0,0,0,23,0,4,0,13,0,0,0,6,0,0,0, 24 | 2,0,0,0,32,0,4,0,14,0,0,0,7,0,0,0,13,0,0,0,32,0,4,0,16,0,0,0,1,0,0,0,13,0,0,0,59,0,4,0, 25 | 16,0,0,0,17,0,0,0,1,0,0,0,30,0,3,0,19,0,0,0,7,0,0,0,32,0,4,0,20,0,0,0,9,0,0,0,19,0,0,0, 26 | 59,0,4,0,20,0,0,0,21,0,0,0,9,0,0,0,21,0,4,0,22,0,0,0,32,0,0,0,1,0,0,0,43,0,4,0,22,0,0,0, 27 | 23,0,0,0,0,0,0,0,32,0,4,0,24,0,0,0,9,0,0,0,7,0,0,0,32,0,4,0,29,0,0,0,3,0,0,0,13,0,0,0, 28 | 59,0,4,0,29,0,0,0,30,0,0,0,3,0,0,0,21,0,4,0,38,0,0,0,32,0,0,0,0,0,0,0,43,0,4,0,38,0,0,0, 29 | 39,0,0,0,1,0,0,0,28,0,4,0,40,0,0,0,6,0,0,0,39,0,0,0,30,0,6,0,41,0,0,0,7,0,0,0,6,0,0,0, 30 | 40,0,0,0,40,0,0,0,32,0,4,0,42,0,0,0,3,0,0,0,41,0,0,0,59,0,4,0,42,0,0,0,43,0,0,0,3,0,0,0, 31 | 43,0,4,0,38,0,0,0,44,0,0,0,0,0,0,0,32,0,4,0,45,0,0,0,7,0,0,0,6,0,0,0,43,0,4,0,6,0,0,0, 32 | 48,0,0,0,0,0,128,63,43,0,4,0,6,0,0,0,53,0,0,0,0,0,0,0,54,0,5,0,2,0,0,0,4,0,0,0,0,0,0,0, 33 | 3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,14,0,0,0,15,0,0,0,7,0,0,0,59,0,4,0,14,0,0,0,32,0,0,0, 34 | 7,0,0,0,61,0,4,0,7,0,0,0,12,0,0,0,11,0,0,0,62,0,3,0,9,0,0,0,12,0,0,0,61,0,4,0,13,0,0,0, 35 | 18,0,0,0,17,0,0,0,65,0,5,0,24,0,0,0,25,0,0,0,21,0,0,0,23,0,0,0,61,0,4,0,7,0,0,0,26,0,0,0, 36 | 25,0,0,0,79,0,7,0,13,0,0,0,27,0,0,0,26,0,0,0,26,0,0,0,0,0,0,0,1,0,0,0,131,0,5,0,13,0,0,0, 37 | 28,0,0,0,18,0,0,0,27,0,0,0,62,0,3,0,15,0,0,0,28,0,0,0,61,0,4,0,13,0,0,0,31,0,0,0,15,0,0,0, 38 | 62,0,3,0,30,0,0,0,31,0,0,0,61,0,4,0,13,0,0,0,33,0,0,0,15,0,0,0,65,0,5,0,24,0,0,0,34,0,0,0, 39 | 21,0,0,0,23,0,0,0,61,0,4,0,7,0,0,0,35,0,0,0,34,0,0,0,79,0,7,0,13,0,0,0,36,0,0,0,35,0,0,0, 40 | 35,0,0,0,2,0,0,0,3,0,0,0,136,0,5,0,13,0,0,0,37,0,0,0,33,0,0,0,36,0,0,0,62,0,3,0,32,0,0,0, 41 | 37,0,0,0,65,0,5,0,45,0,0,0,46,0,0,0,32,0,0,0,44,0,0,0,61,0,4,0,6,0,0,0,47,0,0,0,46,0,0,0, 42 | 131,0,5,0,6,0,0,0,49,0,0,0,47,0,0,0,48,0,0,0,65,0,5,0,45,0,0,0,50,0,0,0,32,0,0,0,39,0,0,0, 43 | 61,0,4,0,6,0,0,0,51,0,0,0,50,0,0,0,131,0,5,0,6,0,0,0,52,0,0,0,48,0,0,0,51,0,0,0,80,0,7,0, 44 | 7,0,0,0,54,0,0,0,49,0,0,0,52,0,0,0,53,0,0,0,48,0,0,0,65,0,5,0,8,0,0,0,55,0,0,0,43,0,0,0, 45 | 23,0,0,0,62,0,3,0,55,0,0,0,54,0,0,0,253,0,1,0,56,0,1,0,0,0}; 46 | const int vertBasicSize = 1664; 47 | 48 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_Image_frag.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t fragImage[] = {3,2,35,7,0,0,1,0,10,0,8,0,28,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,8,0,4,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,11,0,0,0,24,0,0,0,16,0,3,0,4,0,0,0,7,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0, 7 | 4,0,9,0,71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0, 8 | 4,0,0,0,109,97,105,110,0,0,0,0,5,0,5,0,9,0,0,0,111,117,116,67,111,108,111,117,114,0,0,0,5,0,5,0,11,0,0,0, 9 | 102,114,111,110,116,67,111,108,111,117,114,0,5,0,6,0,20,0,0,0,105,109,97,103,101,84,101,120,116,117,114,101,0,0,0,0,5,0,5,0, 10 | 24,0,0,0,116,101,120,116,117,114,101,80,111,115,0,0,71,0,4,0,9,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,11,0,0,0, 11 | 30,0,0,0,0,0,0,0,71,0,4,0,20,0,0,0,34,0,0,0,0,0,0,0,71,0,4,0,20,0,0,0,33,0,0,0,0,0,0,0, 12 | 71,0,4,0,24,0,0,0,30,0,0,0,1,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0, 13 | 6,0,0,0,32,0,0,0,23,0,4,0,7,0,0,0,6,0,0,0,4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0, 14 | 59,0,4,0,8,0,0,0,9,0,0,0,3,0,0,0,32,0,4,0,10,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,10,0,0,0, 15 | 11,0,0,0,1,0,0,0,21,0,4,0,12,0,0,0,32,0,0,0,0,0,0,0,43,0,4,0,12,0,0,0,13,0,0,0,3,0,0,0, 16 | 32,0,4,0,14,0,0,0,1,0,0,0,6,0,0,0,25,0,9,0,17,0,0,0,6,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, 17 | 0,0,0,0,1,0,0,0,0,0,0,0,27,0,3,0,18,0,0,0,17,0,0,0,32,0,4,0,19,0,0,0,0,0,0,0,18,0,0,0, 18 | 59,0,4,0,19,0,0,0,20,0,0,0,0,0,0,0,23,0,4,0,22,0,0,0,6,0,0,0,2,0,0,0,32,0,4,0,23,0,0,0, 19 | 1,0,0,0,22,0,0,0,59,0,4,0,23,0,0,0,24,0,0,0,1,0,0,0,54,0,5,0,2,0,0,0,4,0,0,0,0,0,0,0, 20 | 3,0,0,0,248,0,2,0,5,0,0,0,65,0,5,0,14,0,0,0,15,0,0,0,11,0,0,0,13,0,0,0,61,0,4,0,6,0,0,0, 21 | 16,0,0,0,15,0,0,0,61,0,4,0,18,0,0,0,21,0,0,0,20,0,0,0,61,0,4,0,22,0,0,0,25,0,0,0,24,0,0,0, 22 | 87,0,5,0,7,0,0,0,26,0,0,0,21,0,0,0,25,0,0,0,142,0,5,0,7,0,0,0,27,0,0,0,26,0,0,0,16,0,0,0, 23 | 62,0,3,0,9,0,0,0,27,0,0,0,253,0,1,0,56,0,1,0,0,0}; 24 | const int fragImageSize = 780; 25 | 26 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_LinearGradient1_frag.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t fragLinearGradient1[] = {3,2,35,7,0,0,1,0,10,0,8,0,58,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,8,0,4,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,11,0,0,0,43,0,0,0,45,0,0,0,16,0,3,0,4,0,0,0,7,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0, 7 | 4,0,9,0,71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0, 8 | 4,0,0,0,109,97,105,110,0,0,0,0,5,0,5,0,8,0,0,0,103,114,97,100,105,101,110,116,80,111,115,0,5,0,5,0,11,0,0,0, 9 | 112,105,120,101,108,80,111,115,0,0,0,0,5,0,5,0,18,0,0,0,80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,18,0,0,0, 10 | 0,0,0,0,115,99,114,101,101,110,66,111,117,110,100,115,0,0,0,0,6,0,7,0,18,0,0,0,1,0,0,0,103,114,97,100,105,101,110,116, 11 | 73,110,102,111,0,0,0,0,5,0,3,0,20,0,0,0,112,99,0,0,5,0,5,0,43,0,0,0,111,117,116,67,111,108,111,117,114,0,0,0, 12 | 5,0,5,0,45,0,0,0,102,114,111,110,116,67,111,108,111,117,114,0,5,0,6,0,51,0,0,0,103,114,97,100,105,101,110,116,84,101,120,116, 13 | 117,114,101,0,71,0,4,0,11,0,0,0,30,0,0,0,1,0,0,0,72,0,5,0,18,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0, 14 | 72,0,5,0,18,0,0,0,1,0,0,0,35,0,0,0,16,0,0,0,71,0,3,0,18,0,0,0,2,0,0,0,71,0,4,0,43,0,0,0, 15 | 30,0,0,0,0,0,0,0,71,0,4,0,45,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,51,0,0,0,34,0,0,0,0,0,0,0, 16 | 71,0,4,0,51,0,0,0,33,0,0,0,0,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0, 17 | 6,0,0,0,32,0,0,0,32,0,4,0,7,0,0,0,7,0,0,0,6,0,0,0,23,0,4,0,9,0,0,0,6,0,0,0,2,0,0,0, 18 | 32,0,4,0,10,0,0,0,1,0,0,0,9,0,0,0,59,0,4,0,10,0,0,0,11,0,0,0,1,0,0,0,21,0,4,0,12,0,0,0, 19 | 32,0,0,0,0,0,0,0,43,0,4,0,12,0,0,0,13,0,0,0,1,0,0,0,32,0,4,0,14,0,0,0,1,0,0,0,6,0,0,0, 20 | 23,0,4,0,17,0,0,0,6,0,0,0,4,0,0,0,30,0,4,0,18,0,0,0,17,0,0,0,17,0,0,0,32,0,4,0,19,0,0,0, 21 | 9,0,0,0,18,0,0,0,59,0,4,0,19,0,0,0,20,0,0,0,9,0,0,0,21,0,4,0,21,0,0,0,32,0,0,0,1,0,0,0, 22 | 43,0,4,0,21,0,0,0,22,0,0,0,1,0,0,0,32,0,4,0,23,0,0,0,9,0,0,0,6,0,0,0,43,0,4,0,12,0,0,0, 23 | 26,0,0,0,2,0,0,0,43,0,4,0,12,0,0,0,29,0,0,0,0,0,0,0,43,0,4,0,12,0,0,0,38,0,0,0,3,0,0,0, 24 | 32,0,4,0,42,0,0,0,3,0,0,0,17,0,0,0,59,0,4,0,42,0,0,0,43,0,0,0,3,0,0,0,32,0,4,0,44,0,0,0, 25 | 1,0,0,0,17,0,0,0,59,0,4,0,44,0,0,0,45,0,0,0,1,0,0,0,25,0,9,0,48,0,0,0,6,0,0,0,1,0,0,0, 26 | 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,27,0,3,0,49,0,0,0,48,0,0,0,32,0,4,0,50,0,0,0, 27 | 0,0,0,0,49,0,0,0,59,0,4,0,50,0,0,0,51,0,0,0,0,0,0,0,43,0,4,0,6,0,0,0,54,0,0,0,0,0,0,63, 28 | 54,0,5,0,2,0,0,0,4,0,0,0,0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,7,0,0,0,8,0,0,0, 29 | 7,0,0,0,65,0,5,0,14,0,0,0,15,0,0,0,11,0,0,0,13,0,0,0,61,0,4,0,6,0,0,0,16,0,0,0,15,0,0,0, 30 | 65,0,6,0,23,0,0,0,24,0,0,0,20,0,0,0,22,0,0,0,13,0,0,0,61,0,4,0,6,0,0,0,25,0,0,0,24,0,0,0, 31 | 65,0,6,0,23,0,0,0,27,0,0,0,20,0,0,0,22,0,0,0,26,0,0,0,61,0,4,0,6,0,0,0,28,0,0,0,27,0,0,0, 32 | 65,0,5,0,14,0,0,0,30,0,0,0,11,0,0,0,29,0,0,0,61,0,4,0,6,0,0,0,31,0,0,0,30,0,0,0,65,0,6,0, 33 | 23,0,0,0,32,0,0,0,20,0,0,0,22,0,0,0,29,0,0,0,61,0,4,0,6,0,0,0,33,0,0,0,32,0,0,0,131,0,5,0, 34 | 6,0,0,0,34,0,0,0,31,0,0,0,33,0,0,0,133,0,5,0,6,0,0,0,35,0,0,0,28,0,0,0,34,0,0,0,129,0,5,0, 35 | 6,0,0,0,36,0,0,0,25,0,0,0,35,0,0,0,131,0,5,0,6,0,0,0,37,0,0,0,16,0,0,0,36,0,0,0,65,0,6,0, 36 | 23,0,0,0,39,0,0,0,20,0,0,0,22,0,0,0,38,0,0,0,61,0,4,0,6,0,0,0,40,0,0,0,39,0,0,0,136,0,5,0, 37 | 6,0,0,0,41,0,0,0,37,0,0,0,40,0,0,0,62,0,3,0,8,0,0,0,41,0,0,0,65,0,5,0,14,0,0,0,46,0,0,0, 38 | 45,0,0,0,38,0,0,0,61,0,4,0,6,0,0,0,47,0,0,0,46,0,0,0,61,0,4,0,49,0,0,0,52,0,0,0,51,0,0,0, 39 | 61,0,4,0,6,0,0,0,53,0,0,0,8,0,0,0,80,0,5,0,9,0,0,0,55,0,0,0,53,0,0,0,54,0,0,0,87,0,5,0, 40 | 17,0,0,0,56,0,0,0,52,0,0,0,55,0,0,0,142,0,5,0,17,0,0,0,57,0,0,0,56,0,0,0,47,0,0,0,62,0,3,0, 41 | 43,0,0,0,57,0,0,0,253,0,1,0,56,0,1,0,0,0}; 42 | const int fragLinearGradient1Size = 1496; 43 | 44 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_LinearGradient2_frag.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t fragLinearGradient2[] = {3,2,35,7,0,0,1,0,10,0,8,0,58,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,8,0,4,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,11,0,0,0,43,0,0,0,45,0,0,0,16,0,3,0,4,0,0,0,7,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0, 7 | 4,0,9,0,71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0, 8 | 4,0,0,0,109,97,105,110,0,0,0,0,5,0,5,0,8,0,0,0,103,114,97,100,105,101,110,116,80,111,115,0,5,0,5,0,11,0,0,0, 9 | 112,105,120,101,108,80,111,115,0,0,0,0,5,0,5,0,18,0,0,0,80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,18,0,0,0, 10 | 0,0,0,0,115,99,114,101,101,110,66,111,117,110,100,115,0,0,0,0,6,0,7,0,18,0,0,0,1,0,0,0,103,114,97,100,105,101,110,116, 11 | 73,110,102,111,0,0,0,0,5,0,3,0,20,0,0,0,112,99,0,0,5,0,5,0,43,0,0,0,111,117,116,67,111,108,111,117,114,0,0,0, 12 | 5,0,5,0,45,0,0,0,102,114,111,110,116,67,111,108,111,117,114,0,5,0,6,0,51,0,0,0,103,114,97,100,105,101,110,116,84,101,120,116, 13 | 117,114,101,0,71,0,4,0,11,0,0,0,30,0,0,0,1,0,0,0,72,0,5,0,18,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0, 14 | 72,0,5,0,18,0,0,0,1,0,0,0,35,0,0,0,16,0,0,0,71,0,3,0,18,0,0,0,2,0,0,0,71,0,4,0,43,0,0,0, 15 | 30,0,0,0,0,0,0,0,71,0,4,0,45,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,51,0,0,0,34,0,0,0,0,0,0,0, 16 | 71,0,4,0,51,0,0,0,33,0,0,0,0,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0, 17 | 6,0,0,0,32,0,0,0,32,0,4,0,7,0,0,0,7,0,0,0,6,0,0,0,23,0,4,0,9,0,0,0,6,0,0,0,2,0,0,0, 18 | 32,0,4,0,10,0,0,0,1,0,0,0,9,0,0,0,59,0,4,0,10,0,0,0,11,0,0,0,1,0,0,0,21,0,4,0,12,0,0,0, 19 | 32,0,0,0,0,0,0,0,43,0,4,0,12,0,0,0,13,0,0,0,0,0,0,0,32,0,4,0,14,0,0,0,1,0,0,0,6,0,0,0, 20 | 23,0,4,0,17,0,0,0,6,0,0,0,4,0,0,0,30,0,4,0,18,0,0,0,17,0,0,0,17,0,0,0,32,0,4,0,19,0,0,0, 21 | 9,0,0,0,18,0,0,0,59,0,4,0,19,0,0,0,20,0,0,0,9,0,0,0,21,0,4,0,21,0,0,0,32,0,0,0,1,0,0,0, 22 | 43,0,4,0,21,0,0,0,22,0,0,0,1,0,0,0,32,0,4,0,23,0,0,0,9,0,0,0,6,0,0,0,43,0,4,0,12,0,0,0, 23 | 26,0,0,0,2,0,0,0,43,0,4,0,12,0,0,0,29,0,0,0,1,0,0,0,43,0,4,0,12,0,0,0,38,0,0,0,3,0,0,0, 24 | 32,0,4,0,42,0,0,0,3,0,0,0,17,0,0,0,59,0,4,0,42,0,0,0,43,0,0,0,3,0,0,0,32,0,4,0,44,0,0,0, 25 | 1,0,0,0,17,0,0,0,59,0,4,0,44,0,0,0,45,0,0,0,1,0,0,0,25,0,9,0,48,0,0,0,6,0,0,0,1,0,0,0, 26 | 0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,27,0,3,0,49,0,0,0,48,0,0,0,32,0,4,0,50,0,0,0, 27 | 0,0,0,0,49,0,0,0,59,0,4,0,50,0,0,0,51,0,0,0,0,0,0,0,43,0,4,0,6,0,0,0,54,0,0,0,0,0,0,63, 28 | 54,0,5,0,2,0,0,0,4,0,0,0,0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,7,0,0,0,8,0,0,0, 29 | 7,0,0,0,65,0,5,0,14,0,0,0,15,0,0,0,11,0,0,0,13,0,0,0,61,0,4,0,6,0,0,0,16,0,0,0,15,0,0,0, 30 | 65,0,6,0,23,0,0,0,24,0,0,0,20,0,0,0,22,0,0,0,13,0,0,0,61,0,4,0,6,0,0,0,25,0,0,0,24,0,0,0, 31 | 65,0,6,0,23,0,0,0,27,0,0,0,20,0,0,0,22,0,0,0,26,0,0,0,61,0,4,0,6,0,0,0,28,0,0,0,27,0,0,0, 32 | 65,0,5,0,14,0,0,0,30,0,0,0,11,0,0,0,29,0,0,0,61,0,4,0,6,0,0,0,31,0,0,0,30,0,0,0,65,0,6,0, 33 | 23,0,0,0,32,0,0,0,20,0,0,0,22,0,0,0,29,0,0,0,61,0,4,0,6,0,0,0,33,0,0,0,32,0,0,0,131,0,5,0, 34 | 6,0,0,0,34,0,0,0,31,0,0,0,33,0,0,0,133,0,5,0,6,0,0,0,35,0,0,0,28,0,0,0,34,0,0,0,129,0,5,0, 35 | 6,0,0,0,36,0,0,0,25,0,0,0,35,0,0,0,131,0,5,0,6,0,0,0,37,0,0,0,16,0,0,0,36,0,0,0,65,0,6,0, 36 | 23,0,0,0,39,0,0,0,20,0,0,0,22,0,0,0,38,0,0,0,61,0,4,0,6,0,0,0,40,0,0,0,39,0,0,0,136,0,5,0, 37 | 6,0,0,0,41,0,0,0,37,0,0,0,40,0,0,0,62,0,3,0,8,0,0,0,41,0,0,0,65,0,5,0,14,0,0,0,46,0,0,0, 38 | 45,0,0,0,38,0,0,0,61,0,4,0,6,0,0,0,47,0,0,0,46,0,0,0,61,0,4,0,49,0,0,0,52,0,0,0,51,0,0,0, 39 | 61,0,4,0,6,0,0,0,53,0,0,0,8,0,0,0,80,0,5,0,9,0,0,0,55,0,0,0,53,0,0,0,54,0,0,0,87,0,5,0, 40 | 17,0,0,0,56,0,0,0,52,0,0,0,55,0,0,0,142,0,5,0,17,0,0,0,57,0,0,0,56,0,0,0,47,0,0,0,62,0,3,0, 41 | 43,0,0,0,57,0,0,0,253,0,1,0,56,0,1,0,0,0}; 42 | const int fragLinearGradient2Size = 1496; 43 | 44 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_LinearGradient_vert.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t vertLinearGradient[] = {3,2,35,7,0,0,1,0,10,0,8,0,56,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,11,0,0,0,17,0,0,0,30,0,0,0,43,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0,4,0,9,0, 7 | 71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0,4,0,0,0, 8 | 109,97,105,110,0,0,0,0,5,0,5,0,9,0,0,0,102,114,111,110,116,67,111,108,111,117,114,0,5,0,4,0,11,0,0,0,99,111,108,111, 9 | 117,114,0,0,5,0,5,0,15,0,0,0,97,100,106,117,115,116,101,100,80,111,115,0,5,0,5,0,17,0,0,0,112,111,115,105,116,105,111,110, 10 | 0,0,0,0,5,0,5,0,19,0,0,0,80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,19,0,0,0,0,0,0,0,115,99,114,101, 11 | 101,110,66,111,117,110,100,115,0,0,0,0,6,0,7,0,19,0,0,0,1,0,0,0,103,114,97,100,105,101,110,116,73,110,102,111,0,0,0,0, 12 | 5,0,3,0,21,0,0,0,112,99,0,0,5,0,5,0,30,0,0,0,112,105,120,101,108,80,111,115,0,0,0,0,5,0,5,0,32,0,0,0, 13 | 115,99,97,108,101,100,80,111,115,0,0,0,5,0,6,0,41,0,0,0,103,108,95,80,101,114,86,101,114,116,101,120,0,0,0,0,6,0,6,0, 14 | 41,0,0,0,0,0,0,0,103,108,95,80,111,115,105,116,105,111,110,0,6,0,7,0,41,0,0,0,1,0,0,0,103,108,95,80,111,105,110,116, 15 | 83,105,122,101,0,0,0,0,6,0,7,0,41,0,0,0,2,0,0,0,103,108,95,67,108,105,112,68,105,115,116,97,110,99,101,0,6,0,7,0, 16 | 41,0,0,0,3,0,0,0,103,108,95,67,117,108,108,68,105,115,116,97,110,99,101,0,5,0,3,0,43,0,0,0,0,0,0,0,71,0,4,0, 17 | 9,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,11,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0,17,0,0,0,30,0,0,0, 18 | 0,0,0,0,72,0,5,0,19,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,72,0,5,0,19,0,0,0,1,0,0,0,35,0,0,0, 19 | 16,0,0,0,71,0,3,0,19,0,0,0,2,0,0,0,71,0,4,0,30,0,0,0,30,0,0,0,1,0,0,0,72,0,5,0,41,0,0,0, 20 | 0,0,0,0,11,0,0,0,0,0,0,0,72,0,5,0,41,0,0,0,1,0,0,0,11,0,0,0,1,0,0,0,72,0,5,0,41,0,0,0, 21 | 2,0,0,0,11,0,0,0,3,0,0,0,72,0,5,0,41,0,0,0,3,0,0,0,11,0,0,0,4,0,0,0,71,0,3,0,41,0,0,0, 22 | 2,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0,6,0,0,0,32,0,0,0,23,0,4,0, 23 | 7,0,0,0,6,0,0,0,4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0,59,0,4,0,8,0,0,0,9,0,0,0, 24 | 3,0,0,0,32,0,4,0,10,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,10,0,0,0,11,0,0,0,1,0,0,0,23,0,4,0, 25 | 13,0,0,0,6,0,0,0,2,0,0,0,32,0,4,0,14,0,0,0,7,0,0,0,13,0,0,0,32,0,4,0,16,0,0,0,1,0,0,0, 26 | 13,0,0,0,59,0,4,0,16,0,0,0,17,0,0,0,1,0,0,0,30,0,4,0,19,0,0,0,7,0,0,0,7,0,0,0,32,0,4,0, 27 | 20,0,0,0,9,0,0,0,19,0,0,0,59,0,4,0,20,0,0,0,21,0,0,0,9,0,0,0,21,0,4,0,22,0,0,0,32,0,0,0, 28 | 1,0,0,0,43,0,4,0,22,0,0,0,23,0,0,0,0,0,0,0,32,0,4,0,24,0,0,0,9,0,0,0,7,0,0,0,32,0,4,0, 29 | 29,0,0,0,3,0,0,0,13,0,0,0,59,0,4,0,29,0,0,0,30,0,0,0,3,0,0,0,21,0,4,0,38,0,0,0,32,0,0,0, 30 | 0,0,0,0,43,0,4,0,38,0,0,0,39,0,0,0,1,0,0,0,28,0,4,0,40,0,0,0,6,0,0,0,39,0,0,0,30,0,6,0, 31 | 41,0,0,0,7,0,0,0,6,0,0,0,40,0,0,0,40,0,0,0,32,0,4,0,42,0,0,0,3,0,0,0,41,0,0,0,59,0,4,0, 32 | 42,0,0,0,43,0,0,0,3,0,0,0,43,0,4,0,38,0,0,0,44,0,0,0,0,0,0,0,32,0,4,0,45,0,0,0,7,0,0,0, 33 | 6,0,0,0,43,0,4,0,6,0,0,0,48,0,0,0,0,0,128,63,43,0,4,0,6,0,0,0,53,0,0,0,0,0,0,0,54,0,5,0, 34 | 2,0,0,0,4,0,0,0,0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,14,0,0,0,15,0,0,0,7,0,0,0, 35 | 59,0,4,0,14,0,0,0,32,0,0,0,7,0,0,0,61,0,4,0,7,0,0,0,12,0,0,0,11,0,0,0,62,0,3,0,9,0,0,0, 36 | 12,0,0,0,61,0,4,0,13,0,0,0,18,0,0,0,17,0,0,0,65,0,5,0,24,0,0,0,25,0,0,0,21,0,0,0,23,0,0,0, 37 | 61,0,4,0,7,0,0,0,26,0,0,0,25,0,0,0,79,0,7,0,13,0,0,0,27,0,0,0,26,0,0,0,26,0,0,0,0,0,0,0, 38 | 1,0,0,0,131,0,5,0,13,0,0,0,28,0,0,0,18,0,0,0,27,0,0,0,62,0,3,0,15,0,0,0,28,0,0,0,61,0,4,0, 39 | 13,0,0,0,31,0,0,0,15,0,0,0,62,0,3,0,30,0,0,0,31,0,0,0,61,0,4,0,13,0,0,0,33,0,0,0,15,0,0,0, 40 | 65,0,5,0,24,0,0,0,34,0,0,0,21,0,0,0,23,0,0,0,61,0,4,0,7,0,0,0,35,0,0,0,34,0,0,0,79,0,7,0, 41 | 13,0,0,0,36,0,0,0,35,0,0,0,35,0,0,0,2,0,0,0,3,0,0,0,136,0,5,0,13,0,0,0,37,0,0,0,33,0,0,0, 42 | 36,0,0,0,62,0,3,0,32,0,0,0,37,0,0,0,65,0,5,0,45,0,0,0,46,0,0,0,32,0,0,0,44,0,0,0,61,0,4,0, 43 | 6,0,0,0,47,0,0,0,46,0,0,0,131,0,5,0,6,0,0,0,49,0,0,0,47,0,0,0,48,0,0,0,65,0,5,0,45,0,0,0, 44 | 50,0,0,0,32,0,0,0,39,0,0,0,61,0,4,0,6,0,0,0,51,0,0,0,50,0,0,0,131,0,5,0,6,0,0,0,52,0,0,0, 45 | 48,0,0,0,51,0,0,0,80,0,7,0,7,0,0,0,54,0,0,0,49,0,0,0,52,0,0,0,53,0,0,0,48,0,0,0,65,0,5,0, 46 | 8,0,0,0,55,0,0,0,43,0,0,0,23,0,0,0,62,0,3,0,55,0,0,0,54,0,0,0,253,0,1,0,56,0,1,0,0,0}; 47 | const int vertLinearGradientSize = 1716; 48 | 49 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_Overlay_frag.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t fragOverlay[] = {3,2,35,7,0,0,1,0,10,0,8,0,20,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,7,0,4,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,17,0,0,0,16,0,3,0,4,0,0,0,7,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0,4,0,9,0, 7 | 71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0,4,0,0,0, 8 | 109,97,105,110,0,0,0,0,5,0,5,0,9,0,0,0,111,117,116,67,111,108,111,114,0,0,0,0,5,0,6,0,13,0,0,0,105,109,97,103, 9 | 101,84,101,120,116,117,114,101,0,0,0,0,5,0,5,0,17,0,0,0,116,101,120,116,117,114,101,80,111,115,0,0,71,0,4,0,9,0,0,0, 10 | 30,0,0,0,0,0,0,0,71,0,4,0,13,0,0,0,34,0,0,0,0,0,0,0,71,0,4,0,13,0,0,0,33,0,0,0,0,0,0,0, 11 | 71,0,4,0,17,0,0,0,30,0,0,0,0,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0, 12 | 6,0,0,0,32,0,0,0,23,0,4,0,7,0,0,0,6,0,0,0,4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0, 13 | 59,0,4,0,8,0,0,0,9,0,0,0,3,0,0,0,25,0,9,0,10,0,0,0,6,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0, 14 | 0,0,0,0,1,0,0,0,0,0,0,0,27,0,3,0,11,0,0,0,10,0,0,0,32,0,4,0,12,0,0,0,0,0,0,0,11,0,0,0, 15 | 59,0,4,0,12,0,0,0,13,0,0,0,0,0,0,0,23,0,4,0,15,0,0,0,6,0,0,0,2,0,0,0,32,0,4,0,16,0,0,0, 16 | 1,0,0,0,15,0,0,0,59,0,4,0,16,0,0,0,17,0,0,0,1,0,0,0,54,0,5,0,2,0,0,0,4,0,0,0,0,0,0,0, 17 | 3,0,0,0,248,0,2,0,5,0,0,0,61,0,4,0,11,0,0,0,14,0,0,0,13,0,0,0,61,0,4,0,15,0,0,0,18,0,0,0, 18 | 17,0,0,0,87,0,5,0,7,0,0,0,19,0,0,0,14,0,0,0,18,0,0,0,62,0,3,0,9,0,0,0,19,0,0,0,253,0,1,0, 19 | 56,0,1,0,0,0}; 20 | const int fragOverlaySize = 604; 21 | 22 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_RadialGradient_frag.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t fragRadialGradient[] = {3,2,35,7,0,0,1,0,10,0,8,0,74,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,8,0,4,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,50,0,0,0,57,0,0,0,59,0,0,0,16,0,3,0,4,0,0,0,7,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0, 7 | 4,0,9,0,71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0, 8 | 4,0,0,0,109,97,105,110,0,0,0,0,5,0,5,0,10,0,0,0,116,114,97,110,115,102,111,114,109,0,0,0,5,0,5,0,15,0,0,0, 9 | 80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,15,0,0,0,0,0,0,0,115,99,114,101,101,110,66,111,117,110,100,115,0,0,0,0, 10 | 6,0,5,0,15,0,0,0,1,0,0,0,109,97,116,114,105,120,0,0,5,0,3,0,17,0,0,0,112,99,0,0,5,0,4,0,38,0,0,0, 11 | 111,102,102,115,101,116,0,0,5,0,5,0,47,0,0,0,103,114,97,100,105,101,110,116,80,111,115,0,5,0,5,0,50,0,0,0,112,105,120,101, 12 | 108,80,111,115,0,0,0,0,5,0,5,0,57,0,0,0,111,117,116,67,111,108,111,117,114,0,0,0,5,0,5,0,59,0,0,0,102,114,111,110, 13 | 116,67,111,108,111,117,114,0,5,0,6,0,67,0,0,0,103,114,97,100,105,101,110,116,84,101,120,116,117,114,101,0,71,0,4,0,14,0,0,0, 14 | 6,0,0,0,4,0,0,0,72,0,5,0,15,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,72,0,5,0,15,0,0,0,1,0,0,0, 15 | 35,0,0,0,16,0,0,0,71,0,3,0,15,0,0,0,2,0,0,0,71,0,4,0,50,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0, 16 | 57,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,59,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,67,0,0,0,34,0,0,0, 17 | 0,0,0,0,71,0,4,0,67,0,0,0,33,0,0,0,0,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0, 18 | 22,0,3,0,6,0,0,0,32,0,0,0,23,0,4,0,7,0,0,0,6,0,0,0,2,0,0,0,24,0,4,0,8,0,0,0,7,0,0,0, 19 | 2,0,0,0,32,0,4,0,9,0,0,0,7,0,0,0,8,0,0,0,23,0,4,0,11,0,0,0,6,0,0,0,4,0,0,0,21,0,4,0, 20 | 12,0,0,0,32,0,0,0,0,0,0,0,43,0,4,0,12,0,0,0,13,0,0,0,6,0,0,0,28,0,4,0,14,0,0,0,6,0,0,0, 21 | 13,0,0,0,30,0,4,0,15,0,0,0,11,0,0,0,14,0,0,0,32,0,4,0,16,0,0,0,9,0,0,0,15,0,0,0,59,0,4,0, 22 | 16,0,0,0,17,0,0,0,9,0,0,0,21,0,4,0,18,0,0,0,32,0,0,0,1,0,0,0,43,0,4,0,18,0,0,0,19,0,0,0, 23 | 1,0,0,0,43,0,4,0,18,0,0,0,20,0,0,0,0,0,0,0,32,0,4,0,21,0,0,0,9,0,0,0,6,0,0,0,43,0,4,0, 24 | 18,0,0,0,24,0,0,0,3,0,0,0,43,0,4,0,18,0,0,0,29,0,0,0,4,0,0,0,43,0,4,0,6,0,0,0,32,0,0,0, 25 | 0,0,128,63,43,0,4,0,6,0,0,0,33,0,0,0,0,0,0,0,32,0,4,0,37,0,0,0,7,0,0,0,7,0,0,0,43,0,4,0, 26 | 18,0,0,0,39,0,0,0,2,0,0,0,43,0,4,0,18,0,0,0,42,0,0,0,5,0,0,0,32,0,4,0,46,0,0,0,7,0,0,0, 27 | 6,0,0,0,32,0,4,0,49,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,49,0,0,0,50,0,0,0,1,0,0,0,32,0,4,0, 28 | 56,0,0,0,3,0,0,0,11,0,0,0,59,0,4,0,56,0,0,0,57,0,0,0,3,0,0,0,32,0,4,0,58,0,0,0,1,0,0,0, 29 | 11,0,0,0,59,0,4,0,58,0,0,0,59,0,0,0,1,0,0,0,43,0,4,0,12,0,0,0,60,0,0,0,3,0,0,0,32,0,4,0, 30 | 61,0,0,0,1,0,0,0,6,0,0,0,25,0,9,0,64,0,0,0,6,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 31 | 1,0,0,0,0,0,0,0,27,0,3,0,65,0,0,0,64,0,0,0,32,0,4,0,66,0,0,0,0,0,0,0,65,0,0,0,59,0,4,0, 32 | 66,0,0,0,67,0,0,0,0,0,0,0,43,0,4,0,6,0,0,0,70,0,0,0,0,0,0,63,54,0,5,0,2,0,0,0,4,0,0,0, 33 | 0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,9,0,0,0,10,0,0,0,7,0,0,0,59,0,4,0,37,0,0,0, 34 | 38,0,0,0,7,0,0,0,59,0,4,0,46,0,0,0,47,0,0,0,7,0,0,0,65,0,6,0,21,0,0,0,22,0,0,0,17,0,0,0, 35 | 19,0,0,0,20,0,0,0,61,0,4,0,6,0,0,0,23,0,0,0,22,0,0,0,65,0,6,0,21,0,0,0,25,0,0,0,17,0,0,0, 36 | 19,0,0,0,24,0,0,0,61,0,4,0,6,0,0,0,26,0,0,0,25,0,0,0,65,0,6,0,21,0,0,0,27,0,0,0,17,0,0,0, 37 | 19,0,0,0,19,0,0,0,61,0,4,0,6,0,0,0,28,0,0,0,27,0,0,0,65,0,6,0,21,0,0,0,30,0,0,0,17,0,0,0, 38 | 19,0,0,0,29,0,0,0,61,0,4,0,6,0,0,0,31,0,0,0,30,0,0,0,80,0,5,0,7,0,0,0,34,0,0,0,23,0,0,0, 39 | 26,0,0,0,80,0,5,0,7,0,0,0,35,0,0,0,28,0,0,0,31,0,0,0,80,0,5,0,8,0,0,0,36,0,0,0,34,0,0,0, 40 | 35,0,0,0,62,0,3,0,10,0,0,0,36,0,0,0,65,0,6,0,21,0,0,0,40,0,0,0,17,0,0,0,19,0,0,0,39,0,0,0, 41 | 61,0,4,0,6,0,0,0,41,0,0,0,40,0,0,0,65,0,6,0,21,0,0,0,43,0,0,0,17,0,0,0,19,0,0,0,42,0,0,0, 42 | 61,0,4,0,6,0,0,0,44,0,0,0,43,0,0,0,80,0,5,0,7,0,0,0,45,0,0,0,41,0,0,0,44,0,0,0,62,0,3,0, 43 | 38,0,0,0,45,0,0,0,61,0,4,0,8,0,0,0,48,0,0,0,10,0,0,0,61,0,4,0,7,0,0,0,51,0,0,0,50,0,0,0, 44 | 145,0,5,0,7,0,0,0,52,0,0,0,48,0,0,0,51,0,0,0,61,0,4,0,7,0,0,0,53,0,0,0,38,0,0,0,129,0,5,0, 45 | 7,0,0,0,54,0,0,0,52,0,0,0,53,0,0,0,12,0,6,0,6,0,0,0,55,0,0,0,1,0,0,0,66,0,0,0,54,0,0,0, 46 | 62,0,3,0,47,0,0,0,55,0,0,0,65,0,5,0,61,0,0,0,62,0,0,0,59,0,0,0,60,0,0,0,61,0,4,0,6,0,0,0, 47 | 63,0,0,0,62,0,0,0,61,0,4,0,65,0,0,0,68,0,0,0,67,0,0,0,61,0,4,0,6,0,0,0,69,0,0,0,47,0,0,0, 48 | 80,0,5,0,7,0,0,0,71,0,0,0,69,0,0,0,70,0,0,0,87,0,5,0,11,0,0,0,72,0,0,0,68,0,0,0,71,0,0,0, 49 | 142,0,5,0,11,0,0,0,73,0,0,0,72,0,0,0,63,0,0,0,62,0,3,0,57,0,0,0,73,0,0,0,253,0,1,0,56,0,1,0,0,0}; 50 | const int fragRadialGradientSize = 1840; 51 | 52 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_RadialGradient_vert.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t vertRadialGradient[] = {3,2,35,7,0,0,1,0,10,0,8,0,58,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,11,0,0,0,17,0,0,0,33,0,0,0,45,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0,4,0,9,0, 7 | 71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0,4,0,0,0, 8 | 109,97,105,110,0,0,0,0,5,0,5,0,9,0,0,0,102,114,111,110,116,67,111,108,111,117,114,0,5,0,4,0,11,0,0,0,99,111,108,111, 9 | 117,114,0,0,5,0,5,0,15,0,0,0,97,100,106,117,115,116,101,100,80,111,115,0,5,0,5,0,17,0,0,0,112,111,115,105,116,105,111,110, 10 | 0,0,0,0,5,0,5,0,22,0,0,0,80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,22,0,0,0,0,0,0,0,115,99,114,101, 11 | 101,110,66,111,117,110,100,115,0,0,0,0,6,0,5,0,22,0,0,0,1,0,0,0,109,97,116,114,105,120,0,0,5,0,3,0,24,0,0,0, 12 | 112,99,0,0,5,0,5,0,33,0,0,0,112,105,120,101,108,80,111,115,0,0,0,0,5,0,5,0,35,0,0,0,115,99,97,108,101,100,80,111, 13 | 115,0,0,0,5,0,6,0,43,0,0,0,103,108,95,80,101,114,86,101,114,116,101,120,0,0,0,0,6,0,6,0,43,0,0,0,0,0,0,0, 14 | 103,108,95,80,111,115,105,116,105,111,110,0,6,0,7,0,43,0,0,0,1,0,0,0,103,108,95,80,111,105,110,116,83,105,122,101,0,0,0,0, 15 | 6,0,7,0,43,0,0,0,2,0,0,0,103,108,95,67,108,105,112,68,105,115,116,97,110,99,101,0,6,0,7,0,43,0,0,0,3,0,0,0, 16 | 103,108,95,67,117,108,108,68,105,115,116,97,110,99,101,0,5,0,3,0,45,0,0,0,0,0,0,0,71,0,4,0,9,0,0,0,30,0,0,0, 17 | 0,0,0,0,71,0,4,0,11,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0,17,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0, 18 | 21,0,0,0,6,0,0,0,4,0,0,0,72,0,5,0,22,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,72,0,5,0,22,0,0,0, 19 | 1,0,0,0,35,0,0,0,16,0,0,0,71,0,3,0,22,0,0,0,2,0,0,0,71,0,4,0,33,0,0,0,30,0,0,0,1,0,0,0, 20 | 72,0,5,0,43,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,72,0,5,0,43,0,0,0,1,0,0,0,11,0,0,0,1,0,0,0, 21 | 72,0,5,0,43,0,0,0,2,0,0,0,11,0,0,0,3,0,0,0,72,0,5,0,43,0,0,0,3,0,0,0,11,0,0,0,4,0,0,0, 22 | 71,0,3,0,43,0,0,0,2,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0,6,0,0,0, 23 | 32,0,0,0,23,0,4,0,7,0,0,0,6,0,0,0,4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0,59,0,4,0, 24 | 8,0,0,0,9,0,0,0,3,0,0,0,32,0,4,0,10,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,10,0,0,0,11,0,0,0, 25 | 1,0,0,0,23,0,4,0,13,0,0,0,6,0,0,0,2,0,0,0,32,0,4,0,14,0,0,0,7,0,0,0,13,0,0,0,32,0,4,0, 26 | 16,0,0,0,1,0,0,0,13,0,0,0,59,0,4,0,16,0,0,0,17,0,0,0,1,0,0,0,21,0,4,0,19,0,0,0,32,0,0,0, 27 | 0,0,0,0,43,0,4,0,19,0,0,0,20,0,0,0,6,0,0,0,28,0,4,0,21,0,0,0,6,0,0,0,20,0,0,0,30,0,4,0, 28 | 22,0,0,0,7,0,0,0,21,0,0,0,32,0,4,0,23,0,0,0,9,0,0,0,22,0,0,0,59,0,4,0,23,0,0,0,24,0,0,0, 29 | 9,0,0,0,21,0,4,0,25,0,0,0,32,0,0,0,1,0,0,0,43,0,4,0,25,0,0,0,26,0,0,0,0,0,0,0,32,0,4,0, 30 | 27,0,0,0,9,0,0,0,7,0,0,0,32,0,4,0,32,0,0,0,3,0,0,0,13,0,0,0,59,0,4,0,32,0,0,0,33,0,0,0, 31 | 3,0,0,0,43,0,4,0,19,0,0,0,41,0,0,0,1,0,0,0,28,0,4,0,42,0,0,0,6,0,0,0,41,0,0,0,30,0,6,0, 32 | 43,0,0,0,7,0,0,0,6,0,0,0,42,0,0,0,42,0,0,0,32,0,4,0,44,0,0,0,3,0,0,0,43,0,0,0,59,0,4,0, 33 | 44,0,0,0,45,0,0,0,3,0,0,0,43,0,4,0,19,0,0,0,46,0,0,0,0,0,0,0,32,0,4,0,47,0,0,0,7,0,0,0, 34 | 6,0,0,0,43,0,4,0,6,0,0,0,50,0,0,0,0,0,128,63,43,0,4,0,6,0,0,0,55,0,0,0,0,0,0,0,54,0,5,0, 35 | 2,0,0,0,4,0,0,0,0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,14,0,0,0,15,0,0,0,7,0,0,0, 36 | 59,0,4,0,14,0,0,0,35,0,0,0,7,0,0,0,61,0,4,0,7,0,0,0,12,0,0,0,11,0,0,0,62,0,3,0,9,0,0,0, 37 | 12,0,0,0,61,0,4,0,13,0,0,0,18,0,0,0,17,0,0,0,65,0,5,0,27,0,0,0,28,0,0,0,24,0,0,0,26,0,0,0, 38 | 61,0,4,0,7,0,0,0,29,0,0,0,28,0,0,0,79,0,7,0,13,0,0,0,30,0,0,0,29,0,0,0,29,0,0,0,0,0,0,0, 39 | 1,0,0,0,131,0,5,0,13,0,0,0,31,0,0,0,18,0,0,0,30,0,0,0,62,0,3,0,15,0,0,0,31,0,0,0,61,0,4,0, 40 | 13,0,0,0,34,0,0,0,15,0,0,0,62,0,3,0,33,0,0,0,34,0,0,0,61,0,4,0,13,0,0,0,36,0,0,0,15,0,0,0, 41 | 65,0,5,0,27,0,0,0,37,0,0,0,24,0,0,0,26,0,0,0,61,0,4,0,7,0,0,0,38,0,0,0,37,0,0,0,79,0,7,0, 42 | 13,0,0,0,39,0,0,0,38,0,0,0,38,0,0,0,2,0,0,0,3,0,0,0,136,0,5,0,13,0,0,0,40,0,0,0,36,0,0,0, 43 | 39,0,0,0,62,0,3,0,35,0,0,0,40,0,0,0,65,0,5,0,47,0,0,0,48,0,0,0,35,0,0,0,46,0,0,0,61,0,4,0, 44 | 6,0,0,0,49,0,0,0,48,0,0,0,131,0,5,0,6,0,0,0,51,0,0,0,49,0,0,0,50,0,0,0,65,0,5,0,47,0,0,0, 45 | 52,0,0,0,35,0,0,0,41,0,0,0,61,0,4,0,6,0,0,0,53,0,0,0,52,0,0,0,131,0,5,0,6,0,0,0,54,0,0,0, 46 | 50,0,0,0,53,0,0,0,80,0,7,0,7,0,0,0,56,0,0,0,51,0,0,0,54,0,0,0,55,0,0,0,50,0,0,0,65,0,5,0, 47 | 8,0,0,0,57,0,0,0,45,0,0,0,26,0,0,0,62,0,3,0,57,0,0,0,56,0,0,0,253,0,1,0,56,0,1,0,0,0}; 48 | const int vertRadialGradientSize = 1756; 49 | 50 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_SolidColour_frag.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t fragSolidColour[] = {3,2,35,7,0,0,1,0,10,0,8,0,13,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,7,0,4,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,11,0,0,0,16,0,3,0,4,0,0,0,7,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0,4,0,9,0, 7 | 71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0,4,0,0,0, 8 | 109,97,105,110,0,0,0,0,5,0,5,0,9,0,0,0,111,117,116,67,111,108,111,117,114,0,0,0,5,0,5,0,11,0,0,0,102,114,111,110, 9 | 116,67,111,108,111,117,114,0,71,0,4,0,9,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,11,0,0,0,30,0,0,0,0,0,0,0, 10 | 19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0,6,0,0,0,32,0,0,0,23,0,4,0,7,0,0,0, 11 | 6,0,0,0,4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0,59,0,4,0,8,0,0,0,9,0,0,0,3,0,0,0, 12 | 32,0,4,0,10,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,10,0,0,0,11,0,0,0,1,0,0,0,54,0,5,0,2,0,0,0, 13 | 4,0,0,0,0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,61,0,4,0,7,0,0,0,12,0,0,0,11,0,0,0,62,0,3,0, 14 | 9,0,0,0,12,0,0,0,253,0,1,0,56,0,1,0,0,0}; 15 | const int fragSolidColourSize = 416; 16 | 17 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_SolidColour_vert.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t vertSolidColour[] = {3,2,35,7,0,0,1,0,10,0,8,0,53,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,9,0,0,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,11,0,0,0,17,0,0,0,40,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0,4,0,9,0,71,76,95,65, 7 | 82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0,4,0,0,0,109,97,105,110, 8 | 0,0,0,0,5,0,5,0,9,0,0,0,102,114,111,110,116,67,111,108,111,117,114,0,5,0,4,0,11,0,0,0,99,111,108,111,117,114,0,0, 9 | 5,0,5,0,15,0,0,0,97,100,106,117,115,116,101,100,80,111,115,0,5,0,5,0,17,0,0,0,112,111,115,105,116,105,111,110,0,0,0,0, 10 | 5,0,5,0,19,0,0,0,80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,19,0,0,0,0,0,0,0,115,99,114,101,101,110,66,111, 11 | 117,110,100,115,0,0,0,0,5,0,3,0,21,0,0,0,112,99,0,0,5,0,5,0,29,0,0,0,115,99,97,108,101,100,80,111,115,0,0,0, 12 | 5,0,6,0,38,0,0,0,103,108,95,80,101,114,86,101,114,116,101,120,0,0,0,0,6,0,6,0,38,0,0,0,0,0,0,0,103,108,95,80, 13 | 111,115,105,116,105,111,110,0,6,0,7,0,38,0,0,0,1,0,0,0,103,108,95,80,111,105,110,116,83,105,122,101,0,0,0,0,6,0,7,0, 14 | 38,0,0,0,2,0,0,0,103,108,95,67,108,105,112,68,105,115,116,97,110,99,101,0,6,0,7,0,38,0,0,0,3,0,0,0,103,108,95,67, 15 | 117,108,108,68,105,115,116,97,110,99,101,0,5,0,3,0,40,0,0,0,0,0,0,0,71,0,4,0,9,0,0,0,30,0,0,0,0,0,0,0, 16 | 71,0,4,0,11,0,0,0,30,0,0,0,1,0,0,0,71,0,4,0,17,0,0,0,30,0,0,0,0,0,0,0,72,0,5,0,19,0,0,0, 17 | 0,0,0,0,35,0,0,0,0,0,0,0,71,0,3,0,19,0,0,0,2,0,0,0,72,0,5,0,38,0,0,0,0,0,0,0,11,0,0,0, 18 | 0,0,0,0,72,0,5,0,38,0,0,0,1,0,0,0,11,0,0,0,1,0,0,0,72,0,5,0,38,0,0,0,2,0,0,0,11,0,0,0, 19 | 3,0,0,0,72,0,5,0,38,0,0,0,3,0,0,0,11,0,0,0,4,0,0,0,71,0,3,0,38,0,0,0,2,0,0,0,19,0,2,0, 20 | 2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0,6,0,0,0,32,0,0,0,23,0,4,0,7,0,0,0,6,0,0,0, 21 | 4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0,59,0,4,0,8,0,0,0,9,0,0,0,3,0,0,0,32,0,4,0, 22 | 10,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,10,0,0,0,11,0,0,0,1,0,0,0,23,0,4,0,13,0,0,0,6,0,0,0, 23 | 2,0,0,0,32,0,4,0,14,0,0,0,7,0,0,0,13,0,0,0,32,0,4,0,16,0,0,0,1,0,0,0,13,0,0,0,59,0,4,0, 24 | 16,0,0,0,17,0,0,0,1,0,0,0,30,0,3,0,19,0,0,0,7,0,0,0,32,0,4,0,20,0,0,0,9,0,0,0,19,0,0,0, 25 | 59,0,4,0,20,0,0,0,21,0,0,0,9,0,0,0,21,0,4,0,22,0,0,0,32,0,0,0,1,0,0,0,43,0,4,0,22,0,0,0, 26 | 23,0,0,0,0,0,0,0,32,0,4,0,24,0,0,0,9,0,0,0,7,0,0,0,21,0,4,0,35,0,0,0,32,0,0,0,0,0,0,0, 27 | 43,0,4,0,35,0,0,0,36,0,0,0,1,0,0,0,28,0,4,0,37,0,0,0,6,0,0,0,36,0,0,0,30,0,6,0,38,0,0,0, 28 | 7,0,0,0,6,0,0,0,37,0,0,0,37,0,0,0,32,0,4,0,39,0,0,0,3,0,0,0,38,0,0,0,59,0,4,0,39,0,0,0, 29 | 40,0,0,0,3,0,0,0,43,0,4,0,35,0,0,0,41,0,0,0,0,0,0,0,32,0,4,0,42,0,0,0,7,0,0,0,6,0,0,0, 30 | 43,0,4,0,6,0,0,0,45,0,0,0,0,0,128,63,43,0,4,0,6,0,0,0,50,0,0,0,0,0,0,0,54,0,5,0,2,0,0,0, 31 | 4,0,0,0,0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,14,0,0,0,15,0,0,0,7,0,0,0,59,0,4,0, 32 | 14,0,0,0,29,0,0,0,7,0,0,0,61,0,4,0,7,0,0,0,12,0,0,0,11,0,0,0,62,0,3,0,9,0,0,0,12,0,0,0, 33 | 61,0,4,0,13,0,0,0,18,0,0,0,17,0,0,0,65,0,5,0,24,0,0,0,25,0,0,0,21,0,0,0,23,0,0,0,61,0,4,0, 34 | 7,0,0,0,26,0,0,0,25,0,0,0,79,0,7,0,13,0,0,0,27,0,0,0,26,0,0,0,26,0,0,0,0,0,0,0,1,0,0,0, 35 | 131,0,5,0,13,0,0,0,28,0,0,0,18,0,0,0,27,0,0,0,62,0,3,0,15,0,0,0,28,0,0,0,61,0,4,0,13,0,0,0, 36 | 30,0,0,0,15,0,0,0,65,0,5,0,24,0,0,0,31,0,0,0,21,0,0,0,23,0,0,0,61,0,4,0,7,0,0,0,32,0,0,0, 37 | 31,0,0,0,79,0,7,0,13,0,0,0,33,0,0,0,32,0,0,0,32,0,0,0,2,0,0,0,3,0,0,0,136,0,5,0,13,0,0,0, 38 | 34,0,0,0,30,0,0,0,33,0,0,0,62,0,3,0,29,0,0,0,34,0,0,0,65,0,5,0,42,0,0,0,43,0,0,0,29,0,0,0, 39 | 41,0,0,0,61,0,4,0,6,0,0,0,44,0,0,0,43,0,0,0,131,0,5,0,6,0,0,0,46,0,0,0,44,0,0,0,45,0,0,0, 40 | 65,0,5,0,42,0,0,0,47,0,0,0,29,0,0,0,36,0,0,0,61,0,4,0,6,0,0,0,48,0,0,0,47,0,0,0,131,0,5,0, 41 | 6,0,0,0,49,0,0,0,45,0,0,0,48,0,0,0,80,0,7,0,7,0,0,0,51,0,0,0,46,0,0,0,49,0,0,0,50,0,0,0, 42 | 45,0,0,0,65,0,5,0,8,0,0,0,52,0,0,0,40,0,0,0,23,0,0,0,62,0,3,0,52,0,0,0,51,0,0,0,253,0,1,0, 43 | 56,0,1,0,0,0}; 44 | const int vertSolidColourSize = 1564; 45 | 46 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/contexts/spv/pw_TiledImage_vert.cpp: -------------------------------------------------------------------------------- 1 | namespace parawave 2 | { 3 | 4 | static const uint8_t vertTiledImage[] = {3,2,35,7,0,0,1,0,10,0,8,0,58,0,0,0,0,0,0,0,17,0,2,0,1,0,0,0,11,0,6,0,1,0,0,0,71,76,83,76, 5 | 46,115,116,100,46,52,53,48,0,0,0,0,14,0,3,0,0,0,0,0,1,0,0,0,15,0,10,0,0,0,0,0,4,0,0,0,109,97,105,110, 6 | 0,0,0,0,9,0,0,0,11,0,0,0,17,0,0,0,33,0,0,0,45,0,0,0,3,0,3,0,2,0,0,0,194,1,0,0,4,0,9,0, 7 | 71,76,95,65,82,66,95,115,101,112,97,114,97,116,101,95,115,104,97,100,101,114,95,111,98,106,101,99,116,115,0,0,5,0,4,0,4,0,0,0, 8 | 109,97,105,110,0,0,0,0,5,0,5,0,9,0,0,0,102,114,111,110,116,67,111,108,111,117,114,0,5,0,4,0,11,0,0,0,99,111,108,111, 9 | 117,114,0,0,5,0,5,0,15,0,0,0,97,100,106,117,115,116,101,100,80,111,115,0,5,0,5,0,17,0,0,0,112,111,115,105,116,105,111,110, 10 | 0,0,0,0,5,0,5,0,22,0,0,0,80,117,115,104,67,111,110,115,116,115,0,0,6,0,7,0,22,0,0,0,0,0,0,0,115,99,114,101, 11 | 101,110,66,111,117,110,100,115,0,0,0,0,6,0,6,0,22,0,0,0,1,0,0,0,105,109,97,103,101,76,105,109,105,116,115,0,6,0,5,0, 12 | 22,0,0,0,2,0,0,0,109,97,116,114,105,120,0,0,5,0,3,0,24,0,0,0,112,99,0,0,5,0,5,0,33,0,0,0,112,105,120,101, 13 | 108,80,111,115,0,0,0,0,5,0,5,0,35,0,0,0,115,99,97,108,101,100,80,111,115,0,0,0,5,0,6,0,43,0,0,0,103,108,95,80, 14 | 101,114,86,101,114,116,101,120,0,0,0,0,6,0,6,0,43,0,0,0,0,0,0,0,103,108,95,80,111,115,105,116,105,111,110,0,6,0,7,0, 15 | 43,0,0,0,1,0,0,0,103,108,95,80,111,105,110,116,83,105,122,101,0,0,0,0,6,0,7,0,43,0,0,0,2,0,0,0,103,108,95,67, 16 | 108,105,112,68,105,115,116,97,110,99,101,0,6,0,7,0,43,0,0,0,3,0,0,0,103,108,95,67,117,108,108,68,105,115,116,97,110,99,101,0, 17 | 5,0,3,0,45,0,0,0,0,0,0,0,71,0,4,0,9,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,11,0,0,0,30,0,0,0, 18 | 1,0,0,0,71,0,4,0,17,0,0,0,30,0,0,0,0,0,0,0,71,0,4,0,21,0,0,0,6,0,0,0,4,0,0,0,72,0,5,0, 19 | 22,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,72,0,5,0,22,0,0,0,1,0,0,0,35,0,0,0,16,0,0,0,72,0,5,0, 20 | 22,0,0,0,2,0,0,0,35,0,0,0,24,0,0,0,71,0,3,0,22,0,0,0,2,0,0,0,71,0,4,0,33,0,0,0,30,0,0,0, 21 | 1,0,0,0,72,0,5,0,43,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,72,0,5,0,43,0,0,0,1,0,0,0,11,0,0,0, 22 | 1,0,0,0,72,0,5,0,43,0,0,0,2,0,0,0,11,0,0,0,3,0,0,0,72,0,5,0,43,0,0,0,3,0,0,0,11,0,0,0, 23 | 4,0,0,0,71,0,3,0,43,0,0,0,2,0,0,0,19,0,2,0,2,0,0,0,33,0,3,0,3,0,0,0,2,0,0,0,22,0,3,0, 24 | 6,0,0,0,32,0,0,0,23,0,4,0,7,0,0,0,6,0,0,0,4,0,0,0,32,0,4,0,8,0,0,0,3,0,0,0,7,0,0,0, 25 | 59,0,4,0,8,0,0,0,9,0,0,0,3,0,0,0,32,0,4,0,10,0,0,0,1,0,0,0,7,0,0,0,59,0,4,0,10,0,0,0, 26 | 11,0,0,0,1,0,0,0,23,0,4,0,13,0,0,0,6,0,0,0,2,0,0,0,32,0,4,0,14,0,0,0,7,0,0,0,13,0,0,0, 27 | 32,0,4,0,16,0,0,0,1,0,0,0,13,0,0,0,59,0,4,0,16,0,0,0,17,0,0,0,1,0,0,0,21,0,4,0,19,0,0,0, 28 | 32,0,0,0,0,0,0,0,43,0,4,0,19,0,0,0,20,0,0,0,6,0,0,0,28,0,4,0,21,0,0,0,6,0,0,0,20,0,0,0, 29 | 30,0,5,0,22,0,0,0,7,0,0,0,13,0,0,0,21,0,0,0,32,0,4,0,23,0,0,0,9,0,0,0,22,0,0,0,59,0,4,0, 30 | 23,0,0,0,24,0,0,0,9,0,0,0,21,0,4,0,25,0,0,0,32,0,0,0,1,0,0,0,43,0,4,0,25,0,0,0,26,0,0,0, 31 | 0,0,0,0,32,0,4,0,27,0,0,0,9,0,0,0,7,0,0,0,32,0,4,0,32,0,0,0,3,0,0,0,13,0,0,0,59,0,4,0, 32 | 32,0,0,0,33,0,0,0,3,0,0,0,43,0,4,0,19,0,0,0,41,0,0,0,1,0,0,0,28,0,4,0,42,0,0,0,6,0,0,0, 33 | 41,0,0,0,30,0,6,0,43,0,0,0,7,0,0,0,6,0,0,0,42,0,0,0,42,0,0,0,32,0,4,0,44,0,0,0,3,0,0,0, 34 | 43,0,0,0,59,0,4,0,44,0,0,0,45,0,0,0,3,0,0,0,43,0,4,0,19,0,0,0,46,0,0,0,0,0,0,0,32,0,4,0, 35 | 47,0,0,0,7,0,0,0,6,0,0,0,43,0,4,0,6,0,0,0,50,0,0,0,0,0,128,63,43,0,4,0,6,0,0,0,55,0,0,0, 36 | 0,0,0,0,54,0,5,0,2,0,0,0,4,0,0,0,0,0,0,0,3,0,0,0,248,0,2,0,5,0,0,0,59,0,4,0,14,0,0,0, 37 | 15,0,0,0,7,0,0,0,59,0,4,0,14,0,0,0,35,0,0,0,7,0,0,0,61,0,4,0,7,0,0,0,12,0,0,0,11,0,0,0, 38 | 62,0,3,0,9,0,0,0,12,0,0,0,61,0,4,0,13,0,0,0,18,0,0,0,17,0,0,0,65,0,5,0,27,0,0,0,28,0,0,0, 39 | 24,0,0,0,26,0,0,0,61,0,4,0,7,0,0,0,29,0,0,0,28,0,0,0,79,0,7,0,13,0,0,0,30,0,0,0,29,0,0,0, 40 | 29,0,0,0,0,0,0,0,1,0,0,0,131,0,5,0,13,0,0,0,31,0,0,0,18,0,0,0,30,0,0,0,62,0,3,0,15,0,0,0, 41 | 31,0,0,0,61,0,4,0,13,0,0,0,34,0,0,0,15,0,0,0,62,0,3,0,33,0,0,0,34,0,0,0,61,0,4,0,13,0,0,0, 42 | 36,0,0,0,15,0,0,0,65,0,5,0,27,0,0,0,37,0,0,0,24,0,0,0,26,0,0,0,61,0,4,0,7,0,0,0,38,0,0,0, 43 | 37,0,0,0,79,0,7,0,13,0,0,0,39,0,0,0,38,0,0,0,38,0,0,0,2,0,0,0,3,0,0,0,136,0,5,0,13,0,0,0, 44 | 40,0,0,0,36,0,0,0,39,0,0,0,62,0,3,0,35,0,0,0,40,0,0,0,65,0,5,0,47,0,0,0,48,0,0,0,35,0,0,0, 45 | 46,0,0,0,61,0,4,0,6,0,0,0,49,0,0,0,48,0,0,0,131,0,5,0,6,0,0,0,51,0,0,0,49,0,0,0,50,0,0,0, 46 | 65,0,5,0,47,0,0,0,52,0,0,0,35,0,0,0,41,0,0,0,61,0,4,0,6,0,0,0,53,0,0,0,52,0,0,0,131,0,5,0, 47 | 6,0,0,0,54,0,0,0,50,0,0,0,53,0,0,0,80,0,7,0,7,0,0,0,56,0,0,0,51,0,0,0,54,0,0,0,55,0,0,0, 48 | 50,0,0,0,65,0,5,0,8,0,0,0,57,0,0,0,45,0,0,0,26,0,0,0,62,0,3,0,57,0,0,0,56,0,0,0,253,0,1,0, 49 | 56,0,1,0,0,0}; 50 | const int vertTiledImageSize = 1804; 51 | 52 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/pw_vulkan_graphics.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #include 27 | 28 | #undef max 29 | #undef min 30 | 31 | /******************************************************************************* 32 | pw_vulkan 33 | *******************************************************************************/ 34 | #include "pw_vulkan_graphics.h" 35 | 36 | /** Define the type identifier of the VulkanImageType. Change this number in case of 37 | conflicts with other juce::ImageType implementations that use the same id. */ 38 | #ifndef PW_VULKAN_IMAGE_TYPE_ID 39 | #define PW_VULKAN_IMAGE_TYPE_ID 4 40 | #endif 41 | 42 | //============================================================================== 43 | 44 | namespace parawave 45 | { 46 | class VulkanPixelData; 47 | class RenderLayer; 48 | 49 | } // namespace parawave 50 | 51 | //============================================================================== 52 | 53 | // Compiled Binary SPV Shaders 54 | #include "contexts/spv/pw_Basic_vert.cpp" 55 | #include "contexts/spv/pw_Image_frag.cpp" 56 | #include "contexts/spv/pw_Image_vert.cpp" 57 | #include "contexts/spv/pw_LinearGradient_vert.cpp" 58 | #include "contexts/spv/pw_LinearGradient1_frag.cpp" 59 | #include "contexts/spv/pw_LinearGradient2_frag.cpp" 60 | #include "contexts/spv/pw_Overlay_frag.cpp" 61 | #include "contexts/spv/pw_Overlay_vert.cpp" 62 | #include "contexts/spv/pw_RadialGradient_frag.cpp" 63 | #include "contexts/spv/pw_RadialGradient_vert.cpp" 64 | #include "contexts/spv/pw_SolidColour_frag.cpp" 65 | #include "contexts/spv/pw_SolidColour_vert.cpp" 66 | #include "contexts/spv/pw_TiledImage_frag.cpp" 67 | #include "contexts/spv/pw_TiledImage_vert.cpp" 68 | 69 | //============================================================================== 70 | 71 | #include "contexts/caches/pw_CachedShaders.cpp" 72 | #include "contexts/caches/pw_CachedMemory.cpp" 73 | #include "contexts/caches/pw_CachedImages.cpp" 74 | #include "contexts/caches/pw_CachedRenderPasses.cpp" 75 | 76 | #include "contexts/shaders/pw_ProgramHelpers.cpp" 77 | #include "contexts/shaders/pw_ImageProgram.cpp" 78 | #include "contexts/shaders/pw_LinearGradientProgram.cpp" 79 | #include "contexts/shaders/pw_OverlayProgram.cpp" 80 | #include "contexts/shaders/pw_RadialGradientProgram.cpp" 81 | #include "contexts/shaders/pw_SolidColourProgram.cpp" 82 | #include "contexts/shaders/pw_TiledImageProgram.cpp" 83 | 84 | #include "contexts/caches/pw_CachedPipelines.cpp" 85 | 86 | #include "contexts/pw_DeviceState.cpp" 87 | #include "contexts/pw_VulkanRenderer.cpp" 88 | 89 | #include "contexts/renderer/pw_RenderHelpers.cpp" 90 | #include "contexts/renderer/pw_RenderBase.cpp" 91 | #include "contexts/renderer/pw_RenderFrame.cpp" 92 | #include "contexts/renderer/pw_RenderLayer.cpp" 93 | 94 | #include "contexts/pw_FrameState.cpp" 95 | #include "contexts/pw_OverlayState.cpp" 96 | #include "contexts/pw_RenderContext.cpp" 97 | 98 | #include "contexts/pw_VulkanGraphicsContext.cpp" 99 | #include "contexts/pw_VulkanContext.cpp" 100 | 101 | #include "utils/pw_VulkanImageType.cpp" 102 | #include "utils/pw_VulkanAppComponent.cpp" 103 | -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/pw_vulkan_graphics.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | /******************************************************************************* 27 | 28 | BEGIN_JUCE_MODULE_DECLARATION 29 | 30 | ID: pw_vulkan_graphics 31 | vendor: Parawave 32 | version: 0.5.0 33 | name: Parawave - Vulkan Graphics 34 | description: Vulkan Graphics Context for Component drawing. 35 | website: https://parawave-audio.com/vulkan-cpp-library 36 | license: ISC 37 | 38 | dependencies: juce_core juce_data_structures juce_events juce_graphics juce_gui_basics pw_vulkan 39 | 40 | END_JUCE_MODULE_DECLARATION 41 | 42 | *******************************************************************************/ 43 | 44 | #pragma once 45 | 46 | /******************************************************************************* 47 | JUCE SDK 48 | *******************************************************************************/ 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | /******************************************************************************* 56 | Parawave 57 | *******************************************************************************/ 58 | #include 59 | 60 | /******************************************************************************* 61 | pw_vulkan_graphics 62 | *******************************************************************************/ 63 | namespace parawave 64 | { 65 | class VulkanContext; 66 | class VulkanImageType; 67 | class VulkanAppComponent; 68 | } // namespace parawave 69 | 70 | //============================================================================== 71 | 72 | #include "contexts/pw_VulkanContext.h" 73 | 74 | #include "utils/pw_VulkanUniform.h" 75 | #include "utils/pw_VulkanIndexBuffer.h" 76 | #include "utils/pw_VulkanImageType.h" 77 | #include "utils/pw_VulkanTexture.h" 78 | #include "utils/pw_VulkanAppComponent.h" -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/utils/pw_VulkanAppComponent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | namespace parawave 27 | { 28 | 29 | VulkanAppComponent::VulkanAppComponent() 30 | { 31 | setOpaque(true); 32 | 33 | for (auto& device : instance.getPhysicalDevices()) 34 | { 35 | PW_DBG_V(device->getName() + " : " + device->getDeviceTypeName()); 36 | juce::ignoreUnused(device); 37 | } 38 | 39 | context.setDefaultPhysicalDevice(instance); 40 | context.attachTo(*this); 41 | } 42 | 43 | VulkanAppComponent::~VulkanAppComponent() 44 | { 45 | // Before your subclass's destructor has completed, you must call 46 | // shutdownVulkan() to release the Vulkan context. (Otherwise there's 47 | // a danger that it may invoke a Vulkan callback on your class while 48 | // it's in the process of being deleted. 49 | jassert(!context.isAttached()); 50 | 51 | shutdownVulkan(); 52 | } 53 | 54 | void VulkanAppComponent::shutdownVulkan() 55 | { 56 | context.detach(); 57 | } 58 | 59 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/utils/pw_VulkanAppComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | class VulkanAppComponent : public juce::Component 33 | { 34 | public: 35 | VulkanAppComponent(); 36 | ~VulkanAppComponent() override; 37 | 38 | void shutdownVulkan(); 39 | 40 | private: 41 | VulkanInstance instance; 42 | 43 | protected: 44 | VulkanContext context; 45 | 46 | private: 47 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanAppComponent) 48 | }; 49 | 50 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/utils/pw_VulkanImageType.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | class VulkanImageType : public juce::ImageType 33 | { 34 | private: 35 | VulkanImageType() = delete; 36 | 37 | public: 38 | explicit VulkanImageType(const VulkanContext& context); 39 | ~VulkanImageType() override; 40 | 41 | juce::ImagePixelData::Ptr create(juce::Image::PixelFormat, int width, int height, bool shouldClearImage) const override; 42 | 43 | int getTypeID() const override; 44 | 45 | const VulkanContext& context; 46 | }; 47 | 48 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/utils/pw_VulkanIndexBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | //============================================================================== 31 | /** Helper class to generate static index buffer arrays. */ 32 | template 33 | class VulkanIndexBuffer final 34 | { 35 | public: 36 | static void fillQuadrilateralIndices(IndexType* indices, IndexType numIndices) 37 | { 38 | constexpr auto indicesPerQuad = 6; 39 | constexpr auto verticesPerQuad = 4; 40 | 41 | // [0 1 2 1 2 3] 42 | for (IndexType i = 0, v = 0; i < numIndices; i += indicesPerQuad, v += verticesPerQuad) 43 | { 44 | indices[i] = static_cast(v); 45 | indices[i + 1] = indices[i + 3] = static_cast(v + 1); 46 | indices[i + 2] = indices[i + 4] = static_cast(v + 2); 47 | indices[i + 5] = static_cast(v + 3); 48 | } 49 | } 50 | 51 | /** Generates indices for quad drawing. The supplied destination buffer must be device local. 52 | A staging buffer will be used to transfer the generated indices.*/ 53 | static void generateQuadrilateralIndices(const VulkanMemoryBuffer& dest, const VulkanDevice& device, VulkanMemoryPool& pool, IndexType numIndices) 54 | { 55 | juce::HeapBlock indices(numIndices); 56 | 57 | auto data = indices.getData(); 58 | const auto dataSize = static_cast(numIndices * sizeof(IndexType)); 59 | 60 | fillQuadrilateralIndices(data, numIndices); 61 | writeWithStagingBuffer(dest, device, pool, data, dataSize); 62 | } 63 | 64 | static void writeWithStagingBuffer(const VulkanMemoryBuffer& dest, const VulkanDevice& device, VulkanMemoryPool& pool, const void* dataSrc, size_t dataSrcSize) 65 | { 66 | const auto sourceSize = static_cast(dataSrcSize); 67 | 68 | const VulkanMemoryBuffer stagingBuffer(pool, VulkanMemoryBuffer::CreateInfo(sourceSize).setHostVisible().setTransferSrc()); 69 | stagingBuffer.write(dataSrc, dataSrcSize); 70 | 71 | VulkanBufferTransfer transfer(device, dest.getBuffer(), stagingBuffer.getBuffer()); 72 | 73 | transfer.writeToBuffer(); 74 | transfer.waitForFence(); 75 | } 76 | }; 77 | 78 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/utils/pw_VulkanTexture.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | class VulkanTexture final : public juce::ReferenceCountedObject 33 | { 34 | public: 35 | using Ptr = juce::ReferenceCountedObjectPtr; 36 | 37 | private: 38 | VulkanTexture() = delete; 39 | 40 | public: 41 | VulkanTexture(const VulkanDevice& device, VulkanMemoryPool& memoryPool, uint32_t width_, uint32_t height_) : 42 | width(width_), height(height_), 43 | memoryImage(memoryPool, VulkanMemoryImage::CreateInfo(width, height, vk::Format::eB8G8R8A8Unorm) 44 | .setDeviceLocal().setSampled().setTransferDst()), 45 | imageView(device, memoryImage.getImage()) 46 | { 47 | //DBG("[Vulkan] Created cached image of size " << juce::String(width) << " x " << juce::String(height) << "."); 48 | } 49 | 50 | ~VulkanTexture() 51 | { 52 | //DBG("[Vulkan] Remove cached image of size " << juce::String(width) << " x " << juce::String(height) << "."); 53 | } 54 | 55 | const VulkanMemoryImage& getMemory() const noexcept { return memoryImage; } 56 | 57 | const VulkanImageView& getImageView() const noexcept { return imageView; } 58 | 59 | juce::Time getLastUsedTime() const noexcept { return lastUsed; } 60 | 61 | void setLastUsedTime(juce::Time newTime = juce::Time::getCurrentTime()) noexcept { lastUsed = newTime; } 62 | 63 | uint32_t getWidth() const noexcept { return width; } 64 | uint32_t getHeight() const noexcept { return height; } 65 | 66 | float getWidthProportion() const noexcept { return static_cast(width) / static_cast(memoryImage.getImage().getExtent().width); } 67 | float getHeightProportion() const noexcept { return static_cast(height) / static_cast(memoryImage.getImage().getExtent().height); } 68 | 69 | static VulkanTexture::Ptr get(const juce::Graphics& g, const juce::Image& image); 70 | 71 | private: 72 | const uint32_t width; 73 | const uint32_t height; 74 | 75 | const VulkanMemoryImage memoryImage; 76 | const VulkanImageView imageView; 77 | 78 | juce::Time lastUsed; 79 | 80 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VulkanTexture) 81 | }; 82 | 83 | //============================================================================== 84 | 85 | } // namespace parawave -------------------------------------------------------------------------------- /modules/pw_vulkan_graphics/utils/pw_VulkanUniform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | This file is part of the Parawave Vulkan C++ library. 5 | 6 | The code included in this file is provided under the terms of the ISC license 7 | https://opensource.org/licenses/ISC. 8 | 9 | Copyright (c) 2021 - Parawave Audio (https://parawave-audio.com/vulkan-cpp-library) 10 | 11 | Permission to use, copy, modify, and/or distribute this software for any 12 | purpose with or without fee is hereby granted, provided that the above 13 | copyright notice and this permission notice appear in all copies. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 16 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 19 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 20 | OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 21 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 22 | 23 | ============================================================================== 24 | */ 25 | 26 | #pragma once 27 | 28 | namespace parawave 29 | { 30 | 31 | //============================================================================== 32 | /** 33 | VulkanUniform 34 | 35 | Useful shader uniform or push constants structures. 36 | */ 37 | class VulkanUniform final 38 | { 39 | public: 40 | //============================================================================== 41 | struct ScreenBounds 42 | { 43 | float values[4]; 44 | 45 | void set(const juce::Rectangle& bounds) noexcept 46 | { 47 | values[0] = bounds.getX(); 48 | values[1] = bounds.getY(); 49 | values[2] = 0.5f * bounds.getWidth(); 50 | values[3] = 0.5f * bounds.getHeight(); 51 | } 52 | }; 53 | 54 | //============================================================================== 55 | struct Matrix 56 | { 57 | float values[6]; 58 | 59 | void set(juce::AffineTransform t) noexcept 60 | { 61 | values[0] = t.mat00; values[1] = t.mat01; values[2] = t.mat02; 62 | values[3] = t.mat10; values[4] = t.mat11; values[5] = t.mat12; 63 | } 64 | 65 | void setIdentity() noexcept 66 | { 67 | set(juce::AffineTransform()); 68 | } 69 | }; 70 | 71 | //============================================================================== 72 | struct Colour 73 | { 74 | float values[4]; 75 | 76 | void set(const juce::Colour colour) noexcept 77 | { 78 | values[0] = colour.getFloatRed(); 79 | values[1] = colour.getFloatGreen(); 80 | values[2] = colour.getFloatBlue(); 81 | values[3] = colour.getFloatAlpha(); 82 | } 83 | 84 | void set(juce::PixelARGB colour) noexcept 85 | { 86 | set(juce::Colour(colour)); 87 | } 88 | }; 89 | }; 90 | 91 | } // namespace parawave 92 | --------------------------------------------------------------------------------