remove vulkanlearn
This commit is contained in:
parent
7a046726c7
commit
26a229f20e
@ -1,205 +0,0 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright( c ) 2017 Packt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files( the "Software" ), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Common
|
||||
|
||||
#ifndef ALL_HEADERS
|
||||
#define ALL_HEADERS
|
||||
|
||||
#include "01 Instance and Devices/03 Connecting with a Vulkan Loader library.h"
|
||||
#include "01 Instance and Devices/05 Loading function exported from a Vulkan Loader library.h"
|
||||
#include "01 Instance and Devices/06 Loading global-level functions.h"
|
||||
#include "01 Instance and Devices/07 Checking available Instance extensions.h"
|
||||
#include "01 Instance and Devices/08 Creating a Vulkan Instance.h"
|
||||
#include "01 Instance and Devices/09 Loading instance-level functions.h"
|
||||
#include "01 Instance and Devices/10 Enumerating available physical devices.h"
|
||||
#include "01 Instance and Devices/11 Checking available device extensions.h"
|
||||
#include "01 Instance and Devices/12 Getting features and properties of a physical device.h"
|
||||
#include "01 Instance and Devices/13 Checking available queue families and their properties.h"
|
||||
#include "01 Instance and Devices/14 Selecting index of a queue family with desired capabilities.h"
|
||||
#include "01 Instance and Devices/15 Creating a logical device.h"
|
||||
#include "01 Instance and Devices/16 Loading device-level functions.h"
|
||||
#include "01 Instance and Devices/17 Getting a device queue.h"
|
||||
#include "01 Instance and Devices/18 Creating a logical device with geometry shaders and graphics queue.h"
|
||||
#include "01 Instance and Devices/19 Destroying a logical device.h"
|
||||
#include "01 Instance and Devices/20 Destroying a Vulkan Instance.h"
|
||||
#include "01 Instance and Devices/21 Releasing a Vulkan Loader library.h"
|
||||
|
||||
#include "02 Image Presentation/01 Creating a Vulkan Instance with WSI extensions enabled.h"
|
||||
#include "02 Image Presentation/02 Creating a presentation surface.h"
|
||||
#include "02 Image Presentation/03 Selecting a queue family that supports presentation to a given surface.h"
|
||||
#include "02 Image Presentation/04 Creating a logical device with WSI extensions enabled.h"
|
||||
#include "02 Image Presentation/05 Selecting a desired presentation mode.h"
|
||||
#include "02 Image Presentation/06 Getting capabilities of a presentation surface.h"
|
||||
#include "02 Image Presentation/07 Selecting a number of swapchain images.h"
|
||||
#include "02 Image Presentation/08 Choosing a size of swapchain images.h"
|
||||
#include "02 Image Presentation/09 Selecting desired usage scenarios of swapchain images.h"
|
||||
#include "02 Image Presentation/10 Selecting a transformation of swapchain images.h"
|
||||
#include "02 Image Presentation/11 Selecting a format of swapchain images.h"
|
||||
#include "02 Image Presentation/12 Creating a swapchain.h"
|
||||
#include "02 Image Presentation/13 Getting handles of swapchain images.h"
|
||||
#include "02 Image Presentation/14 Creating a swapchain with R8G8B8A8 format and a MAILBOX present mode.h"
|
||||
#include "02 Image Presentation/15 Acquiring a swapchain image.h"
|
||||
#include "02 Image Presentation/16 Presenting an image.h"
|
||||
#include "02 Image Presentation/17 Destroying a swapchain.h"
|
||||
#include "02 Image Presentation/18 Destroying a presentation surface.h"
|
||||
|
||||
#include "03 Command Buffers and Synchronization/01 Creating a command pool.h"
|
||||
#include "03 Command Buffers and Synchronization/02 Allocating command buffers.h"
|
||||
#include "03 Command Buffers and Synchronization/03 Beginning a command buffer recording operation.h"
|
||||
#include "03 Command Buffers and Synchronization/04 Ending a command buffer recording operation.h"
|
||||
#include "03 Command Buffers and Synchronization/05 Resetting a command buffer.h"
|
||||
#include "03 Command Buffers and Synchronization/06 Resetting a command pool.h"
|
||||
#include "03 Command Buffers and Synchronization/07 Creating a semaphore.h"
|
||||
#include "03 Command Buffers and Synchronization/08 Creating a fence.h"
|
||||
#include "03 Command Buffers and Synchronization/09 Waiting for fences.h"
|
||||
#include "03 Command Buffers and Synchronization/10 Resetting fences.h"
|
||||
#include "03 Command Buffers and Synchronization/11 Submitting command buffers to the queue.h"
|
||||
#include "03 Command Buffers and Synchronization/12 Synchronizing two command buffers.h"
|
||||
#include "03 Command Buffers and Synchronization/13 Checking if processing of a submitted command buffer has finished.h"
|
||||
#include "03 Command Buffers and Synchronization/14 Waiting until all commands submitted to a queue are finished.h"
|
||||
#include "03 Command Buffers and Synchronization/15 Waiting for all submitted commands to be finished.h"
|
||||
#include "03 Command Buffers and Synchronization/16 Destroying a fence.h"
|
||||
#include "03 Command Buffers and Synchronization/17 Destroying a semaphore.h"
|
||||
#include "03 Command Buffers and Synchronization/18 Freeing command buffers.h"
|
||||
#include "03 Command Buffers and Synchronization/19 Destroying a command pool.h"
|
||||
|
||||
#include "04 Resources and Memory/01 Creating a buffer.h"
|
||||
#include "04 Resources and Memory/02 Allocating and binding memory object to a buffer.h"
|
||||
#include "04 Resources and Memory/03 Setting a buffer memory barrier.h"
|
||||
#include "04 Resources and Memory/04 Creating a buffer view.h"
|
||||
#include "04 Resources and Memory/05 Creating an image.h"
|
||||
#include "04 Resources and Memory/06 Allocating and binding memory object to an image.h"
|
||||
#include "04 Resources and Memory/07 Setting an image memory barrier.h"
|
||||
#include "04 Resources and Memory/08 Creating an image view.h"
|
||||
#include "04 Resources and Memory/09 Creating a 2D image and view.h"
|
||||
#include "04 Resources and Memory/10 Creating a layered 2D image with a CUBEMAP view.h"
|
||||
#include "04 Resources and Memory/11 Mapping, updating and unmapping host-visible memory.h"
|
||||
#include "04 Resources and Memory/12 Copying data between buffers.h"
|
||||
#include "04 Resources and Memory/13 Copying data from a buffer to an image.h"
|
||||
#include "04 Resources and Memory/14 Copying data from an image to a buffer.h"
|
||||
#include "04 Resources and Memory/15 Using staging buffer to update a buffer with a device-local memory bound.h"
|
||||
#include "04 Resources and Memory/16 Using staging buffer to update an image with a device-local memory bound.h"
|
||||
#include "04 Resources and Memory/17 Destroying an image view.h"
|
||||
#include "04 Resources and Memory/18 Destroying an image.h"
|
||||
#include "04 Resources and Memory/19 Destroying a buffer view.h"
|
||||
#include "04 Resources and Memory/20 Freeing a memory object.h"
|
||||
#include "04 Resources and Memory/21 Destroying a buffer.h"
|
||||
|
||||
#include "05 Descriptor Sets/01 Creating a sampler.h"
|
||||
#include "05 Descriptor Sets/02 Creating a sampled image.h"
|
||||
#include "05 Descriptor Sets/03 Creating a combined image sampler.h"
|
||||
#include "05 Descriptor Sets/04 Creating a storage image.h"
|
||||
#include "05 Descriptor Sets/05 Creating a uniform texel buffer.h"
|
||||
#include "05 Descriptor Sets/06 Creating a storage texel buffer.h"
|
||||
#include "05 Descriptor Sets/07 Creating a uniform buffer.h"
|
||||
#include "05 Descriptor Sets/08 Creating a storage buffer.h"
|
||||
#include "05 Descriptor Sets/09 Creating an input attachment.h"
|
||||
#include "05 Descriptor Sets/10 Creating a descriptor set layout.h"
|
||||
#include "05 Descriptor Sets/11 Creating a descriptor pool.h"
|
||||
#include "05 Descriptor Sets/12 Allocating descriptor sets.h"
|
||||
#include "05 Descriptor Sets/13 Updating descriptor sets.h"
|
||||
#include "05 Descriptor Sets/14 Binding descriptor sets.h"
|
||||
#include "05 Descriptor Sets/15 Creating descriptors with a texture and a uniform buffer.h"
|
||||
#include "05 Descriptor Sets/16 Freeing descriptor sets.h"
|
||||
#include "05 Descriptor Sets/17 Resetting a descriptor pool.h"
|
||||
#include "05 Descriptor Sets/18 Destroying a descriptor pool.h"
|
||||
#include "05 Descriptor Sets/19 Destroying a descriptor set layout.h"
|
||||
#include "05 Descriptor Sets/20 Destroying a sampler.h"
|
||||
|
||||
#include "06 Render Passes and Framebuffers/01 Specifying attachments descriptions.h"
|
||||
#include "06 Render Passes and Framebuffers/02 Specifying subpass descriptions.h"
|
||||
#include "06 Render Passes and Framebuffers/03 Specifying dependencies between subpasses.h"
|
||||
#include "06 Render Passes and Framebuffers/04 Creating a render pass.h"
|
||||
#include "06 Render Passes and Framebuffers/05 Creating a framebuffer.h"
|
||||
#include "06 Render Passes and Framebuffers/06 Preparing a render pass for geometry rendering and postprocess subpasses.h"
|
||||
#include "06 Render Passes and Framebuffers/07 Preparing a render pass and a framebuffer with color and depth attachments.h"
|
||||
#include "06 Render Passes and Framebuffers/08 Beginning a render pass.h"
|
||||
#include "06 Render Passes and Framebuffers/09 Progressing to the next subpass.h"
|
||||
#include "06 Render Passes and Framebuffers/10 Ending a render pass.h"
|
||||
#include "06 Render Passes and Framebuffers/11 Destroying a framebuffer.h"
|
||||
#include "06 Render Passes and Framebuffers/12 Destroying a render pass.h"
|
||||
|
||||
#include "08 Graphics and Compute Pipelines/01 Creating a shader module.h"
|
||||
#include "08 Graphics and Compute Pipelines/02 Specifying pipeline shader stages.h"
|
||||
#include "08 Graphics and Compute Pipelines/03 Specifying pipeline vertex input state.h"
|
||||
#include "08 Graphics and Compute Pipelines/04 Specifying pipeline input assembly state.h"
|
||||
#include "08 Graphics and Compute Pipelines/05 Specifying pipeline tessellation state.h"
|
||||
#include "08 Graphics and Compute Pipelines/06 Specifying pipeline viewport and scissor test state.h"
|
||||
#include "08 Graphics and Compute Pipelines/07 Specifying pipeline rasterization state.h"
|
||||
#include "08 Graphics and Compute Pipelines/08 Specifying pipeline multisample state.h"
|
||||
#include "08 Graphics and Compute Pipelines/09 Specifying pipeline depth and stencil state.h"
|
||||
#include "08 Graphics and Compute Pipelines/10 Specifying pipeline blend state.h"
|
||||
#include "08 Graphics and Compute Pipelines/11 Specifying pipeline dynamic states.h"
|
||||
#include "08 Graphics and Compute Pipelines/12 Creating a pipeline layout.h"
|
||||
#include "08 Graphics and Compute Pipelines/13 Specifying graphics pipeline creation parameters.h"
|
||||
#include "08 Graphics and Compute Pipelines/14 Creating a pipeline cache object.h"
|
||||
#include "08 Graphics and Compute Pipelines/15 Retrieving data from a pipeline cache.h"
|
||||
#include "08 Graphics and Compute Pipelines/16 Merging multiple pipeline cache objects.h"
|
||||
#include "08 Graphics and Compute Pipelines/17 Creating graphics pipelines.h"
|
||||
#include "08 Graphics and Compute Pipelines/18 Creating a compute pipeline.h"
|
||||
#include "08 Graphics and Compute Pipelines/19 Binding a pipeline object.h"
|
||||
#include "08 Graphics and Compute Pipelines/20 Creating a pipeline layout with a combined image sampler, a buffer and push constant ranges.h"
|
||||
#include "08 Graphics and Compute Pipelines/21 Creating a graphics pipeline with vertex and fragment shaders, depth test enabled, and with dynamic viewport and scissor tests.h"
|
||||
#include "08 Graphics and Compute Pipelines/22 Creating multiple graphics pipelines on multiple threads.h"
|
||||
#include "08 Graphics and Compute Pipelines/23 Destroying a pipeline.h"
|
||||
#include "08 Graphics and Compute Pipelines/24 Destroying a pipeline cache.h"
|
||||
#include "08 Graphics and Compute Pipelines/25 Destroying a pipeline layout.h"
|
||||
#include "08 Graphics and Compute Pipelines/26 Destroying a shader module.h"
|
||||
|
||||
#include "09 Command Recording and Drawing/01 Clearing a color image.h"
|
||||
#include "09 Command Recording and Drawing/02 Clearing a depth-stencil image.h"
|
||||
#include "09 Command Recording and Drawing/03 Clearing render pass attachments.h"
|
||||
#include "09 Command Recording and Drawing/04 Binding vertex buffers.h"
|
||||
#include "09 Command Recording and Drawing/05 Binding an index buffer.h"
|
||||
#include "09 Command Recording and Drawing/06 Providing data to shaders through push constants.h"
|
||||
#include "09 Command Recording and Drawing/07 Setting viewport state dynamically.h"
|
||||
#include "09 Command Recording and Drawing/08 Setting scissor state dynamically.h"
|
||||
#include "09 Command Recording and Drawing/09 Setting line width state dynamically.h"
|
||||
#include "09 Command Recording and Drawing/10 Setting depth bias state dynamically.h"
|
||||
#include "09 Command Recording and Drawing/11 Setting blend constants state dynamically.h"
|
||||
#include "09 Command Recording and Drawing/12 Drawing a geometry.h"
|
||||
#include "09 Command Recording and Drawing/13 Drawing an indexed geometry.h"
|
||||
#include "09 Command Recording and Drawing/14 Dispatching compute work.h"
|
||||
#include "09 Command Recording and Drawing/15 Executing secondary command buffer inside a primary command buffer.h"
|
||||
#include "09 Command Recording and Drawing/16 Recording a command buffer that draws a geometry with dynamic viewport and scissor states.h"
|
||||
#include "09 Command Recording and Drawing/17 Recording command buffers on multiple threads.h"
|
||||
#include "09 Command Recording and Drawing/18 Preparing a single frame of animation.h"
|
||||
#include "09 Command Recording and Drawing/19 Increasing the performance through increasing the number of separately rendered frames.h"
|
||||
|
||||
#include "10 Helper Recipes/01 Preparing a translation matrix.h"
|
||||
#include "10 Helper Recipes/02 Preparing a rotation matrix.h"
|
||||
#include "10 Helper Recipes/03 Preparing a scaling matrix.h"
|
||||
#include "10 Helper Recipes/04 Preparing a perspective projection matrix.h"
|
||||
#include "10 Helper Recipes/05 Preparing an orthographic projection matrix.h"
|
||||
#include "10 Helper Recipes/06 Loading texture data from a file.h"
|
||||
#include "10 Helper Recipes/07 Loading a 3D model from an OBJ file.h"
|
||||
|
||||
|
||||
#endif // ALL_HEADERS
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Common
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool IsExtensionSupported( std::vector<VkExtensionProperties> const & available_extensions,
|
||||
char const * const extension ) {
|
||||
for( auto & available_extension : available_extensions ) {
|
||||
if( strstr( available_extension.extensionName, extension ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,87 +0,0 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright( c ) 2017 Packt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files( the "Software" ), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Common
|
||||
|
||||
#ifndef COMMON
|
||||
#define COMMON
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#elif defined __linux
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include "VulkanDestroyer.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
// Vulkan library type
|
||||
#ifdef _WIN32
|
||||
#define LIBRARY_TYPE HMODULE
|
||||
#elif defined __linux
|
||||
#define LIBRARY_TYPE void*
|
||||
#endif
|
||||
|
||||
// OS-specific parameters
|
||||
struct WindowParameters {
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
HINSTANCE HInstance;
|
||||
HWND HWnd;
|
||||
|
||||
#elif defined VK_USE_PLATFORM_XLIB_KHR
|
||||
|
||||
Display * Dpy;
|
||||
Window Window;
|
||||
|
||||
#elif defined VK_USE_PLATFORM_XCB_KHR
|
||||
|
||||
xcb_connection_t * Connection;
|
||||
xcb_window_t Window;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
// Extension availability check
|
||||
bool IsExtensionSupported( std::vector<VkExtensionProperties> const & available_extensions,
|
||||
char const * const extension );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // COMMON
|
||||
@ -1,204 +0,0 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright( c ) 2017 Packt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files( the "Software" ), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// List of Vulkan Functions
|
||||
|
||||
//
|
||||
|
||||
#ifndef EXPORTED_VULKAN_FUNCTION
|
||||
#define EXPORTED_VULKAN_FUNCTION( function )
|
||||
#endif
|
||||
|
||||
EXPORTED_VULKAN_FUNCTION( vkGetInstanceProcAddr )
|
||||
|
||||
#undef EXPORTED_VULKAN_FUNCTION
|
||||
|
||||
//
|
||||
|
||||
#ifndef GLOBAL_LEVEL_VULKAN_FUNCTION
|
||||
#define GLOBAL_LEVEL_VULKAN_FUNCTION( function )
|
||||
#endif
|
||||
|
||||
GLOBAL_LEVEL_VULKAN_FUNCTION( vkEnumerateInstanceExtensionProperties )
|
||||
GLOBAL_LEVEL_VULKAN_FUNCTION( vkEnumerateInstanceLayerProperties )
|
||||
GLOBAL_LEVEL_VULKAN_FUNCTION( vkCreateInstance )
|
||||
|
||||
#undef GLOBAL_LEVEL_VULKAN_FUNCTION
|
||||
|
||||
//
|
||||
|
||||
#ifndef INSTANCE_LEVEL_VULKAN_FUNCTION
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION( function )
|
||||
#endif
|
||||
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkEnumeratePhysicalDevices )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkEnumerateDeviceExtensionProperties )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkGetPhysicalDeviceFeatures )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkGetPhysicalDeviceProperties )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkGetPhysicalDeviceQueueFamilyProperties )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkGetPhysicalDeviceMemoryProperties )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkGetPhysicalDeviceFormatProperties )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkCreateDevice )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkGetDeviceProcAddr )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION( vkDestroyInstance )
|
||||
|
||||
#undef INSTANCE_LEVEL_VULKAN_FUNCTION
|
||||
|
||||
//
|
||||
|
||||
#ifndef INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( function, extension )
|
||||
#endif
|
||||
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkGetPhysicalDeviceSurfaceSupportKHR, VK_KHR_SURFACE_EXTENSION_NAME )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkGetPhysicalDeviceSurfaceCapabilitiesKHR, VK_KHR_SURFACE_EXTENSION_NAME )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkGetPhysicalDeviceSurfaceFormatsKHR, VK_KHR_SURFACE_EXTENSION_NAME )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkGetPhysicalDeviceSurfacePresentModesKHR, VK_KHR_SURFACE_EXTENSION_NAME )
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkDestroySurfaceKHR, VK_KHR_SURFACE_EXTENSION_NAME )
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkCreateWin32SurfaceKHR, VK_KHR_WIN32_SURFACE_EXTENSION_NAME )
|
||||
#elif defined VK_USE_PLATFORM_XCB_KHR
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkCreateXcbSurfaceKHR, VK_KHR_XCB_SURFACE_EXTENSION_NAME )
|
||||
#elif defined VK_USE_PLATFORM_XLIB_KHR
|
||||
INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkCreateXlibSurfaceKHR, VK_KHR_XLIB_SURFACE_EXTENSION_NAME )
|
||||
#endif
|
||||
|
||||
#undef INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||
|
||||
//
|
||||
|
||||
#ifndef DEVICE_LEVEL_VULKAN_FUNCTION
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION( function )
|
||||
#endif
|
||||
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkGetDeviceQueue )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDeviceWaitIdle )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyDevice )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkGetBufferMemoryRequirements )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkAllocateMemory )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkBindBufferMemory )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdPipelineBarrier )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateImage )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkGetImageMemoryRequirements )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkBindImageMemory )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateImageView )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkMapMemory )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkFlushMappedMemoryRanges )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkUnmapMemory )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdCopyBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdCopyBufferToImage )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdCopyImageToBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkBeginCommandBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkEndCommandBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkQueueSubmit )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyImageView )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyImage )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkFreeMemory )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateCommandPool )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkAllocateCommandBuffers )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateSemaphore )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateFence )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkWaitForFences )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkResetFences )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyFence )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroySemaphore )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkResetCommandBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkFreeCommandBuffers )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkResetCommandPool )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyCommandPool )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateBufferView )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyBufferView )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkQueueWaitIdle )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateSampler )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateDescriptorSetLayout )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateDescriptorPool )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkAllocateDescriptorSets )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkUpdateDescriptorSets )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdBindDescriptorSets )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkFreeDescriptorSets )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkResetDescriptorPool )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyDescriptorPool )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyDescriptorSetLayout )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroySampler )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateRenderPass )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateFramebuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyFramebuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyRenderPass )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdBeginRenderPass )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdNextSubpass )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdEndRenderPass )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreatePipelineCache )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkGetPipelineCacheData )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkMergePipelineCaches )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyPipelineCache )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateGraphicsPipelines )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateComputePipelines )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyPipeline )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyEvent )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyQueryPool )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreateShaderModule )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyShaderModule )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCreatePipelineLayout )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkDestroyPipelineLayout )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdBindPipeline )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdSetViewport )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdSetScissor )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdBindVertexBuffers )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdDraw )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdDrawIndexed )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdDispatch )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdCopyImage )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdPushConstants )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdClearColorImage )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdClearDepthStencilImage )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdBindIndexBuffer )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdSetLineWidth )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdSetDepthBias )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdSetBlendConstants )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdExecuteCommands )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION( vkCmdClearAttachments )
|
||||
|
||||
#undef DEVICE_LEVEL_VULKAN_FUNCTION
|
||||
|
||||
//
|
||||
|
||||
#ifndef DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( function, extension )
|
||||
#endif
|
||||
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkCreateSwapchainKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkGetSwapchainImagesKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkAcquireNextImageKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkQueuePresentKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME )
|
||||
DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( vkDestroySwapchainKHR, VK_KHR_SWAPCHAIN_EXTENSION_NAME )
|
||||
|
||||
#undef DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION
|
||||
@ -1,215 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Tools
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include "Tools.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool GetBinaryFileContents( std::string const & filename,
|
||||
std::vector<unsigned char> & contents ) {
|
||||
contents.clear();
|
||||
|
||||
std::ifstream file( filename, std::ios::binary );
|
||||
if( file.fail() ) {
|
||||
std::cout << "Could not open '" << filename << "' file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::streampos begin;
|
||||
std::streampos end;
|
||||
begin = file.tellg();
|
||||
file.seekg( 0, std::ios::end );
|
||||
end = file.tellg();
|
||||
|
||||
if( (end - begin) == 0 ) {
|
||||
std::cout << "The '" << filename << "' file is empty." << std::endl;
|
||||
return false;
|
||||
}
|
||||
contents.resize( static_cast<size_t>(end - begin) );
|
||||
file.seekg( 0, std::ios::beg );
|
||||
file.read( reinterpret_cast<char*>(contents.data()), end - begin );
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float Deg2Rad( float value ) {
|
||||
return value * 0.01745329251994329576923690768489f;
|
||||
}
|
||||
|
||||
float Dot( Vector3 const & left,
|
||||
Vector3 const & right ) {
|
||||
return left[0] * right[0] + left[1] * right[1] + left[2] * right[2];
|
||||
}
|
||||
|
||||
Vector3 Cross( Vector3 const & left,
|
||||
Vector3 const & right ) {
|
||||
return {
|
||||
left[1] * right[2] - left[2] * right[1],
|
||||
left[2] * right[0] - left[0] * right[2],
|
||||
left[0] * right[1] - left[1] * right[0]
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 Normalize( Vector3 const & vector ) {
|
||||
float length = std::sqrt( vector[0] * vector[0] + vector[1] * vector[1] + vector[2] * vector[2] );
|
||||
return {
|
||||
vector[0] / length,
|
||||
vector[1] / length,
|
||||
vector[2] / length
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator+ ( Vector3 const & left,
|
||||
Vector3 const & right ) {
|
||||
return{
|
||||
left[0] + right[0],
|
||||
left[1] + right[1],
|
||||
left[2] + right[2]
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator- ( Vector3 const & left,
|
||||
Vector3 const & right ) {
|
||||
return{
|
||||
left[0] - right[0],
|
||||
left[1] - right[1],
|
||||
left[2] - right[2]
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator+ ( float const & left,
|
||||
Vector3 const & right ) {
|
||||
return {
|
||||
left + right[0],
|
||||
left + right[1],
|
||||
left + right[2]
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator- ( float const & left,
|
||||
Vector3 const & right ) {
|
||||
return {
|
||||
left - right[0],
|
||||
left - right[1],
|
||||
left - right[2]
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator+ ( Vector3 const & left,
|
||||
float const & right ) {
|
||||
return{
|
||||
left[0] + right,
|
||||
left[1] + right,
|
||||
left[2] + right
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator- ( Vector3 const & left,
|
||||
float const & right ) {
|
||||
return {
|
||||
left[0] - right,
|
||||
left[1] - right,
|
||||
left[2] - right
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator* ( float left,
|
||||
Vector3 const & right ) {
|
||||
return {
|
||||
left * right[0],
|
||||
left * right[1],
|
||||
left * right[2]
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator* ( Vector3 const & left,
|
||||
float right ) {
|
||||
return {
|
||||
left[0] * right,
|
||||
left[1] * right,
|
||||
left[2] * right
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator* ( Vector3 const & left,
|
||||
Matrix4x4 const & right ) {
|
||||
return {
|
||||
left[0] * right[0] + left[1] * right[1] + left[2] * right[2],
|
||||
left[0] * right[4] + left[1] * right[5] + left[2] * right[6],
|
||||
left[0] * right[8] + left[1] * right[9] + left[2] * right[10]
|
||||
};
|
||||
}
|
||||
|
||||
Vector3 operator- ( Vector3 const & vector ) {
|
||||
return {
|
||||
-vector[0],
|
||||
-vector[1],
|
||||
-vector[2]
|
||||
};
|
||||
}
|
||||
|
||||
bool operator== ( Vector3 const & left,
|
||||
Vector3 const & right ) {
|
||||
if( (std::abs( left[0] - right[0] ) > 0.00001f) ||
|
||||
(std::abs( left[1] - right[1] ) > 0.00001f) ||
|
||||
(std::abs( left[2] - right[2] ) > 0.00001f) ) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Matrix4x4 operator* ( Matrix4x4 const & left,
|
||||
Matrix4x4 const & right ) {
|
||||
return {
|
||||
left[0] * right[0] + left[4] * right[1] + left[8] * right[2] + left[12] * right[3],
|
||||
left[1] * right[0] + left[5] * right[1] + left[9] * right[2] + left[13] * right[3],
|
||||
left[2] * right[0] + left[6] * right[1] + left[10] * right[2] + left[14] * right[3],
|
||||
left[3] * right[0] + left[7] * right[1] + left[11] * right[2] + left[15] * right[3],
|
||||
|
||||
left[0] * right[4] + left[4] * right[5] + left[8] * right[6] + left[12] * right[7],
|
||||
left[1] * right[4] + left[5] * right[5] + left[9] * right[6] + left[13] * right[7],
|
||||
left[2] * right[4] + left[6] * right[5] + left[10] * right[6] + left[14] * right[7],
|
||||
left[3] * right[4] + left[7] * right[5] + left[11] * right[6] + left[15] * right[7],
|
||||
|
||||
left[0] * right[8] + left[4] * right[9] + left[8] * right[10] + left[12] * right[11],
|
||||
left[1] * right[8] + left[5] * right[9] + left[9] * right[10] + left[13] * right[11],
|
||||
left[2] * right[8] + left[6] * right[9] + left[10] * right[10] + left[14] * right[11],
|
||||
left[3] * right[8] + left[7] * right[9] + left[11] * right[10] + left[15] * right[11],
|
||||
|
||||
left[0] * right[12] + left[4] * right[13] + left[8] * right[14] + left[12] * right[15],
|
||||
left[1] * right[12] + left[5] * right[13] + left[9] * right[14] + left[13] * right[15],
|
||||
left[2] * right[12] + left[6] * right[13] + left[10] * right[14] + left[14] * right[15],
|
||||
left[3] * right[12] + left[7] * right[13] + left[11] * right[14] + left[15] * right[15]
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,92 +0,0 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright( c ) 2017 Packt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files( the "Software" ), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Tools
|
||||
|
||||
#ifndef TOOLS
|
||||
#define TOOLS
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
using Vector3 = std::array<float, 3>;
|
||||
using Matrix4x4 = std::array<float, 16>;
|
||||
|
||||
bool GetBinaryFileContents( std::string const & filename,
|
||||
std::vector<unsigned char> & contents );
|
||||
|
||||
float Deg2Rad( float value );
|
||||
|
||||
float Dot( Vector3 const & left,
|
||||
Vector3 const & right );
|
||||
|
||||
Vector3 Cross( Vector3 const & left,
|
||||
Vector3 const & right );
|
||||
|
||||
Vector3 Normalize( Vector3 const & vector );
|
||||
|
||||
Vector3 operator+ ( Vector3 const & left,
|
||||
Vector3 const & right );
|
||||
|
||||
Vector3 operator- ( Vector3 const & left,
|
||||
Vector3 const & right );
|
||||
|
||||
Vector3 operator+ ( float const & left,
|
||||
Vector3 const & right );
|
||||
|
||||
Vector3 operator- ( float const & left,
|
||||
Vector3 const & right );
|
||||
|
||||
Vector3 operator+ ( Vector3 const & left,
|
||||
float const & right );
|
||||
|
||||
Vector3 operator- ( Vector3 const & left,
|
||||
float const & right );
|
||||
|
||||
Vector3 operator* ( float left,
|
||||
Vector3 const & right );
|
||||
|
||||
Vector3 operator* ( Vector3 const & left,
|
||||
float right );
|
||||
|
||||
Vector3 operator* ( Vector3 const & left,
|
||||
Matrix4x4 const & right );
|
||||
|
||||
Vector3 operator- ( Vector3 const & vector );
|
||||
|
||||
bool operator== ( Vector3 const & left,
|
||||
Vector3 const & right );
|
||||
|
||||
Matrix4x4 operator* ( Matrix4x4 const & left,
|
||||
Matrix4x4 const & right );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // TOOLS
|
||||
@ -1,207 +0,0 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright( c ) 2017 Packt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files( the "Software" ), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Vulkan Destroyer
|
||||
|
||||
#ifndef VULKAN_DESTROYER
|
||||
#define VULKAN_DESTROYER
|
||||
|
||||
#include <functional>
|
||||
#include "VulkanFunctions.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
// VkDestroyer<> - wrapper for automatic object destruction
|
||||
|
||||
struct VkInstanceWrapper {
|
||||
VkInstance Handle;
|
||||
};
|
||||
|
||||
struct VkDeviceWrapper {
|
||||
VkDevice Handle;
|
||||
};
|
||||
|
||||
struct VkSurfaceKHRWrapper {
|
||||
VkSurfaceKHR Handle;
|
||||
};
|
||||
|
||||
// Deleter functions
|
||||
|
||||
template<class VkType>
|
||||
void DestroyVulkanObject( VkType object );
|
||||
|
||||
template<>
|
||||
inline void DestroyVulkanObject<VkInstanceWrapper>( VkInstanceWrapper object ) {
|
||||
vkDestroyInstance( object.Handle, nullptr );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void DestroyVulkanObject<VkDeviceWrapper>( VkDeviceWrapper object ) {
|
||||
vkDestroyDevice( object.Handle, nullptr );
|
||||
}
|
||||
|
||||
template<class VkParent, class VkChild>
|
||||
void DestroyVulkanObject( VkParent parent, VkChild object );
|
||||
|
||||
template<>
|
||||
inline void DestroyVulkanObject<VkInstance, VkSurfaceKHRWrapper>( VkInstance instance, VkSurfaceKHRWrapper surface ) {
|
||||
vkDestroySurfaceKHR( instance, surface.Handle, nullptr );
|
||||
}
|
||||
|
||||
#define VK_DESTROYER_SPECIALIZATION( VkChild, VkDeleter ) \
|
||||
struct VkChild##Wrapper { \
|
||||
VkChild Handle; \
|
||||
}; \
|
||||
\
|
||||
template<> \
|
||||
inline void DestroyVulkanObject<VkDevice, VkChild##Wrapper>( VkDevice device, VkChild##Wrapper object ) { \
|
||||
VkDeleter( device, object.Handle, nullptr ); \
|
||||
}
|
||||
|
||||
VK_DESTROYER_SPECIALIZATION( VkSemaphore, vkDestroySemaphore )
|
||||
// VK_DESTROYER_SPECIALIZATION( VkCommandBuffer, vkFreeCommandBuffers ) <- command buffers are freed along with the pool
|
||||
VK_DESTROYER_SPECIALIZATION( VkFence, vkDestroyFence )
|
||||
VK_DESTROYER_SPECIALIZATION( VkDeviceMemory, vkFreeMemory )
|
||||
VK_DESTROYER_SPECIALIZATION( VkBuffer, vkDestroyBuffer )
|
||||
VK_DESTROYER_SPECIALIZATION( VkImage, vkDestroyImage )
|
||||
VK_DESTROYER_SPECIALIZATION( VkEvent, vkDestroyEvent )
|
||||
VK_DESTROYER_SPECIALIZATION( VkQueryPool, vkDestroyQueryPool )
|
||||
VK_DESTROYER_SPECIALIZATION( VkBufferView, vkDestroyBufferView )
|
||||
VK_DESTROYER_SPECIALIZATION( VkImageView, vkDestroyImageView )
|
||||
VK_DESTROYER_SPECIALIZATION( VkShaderModule, vkDestroyShaderModule )
|
||||
VK_DESTROYER_SPECIALIZATION( VkPipelineCache, vkDestroyPipelineCache )
|
||||
VK_DESTROYER_SPECIALIZATION( VkPipelineLayout, vkDestroyPipelineLayout )
|
||||
VK_DESTROYER_SPECIALIZATION( VkRenderPass, vkDestroyRenderPass )
|
||||
VK_DESTROYER_SPECIALIZATION( VkPipeline, vkDestroyPipeline )
|
||||
VK_DESTROYER_SPECIALIZATION( VkDescriptorSetLayout, vkDestroyDescriptorSetLayout )
|
||||
VK_DESTROYER_SPECIALIZATION( VkSampler, vkDestroySampler )
|
||||
VK_DESTROYER_SPECIALIZATION( VkDescriptorPool, vkDestroyDescriptorPool )
|
||||
// VK_DESTROYER_SPECIALIZATION( VkDescriptorSet, vkFreeDescriptorSets ) <- descriptor sets are freed along with the pool
|
||||
VK_DESTROYER_SPECIALIZATION( VkFramebuffer, vkDestroyFramebuffer )
|
||||
VK_DESTROYER_SPECIALIZATION( VkCommandPool, vkDestroyCommandPool )
|
||||
VK_DESTROYER_SPECIALIZATION( VkSwapchainKHR, vkDestroySwapchainKHR )
|
||||
|
||||
// Class definition
|
||||
|
||||
template<class VkTypeWrapper>
|
||||
class VkDestroyer {
|
||||
public:
|
||||
VkDestroyer() :
|
||||
DestroyerFunction( nullptr ) {
|
||||
Object.Handle = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
VkDestroyer( std::function<void( VkTypeWrapper )> destroyer_function ) :
|
||||
DestroyerFunction( destroyer_function ) {
|
||||
Object.Handle = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
VkDestroyer( VkTypeWrapper object, std::function<void( VkTypeWrapper )> destroyer_function ) :
|
||||
DestroyerFunction( destroyer_function ) {
|
||||
Object.Handle = object.Handle;
|
||||
}
|
||||
|
||||
~VkDestroyer() {
|
||||
if( DestroyerFunction && Object.Handle ) {
|
||||
DestroyerFunction( Object );
|
||||
}
|
||||
}
|
||||
|
||||
VkDestroyer( VkDestroyer<VkTypeWrapper> && other ) :
|
||||
DestroyerFunction( other.DestroyerFunction ) {
|
||||
Object.Handle = other.Object.Handle;
|
||||
other.Object.Handle = VK_NULL_HANDLE;
|
||||
other.DestroyerFunction = nullptr;
|
||||
}
|
||||
|
||||
VkDestroyer& operator=( VkDestroyer<VkTypeWrapper> && other ) {
|
||||
if( this != &other ) {
|
||||
VkTypeWrapper object = Object;
|
||||
std::function<void( VkTypeWrapper )> destroyer_function = DestroyerFunction;
|
||||
|
||||
Object.Handle = other.Object.Handle;
|
||||
DestroyerFunction = other.DestroyerFunction;
|
||||
|
||||
other.Object.Handle = object.Handle;
|
||||
other.DestroyerFunction = destroyer_function;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
decltype(VkTypeWrapper::Handle) & operator*() {
|
||||
return Object.Handle;
|
||||
}
|
||||
|
||||
decltype(VkTypeWrapper::Handle) const & operator*() const {
|
||||
return Object.Handle;
|
||||
}
|
||||
|
||||
bool operator!() const {
|
||||
return Object.Handle == VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return Object.Handle != VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
VkDestroyer( VkDestroyer<VkTypeWrapper> const & ) = delete;
|
||||
VkDestroyer& operator=( VkDestroyer<VkTypeWrapper> const & ) = delete;
|
||||
|
||||
private:
|
||||
VkTypeWrapper Object;
|
||||
std::function<void( VkTypeWrapper )> DestroyerFunction;
|
||||
};
|
||||
|
||||
// Helper macro
|
||||
|
||||
#define VkDestroyer( VkType ) VkDestroyer<VkType##Wrapper>
|
||||
|
||||
// Helper functions
|
||||
|
||||
inline void InitVkDestroyer( VkDestroyer<VkInstanceWrapper> & destroyer ) {
|
||||
destroyer = VkDestroyer<VkInstanceWrapper>( std::bind( DestroyVulkanObject<VkInstanceWrapper>, std::placeholders::_1 ) );
|
||||
}
|
||||
|
||||
inline void InitVkDestroyer( VkDestroyer<VkDeviceWrapper> & destroyer ) {
|
||||
destroyer = VkDestroyer<VkDeviceWrapper>( std::bind( DestroyVulkanObject<VkDeviceWrapper>, std::placeholders::_1 ) );
|
||||
}
|
||||
|
||||
template<class VkParent, class VkType>
|
||||
inline void InitVkDestroyer( VkParent const & parent, VkDestroyer<VkType> & destroyer ) {
|
||||
destroyer = VkDestroyer<VkType>( std::bind( DestroyVulkanObject<VkParent, VkType>, parent, std::placeholders::_1 ) );
|
||||
}
|
||||
|
||||
template<class VkParent, class VkType>
|
||||
inline void InitVkDestroyer( VkDestroyer<VkParent> const & parent, VkDestroyer<VkType> & destroyer ) {
|
||||
destroyer = VkDestroyer<VkType>( std::bind( DestroyVulkanObject<decltype(VkParent::Handle), VkType>, *parent, std::placeholders::_1 ) );
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // VULKAN_DESTROYER
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Vulkan Functions
|
||||
|
||||
#include "VulkanFunctions.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
#define EXPORTED_VULKAN_FUNCTION( name ) PFN_##name name;
|
||||
#define GLOBAL_LEVEL_VULKAN_FUNCTION( name ) PFN_##name name;
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION( name ) PFN_##name name;
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( name, extension ) PFN_##name name;
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION( name ) PFN_##name name;
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( name, extension ) PFN_##name name;
|
||||
|
||||
#include "ListOfVulkanFunctions.inl"
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,50 +0,0 @@
|
||||
// MIT License
|
||||
//
|
||||
// Copyright( c ) 2017 Packt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files( the "Software" ), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Vulkan Functions
|
||||
|
||||
#ifndef VULKAN_FUNCTIONS
|
||||
#define VULKAN_FUNCTIONS
|
||||
|
||||
#include "vulkan.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
#define EXPORTED_VULKAN_FUNCTION( name ) extern PFN_##name name;
|
||||
#define GLOBAL_LEVEL_VULKAN_FUNCTION( name ) extern PFN_##name name;
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION( name ) extern PFN_##name name;
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( name, extension ) extern PFN_##name name;
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION( name ) extern PFN_##name name;
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( name, extension ) extern PFN_##name name;
|
||||
|
||||
#include "ListOfVulkanFunctions.inl"
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // VULKAN_FUNCTIONS
|
||||
@ -1,47 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// © Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 03 Connecting with a Vulkan Loader library
|
||||
|
||||
#include "01 Instance and Devices/03 Connecting with a Vulkan Loader library.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ConnectWithVulkanLoaderLibrary( LIBRARY_TYPE & vulkan_library ) {
|
||||
#if defined _WIN32
|
||||
vulkan_library = LoadLibrary( "vulkan-1.dll" );
|
||||
#elif defined __linux
|
||||
vulkan_library = dlopen( "libvulkan.so.1", RTLD_NOW );
|
||||
#endif
|
||||
|
||||
if( vulkan_library == nullptr ) {
|
||||
std::cout << "Could not connect with a Vulkan Runtime library." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 03 Connecting with a Vulkan Loader library
|
||||
|
||||
#ifndef CONNECTING_WITH_A_VULKAN_LOADER_LIBRARY
|
||||
#define CONNECTING_WITH_A_VULKAN_LOADER_LIBRARY
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ConnectWithVulkanLoaderLibrary( LIBRARY_TYPE & vulkan_library );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CONNECTING_WITH_A_VULKAN_LOADER_LIBRARY
|
||||
@ -1,53 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 05 Loading function exported from a Vulkan Loader library
|
||||
|
||||
#include "01 Instance and Devices/05 Loading function exported from a Vulkan Loader library.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadFunctionExportedFromVulkanLoaderLibrary( LIBRARY_TYPE const & vulkan_library ) {
|
||||
#if defined _WIN32
|
||||
#define LoadFunction GetProcAddress
|
||||
#elif defined __linux
|
||||
#define LoadFunction dlsym
|
||||
#endif
|
||||
|
||||
#define EXPORTED_VULKAN_FUNCTION( name ) \
|
||||
name = (PFN_##name)LoadFunction( vulkan_library, #name ); \
|
||||
if( name == nullptr ) { \
|
||||
std::cout << "Could not load exported Vulkan function named: " \
|
||||
#name << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfVulkanFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// © Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 05 Loading function exported from a Vulkan Loader library
|
||||
|
||||
#ifndef LOADING_FUNCTION_EXPORTED_FROM_A_VULKAN_LOADER_LIBRARY
|
||||
#define LOADING_FUNCTION_EXPORTED_FROM_A_VULKAN_LOADER_LIBRARY
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadFunctionExportedFromVulkanLoaderLibrary( LIBRARY_TYPE const & vulkan_library );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // LOADING_FUNCTION_EXPORTED_FROM_A_VULKAN_LOADER_LIBRARY
|
||||
@ -1,47 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 06 Loading global-level functions
|
||||
|
||||
#include "01 Instance and Devices/06 Loading global-level functions.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadGlobalLevelFunctions() {
|
||||
#define GLOBAL_LEVEL_VULKAN_FUNCTION( name ) \
|
||||
name = (PFN_##name)vkGetInstanceProcAddr( nullptr, #name ); \
|
||||
if( name == nullptr ) { \
|
||||
std::cout << "Could not load global level Vulkan function named: " \
|
||||
#name << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfVulkanFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 06 Loading global-level functions
|
||||
|
||||
#ifndef LOADING_GLOBAL_LEVEL_FUNCTIONS
|
||||
#define LOADING_GLOBAL_LEVEL_FUNCTIONS
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadGlobalLevelFunctions();
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // LOADING_GLOBAL_LEVEL_FUNCTIONS
|
||||
@ -1,55 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 07 Checking available Instance extensions
|
||||
|
||||
#include "01 Instance and Devices/07 Checking available Instance extensions.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CheckAvailableInstanceExtensions( std::vector<VkExtensionProperties> & available_extensions ) {
|
||||
uint32_t extensions_count = 0;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
result = vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, nullptr );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(extensions_count == 0) ) {
|
||||
std::cout << "Could not get the number of instance extensions." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
available_extensions.resize( extensions_count );
|
||||
result = vkEnumerateInstanceExtensionProperties( nullptr, &extensions_count, available_extensions.data() );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(extensions_count == 0) ) {
|
||||
std::cout << "Could not enumerate instance extensions." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 07 Checking available Instance extensions
|
||||
|
||||
#ifndef CHECKING_AVAILABLE_INSTANCE_EXTENSIONS
|
||||
#define CHECKING_AVAILABLE_INSTANCE_EXTENSIONS
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CheckAvailableInstanceExtensions( std::vector<VkExtensionProperties> & available_extensions );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CHECKING_AVAILABLE_INSTANCE_EXTENSIONS
|
||||
@ -1,80 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 08 Creating a Vulkan Instance
|
||||
|
||||
#include "01 Instance and Devices/07 Checking available Instance extensions.h"
|
||||
#include "01 Instance and Devices/08 Creating a Vulkan Instance.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateVulkanInstance( std::vector<char const *> const & desired_extensions,
|
||||
char const * const application_name,
|
||||
VkInstance & instance ) {
|
||||
std::vector<VkExtensionProperties> available_extensions;
|
||||
if( !CheckAvailableInstanceExtensions( available_extensions ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for( auto & extension : desired_extensions ) {
|
||||
if( !IsExtensionSupported( available_extensions, extension ) ) {
|
||||
std::cout << "Extension named '" << extension << "' is not supported by an Instance object." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
VkApplicationInfo application_info = {
|
||||
VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
application_name, // const char * pApplicationName
|
||||
VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t applicationVersion
|
||||
"Vulkan Cookbook", // const char * pEngineName
|
||||
VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t engineVersion
|
||||
VK_MAKE_VERSION( 1, 0, 0 ) // uint32_t apiVersion
|
||||
};
|
||||
|
||||
VkInstanceCreateInfo instance_create_info = {
|
||||
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0, // VkInstanceCreateFlags flags
|
||||
&application_info, // const VkApplicationInfo * pApplicationInfo
|
||||
0, // uint32_t enabledLayerCount
|
||||
nullptr, // const char * const * ppEnabledLayerNames
|
||||
static_cast<uint32_t>(desired_extensions.size()), // uint32_t enabledExtensionCount
|
||||
desired_extensions.data() // const char * const * ppEnabledExtensionNames
|
||||
};
|
||||
|
||||
VkResult result = vkCreateInstance( &instance_create_info, nullptr, &instance );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(instance == VK_NULL_HANDLE) ) {
|
||||
std::cout << "Could not create Vulkan instance." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 08 Creating a Vulkan Instance
|
||||
|
||||
#ifndef CREATING_A_VULKAN_INSTANCE
|
||||
#define CREATING_A_VULKAN_INSTANCE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateVulkanInstance( std::vector<char const *> const & desired_extensions,
|
||||
char const * const application_name,
|
||||
VkInstance & instance );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_VULKAN_INSTANCE
|
||||
@ -1,62 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 09 Loading instance-level functions
|
||||
|
||||
#include "01 Instance and Devices/09 Loading instance-level functions.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadInstanceLevelFunctions( VkInstance instance,
|
||||
std::vector<char const *> const & enabled_extensions ) {
|
||||
// Load core Vulkan API instance-level functions
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION( name ) \
|
||||
name = (PFN_##name)vkGetInstanceProcAddr( instance, #name ); \
|
||||
if( name == nullptr ) { \
|
||||
std::cout << "Could not load instance-level Vulkan function named: " \
|
||||
#name << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
// Load instance-level functions from enabled extensions
|
||||
#define INSTANCE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( name, extension ) \
|
||||
for( auto & enabled_extension : enabled_extensions ) { \
|
||||
if( std::string( enabled_extension ) == std::string( extension ) ) { \
|
||||
name = (PFN_##name)vkGetInstanceProcAddr( instance, #name ); \
|
||||
if( name == nullptr ) { \
|
||||
std::cout << "Could not load instance-level Vulkan function named: " \
|
||||
#name << std::endl; \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "ListOfVulkanFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 09 Loading instance-level functions
|
||||
|
||||
#ifndef LOADING_INSTANCE_LEVEL_FUNCTIONS
|
||||
#define LOADING_INSTANCE_LEVEL_FUNCTIONS
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadInstanceLevelFunctions( VkInstance instance,
|
||||
std::vector<char const *> const & enabled_extensions );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // LOADING_INSTANCE_LEVEL_FUNCTIONS
|
||||
@ -1,56 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 10 Enumerating available physical devices
|
||||
|
||||
#include "01 Instance and Devices/10 Enumerating available physical devices.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool EnumerateAvailablePhysicalDevices( VkInstance instance,
|
||||
std::vector<VkPhysicalDevice> & available_devices ) {
|
||||
uint32_t devices_count = 0;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
result = vkEnumeratePhysicalDevices( instance, &devices_count, nullptr );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(devices_count == 0) ) {
|
||||
std::cout << "Could not get the number of available physical devices." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
available_devices.resize( devices_count );
|
||||
result = vkEnumeratePhysicalDevices( instance, &devices_count, available_devices.data() );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(devices_count == 0) ) {
|
||||
std::cout << "Could not enumerate physical devices." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 10 Enumerating available physical devices
|
||||
|
||||
#ifndef ENUMERATING_AVAILABLE_PHYSICAL_DEVICES
|
||||
#define ENUMERATING_AVAILABLE_PHYSICAL_DEVICES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool EnumerateAvailablePhysicalDevices( VkInstance instance,
|
||||
std::vector<VkPhysicalDevice> & available_devices );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // ENUMERATING_AVAILABLE_PHYSICAL_DEVICES
|
||||
@ -1,56 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 11 Checking available device extensions
|
||||
|
||||
#include "01 Instance and Devices/11 Checking available device extensions.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CheckAvailableDeviceExtensions( VkPhysicalDevice physical_device,
|
||||
std::vector<VkExtensionProperties> & available_extensions ) {
|
||||
uint32_t extensions_count = 0;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
result = vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, nullptr );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(extensions_count == 0) ) {
|
||||
std::cout << "Could not get the number of device extensions." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
available_extensions.resize( extensions_count );
|
||||
result = vkEnumerateDeviceExtensionProperties( physical_device, nullptr, &extensions_count, available_extensions.data() );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(extensions_count == 0) ) {
|
||||
std::cout << "Could not enumerate device extensions." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 11 Checking available device extensions
|
||||
|
||||
#ifndef CHECKING_AVAILABLE_DEVICE_EXTENSIONS
|
||||
#define CHECKING_AVAILABLE_DEVICE_EXTENSIONS
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CheckAvailableDeviceExtensions( VkPhysicalDevice physical_device,
|
||||
std::vector<VkExtensionProperties> & available_extensions );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CHECKING_AVAILABLE_DEVICE_EXTENSIONS
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 12 Getting features and properties of a physical device
|
||||
|
||||
#include "01 Instance and Devices/12 Getting features and properties of a physical device.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void GetFeaturesAndPropertiesOfPhysicalDevice( VkPhysicalDevice physical_device,
|
||||
VkPhysicalDeviceFeatures & device_features,
|
||||
VkPhysicalDeviceProperties & device_properties ) {
|
||||
vkGetPhysicalDeviceFeatures( physical_device, &device_features );
|
||||
|
||||
vkGetPhysicalDeviceProperties( physical_device, &device_properties );
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 12 Getting features and properties of a physical device
|
||||
|
||||
#ifndef GETTING_FEATURES_AND_PROPERTIES_OF_A_PHYSICAL_DEVICE
|
||||
#define GETTING_FEATURES_AND_PROPERTIES_OF_A_PHYSICAL_DEVICE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void GetFeaturesAndPropertiesOfPhysicalDevice( VkPhysicalDevice physical_device,
|
||||
VkPhysicalDeviceFeatures & device_features,
|
||||
VkPhysicalDeviceProperties & device_properties );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // GETTING_FEATURES_AND_PROPERTIES_OF_A_PHYSICAL_DEVICE
|
||||
@ -1,53 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 13 Checking available queue families and their properties
|
||||
|
||||
#include "01 Instance and Devices/13 Checking available queue families and their properties.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CheckAvailableQueueFamiliesAndTheirProperties( VkPhysicalDevice physical_device,
|
||||
std::vector<VkQueueFamilyProperties> & queue_families ) {
|
||||
uint32_t queue_families_count = 0;
|
||||
|
||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
||||
if( queue_families_count == 0 ) {
|
||||
std::cout << "Could not get the number of queue families." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
queue_families.resize( queue_families_count );
|
||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, queue_families.data() );
|
||||
if( queue_families_count == 0 ) {
|
||||
std::cout << "Could not acquire properties of queue families." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 13 Checking available queue families and their properties
|
||||
|
||||
#ifndef Checking_available_queue_families_and_their_properties
|
||||
#define CHECKING_AVAILABLE_QUEUE_FAMILIES_AND_THEIR_PROPERTIES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CheckAvailableQueueFamiliesAndTheirProperties( VkPhysicalDevice physical_device,
|
||||
std::vector<VkQueueFamilyProperties> & queue_families );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CHECKING_AVAILABLE_QUEUE_FAMILIES_AND_THEIR_PROPERTIES
|
||||
@ -1,52 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 14 Selecting index of a queue family with desired capabilities
|
||||
|
||||
#include "01 Instance and Devices/13 Checking available queue families and their properties.h"
|
||||
#include "01 Instance and Devices/14 Selecting index of a queue family with desired capabilities.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectIndexOfQueueFamilyWithDesiredCapabilities( VkPhysicalDevice physical_device,
|
||||
VkQueueFlags desired_capabilities,
|
||||
uint32_t & queue_family_index ) {
|
||||
std::vector<VkQueueFamilyProperties> queue_families;
|
||||
if( !CheckAvailableQueueFamiliesAndTheirProperties( physical_device, queue_families ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for( uint32_t index = 0; index < static_cast<uint32_t>(queue_families.size()); ++index ) {
|
||||
if( (queue_families[index].queueCount > 0) &&
|
||||
((queue_families[index].queueFlags & desired_capabilities) == desired_capabilities) ) {
|
||||
queue_family_index = index;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 14 Selecting index of a queue family with desired capabilities
|
||||
|
||||
#ifndef SELECTING_INDEX_OF_A_QUEUE_FAMILY_WITH_DESIRED_CAPABILITIES
|
||||
#define SELECTING_INDEX_OF_A_QUEUE_FAMILY_WITH_DESIRED_CAPABILITIES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectIndexOfQueueFamilyWithDesiredCapabilities( VkPhysicalDevice physical_device,
|
||||
VkQueueFlags desired_capabilities,
|
||||
uint32_t & queue_family_index );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // SELECTING_INDEX_OF_A_QUEUE_FAMILY_WITH_DESIRED_CAPABILITIES
|
||||
@ -1,87 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 15 Creating a logical device
|
||||
|
||||
#include "01 Instance and Devices/11 Checking available device extensions.h"
|
||||
#include "01 Instance and Devices/15 Creating a logical device.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateLogicalDevice( VkPhysicalDevice physical_device,
|
||||
std::vector<QueueInfo> queue_infos,
|
||||
std::vector<char const *> const & desired_extensions,
|
||||
VkPhysicalDeviceFeatures * desired_features,
|
||||
VkDevice & logical_device ) {
|
||||
std::vector<VkExtensionProperties> available_extensions;
|
||||
if( !CheckAvailableDeviceExtensions( physical_device, available_extensions ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for( auto & extension : desired_extensions ) {
|
||||
if( !IsExtensionSupported( available_extensions, extension ) ) {
|
||||
std::cout << "Extension named '" << extension << "' is not supported by a physical device." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<VkDeviceQueueCreateInfo> queue_create_infos;
|
||||
|
||||
for( auto & info : queue_infos ) {
|
||||
queue_create_infos.push_back( {
|
||||
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0, // VkDeviceQueueCreateFlags flags
|
||||
info.FamilyIndex, // uint32_t queueFamilyIndex
|
||||
static_cast<uint32_t>(info.Priorities.size()), // uint32_t queueCount
|
||||
info.Priorities.data() // const float * pQueuePriorities
|
||||
} );
|
||||
};
|
||||
|
||||
VkDeviceCreateInfo device_create_info = {
|
||||
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0, // VkDeviceCreateFlags flags
|
||||
static_cast<uint32_t>(queue_create_infos.size()), // uint32_t queueCreateInfoCount
|
||||
queue_create_infos.data(), // const VkDeviceQueueCreateInfo * pQueueCreateInfos
|
||||
0, // uint32_t enabledLayerCount
|
||||
nullptr, // const char * const * ppEnabledLayerNames
|
||||
static_cast<uint32_t>(desired_extensions.size()), // uint32_t enabledExtensionCount
|
||||
desired_extensions.data(), // const char * const * ppEnabledExtensionNames
|
||||
desired_features // const VkPhysicalDeviceFeatures * pEnabledFeatures
|
||||
};
|
||||
|
||||
VkResult result = vkCreateDevice( physical_device, &device_create_info, nullptr, &logical_device );
|
||||
if( (result != VK_SUCCESS) ||
|
||||
(logical_device == VK_NULL_HANDLE) ) {
|
||||
std::cout << "Could not create logical device." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,49 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 15 Creating a logical device
|
||||
|
||||
#ifndef CREATING_A_LOGICAL_DEVICE
|
||||
#define CREATING_A_LOGICAL_DEVICE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
struct QueueInfo {
|
||||
uint32_t FamilyIndex;
|
||||
std::vector<float> Priorities;
|
||||
};
|
||||
|
||||
bool CreateLogicalDevice( VkPhysicalDevice physical_device,
|
||||
std::vector< QueueInfo > queue_infos,
|
||||
std::vector<char const *> const & desired_extensions,
|
||||
VkPhysicalDeviceFeatures * desired_features,
|
||||
VkDevice & logical_device );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_LOGICAL_DEVICE
|
||||
@ -1,62 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 16 Loading device-level functions
|
||||
|
||||
#include "01 Instance and Devices/16 Loading device-level functions.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadDeviceLevelFunctions( VkDevice logical_device,
|
||||
std::vector<char const *> const & enabled_extensions ) {
|
||||
// Load core Vulkan API device-level functions
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION( name ) \
|
||||
name = (PFN_##name)vkGetDeviceProcAddr( logical_device, #name ); \
|
||||
if( name == nullptr ) { \
|
||||
std::cout << "Could not load device-level Vulkan function named: " \
|
||||
#name << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
// Load device-level functions from enabled extensions
|
||||
#define DEVICE_LEVEL_VULKAN_FUNCTION_FROM_EXTENSION( name, extension ) \
|
||||
for( auto & enabled_extension : enabled_extensions ) { \
|
||||
if( std::string( enabled_extension ) == std::string( extension ) ) { \
|
||||
name = (PFN_##name)vkGetDeviceProcAddr( logical_device, #name ); \
|
||||
if( name == nullptr ) { \
|
||||
std::cout << "Could not load device-level Vulkan function named: " \
|
||||
#name << std::endl; \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "ListOfVulkanFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 16 Loading device-level functions
|
||||
|
||||
#ifndef LOADING_DEVICE_LEVEL_FUNCTIONS
|
||||
#define LOADING_DEVICE_LEVEL_FUNCTIONS
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool LoadDeviceLevelFunctions( VkDevice logical_device,
|
||||
std::vector<char const *> const & enabled_extensions );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // LOADING_DEVICE_LEVEL_FUNCTIONS
|
||||
@ -1,37 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 17 Getting a device queue
|
||||
|
||||
#include "01 Instance and Devices/17 Getting a device queue.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void GetDeviceQueue( VkDevice logical_device, uint32_t queue_family_index, uint32_t queue_index, VkQueue & queue ) {
|
||||
vkGetDeviceQueue( logical_device, queue_family_index, queue_index, &queue );
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 17 Getting a device queue
|
||||
|
||||
#ifndef GETTING_A_DEVICE_QUEUE
|
||||
#define GETTING_A_DEVICE_QUEUE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void GetDeviceQueue( VkDevice logical_device, uint32_t queue_family_index, uint32_t queue_index, VkQueue & queue );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // GETTING_A_DEVICE_QUEUE
|
||||
@ -1,86 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 18 Creating a logical device with geometry shaders and graphics and compute queues
|
||||
|
||||
#include "01 Instance and Devices/10 Enumerating available physical devices.h"
|
||||
#include "01 Instance and Devices/12 Getting features and properties of a physical device.h"
|
||||
#include "01 Instance and Devices/14 Selecting index of a queue family with desired capabilities.h"
|
||||
#include "01 Instance and Devices/15 Creating a logical device.h"
|
||||
#include "01 Instance and Devices/16 Loading device-level functions.h"
|
||||
#include "01 Instance and Devices/17 Getting a device queue.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateLogicalDeviceWithGeometryShadersAndGraphicsAndComputeQueues( VkInstance instance,
|
||||
VkDevice & logical_device,
|
||||
VkQueue & graphics_queue,
|
||||
VkQueue & compute_queue ) {
|
||||
std::vector<VkPhysicalDevice> physical_devices;
|
||||
EnumerateAvailablePhysicalDevices( instance, physical_devices );
|
||||
|
||||
for( auto & physical_device : physical_devices ) {
|
||||
VkPhysicalDeviceFeatures device_features;
|
||||
VkPhysicalDeviceProperties device_properties;
|
||||
GetFeaturesAndPropertiesOfPhysicalDevice( physical_device, device_features, device_properties );
|
||||
|
||||
if( !device_features.geometryShader ) {
|
||||
continue;
|
||||
} else {
|
||||
device_features = {};
|
||||
device_features.geometryShader = VK_TRUE;
|
||||
}
|
||||
|
||||
uint32_t graphics_queue_family_index;
|
||||
if( !SelectIndexOfQueueFamilyWithDesiredCapabilities( physical_device, VK_QUEUE_GRAPHICS_BIT, graphics_queue_family_index ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t compute_queue_family_index;
|
||||
if( !SelectIndexOfQueueFamilyWithDesiredCapabilities( physical_device, VK_QUEUE_COMPUTE_BIT, compute_queue_family_index ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<QueueInfo> requested_queues = { { graphics_queue_family_index, { 1.0f } } };
|
||||
if( graphics_queue_family_index != compute_queue_family_index ) {
|
||||
requested_queues.push_back( { compute_queue_family_index, { 1.0f } } );
|
||||
}
|
||||
|
||||
if( !CreateLogicalDevice( physical_device, requested_queues, {}, &device_features, logical_device ) ) {
|
||||
continue;
|
||||
} else {
|
||||
if( !LoadDeviceLevelFunctions( logical_device, {} ) ) {
|
||||
return false;
|
||||
}
|
||||
GetDeviceQueue( logical_device, graphics_queue_family_index, 0, graphics_queue );
|
||||
GetDeviceQueue( logical_device, compute_queue_family_index, 0, compute_queue );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,43 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 18 Creating a logical device with geometry shaders and graphics and compute queues
|
||||
|
||||
#ifndef CREATING_A_LOGICAL_DEVICE_WITH_GEOMETRY_SHADERS_AND_GRAPHICS_AND_COMPUTE_QUEUES
|
||||
#define CREATING_A_LOGICAL_DEVICE_WITH_GEOMETRY_SHADERS_AND_GRAPHICS_AND_COMPUTE_QUEUES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateLogicalDeviceWithGeometryShadersAndGraphicsAndComputeQueues( VkInstance instance,
|
||||
VkDevice & logical_device,
|
||||
VkQueue & graphics_queue,
|
||||
VkQueue & compute_queue );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_LOGICAL_DEVICE_WITH_GEOMETRY_SHADERS_AND_GRAPHICS_AND_COMPUTE_QUEUES
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 19 Destroying a logical device
|
||||
|
||||
#include "01 Instance and Devices/19 Destroying a logical device.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroyLogicalDevice( VkDevice & logical_device ) {
|
||||
if( logical_device ) {
|
||||
vkDestroyDevice( logical_device, nullptr );
|
||||
logical_device = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 19 Destroying a logical device
|
||||
|
||||
#ifndef DESTROYING_A_LOGICAL_DEVICE
|
||||
#define DESTROYING_A_LOGICAL_DEVICE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroyLogicalDevice( VkDevice & logical_device );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // DESTROYING_A_LOGICAL_DEVICE
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 20 Destroying a Vulkan Instance
|
||||
|
||||
#include "01 Instance and Devices/20 Destroying a Vulkan Instance.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroyVulkanInstance( VkInstance & instance ) {
|
||||
if( instance ) {
|
||||
vkDestroyInstance( instance, nullptr );
|
||||
instance = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 20 Destroying a Vulkan Instance
|
||||
|
||||
#ifndef DESTROYING_VULKAN_INSTANCE
|
||||
#define DESTROYING_VULKAN_INSTANCE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroyVulkanInstance( VkInstance & instance );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // DESTROYING_VULKAN_INSTANCE
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 21 Releasing a Vulkan Loader library
|
||||
|
||||
#include "01 Instance and Devices/21 Releasing a Vulkan Loader library.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void ReleaseVulkanLoaderLibrary( LIBRARY_TYPE & vulkan_library ) {
|
||||
if( nullptr != vulkan_library ) {
|
||||
#if defined _WIN32
|
||||
FreeLibrary( vulkan_library );
|
||||
#elif defined __linux
|
||||
dlclose( vulkan_library );
|
||||
#endif
|
||||
vulkan_library = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 01 Instance and Devices
|
||||
// Recipe: 21 Releasing a Vulkan Loader library
|
||||
|
||||
#ifndef RELEASING_A_VULKAN_RUNTIME_LIBRARY
|
||||
#define RELEASING_A_VULKAN_RUNTIME_LIBRARY
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void ReleaseVulkanLoaderLibrary( LIBRARY_TYPE & vulkan_library );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // RELEASING_A_VULKAN_RUNTIME_LIBRARY
|
||||
@ -1,53 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 01 Creating a Vulkan Instance with WSI extensions enabled
|
||||
|
||||
#include "01 Instance and Devices/08 Creating a Vulkan Instance.h"
|
||||
#include "02 Image Presentation/01 Creating a Vulkan Instance with WSI extensions enabled.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateVulkanInstanceWithWsiExtensionsEnabled( std::vector<char const *> & desired_extensions,
|
||||
char const * const application_name,
|
||||
VkInstance & instance ) {
|
||||
desired_extensions.emplace_back( VK_KHR_SURFACE_EXTENSION_NAME );
|
||||
desired_extensions.emplace_back(
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
VK_KHR_WIN32_SURFACE_EXTENSION_NAME
|
||||
|
||||
#elif defined VK_USE_PLATFORM_XCB_KHR
|
||||
VK_KHR_XCB_SURFACE_EXTENSION_NAME
|
||||
|
||||
#elif defined VK_USE_PLATFORM_XLIB_KHR
|
||||
VK_KHR_XLIB_SURFACE_EXTENSION_NAME
|
||||
#endif
|
||||
);
|
||||
|
||||
return CreateVulkanInstance( desired_extensions, application_name, instance );
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 01 Creating a Vulkan Instance with WSI extensions enabled
|
||||
|
||||
#ifndef CREATING_A_VULKAN_INSTANCE_WITH_WSI_EXTENSIONS_ENABLED
|
||||
#define CREATING_A_VULKAN_INSTANCE_WITH_WSI_EXTENSIONS_ENABLED
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateVulkanInstanceWithWsiExtensionsEnabled( std::vector<char const *> & desired_extensions,
|
||||
char const * const application_name,
|
||||
VkInstance & instance );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_VULKAN_INSTANCE_WITH_WSI_EXTENSIONS_ENABLED
|
||||
@ -1,84 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 02 Creating a presentation surface
|
||||
|
||||
#include "02 Image Presentation/02 Creating a presentation surface.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreatePresentationSurface( VkInstance instance,
|
||||
WindowParameters window_parameters,
|
||||
VkSurfaceKHR & presentation_surface ) {
|
||||
VkResult result;
|
||||
|
||||
#ifdef VK_USE_PLATFORM_WIN32_KHR
|
||||
|
||||
VkWin32SurfaceCreateInfoKHR surface_create_info = {
|
||||
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0, // VkWin32SurfaceCreateFlagsKHR flags
|
||||
window_parameters.HInstance, // HINSTANCE hinstance
|
||||
window_parameters.HWnd // HWND hwnd
|
||||
};
|
||||
|
||||
result = vkCreateWin32SurfaceKHR( instance, &surface_create_info, nullptr, &presentation_surface );
|
||||
|
||||
#elif defined VK_USE_PLATFORM_XLIB_KHR
|
||||
|
||||
VkXlibSurfaceCreateInfoKHR surface_create_info = {
|
||||
VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0, // VkXlibSurfaceCreateFlagsKHR flags
|
||||
window_parameters.Dpy, // Display * dpy
|
||||
window_parameters.Window // Window window
|
||||
};
|
||||
|
||||
result = vkCreateXlibSurfaceKHR( instance, &surface_create_info, nullptr, &presentation_surface );
|
||||
|
||||
#elif defined VK_USE_PLATFORM_XCB_KHR
|
||||
|
||||
VkXcbSurfaceCreateInfoKHR surface_create_info = {
|
||||
VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0, // VkXcbSurfaceCreateFlagsKHR flags
|
||||
window_parameters.Connection, // xcb_connection_t * connection
|
||||
window_parameters.Window // xcb_window_t window
|
||||
};
|
||||
|
||||
result = vkCreateXcbSurfaceKHR( instance, &surface_create_info, nullptr, &presentation_surface );
|
||||
|
||||
#endif
|
||||
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(VK_NULL_HANDLE == presentation_surface) ) {
|
||||
std::cout << "Could not create presentation surface." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 02 Creating a presentation surface
|
||||
|
||||
#ifndef CREATING_A_PRESENTATION_SURFACE
|
||||
#define CREATING_A_PRESENTATION_SURFACE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreatePresentationSurface( VkInstance instance,
|
||||
WindowParameters window_parameters,
|
||||
VkSurfaceKHR & presentation_surface );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_PRESENTATION_SURFACE
|
||||
@ -1,54 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 03 Selecting a queue family that supports presentation to a given surface
|
||||
|
||||
#include "01 Instance and Devices/13 Checking available queue families and their properties.h"
|
||||
#include "02 Image Presentation/03 Selecting a queue family that supports presentation to a given surface.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectQueueFamilyThatSupportsPresentationToGivenSurface( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
uint32_t & queue_family_index ) {
|
||||
std::vector<VkQueueFamilyProperties> queue_families;
|
||||
if( !CheckAvailableQueueFamiliesAndTheirProperties( physical_device, queue_families ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for( uint32_t index = 0; index < static_cast<uint32_t>(queue_families.size()); ++index ) {
|
||||
VkBool32 presentation_supported = VK_FALSE;
|
||||
VkResult result = vkGetPhysicalDeviceSurfaceSupportKHR( physical_device, index, presentation_surface, &presentation_supported );
|
||||
if( (VK_SUCCESS == result) &&
|
||||
(VK_TRUE == presentation_supported) ) {
|
||||
queue_family_index = index;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 03 Selecting a queue family that supports presentation to a given surface
|
||||
|
||||
#ifndef SELECTING_A_QUEUE_FAMILY_THAT_SUPPORTS_PRESENTATION_TO_A_GIVEN_SURFACE
|
||||
#define SELECTING_A_QUEUE_FAMILY_THAT_SUPPORTS_PRESENTATION_TO_A_GIVEN_SURFACE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectQueueFamilyThatSupportsPresentationToGivenSurface( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
uint32_t & queue_family_index );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // SELECTING_A_QUEUE_FAMILY_THAT_SUPPORTS_PRESENTATION_TO_A_GIVEN_SURFACE
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 04 Creating a logical device with WSI extensions enabled
|
||||
|
||||
#include "01 Instance and Devices/15 Creating a logical device.h"
|
||||
#include "02 Image Presentation/04 Creating a logical device with WSI extensions enabled.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateLogicalDeviceWithWsiExtensionsEnabled( VkPhysicalDevice physical_device,
|
||||
std::vector< QueueInfo > queue_infos,
|
||||
std::vector<char const *> & desired_extensions,
|
||||
VkPhysicalDeviceFeatures * desired_features,
|
||||
VkDevice & logical_device ) {
|
||||
desired_extensions.emplace_back( VK_KHR_SWAPCHAIN_EXTENSION_NAME );
|
||||
|
||||
return CreateLogicalDevice( physical_device, queue_infos, desired_extensions, desired_features, logical_device );
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 04 Creating a logical device with WSI extensions enabled
|
||||
|
||||
#ifndef CREATING_A_LOGICAL_DEVICE_WITH_WSI_EXTENSIONS_ENABLED
|
||||
#define CREATING_A_LOGICAL_DEVICE_WITH_WSI_EXTENSIONS_ENABLED
|
||||
|
||||
#include "01 Instance and Devices/15 Creating a logical device.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateLogicalDeviceWithWsiExtensionsEnabled( VkPhysicalDevice physical_device,
|
||||
std::vector< QueueInfo > queue_infos,
|
||||
std::vector<char const *> & desired_extensions,
|
||||
VkPhysicalDeviceFeatures * desired_features,
|
||||
VkDevice & logical_device );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_LOGICAL_DEVICE_WITH_WSI_EXTENSIONS_ENABLED
|
||||
@ -1,76 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 05 Selecting a desired presentation mode
|
||||
|
||||
#include "02 Image Presentation/05 Selecting a desired presentation mode.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectDesiredPresentationMode( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkPresentModeKHR desired_present_mode,
|
||||
VkPresentModeKHR & present_mode ) {
|
||||
// Enumerate supported present modes
|
||||
uint32_t present_modes_count = 0;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
result = vkGetPhysicalDeviceSurfacePresentModesKHR( physical_device, presentation_surface, &present_modes_count, nullptr );
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(0 == present_modes_count) ) {
|
||||
std::cout << "Could not get the number of supported present modes." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<VkPresentModeKHR> present_modes( present_modes_count );
|
||||
result = vkGetPhysicalDeviceSurfacePresentModesKHR( physical_device, presentation_surface, &present_modes_count, present_modes.data() );
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(0 == present_modes_count) ) {
|
||||
std::cout << "Could not enumerate present modes." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Select present mode
|
||||
for( auto & current_present_mode : present_modes ) {
|
||||
if( current_present_mode == desired_present_mode ) {
|
||||
present_mode = desired_present_mode;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Desired present mode is not supported. Selecting default FIFO mode." << std::endl;
|
||||
for( auto & current_present_mode : present_modes ) {
|
||||
if( current_present_mode == VK_PRESENT_MODE_FIFO_KHR ) {
|
||||
present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "VK_PRESENT_MODE_FIFO_KHR is not supported though it's mandatory for all drivers!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,43 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 05 Selecting a desired presentation mode
|
||||
|
||||
#ifndef SELECTING_A_DESIRED_PRESENTATION_MODE
|
||||
#define SELECTING_A_DESIRED_PRESENTATION_MODE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectDesiredPresentationMode( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkPresentModeKHR desired_present_mode,
|
||||
VkPresentModeKHR & present_mode );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // SELECTING_A_DESIRED_PRESENTATION_MODE
|
||||
@ -1,45 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 06 Getting capabilities of a presentation surface
|
||||
|
||||
#include "02 Image Presentation/06 Getting capabilities of a presentation surface.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool GetCapabilitiesOfPresentationSurface( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkSurfaceCapabilitiesKHR & surface_capabilities ) {
|
||||
VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR( physical_device, presentation_surface, &surface_capabilities );
|
||||
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Could not get the capabilities of a presentation surface." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 06 Getting capabilities of a presentation surface
|
||||
|
||||
#ifndef GETTING_CAPABILITIES_OF_A_PRESENTATION_SURFACE
|
||||
#define GETTING_CAPABILITIES_OF_A_PRESENTATION_SURFACE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool GetCapabilitiesOfPresentationSurface( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkSurfaceCapabilitiesKHR & surface_capabilities );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // GETTING_CAPABILITIES_OF_A_PRESENTATION_SURFACE
|
||||
@ -1,43 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 07 Selecting a number of swapchain images
|
||||
|
||||
#include "02 Image Presentation/07 Selecting a number of swapchain images.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectNumberOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
uint32_t & number_of_images ) {
|
||||
number_of_images = surface_capabilities.minImageCount + 1;
|
||||
if( (surface_capabilities.maxImageCount > 0) &&
|
||||
(number_of_images > surface_capabilities.maxImageCount) ) {
|
||||
number_of_images = surface_capabilities.maxImageCount;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 07 Selecting a number of swapchain images
|
||||
|
||||
#ifndef SELECTING_A_NUMBER_OF_SWAPCHAIN_IMAGES
|
||||
#define SELECTING_A_NUMBER_OF_SWAPCHAIN_IMAGES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectNumberOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
uint32_t & number_of_images );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // SELECTING_A_NUMBER_OF_SWAPCHAIN_IMAGES
|
||||
@ -1,55 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 08 Choosing a size of swapchain images
|
||||
|
||||
#include "02 Image Presentation/08 Choosing a size of swapchain images.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ChooseSizeOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
VkExtent2D & size_of_images ) {
|
||||
if( 0xFFFFFFFF == surface_capabilities.currentExtent.width ) {
|
||||
size_of_images = { 640, 480 };
|
||||
|
||||
if( size_of_images.width < surface_capabilities.minImageExtent.width ) {
|
||||
size_of_images.width = surface_capabilities.minImageExtent.width;
|
||||
} else if( size_of_images.width > surface_capabilities.maxImageExtent.width ) {
|
||||
size_of_images.width = surface_capabilities.maxImageExtent.width;
|
||||
}
|
||||
|
||||
if( size_of_images.height < surface_capabilities.minImageExtent.height ) {
|
||||
size_of_images.height = surface_capabilities.minImageExtent.height;
|
||||
} else if( size_of_images.height > surface_capabilities.maxImageExtent.height ) {
|
||||
size_of_images.height = surface_capabilities.maxImageExtent.height;
|
||||
}
|
||||
} else {
|
||||
size_of_images = surface_capabilities.currentExtent;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 08 Choosing a size of swapchain images
|
||||
|
||||
#ifndef CHOOSING_A_SIZE_OF_SWAPCHAIN_IMAGES
|
||||
#define CHOOSING_A_SIZE_OF_SWAPCHAIN_IMAGES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ChooseSizeOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
VkExtent2D & size_of_images );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CHOOSING_A_SIZE_OF_SWAPCHAIN_IMAGES
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 09 Selecting desired usage scenarios of swapchain images
|
||||
|
||||
#include "02 Image Presentation/09 Selecting desired usage scenarios of swapchain images.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectDesiredUsageScenariosOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
VkImageUsageFlags desired_usages,
|
||||
VkImageUsageFlags & image_usage ) {
|
||||
image_usage = desired_usages & surface_capabilities.supportedUsageFlags;
|
||||
|
||||
return desired_usages == image_usage;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 09 Selecting desired usage scenarios of swapchain images
|
||||
|
||||
#ifndef SELECTING_DESIRED_USAGE_SCENARIOS_OF_SWAPCHAIN_IMAGES
|
||||
#define SELECTING_DESIRED_USAGE_SCENARIOS_OF_SWAPCHAIN_IMAGES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectDesiredUsageScenariosOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
VkImageUsageFlags desired_usages,
|
||||
VkImageUsageFlags & image_usage );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // SELECTING_DESIRED_USAGE_SCENARIOS_OF_SWAPCHAIN_IMAGES
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 10 Selecting a transformation of swapchain images
|
||||
|
||||
#include "02 Image Presentation/10 Selecting a transformation of swapchain images.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectTransformationOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
VkSurfaceTransformFlagBitsKHR desired_transform,
|
||||
VkSurfaceTransformFlagBitsKHR & surface_transform ) {
|
||||
if( surface_capabilities.supportedTransforms & desired_transform ) {
|
||||
surface_transform = desired_transform;
|
||||
} else {
|
||||
surface_transform = surface_capabilities.currentTransform;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 10 Selecting a transformation of swapchain images
|
||||
|
||||
#ifndef SELECTING_A_TRANSFORMATION_OF_SWAPCHAIN_IMAGES
|
||||
#define SELECTING_A_TRANSFORMATION_OF_SWAPCHAIN_IMAGES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectTransformationOfSwapchainImages( VkSurfaceCapabilitiesKHR const & surface_capabilities,
|
||||
VkSurfaceTransformFlagBitsKHR desired_transform,
|
||||
VkSurfaceTransformFlagBitsKHR & surface_transform );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // SELECTING_A_TRANSFORMATION_OF_SWAPCHAIN_IMAGES
|
||||
@ -1,89 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 11 Selecting a format of swapchain images
|
||||
|
||||
#include "02 Image Presentation/11 Selecting a format of swapchain images.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectFormatOfSwapchainImages( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkSurfaceFormatKHR desired_surface_format,
|
||||
VkFormat & image_format,
|
||||
VkColorSpaceKHR & image_color_space ) {
|
||||
// Enumerate supported formats
|
||||
uint32_t formats_count = 0;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
result = vkGetPhysicalDeviceSurfaceFormatsKHR( physical_device, presentation_surface, &formats_count, nullptr );
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(0 == formats_count) ) {
|
||||
std::cout << "Could not get the number of supported surface formats." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<VkSurfaceFormatKHR> surface_formats( formats_count );
|
||||
result = vkGetPhysicalDeviceSurfaceFormatsKHR( physical_device, presentation_surface, &formats_count, surface_formats.data() );
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(0 == formats_count) ) {
|
||||
std::cout << "Could not enumerate supported surface formats." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Select surface format
|
||||
if( (1 == surface_formats.size()) &&
|
||||
(VK_FORMAT_UNDEFINED == surface_formats[0].format) ) {
|
||||
image_format = desired_surface_format.format;
|
||||
image_color_space = desired_surface_format.colorSpace;
|
||||
return true;
|
||||
}
|
||||
|
||||
for( auto & surface_format : surface_formats ) {
|
||||
if( (desired_surface_format.format == surface_format.format) &&
|
||||
(desired_surface_format.colorSpace == surface_format.colorSpace) ) {
|
||||
image_format = desired_surface_format.format;
|
||||
image_color_space = desired_surface_format.colorSpace;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for( auto & surface_format : surface_formats ) {
|
||||
if( (desired_surface_format.format == surface_format.format) ) {
|
||||
image_format = desired_surface_format.format;
|
||||
image_color_space = surface_format.colorSpace;
|
||||
std::cout << "Desired combination of format and colorspace is not supported. Selecting other colorspace." << std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
image_format = surface_formats[0].format;
|
||||
image_color_space = surface_formats[0].colorSpace;
|
||||
std::cout << "Desired format is not supported. Selecting available format - colorspace combination." << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 11 Selecting a format of swapchain images
|
||||
|
||||
#ifndef SELECTING_A_FORMAT_OF_SWAPCHAIN_IMAGES
|
||||
#define SELECTING_A_FORMAT_OF_SWAPCHAIN_IMAGES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool SelectFormatOfSwapchainImages( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkSurfaceFormatKHR desired_surface_format,
|
||||
VkFormat & image_format,
|
||||
VkColorSpaceKHR & image_color_space );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // SELECTING_A_FORMAT_OF_SWAPCHAIN_IMAGES
|
||||
@ -1,79 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 12 Creating a swapchain
|
||||
|
||||
#include "02 Image Presentation/12 Creating a swapchain.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateSwapchain( VkDevice logical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
uint32_t image_count,
|
||||
VkSurfaceFormatKHR surface_format,
|
||||
VkExtent2D image_size,
|
||||
VkImageUsageFlags image_usage,
|
||||
VkSurfaceTransformFlagBitsKHR surface_transform,
|
||||
VkPresentModeKHR present_mode,
|
||||
VkSwapchainKHR & old_swapchain,
|
||||
VkSwapchainKHR & swapchain ) {
|
||||
VkSwapchainCreateInfoKHR swapchain_create_info = {
|
||||
VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0, // VkSwapchainCreateFlagsKHR flags
|
||||
presentation_surface, // VkSurfaceKHR surface
|
||||
image_count, // uint32_t minImageCount
|
||||
surface_format.format, // VkFormat imageFormat
|
||||
surface_format.colorSpace, // VkColorSpaceKHR imageColorSpace
|
||||
image_size, // VkExtent2D imageExtent
|
||||
1, // uint32_t imageArrayLayers
|
||||
image_usage, // VkImageUsageFlags imageUsage
|
||||
VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode imageSharingMode
|
||||
0, // uint32_t queueFamilyIndexCount
|
||||
nullptr, // const uint32_t * pQueueFamilyIndices
|
||||
surface_transform, // VkSurfaceTransformFlagBitsKHR preTransform
|
||||
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, // VkCompositeAlphaFlagBitsKHR compositeAlpha
|
||||
present_mode, // VkPresentModeKHR presentMode
|
||||
VK_TRUE, // VkBool32 clipped
|
||||
old_swapchain // VkSwapchainKHR oldSwapchain
|
||||
};
|
||||
|
||||
VkResult result = vkCreateSwapchainKHR( logical_device, &swapchain_create_info, nullptr, &swapchain );
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(VK_NULL_HANDLE == swapchain) ) {
|
||||
std::cout << "Could not create a swapchain." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( VK_NULL_HANDLE != old_swapchain ) {
|
||||
vkDestroySwapchainKHR( logical_device, old_swapchain, nullptr );
|
||||
old_swapchain = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,49 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 12 Creating a swapchain
|
||||
|
||||
#ifndef CREATING_A_SWAPCHAIN
|
||||
#define CREATING_A_SWAPCHAIN
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateSwapchain( VkDevice logical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
uint32_t image_count,
|
||||
VkSurfaceFormatKHR surface_format,
|
||||
VkExtent2D image_size,
|
||||
VkImageUsageFlags image_usage,
|
||||
VkSurfaceTransformFlagBitsKHR surface_transform,
|
||||
VkPresentModeKHR present_mode,
|
||||
VkSwapchainKHR & old_swapchain,
|
||||
VkSwapchainKHR & swapchain );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_SWAPCHAIN
|
||||
@ -1,57 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 13 Getting handles of swapchain images
|
||||
|
||||
#include "02 Image Presentation/13 Getting handles of swapchain images.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool GetHandlesOfSwapchainImages( VkDevice logical_device,
|
||||
VkSwapchainKHR swapchain,
|
||||
std::vector<VkImage> & swapchain_images ) {
|
||||
uint32_t images_count = 0;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
result = vkGetSwapchainImagesKHR( logical_device, swapchain, &images_count, nullptr );
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(0 == images_count) ) {
|
||||
std::cout << "Could not get the number of swapchain images." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
swapchain_images.resize( images_count );
|
||||
result = vkGetSwapchainImagesKHR( logical_device, swapchain, &images_count, swapchain_images.data() );
|
||||
if( (VK_SUCCESS != result) ||
|
||||
(0 == images_count) ) {
|
||||
std::cout << "Could not enumerate swapchain images." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 13 Getting handles of swapchain images
|
||||
|
||||
#ifndef GETTING_HANDLES_OF_SWAPCHAIN_IMAGES
|
||||
#define GETTING_HANDLES_OF_SWAPCHAIN_IMAGES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool GetHandlesOfSwapchainImages( VkDevice logical_device,
|
||||
VkSwapchainKHR swapchain,
|
||||
std::vector<VkImage> & swapchain_images );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // GETTING_HANDLES_OF_SWAPCHAIN_IMAGES
|
||||
@ -1,97 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 14 Creating a swapchain with R8G8B8A8 format and a MAILBOX present mode
|
||||
|
||||
#include "02 Image Presentation/05 Selecting a desired presentation mode.h"
|
||||
#include "02 Image Presentation/06 Getting capabilities of a presentation surface.h"
|
||||
#include "02 Image Presentation/07 Selecting a number of swapchain images.h"
|
||||
#include "02 Image Presentation/08 Choosing a size of swapchain images.h"
|
||||
#include "02 Image Presentation/09 Selecting desired usage scenarios of swapchain images.h"
|
||||
#include "02 Image Presentation/10 Selecting a transformation of swapchain images.h"
|
||||
#include "02 Image Presentation/11 Selecting a format of swapchain images.h"
|
||||
#include "02 Image Presentation/12 Creating a swapchain.h"
|
||||
#include "02 Image Presentation/13 Getting handles of swapchain images.h"
|
||||
#include "02 Image Presentation/14 Creating a swapchain with R8G8B8A8 format and a MAILBOX present mode.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateSwapchainWithR8G8B8A8FormatAndMailboxPresentMode( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkDevice logical_device,
|
||||
VkImageUsageFlags swapchain_image_usage,
|
||||
VkExtent2D & image_size,
|
||||
VkFormat & image_format,
|
||||
VkSwapchainKHR & old_swapchain,
|
||||
VkSwapchainKHR & swapchain,
|
||||
std::vector<VkImage> & swapchain_images ) {
|
||||
VkPresentModeKHR desired_present_mode;
|
||||
if( !SelectDesiredPresentationMode( physical_device, presentation_surface, VK_PRESENT_MODE_MAILBOX_KHR, desired_present_mode ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VkSurfaceCapabilitiesKHR surface_capabilities;
|
||||
if( !GetCapabilitiesOfPresentationSurface( physical_device, presentation_surface, surface_capabilities ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t number_of_images;
|
||||
if( !SelectNumberOfSwapchainImages( surface_capabilities, number_of_images ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !ChooseSizeOfSwapchainImages( surface_capabilities, image_size ) ) {
|
||||
return false;
|
||||
}
|
||||
if( (0 == image_size.width) ||
|
||||
(0 == image_size.height) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
VkImageUsageFlags image_usage;
|
||||
if( !SelectDesiredUsageScenariosOfSwapchainImages( surface_capabilities, swapchain_image_usage, image_usage ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
VkSurfaceTransformFlagBitsKHR surface_transform;
|
||||
SelectTransformationOfSwapchainImages( surface_capabilities, VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR, surface_transform );
|
||||
|
||||
VkColorSpaceKHR image_color_space;
|
||||
if( !SelectFormatOfSwapchainImages( physical_device, presentation_surface, { VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR }, image_format, image_color_space ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !CreateSwapchain( logical_device, presentation_surface, number_of_images, { image_format, image_color_space }, image_size, image_usage, surface_transform, desired_present_mode, old_swapchain, swapchain ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !GetHandlesOfSwapchainImages( logical_device, swapchain, swapchain_images ) ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,48 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 14 Creating a swapchain with R8G8B8A8 format and a MAILBOX present mode
|
||||
|
||||
#ifndef CREATING_A_SWAPCHAIN_WITH_R8G8B8A8_FORMAT_AND_A_MAILBOX_PRESENT_MODE
|
||||
#define CREATING_A_SWAPCHAIN_WITH_R8G8B8A8_FORMAT_AND_A_MAILBOX_PRESENT_MODE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateSwapchainWithR8G8B8A8FormatAndMailboxPresentMode( VkPhysicalDevice physical_device,
|
||||
VkSurfaceKHR presentation_surface,
|
||||
VkDevice logical_device,
|
||||
VkImageUsageFlags swapchain_image_usage,
|
||||
VkExtent2D & image_size,
|
||||
VkFormat & image_format,
|
||||
VkSwapchainKHR & old_swapchain,
|
||||
VkSwapchainKHR & swapchain,
|
||||
std::vector<VkImage> & swapchain_images );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_SWAPCHAIN_WITH_R8G8B8A8_FORMAT_AND_A_MAILBOX_PRESENT_MODE
|
||||
@ -1,50 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 15 Acquiring a swapchain image
|
||||
|
||||
#include "02 Image Presentation/15 Acquiring a swapchain image.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool AcquireSwapchainImage( VkDevice logical_device,
|
||||
VkSwapchainKHR swapchain,
|
||||
VkSemaphore semaphore,
|
||||
VkFence fence,
|
||||
uint32_t & image_index ) {
|
||||
VkResult result;
|
||||
|
||||
result = vkAcquireNextImageKHR( logical_device, swapchain, 2000000000, semaphore, fence, &image_index );
|
||||
switch( result ) {
|
||||
case VK_SUCCESS:
|
||||
case VK_SUBOPTIMAL_KHR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 15 Acquiring a swapchain image
|
||||
|
||||
#ifndef ACQUIRING_A_SWAPCHAIN_IMAGE
|
||||
#define ACQUIRING_A_SWAPCHAIN_IMAGE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool AcquireSwapchainImage( VkDevice logical_device,
|
||||
VkSwapchainKHR swapchain,
|
||||
VkSemaphore semaphore,
|
||||
VkFence fence,
|
||||
uint32_t & image_index );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // ACQUIRING_A_SWAPCHAIN_IMAGE
|
||||
@ -1,65 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 16 Presenting an image
|
||||
|
||||
#include "02 Image Presentation/16 Presenting an image.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool PresentImage( VkQueue queue,
|
||||
std::vector<VkSemaphore> rendering_semaphores,
|
||||
std::vector<PresentInfo> images_to_present ) {
|
||||
VkResult result;
|
||||
std::vector<VkSwapchainKHR> swapchains;
|
||||
std::vector<uint32_t> image_indices;
|
||||
|
||||
for( auto & image_to_present : images_to_present ) {
|
||||
swapchains.emplace_back( image_to_present.Swapchain );
|
||||
image_indices.emplace_back( image_to_present.ImageIndex );
|
||||
}
|
||||
|
||||
VkPresentInfoKHR present_info = {
|
||||
VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, // VkStructureType sType
|
||||
nullptr, // const void* pNext
|
||||
static_cast<uint32_t>(rendering_semaphores.size()), // uint32_t waitSemaphoreCount
|
||||
rendering_semaphores.data(), // const VkSemaphore * pWaitSemaphores
|
||||
static_cast<uint32_t>(swapchains.size()), // uint32_t swapchainCount
|
||||
swapchains.data(), // const VkSwapchainKHR * pSwapchains
|
||||
image_indices.data(), // const uint32_t * pImageIndices
|
||||
nullptr // VkResult* pResults
|
||||
};
|
||||
|
||||
result = vkQueuePresentKHR( queue, &present_info );
|
||||
switch( result ) {
|
||||
case VK_SUCCESS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,47 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 16 Presenting an image
|
||||
|
||||
#ifndef PRESENTING_AN_IMAGE
|
||||
#define PRESENTING_AN_IMAGE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
struct PresentInfo {
|
||||
VkSwapchainKHR Swapchain;
|
||||
uint32_t ImageIndex;
|
||||
};
|
||||
|
||||
bool PresentImage( VkQueue queue,
|
||||
std::vector<VkSemaphore> rendering_semaphores,
|
||||
std::vector<PresentInfo> images_to_present );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // PRESENTING_AN_IMAGE
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 17 Destroying a swapchain
|
||||
|
||||
#include "02 Image Presentation/17 Destroying a swapchain.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroySwapchain( VkDevice logical_device,
|
||||
VkSwapchainKHR & swapchain ) {
|
||||
if( swapchain ) {
|
||||
vkDestroySwapchainKHR( logical_device, swapchain, nullptr );
|
||||
swapchain = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 17 Destroying a swapchain
|
||||
|
||||
#ifndef DESTROYING_A_SWAPCHAIN
|
||||
#define DESTROYING_A_SWAPCHAIN
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroySwapchain( VkDevice logical_device,
|
||||
VkSwapchainKHR & swapchain );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // DESTROYING_A_SWAPCHAIN
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 18 Destroying a presentation surface
|
||||
|
||||
#include "02 Image Presentation/18 Destroying a presentation surface.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroyPresentationSurface( VkInstance instance,
|
||||
VkSurfaceKHR & presentation_surface ) {
|
||||
if( presentation_surface ) {
|
||||
vkDestroySurfaceKHR( instance, presentation_surface, nullptr );
|
||||
presentation_surface = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 02 Image Presentation
|
||||
// Recipe: 18 Destroying a presentation surface
|
||||
|
||||
#ifndef DESTROYING_A_PRESENTATION_SURFACE
|
||||
#define DESTROYING_A_PRESENTATION_SURFACE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
void DestroyPresentationSurface( VkInstance instance,
|
||||
VkSurfaceKHR & presentation_surface );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // DESTROYING_A_PRESENTATION_SURFACE
|
||||
@ -1,52 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 01 Creating a command pool
|
||||
|
||||
#include "03 Command Buffers and Synchronization/01 Creating a command pool.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateCommandPool( VkDevice logical_device,
|
||||
VkCommandPoolCreateFlags parameters,
|
||||
uint32_t queue_family,
|
||||
VkCommandPool & command_pool ) {
|
||||
VkCommandPoolCreateInfo command_pool_create_info = {
|
||||
VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
parameters, // VkCommandPoolCreateFlags flags
|
||||
queue_family // uint32_t queueFamilyIndex
|
||||
};
|
||||
|
||||
VkResult result = vkCreateCommandPool( logical_device, &command_pool_create_info, nullptr, &command_pool );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Could not create command pool." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,43 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 01 Creating a command pool
|
||||
|
||||
#ifndef CREATING_A_COMMAND_POOL
|
||||
#define CREATING_A_COMMAND_POOL
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateCommandPool( VkDevice logical_device,
|
||||
VkCommandPoolCreateFlags command_pool_flags,
|
||||
uint32_t queue_family,
|
||||
VkCommandPool & command_pool );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_COMMAND_POOL
|
||||
@ -1,56 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 02 Allocating command buffers
|
||||
|
||||
#include "03 Command Buffers and Synchronization/02 Allocating command buffers.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool AllocateCommandBuffers( VkDevice logical_device,
|
||||
VkCommandPool command_pool,
|
||||
VkCommandBufferLevel level,
|
||||
uint32_t count,
|
||||
std::vector<VkCommandBuffer> & command_buffers ) {
|
||||
VkCommandBufferAllocateInfo command_buffer_allocate_info = {
|
||||
VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
command_pool, // VkCommandPool commandPool
|
||||
level, // VkCommandBufferLevel level
|
||||
count // uint32_t commandBufferCount
|
||||
};
|
||||
|
||||
command_buffers.resize( count );
|
||||
|
||||
VkResult result = vkAllocateCommandBuffers( logical_device, &command_buffer_allocate_info, command_buffers.data() );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Could not allocate command buffers." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 02 Allocating command buffers
|
||||
|
||||
#ifndef ALLOCATING_COMMAND_BUFFERS
|
||||
#define ALLOCATING_COMMAND_BUFFERS
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool AllocateCommandBuffers( VkDevice logical_device,
|
||||
VkCommandPool command_pool,
|
||||
VkCommandBufferLevel level,
|
||||
uint32_t count,
|
||||
std::vector<VkCommandBuffer> & command_buffers );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // ALLOCATING_COMMAND_BUFFERS
|
||||
@ -1,51 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 03 Beginning a command buffer recording operation
|
||||
|
||||
#include "03 Command Buffers and Synchronization/03 Beginning a command buffer recording operation.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool BeginCommandBufferRecordingOperation( VkCommandBuffer command_buffer,
|
||||
VkCommandBufferUsageFlags usage,
|
||||
VkCommandBufferInheritanceInfo * secondary_command_buffer_info ) {
|
||||
VkCommandBufferBeginInfo command_buffer_begin_info = {
|
||||
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
usage, // VkCommandBufferUsageFlags flags
|
||||
secondary_command_buffer_info // const VkCommandBufferInheritanceInfo * pInheritanceInfo
|
||||
};
|
||||
|
||||
VkResult result = vkBeginCommandBuffer( command_buffer, &command_buffer_begin_info );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Could not begin command buffer recording operation." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 03 Beginning a command buffer recording operation
|
||||
|
||||
#ifndef BEGINNING_A_COMMAND_BUFFER_RECORDING_OPERATION
|
||||
#define BEGINNING_A_COMMAND_BUFFER_RECORDING_OPERATION
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool BeginCommandBufferRecordingOperation( VkCommandBuffer command_buffer,
|
||||
VkCommandBufferUsageFlags usage,
|
||||
VkCommandBufferInheritanceInfo * secondary_command_buffer_info );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // BEGINNING_A_COMMAND_BUFFER_RECORDING_OPERATION
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 04 Ending a command buffer recording operation
|
||||
|
||||
#include "03 Command Buffers and Synchronization/04 Ending a command buffer recording operation.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool EndCommandBufferRecordingOperation( VkCommandBuffer command_buffer ) {
|
||||
VkResult result = vkEndCommandBuffer( command_buffer );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Error occurred during command buffer recording." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,40 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 04 Ending a command buffer recording operation
|
||||
|
||||
#ifndef ENDING_A_COMMAND_BUFFER_RECORDING_OPERATION
|
||||
#define ENDING_A_COMMAND_BUFFER_RECORDING_OPERATION
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool EndCommandBufferRecordingOperation( VkCommandBuffer command_buffer );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // ENDING_A_COMMAND_BUFFER_RECORDING_OPERATIONko
|
||||
@ -1,43 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 05 Resetting a command buffer
|
||||
|
||||
#include "03 Command Buffers and Synchronization/05 Resetting a command buffer.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ResetCommandBuffer( VkCommandBuffer command_buffer,
|
||||
bool release_resources ) {
|
||||
VkResult result = vkResetCommandBuffer( command_buffer, release_resources ? VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT : 0 );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Error occurred during command buffer reset." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 05 Resetting a command buffer
|
||||
|
||||
#ifndef RESETTING_A_COMMAND_BUFFER
|
||||
#define RESETTING_A_COMMAND_BUFFER
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ResetCommandBuffer( VkCommandBuffer command_buffer,
|
||||
bool release_resources );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // RESETTING_A_COMMAND_BUFFER
|
||||
@ -1,44 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 06 Resetting a command pool
|
||||
|
||||
#include "03 Command Buffers and Synchronization/06 Resetting a command pool.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ResetCommandPool( VkDevice logical_device,
|
||||
VkCommandPool command_pool,
|
||||
bool release_resources ) {
|
||||
VkResult result = vkResetCommandPool( logical_device, command_pool, release_resources ? VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT : 0 );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Error occurred during command pool reset." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 06 Resetting a command pool
|
||||
|
||||
#ifndef RESETTING_A_COMMAND_POOL
|
||||
#define RESETTING_A_COMMAND_POOL
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ResetCommandPool( VkDevice logical_device,
|
||||
VkCommandPool command_pool,
|
||||
bool release_resources );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // RESETTING_A_COMMAND_POOL
|
||||
@ -1,49 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 07 Creating a semaphore
|
||||
|
||||
#include "03 Command Buffers and Synchronization/07 Creating a semaphore.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateSemaphore( VkDevice logical_device,
|
||||
VkSemaphore & semaphore ) {
|
||||
VkSemaphoreCreateInfo semaphore_create_info = {
|
||||
VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
0 // VkSemaphoreCreateFlags flags
|
||||
};
|
||||
|
||||
VkResult result = vkCreateSemaphore( logical_device, &semaphore_create_info, nullptr, &semaphore );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Could not create a semaphore." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,41 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 07 Creating a semaphore
|
||||
|
||||
#ifndef CREATING_A_SEMAPHORE
|
||||
#define CREATING_A_SEMAPHORE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateSemaphore( VkDevice logical_device,
|
||||
VkSemaphore & semaphore );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_SEMAPHORE
|
||||
@ -1,50 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 08 Creating a fence
|
||||
|
||||
#include "03 Command Buffers and Synchronization/08 Creating a fence.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateFence( VkDevice logical_device,
|
||||
bool signaled,
|
||||
VkFence & fence ) {
|
||||
VkFenceCreateInfo fence_create_info = {
|
||||
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void * pNext
|
||||
signaled ? VK_FENCE_CREATE_SIGNALED_BIT : 0u, // VkFenceCreateFlags flags
|
||||
};
|
||||
|
||||
VkResult result = vkCreateFence( logical_device, &fence_create_info, nullptr, &fence );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Could not create a fence." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,42 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 08 Creating a fence
|
||||
|
||||
#ifndef CREATING_A_FENCE
|
||||
#define CREATING_A_FENCE
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool CreateFence( VkDevice logical_device,
|
||||
bool signaled,
|
||||
VkFence & fence );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // CREATING_A_FENCE
|
||||
@ -1,48 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// © Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 09 Waiting for fences
|
||||
|
||||
#include "03 Command Buffers and Synchronization/09 Waiting for fences.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool WaitForFences( VkDevice logical_device,
|
||||
std::vector<VkFence> const & fences,
|
||||
VkBool32 wait_for_all,
|
||||
uint64_t timeout ) {
|
||||
if( fences.size() > 0 ) {
|
||||
VkResult result = vkWaitForFences( logical_device, static_cast<uint32_t>(fences.size()), fences.data(), wait_for_all, timeout );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Waiting on fence failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
@ -1,43 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// ?Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 09 Waiting for fences
|
||||
|
||||
#ifndef WAITING_FOR_FENCES
|
||||
#define WAITING_FOR_FENCES
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool WaitForFences( VkDevice logical_device,
|
||||
std::vector<VkFence> const & fences,
|
||||
VkBool32 wait_for_all,
|
||||
uint64_t timeout );
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
|
||||
#endif // WAITING_FOR_FENCES
|
||||
@ -1,46 +0,0 @@
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and / or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The below copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// Vulkan Cookbook
|
||||
// ISBN: 9781786468154
|
||||
// © Packt Publishing Limited
|
||||
//
|
||||
// Author: Pawel Lapinski
|
||||
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
|
||||
//
|
||||
// Chapter: 03 Command Buffers and Synchronization
|
||||
// Recipe: 10 Resetting fences
|
||||
|
||||
#include "03 Command Buffers and Synchronization/10 Resetting fences.h"
|
||||
|
||||
namespace VulkanCookbook {
|
||||
|
||||
bool ResetFences( VkDevice logical_device,
|
||||
std::vector<VkFence> const & fences ) {
|
||||
if( fences.size() > 0 ) {
|
||||
VkResult result = vkResetFences( logical_device, static_cast<uint32_t>(fences.size()), fences.data() );
|
||||
if( VK_SUCCESS != result ) {
|
||||
std::cout << "Error occurred when tried to reset fences." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return VK_SUCCESS == result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace VulkanCookbook
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user