mirror of
https://github.com/opus-tango/IntroductionToVulkan.git
synced 2026-03-19 19:52:51 +00:00
Updated License to Apache 2.0
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
# Copyright 2016 Intel Corporation All Rights Reserved
|
||||
#
|
||||
# Intel makes no representations about the suitability of this software for any purpose.
|
||||
# THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
# EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
# FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
# RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# Intel does not assume any responsibility for any errors which may appear in this software
|
||||
# nor any responsibility to update it.
|
||||
# /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
# // Copyright 2017 Intel Corporation
|
||||
# //
|
||||
# // Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# // you may not use this file except in compliance with the License.
|
||||
# // You may obtain a copy of the License at
|
||||
# //
|
||||
# // http://www.apache.org/licenses/LICENSE-2.0
|
||||
# //
|
||||
# // Unless required by applicable law or agreed to in writing, software
|
||||
# // distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# // See the License for the specific language governing permissions and
|
||||
# // limitations under the License.
|
||||
# /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
project( "IntroductionToVulkan" )
|
||||
|
||||
@@ -1,179 +1,175 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
// ************************************************************ //
|
||||
// Exported functions //
|
||||
// //
|
||||
// These functions are always exposed by vulkan libraries. //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_EXPORTED_FUNCTION)
|
||||
#define VK_EXPORTED_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
VK_EXPORTED_FUNCTION( vkGetInstanceProcAddr )
|
||||
|
||||
#undef VK_EXPORTED_FUNCTION
|
||||
|
||||
|
||||
// ************************************************************ //
|
||||
// Global level functions //
|
||||
// //
|
||||
// They allow checking what instance extensions are available //
|
||||
// and allow creation of a Vulkan Instance. //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_GLOBAL_LEVEL_FUNCTION)
|
||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
// Tutorial 01
|
||||
VK_GLOBAL_LEVEL_FUNCTION( vkCreateInstance )
|
||||
|
||||
// Tutorial 02
|
||||
VK_GLOBAL_LEVEL_FUNCTION( vkEnumerateInstanceExtensionProperties )
|
||||
|
||||
#undef VK_GLOBAL_LEVEL_FUNCTION
|
||||
|
||||
|
||||
// ************************************************************ //
|
||||
// Instance level functions //
|
||||
// //
|
||||
// These functions allow for device queries and creation. //
|
||||
// They help choose which device is well suited for our needs. //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_INSTANCE_LEVEL_FUNCTION)
|
||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
// Tutorial 01
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkEnumeratePhysicalDevices )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceProperties )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceFeatures )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceQueueFamilyProperties )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateDevice )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetDeviceProcAddr )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkDestroyInstance )
|
||||
|
||||
// Tutorial 02
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkEnumerateDeviceExtensionProperties )
|
||||
#if defined(USE_SWAPCHAIN_EXTENSIONS)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceSupportKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceCapabilitiesKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceFormatsKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfacePresentModesKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkDestroySurfaceKHR )
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateWin32SurfaceKHR )
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXcbSurfaceKHR )
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXlibSurfaceKHR )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Tutorial 04
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceMemoryProperties )
|
||||
|
||||
#undef VK_INSTANCE_LEVEL_FUNCTION
|
||||
|
||||
|
||||
// ************************************************************ //
|
||||
// Device level functions //
|
||||
// //
|
||||
// These functions are used mainly for drawing //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_DEVICE_LEVEL_FUNCTION)
|
||||
#define VK_DEVICE_LEVEL_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
// Tutorial 01
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetDeviceQueue )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDeviceWaitIdle )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDevice )
|
||||
|
||||
// Tutorial 02
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateSemaphore )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateCommandPool )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkAllocateCommandBuffers )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkBeginCommandBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdPipelineBarrier )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdClearColorImage )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkEndCommandBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkQueueSubmit )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkFreeCommandBuffers )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyCommandPool )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroySemaphore )
|
||||
#if defined(USE_SWAPCHAIN_EXTENSIONS)
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateSwapchainKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetSwapchainImagesKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkAcquireNextImageKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkQueuePresentKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroySwapchainKHR )
|
||||
#endif
|
||||
|
||||
// Tutorial 03
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateImageView )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateFramebuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateShaderModule )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreatePipelineLayout )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateGraphicsPipelines )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdBeginRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindPipeline )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdDraw )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdEndRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyShaderModule )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipelineLayout )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipeline )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFramebuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyImageView )
|
||||
|
||||
// Tutorial 04
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateFence )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetBufferMemoryRequirements )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkAllocateMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkBindBufferMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkMapMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkFlushMappedMemoryRanges )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkUnmapMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetViewport )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetScissor )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindVertexBuffers )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkWaitForFences )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkResetFences )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkFreeMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFence )
|
||||
|
||||
// Tutorial 05
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBuffer )
|
||||
|
||||
// Tutorial 06
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateImage )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetImageMemoryRequirements )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkBindImageMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateSampler )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBufferToImage )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorSetLayout )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorPool )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkAllocateDescriptorSets )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkUpdateDescriptorSets )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindDescriptorSets )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorPool )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorSetLayout )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroySampler )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyImage )
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ************************************************************ //
|
||||
// Exported functions //
|
||||
// //
|
||||
// These functions are always exposed by vulkan libraries. //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_EXPORTED_FUNCTION)
|
||||
#define VK_EXPORTED_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
VK_EXPORTED_FUNCTION( vkGetInstanceProcAddr )
|
||||
|
||||
#undef VK_EXPORTED_FUNCTION
|
||||
|
||||
|
||||
// ************************************************************ //
|
||||
// Global level functions //
|
||||
// //
|
||||
// They allow checking what instance extensions are available //
|
||||
// and allow creation of a Vulkan Instance. //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_GLOBAL_LEVEL_FUNCTION)
|
||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
// Tutorial 01
|
||||
VK_GLOBAL_LEVEL_FUNCTION( vkCreateInstance )
|
||||
|
||||
// Tutorial 02
|
||||
VK_GLOBAL_LEVEL_FUNCTION( vkEnumerateInstanceExtensionProperties )
|
||||
|
||||
#undef VK_GLOBAL_LEVEL_FUNCTION
|
||||
|
||||
|
||||
// ************************************************************ //
|
||||
// Instance level functions //
|
||||
// //
|
||||
// These functions allow for device queries and creation. //
|
||||
// They help choose which device is well suited for our needs. //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_INSTANCE_LEVEL_FUNCTION)
|
||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
// Tutorial 01
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkEnumeratePhysicalDevices )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceProperties )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceFeatures )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceQueueFamilyProperties )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateDevice )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetDeviceProcAddr )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkDestroyInstance )
|
||||
|
||||
// Tutorial 02
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkEnumerateDeviceExtensionProperties )
|
||||
#if defined(USE_SWAPCHAIN_EXTENSIONS)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceSupportKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceCapabilitiesKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceFormatsKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfacePresentModesKHR )
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkDestroySurfaceKHR )
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateWin32SurfaceKHR )
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXcbSurfaceKHR )
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXlibSurfaceKHR )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Tutorial 04
|
||||
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceMemoryProperties )
|
||||
|
||||
#undef VK_INSTANCE_LEVEL_FUNCTION
|
||||
|
||||
|
||||
// ************************************************************ //
|
||||
// Device level functions //
|
||||
// //
|
||||
// These functions are used mainly for drawing //
|
||||
// ************************************************************ //
|
||||
|
||||
#if !defined(VK_DEVICE_LEVEL_FUNCTION)
|
||||
#define VK_DEVICE_LEVEL_FUNCTION( fun )
|
||||
#endif
|
||||
|
||||
// Tutorial 01
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetDeviceQueue )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDeviceWaitIdle )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDevice )
|
||||
|
||||
// Tutorial 02
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateSemaphore )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateCommandPool )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkAllocateCommandBuffers )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkBeginCommandBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdPipelineBarrier )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdClearColorImage )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkEndCommandBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkQueueSubmit )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkFreeCommandBuffers )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyCommandPool )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroySemaphore )
|
||||
#if defined(USE_SWAPCHAIN_EXTENSIONS)
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateSwapchainKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetSwapchainImagesKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkAcquireNextImageKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkQueuePresentKHR )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroySwapchainKHR )
|
||||
#endif
|
||||
|
||||
// Tutorial 03
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateImageView )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateFramebuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateShaderModule )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreatePipelineLayout )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateGraphicsPipelines )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdBeginRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindPipeline )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdDraw )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdEndRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyShaderModule )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipelineLayout )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipeline )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyRenderPass )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFramebuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyImageView )
|
||||
|
||||
// Tutorial 04
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateFence )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetBufferMemoryRequirements )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkAllocateMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkBindBufferMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkMapMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkFlushMappedMemoryRanges )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkUnmapMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetViewport )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetScissor )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindVertexBuffers )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkWaitForFences )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkResetFences )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkFreeMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyBuffer )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFence )
|
||||
|
||||
// Tutorial 05
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBuffer )
|
||||
|
||||
// Tutorial 06
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateImage )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkGetImageMemoryRequirements )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkBindImageMemory )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateSampler )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBufferToImage )
|
||||
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorSetLayout )
|
||||
@@ -1,379 +1,375 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace OS {
|
||||
|
||||
Window::Window() :
|
||||
Parameters() {
|
||||
}
|
||||
|
||||
WindowParameters Window::GetParameters() const {
|
||||
return Parameters;
|
||||
}
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
|
||||
#define TUTORIAL_NAME "API without Secrets: Introduction to Vulkan"
|
||||
|
||||
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
|
||||
switch( message ) {
|
||||
case WM_SIZE:
|
||||
case WM_EXITSIZEMOVE:
|
||||
PostMessage( hWnd, WM_USER + 1, wParam, lParam );
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
case WM_CLOSE:
|
||||
PostMessage( hWnd, WM_USER + 2, wParam, lParam );
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
if( Parameters.Handle ) {
|
||||
DestroyWindow( Parameters.Handle );
|
||||
}
|
||||
|
||||
if( Parameters.Instance ) {
|
||||
UnregisterClass( TUTORIAL_NAME, Parameters.Instance );
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::Create( const char *title ) {
|
||||
Parameters.Instance = GetModuleHandle( nullptr );
|
||||
|
||||
// Register window class
|
||||
WNDCLASSEX wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = Parameters.Instance;
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = TUTORIAL_NAME;
|
||||
wcex.hIconSm = NULL;
|
||||
|
||||
if( !RegisterClassEx( &wcex ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create window
|
||||
Parameters.Handle = CreateWindow( TUTORIAL_NAME, title, WS_OVERLAPPEDWINDOW, 20, 20, 500, 500, nullptr, nullptr, Parameters.Instance, nullptr );
|
||||
if( !Parameters.Handle ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
|
||||
// Display window
|
||||
ShowWindow( Parameters.Handle, SW_SHOWNORMAL );
|
||||
UpdateWindow( Parameters.Handle );
|
||||
|
||||
// Main message loop
|
||||
MSG message;
|
||||
bool loop = true;
|
||||
bool resize = false;
|
||||
bool result = true;
|
||||
|
||||
while( loop ) {
|
||||
if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) ) {
|
||||
// Process events
|
||||
switch( message.message ) {
|
||||
// Resize
|
||||
case WM_USER + 1:
|
||||
resize = true;
|
||||
break;
|
||||
// Close
|
||||
case WM_USER + 2:
|
||||
loop = false;
|
||||
break;
|
||||
}
|
||||
TranslateMessage( &message );
|
||||
DispatchMessage( &message );
|
||||
} else {
|
||||
// Draw
|
||||
if( resize ) {
|
||||
resize = false;
|
||||
if( !tutorial.OnWindowSizeChanged() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( tutorial.ReadyToDraw() ) {
|
||||
if( !tutorial.Draw() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
|
||||
Window::~Window() {
|
||||
xcb_destroy_window( Parameters.Connection, Parameters.Handle );
|
||||
xcb_disconnect( Parameters.Connection );
|
||||
}
|
||||
|
||||
bool Window::Create( const char *title ) {
|
||||
int screen_index;
|
||||
Parameters.Connection = xcb_connect( nullptr, &screen_index );
|
||||
|
||||
if( !Parameters.Connection ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const xcb_setup_t *setup = xcb_get_setup( Parameters.Connection );
|
||||
xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator( setup );
|
||||
|
||||
while( screen_index-- > 0 ) {
|
||||
xcb_screen_next( &screen_iterator );
|
||||
}
|
||||
|
||||
xcb_screen_t *screen = screen_iterator.data;
|
||||
|
||||
Parameters.Handle = xcb_generate_id( Parameters.Connection );
|
||||
|
||||
uint32_t value_list[] = {
|
||||
screen->white_pixel,
|
||||
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||
};
|
||||
|
||||
xcb_create_window(
|
||||
Parameters.Connection,
|
||||
XCB_COPY_FROM_PARENT,
|
||||
Parameters.Handle,
|
||||
screen->root,
|
||||
20,
|
||||
20,
|
||||
500,
|
||||
500,
|
||||
0,
|
||||
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
screen->root_visual,
|
||||
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
|
||||
value_list );
|
||||
|
||||
xcb_flush( Parameters.Connection );
|
||||
|
||||
xcb_change_property(
|
||||
Parameters.Connection,
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
Parameters.Handle,
|
||||
XCB_ATOM_WM_NAME,
|
||||
XCB_ATOM_STRING,
|
||||
8,
|
||||
strlen( title ),
|
||||
title );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
|
||||
// Prepare notification for window destruction
|
||||
xcb_intern_atom_cookie_t protocols_cookie = xcb_intern_atom( Parameters.Connection, 1, 12, "WM_PROTOCOLS" );
|
||||
xcb_intern_atom_reply_t *protocols_reply = xcb_intern_atom_reply( Parameters.Connection, protocols_cookie, 0 );
|
||||
xcb_intern_atom_cookie_t delete_cookie = xcb_intern_atom( Parameters.Connection, 0, 16, "WM_DELETE_WINDOW" );
|
||||
xcb_intern_atom_reply_t *delete_reply = xcb_intern_atom_reply( Parameters.Connection, delete_cookie, 0 );
|
||||
xcb_change_property( Parameters.Connection, XCB_PROP_MODE_REPLACE, Parameters.Handle, (*protocols_reply).atom, 4, 32, 1, &(*delete_reply).atom );
|
||||
free( protocols_reply );
|
||||
|
||||
// Display window
|
||||
xcb_map_window( Parameters.Connection, Parameters.Handle );
|
||||
xcb_flush( Parameters.Connection );
|
||||
|
||||
// Main message loop
|
||||
xcb_generic_event_t *event;
|
||||
bool loop = true;
|
||||
bool resize = false;
|
||||
bool result = true;
|
||||
|
||||
while( loop ) {
|
||||
event = xcb_poll_for_event( Parameters.Connection );
|
||||
|
||||
if( event ) {
|
||||
// Process events
|
||||
switch (event->response_type & 0x7f) {
|
||||
// Resize
|
||||
case XCB_CONFIGURE_NOTIFY: {
|
||||
xcb_configure_notify_event_t *configure_event = (xcb_configure_notify_event_t*)event;
|
||||
static uint16_t width = configure_event->width;
|
||||
static uint16_t height = configure_event->height;
|
||||
|
||||
if( ((configure_event->width > 0) && (width != configure_event->width)) ||
|
||||
((configure_event->height > 0) && (height != configure_event->height)) ) {
|
||||
resize = true;
|
||||
width = configure_event->width;
|
||||
height = configure_event->height;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Close
|
||||
case XCB_CLIENT_MESSAGE:
|
||||
if( (*(xcb_client_message_event_t*)event).data.data32[0] == (*delete_reply).atom ) {
|
||||
loop = false;
|
||||
free( delete_reply );
|
||||
}
|
||||
break;
|
||||
case XCB_KEY_PRESS:
|
||||
loop = false;
|
||||
break;
|
||||
}
|
||||
free( event );
|
||||
} else {
|
||||
// Draw
|
||||
if( resize ) {
|
||||
resize = false;
|
||||
if( !tutorial.OnWindowSizeChanged() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( tutorial.ReadyToDraw() ) {
|
||||
if( !tutorial.Draw() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
|
||||
Window::~Window() {
|
||||
XDestroyWindow( Parameters.DisplayPtr, Parameters.Handle );
|
||||
XCloseDisplay( Parameters.DisplayPtr );
|
||||
}
|
||||
|
||||
bool Window::Create( const char *title ) {
|
||||
Parameters.DisplayPtr = XOpenDisplay( nullptr );
|
||||
if( !Parameters.DisplayPtr ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int default_screen = DefaultScreen( Parameters.DisplayPtr );
|
||||
|
||||
Parameters.Handle = XCreateSimpleWindow(
|
||||
Parameters.DisplayPtr,
|
||||
DefaultRootWindow( Parameters.DisplayPtr ),
|
||||
20,
|
||||
20,
|
||||
500,
|
||||
500,
|
||||
1,
|
||||
BlackPixel( Parameters.DisplayPtr, default_screen ),
|
||||
WhitePixel( Parameters.DisplayPtr, default_screen ) );
|
||||
|
||||
// XSync( Parameters.DisplayPtr, false );
|
||||
XSetStandardProperties( Parameters.DisplayPtr, Parameters.Handle, title, title, None, nullptr, 0, nullptr );
|
||||
XSelectInput( Parameters.DisplayPtr, Parameters.Handle, ExposureMask | KeyPressMask | StructureNotifyMask );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
|
||||
// Prepare notification for window destruction
|
||||
Atom delete_window_atom;
|
||||
delete_window_atom = XInternAtom( Parameters.DisplayPtr, "WM_DELETE_WINDOW", false );
|
||||
XSetWMProtocols( Parameters.DisplayPtr, Parameters.Handle, &delete_window_atom, 1);
|
||||
|
||||
// Display window
|
||||
XClearWindow( Parameters.DisplayPtr, Parameters.Handle );
|
||||
XMapWindow( Parameters.DisplayPtr, Parameters.Handle );
|
||||
|
||||
// Main message loop
|
||||
XEvent event;
|
||||
bool loop = true;
|
||||
bool resize = false;
|
||||
bool result = true;
|
||||
|
||||
while( loop ) {
|
||||
if( XPending( Parameters.DisplayPtr ) ) {
|
||||
XNextEvent( Parameters.DisplayPtr, &event );
|
||||
switch( event.type ) {
|
||||
//Process events
|
||||
case ConfigureNotify: {
|
||||
static int width = event.xconfigure.width;
|
||||
static int height = event.xconfigure.height;
|
||||
|
||||
if( ((event.xconfigure.width > 0) && (event.xconfigure.width != width)) ||
|
||||
((event.xconfigure.height > 0) && (event.xconfigure.width != height)) ) {
|
||||
width = event.xconfigure.width;
|
||||
height = event.xconfigure.height;
|
||||
resize = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyPress:
|
||||
loop = false;
|
||||
break;
|
||||
case DestroyNotify:
|
||||
loop = false;
|
||||
break;
|
||||
case ClientMessage:
|
||||
if( static_cast<unsigned int>(event.xclient.data.l[0]) == delete_window_atom ) {
|
||||
loop = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Draw
|
||||
if( resize ) {
|
||||
resize = false;
|
||||
if( !tutorial.OnWindowSizeChanged() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( tutorial.ReadyToDraw() ) {
|
||||
if( !tutorial.Draw() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace OS
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace OS {
|
||||
|
||||
Window::Window() :
|
||||
Parameters() {
|
||||
}
|
||||
|
||||
WindowParameters Window::GetParameters() const {
|
||||
return Parameters;
|
||||
}
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
|
||||
#define TUTORIAL_NAME "API without Secrets: Introduction to Vulkan"
|
||||
|
||||
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
|
||||
switch( message ) {
|
||||
case WM_SIZE:
|
||||
case WM_EXITSIZEMOVE:
|
||||
PostMessage( hWnd, WM_USER + 1, wParam, lParam );
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
case WM_CLOSE:
|
||||
PostMessage( hWnd, WM_USER + 2, wParam, lParam );
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
if( Parameters.Handle ) {
|
||||
DestroyWindow( Parameters.Handle );
|
||||
}
|
||||
|
||||
if( Parameters.Instance ) {
|
||||
UnregisterClass( TUTORIAL_NAME, Parameters.Instance );
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::Create( const char *title ) {
|
||||
Parameters.Instance = GetModuleHandle( nullptr );
|
||||
|
||||
// Register window class
|
||||
WNDCLASSEX wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = Parameters.Instance;
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||
wcex.lpszMenuName = NULL;
|
||||
wcex.lpszClassName = TUTORIAL_NAME;
|
||||
wcex.hIconSm = NULL;
|
||||
|
||||
if( !RegisterClassEx( &wcex ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create window
|
||||
Parameters.Handle = CreateWindow( TUTORIAL_NAME, title, WS_OVERLAPPEDWINDOW, 20, 20, 500, 500, nullptr, nullptr, Parameters.Instance, nullptr );
|
||||
if( !Parameters.Handle ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
|
||||
// Display window
|
||||
ShowWindow( Parameters.Handle, SW_SHOWNORMAL );
|
||||
UpdateWindow( Parameters.Handle );
|
||||
|
||||
// Main message loop
|
||||
MSG message;
|
||||
bool loop = true;
|
||||
bool resize = false;
|
||||
bool result = true;
|
||||
|
||||
while( loop ) {
|
||||
if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) ) {
|
||||
// Process events
|
||||
switch( message.message ) {
|
||||
// Resize
|
||||
case WM_USER + 1:
|
||||
resize = true;
|
||||
break;
|
||||
// Close
|
||||
case WM_USER + 2:
|
||||
loop = false;
|
||||
break;
|
||||
}
|
||||
TranslateMessage( &message );
|
||||
DispatchMessage( &message );
|
||||
} else {
|
||||
// Draw
|
||||
if( resize ) {
|
||||
resize = false;
|
||||
if( !tutorial.OnWindowSizeChanged() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( tutorial.ReadyToDraw() ) {
|
||||
if( !tutorial.Draw() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
|
||||
Window::~Window() {
|
||||
xcb_destroy_window( Parameters.Connection, Parameters.Handle );
|
||||
xcb_disconnect( Parameters.Connection );
|
||||
}
|
||||
|
||||
bool Window::Create( const char *title ) {
|
||||
int screen_index;
|
||||
Parameters.Connection = xcb_connect( nullptr, &screen_index );
|
||||
|
||||
if( !Parameters.Connection ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const xcb_setup_t *setup = xcb_get_setup( Parameters.Connection );
|
||||
xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator( setup );
|
||||
|
||||
while( screen_index-- > 0 ) {
|
||||
xcb_screen_next( &screen_iterator );
|
||||
}
|
||||
|
||||
xcb_screen_t *screen = screen_iterator.data;
|
||||
|
||||
Parameters.Handle = xcb_generate_id( Parameters.Connection );
|
||||
|
||||
uint32_t value_list[] = {
|
||||
screen->white_pixel,
|
||||
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||
};
|
||||
|
||||
xcb_create_window(
|
||||
Parameters.Connection,
|
||||
XCB_COPY_FROM_PARENT,
|
||||
Parameters.Handle,
|
||||
screen->root,
|
||||
20,
|
||||
20,
|
||||
500,
|
||||
500,
|
||||
0,
|
||||
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
screen->root_visual,
|
||||
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
|
||||
value_list );
|
||||
|
||||
xcb_flush( Parameters.Connection );
|
||||
|
||||
xcb_change_property(
|
||||
Parameters.Connection,
|
||||
XCB_PROP_MODE_REPLACE,
|
||||
Parameters.Handle,
|
||||
XCB_ATOM_WM_NAME,
|
||||
XCB_ATOM_STRING,
|
||||
8,
|
||||
strlen( title ),
|
||||
title );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
|
||||
// Prepare notification for window destruction
|
||||
xcb_intern_atom_cookie_t protocols_cookie = xcb_intern_atom( Parameters.Connection, 1, 12, "WM_PROTOCOLS" );
|
||||
xcb_intern_atom_reply_t *protocols_reply = xcb_intern_atom_reply( Parameters.Connection, protocols_cookie, 0 );
|
||||
xcb_intern_atom_cookie_t delete_cookie = xcb_intern_atom( Parameters.Connection, 0, 16, "WM_DELETE_WINDOW" );
|
||||
xcb_intern_atom_reply_t *delete_reply = xcb_intern_atom_reply( Parameters.Connection, delete_cookie, 0 );
|
||||
xcb_change_property( Parameters.Connection, XCB_PROP_MODE_REPLACE, Parameters.Handle, (*protocols_reply).atom, 4, 32, 1, &(*delete_reply).atom );
|
||||
free( protocols_reply );
|
||||
|
||||
// Display window
|
||||
xcb_map_window( Parameters.Connection, Parameters.Handle );
|
||||
xcb_flush( Parameters.Connection );
|
||||
|
||||
// Main message loop
|
||||
xcb_generic_event_t *event;
|
||||
bool loop = true;
|
||||
bool resize = false;
|
||||
bool result = true;
|
||||
|
||||
while( loop ) {
|
||||
event = xcb_poll_for_event( Parameters.Connection );
|
||||
|
||||
if( event ) {
|
||||
// Process events
|
||||
switch (event->response_type & 0x7f) {
|
||||
// Resize
|
||||
case XCB_CONFIGURE_NOTIFY: {
|
||||
xcb_configure_notify_event_t *configure_event = (xcb_configure_notify_event_t*)event;
|
||||
static uint16_t width = configure_event->width;
|
||||
static uint16_t height = configure_event->height;
|
||||
|
||||
if( ((configure_event->width > 0) && (width != configure_event->width)) ||
|
||||
((configure_event->height > 0) && (height != configure_event->height)) ) {
|
||||
resize = true;
|
||||
width = configure_event->width;
|
||||
height = configure_event->height;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Close
|
||||
case XCB_CLIENT_MESSAGE:
|
||||
if( (*(xcb_client_message_event_t*)event).data.data32[0] == (*delete_reply).atom ) {
|
||||
loop = false;
|
||||
free( delete_reply );
|
||||
}
|
||||
break;
|
||||
case XCB_KEY_PRESS:
|
||||
loop = false;
|
||||
break;
|
||||
}
|
||||
free( event );
|
||||
} else {
|
||||
// Draw
|
||||
if( resize ) {
|
||||
resize = false;
|
||||
if( !tutorial.OnWindowSizeChanged() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( tutorial.ReadyToDraw() ) {
|
||||
if( !tutorial.Draw() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
|
||||
Window::~Window() {
|
||||
XDestroyWindow( Parameters.DisplayPtr, Parameters.Handle );
|
||||
XCloseDisplay( Parameters.DisplayPtr );
|
||||
}
|
||||
|
||||
bool Window::Create( const char *title ) {
|
||||
Parameters.DisplayPtr = XOpenDisplay( nullptr );
|
||||
if( !Parameters.DisplayPtr ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int default_screen = DefaultScreen( Parameters.DisplayPtr );
|
||||
|
||||
Parameters.Handle = XCreateSimpleWindow(
|
||||
Parameters.DisplayPtr,
|
||||
DefaultRootWindow( Parameters.DisplayPtr ),
|
||||
20,
|
||||
20,
|
||||
500,
|
||||
500,
|
||||
1,
|
||||
BlackPixel( Parameters.DisplayPtr, default_screen ),
|
||||
WhitePixel( Parameters.DisplayPtr, default_screen ) );
|
||||
|
||||
// XSync( Parameters.DisplayPtr, false );
|
||||
XSetStandardProperties( Parameters.DisplayPtr, Parameters.Handle, title, title, None, nullptr, 0, nullptr );
|
||||
XSelectInput( Parameters.DisplayPtr, Parameters.Handle, ExposureMask | KeyPressMask | StructureNotifyMask );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
|
||||
// Prepare notification for window destruction
|
||||
Atom delete_window_atom;
|
||||
delete_window_atom = XInternAtom( Parameters.DisplayPtr, "WM_DELETE_WINDOW", false );
|
||||
XSetWMProtocols( Parameters.DisplayPtr, Parameters.Handle, &delete_window_atom, 1);
|
||||
|
||||
// Display window
|
||||
XClearWindow( Parameters.DisplayPtr, Parameters.Handle );
|
||||
XMapWindow( Parameters.DisplayPtr, Parameters.Handle );
|
||||
|
||||
// Main message loop
|
||||
XEvent event;
|
||||
bool loop = true;
|
||||
bool resize = false;
|
||||
bool result = true;
|
||||
|
||||
while( loop ) {
|
||||
if( XPending( Parameters.DisplayPtr ) ) {
|
||||
XNextEvent( Parameters.DisplayPtr, &event );
|
||||
switch( event.type ) {
|
||||
//Process events
|
||||
case ConfigureNotify: {
|
||||
static int width = event.xconfigure.width;
|
||||
static int height = event.xconfigure.height;
|
||||
|
||||
if( ((event.xconfigure.width > 0) && (event.xconfigure.width != width)) ||
|
||||
((event.xconfigure.height > 0) && (event.xconfigure.width != height)) ) {
|
||||
width = event.xconfigure.width;
|
||||
height = event.xconfigure.height;
|
||||
resize = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyPress:
|
||||
loop = false;
|
||||
break;
|
||||
case DestroyNotify:
|
||||
loop = false;
|
||||
break;
|
||||
case ClientMessage:
|
||||
if( static_cast<unsigned int>(event.xclient.data.l[0]) == delete_window_atom ) {
|
||||
loop = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Draw
|
||||
if( resize ) {
|
||||
resize = false;
|
||||
if( !tutorial.OnWindowSizeChanged() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( tutorial.ReadyToDraw() ) {
|
||||
if( !tutorial.Draw() ) {
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,134 +1,130 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(OPERATING_SYSTEM_HEADER)
|
||||
#define OPERATING_SYSTEM_HEADER
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
#include <Windows.h>
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
#include <xcb/xcb.h>
|
||||
#include <dlfcn.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <dlfcn.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace OS {
|
||||
|
||||
// ************************************************************ //
|
||||
// LibraryHandle //
|
||||
// //
|
||||
// Dynamic Library OS dependent type //
|
||||
// ************************************************************ //
|
||||
//
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
typedef HMODULE LibraryHandle;
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
typedef void* LibraryHandle;
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************ //
|
||||
// OnWindowSizeChanged //
|
||||
// //
|
||||
// Base class for handling window size changes //
|
||||
// ************************************************************ //
|
||||
class TutorialBase {
|
||||
public:
|
||||
virtual bool OnWindowSizeChanged() = 0;
|
||||
virtual bool Draw() = 0;
|
||||
|
||||
virtual bool ReadyToDraw() const final {
|
||||
return CanRender;
|
||||
}
|
||||
|
||||
TutorialBase() :
|
||||
CanRender( false ) {
|
||||
}
|
||||
|
||||
virtual ~TutorialBase() {
|
||||
}
|
||||
|
||||
protected:
|
||||
bool CanRender;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// WindowParameters //
|
||||
// //
|
||||
// OS dependent window parameters //
|
||||
// ************************************************************ //
|
||||
struct WindowParameters {
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
HINSTANCE Instance;
|
||||
HWND Handle;
|
||||
|
||||
WindowParameters() :
|
||||
Instance(),
|
||||
Handle() {
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
xcb_connection_t *Connection;
|
||||
xcb_window_t Handle;
|
||||
|
||||
WindowParameters() :
|
||||
Connection(),
|
||||
Handle() {
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
Display *DisplayPtr;
|
||||
Window Handle;
|
||||
|
||||
WindowParameters() :
|
||||
DisplayPtr(),
|
||||
Handle() {
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Window //
|
||||
// //
|
||||
// OS dependent window creation and destruction class //
|
||||
// ************************************************************ //
|
||||
class Window {
|
||||
public:
|
||||
Window();
|
||||
~Window();
|
||||
|
||||
bool Create( const char *title );
|
||||
bool RenderingLoop( TutorialBase &tutorial ) const;
|
||||
WindowParameters GetParameters() const;
|
||||
|
||||
private:
|
||||
WindowParameters Parameters;
|
||||
};
|
||||
|
||||
} // namespace OS
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(OPERATING_SYSTEM_HEADER)
|
||||
#define OPERATING_SYSTEM_HEADER
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
#include <Windows.h>
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
#include <xcb/xcb.h>
|
||||
#include <dlfcn.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <dlfcn.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace OS {
|
||||
|
||||
// ************************************************************ //
|
||||
// LibraryHandle //
|
||||
// //
|
||||
// Dynamic Library OS dependent type //
|
||||
// ************************************************************ //
|
||||
//
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
typedef HMODULE LibraryHandle;
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
typedef void* LibraryHandle;
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************ //
|
||||
// OnWindowSizeChanged //
|
||||
// //
|
||||
// Base class for handling window size changes //
|
||||
// ************************************************************ //
|
||||
class TutorialBase {
|
||||
public:
|
||||
virtual bool OnWindowSizeChanged() = 0;
|
||||
virtual bool Draw() = 0;
|
||||
|
||||
virtual bool ReadyToDraw() const final {
|
||||
return CanRender;
|
||||
}
|
||||
|
||||
TutorialBase() :
|
||||
CanRender( false ) {
|
||||
}
|
||||
|
||||
virtual ~TutorialBase() {
|
||||
}
|
||||
|
||||
protected:
|
||||
bool CanRender;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// WindowParameters //
|
||||
// //
|
||||
// OS dependent window parameters //
|
||||
// ************************************************************ //
|
||||
struct WindowParameters {
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
HINSTANCE Instance;
|
||||
HWND Handle;
|
||||
|
||||
WindowParameters() :
|
||||
Instance(),
|
||||
Handle() {
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR)
|
||||
xcb_connection_t *Connection;
|
||||
xcb_window_t Handle;
|
||||
|
||||
WindowParameters() :
|
||||
Connection(),
|
||||
Handle() {
|
||||
}
|
||||
|
||||
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
Display *DisplayPtr;
|
||||
Window Handle;
|
||||
|
||||
WindowParameters() :
|
||||
DisplayPtr(),
|
||||
Handle() {
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Window //
|
||||
// //
|
||||
// OS dependent window creation and destruction class //
|
||||
// ************************************************************ //
|
||||
class Window {
|
||||
public:
|
||||
Window();
|
||||
~Window();
|
||||
|
||||
bool Create( const char *title );
|
||||
bool RenderingLoop( TutorialBase &tutorial ) const;
|
||||
WindowParameters GetParameters() const;
|
||||
@@ -1,152 +1,148 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "Tools.h"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace Tools {
|
||||
|
||||
// ************************************************************ //
|
||||
// GetBinaryFileContents //
|
||||
// //
|
||||
// Function reading binary contents of a file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetBinaryFileContents( std::string const &filename ) {
|
||||
|
||||
std::ifstream file( filename, std::ios::binary );
|
||||
if( file.fail() ) {
|
||||
std::cout << "Could not open \"" << filename << "\" file!" << std::endl;
|
||||
return std::vector<char>();
|
||||
}
|
||||
|
||||
std::streampos begin, end;
|
||||
begin = file.tellg();
|
||||
file.seekg( 0, std::ios::end );
|
||||
end = file.tellg();
|
||||
|
||||
std::vector<char> result( static_cast<size_t>(end - begin) );
|
||||
file.seekg( 0, std::ios::beg );
|
||||
file.read( &result[0], end - begin );
|
||||
file.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ************************************************************ //
|
||||
// GetImageData //
|
||||
// //
|
||||
// Function loading image (texture) data from a specified file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size ) {
|
||||
std::vector<char> file_data = Tools::GetBinaryFileContents( filename );
|
||||
if( file_data.size() == 0 ) {
|
||||
return std::vector<char>();
|
||||
}
|
||||
|
||||
int tmp_width = 0, tmp_height = 0, tmp_components = 0;
|
||||
unsigned char *image_data = stbi_load_from_memory( reinterpret_cast<unsigned char*>(&file_data[0]), static_cast<int>(file_data.size()), &tmp_width, &tmp_height, &tmp_components, requested_components );
|
||||
if( (image_data == nullptr) ||
|
||||
(tmp_width <= 0) ||
|
||||
(tmp_height <= 0) ||
|
||||
(tmp_components <= 0) ) {
|
||||
std::cout << "Could not read image data!" << std::endl;
|
||||
return std::vector<char>();
|
||||
}
|
||||
|
||||
int size = (tmp_width) * (tmp_height) * (requested_components <= 0 ? tmp_components : requested_components);
|
||||
if( data_size ) {
|
||||
*data_size = size;
|
||||
}
|
||||
if( width ) {
|
||||
*width = tmp_width;
|
||||
}
|
||||
if( height ) {
|
||||
*height = tmp_height;
|
||||
}
|
||||
if( components ) {
|
||||
*components = tmp_components;
|
||||
}
|
||||
|
||||
std::vector<char> output(size);
|
||||
memcpy( &output[0], image_data, size );
|
||||
|
||||
stbi_image_free( image_data );
|
||||
return output;
|
||||
}
|
||||
|
||||
// ************************************************************ //
|
||||
// GetPerspectiveProjectionMatrix //
|
||||
// //
|
||||
// Function calculating perspective projection matrix //
|
||||
// ************************************************************ //
|
||||
std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip ) {
|
||||
float f = 1.0f / std::tan( field_of_view * 0.5f * 0.01745329251994329576923690768489f );
|
||||
|
||||
return {
|
||||
f / aspect_ratio,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
0.0f,
|
||||
(near_clip + far_clip) / (near_clip - far_clip),
|
||||
-1.0f,
|
||||
|
||||
0.0f,
|
||||
0.0f,
|
||||
(2.0f * near_clip * far_clip) / (near_clip - far_clip),
|
||||
0.0f
|
||||
};
|
||||
}
|
||||
|
||||
// ************************************************************ //
|
||||
// GetOrthographicsProjectionMatrix //
|
||||
// //
|
||||
// Function calculating orthographic projection matrix //
|
||||
// ************************************************************ //
|
||||
std::array<float, 16> GetOrthographicProjectionMatrix( float const left_plane, float const right_plane, float const top_plane, float const bottom_plane, float const near_plane, float const far_plane ) {
|
||||
return {
|
||||
2.0f / (right_plane - left_plane),
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
2.0f / (bottom_plane - top_plane),
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
0.0f,
|
||||
-2.0f / (far_plane - near_plane),
|
||||
0.0f,
|
||||
|
||||
-(right_plane + left_plane) / (right_plane - left_plane),
|
||||
-(bottom_plane + top_plane) / (bottom_plane - top_plane),
|
||||
-(far_plane + near_plane) / (far_plane - near_plane),
|
||||
1.0f
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "Tools.h"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace Tools {
|
||||
|
||||
// ************************************************************ //
|
||||
// GetBinaryFileContents //
|
||||
// //
|
||||
// Function reading binary contents of a file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetBinaryFileContents( std::string const &filename ) {
|
||||
|
||||
std::ifstream file( filename, std::ios::binary );
|
||||
if( file.fail() ) {
|
||||
std::cout << "Could not open \"" << filename << "\" file!" << std::endl;
|
||||
return std::vector<char>();
|
||||
}
|
||||
|
||||
std::streampos begin, end;
|
||||
begin = file.tellg();
|
||||
file.seekg( 0, std::ios::end );
|
||||
end = file.tellg();
|
||||
|
||||
std::vector<char> result( static_cast<size_t>(end - begin) );
|
||||
file.seekg( 0, std::ios::beg );
|
||||
file.read( &result[0], end - begin );
|
||||
file.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ************************************************************ //
|
||||
// GetImageData //
|
||||
// //
|
||||
// Function loading image (texture) data from a specified file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size ) {
|
||||
std::vector<char> file_data = Tools::GetBinaryFileContents( filename );
|
||||
if( file_data.size() == 0 ) {
|
||||
return std::vector<char>();
|
||||
}
|
||||
|
||||
int tmp_width = 0, tmp_height = 0, tmp_components = 0;
|
||||
unsigned char *image_data = stbi_load_from_memory( reinterpret_cast<unsigned char*>(&file_data[0]), static_cast<int>(file_data.size()), &tmp_width, &tmp_height, &tmp_components, requested_components );
|
||||
if( (image_data == nullptr) ||
|
||||
(tmp_width <= 0) ||
|
||||
(tmp_height <= 0) ||
|
||||
(tmp_components <= 0) ) {
|
||||
std::cout << "Could not read image data!" << std::endl;
|
||||
return std::vector<char>();
|
||||
}
|
||||
|
||||
int size = (tmp_width) * (tmp_height) * (requested_components <= 0 ? tmp_components : requested_components);
|
||||
if( data_size ) {
|
||||
*data_size = size;
|
||||
}
|
||||
if( width ) {
|
||||
*width = tmp_width;
|
||||
}
|
||||
if( height ) {
|
||||
*height = tmp_height;
|
||||
}
|
||||
if( components ) {
|
||||
*components = tmp_components;
|
||||
}
|
||||
|
||||
std::vector<char> output(size);
|
||||
memcpy( &output[0], image_data, size );
|
||||
|
||||
stbi_image_free( image_data );
|
||||
return output;
|
||||
}
|
||||
|
||||
// ************************************************************ //
|
||||
// GetPerspectiveProjectionMatrix //
|
||||
// //
|
||||
// Function calculating perspective projection matrix //
|
||||
// ************************************************************ //
|
||||
std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip ) {
|
||||
float f = 1.0f / std::tan( field_of_view * 0.5f * 0.01745329251994329576923690768489f );
|
||||
|
||||
return {
|
||||
f / aspect_ratio,
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
0.0f,
|
||||
(near_clip + far_clip) / (near_clip - far_clip),
|
||||
-1.0f,
|
||||
|
||||
0.0f,
|
||||
0.0f,
|
||||
(2.0f * near_clip * far_clip) / (near_clip - far_clip),
|
||||
0.0f
|
||||
};
|
||||
}
|
||||
|
||||
// ************************************************************ //
|
||||
// GetOrthographicsProjectionMatrix //
|
||||
// //
|
||||
// Function calculating orthographic projection matrix //
|
||||
// ************************************************************ //
|
||||
std::array<float, 16> GetOrthographicProjectionMatrix( float const left_plane, float const right_plane, float const top_plane, float const bottom_plane, float const near_plane, float const far_plane ) {
|
||||
return {
|
||||
2.0f / (right_plane - left_plane),
|
||||
0.0f,
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
2.0f / (bottom_plane - top_plane),
|
||||
0.0f,
|
||||
0.0f,
|
||||
|
||||
0.0f,
|
||||
0.0f,
|
||||
-2.0f / (far_plane - near_plane),
|
||||
0.0f,
|
||||
|
||||
@@ -1,113 +1,109 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TOOLS_HEADER)
|
||||
#define TOOLS_HEADER
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include "vulkan.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace Tools {
|
||||
|
||||
// ************************************************************ //
|
||||
// AutoDeleter //
|
||||
// //
|
||||
// Auto-deleter helper template class responsible for calling //
|
||||
// provided function which deletes given object of type T //
|
||||
// ************************************************************ //
|
||||
template<class T, class F>
|
||||
class AutoDeleter {
|
||||
public:
|
||||
AutoDeleter() :
|
||||
Object( VK_NULL_HANDLE ),
|
||||
Deleter( nullptr ),
|
||||
Device( VK_NULL_HANDLE ) {
|
||||
}
|
||||
|
||||
AutoDeleter( T object, F deleter, VkDevice device ) :
|
||||
Object( object ),
|
||||
Deleter( deleter ),
|
||||
Device( device ) {
|
||||
}
|
||||
|
||||
AutoDeleter( AutoDeleter&& other ) {
|
||||
*this = std::move( other );
|
||||
}
|
||||
|
||||
~AutoDeleter() {
|
||||
if( (Object != VK_NULL_HANDLE) && (Deleter != nullptr) && (Device != VK_NULL_HANDLE) ) {
|
||||
Deleter( Device, Object, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
AutoDeleter& operator=(AutoDeleter&& other) {
|
||||
if( this != &other ) {
|
||||
Object = other.Object;
|
||||
Deleter = other.Deleter;
|
||||
Device = other.Device;
|
||||
other.Object = VK_NULL_HANDLE;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T Get() {
|
||||
return Object;
|
||||
}
|
||||
|
||||
bool operator !() const {
|
||||
return Object == VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
private:
|
||||
AutoDeleter( const AutoDeleter& );
|
||||
AutoDeleter& operator=( const AutoDeleter& );
|
||||
T Object;
|
||||
F Deleter;
|
||||
VkDevice Device;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// GetBinaryFileContents //
|
||||
// //
|
||||
// Function reading binary contents of a file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetBinaryFileContents( std::string const &filename );
|
||||
|
||||
// ************************************************************ //
|
||||
// GetImageData //
|
||||
// //
|
||||
// Function loading image (texture) data from a specified file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size );
|
||||
|
||||
// ************************************************************ //
|
||||
// GetPerspectiveProjectionMatrix //
|
||||
// //
|
||||
// Function calculating perspective projection matrix //
|
||||
// ************************************************************ //
|
||||
std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip );
|
||||
|
||||
// ************************************************************ //
|
||||
// GetOrthographicsProjectionMatrix //
|
||||
// //
|
||||
// Function calculating orthographic projection matrix //
|
||||
// ************************************************************ //
|
||||
std::array<float, 16> GetOrthographicProjectionMatrix( float const left_plane, float const right_plane, float const top_plane, float const bottom_plane, float const near_plane, float const far_plane );
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TOOLS_HEADER)
|
||||
#define TOOLS_HEADER
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include "vulkan.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
namespace Tools {
|
||||
|
||||
// ************************************************************ //
|
||||
// AutoDeleter //
|
||||
// //
|
||||
// Auto-deleter helper template class responsible for calling //
|
||||
// provided function which deletes given object of type T //
|
||||
// ************************************************************ //
|
||||
template<class T, class F>
|
||||
class AutoDeleter {
|
||||
public:
|
||||
AutoDeleter() :
|
||||
Object( VK_NULL_HANDLE ),
|
||||
Deleter( nullptr ),
|
||||
Device( VK_NULL_HANDLE ) {
|
||||
}
|
||||
|
||||
AutoDeleter( T object, F deleter, VkDevice device ) :
|
||||
Object( object ),
|
||||
Deleter( deleter ),
|
||||
Device( device ) {
|
||||
}
|
||||
|
||||
AutoDeleter( AutoDeleter&& other ) {
|
||||
*this = std::move( other );
|
||||
}
|
||||
|
||||
~AutoDeleter() {
|
||||
if( (Object != VK_NULL_HANDLE) && (Deleter != nullptr) && (Device != VK_NULL_HANDLE) ) {
|
||||
Deleter( Device, Object, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
AutoDeleter& operator=(AutoDeleter&& other) {
|
||||
if( this != &other ) {
|
||||
Object = other.Object;
|
||||
Deleter = other.Deleter;
|
||||
Device = other.Device;
|
||||
other.Object = VK_NULL_HANDLE;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T Get() {
|
||||
return Object;
|
||||
}
|
||||
|
||||
bool operator !() const {
|
||||
return Object == VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
private:
|
||||
AutoDeleter( const AutoDeleter& );
|
||||
AutoDeleter& operator=( const AutoDeleter& );
|
||||
T Object;
|
||||
F Deleter;
|
||||
VkDevice Device;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// GetBinaryFileContents //
|
||||
// //
|
||||
// Function reading binary contents of a file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetBinaryFileContents( std::string const &filename );
|
||||
|
||||
// ************************************************************ //
|
||||
// GetImageData //
|
||||
// //
|
||||
// Function loading image (texture) data from a specified file //
|
||||
// ************************************************************ //
|
||||
std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size );
|
||||
|
||||
// ************************************************************ //
|
||||
// GetPerspectiveProjectionMatrix //
|
||||
// //
|
||||
// Function calculating perspective projection matrix //
|
||||
// ************************************************************ //
|
||||
std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip );
|
||||
|
||||
// ************************************************************ //
|
||||
// GetOrthographicsProjectionMatrix //
|
||||
// //
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,151 +1,147 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(VULKAN_COMMON_HEADER)
|
||||
#define VULKAN_COMMON_HEADER
|
||||
|
||||
#include <vector>
|
||||
#include "vulkan.h"
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// QueueParameters //
|
||||
// //
|
||||
// Vulkan Queue's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct QueueParameters {
|
||||
VkQueue Handle;
|
||||
uint32_t FamilyIndex;
|
||||
|
||||
QueueParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
FamilyIndex( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// ImageParameters //
|
||||
// //
|
||||
// Vulkan Image's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct ImageParameters {
|
||||
VkImage Handle;
|
||||
VkImageView View;
|
||||
VkSampler Sampler;
|
||||
VkDeviceMemory Memory;
|
||||
|
||||
ImageParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
View( VK_NULL_HANDLE ),
|
||||
Sampler( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// SwapChainParameters //
|
||||
// //
|
||||
// Vulkan SwapChain's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct SwapChainParameters {
|
||||
VkSwapchainKHR Handle;
|
||||
VkFormat Format;
|
||||
std::vector<ImageParameters> Images;
|
||||
VkExtent2D Extent;
|
||||
|
||||
SwapChainParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Format( VK_FORMAT_UNDEFINED ),
|
||||
Images(),
|
||||
Extent() {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanCommonParameters //
|
||||
// //
|
||||
// General Vulkan parameters' container class //
|
||||
// ************************************************************ //
|
||||
struct VulkanCommonParameters {
|
||||
VkInstance Instance;
|
||||
VkPhysicalDevice PhysicalDevice;
|
||||
VkDevice Device;
|
||||
QueueParameters GraphicsQueue;
|
||||
QueueParameters PresentQueue;
|
||||
VkSurfaceKHR PresentationSurface;
|
||||
SwapChainParameters SwapChain;
|
||||
|
||||
VulkanCommonParameters() :
|
||||
Instance( VK_NULL_HANDLE ),
|
||||
PhysicalDevice( VK_NULL_HANDLE ),
|
||||
Device( VK_NULL_HANDLE ),
|
||||
GraphicsQueue(),
|
||||
PresentQueue(),
|
||||
PresentationSurface( VK_NULL_HANDLE ),
|
||||
SwapChain() {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanCommon //
|
||||
// //
|
||||
// Base class for Vulkan more advanced tutorial classes //
|
||||
// ************************************************************ //
|
||||
class VulkanCommon : public OS::TutorialBase {
|
||||
public:
|
||||
VulkanCommon();
|
||||
virtual ~VulkanCommon();
|
||||
|
||||
bool PrepareVulkan( OS::WindowParameters parameters );
|
||||
virtual bool OnWindowSizeChanged() final override;
|
||||
|
||||
protected:
|
||||
VkPhysicalDevice GetPhysicalDevice() const;
|
||||
VkDevice GetDevice() const;
|
||||
|
||||
const QueueParameters GetGraphicsQueue() const;
|
||||
const QueueParameters GetPresentQueue() const;
|
||||
|
||||
const SwapChainParameters GetSwapChain() const;
|
||||
|
||||
private:
|
||||
OS::LibraryHandle VulkanLibrary;
|
||||
OS::WindowParameters Window;
|
||||
VulkanCommonParameters Vulkan;
|
||||
|
||||
bool LoadVulkanLibrary();
|
||||
bool LoadExportedEntryPoints();
|
||||
bool LoadGlobalLevelEntryPoints();
|
||||
bool CreateInstance();
|
||||
bool LoadInstanceLevelEntryPoints();
|
||||
bool CreatePresentationSurface();
|
||||
bool CreateDevice();
|
||||
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
|
||||
bool LoadDeviceLevelEntryPoints();
|
||||
bool GetDeviceQueue();
|
||||
bool CreateSwapChain();
|
||||
bool CreateSwapChainImageViews();
|
||||
virtual bool ChildOnWindowSizeChanged() = 0;
|
||||
virtual void ChildClear() = 0;
|
||||
|
||||
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
|
||||
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats );
|
||||
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes );
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(VULKAN_COMMON_HEADER)
|
||||
#define VULKAN_COMMON_HEADER
|
||||
|
||||
#include <vector>
|
||||
#include "vulkan.h"
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// QueueParameters //
|
||||
// //
|
||||
// Vulkan Queue's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct QueueParameters {
|
||||
VkQueue Handle;
|
||||
uint32_t FamilyIndex;
|
||||
|
||||
QueueParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
FamilyIndex( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// ImageParameters //
|
||||
// //
|
||||
// Vulkan Image's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct ImageParameters {
|
||||
VkImage Handle;
|
||||
VkImageView View;
|
||||
VkSampler Sampler;
|
||||
VkDeviceMemory Memory;
|
||||
|
||||
ImageParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
View( VK_NULL_HANDLE ),
|
||||
Sampler( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// SwapChainParameters //
|
||||
// //
|
||||
// Vulkan SwapChain's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct SwapChainParameters {
|
||||
VkSwapchainKHR Handle;
|
||||
VkFormat Format;
|
||||
std::vector<ImageParameters> Images;
|
||||
VkExtent2D Extent;
|
||||
|
||||
SwapChainParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Format( VK_FORMAT_UNDEFINED ),
|
||||
Images(),
|
||||
Extent() {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanCommonParameters //
|
||||
// //
|
||||
// General Vulkan parameters' container class //
|
||||
// ************************************************************ //
|
||||
struct VulkanCommonParameters {
|
||||
VkInstance Instance;
|
||||
VkPhysicalDevice PhysicalDevice;
|
||||
VkDevice Device;
|
||||
QueueParameters GraphicsQueue;
|
||||
QueueParameters PresentQueue;
|
||||
VkSurfaceKHR PresentationSurface;
|
||||
SwapChainParameters SwapChain;
|
||||
|
||||
VulkanCommonParameters() :
|
||||
Instance( VK_NULL_HANDLE ),
|
||||
PhysicalDevice( VK_NULL_HANDLE ),
|
||||
Device( VK_NULL_HANDLE ),
|
||||
GraphicsQueue(),
|
||||
PresentQueue(),
|
||||
PresentationSurface( VK_NULL_HANDLE ),
|
||||
SwapChain() {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanCommon //
|
||||
// //
|
||||
// Base class for Vulkan more advanced tutorial classes //
|
||||
// ************************************************************ //
|
||||
class VulkanCommon : public OS::TutorialBase {
|
||||
public:
|
||||
VulkanCommon();
|
||||
virtual ~VulkanCommon();
|
||||
|
||||
bool PrepareVulkan( OS::WindowParameters parameters );
|
||||
virtual bool OnWindowSizeChanged() final override;
|
||||
|
||||
protected:
|
||||
VkPhysicalDevice GetPhysicalDevice() const;
|
||||
VkDevice GetDevice() const;
|
||||
|
||||
const QueueParameters GetGraphicsQueue() const;
|
||||
const QueueParameters GetPresentQueue() const;
|
||||
|
||||
const SwapChainParameters GetSwapChain() const;
|
||||
|
||||
private:
|
||||
OS::LibraryHandle VulkanLibrary;
|
||||
OS::WindowParameters Window;
|
||||
VulkanCommonParameters Vulkan;
|
||||
|
||||
bool LoadVulkanLibrary();
|
||||
bool LoadExportedEntryPoints();
|
||||
bool LoadGlobalLevelEntryPoints();
|
||||
bool CreateInstance();
|
||||
bool LoadInstanceLevelEntryPoints();
|
||||
bool CreatePresentationSurface();
|
||||
bool CreateDevice();
|
||||
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
|
||||
bool LoadDeviceLevelEntryPoints();
|
||||
bool GetDeviceQueue();
|
||||
bool CreateSwapChain();
|
||||
bool CreateSwapChainImageViews();
|
||||
virtual bool ChildOnWindowSizeChanged() = 0;
|
||||
virtual void ChildClear() = 0;
|
||||
|
||||
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
|
||||
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
@@ -1,22 +1,18 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "vulkan.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
#define VK_EXPORTED_FUNCTION( fun ) PFN_##fun fun;
|
||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) PFN_##fun fun;
|
||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) PFN_##fun fun;
|
||||
#define VK_DEVICE_LEVEL_FUNCTION( fun ) PFN_##fun fun;
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "vulkan.h"
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(VULKAN_FUNCTIONS_HEADER)
|
||||
#define VULKAN_FUNCTIONS_HEADER
|
||||
|
||||
#include "vulkan.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
#define VK_EXPORTED_FUNCTION( fun ) extern PFN_##fun fun;
|
||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun) extern PFN_##fun fun;
|
||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun;
|
||||
#define VK_DEVICE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun;
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(VULKAN_FUNCTIONS_HEADER)
|
||||
#define VULKAN_FUNCTIONS_HEADER
|
||||
|
||||
#include "vulkan.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
@@ -1,276 +1,272 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include <vector>
|
||||
#include "Tutorial01.h"
|
||||
#include "VulkanFunctions.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
Tutorial01::Tutorial01() :
|
||||
VulkanLibrary(),
|
||||
Vulkan() {
|
||||
}
|
||||
|
||||
bool Tutorial01::OnWindowSizeChanged() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::Draw() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::PrepareVulkan() {
|
||||
if( !LoadVulkanLibrary() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadExportedEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadGlobalLevelEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !CreateInstance() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadInstanceLevelEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !CreateDevice() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadDeviceLevelEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !GetDeviceQueue() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadVulkanLibrary() {
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VulkanLibrary = LoadLibrary( "vulkan-1.dll" );
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
VulkanLibrary = dlopen( "libvulkan.so.1", RTLD_NOW );
|
||||
#endif
|
||||
|
||||
if( VulkanLibrary == nullptr ) {
|
||||
std::cout << "Could not load Vulkan library!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadExportedEntryPoints() {
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
#define LoadProcAddress GetProcAddress
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
#define LoadProcAddress dlsym
|
||||
#endif
|
||||
|
||||
#define VK_EXPORTED_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
||||
std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadGlobalLevelEntryPoints() {
|
||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
||||
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::CreateInstance() {
|
||||
VkApplicationInfo application_info = {
|
||||
VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType
|
||||
nullptr, // const void *pNext
|
||||
"API without Secrets: Introduction to Vulkan", // const char *pApplicationName
|
||||
VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t applicationVersion
|
||||
"Vulkan Tutorial by Intel", // 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
|
||||
0, // uint32_t enabledExtensionCount
|
||||
nullptr // const char * const *ppEnabledExtensionNames
|
||||
};
|
||||
|
||||
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
||||
std::cout << "Could not create Vulkan instance!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadInstanceLevelEntryPoints() {
|
||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
||||
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::CreateDevice() {
|
||||
uint32_t num_devices = 0;
|
||||
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
||||
(num_devices == 0) ) {
|
||||
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
||||
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
||||
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
VkPhysicalDevice selected_physical_device = VK_NULL_HANDLE;
|
||||
uint32_t selected_queue_family_index = UINT32_MAX;
|
||||
for( uint32_t i = 0; i < num_devices; ++i ) {
|
||||
if( CheckPhysicalDeviceProperties( physical_devices[i], selected_queue_family_index ) ) {
|
||||
selected_physical_device = physical_devices[i];
|
||||
}
|
||||
}
|
||||
if( selected_physical_device == VK_NULL_HANDLE ) {
|
||||
std::cout << "Could not select physical device based on the chosen properties!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<float> queue_priorities = { 1.0f };
|
||||
|
||||
VkDeviceQueueCreateInfo queue_create_info = {
|
||||
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void *pNext
|
||||
0, // VkDeviceQueueCreateFlags flags
|
||||
selected_queue_family_index, // uint32_t queueFamilyIndex
|
||||
static_cast<uint32_t>(queue_priorities.size()), // uint32_t queueCount
|
||||
&queue_priorities[0] // const float *pQueuePriorities
|
||||
};
|
||||
|
||||
VkDeviceCreateInfo device_create_info = {
|
||||
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void *pNext
|
||||
0, // VkDeviceCreateFlags flags
|
||||
1, // uint32_t queueCreateInfoCount
|
||||
&queue_create_info, // const VkDeviceQueueCreateInfo *pQueueCreateInfos
|
||||
0, // uint32_t enabledLayerCount
|
||||
nullptr, // const char * const *ppEnabledLayerNames
|
||||
0, // uint32_t enabledExtensionCount
|
||||
nullptr, // const char * const *ppEnabledExtensionNames
|
||||
nullptr // const VkPhysicalDeviceFeatures *pEnabledFeatures
|
||||
};
|
||||
|
||||
if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
||||
std::cout << "Could not create Vulkan device!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
Vulkan.QueueFamilyIndex = selected_queue_family_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index ) {
|
||||
VkPhysicalDeviceProperties device_properties;
|
||||
VkPhysicalDeviceFeatures device_features;
|
||||
|
||||
vkGetPhysicalDeviceProperties( physical_device, &device_properties );
|
||||
vkGetPhysicalDeviceFeatures( physical_device, &device_features );
|
||||
|
||||
uint32_t major_version = VK_VERSION_MAJOR( device_properties.apiVersion );
|
||||
uint32_t minor_version = VK_VERSION_MINOR( device_properties.apiVersion );
|
||||
uint32_t patch_version = VK_VERSION_PATCH( device_properties.apiVersion );
|
||||
|
||||
if( (major_version < 1) ||
|
||||
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
||||
std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t queue_families_count = 0;
|
||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
||||
if( queue_families_count == 0 ) {
|
||||
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<VkQueueFamilyProperties> queue_family_properties( queue_families_count );
|
||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, &queue_family_properties[0] );
|
||||
for( uint32_t i = 0; i < queue_families_count; ++i ) {
|
||||
if( (queue_family_properties[i].queueCount > 0) &&
|
||||
(queue_family_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) ) {
|
||||
queue_family_index = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadDeviceLevelEntryPoints() {
|
||||
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
||||
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::GetDeviceQueue() {
|
||||
vkGetDeviceQueue( Vulkan.Device, Vulkan.QueueFamilyIndex, 0, &Vulkan.Queue );
|
||||
return true;
|
||||
}
|
||||
|
||||
Tutorial01::~Tutorial01() {
|
||||
if( Vulkan.Device != VK_NULL_HANDLE ) {
|
||||
vkDeviceWaitIdle( Vulkan.Device );
|
||||
vkDestroyDevice( Vulkan.Device, nullptr );
|
||||
}
|
||||
|
||||
if( Vulkan.Instance != VK_NULL_HANDLE ) {
|
||||
vkDestroyInstance( Vulkan.Instance, nullptr );
|
||||
}
|
||||
|
||||
if( VulkanLibrary ) {
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
FreeLibrary( VulkanLibrary );
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
dlclose( VulkanLibrary );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <vector>
|
||||
#include "Tutorial01.h"
|
||||
#include "VulkanFunctions.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
Tutorial01::Tutorial01() :
|
||||
VulkanLibrary(),
|
||||
Vulkan() {
|
||||
}
|
||||
|
||||
bool Tutorial01::OnWindowSizeChanged() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::Draw() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::PrepareVulkan() {
|
||||
if( !LoadVulkanLibrary() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadExportedEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadGlobalLevelEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !CreateInstance() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadInstanceLevelEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !CreateDevice() ) {
|
||||
return false;
|
||||
}
|
||||
if( !LoadDeviceLevelEntryPoints() ) {
|
||||
return false;
|
||||
}
|
||||
if( !GetDeviceQueue() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadVulkanLibrary() {
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VulkanLibrary = LoadLibrary( "vulkan-1.dll" );
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
VulkanLibrary = dlopen( "libvulkan.so.1", RTLD_NOW );
|
||||
#endif
|
||||
|
||||
if( VulkanLibrary == nullptr ) {
|
||||
std::cout << "Could not load Vulkan library!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadExportedEntryPoints() {
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
#define LoadProcAddress GetProcAddress
|
||||
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
#define LoadProcAddress dlsym
|
||||
#endif
|
||||
|
||||
#define VK_EXPORTED_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
|
||||
std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadGlobalLevelEntryPoints() {
|
||||
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
|
||||
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::CreateInstance() {
|
||||
VkApplicationInfo application_info = {
|
||||
VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType
|
||||
nullptr, // const void *pNext
|
||||
"API without Secrets: Introduction to Vulkan", // const char *pApplicationName
|
||||
VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t applicationVersion
|
||||
"Vulkan Tutorial by Intel", // 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
|
||||
0, // uint32_t enabledExtensionCount
|
||||
nullptr // const char * const *ppEnabledExtensionNames
|
||||
};
|
||||
|
||||
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
|
||||
std::cout << "Could not create Vulkan instance!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadInstanceLevelEntryPoints() {
|
||||
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
|
||||
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::CreateDevice() {
|
||||
uint32_t num_devices = 0;
|
||||
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
|
||||
(num_devices == 0) ) {
|
||||
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<VkPhysicalDevice> physical_devices( num_devices );
|
||||
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
|
||||
std::cout << "Error occurred during physical devices enumeration!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
VkPhysicalDevice selected_physical_device = VK_NULL_HANDLE;
|
||||
uint32_t selected_queue_family_index = UINT32_MAX;
|
||||
for( uint32_t i = 0; i < num_devices; ++i ) {
|
||||
if( CheckPhysicalDeviceProperties( physical_devices[i], selected_queue_family_index ) ) {
|
||||
selected_physical_device = physical_devices[i];
|
||||
}
|
||||
}
|
||||
if( selected_physical_device == VK_NULL_HANDLE ) {
|
||||
std::cout << "Could not select physical device based on the chosen properties!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<float> queue_priorities = { 1.0f };
|
||||
|
||||
VkDeviceQueueCreateInfo queue_create_info = {
|
||||
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void *pNext
|
||||
0, // VkDeviceQueueCreateFlags flags
|
||||
selected_queue_family_index, // uint32_t queueFamilyIndex
|
||||
static_cast<uint32_t>(queue_priorities.size()), // uint32_t queueCount
|
||||
&queue_priorities[0] // const float *pQueuePriorities
|
||||
};
|
||||
|
||||
VkDeviceCreateInfo device_create_info = {
|
||||
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType
|
||||
nullptr, // const void *pNext
|
||||
0, // VkDeviceCreateFlags flags
|
||||
1, // uint32_t queueCreateInfoCount
|
||||
&queue_create_info, // const VkDeviceQueueCreateInfo *pQueueCreateInfos
|
||||
0, // uint32_t enabledLayerCount
|
||||
nullptr, // const char * const *ppEnabledLayerNames
|
||||
0, // uint32_t enabledExtensionCount
|
||||
nullptr, // const char * const *ppEnabledExtensionNames
|
||||
nullptr // const VkPhysicalDeviceFeatures *pEnabledFeatures
|
||||
};
|
||||
|
||||
if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
|
||||
std::cout << "Could not create Vulkan device!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
Vulkan.QueueFamilyIndex = selected_queue_family_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index ) {
|
||||
VkPhysicalDeviceProperties device_properties;
|
||||
VkPhysicalDeviceFeatures device_features;
|
||||
|
||||
vkGetPhysicalDeviceProperties( physical_device, &device_properties );
|
||||
vkGetPhysicalDeviceFeatures( physical_device, &device_features );
|
||||
|
||||
uint32_t major_version = VK_VERSION_MAJOR( device_properties.apiVersion );
|
||||
uint32_t minor_version = VK_VERSION_MINOR( device_properties.apiVersion );
|
||||
uint32_t patch_version = VK_VERSION_PATCH( device_properties.apiVersion );
|
||||
|
||||
if( (major_version < 1) ||
|
||||
(device_properties.limits.maxImageDimension2D < 4096) ) {
|
||||
std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t queue_families_count = 0;
|
||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
|
||||
if( queue_families_count == 0 ) {
|
||||
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<VkQueueFamilyProperties> queue_family_properties( queue_families_count );
|
||||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, &queue_family_properties[0] );
|
||||
for( uint32_t i = 0; i < queue_families_count; ++i ) {
|
||||
if( (queue_family_properties[i].queueCount > 0) &&
|
||||
(queue_family_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) ) {
|
||||
queue_family_index = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Tutorial01::LoadDeviceLevelEntryPoints() {
|
||||
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
|
||||
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
|
||||
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#include "ListOfFunctions.inl"
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tutorial01::GetDeviceQueue() {
|
||||
vkGetDeviceQueue( Vulkan.Device, Vulkan.QueueFamilyIndex, 0, &Vulkan.Queue );
|
||||
return true;
|
||||
}
|
||||
|
||||
Tutorial01::~Tutorial01() {
|
||||
if( Vulkan.Device != VK_NULL_HANDLE ) {
|
||||
vkDeviceWaitIdle( Vulkan.Device );
|
||||
vkDestroyDevice( Vulkan.Device, nullptr );
|
||||
}
|
||||
|
||||
if( Vulkan.Instance != VK_NULL_HANDLE ) {
|
||||
vkDestroyInstance( Vulkan.Instance, nullptr );
|
||||
}
|
||||
|
||||
@@ -1,70 +1,66 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TUTORIAL_01_HEADER)
|
||||
#define TUTORIAL_01_HEADER
|
||||
|
||||
#include "vulkan.h"
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial01Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial01Parameters {
|
||||
VkInstance Instance;
|
||||
VkDevice Device;
|
||||
uint32_t QueueFamilyIndex;
|
||||
VkQueue Queue;
|
||||
|
||||
VulkanTutorial01Parameters() :
|
||||
Instance( VK_NULL_HANDLE ),
|
||||
Device( VK_NULL_HANDLE ),
|
||||
QueueFamilyIndex( 0 ),
|
||||
Queue( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial01 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial01 : public OS::TutorialBase {
|
||||
public:
|
||||
Tutorial01();
|
||||
~Tutorial01();
|
||||
|
||||
bool OnWindowSizeChanged() override;
|
||||
bool Draw() override;
|
||||
|
||||
bool PrepareVulkan();
|
||||
|
||||
private:
|
||||
OS::LibraryHandle VulkanLibrary;
|
||||
VulkanTutorial01Parameters Vulkan;
|
||||
|
||||
bool LoadVulkanLibrary();
|
||||
bool LoadExportedEntryPoints();
|
||||
bool LoadGlobalLevelEntryPoints();
|
||||
bool CreateInstance();
|
||||
bool LoadInstanceLevelEntryPoints();
|
||||
bool CreateDevice();
|
||||
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index );
|
||||
bool LoadDeviceLevelEntryPoints();
|
||||
bool GetDeviceQueue();
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TUTORIAL_01_HEADER)
|
||||
#define TUTORIAL_01_HEADER
|
||||
|
||||
#include "vulkan.h"
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial01Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial01Parameters {
|
||||
VkInstance Instance;
|
||||
VkDevice Device;
|
||||
uint32_t QueueFamilyIndex;
|
||||
VkQueue Queue;
|
||||
|
||||
VulkanTutorial01Parameters() :
|
||||
Instance( VK_NULL_HANDLE ),
|
||||
Device( VK_NULL_HANDLE ),
|
||||
QueueFamilyIndex( 0 ),
|
||||
Queue( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial01 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial01 : public OS::TutorialBase {
|
||||
public:
|
||||
Tutorial01();
|
||||
~Tutorial01();
|
||||
|
||||
bool OnWindowSizeChanged() override;
|
||||
bool Draw() override;
|
||||
|
||||
bool PrepareVulkan();
|
||||
|
||||
private:
|
||||
OS::LibraryHandle VulkanLibrary;
|
||||
VulkanTutorial01Parameters Vulkan;
|
||||
|
||||
bool LoadVulkanLibrary();
|
||||
bool LoadExportedEntryPoints();
|
||||
bool LoadGlobalLevelEntryPoints();
|
||||
bool CreateInstance();
|
||||
@@ -1,33 +1,29 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "Tutorial01.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial01 tutorial01;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "01 - The Beginning" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial01.PrepareVulkan() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rendering loop
|
||||
if( !window.RenderingLoop( tutorial01 ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Tutorial01.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial01 tutorial01;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "01 - The Beginning" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial01.PrepareVulkan() ) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,101 +1,97 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TUTORIAL_02_HEADER)
|
||||
#define TUTORIAL_02_HEADER
|
||||
|
||||
#include <vector>
|
||||
#include "vulkan.h"
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial02Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial02Parameters {
|
||||
VkInstance Instance;
|
||||
VkPhysicalDevice PhysicalDevice;
|
||||
VkDevice Device;
|
||||
VkQueue GraphicsQueue;
|
||||
VkQueue PresentQueue;
|
||||
uint32_t GraphicsQueueFamilyIndex;
|
||||
uint32_t PresentQueueFamilyIndex;
|
||||
VkSurfaceKHR PresentationSurface;
|
||||
VkSwapchainKHR SwapChain;
|
||||
std::vector<VkCommandBuffer> PresentQueueCmdBuffers;
|
||||
VkCommandPool PresentQueueCmdPool;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore RenderingFinishedSemaphore;
|
||||
|
||||
VulkanTutorial02Parameters() :
|
||||
Instance( VK_NULL_HANDLE ),
|
||||
PhysicalDevice( VK_NULL_HANDLE ),
|
||||
Device( VK_NULL_HANDLE ),
|
||||
GraphicsQueue( VK_NULL_HANDLE ),
|
||||
PresentQueue( VK_NULL_HANDLE ),
|
||||
GraphicsQueueFamilyIndex( 0 ),
|
||||
PresentQueueFamilyIndex( 0 ),
|
||||
PresentationSurface( VK_NULL_HANDLE ),
|
||||
SwapChain( VK_NULL_HANDLE ),
|
||||
PresentQueueCmdBuffers( 0 ),
|
||||
PresentQueueCmdPool( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial02 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial02 : public OS::TutorialBase {
|
||||
public:
|
||||
Tutorial02();
|
||||
~Tutorial02();
|
||||
|
||||
bool PrepareVulkan( OS::WindowParameters parameters );
|
||||
bool CreateSwapChain();
|
||||
bool OnWindowSizeChanged() override;
|
||||
bool CreateCommandBuffers();
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
OS::LibraryHandle VulkanLibrary;
|
||||
OS::WindowParameters Window;
|
||||
VulkanTutorial02Parameters Vulkan;
|
||||
|
||||
bool LoadVulkanLibrary();
|
||||
bool LoadExportedEntryPoints();
|
||||
bool LoadGlobalLevelEntryPoints();
|
||||
bool CreateInstance();
|
||||
bool LoadInstanceLevelEntryPoints();
|
||||
bool CreatePresentationSurface();
|
||||
bool CreateDevice();
|
||||
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
|
||||
bool LoadDeviceLevelEntryPoints();
|
||||
bool GetDeviceQueue();
|
||||
bool CreateSemaphores();
|
||||
bool RecordCommandBuffers();
|
||||
void Clear();
|
||||
|
||||
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
|
||||
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats );
|
||||
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes );
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TUTORIAL_02_HEADER)
|
||||
#define TUTORIAL_02_HEADER
|
||||
|
||||
#include <vector>
|
||||
#include "vulkan.h"
|
||||
#include "OperatingSystem.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial02Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial02Parameters {
|
||||
VkInstance Instance;
|
||||
VkPhysicalDevice PhysicalDevice;
|
||||
VkDevice Device;
|
||||
VkQueue GraphicsQueue;
|
||||
VkQueue PresentQueue;
|
||||
uint32_t GraphicsQueueFamilyIndex;
|
||||
uint32_t PresentQueueFamilyIndex;
|
||||
VkSurfaceKHR PresentationSurface;
|
||||
VkSwapchainKHR SwapChain;
|
||||
std::vector<VkCommandBuffer> PresentQueueCmdBuffers;
|
||||
VkCommandPool PresentQueueCmdPool;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore RenderingFinishedSemaphore;
|
||||
|
||||
VulkanTutorial02Parameters() :
|
||||
Instance( VK_NULL_HANDLE ),
|
||||
PhysicalDevice( VK_NULL_HANDLE ),
|
||||
Device( VK_NULL_HANDLE ),
|
||||
GraphicsQueue( VK_NULL_HANDLE ),
|
||||
PresentQueue( VK_NULL_HANDLE ),
|
||||
GraphicsQueueFamilyIndex( 0 ),
|
||||
PresentQueueFamilyIndex( 0 ),
|
||||
PresentationSurface( VK_NULL_HANDLE ),
|
||||
SwapChain( VK_NULL_HANDLE ),
|
||||
PresentQueueCmdBuffers( 0 ),
|
||||
PresentQueueCmdPool( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial02 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial02 : public OS::TutorialBase {
|
||||
public:
|
||||
Tutorial02();
|
||||
~Tutorial02();
|
||||
|
||||
bool PrepareVulkan( OS::WindowParameters parameters );
|
||||
bool CreateSwapChain();
|
||||
bool OnWindowSizeChanged() override;
|
||||
bool CreateCommandBuffers();
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
OS::LibraryHandle VulkanLibrary;
|
||||
OS::WindowParameters Window;
|
||||
VulkanTutorial02Parameters Vulkan;
|
||||
|
||||
bool LoadVulkanLibrary();
|
||||
bool LoadExportedEntryPoints();
|
||||
bool LoadGlobalLevelEntryPoints();
|
||||
bool CreateInstance();
|
||||
bool LoadInstanceLevelEntryPoints();
|
||||
bool CreatePresentationSurface();
|
||||
bool CreateDevice();
|
||||
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
|
||||
bool LoadDeviceLevelEntryPoints();
|
||||
bool GetDeviceQueue();
|
||||
bool CreateSemaphores();
|
||||
bool RecordCommandBuffers();
|
||||
void Clear();
|
||||
|
||||
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
|
||||
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );
|
||||
@@ -1,39 +1,35 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "Tutorial02.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial02 tutorial02;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "02 - Swap chain" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial02.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial02.CreateSwapChain() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial02.CreateCommandBuffers() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rendering loop
|
||||
if( !window.RenderingLoop( tutorial02 ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Tutorial02.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial02 tutorial02;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "02 - Swap chain" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial02.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial02.CreateSwapChain() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial02.CreateCommandBuffers() ) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,77 +1,73 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TUTORIAL_03_HEADER)
|
||||
#define TUTORIAL_03_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial03Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial03Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
std::vector<VkFramebuffer> Framebuffers;
|
||||
VkPipeline GraphicsPipeline;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore RenderingFinishedSemaphore;
|
||||
VkCommandPool GraphicsCommandPool;
|
||||
std::vector<VkCommandBuffer> GraphicsCommandBuffers;
|
||||
|
||||
VulkanTutorial03Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
Framebuffers(),
|
||||
GraphicsCommandPool( VK_NULL_HANDLE ),
|
||||
GraphicsCommandBuffers(),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
RenderingFinishedSemaphore( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial03 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial03 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial03();
|
||||
~Tutorial03();
|
||||
|
||||
bool CreateRenderPass();
|
||||
bool CreateFramebuffers();
|
||||
bool CreatePipeline();
|
||||
bool CreateSemaphores();
|
||||
bool CreateCommandBuffers();
|
||||
bool RecordCommandBuffers();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial03Parameters Vulkan;
|
||||
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
|
||||
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
|
||||
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
|
||||
|
||||
void ChildClear() override;
|
||||
bool ChildOnWindowSizeChanged() override;
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TUTORIAL_03_HEADER)
|
||||
#define TUTORIAL_03_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial03Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial03Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
std::vector<VkFramebuffer> Framebuffers;
|
||||
VkPipeline GraphicsPipeline;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore RenderingFinishedSemaphore;
|
||||
VkCommandPool GraphicsCommandPool;
|
||||
std::vector<VkCommandBuffer> GraphicsCommandBuffers;
|
||||
|
||||
VulkanTutorial03Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
Framebuffers(),
|
||||
GraphicsCommandPool( VK_NULL_HANDLE ),
|
||||
GraphicsCommandBuffers(),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
RenderingFinishedSemaphore( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial03 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial03 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial03();
|
||||
~Tutorial03();
|
||||
|
||||
bool CreateRenderPass();
|
||||
bool CreateFramebuffers();
|
||||
bool CreatePipeline();
|
||||
bool CreateSemaphores();
|
||||
bool CreateCommandBuffers();
|
||||
bool RecordCommandBuffers();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial03Parameters Vulkan;
|
||||
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
|
||||
@@ -1,53 +1,49 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "Tutorial03.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial03 tutorial03;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "03 - First Triangle" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial03.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 03
|
||||
if( !tutorial03.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreateFramebuffers() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreateSemaphores() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreateCommandBuffers() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.RecordCommandBuffers() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rendering loop
|
||||
if( !window.RenderingLoop( tutorial03 ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Tutorial03.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial03 tutorial03;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "03 - First Triangle" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial03.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 03
|
||||
if( !tutorial03.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreateFramebuffers() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreateSemaphores() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.CreateCommandBuffers() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial03.RecordCommandBuffers() ) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,127 +1,123 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TUTORIAL_04_HEADER)
|
||||
#define TUTORIAL_04_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float r, g, b, a;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial04Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial04Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial04 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial04();
|
||||
~Tutorial04();
|
||||
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
bool CreateRenderingResources();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial04Parameters Vulkan;
|
||||
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
|
||||
bool AllocateBufferMemory( VkBuffer buffer, VkDeviceMemory *memory );
|
||||
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
|
||||
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
|
||||
bool CreateCommandBuffers();
|
||||
bool CreateSemaphores();
|
||||
bool CreateFences();
|
||||
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
|
||||
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
|
||||
|
||||
void ChildClear() override;
|
||||
bool ChildOnWindowSizeChanged() override;
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TUTORIAL_04_HEADER)
|
||||
#define TUTORIAL_04_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float r, g, b, a;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial04Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial04Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial04 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial04();
|
||||
~Tutorial04();
|
||||
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
bool CreateRenderingResources();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial04Parameters Vulkan;
|
||||
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
|
||||
bool AllocateBufferMemory( VkBuffer buffer, VkDeviceMemory *memory );
|
||||
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
|
||||
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
|
||||
bool CreateCommandBuffers();
|
||||
bool CreateSemaphores();
|
||||
bool CreateFences();
|
||||
@@ -1,47 +1,43 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "Tutorial04.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial04 tutorial04;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "04 - Vertex Attributes" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial04.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 04
|
||||
if( !tutorial04.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial04.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial04.CreateVertexBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial04.CreateRenderingResources() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rendering loop
|
||||
if( !window.RenderingLoop( tutorial04 ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Tutorial04.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial04 tutorial04;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "04 - Vertex Attributes" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial04.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 04
|
||||
if( !tutorial04.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial04.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial04.CreateVertexBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial04.CreateRenderingResources() ) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,133 +1,129 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TUTORIAL_05_HEADER)
|
||||
#define TUTORIAL_05_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float r, g, b, a;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial05Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
BufferParameters StagingBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial05Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
StagingBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial05 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial05();
|
||||
~Tutorial05();
|
||||
|
||||
bool CreateRenderingResources();
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
bool CreateStagingBuffer();
|
||||
bool CopyVertexData();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial05Parameters Vulkan;
|
||||
|
||||
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
|
||||
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
|
||||
bool CreateSemaphore( VkSemaphore *semaphore );
|
||||
bool CreateFence( VkFenceCreateFlags flags, VkFence *fence );
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
|
||||
bool CreateBuffer( VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer );
|
||||
bool AllocateBufferMemory( VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
|
||||
const std::vector<float>& GetVertexData() const;
|
||||
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
|
||||
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
|
||||
void DestroyBuffer( BufferParameters& buffer );
|
||||
|
||||
void ChildClear() override;
|
||||
bool ChildOnWindowSizeChanged() override;
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TUTORIAL_05_HEADER)
|
||||
#define TUTORIAL_05_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float r, g, b, a;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial05Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
BufferParameters StagingBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial05Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
StagingBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial05 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial05();
|
||||
~Tutorial05();
|
||||
|
||||
bool CreateRenderingResources();
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
bool CreateStagingBuffer();
|
||||
bool CopyVertexData();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial05Parameters Vulkan;
|
||||
|
||||
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
|
||||
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
|
||||
bool CreateSemaphore( VkSemaphore *semaphore );
|
||||
bool CreateFence( VkFenceCreateFlags flags, VkFence *fence );
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
|
||||
bool CreateBuffer( VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer );
|
||||
bool AllocateBufferMemory( VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
|
||||
const std::vector<float>& GetVertexData() const;
|
||||
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
|
||||
@@ -1,53 +1,49 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "Tutorial05.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial05 tutorial05;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "05 - Staging Resources" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial05.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 05
|
||||
if( !tutorial05.CreateRenderingResources() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreateVertexBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreateStagingBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CopyVertexData() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rendering loop
|
||||
if( !window.RenderingLoop( tutorial05 ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Tutorial05.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial05 tutorial05;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "05 - Staging Resources" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial05.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 05
|
||||
if( !tutorial05.CreateRenderingResources() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreateVertexBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CreateStagingBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial05.CopyVertexData() ) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,167 +1,163 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TUTORIAL_06_HEADER)
|
||||
#define TUTORIAL_06_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// DescriptorParameters //
|
||||
// //
|
||||
// Container class for descriptor related resources //
|
||||
// ************************************************************ //
|
||||
struct DescriptorSetParameters {
|
||||
VkDescriptorPool Pool;
|
||||
VkDescriptorSetLayout Layout;
|
||||
VkDescriptorSet Handle;
|
||||
|
||||
DescriptorSetParameters() :
|
||||
Pool( VK_NULL_HANDLE ),
|
||||
Layout( VK_NULL_HANDLE ),
|
||||
Handle( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial06Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
ImageParameters Image;
|
||||
DescriptorSetParameters DescriptorSet;
|
||||
VkPipelineLayout PipelineLayout;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
BufferParameters StagingBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial06Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
Image(),
|
||||
DescriptorSet(),
|
||||
PipelineLayout(),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
StagingBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial06 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial06();
|
||||
~Tutorial06();
|
||||
|
||||
bool CreateRenderingResources();
|
||||
bool CreateStagingBuffer();
|
||||
bool CreateTexture();
|
||||
bool CreateDescriptorSetLayout();
|
||||
bool CreateDescriptorPool();
|
||||
bool AllocateDescriptorSet();
|
||||
bool UpdateDescriptorSet();
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipelineLayout();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial06Parameters Vulkan;
|
||||
|
||||
bool CreateCommandBuffers();
|
||||
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
|
||||
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
|
||||
bool CreateSemaphores();
|
||||
bool CreateFences();
|
||||
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
|
||||
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
|
||||
bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
|
||||
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
|
||||
bool CreateImageView( ImageParameters &image_parameters );
|
||||
bool CreateSampler( VkSampler *sampler );
|
||||
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
const std::vector<float>& GetVertexData() const;
|
||||
bool CopyVertexData();
|
||||
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
|
||||
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
|
||||
void DestroyBuffer( BufferParameters& buffer );
|
||||
|
||||
bool ChildOnWindowSizeChanged() override;
|
||||
void ChildClear() override;
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TUTORIAL_06_HEADER)
|
||||
#define TUTORIAL_06_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// DescriptorParameters //
|
||||
// //
|
||||
// Container class for descriptor related resources //
|
||||
// ************************************************************ //
|
||||
struct DescriptorSetParameters {
|
||||
VkDescriptorPool Pool;
|
||||
VkDescriptorSetLayout Layout;
|
||||
VkDescriptorSet Handle;
|
||||
|
||||
DescriptorSetParameters() :
|
||||
Pool( VK_NULL_HANDLE ),
|
||||
Layout( VK_NULL_HANDLE ),
|
||||
Handle( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial06Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
ImageParameters Image;
|
||||
DescriptorSetParameters DescriptorSet;
|
||||
VkPipelineLayout PipelineLayout;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
BufferParameters StagingBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial06Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
Image(),
|
||||
DescriptorSet(),
|
||||
PipelineLayout(),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
StagingBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial06 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial06();
|
||||
~Tutorial06();
|
||||
|
||||
bool CreateRenderingResources();
|
||||
bool CreateStagingBuffer();
|
||||
bool CreateTexture();
|
||||
bool CreateDescriptorSetLayout();
|
||||
bool CreateDescriptorPool();
|
||||
bool AllocateDescriptorSet();
|
||||
bool UpdateDescriptorSet();
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipelineLayout();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial06Parameters Vulkan;
|
||||
|
||||
bool CreateCommandBuffers();
|
||||
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
|
||||
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
|
||||
bool CreateSemaphores();
|
||||
bool CreateFences();
|
||||
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
|
||||
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
|
||||
bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
|
||||
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
|
||||
bool CreateImageView( ImageParameters &image_parameters );
|
||||
bool CreateSampler( VkSampler *sampler );
|
||||
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
const std::vector<float>& GetVertexData() const;
|
||||
bool CopyVertexData();
|
||||
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
|
||||
@@ -1,68 +1,64 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "Tutorial06.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial06 tutorial06;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "06 - Descriptor Sets" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial06.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 06
|
||||
if( !tutorial06.CreateRenderingResources() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateStagingBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateTexture() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateDescriptorSetLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateDescriptorPool() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.AllocateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.UpdateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreatePipelineLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateVertexBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rendering loop
|
||||
if( !window.RenderingLoop( tutorial06 ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Tutorial06.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial06 tutorial06;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "06 - Descriptor Sets" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial06.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 06
|
||||
if( !tutorial06.CreateRenderingResources() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateStagingBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateTexture() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateDescriptorSetLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateDescriptorPool() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.AllocateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.UpdateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreatePipelineLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial06.CreateVertexBuffer() ) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,171 +1,167 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#if !defined(TUTORIAL_07_HEADER)
|
||||
#define TUTORIAL_07_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// DescriptorParameters //
|
||||
// //
|
||||
// Container class for descriptor related resources //
|
||||
// ************************************************************ //
|
||||
struct DescriptorSetParameters {
|
||||
VkDescriptorPool Pool;
|
||||
VkDescriptorSetLayout Layout;
|
||||
VkDescriptorSet Handle;
|
||||
|
||||
DescriptorSetParameters() :
|
||||
Pool( VK_NULL_HANDLE ),
|
||||
Layout( VK_NULL_HANDLE ),
|
||||
Handle( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial07Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
ImageParameters Image;
|
||||
BufferParameters UniformBuffer;
|
||||
DescriptorSetParameters DescriptorSet;
|
||||
VkPipelineLayout PipelineLayout;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
BufferParameters StagingBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial07Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
Image(),
|
||||
DescriptorSet(),
|
||||
PipelineLayout(),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
StagingBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial07 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial07();
|
||||
~Tutorial07();
|
||||
|
||||
bool CreateRenderingResources();
|
||||
bool CreateStagingBuffer();
|
||||
bool CreateTexture();
|
||||
bool CreateUniformBuffer();
|
||||
bool CreateDescriptorSetLayout();
|
||||
bool CreateDescriptorPool();
|
||||
bool AllocateDescriptorSet();
|
||||
bool UpdateDescriptorSet();
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipelineLayout();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial07Parameters Vulkan;
|
||||
|
||||
bool CreateCommandBuffers();
|
||||
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
|
||||
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
|
||||
bool CreateSemaphores();
|
||||
bool CreateFences();
|
||||
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
|
||||
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
|
||||
bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
|
||||
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
|
||||
bool CreateImageView( ImageParameters &image_parameters );
|
||||
bool CreateSampler( VkSampler *sampler );
|
||||
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
|
||||
const std::array<float, 16> GetUniformBufferData() const;
|
||||
bool CopyUniformBufferData();
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
const std::vector<float>& GetVertexData() const;
|
||||
bool CopyVertexData();
|
||||
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
|
||||
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
|
||||
void DestroyBuffer( BufferParameters& buffer );
|
||||
|
||||
bool ChildOnWindowSizeChanged() override;
|
||||
void ChildClear() override;
|
||||
};
|
||||
|
||||
} // namespace ApiWithoutSecrets
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(TUTORIAL_07_HEADER)
|
||||
#define TUTORIAL_07_HEADER
|
||||
|
||||
#include "VulkanCommon.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace ApiWithoutSecrets {
|
||||
|
||||
// ************************************************************ //
|
||||
// BufferParameters //
|
||||
// //
|
||||
// Vulkan Buffer's parameters container class //
|
||||
// ************************************************************ //
|
||||
struct BufferParameters {
|
||||
VkBuffer Handle;
|
||||
VkDeviceMemory Memory;
|
||||
uint32_t Size;
|
||||
|
||||
BufferParameters() :
|
||||
Handle( VK_NULL_HANDLE ),
|
||||
Memory( VK_NULL_HANDLE ),
|
||||
Size( 0 ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// DescriptorParameters //
|
||||
// //
|
||||
// Container class for descriptor related resources //
|
||||
// ************************************************************ //
|
||||
struct DescriptorSetParameters {
|
||||
VkDescriptorPool Pool;
|
||||
VkDescriptorSetLayout Layout;
|
||||
VkDescriptorSet Handle;
|
||||
|
||||
DescriptorSetParameters() :
|
||||
Pool( VK_NULL_HANDLE ),
|
||||
Layout( VK_NULL_HANDLE ),
|
||||
Handle( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VertexData //
|
||||
// //
|
||||
// Struct describing data type and format of vertex attributes //
|
||||
// ************************************************************ //
|
||||
struct VertexData {
|
||||
float x, y, z, w;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// RenderingResourcesData //
|
||||
// //
|
||||
// Struct containing data used during rendering process //
|
||||
// ************************************************************ //
|
||||
struct RenderingResourcesData {
|
||||
VkFramebuffer Framebuffer;
|
||||
VkCommandBuffer CommandBuffer;
|
||||
VkSemaphore ImageAvailableSemaphore;
|
||||
VkSemaphore FinishedRenderingSemaphore;
|
||||
VkFence Fence;
|
||||
|
||||
RenderingResourcesData() :
|
||||
Framebuffer( VK_NULL_HANDLE ),
|
||||
CommandBuffer( VK_NULL_HANDLE ),
|
||||
ImageAvailableSemaphore( VK_NULL_HANDLE ),
|
||||
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
|
||||
Fence( VK_NULL_HANDLE ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// VulkanTutorial04Parameters //
|
||||
// //
|
||||
// Vulkan specific parameters //
|
||||
// ************************************************************ //
|
||||
struct VulkanTutorial07Parameters {
|
||||
VkRenderPass RenderPass;
|
||||
ImageParameters Image;
|
||||
BufferParameters UniformBuffer;
|
||||
DescriptorSetParameters DescriptorSet;
|
||||
VkPipelineLayout PipelineLayout;
|
||||
VkPipeline GraphicsPipeline;
|
||||
BufferParameters VertexBuffer;
|
||||
BufferParameters StagingBuffer;
|
||||
VkCommandPool CommandPool;
|
||||
std::vector<RenderingResourcesData> RenderingResources;
|
||||
|
||||
static const size_t ResourcesCount = 3;
|
||||
|
||||
VulkanTutorial07Parameters() :
|
||||
RenderPass( VK_NULL_HANDLE ),
|
||||
Image(),
|
||||
DescriptorSet(),
|
||||
PipelineLayout(),
|
||||
GraphicsPipeline( VK_NULL_HANDLE ),
|
||||
VertexBuffer(),
|
||||
StagingBuffer(),
|
||||
CommandPool( VK_NULL_HANDLE ),
|
||||
RenderingResources( ResourcesCount ) {
|
||||
}
|
||||
};
|
||||
|
||||
// ************************************************************ //
|
||||
// Tutorial04 //
|
||||
// //
|
||||
// Class for presenting Vulkan usage topics //
|
||||
// ************************************************************ //
|
||||
class Tutorial07 : public VulkanCommon {
|
||||
public:
|
||||
Tutorial07();
|
||||
~Tutorial07();
|
||||
|
||||
bool CreateRenderingResources();
|
||||
bool CreateStagingBuffer();
|
||||
bool CreateTexture();
|
||||
bool CreateUniformBuffer();
|
||||
bool CreateDescriptorSetLayout();
|
||||
bool CreateDescriptorPool();
|
||||
bool AllocateDescriptorSet();
|
||||
bool UpdateDescriptorSet();
|
||||
bool CreateRenderPass();
|
||||
bool CreatePipelineLayout();
|
||||
bool CreatePipeline();
|
||||
bool CreateVertexBuffer();
|
||||
|
||||
bool Draw() override;
|
||||
|
||||
private:
|
||||
VulkanTutorial07Parameters Vulkan;
|
||||
|
||||
bool CreateCommandBuffers();
|
||||
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
|
||||
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
|
||||
bool CreateSemaphores();
|
||||
bool CreateFences();
|
||||
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
|
||||
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
|
||||
bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
|
||||
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
|
||||
bool CreateImageView( ImageParameters &image_parameters );
|
||||
bool CreateSampler( VkSampler *sampler );
|
||||
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
|
||||
const std::array<float, 16> GetUniformBufferData() const;
|
||||
bool CopyUniformBufferData();
|
||||
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
|
||||
const std::vector<float>& GetVertexData() const;
|
||||
bool CopyVertexData();
|
||||
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
|
||||
@@ -1,71 +1,67 @@
|
||||
// Copyright 2016 Intel Corporation All Rights Reserved
|
||||
//
|
||||
// Intel makes no representations about the suitability of this software for any purpose.
|
||||
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// Intel does not assume any responsibility for any errors which may appear in this software
|
||||
// nor any responsibility to update it.
|
||||
|
||||
#include "Tutorial07.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial07 tutorial07;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "07 - Uniform Buffers" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial07.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 06
|
||||
if( !tutorial07.CreateRenderingResources() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateStagingBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateTexture() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateUniformBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateDescriptorSetLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateDescriptorPool() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.AllocateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.UpdateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreatePipelineLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateVertexBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Rendering loop
|
||||
if( !window.RenderingLoop( tutorial07 ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Tutorial07.h"
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
ApiWithoutSecrets::OS::Window window;
|
||||
ApiWithoutSecrets::Tutorial07 tutorial07;
|
||||
|
||||
// Window creation
|
||||
if( !window.Create( "07 - Uniform Buffers" ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Vulkan preparations and initialization
|
||||
if( !tutorial07.PrepareVulkan( window.GetParameters() ) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Tutorial 06
|
||||
if( !tutorial07.CreateRenderingResources() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateStagingBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateTexture() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateUniformBuffer() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateDescriptorSetLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateDescriptorPool() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.AllocateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.UpdateDescriptorSet() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateRenderPass() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreatePipelineLayout() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreatePipeline() ) {
|
||||
return -1;
|
||||
}
|
||||
if( !tutorial07.CreateVertexBuffer() ) {
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Copyright 2016 Intel Corporation All Rights Reserved
|
||||
REM
|
||||
REM Intel makes no representations about the suitability of this software for any purpose.
|
||||
REM THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
REM EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
REM FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
REM RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
REM Intel does not assume any responsibility for any errors which may appear in this software
|
||||
REM nor any responsibility to update it.
|
||||
REM /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
REM // Copyright 2017 Intel Corporation
|
||||
REM //
|
||||
REM // Licensed under the Apache License, Version 2.0 (the "License");
|
||||
REM // you may not use this file except in compliance with the License.
|
||||
REM // You may obtain a copy of the License at
|
||||
REM //
|
||||
REM // http://www.apache.org/licenses/LICENSE-2.0
|
||||
REM //
|
||||
REM // Unless required by applicable law or agreed to in writing, software
|
||||
REM // distributed under the License is distributed on an "AS IS" BASIS,
|
||||
REM // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
REM // See the License for the specific language governing permissions and
|
||||
REM // limitations under the License.
|
||||
REM /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo Preparing 'IntroductionToVulkan' solution...
|
||||
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
@ECHO OFF
|
||||
SETLOCAL
|
||||
|
||||
REM Copyright 2016 Intel Corporation All Rights Reserved
|
||||
REM
|
||||
REM Intel makes no representations about the suitability of this software for any purpose.
|
||||
REM THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
REM EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES,
|
||||
REM FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
|
||||
REM RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
REM Intel does not assume any responsibility for any errors which may appear in this software
|
||||
REM nor any responsibility to update it.
|
||||
|
||||
if [%1] == [] (
|
||||
echo No arguments provided! Please specify folder number.
|
||||
echo Example usage: compile_shaders.bat 03
|
||||
goto end
|
||||
)
|
||||
|
||||
if exist glslangValidator.exe (
|
||||
goto convert
|
||||
)
|
||||
for %%X in (glslangValidator.exe) do (set glslangValidator=%%~$PATH:X)
|
||||
if defined glslangValidator (
|
||||
goto convert
|
||||
)
|
||||
|
||||
echo Could not find "glslangValidator.exe" file.
|
||||
goto end
|
||||
|
||||
:convert
|
||||
|
||||
set folder=Tutorial%1/Data%1
|
||||
echo Converting GLSL shaders into SPIR-V assembly in the "%folder%" folder.
|
||||
|
||||
if exist %folder%/shader.vert (
|
||||
glslangValidator.exe -V -H -o %folder%/vert.spv %folder%/shader.vert > %folder%/vert.spv.txt
|
||||
)
|
||||
|
||||
if exist %folder%/shader.frag (
|
||||
glslangValidator.exe -V -H -o %folder%/frag.spv %folder%/shader.frag > %folder%/frag.spv.txt
|
||||
)
|
||||
|
||||
:end
|
||||
|
||||
@ECHO OFF
|
||||
SETLOCAL
|
||||
|
||||
REM /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
REM // Copyright 2017 Intel Corporation
|
||||
REM //
|
||||
REM // Licensed under the Apache License, Version 2.0 (the "License");
|
||||
REM // you may not use this file except in compliance with the License.
|
||||
REM // You may obtain a copy of the License at
|
||||
REM //
|
||||
REM // http://www.apache.org/licenses/LICENSE-2.0
|
||||
REM //
|
||||
REM // Unless required by applicable law or agreed to in writing, software
|
||||
REM // distributed under the License is distributed on an "AS IS" BASIS,
|
||||
REM // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
REM // See the License for the specific language governing permissions and
|
||||
REM // limitations under the License.
|
||||
REM /////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if [%1] == [] (
|
||||
echo No arguments provided! Please specify folder number.
|
||||
echo Example usage: compile_shaders.bat 03
|
||||
goto end
|
||||
)
|
||||
|
||||
if exist glslangValidator.exe (
|
||||
goto convert
|
||||
)
|
||||
for %%X in (glslangValidator.exe) do (set glslangValidator=%%~$PATH:X)
|
||||
if defined glslangValidator (
|
||||
goto convert
|
||||
)
|
||||
|
||||
echo Could not find "glslangValidator.exe" file.
|
||||
goto end
|
||||
|
||||
:convert
|
||||
|
||||
set folder=Tutorial%1/Data%1
|
||||
echo Converting GLSL shaders into SPIR-V assembly in the "%folder%" folder.
|
||||
|
||||
if exist %folder%/shader.vert (
|
||||
375
license.txt
375
license.txt
@@ -1,258 +1,181 @@
|
||||
Code Samples License Agreement (Version December 2015)
|
||||
|
||||
IMPORTANT - READ BEFORE COPYING, INSTALLING OR USING. Do not copy, install or
|
||||
use the Materials (as defined below) provided under this license agreement
|
||||
("Agreement") from Intel Corporation ("Intel"), until you ("You") have carefully
|
||||
read the following terms and conditions. By copying, installing or otherwise
|
||||
using the Materials, You agree to be bound by the terms of this Agreement. If
|
||||
You do not agree to the terms of this Agreement, do not copy, install or use the
|
||||
Materials.
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
|
||||
If You are agreeing to the terms and conditions of this Agreement on behalf of a
|
||||
company or other legal entity ("Legal Entity"), You represent and warrant that
|
||||
You have the legal authority to bind that Legal Entity to the Agreement, in
|
||||
which case, "You" or "Your" will mean such Legal Entity.
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
By agreeing to this Agreement, You affirm that You are of legal age (18 years
|
||||
old or older) to enter into this Agreement. If You are not of legal age You may
|
||||
not enter into this Agreement, and either Your parent, legal guardian or Legal
|
||||
Entity must agree to the terms and conditions of this Agreement and enter into
|
||||
this Agreement, in which case, "You" or "Your" will mean such parent, legal
|
||||
guardian, or Legal Entity.
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Third Party Programs (as defined below), even if included with the distribution
|
||||
of the Materials, are governed by separate third party license terms, including
|
||||
without limitation, open source software license terms. Such third party license
|
||||
terms (and not this Agreement) govern Your use of the Third Party Programs, and
|
||||
Intel is not liable for the Third Party Programs.
|
||||
1. Definitions.
|
||||
|
||||
1. LICENSE DEFINITIONS:
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensed Patent Claims" means the claims of Intel's patents that are
|
||||
necessarily and directly infringed by the reproduction and distribution of the
|
||||
Materials that is authorized in Section 2 below, when the Materials are in its
|
||||
unmodified form as delivered by Intel to You and not modified or combined with
|
||||
anything else. Licensed Patent Claims are only those claims that Intel can
|
||||
license without paying, or getting the consent of, a third party.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
"Materials" means Sample Source Code, Redistributables, and End-User
|
||||
Documentation but do not include Third Party Programs.
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, "control" means (i) the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"Sample Source Code" means Source Code files that are identified as sample code
|
||||
and which may include example interface or application source code, and any
|
||||
updates, provided under this Agreement.
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
"Source Code" is defined as the software (and not documentation or text) portion
|
||||
of the Materials provided in human readable format, and includes modifications
|
||||
that You make or are made on Your behalf as expressly permitted under the terms
|
||||
of this Agreement.
|
||||
"Source" form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
"Redistributables" means header, library, and dynamically linkable library
|
||||
files, and any updates, provided under this Agreement.
|
||||
"Object" form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
"Third Party Programs" (if any) are the third party software files that may be
|
||||
included with the Materials for the applicable software that include a separate
|
||||
third party license agreement in an attached text file.
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"End-User Documentation" means textual materials intended for end users relating
|
||||
to the Materials.
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
2. LICENSE GRANT:
|
||||
"Contribution" shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
Subject to the terms and conditions of this Agreement, Intel grants You a
|
||||
non-exclusive, worldwide, non-assignable, royalty-free limited right and
|
||||
license:
|
||||
A. under its copyrights, to:
|
||||
1) Copy, modify, and compile the Sample Source Code and distribute it solely
|
||||
in Your products in executable and source code form;
|
||||
2) Copy and distribute the Redistributables solely with Your products;
|
||||
3) Copy, modify, and distribute the End User Documentation solely with Your
|
||||
products.
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
B. Under its patents, to:
|
||||
1) make copies of the Materials internally only;
|
||||
2) use the Materials internally only; and 3) offer to distribute, and
|
||||
distribute, but not sell, the Materials only as part of or with Your
|
||||
products, under Intel's copyright license granted in Section 2(A) but only
|
||||
under the terms of that copyright license and not as a sale (but this
|
||||
right does not include the right to sub-license);
|
||||
4) provided, further, that the license under the Licensed Patent Claims does
|
||||
not and will not apply to any modifications to, or derivative works of,
|
||||
the Materials, whether made by You, Your end user (which, for all purposes
|
||||
under this Agreement, will mean either an end user, a customer, reseller,
|
||||
distributor or other channel partner), or any third party even if the
|
||||
modification and creation of derivative works are permitted under 2(A).
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this
|
||||
License, each Contributor hereby grants to You a perpetual, worldwide,
|
||||
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
||||
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
||||
sublicense, and distribute the Work and such Derivative Works in Source or
|
||||
Object form.
|
||||
|
||||
3. LICENSE RESTRICTIONS:
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
||||
license to make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer the Work, where such license applies only to those patent claims
|
||||
licensable by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s) with the Work
|
||||
to which such Contribution(s) was submitted. If You institute patent litigation
|
||||
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
||||
alleging that the Work or a Contribution incorporated within the Work
|
||||
constitutes direct or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate as of the date
|
||||
such litigation is filed.
|
||||
|
||||
Except as expressly provided in this Agreement, You may not:
|
||||
i. use, copy, distribute or publicly display the Materials;
|
||||
ii. reverse-assemble, reverse-compile, or otherwise reverse-engineer any
|
||||
software provided solely in binary form,
|
||||
iii. rent or lease the Materials to any third party;
|
||||
iv. assign this Agreement or display the Materials;
|
||||
v. assign this Agreement or transfer the Materials;
|
||||
vi. modify, adapt or translate the Materials in whole or in part;
|
||||
vii. distribute, sublicense or transfer the source code form of the Materials
|
||||
or derivatives thereof to any third party;
|
||||
viii. distribute the Materials except as part of Your products;
|
||||
ix. include the Materials in malicious, deceptive, or unlawful programs or
|
||||
products;
|
||||
x. modify, create a derivative work, link or distribute the Materials so that
|
||||
any part of it becomes subject to an Excluded License.
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or
|
||||
Derivative Works thereof in any medium, with or without modifications, and in
|
||||
Source or Object form, provided that You meet the following conditions:
|
||||
You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
|
||||
Upon Intel's release of an update, upgrade, or new version of the Materials, you
|
||||
will make reasonable efforts to discontinue distribution of the enclosed
|
||||
Materials and you will make reasonable efforts to distribute such updates,
|
||||
upgrades, or new versions to your customers who have received the Materials
|
||||
herein.
|
||||
|
||||
Distribution of the Materials is also subject to the following limitations.
|
||||
You:
|
||||
i. will be solely responsible to your customers for any update or support
|
||||
obligation or other liability which may arise from the distribution;
|
||||
ii. will not make any statement that your product is "certified", or that its
|
||||
performance is guaranteed, by Intel;
|
||||
iii. will not use Intel's name or trademarks to market your product without
|
||||
written permission;
|
||||
iv. will prohibit disassembly and reverse engineering of the Materials
|
||||
provided in executable form;
|
||||
v. will not publish reviews of Materials without written permission by Intel,
|
||||
and
|
||||
vi. will indemnify, hold harmless, and defend Intel and its suppliers from and
|
||||
against any claims or lawsuits, including attorney's fees, that arise or
|
||||
result from your distribution of any product.
|
||||
You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
|
||||
4. OWNERSHIP:
|
||||
|
||||
Title to the Materials and all copies thereof remain with Intel or its
|
||||
suppliers. The Materials are copyrighted and are protected by United States
|
||||
copyright laws and international treaty provisions. You will not remove any
|
||||
copyright notice from the Materials. You agree to prevent unauthorized copying
|
||||
of the Materials. Except as expressly provided herein, Intel does not grant any
|
||||
express or implied right to you under Intel patents, copyrights, trademarks, or
|
||||
trade secret information.
|
||||
You must retain, in the Source form of any Derivative Works that You
|
||||
distribute, all copyright, patent, trademark, and attribution notices from the
|
||||
Source form of the Work, excluding those notices that do not pertain to any
|
||||
part of the Derivative Works; and
|
||||
|
||||
5. NO WARRANTY AND NO SUPPORT:
|
||||
|
||||
Disclaimer. Intel disclaims all warranties of any kind and the terms and
|
||||
remedies provided in this Agreement are instead of any other warranty or
|
||||
condition, express, implied or statutory, including those regarding
|
||||
merchantability, fitness for any particular purpose, non-infringement or any
|
||||
warranty arising out of any course of dealing, usage of trade, proposal,
|
||||
specification or sample. Intel does not assume (and does not authorize any
|
||||
person to assume on its behalf) any other liability.
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then
|
||||
any Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of
|
||||
the following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
Intel may make changes to the Materials, or to items referenced therein, at any
|
||||
time without notice, but is not obligated to support, update or provide training
|
||||
for the Materials. Intel may in its sole discretion offer such support, update
|
||||
or training services under separate terms at Intel's then-current rates. You
|
||||
may request additional information on Intel's service offerings from an Intel
|
||||
sales representative.
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
||||
Contribution intentionally submitted for inclusion in the Work by You to the
|
||||
Licensor shall be under the terms and conditions of this License, without any
|
||||
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
||||
supersede or modify the terms of any separate license agreement you may have
|
||||
executed with Licensor regarding such Contributions.
|
||||
|
||||
6. USER SUBMISSIONS:
|
||||
6. Trademarks. This License does not grant permission to use the trade names,
|
||||
trademarks, service marks, or product names of the Licensor, except as required
|
||||
for reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
You agree that any material, information, or other communication, including all
|
||||
data, images, sounds, text, and other things embodied therein, you transmit or
|
||||
post to an Intel website will be considered non-confidential ("Communications").
|
||||
Intel will have no confidentiality obligations with respect to the
|
||||
Communications. You agree that Intel and its designees will be free to copy,
|
||||
modify, create derivative works, publicly display, disclose, distribute, license
|
||||
and sublicense through multiple tiers of distribution and licensees,
|
||||
incorporate, and otherwise use the Communications, including derivative works
|
||||
thereto, for any and all commercial or non-commercial purposes.
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
||||
writing, Licensor provides the Work (and each Contributor provides its
|
||||
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied, including, without limitation, any warranties
|
||||
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any risks
|
||||
associated with Your exercise of permissions under this License.
|
||||
|
||||
7.LIMITATION OF LIABILITY:
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in
|
||||
tort (including negligence), contract, or otherwise, unless required by
|
||||
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
||||
writing, shall any Contributor be liable to You for damages, including any
|
||||
direct, indirect, special, incidental, or consequential damages of any character
|
||||
arising as a result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
||||
computer failure or malfunction, or any and all other commercial damages or
|
||||
losses), even if such Contributor has been advised of the possibility of such
|
||||
damages.
|
||||
|
||||
Neither Intel nor its suppliers shall be liable for any damages whatsoever
|
||||
(including, without limitation, damages for loss of business profits, business
|
||||
interruption, loss of business information, or other loss) arising out of the
|
||||
use of or inability to use the Materials, even if Intel has been advised of the
|
||||
possibility of such damages. Because some jurisdictions prohibit the exclusion
|
||||
or limitation of liability for consequential or incidental damages, the above
|
||||
limitation may not apply to You.
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
||||
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
||||
acceptance of support, warranty, indemnity, or other liability obligations
|
||||
and/or rights consistent with this License. However, in accepting such
|
||||
obligations, You may act only on Your own behalf and on Your sole
|
||||
responsibility, not on behalf of any other Contributor, and only if You agree to
|
||||
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
||||
by, or claims asserted against, such Contributor by reason of your accepting any
|
||||
such warranty or additional liability.
|
||||
|
||||
8. TERM AND TERMINATION:
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
This Agreement commences upon Your copying, installing or using the Materials
|
||||
and continues until terminated. Either You or Intel may terminate this
|
||||
Agreement at any time upon 30 days prior written notice to the other party.
|
||||
Intel may terminate this license at any time if you are in breach of any of its
|
||||
terms and conditions. Upon termination, You will immediately destroy the
|
||||
Materials or return all copies of the Materials to Intel along with any copies
|
||||
You have made. After termination, the license grant to any Materials or
|
||||
Redistributables distributed by You in accordance with the terms and conditions
|
||||
of this Agreement, prior to the effective date of such termination, will survive
|
||||
any such termination of this Agreement.
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
9. U.S. GOVERNMENT RESTRICTED RIGHTS:
|
||||
|
||||
The technical data and computer software covered by this license is a
|
||||
"Commercial Item", as such term is defined by the FAR 2.101 (48 C.F.R. 2.101)
|
||||
and is "commercial computer software" and "commercial computer software
|
||||
documentation" as specified under FAR 12.212 (48 C.F.R. 12.212) or DFARS
|
||||
227.7202 (48 C.F.R. 227.7202), as applicable. This commercial computer software
|
||||
and related documentation is provided to end users for use by and on behalf of
|
||||
the U.S. Government, with only those rights as are granted to all other end
|
||||
users pursuant to the terms and conditions herein. Use for or on behalf of the
|
||||
U.S. Government is permitted only if the party acquiring or using this software
|
||||
is properly authorized by an appropriate U.S. Government official. This use by
|
||||
or for the U.S. Government clause is in lieu of, and supersedes, any other FAR,
|
||||
DFARS, or other provision that addresses Government rights in the computer
|
||||
software or documentation covered by this license. All copyright licenses
|
||||
granted to the U.S. Government are coextensive with the technical data and
|
||||
computer software licenses granted herein. The U.S. Government will only have
|
||||
the right to reproduce, distribute, perform, display, and prepare derivative
|
||||
works as needed to implement those rights.
|
||||
|
||||
10. APPLICABLE LAWS:
|
||||
|
||||
All disputes arising out of or related to this Agreement, whether based on
|
||||
contract, tort, or any other legal or equitable theory, will in all respects be
|
||||
governed by, and construed and interpreted under, the laws of the United States
|
||||
of America and the State of Delaware, without reference to conflict of laws
|
||||
principles. The parties agree that the United Nations Convention on Contracts
|
||||
for the International Sale of Goods (1980) is specifically excluded from and
|
||||
will not apply to this Agreement. All disputes arising out of or related to this
|
||||
Agreement, whether based on contract, tort, or any other legal or equitable
|
||||
theory, will be subject to the exclusive jurisdiction of the courts of the State
|
||||
of Delaware or of the Federal courts sitting in that State. Each party submits
|
||||
to the personal jurisdiction of those courts and waives all objections to that
|
||||
jurisdiction and venue for those disputes.
|
||||
|
||||
10. SEVERABILITY:
|
||||
|
||||
The parties intend that if a court holds that any provision or part of this
|
||||
Agreement is invalid or unenforceable under applicable law, the court will
|
||||
modify the provision to the minimum extent necessary to make it valid and
|
||||
enforceable, or if it cannot be made valid and enforceable, the parties intend
|
||||
that the court will sever and delete the provision or part from this Agreement.
|
||||
Any change to or deletion of a provision or part of this Agreement under this
|
||||
Section will not affect the validity or enforceability of the remainder of this
|
||||
Agreement, which will continue in full force and effect.
|
||||
|
||||
11. EXPORT:
|
||||
|
||||
You must comply with all laws and regulations of the United States and other
|
||||
countries governing the export, re-export, import, transfer, distribution, use,
|
||||
and servicing of Software. In particular, You must not: (a) sell or transfer
|
||||
Software to a country subject to sanctions, or to any entity listed on a denial
|
||||
order published by the United States government or any other relevant
|
||||
government; or (b) use, sell, or transfer Software for the development, design,
|
||||
manufacture, or production of nuclear, missile, chemical or biological weapons,
|
||||
or for any other purpose prohibited by the United States government or other
|
||||
applicable government; without first obtaining all authorizations required by
|
||||
all applicable laws. For more details on Your export obligations, please visit
|
||||
http://www.intel.com/content/www/us/en/legal/export-compliance.html?wapkw=export.
|
||||
|
||||
12. ENTIRE AGREEMENT:
|
||||
|
||||
This Agreement contains the complete and exclusive agreement and understanding
|
||||
between the parties concerning the subject matter of this Agreement, and
|
||||
supersedes all prior and contemporaneous proposals, agreements, understanding,
|
||||
negotiations, representations, warranties, conditions, and communications, oral
|
||||
or written, between the parties relating to the same subject matter. No
|
||||
modification or amendment to this Agreement will be effective unless in writing
|
||||
and signed by authorized representatives of each party, and must specifically
|
||||
identify this Agreement.
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets "[]" replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same "printed page" as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner] Licensed under the Apache License,
|
||||
Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or
|
||||
agreed to in writing, software distributed under the License is distributed on
|
||||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Reference in New Issue
Block a user