Updated License to Apache 2.0

This commit is contained in:
codergirl42
2017-04-21 16:20:21 -07:00
parent 8e634b23bc
commit 561ac8c3c7
34 changed files with 9141 additions and 9330 deletions

View File

@@ -1,12 +1,18 @@
# Copyright 2016 Intel Corporation All Rights Reserved # /////////////////////////////////////////////////////////////////////////////////////////////
# # // Copyright 2017 Intel Corporation
# Intel makes no representations about the suitability of this software for any purpose. # //
# THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, # // Licensed under the Apache License, Version 2.0 (the "License");
# EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, # // you may not use this file except in compliance with the License.
# FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY # // You may obtain a copy of the License at
# 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 # // http://www.apache.org/licenses/LICENSE-2.0
# nor any responsibility to update it. # //
# // 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) cmake_minimum_required (VERSION 3.0)
project( "IntroductionToVulkan" ) project( "IntroductionToVulkan" )

View File

@@ -1,179 +1,175 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
// ************************************************************ // // distributed under the License is distributed on an "AS IS" BASIS,
// Exported functions // // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// // // See the License for the specific language governing permissions and
// These functions are always exposed by vulkan libraries. // // limitations under the License.
// ************************************************************ // /////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(VK_EXPORTED_FUNCTION) // ************************************************************ //
#define VK_EXPORTED_FUNCTION( fun ) // Exported functions //
#endif // //
// These functions are always exposed by vulkan libraries. //
VK_EXPORTED_FUNCTION( vkGetInstanceProcAddr ) // ************************************************************ //
#undef VK_EXPORTED_FUNCTION #if !defined(VK_EXPORTED_FUNCTION)
#define VK_EXPORTED_FUNCTION( fun )
#endif
// ************************************************************ //
// Global level functions // VK_EXPORTED_FUNCTION( vkGetInstanceProcAddr )
// //
// They allow checking what instance extensions are available // #undef VK_EXPORTED_FUNCTION
// and allow creation of a Vulkan Instance. //
// ************************************************************ //
// ************************************************************ //
#if !defined(VK_GLOBAL_LEVEL_FUNCTION) // Global level functions //
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) // //
#endif // They allow checking what instance extensions are available //
// and allow creation of a Vulkan Instance. //
// Tutorial 01 // ************************************************************ //
VK_GLOBAL_LEVEL_FUNCTION( vkCreateInstance )
#if !defined(VK_GLOBAL_LEVEL_FUNCTION)
// Tutorial 02 #define VK_GLOBAL_LEVEL_FUNCTION( fun )
VK_GLOBAL_LEVEL_FUNCTION( vkEnumerateInstanceExtensionProperties ) #endif
#undef VK_GLOBAL_LEVEL_FUNCTION // Tutorial 01
VK_GLOBAL_LEVEL_FUNCTION( vkCreateInstance )
// ************************************************************ // // Tutorial 02
// Instance level functions // VK_GLOBAL_LEVEL_FUNCTION( vkEnumerateInstanceExtensionProperties )
// //
// These functions allow for device queries and creation. // #undef VK_GLOBAL_LEVEL_FUNCTION
// They help choose which device is well suited for our needs. //
// ************************************************************ //
// ************************************************************ //
#if !defined(VK_INSTANCE_LEVEL_FUNCTION) // Instance level functions //
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) // //
#endif // These functions allow for device queries and creation. //
// They help choose which device is well suited for our needs. //
// Tutorial 01 // ************************************************************ //
VK_INSTANCE_LEVEL_FUNCTION( vkEnumeratePhysicalDevices )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceProperties ) #if !defined(VK_INSTANCE_LEVEL_FUNCTION)
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceFeatures ) #define VK_INSTANCE_LEVEL_FUNCTION( fun )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceQueueFamilyProperties ) #endif
VK_INSTANCE_LEVEL_FUNCTION( vkCreateDevice )
VK_INSTANCE_LEVEL_FUNCTION( vkGetDeviceProcAddr ) // Tutorial 01
VK_INSTANCE_LEVEL_FUNCTION( vkDestroyInstance ) VK_INSTANCE_LEVEL_FUNCTION( vkEnumeratePhysicalDevices )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceProperties )
// Tutorial 02 VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceFeatures )
VK_INSTANCE_LEVEL_FUNCTION( vkEnumerateDeviceExtensionProperties ) VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceQueueFamilyProperties )
#if defined(USE_SWAPCHAIN_EXTENSIONS) VK_INSTANCE_LEVEL_FUNCTION( vkCreateDevice )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceSupportKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkGetDeviceProcAddr )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceCapabilitiesKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkDestroyInstance )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceFormatsKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfacePresentModesKHR ) // Tutorial 02
VK_INSTANCE_LEVEL_FUNCTION( vkDestroySurfaceKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkEnumerateDeviceExtensionProperties )
#if defined(VK_USE_PLATFORM_WIN32_KHR) #if defined(USE_SWAPCHAIN_EXTENSIONS)
VK_INSTANCE_LEVEL_FUNCTION( vkCreateWin32SurfaceKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceSupportKHR )
#elif defined(VK_USE_PLATFORM_XCB_KHR) VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceCapabilitiesKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXcbSurfaceKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceFormatsKHR )
#elif defined(VK_USE_PLATFORM_XLIB_KHR) VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfacePresentModesKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXlibSurfaceKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkDestroySurfaceKHR )
#endif #if defined(VK_USE_PLATFORM_WIN32_KHR)
#endif VK_INSTANCE_LEVEL_FUNCTION( vkCreateWin32SurfaceKHR )
#elif defined(VK_USE_PLATFORM_XCB_KHR)
// Tutorial 04 VK_INSTANCE_LEVEL_FUNCTION( vkCreateXcbSurfaceKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceMemoryProperties ) #elif defined(VK_USE_PLATFORM_XLIB_KHR)
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXlibSurfaceKHR )
#undef VK_INSTANCE_LEVEL_FUNCTION #endif
#endif
// ************************************************************ // // Tutorial 04
// Device level functions // VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceMemoryProperties )
// //
// These functions are used mainly for drawing // #undef VK_INSTANCE_LEVEL_FUNCTION
// ************************************************************ //
#if !defined(VK_DEVICE_LEVEL_FUNCTION) // ************************************************************ //
#define VK_DEVICE_LEVEL_FUNCTION( fun ) // Device level functions //
#endif // //
// These functions are used mainly for drawing //
// Tutorial 01 // ************************************************************ //
VK_DEVICE_LEVEL_FUNCTION( vkGetDeviceQueue )
VK_DEVICE_LEVEL_FUNCTION( vkDeviceWaitIdle ) #if !defined(VK_DEVICE_LEVEL_FUNCTION)
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDevice ) #define VK_DEVICE_LEVEL_FUNCTION( fun )
#endif
// Tutorial 02
VK_DEVICE_LEVEL_FUNCTION( vkCreateSemaphore ) // Tutorial 01
VK_DEVICE_LEVEL_FUNCTION( vkCreateCommandPool ) VK_DEVICE_LEVEL_FUNCTION( vkGetDeviceQueue )
VK_DEVICE_LEVEL_FUNCTION( vkAllocateCommandBuffers ) VK_DEVICE_LEVEL_FUNCTION( vkDeviceWaitIdle )
VK_DEVICE_LEVEL_FUNCTION( vkBeginCommandBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyDevice )
VK_DEVICE_LEVEL_FUNCTION( vkCmdPipelineBarrier )
VK_DEVICE_LEVEL_FUNCTION( vkCmdClearColorImage ) // Tutorial 02
VK_DEVICE_LEVEL_FUNCTION( vkEndCommandBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkCreateSemaphore )
VK_DEVICE_LEVEL_FUNCTION( vkQueueSubmit ) VK_DEVICE_LEVEL_FUNCTION( vkCreateCommandPool )
VK_DEVICE_LEVEL_FUNCTION( vkFreeCommandBuffers ) VK_DEVICE_LEVEL_FUNCTION( vkAllocateCommandBuffers )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyCommandPool ) VK_DEVICE_LEVEL_FUNCTION( vkBeginCommandBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkDestroySemaphore ) VK_DEVICE_LEVEL_FUNCTION( vkCmdPipelineBarrier )
#if defined(USE_SWAPCHAIN_EXTENSIONS) VK_DEVICE_LEVEL_FUNCTION( vkCmdClearColorImage )
VK_DEVICE_LEVEL_FUNCTION( vkCreateSwapchainKHR ) VK_DEVICE_LEVEL_FUNCTION( vkEndCommandBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkGetSwapchainImagesKHR ) VK_DEVICE_LEVEL_FUNCTION( vkQueueSubmit )
VK_DEVICE_LEVEL_FUNCTION( vkAcquireNextImageKHR ) VK_DEVICE_LEVEL_FUNCTION( vkFreeCommandBuffers )
VK_DEVICE_LEVEL_FUNCTION( vkQueuePresentKHR ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyCommandPool )
VK_DEVICE_LEVEL_FUNCTION( vkDestroySwapchainKHR ) VK_DEVICE_LEVEL_FUNCTION( vkDestroySemaphore )
#endif #if defined(USE_SWAPCHAIN_EXTENSIONS)
VK_DEVICE_LEVEL_FUNCTION( vkCreateSwapchainKHR )
// Tutorial 03 VK_DEVICE_LEVEL_FUNCTION( vkGetSwapchainImagesKHR )
VK_DEVICE_LEVEL_FUNCTION( vkCreateImageView ) VK_DEVICE_LEVEL_FUNCTION( vkAcquireNextImageKHR )
VK_DEVICE_LEVEL_FUNCTION( vkCreateRenderPass ) VK_DEVICE_LEVEL_FUNCTION( vkQueuePresentKHR )
VK_DEVICE_LEVEL_FUNCTION( vkCreateFramebuffer ) VK_DEVICE_LEVEL_FUNCTION( vkDestroySwapchainKHR )
VK_DEVICE_LEVEL_FUNCTION( vkCreateShaderModule ) #endif
VK_DEVICE_LEVEL_FUNCTION( vkCreatePipelineLayout )
VK_DEVICE_LEVEL_FUNCTION( vkCreateGraphicsPipelines ) // Tutorial 03
VK_DEVICE_LEVEL_FUNCTION( vkCmdBeginRenderPass ) VK_DEVICE_LEVEL_FUNCTION( vkCreateImageView )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindPipeline ) VK_DEVICE_LEVEL_FUNCTION( vkCreateRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkCmdDraw ) VK_DEVICE_LEVEL_FUNCTION( vkCreateFramebuffer )
VK_DEVICE_LEVEL_FUNCTION( vkCmdEndRenderPass ) VK_DEVICE_LEVEL_FUNCTION( vkCreateShaderModule )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyShaderModule ) VK_DEVICE_LEVEL_FUNCTION( vkCreatePipelineLayout )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipelineLayout ) VK_DEVICE_LEVEL_FUNCTION( vkCreateGraphicsPipelines )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipeline ) VK_DEVICE_LEVEL_FUNCTION( vkCmdBeginRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyRenderPass ) VK_DEVICE_LEVEL_FUNCTION( vkCmdBindPipeline )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFramebuffer ) VK_DEVICE_LEVEL_FUNCTION( vkCmdDraw )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyImageView ) VK_DEVICE_LEVEL_FUNCTION( vkCmdEndRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyShaderModule )
// Tutorial 04 VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipelineLayout )
VK_DEVICE_LEVEL_FUNCTION( vkCreateFence ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipeline )
VK_DEVICE_LEVEL_FUNCTION( vkCreateBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkGetBufferMemoryRequirements ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyFramebuffer )
VK_DEVICE_LEVEL_FUNCTION( vkAllocateMemory ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyImageView )
VK_DEVICE_LEVEL_FUNCTION( vkBindBufferMemory )
VK_DEVICE_LEVEL_FUNCTION( vkMapMemory ) // Tutorial 04
VK_DEVICE_LEVEL_FUNCTION( vkFlushMappedMemoryRanges ) VK_DEVICE_LEVEL_FUNCTION( vkCreateFence )
VK_DEVICE_LEVEL_FUNCTION( vkUnmapMemory ) VK_DEVICE_LEVEL_FUNCTION( vkCreateBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetViewport ) VK_DEVICE_LEVEL_FUNCTION( vkGetBufferMemoryRequirements )
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetScissor ) VK_DEVICE_LEVEL_FUNCTION( vkAllocateMemory )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindVertexBuffers ) VK_DEVICE_LEVEL_FUNCTION( vkBindBufferMemory )
VK_DEVICE_LEVEL_FUNCTION( vkWaitForFences ) VK_DEVICE_LEVEL_FUNCTION( vkMapMemory )
VK_DEVICE_LEVEL_FUNCTION( vkResetFences ) VK_DEVICE_LEVEL_FUNCTION( vkFlushMappedMemoryRanges )
VK_DEVICE_LEVEL_FUNCTION( vkFreeMemory ) VK_DEVICE_LEVEL_FUNCTION( vkUnmapMemory )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkCmdSetViewport )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFence ) VK_DEVICE_LEVEL_FUNCTION( vkCmdSetScissor )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindVertexBuffers )
// Tutorial 05 VK_DEVICE_LEVEL_FUNCTION( vkWaitForFences )
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkResetFences )
VK_DEVICE_LEVEL_FUNCTION( vkFreeMemory )
// Tutorial 06 VK_DEVICE_LEVEL_FUNCTION( vkDestroyBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkCreateImage ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyFence )
VK_DEVICE_LEVEL_FUNCTION( vkGetImageMemoryRequirements )
VK_DEVICE_LEVEL_FUNCTION( vkBindImageMemory ) // Tutorial 05
VK_DEVICE_LEVEL_FUNCTION( vkCreateSampler ) VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBufferToImage )
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorSetLayout ) // Tutorial 06
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorPool ) VK_DEVICE_LEVEL_FUNCTION( vkCreateImage )
VK_DEVICE_LEVEL_FUNCTION( vkAllocateDescriptorSets ) VK_DEVICE_LEVEL_FUNCTION( vkGetImageMemoryRequirements )
VK_DEVICE_LEVEL_FUNCTION( vkUpdateDescriptorSets ) VK_DEVICE_LEVEL_FUNCTION( vkBindImageMemory )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindDescriptorSets ) VK_DEVICE_LEVEL_FUNCTION( vkCreateSampler )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorPool ) VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBufferToImage )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorSetLayout )
VK_DEVICE_LEVEL_FUNCTION( vkDestroySampler )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyImage )
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorSetLayout ) VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorSetLayout )

View File

@@ -1,379 +1,375 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include <thread> // distributed under the License is distributed on an "AS IS" BASIS,
#include <chrono> // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#include "OperatingSystem.h" // See the License for the specific language governing permissions and
// limitations under the License.
namespace ApiWithoutSecrets { /////////////////////////////////////////////////////////////////////////////////////////////
namespace OS { #include <thread>
#include <chrono>
Window::Window() : #include "OperatingSystem.h"
Parameters() {
} namespace ApiWithoutSecrets {
WindowParameters Window::GetParameters() const { namespace OS {
return Parameters;
} Window::Window() :
Parameters() {
#if defined(VK_USE_PLATFORM_WIN32_KHR) }
#define TUTORIAL_NAME "API without Secrets: Introduction to Vulkan" WindowParameters Window::GetParameters() const {
return Parameters;
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { }
switch( message ) {
case WM_SIZE: #if defined(VK_USE_PLATFORM_WIN32_KHR)
case WM_EXITSIZEMOVE:
PostMessage( hWnd, WM_USER + 1, wParam, lParam ); #define TUTORIAL_NAME "API without Secrets: Introduction to Vulkan"
break;
case WM_KEYDOWN: LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
case WM_CLOSE: switch( message ) {
PostMessage( hWnd, WM_USER + 2, wParam, lParam ); case WM_SIZE:
break; case WM_EXITSIZEMOVE:
default: PostMessage( hWnd, WM_USER + 1, wParam, lParam );
return DefWindowProc( hWnd, message, wParam, lParam ); break;
} case WM_KEYDOWN:
return 0; case WM_CLOSE:
} PostMessage( hWnd, WM_USER + 2, wParam, lParam );
break;
Window::~Window() { default:
if( Parameters.Handle ) { return DefWindowProc( hWnd, message, wParam, lParam );
DestroyWindow( Parameters.Handle ); }
} return 0;
}
if( Parameters.Instance ) {
UnregisterClass( TUTORIAL_NAME, Parameters.Instance ); Window::~Window() {
} if( Parameters.Handle ) {
} DestroyWindow( Parameters.Handle );
}
bool Window::Create( const char *title ) {
Parameters.Instance = GetModuleHandle( nullptr ); if( Parameters.Instance ) {
UnregisterClass( TUTORIAL_NAME, Parameters.Instance );
// Register window class }
WNDCLASSEX wcex; }
wcex.cbSize = sizeof(WNDCLASSEX); bool Window::Create( const char *title ) {
Parameters.Instance = GetModuleHandle( nullptr );
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc; // Register window class
wcex.cbClsExtra = 0; WNDCLASSEX wcex;
wcex.cbWndExtra = 0;
wcex.hInstance = Parameters.Instance; wcex.cbSize = sizeof(WNDCLASSEX);
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor( NULL, IDC_ARROW ); wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpfnWndProc = WndProc;
wcex.lpszMenuName = NULL; wcex.cbClsExtra = 0;
wcex.lpszClassName = TUTORIAL_NAME; wcex.cbWndExtra = 0;
wcex.hIconSm = NULL; wcex.hInstance = Parameters.Instance;
wcex.hIcon = NULL;
if( !RegisterClassEx( &wcex ) ) { wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
return false; wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
} wcex.lpszMenuName = NULL;
wcex.lpszClassName = TUTORIAL_NAME;
// Create window wcex.hIconSm = NULL;
Parameters.Handle = CreateWindow( TUTORIAL_NAME, title, WS_OVERLAPPEDWINDOW, 20, 20, 500, 500, nullptr, nullptr, Parameters.Instance, nullptr );
if( !Parameters.Handle ) { if( !RegisterClassEx( &wcex ) ) {
return false; return false;
} }
return true; // Create window
} Parameters.Handle = CreateWindow( TUTORIAL_NAME, title, WS_OVERLAPPEDWINDOW, 20, 20, 500, 500, nullptr, nullptr, Parameters.Instance, nullptr );
if( !Parameters.Handle ) {
bool Window::RenderingLoop( TutorialBase &tutorial ) const { return false;
// Display window }
ShowWindow( Parameters.Handle, SW_SHOWNORMAL );
UpdateWindow( Parameters.Handle ); return true;
}
// Main message loop
MSG message; bool Window::RenderingLoop( TutorialBase &tutorial ) const {
bool loop = true; // Display window
bool resize = false; ShowWindow( Parameters.Handle, SW_SHOWNORMAL );
bool result = true; UpdateWindow( Parameters.Handle );
while( loop ) { // Main message loop
if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) ) { MSG message;
// Process events bool loop = true;
switch( message.message ) { bool resize = false;
// Resize bool result = true;
case WM_USER + 1:
resize = true; while( loop ) {
break; if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) ) {
// Close // Process events
case WM_USER + 2: switch( message.message ) {
loop = false; // Resize
break; case WM_USER + 1:
} resize = true;
TranslateMessage( &message ); break;
DispatchMessage( &message ); // Close
} else { case WM_USER + 2:
// Draw loop = false;
if( resize ) { break;
resize = false; }
if( !tutorial.OnWindowSizeChanged() ) { TranslateMessage( &message );
result = false; DispatchMessage( &message );
break; } else {
} // Draw
} if( resize ) {
if( tutorial.ReadyToDraw() ) { resize = false;
if( !tutorial.Draw() ) { if( !tutorial.OnWindowSizeChanged() ) {
result = false; result = false;
break; break;
} }
} else { }
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); if( tutorial.ReadyToDraw() ) {
} if( !tutorial.Draw() ) {
} result = false;
} break;
}
return result; } else {
} std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
}
#elif defined(VK_USE_PLATFORM_XCB_KHR) }
}
Window::~Window() {
xcb_destroy_window( Parameters.Connection, Parameters.Handle ); return result;
xcb_disconnect( Parameters.Connection ); }
}
#elif defined(VK_USE_PLATFORM_XCB_KHR)
bool Window::Create( const char *title ) {
int screen_index; Window::~Window() {
Parameters.Connection = xcb_connect( nullptr, &screen_index ); xcb_destroy_window( Parameters.Connection, Parameters.Handle );
xcb_disconnect( Parameters.Connection );
if( !Parameters.Connection ) { }
return false;
} bool Window::Create( const char *title ) {
int screen_index;
const xcb_setup_t *setup = xcb_get_setup( Parameters.Connection ); Parameters.Connection = xcb_connect( nullptr, &screen_index );
xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator( setup );
if( !Parameters.Connection ) {
while( screen_index-- > 0 ) { return false;
xcb_screen_next( &screen_iterator ); }
}
const xcb_setup_t *setup = xcb_get_setup( Parameters.Connection );
xcb_screen_t *screen = screen_iterator.data; xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator( setup );
Parameters.Handle = xcb_generate_id( Parameters.Connection ); while( screen_index-- > 0 ) {
xcb_screen_next( &screen_iterator );
uint32_t value_list[] = { }
screen->white_pixel,
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_STRUCTURE_NOTIFY xcb_screen_t *screen = screen_iterator.data;
};
Parameters.Handle = xcb_generate_id( Parameters.Connection );
xcb_create_window(
Parameters.Connection, uint32_t value_list[] = {
XCB_COPY_FROM_PARENT, screen->white_pixel,
Parameters.Handle, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_STRUCTURE_NOTIFY
screen->root, };
20,
20, xcb_create_window(
500, Parameters.Connection,
500, XCB_COPY_FROM_PARENT,
0, Parameters.Handle,
XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root,
screen->root_visual, 20,
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, 20,
value_list ); 500,
500,
xcb_flush( Parameters.Connection ); 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
xcb_change_property( screen->root_visual,
Parameters.Connection, XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
XCB_PROP_MODE_REPLACE, value_list );
Parameters.Handle,
XCB_ATOM_WM_NAME, xcb_flush( Parameters.Connection );
XCB_ATOM_STRING,
8, xcb_change_property(
strlen( title ), Parameters.Connection,
title ); XCB_PROP_MODE_REPLACE,
Parameters.Handle,
return true; XCB_ATOM_WM_NAME,
} XCB_ATOM_STRING,
8,
bool Window::RenderingLoop( TutorialBase &tutorial ) const { strlen( title ),
// Prepare notification for window destruction title );
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 ); return true;
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 ); bool Window::RenderingLoop( TutorialBase &tutorial ) const {
free( protocols_reply ); // Prepare notification for window destruction
xcb_intern_atom_cookie_t protocols_cookie = xcb_intern_atom( Parameters.Connection, 1, 12, "WM_PROTOCOLS" );
// Display window xcb_intern_atom_reply_t *protocols_reply = xcb_intern_atom_reply( Parameters.Connection, protocols_cookie, 0 );
xcb_map_window( Parameters.Connection, Parameters.Handle ); xcb_intern_atom_cookie_t delete_cookie = xcb_intern_atom( Parameters.Connection, 0, 16, "WM_DELETE_WINDOW" );
xcb_flush( Parameters.Connection ); 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 );
// Main message loop free( protocols_reply );
xcb_generic_event_t *event;
bool loop = true; // Display window
bool resize = false; xcb_map_window( Parameters.Connection, Parameters.Handle );
bool result = true; xcb_flush( Parameters.Connection );
while( loop ) { // Main message loop
event = xcb_poll_for_event( Parameters.Connection ); xcb_generic_event_t *event;
bool loop = true;
if( event ) { bool resize = false;
// Process events bool result = true;
switch (event->response_type & 0x7f) {
// Resize while( loop ) {
case XCB_CONFIGURE_NOTIFY: { event = xcb_poll_for_event( Parameters.Connection );
xcb_configure_notify_event_t *configure_event = (xcb_configure_notify_event_t*)event;
static uint16_t width = configure_event->width; if( event ) {
static uint16_t height = configure_event->height; // Process events
switch (event->response_type & 0x7f) {
if( ((configure_event->width > 0) && (width != configure_event->width)) || // Resize
((configure_event->height > 0) && (height != configure_event->height)) ) { case XCB_CONFIGURE_NOTIFY: {
resize = true; xcb_configure_notify_event_t *configure_event = (xcb_configure_notify_event_t*)event;
width = configure_event->width; static uint16_t width = configure_event->width;
height = configure_event->height; static uint16_t height = configure_event->height;
}
} if( ((configure_event->width > 0) && (width != configure_event->width)) ||
break; ((configure_event->height > 0) && (height != configure_event->height)) ) {
// Close resize = true;
case XCB_CLIENT_MESSAGE: width = configure_event->width;
if( (*(xcb_client_message_event_t*)event).data.data32[0] == (*delete_reply).atom ) { height = configure_event->height;
loop = false; }
free( delete_reply ); }
} break;
break; // Close
case XCB_KEY_PRESS: case XCB_CLIENT_MESSAGE:
loop = false; if( (*(xcb_client_message_event_t*)event).data.data32[0] == (*delete_reply).atom ) {
break; loop = false;
} free( delete_reply );
free( event ); }
} else { break;
// Draw case XCB_KEY_PRESS:
if( resize ) { loop = false;
resize = false; break;
if( !tutorial.OnWindowSizeChanged() ) { }
result = false; free( event );
break; } else {
} // Draw
} if( resize ) {
if( tutorial.ReadyToDraw() ) { resize = false;
if( !tutorial.Draw() ) { if( !tutorial.OnWindowSizeChanged() ) {
result = false; result = false;
break; break;
} }
} else { }
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); if( tutorial.ReadyToDraw() ) {
} if( !tutorial.Draw() ) {
} result = false;
} break;
}
return result; } else {
} std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
}
#elif defined(VK_USE_PLATFORM_XLIB_KHR) }
}
Window::~Window() {
XDestroyWindow( Parameters.DisplayPtr, Parameters.Handle ); return result;
XCloseDisplay( Parameters.DisplayPtr ); }
}
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
bool Window::Create( const char *title ) {
Parameters.DisplayPtr = XOpenDisplay( nullptr ); Window::~Window() {
if( !Parameters.DisplayPtr ) { XDestroyWindow( Parameters.DisplayPtr, Parameters.Handle );
return false; XCloseDisplay( Parameters.DisplayPtr );
} }
int default_screen = DefaultScreen( Parameters.DisplayPtr ); bool Window::Create( const char *title ) {
Parameters.DisplayPtr = XOpenDisplay( nullptr );
Parameters.Handle = XCreateSimpleWindow( if( !Parameters.DisplayPtr ) {
Parameters.DisplayPtr, return false;
DefaultRootWindow( Parameters.DisplayPtr ), }
20,
20, int default_screen = DefaultScreen( Parameters.DisplayPtr );
500,
500, Parameters.Handle = XCreateSimpleWindow(
1, Parameters.DisplayPtr,
BlackPixel( Parameters.DisplayPtr, default_screen ), DefaultRootWindow( Parameters.DisplayPtr ),
WhitePixel( Parameters.DisplayPtr, default_screen ) ); 20,
20,
// XSync( Parameters.DisplayPtr, false ); 500,
XSetStandardProperties( Parameters.DisplayPtr, Parameters.Handle, title, title, None, nullptr, 0, nullptr ); 500,
XSelectInput( Parameters.DisplayPtr, Parameters.Handle, ExposureMask | KeyPressMask | StructureNotifyMask ); 1,
BlackPixel( Parameters.DisplayPtr, default_screen ),
return true; WhitePixel( Parameters.DisplayPtr, default_screen ) );
}
// XSync( Parameters.DisplayPtr, false );
bool Window::RenderingLoop( TutorialBase &tutorial ) const { XSetStandardProperties( Parameters.DisplayPtr, Parameters.Handle, title, title, None, nullptr, 0, nullptr );
// Prepare notification for window destruction XSelectInput( Parameters.DisplayPtr, Parameters.Handle, ExposureMask | KeyPressMask | StructureNotifyMask );
Atom delete_window_atom;
delete_window_atom = XInternAtom( Parameters.DisplayPtr, "WM_DELETE_WINDOW", false ); return true;
XSetWMProtocols( Parameters.DisplayPtr, Parameters.Handle, &delete_window_atom, 1); }
// Display window bool Window::RenderingLoop( TutorialBase &tutorial ) const {
XClearWindow( Parameters.DisplayPtr, Parameters.Handle ); // Prepare notification for window destruction
XMapWindow( Parameters.DisplayPtr, Parameters.Handle ); Atom delete_window_atom;
delete_window_atom = XInternAtom( Parameters.DisplayPtr, "WM_DELETE_WINDOW", false );
// Main message loop XSetWMProtocols( Parameters.DisplayPtr, Parameters.Handle, &delete_window_atom, 1);
XEvent event;
bool loop = true; // Display window
bool resize = false; XClearWindow( Parameters.DisplayPtr, Parameters.Handle );
bool result = true; XMapWindow( Parameters.DisplayPtr, Parameters.Handle );
while( loop ) { // Main message loop
if( XPending( Parameters.DisplayPtr ) ) { XEvent event;
XNextEvent( Parameters.DisplayPtr, &event ); bool loop = true;
switch( event.type ) { bool resize = false;
//Process events bool result = true;
case ConfigureNotify: {
static int width = event.xconfigure.width; while( loop ) {
static int height = event.xconfigure.height; if( XPending( Parameters.DisplayPtr ) ) {
XNextEvent( Parameters.DisplayPtr, &event );
if( ((event.xconfigure.width > 0) && (event.xconfigure.width != width)) || switch( event.type ) {
((event.xconfigure.height > 0) && (event.xconfigure.width != height)) ) { //Process events
width = event.xconfigure.width; case ConfigureNotify: {
height = event.xconfigure.height; static int width = event.xconfigure.width;
resize = true; static int height = event.xconfigure.height;
}
} if( ((event.xconfigure.width > 0) && (event.xconfigure.width != width)) ||
break; ((event.xconfigure.height > 0) && (event.xconfigure.width != height)) ) {
case KeyPress: width = event.xconfigure.width;
loop = false; height = event.xconfigure.height;
break; resize = true;
case DestroyNotify: }
loop = false; }
break; break;
case ClientMessage: case KeyPress:
if( static_cast<unsigned int>(event.xclient.data.l[0]) == delete_window_atom ) { loop = false;
loop = false; break;
} case DestroyNotify:
break; loop = false;
} break;
} else { case ClientMessage:
// Draw if( static_cast<unsigned int>(event.xclient.data.l[0]) == delete_window_atom ) {
if( resize ) { loop = false;
resize = false; }
if( !tutorial.OnWindowSizeChanged() ) { break;
result = false; }
break; } else {
} // Draw
} if( resize ) {
if( tutorial.ReadyToDraw() ) { resize = false;
if( !tutorial.Draw() ) { if( !tutorial.OnWindowSizeChanged() ) {
result = false; result = false;
break; break;
} }
} else { }
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); if( tutorial.ReadyToDraw() ) {
} if( !tutorial.Draw() ) {
} result = false;
} break;
}
return result; } else {
} std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
}
#endif }
} // namespace OS
} // namespace ApiWithoutSecrets

View File

@@ -1,134 +1,130 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(OPERATING_SYSTEM_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define OPERATING_SYSTEM_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#if defined(VK_USE_PLATFORM_WIN32_KHR) // limitations under the License.
#include <Windows.h> /////////////////////////////////////////////////////////////////////////////////////////////
#elif defined(VK_USE_PLATFORM_XCB_KHR) #if !defined(OPERATING_SYSTEM_HEADER)
#include <xcb/xcb.h> #define OPERATING_SYSTEM_HEADER
#include <dlfcn.h>
#include <cstdlib> #if defined(VK_USE_PLATFORM_WIN32_KHR)
#include <Windows.h>
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
#include <X11/Xlib.h> #elif defined(VK_USE_PLATFORM_XCB_KHR)
#include <X11/Xutil.h> #include <xcb/xcb.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <cstdlib> #include <cstdlib>
#endif #elif defined(VK_USE_PLATFORM_XLIB_KHR)
#include <X11/Xlib.h>
#include <cstring> #include <X11/Xutil.h>
#include <iostream> #include <dlfcn.h>
#include <cstdlib>
namespace ApiWithoutSecrets {
#endif
namespace OS {
#include <cstring>
// ************************************************************ // #include <iostream>
// LibraryHandle //
// // namespace ApiWithoutSecrets {
// Dynamic Library OS dependent type //
// ************************************************************ // namespace OS {
//
#if defined(VK_USE_PLATFORM_WIN32_KHR) // ************************************************************ //
typedef HMODULE LibraryHandle; // LibraryHandle //
// //
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) // Dynamic Library OS dependent type //
typedef void* LibraryHandle; // ************************************************************ //
//
#endif #if defined(VK_USE_PLATFORM_WIN32_KHR)
typedef HMODULE LibraryHandle;
// ************************************************************ //
// OnWindowSizeChanged // #elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
// // typedef void* LibraryHandle;
// Base class for handling window size changes //
// ************************************************************ // #endif
class TutorialBase {
public: // ************************************************************ //
virtual bool OnWindowSizeChanged() = 0; // OnWindowSizeChanged //
virtual bool Draw() = 0; // //
// Base class for handling window size changes //
virtual bool ReadyToDraw() const final { // ************************************************************ //
return CanRender; class TutorialBase {
} public:
virtual bool OnWindowSizeChanged() = 0;
TutorialBase() : virtual bool Draw() = 0;
CanRender( false ) {
} virtual bool ReadyToDraw() const final {
return CanRender;
virtual ~TutorialBase() { }
}
TutorialBase() :
protected: CanRender( false ) {
bool CanRender; }
};
virtual ~TutorialBase() {
// ************************************************************ // }
// WindowParameters //
// // protected:
// OS dependent window parameters // bool CanRender;
// ************************************************************ // };
struct WindowParameters {
#if defined(VK_USE_PLATFORM_WIN32_KHR) // ************************************************************ //
HINSTANCE Instance; // WindowParameters //
HWND Handle; // //
// OS dependent window parameters //
WindowParameters() : // ************************************************************ //
Instance(), struct WindowParameters {
Handle() { #if defined(VK_USE_PLATFORM_WIN32_KHR)
} HINSTANCE Instance;
HWND Handle;
#elif defined(VK_USE_PLATFORM_XCB_KHR)
xcb_connection_t *Connection; WindowParameters() :
xcb_window_t Handle; Instance(),
Handle() {
WindowParameters() : }
Connection(),
Handle() { #elif defined(VK_USE_PLATFORM_XCB_KHR)
} xcb_connection_t *Connection;
xcb_window_t Handle;
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
Display *DisplayPtr; WindowParameters() :
Window Handle; Connection(),
Handle() {
WindowParameters() : }
DisplayPtr(),
Handle() { #elif defined(VK_USE_PLATFORM_XLIB_KHR)
} Display *DisplayPtr;
Window Handle;
#endif
}; WindowParameters() :
DisplayPtr(),
// ************************************************************ // Handle() {
// Window // }
// //
// OS dependent window creation and destruction class // #endif
// ************************************************************ // };
class Window {
public: // ************************************************************ //
Window(); // Window //
~Window(); // //
// OS dependent window creation and destruction class //
bool Create( const char *title ); // ************************************************************ //
bool RenderingLoop( TutorialBase &tutorial ) const; class Window {
WindowParameters GetParameters() const; public:
Window();
private: ~Window();
WindowParameters Parameters;
}; bool Create( const char *title );
bool RenderingLoop( TutorialBase &tutorial ) const;
} // namespace OS
} // namespace ApiWithoutSecrets
WindowParameters GetParameters() const; WindowParameters GetParameters() const;

View File

@@ -1,152 +1,148 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include <cmath> // distributed under the License is distributed on an "AS IS" BASIS,
#include <fstream> // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#include <iostream> // See the License for the specific language governing permissions and
#include "Tools.h" // limitations under the License.
#define STB_IMAGE_IMPLEMENTATION /////////////////////////////////////////////////////////////////////////////////////////////
#include "stb_image.h"
#include <cmath>
namespace ApiWithoutSecrets { #include <fstream>
#include <iostream>
namespace Tools { #include "Tools.h"
#define STB_IMAGE_IMPLEMENTATION
// ************************************************************ // #include "stb_image.h"
// GetBinaryFileContents //
// // namespace ApiWithoutSecrets {
// Function reading binary contents of a file //
// ************************************************************ // namespace Tools {
std::vector<char> GetBinaryFileContents( std::string const &filename ) {
// ************************************************************ //
std::ifstream file( filename, std::ios::binary ); // GetBinaryFileContents //
if( file.fail() ) { // //
std::cout << "Could not open \"" << filename << "\" file!" << std::endl; // Function reading binary contents of a file //
return std::vector<char>(); // ************************************************************ //
} std::vector<char> GetBinaryFileContents( std::string const &filename ) {
std::streampos begin, end; std::ifstream file( filename, std::ios::binary );
begin = file.tellg(); if( file.fail() ) {
file.seekg( 0, std::ios::end ); std::cout << "Could not open \"" << filename << "\" file!" << std::endl;
end = file.tellg(); return std::vector<char>();
}
std::vector<char> result( static_cast<size_t>(end - begin) );
file.seekg( 0, std::ios::beg ); std::streampos begin, end;
file.read( &result[0], end - begin ); begin = file.tellg();
file.close(); file.seekg( 0, std::ios::end );
end = file.tellg();
return result;
} std::vector<char> result( static_cast<size_t>(end - begin) );
file.seekg( 0, std::ios::beg );
// ************************************************************ // file.read( &result[0], end - begin );
// GetImageData // file.close();
// //
// Function loading image (texture) data from a specified file // return result;
// ************************************************************ // }
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 ) { // GetImageData //
return std::vector<char>(); // //
} // Function loading image (texture) data from a specified file //
// ************************************************************ //
int tmp_width = 0, tmp_height = 0, tmp_components = 0; std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size ) {
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 ); std::vector<char> file_data = Tools::GetBinaryFileContents( filename );
if( (image_data == nullptr) || if( file_data.size() == 0 ) {
(tmp_width <= 0) || return std::vector<char>();
(tmp_height <= 0) || }
(tmp_components <= 0) ) {
std::cout << "Could not read image data!" << std::endl; int tmp_width = 0, tmp_height = 0, tmp_components = 0;
return std::vector<char>(); 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) ||
int size = (tmp_width) * (tmp_height) * (requested_components <= 0 ? tmp_components : requested_components); (tmp_height <= 0) ||
if( data_size ) { (tmp_components <= 0) ) {
*data_size = size; std::cout << "Could not read image data!" << std::endl;
} return std::vector<char>();
if( width ) { }
*width = tmp_width;
} int size = (tmp_width) * (tmp_height) * (requested_components <= 0 ? tmp_components : requested_components);
if( height ) { if( data_size ) {
*height = tmp_height; *data_size = size;
} }
if( components ) { if( width ) {
*components = tmp_components; *width = tmp_width;
} }
if( height ) {
std::vector<char> output(size); *height = tmp_height;
memcpy( &output[0], image_data, size ); }
if( components ) {
stbi_image_free( image_data ); *components = tmp_components;
return output; }
}
std::vector<char> output(size);
// ************************************************************ // memcpy( &output[0], image_data, size );
// GetPerspectiveProjectionMatrix //
// // stbi_image_free( image_data );
// Function calculating perspective projection matrix // return output;
// ************************************************************ // }
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 ); // ************************************************************ //
// GetPerspectiveProjectionMatrix //
return { // //
f / aspect_ratio, // Function calculating perspective projection matrix //
0.0f, // ************************************************************ //
0.0f, std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip ) {
0.0f, float f = 1.0f / std::tan( field_of_view * 0.5f * 0.01745329251994329576923690768489f );
0.0f, return {
f, f / aspect_ratio,
0.0f, 0.0f,
0.0f, 0.0f,
0.0f,
0.0f,
0.0f, 0.0f,
(near_clip + far_clip) / (near_clip - far_clip), f,
-1.0f, 0.0f,
0.0f,
0.0f,
0.0f, 0.0f,
(2.0f * near_clip * far_clip) / (near_clip - far_clip), 0.0f,
0.0f (near_clip + far_clip) / (near_clip - far_clip),
}; -1.0f,
}
0.0f,
// ************************************************************ // 0.0f,
// GetOrthographicsProjectionMatrix // (2.0f * near_clip * far_clip) / (near_clip - far_clip),
// // 0.0f
// 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), // GetOrthographicsProjectionMatrix //
0.0f, // //
0.0f, // Function calculating orthographic projection matrix //
0.0f, // ************************************************************ //
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 ) {
0.0f, return {
2.0f / (bottom_plane - top_plane), 2.0f / (right_plane - left_plane),
0.0f, 0.0f,
0.0f, 0.0f,
0.0f,
0.0f,
0.0f, 0.0f,
-2.0f / (far_plane - near_plane), 2.0f / (bottom_plane - top_plane),
0.0f, 0.0f,
0.0f,
-(right_plane + left_plane) / (right_plane - left_plane),
-(bottom_plane + top_plane) / (bottom_plane - top_plane), 0.0f,
-(far_plane + near_plane) / (far_plane - near_plane), 0.0f,
1.0f -2.0f / (far_plane - near_plane),
}; 0.0f,
}
} // namespace Tools

View File

@@ -1,113 +1,109 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TOOLS_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TOOLS_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include <string> // limitations under the License.
#include <vector> /////////////////////////////////////////////////////////////////////////////////////////////
#include <array>
#include "vulkan.h" #if !defined(TOOLS_HEADER)
#define TOOLS_HEADER
namespace ApiWithoutSecrets {
#include <string>
namespace Tools { #include <vector>
#include <array>
// ************************************************************ // #include "vulkan.h"
// AutoDeleter //
// // namespace ApiWithoutSecrets {
// Auto-deleter helper template class responsible for calling //
// provided function which deletes given object of type T // namespace Tools {
// ************************************************************ //
template<class T, class F> // ************************************************************ //
class AutoDeleter { // AutoDeleter //
public: // //
AutoDeleter() : // Auto-deleter helper template class responsible for calling //
Object( VK_NULL_HANDLE ), // provided function which deletes given object of type T //
Deleter( nullptr ), // ************************************************************ //
Device( VK_NULL_HANDLE ) { template<class T, class F>
} class AutoDeleter {
public:
AutoDeleter( T object, F deleter, VkDevice device ) : AutoDeleter() :
Object( object ), Object( VK_NULL_HANDLE ),
Deleter( deleter ), Deleter( nullptr ),
Device( device ) { Device( VK_NULL_HANDLE ) {
} }
AutoDeleter( AutoDeleter&& other ) { AutoDeleter( T object, F deleter, VkDevice device ) :
*this = std::move( other ); Object( object ),
} Deleter( deleter ),
Device( device ) {
~AutoDeleter() { }
if( (Object != VK_NULL_HANDLE) && (Deleter != nullptr) && (Device != VK_NULL_HANDLE) ) {
Deleter( Device, Object, nullptr ); AutoDeleter( AutoDeleter&& other ) {
} *this = std::move( other );
} }
AutoDeleter& operator=(AutoDeleter&& other) { ~AutoDeleter() {
if( this != &other ) { if( (Object != VK_NULL_HANDLE) && (Deleter != nullptr) && (Device != VK_NULL_HANDLE) ) {
Object = other.Object; Deleter( Device, Object, nullptr );
Deleter = other.Deleter; }
Device = other.Device; }
other.Object = VK_NULL_HANDLE;
} AutoDeleter& operator=(AutoDeleter&& other) {
return *this; if( this != &other ) {
} Object = other.Object;
Deleter = other.Deleter;
T Get() { Device = other.Device;
return Object; other.Object = VK_NULL_HANDLE;
} }
return *this;
bool operator !() const { }
return Object == VK_NULL_HANDLE;
} T Get() {
return Object;
private: }
AutoDeleter( const AutoDeleter& );
AutoDeleter& operator=( const AutoDeleter& ); bool operator !() const {
T Object; return Object == VK_NULL_HANDLE;
F Deleter; }
VkDevice Device;
}; private:
AutoDeleter( const AutoDeleter& );
// ************************************************************ // AutoDeleter& operator=( const AutoDeleter& );
// GetBinaryFileContents // T Object;
// // F Deleter;
// Function reading binary contents of a file // VkDevice Device;
// ************************************************************ // };
std::vector<char> GetBinaryFileContents( std::string const &filename );
// ************************************************************ //
// ************************************************************ // // GetBinaryFileContents //
// GetImageData // // //
// // // Function reading binary contents of a file //
// Function loading image (texture) data from a specified file // // ************************************************************ //
// ************************************************************ // std::vector<char> GetBinaryFileContents( std::string const &filename );
std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size );
// ************************************************************ //
// ************************************************************ // // GetImageData //
// GetPerspectiveProjectionMatrix // // //
// // // Function loading image (texture) data from a specified file //
// Function calculating perspective projection matrix // // ************************************************************ //
// ************************************************************ // std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size );
std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip );
// ************************************************************ //
// ************************************************************ // // GetPerspectiveProjectionMatrix //
// GetOrthographicsProjectionMatrix // // //
// // // Function calculating perspective projection matrix //
// Function calculating orthographic projection matrix // // ************************************************************ //
// ************************************************************ // std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip );
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 // GetOrthographicsProjectionMatrix //
} // namespace ApiWithoutSecrets
// // // //

File diff suppressed because it is too large Load Diff

View File

@@ -1,151 +1,147 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(VULKAN_COMMON_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define VULKAN_COMMON_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include <vector> // limitations under the License.
#include "vulkan.h" /////////////////////////////////////////////////////////////////////////////////////////////
#include "OperatingSystem.h"
#if !defined(VULKAN_COMMON_HEADER)
namespace ApiWithoutSecrets { #define VULKAN_COMMON_HEADER
// ************************************************************ // #include <vector>
// QueueParameters // #include "vulkan.h"
// // #include "OperatingSystem.h"
// Vulkan Queue's parameters container class //
// ************************************************************ // namespace ApiWithoutSecrets {
struct QueueParameters {
VkQueue Handle; // ************************************************************ //
uint32_t FamilyIndex; // QueueParameters //
// //
QueueParameters() : // Vulkan Queue's parameters container class //
Handle( VK_NULL_HANDLE ), // ************************************************************ //
FamilyIndex( 0 ) { struct QueueParameters {
} VkQueue Handle;
}; uint32_t FamilyIndex;
// ************************************************************ // QueueParameters() :
// ImageParameters // Handle( VK_NULL_HANDLE ),
// // FamilyIndex( 0 ) {
// Vulkan Image's parameters container class // }
// ************************************************************ // };
struct ImageParameters {
VkImage Handle; // ************************************************************ //
VkImageView View; // ImageParameters //
VkSampler Sampler; // //
VkDeviceMemory Memory; // Vulkan Image's parameters container class //
// ************************************************************ //
ImageParameters() : struct ImageParameters {
Handle( VK_NULL_HANDLE ), VkImage Handle;
View( VK_NULL_HANDLE ), VkImageView View;
Sampler( VK_NULL_HANDLE ), VkSampler Sampler;
Memory( VK_NULL_HANDLE ) { VkDeviceMemory Memory;
}
}; ImageParameters() :
Handle( VK_NULL_HANDLE ),
// ************************************************************ // View( VK_NULL_HANDLE ),
// SwapChainParameters // Sampler( VK_NULL_HANDLE ),
// // Memory( VK_NULL_HANDLE ) {
// Vulkan SwapChain's parameters container class // }
// ************************************************************ // };
struct SwapChainParameters {
VkSwapchainKHR Handle; // ************************************************************ //
VkFormat Format; // SwapChainParameters //
std::vector<ImageParameters> Images; // //
VkExtent2D Extent; // Vulkan SwapChain's parameters container class //
// ************************************************************ //
SwapChainParameters() : struct SwapChainParameters {
Handle( VK_NULL_HANDLE ), VkSwapchainKHR Handle;
Format( VK_FORMAT_UNDEFINED ), VkFormat Format;
Images(), std::vector<ImageParameters> Images;
Extent() { VkExtent2D Extent;
}
}; SwapChainParameters() :
Handle( VK_NULL_HANDLE ),
// ************************************************************ // Format( VK_FORMAT_UNDEFINED ),
// VulkanCommonParameters // Images(),
// // Extent() {
// General Vulkan parameters' container class // }
// ************************************************************ // };
struct VulkanCommonParameters {
VkInstance Instance; // ************************************************************ //
VkPhysicalDevice PhysicalDevice; // VulkanCommonParameters //
VkDevice Device; // //
QueueParameters GraphicsQueue; // General Vulkan parameters' container class //
QueueParameters PresentQueue; // ************************************************************ //
VkSurfaceKHR PresentationSurface; struct VulkanCommonParameters {
SwapChainParameters SwapChain; VkInstance Instance;
VkPhysicalDevice PhysicalDevice;
VulkanCommonParameters() : VkDevice Device;
Instance( VK_NULL_HANDLE ), QueueParameters GraphicsQueue;
PhysicalDevice( VK_NULL_HANDLE ), QueueParameters PresentQueue;
Device( VK_NULL_HANDLE ), VkSurfaceKHR PresentationSurface;
GraphicsQueue(), SwapChainParameters SwapChain;
PresentQueue(),
PresentationSurface( VK_NULL_HANDLE ), VulkanCommonParameters() :
SwapChain() { Instance( VK_NULL_HANDLE ),
} PhysicalDevice( VK_NULL_HANDLE ),
}; Device( VK_NULL_HANDLE ),
GraphicsQueue(),
// ************************************************************ // PresentQueue(),
// VulkanCommon // PresentationSurface( VK_NULL_HANDLE ),
// // SwapChain() {
// Base class for Vulkan more advanced tutorial classes // }
// ************************************************************ // };
class VulkanCommon : public OS::TutorialBase {
public: // ************************************************************ //
VulkanCommon(); // VulkanCommon //
virtual ~VulkanCommon(); // //
// Base class for Vulkan more advanced tutorial classes //
bool PrepareVulkan( OS::WindowParameters parameters ); // ************************************************************ //
virtual bool OnWindowSizeChanged() final override; class VulkanCommon : public OS::TutorialBase {
public:
protected: VulkanCommon();
VkPhysicalDevice GetPhysicalDevice() const; virtual ~VulkanCommon();
VkDevice GetDevice() const;
bool PrepareVulkan( OS::WindowParameters parameters );
const QueueParameters GetGraphicsQueue() const; virtual bool OnWindowSizeChanged() final override;
const QueueParameters GetPresentQueue() const;
protected:
const SwapChainParameters GetSwapChain() const; VkPhysicalDevice GetPhysicalDevice() const;
VkDevice GetDevice() const;
private:
OS::LibraryHandle VulkanLibrary; const QueueParameters GetGraphicsQueue() const;
OS::WindowParameters Window; const QueueParameters GetPresentQueue() const;
VulkanCommonParameters Vulkan;
const SwapChainParameters GetSwapChain() const;
bool LoadVulkanLibrary();
bool LoadExportedEntryPoints(); private:
bool LoadGlobalLevelEntryPoints(); OS::LibraryHandle VulkanLibrary;
bool CreateInstance(); OS::WindowParameters Window;
bool LoadInstanceLevelEntryPoints(); VulkanCommonParameters Vulkan;
bool CreatePresentationSurface();
bool CreateDevice(); bool LoadVulkanLibrary();
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index ); bool LoadExportedEntryPoints();
bool LoadDeviceLevelEntryPoints(); bool LoadGlobalLevelEntryPoints();
bool GetDeviceQueue(); bool CreateInstance();
bool CreateSwapChain(); bool LoadInstanceLevelEntryPoints();
bool CreateSwapChainImageViews(); bool CreatePresentationSurface();
virtual bool ChildOnWindowSizeChanged() = 0; bool CreateDevice();
virtual void ChildClear() = 0; bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
bool LoadDeviceLevelEntryPoints();
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions ); bool GetDeviceQueue();
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities ); bool CreateSwapChain();
VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats ); bool CreateSwapChainImageViews();
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities ); virtual bool ChildOnWindowSizeChanged() = 0;
VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities ); virtual void ChildClear() = 0;
VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities );
VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes ); bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
};
} // namespace ApiWithoutSecrets
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities ); uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );

View File

@@ -1,22 +1,18 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "vulkan.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
namespace ApiWithoutSecrets { // See the License for the specific language governing permissions and
// limitations under the License.
#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; #include "vulkan.h"
#define VK_DEVICE_LEVEL_FUNCTION( fun ) PFN_##fun fun;
#include "ListOfFunctions.inl"

View File

@@ -1,27 +1,23 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(VULKAN_FUNCTIONS_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define VULKAN_FUNCTIONS_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include "vulkan.h" // limitations under the License.
/////////////////////////////////////////////////////////////////////////////////////////////
namespace ApiWithoutSecrets {
#if !defined(VULKAN_FUNCTIONS_HEADER)
#define VK_EXPORTED_FUNCTION( fun ) extern PFN_##fun fun; #define VULKAN_FUNCTIONS_HEADER
#define VK_GLOBAL_LEVEL_FUNCTION( fun) extern PFN_##fun fun;
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun; #include "vulkan.h"
#define VK_DEVICE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun;
namespace ApiWithoutSecrets {
#include "ListOfFunctions.inl"
} // namespace ApiWithoutSecrets

View File

@@ -1,276 +1,272 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include <vector> // distributed under the License is distributed on an "AS IS" BASIS,
#include "Tutorial01.h" // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#include "VulkanFunctions.h" // See the License for the specific language governing permissions and
// limitations under the License.
namespace ApiWithoutSecrets { /////////////////////////////////////////////////////////////////////////////////////////////
Tutorial01::Tutorial01() : #include <vector>
VulkanLibrary(), #include "Tutorial01.h"
Vulkan() { #include "VulkanFunctions.h"
}
namespace ApiWithoutSecrets {
bool Tutorial01::OnWindowSizeChanged() {
return true; Tutorial01::Tutorial01() :
} VulkanLibrary(),
Vulkan() {
bool Tutorial01::Draw() { }
return true;
} bool Tutorial01::OnWindowSizeChanged() {
return true;
bool Tutorial01::PrepareVulkan() { }
if( !LoadVulkanLibrary() ) {
return false; bool Tutorial01::Draw() {
} return true;
if( !LoadExportedEntryPoints() ) { }
return false;
} bool Tutorial01::PrepareVulkan() {
if( !LoadGlobalLevelEntryPoints() ) { if( !LoadVulkanLibrary() ) {
return false; return false;
} }
if( !CreateInstance() ) { if( !LoadExportedEntryPoints() ) {
return false; return false;
} }
if( !LoadInstanceLevelEntryPoints() ) { if( !LoadGlobalLevelEntryPoints() ) {
return false; return false;
} }
if( !CreateDevice() ) { if( !CreateInstance() ) {
return false; return false;
} }
if( !LoadDeviceLevelEntryPoints() ) { if( !LoadInstanceLevelEntryPoints() ) {
return false; return false;
} }
if( !GetDeviceQueue() ) { if( !CreateDevice() ) {
return false; return false;
} }
return true; if( !LoadDeviceLevelEntryPoints() ) {
} return false;
}
bool Tutorial01::LoadVulkanLibrary() { if( !GetDeviceQueue() ) {
#if defined(VK_USE_PLATFORM_WIN32_KHR) return false;
VulkanLibrary = LoadLibrary( "vulkan-1.dll" ); }
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) return true;
VulkanLibrary = dlopen( "libvulkan.so.1", RTLD_NOW ); }
#endif
bool Tutorial01::LoadVulkanLibrary() {
if( VulkanLibrary == nullptr ) { #if defined(VK_USE_PLATFORM_WIN32_KHR)
std::cout << "Could not load Vulkan library!" << std::endl; VulkanLibrary = LoadLibrary( "vulkan-1.dll" );
return false; #elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
} VulkanLibrary = dlopen( "libvulkan.so.1", RTLD_NOW );
return true; #endif
}
if( VulkanLibrary == nullptr ) {
bool Tutorial01::LoadExportedEntryPoints() { std::cout << "Could not load Vulkan library!" << std::endl;
#if defined(VK_USE_PLATFORM_WIN32_KHR) return false;
#define LoadProcAddress GetProcAddress }
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) return true;
#define LoadProcAddress dlsym }
#endif
bool Tutorial01::LoadExportedEntryPoints() {
#define VK_EXPORTED_FUNCTION( fun ) \ #if defined(VK_USE_PLATFORM_WIN32_KHR)
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \ #define LoadProcAddress GetProcAddress
std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \ #elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
return false; \ #define LoadProcAddress dlsym
} #endif
#include "ListOfFunctions.inl" #define VK_EXPORTED_FUNCTION( fun ) \
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
return true; std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \
} return false; \
}
bool Tutorial01::LoadGlobalLevelEntryPoints() {
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \ #include "ListOfFunctions.inl"
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \ return true;
return false; \ }
}
bool Tutorial01::LoadGlobalLevelEntryPoints() {
#include "ListOfFunctions.inl" #define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
return true; std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \
} return false; \
}
bool Tutorial01::CreateInstance() {
VkApplicationInfo application_info = { #include "ListOfFunctions.inl"
VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType
nullptr, // const void *pNext return true;
"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 bool Tutorial01::CreateInstance() {
VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t engineVersion VkApplicationInfo application_info = {
VK_MAKE_VERSION( 1, 0, 0 ) // uint32_t apiVersion VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType
}; nullptr, // const void *pNext
"API without Secrets: Introduction to Vulkan", // const char *pApplicationName
VkInstanceCreateInfo instance_create_info = { VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t applicationVersion
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType "Vulkan Tutorial by Intel", // const char *pEngineName
nullptr, // const void* pNext VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t engineVersion
0, // VkInstanceCreateFlags flags VK_MAKE_VERSION( 1, 0, 0 ) // uint32_t apiVersion
&application_info, // const VkApplicationInfo *pApplicationInfo };
0, // uint32_t enabledLayerCount
nullptr, // const char * const *ppEnabledLayerNames VkInstanceCreateInfo instance_create_info = {
0, // uint32_t enabledExtensionCount VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType
nullptr // const char * const *ppEnabledExtensionNames nullptr, // const void* pNext
}; 0, // VkInstanceCreateFlags flags
&application_info, // const VkApplicationInfo *pApplicationInfo
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) { 0, // uint32_t enabledLayerCount
std::cout << "Could not create Vulkan instance!" << std::endl; nullptr, // const char * const *ppEnabledLayerNames
return false; 0, // uint32_t enabledExtensionCount
} nullptr // const char * const *ppEnabledExtensionNames
return true; };
}
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
bool Tutorial01::LoadInstanceLevelEntryPoints() { std::cout << "Could not create Vulkan instance!" << std::endl;
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \ return false;
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \ }
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \ return true;
return false; \ }
}
bool Tutorial01::LoadInstanceLevelEntryPoints() {
#include "ListOfFunctions.inl" #define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
return true; std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \
} return false; \
}
bool Tutorial01::CreateDevice() {
uint32_t num_devices = 0; #include "ListOfFunctions.inl"
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
(num_devices == 0) ) { return true;
std::cout << "Error occurred during physical devices enumeration!" << std::endl; }
return false;
} bool Tutorial01::CreateDevice() {
uint32_t num_devices = 0;
std::vector<VkPhysicalDevice> physical_devices( num_devices ); if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) { (num_devices == 0) ) {
std::cout << "Error occurred during physical devices enumeration!" << std::endl; std::cout << "Error occurred during physical devices enumeration!" << std::endl;
return false; return false;
} }
VkPhysicalDevice selected_physical_device = VK_NULL_HANDLE; std::vector<VkPhysicalDevice> physical_devices( num_devices );
uint32_t selected_queue_family_index = UINT32_MAX; if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
for( uint32_t i = 0; i < num_devices; ++i ) { std::cout << "Error occurred during physical devices enumeration!" << std::endl;
if( CheckPhysicalDeviceProperties( physical_devices[i], selected_queue_family_index ) ) { return false;
selected_physical_device = physical_devices[i]; }
}
} VkPhysicalDevice selected_physical_device = VK_NULL_HANDLE;
if( selected_physical_device == VK_NULL_HANDLE ) { uint32_t selected_queue_family_index = UINT32_MAX;
std::cout << "Could not select physical device based on the chosen properties!" << std::endl; for( uint32_t i = 0; i < num_devices; ++i ) {
return false; if( CheckPhysicalDeviceProperties( physical_devices[i], selected_queue_family_index ) ) {
} selected_physical_device = physical_devices[i];
}
std::vector<float> queue_priorities = { 1.0f }; }
if( selected_physical_device == VK_NULL_HANDLE ) {
VkDeviceQueueCreateInfo queue_create_info = { std::cout << "Could not select physical device based on the chosen properties!" << std::endl;
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType return false;
nullptr, // const void *pNext }
0, // VkDeviceQueueCreateFlags flags
selected_queue_family_index, // uint32_t queueFamilyIndex std::vector<float> queue_priorities = { 1.0f };
static_cast<uint32_t>(queue_priorities.size()), // uint32_t queueCount
&queue_priorities[0] // const float *pQueuePriorities VkDeviceQueueCreateInfo queue_create_info = {
}; VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType
nullptr, // const void *pNext
VkDeviceCreateInfo device_create_info = { 0, // VkDeviceQueueCreateFlags flags
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType selected_queue_family_index, // uint32_t queueFamilyIndex
nullptr, // const void *pNext static_cast<uint32_t>(queue_priorities.size()), // uint32_t queueCount
0, // VkDeviceCreateFlags flags &queue_priorities[0] // const float *pQueuePriorities
1, // uint32_t queueCreateInfoCount };
&queue_create_info, // const VkDeviceQueueCreateInfo *pQueueCreateInfos
0, // uint32_t enabledLayerCount VkDeviceCreateInfo device_create_info = {
nullptr, // const char * const *ppEnabledLayerNames VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType
0, // uint32_t enabledExtensionCount nullptr, // const void *pNext
nullptr, // const char * const *ppEnabledExtensionNames 0, // VkDeviceCreateFlags flags
nullptr // const VkPhysicalDeviceFeatures *pEnabledFeatures 1, // uint32_t queueCreateInfoCount
}; &queue_create_info, // const VkDeviceQueueCreateInfo *pQueueCreateInfos
0, // uint32_t enabledLayerCount
if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) { nullptr, // const char * const *ppEnabledLayerNames
std::cout << "Could not create Vulkan device!" << std::endl; 0, // uint32_t enabledExtensionCount
return false; nullptr, // const char * const *ppEnabledExtensionNames
} nullptr // const VkPhysicalDeviceFeatures *pEnabledFeatures
};
Vulkan.QueueFamilyIndex = selected_queue_family_index;
return true; if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
} std::cout << "Could not create Vulkan device!" << std::endl;
return false;
bool Tutorial01::CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index ) { }
VkPhysicalDeviceProperties device_properties;
VkPhysicalDeviceFeatures device_features; Vulkan.QueueFamilyIndex = selected_queue_family_index;
return true;
vkGetPhysicalDeviceProperties( physical_device, &device_properties ); }
vkGetPhysicalDeviceFeatures( physical_device, &device_features );
bool Tutorial01::CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index ) {
uint32_t major_version = VK_VERSION_MAJOR( device_properties.apiVersion ); VkPhysicalDeviceProperties device_properties;
uint32_t minor_version = VK_VERSION_MINOR( device_properties.apiVersion ); VkPhysicalDeviceFeatures device_features;
uint32_t patch_version = VK_VERSION_PATCH( device_properties.apiVersion );
vkGetPhysicalDeviceProperties( physical_device, &device_properties );
if( (major_version < 1) || vkGetPhysicalDeviceFeatures( physical_device, &device_features );
(device_properties.limits.maxImageDimension2D < 4096) ) {
std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl; uint32_t major_version = VK_VERSION_MAJOR( device_properties.apiVersion );
return false; uint32_t minor_version = VK_VERSION_MINOR( device_properties.apiVersion );
} uint32_t patch_version = VK_VERSION_PATCH( device_properties.apiVersion );
uint32_t queue_families_count = 0; if( (major_version < 1) ||
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr ); (device_properties.limits.maxImageDimension2D < 4096) ) {
if( queue_families_count == 0 ) { std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl;
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl; return false;
return false; }
}
uint32_t queue_families_count = 0;
std::vector<VkQueueFamilyProperties> queue_family_properties( queue_families_count ); vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, &queue_family_properties[0] ); if( queue_families_count == 0 ) {
for( uint32_t i = 0; i < queue_families_count; ++i ) { std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl;
if( (queue_family_properties[i].queueCount > 0) && return false;
(queue_family_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) ) { }
queue_family_index = i;
return true; 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) &&
std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl; (queue_family_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) ) {
return false; queue_family_index = i;
} return true;
}
bool Tutorial01::LoadDeviceLevelEntryPoints() { }
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \ std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl;
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \ return false;
return false; \ }
}
bool Tutorial01::LoadDeviceLevelEntryPoints() {
#include "ListOfFunctions.inl" #define VK_DEVICE_LEVEL_FUNCTION( fun ) \
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
return true; std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \
} return false; \
}
bool Tutorial01::GetDeviceQueue() {
vkGetDeviceQueue( Vulkan.Device, Vulkan.QueueFamilyIndex, 0, &Vulkan.Queue ); #include "ListOfFunctions.inl"
return true;
} return true;
}
Tutorial01::~Tutorial01() {
if( Vulkan.Device != VK_NULL_HANDLE ) { bool Tutorial01::GetDeviceQueue() {
vkDeviceWaitIdle( Vulkan.Device ); vkGetDeviceQueue( Vulkan.Device, Vulkan.QueueFamilyIndex, 0, &Vulkan.Queue );
vkDestroyDevice( Vulkan.Device, nullptr ); return true;
} }
if( Vulkan.Instance != VK_NULL_HANDLE ) { Tutorial01::~Tutorial01() {
vkDestroyInstance( Vulkan.Instance, nullptr ); if( Vulkan.Device != VK_NULL_HANDLE ) {
} vkDeviceWaitIdle( Vulkan.Device );
vkDestroyDevice( Vulkan.Device, nullptr );
if( VulkanLibrary ) { }
#if defined(VK_USE_PLATFORM_WIN32_KHR)
FreeLibrary( VulkanLibrary ); if( Vulkan.Instance != VK_NULL_HANDLE ) {
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) vkDestroyInstance( Vulkan.Instance, nullptr );
dlclose( VulkanLibrary ); }
#endif
}
}

View File

@@ -1,70 +1,66 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TUTORIAL_01_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TUTORIAL_01_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include "vulkan.h" // limitations under the License.
#include "OperatingSystem.h" /////////////////////////////////////////////////////////////////////////////////////////////
namespace ApiWithoutSecrets { #if !defined(TUTORIAL_01_HEADER)
#define TUTORIAL_01_HEADER
// ************************************************************ //
// VulkanTutorial01Parameters // #include "vulkan.h"
// // #include "OperatingSystem.h"
// Vulkan specific parameters //
// ************************************************************ // namespace ApiWithoutSecrets {
struct VulkanTutorial01Parameters {
VkInstance Instance; // ************************************************************ //
VkDevice Device; // VulkanTutorial01Parameters //
uint32_t QueueFamilyIndex; // //
VkQueue Queue; // Vulkan specific parameters //
// ************************************************************ //
VulkanTutorial01Parameters() : struct VulkanTutorial01Parameters {
Instance( VK_NULL_HANDLE ), VkInstance Instance;
Device( VK_NULL_HANDLE ), VkDevice Device;
QueueFamilyIndex( 0 ), uint32_t QueueFamilyIndex;
Queue( VK_NULL_HANDLE ) { VkQueue Queue;
}
}; VulkanTutorial01Parameters() :
Instance( VK_NULL_HANDLE ),
// ************************************************************ // Device( VK_NULL_HANDLE ),
// Tutorial01 // QueueFamilyIndex( 0 ),
// // Queue( VK_NULL_HANDLE ) {
// Class for presenting Vulkan usage topics // }
// ************************************************************ // };
class Tutorial01 : public OS::TutorialBase {
public: // ************************************************************ //
Tutorial01(); // Tutorial01 //
~Tutorial01(); // //
// Class for presenting Vulkan usage topics //
bool OnWindowSizeChanged() override; // ************************************************************ //
bool Draw() override; class Tutorial01 : public OS::TutorialBase {
public:
bool PrepareVulkan(); Tutorial01();
~Tutorial01();
private:
OS::LibraryHandle VulkanLibrary; bool OnWindowSizeChanged() override;
VulkanTutorial01Parameters Vulkan; bool Draw() override;
bool LoadVulkanLibrary(); bool PrepareVulkan();
bool LoadExportedEntryPoints();
bool LoadGlobalLevelEntryPoints(); private:
bool CreateInstance(); OS::LibraryHandle VulkanLibrary;
bool LoadInstanceLevelEntryPoints(); VulkanTutorial01Parameters Vulkan;
bool CreateDevice();
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index ); bool LoadVulkanLibrary();
bool LoadDeviceLevelEntryPoints(); bool LoadExportedEntryPoints();
bool GetDeviceQueue(); bool LoadGlobalLevelEntryPoints();
};
} // namespace ApiWithoutSecrets
bool CreateInstance(); bool CreateInstance();

View File

@@ -1,33 +1,29 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "Tutorial01.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
int main( int argc, char **argv ) { // See the License for the specific language governing permissions and
ApiWithoutSecrets::OS::Window window; // limitations under the License.
ApiWithoutSecrets::Tutorial01 tutorial01; /////////////////////////////////////////////////////////////////////////////////////////////
// Window creation #include "Tutorial01.h"
if( !window.Create( "01 - The Beginning" ) ) {
return -1; int main( int argc, char **argv ) {
} ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial01 tutorial01;
// Vulkan preparations and initialization
if( !tutorial01.PrepareVulkan() ) { // Window creation
return -1; if( !window.Create( "01 - The Beginning" ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial01 ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial01.PrepareVulkan() ) {
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,101 +1,97 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TUTORIAL_02_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TUTORIAL_02_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include <vector> // limitations under the License.
#include "vulkan.h" /////////////////////////////////////////////////////////////////////////////////////////////
#include "OperatingSystem.h"
#if !defined(TUTORIAL_02_HEADER)
namespace ApiWithoutSecrets { #define TUTORIAL_02_HEADER
// ************************************************************ // #include <vector>
// VulkanTutorial02Parameters // #include "vulkan.h"
// // #include "OperatingSystem.h"
// Vulkan specific parameters //
// ************************************************************ // namespace ApiWithoutSecrets {
struct VulkanTutorial02Parameters {
VkInstance Instance; // ************************************************************ //
VkPhysicalDevice PhysicalDevice; // VulkanTutorial02Parameters //
VkDevice Device; // //
VkQueue GraphicsQueue; // Vulkan specific parameters //
VkQueue PresentQueue; // ************************************************************ //
uint32_t GraphicsQueueFamilyIndex; struct VulkanTutorial02Parameters {
uint32_t PresentQueueFamilyIndex; VkInstance Instance;
VkSurfaceKHR PresentationSurface; VkPhysicalDevice PhysicalDevice;
VkSwapchainKHR SwapChain; VkDevice Device;
std::vector<VkCommandBuffer> PresentQueueCmdBuffers; VkQueue GraphicsQueue;
VkCommandPool PresentQueueCmdPool; VkQueue PresentQueue;
VkSemaphore ImageAvailableSemaphore; uint32_t GraphicsQueueFamilyIndex;
VkSemaphore RenderingFinishedSemaphore; uint32_t PresentQueueFamilyIndex;
VkSurfaceKHR PresentationSurface;
VulkanTutorial02Parameters() : VkSwapchainKHR SwapChain;
Instance( VK_NULL_HANDLE ), std::vector<VkCommandBuffer> PresentQueueCmdBuffers;
PhysicalDevice( VK_NULL_HANDLE ), VkCommandPool PresentQueueCmdPool;
Device( VK_NULL_HANDLE ), VkSemaphore ImageAvailableSemaphore;
GraphicsQueue( VK_NULL_HANDLE ), VkSemaphore RenderingFinishedSemaphore;
PresentQueue( VK_NULL_HANDLE ),
GraphicsQueueFamilyIndex( 0 ), VulkanTutorial02Parameters() :
PresentQueueFamilyIndex( 0 ), Instance( VK_NULL_HANDLE ),
PresentationSurface( VK_NULL_HANDLE ), PhysicalDevice( VK_NULL_HANDLE ),
SwapChain( VK_NULL_HANDLE ), Device( VK_NULL_HANDLE ),
PresentQueueCmdBuffers( 0 ), GraphicsQueue( VK_NULL_HANDLE ),
PresentQueueCmdPool( VK_NULL_HANDLE ) { PresentQueue( VK_NULL_HANDLE ),
} GraphicsQueueFamilyIndex( 0 ),
}; PresentQueueFamilyIndex( 0 ),
PresentationSurface( VK_NULL_HANDLE ),
// ************************************************************ // SwapChain( VK_NULL_HANDLE ),
// Tutorial02 // PresentQueueCmdBuffers( 0 ),
// // PresentQueueCmdPool( VK_NULL_HANDLE ) {
// Class for presenting Vulkan usage topics // }
// ************************************************************ // };
class Tutorial02 : public OS::TutorialBase {
public: // ************************************************************ //
Tutorial02(); // Tutorial02 //
~Tutorial02(); // //
// Class for presenting Vulkan usage topics //
bool PrepareVulkan( OS::WindowParameters parameters ); // ************************************************************ //
bool CreateSwapChain(); class Tutorial02 : public OS::TutorialBase {
bool OnWindowSizeChanged() override; public:
bool CreateCommandBuffers(); Tutorial02();
bool Draw() override; ~Tutorial02();
private: bool PrepareVulkan( OS::WindowParameters parameters );
OS::LibraryHandle VulkanLibrary; bool CreateSwapChain();
OS::WindowParameters Window; bool OnWindowSizeChanged() override;
VulkanTutorial02Parameters Vulkan; bool CreateCommandBuffers();
bool Draw() override;
bool LoadVulkanLibrary();
bool LoadExportedEntryPoints(); private:
bool LoadGlobalLevelEntryPoints(); OS::LibraryHandle VulkanLibrary;
bool CreateInstance(); OS::WindowParameters Window;
bool LoadInstanceLevelEntryPoints(); VulkanTutorial02Parameters Vulkan;
bool CreatePresentationSurface();
bool CreateDevice(); bool LoadVulkanLibrary();
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index ); bool LoadExportedEntryPoints();
bool LoadDeviceLevelEntryPoints(); bool LoadGlobalLevelEntryPoints();
bool GetDeviceQueue(); bool CreateInstance();
bool CreateSemaphores(); bool LoadInstanceLevelEntryPoints();
bool RecordCommandBuffers(); bool CreatePresentationSurface();
void Clear(); bool CreateDevice();
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions ); bool LoadDeviceLevelEntryPoints();
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities ); bool GetDeviceQueue();
VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats ); bool CreateSemaphores();
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities ); bool RecordCommandBuffers();
VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities ); void Clear();
VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities );
VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes ); bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
};
} // namespace ApiWithoutSecrets
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities ); uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );

View File

@@ -1,39 +1,35 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "Tutorial02.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
int main( int argc, char **argv ) { // See the License for the specific language governing permissions and
ApiWithoutSecrets::OS::Window window; // limitations under the License.
ApiWithoutSecrets::Tutorial02 tutorial02; /////////////////////////////////////////////////////////////////////////////////////////////
// Window creation #include "Tutorial02.h"
if( !window.Create( "02 - Swap chain" ) ) {
return -1; int main( int argc, char **argv ) {
} ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial02 tutorial02;
// Vulkan preparations and initialization
if( !tutorial02.PrepareVulkan( window.GetParameters() ) ) { // Window creation
return -1; if( !window.Create( "02 - Swap chain" ) ) {
} return -1;
if( !tutorial02.CreateSwapChain() ) { }
return -1;
} // Vulkan preparations and initialization
if( !tutorial02.CreateCommandBuffers() ) { if( !tutorial02.PrepareVulkan( window.GetParameters() ) ) {
return -1; return -1;
} }
if( !tutorial02.CreateSwapChain() ) {
// Rendering loop return -1;
if( !window.RenderingLoop( tutorial02 ) ) { }
return -1; if( !tutorial02.CreateCommandBuffers() ) {
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,77 +1,73 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TUTORIAL_03_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TUTORIAL_03_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include "VulkanCommon.h" // limitations under the License.
#include "Tools.h" /////////////////////////////////////////////////////////////////////////////////////////////
namespace ApiWithoutSecrets { #if !defined(TUTORIAL_03_HEADER)
#define TUTORIAL_03_HEADER
// ************************************************************ //
// VulkanTutorial03Parameters // #include "VulkanCommon.h"
// // #include "Tools.h"
// Vulkan specific parameters //
// ************************************************************ // namespace ApiWithoutSecrets {
struct VulkanTutorial03Parameters {
VkRenderPass RenderPass; // ************************************************************ //
std::vector<VkFramebuffer> Framebuffers; // VulkanTutorial03Parameters //
VkPipeline GraphicsPipeline; // //
VkSemaphore ImageAvailableSemaphore; // Vulkan specific parameters //
VkSemaphore RenderingFinishedSemaphore; // ************************************************************ //
VkCommandPool GraphicsCommandPool; struct VulkanTutorial03Parameters {
std::vector<VkCommandBuffer> GraphicsCommandBuffers; VkRenderPass RenderPass;
std::vector<VkFramebuffer> Framebuffers;
VulkanTutorial03Parameters() : VkPipeline GraphicsPipeline;
RenderPass( VK_NULL_HANDLE ), VkSemaphore ImageAvailableSemaphore;
Framebuffers(), VkSemaphore RenderingFinishedSemaphore;
GraphicsCommandPool( VK_NULL_HANDLE ), VkCommandPool GraphicsCommandPool;
GraphicsCommandBuffers(), std::vector<VkCommandBuffer> GraphicsCommandBuffers;
GraphicsPipeline( VK_NULL_HANDLE ),
ImageAvailableSemaphore( VK_NULL_HANDLE ), VulkanTutorial03Parameters() :
RenderingFinishedSemaphore( VK_NULL_HANDLE ) { RenderPass( VK_NULL_HANDLE ),
} Framebuffers(),
}; GraphicsCommandPool( VK_NULL_HANDLE ),
GraphicsCommandBuffers(),
// ************************************************************ // GraphicsPipeline( VK_NULL_HANDLE ),
// Tutorial03 // ImageAvailableSemaphore( VK_NULL_HANDLE ),
// // RenderingFinishedSemaphore( VK_NULL_HANDLE ) {
// Class for presenting Vulkan usage topics // }
// ************************************************************ // };
class Tutorial03 : public VulkanCommon {
public: // ************************************************************ //
Tutorial03(); // Tutorial03 //
~Tutorial03(); // //
// Class for presenting Vulkan usage topics //
bool CreateRenderPass(); // ************************************************************ //
bool CreateFramebuffers(); class Tutorial03 : public VulkanCommon {
bool CreatePipeline(); public:
bool CreateSemaphores(); Tutorial03();
bool CreateCommandBuffers(); ~Tutorial03();
bool RecordCommandBuffers();
bool CreateRenderPass();
bool Draw() override; bool CreateFramebuffers();
bool CreatePipeline();
private: bool CreateSemaphores();
VulkanTutorial03Parameters Vulkan; bool CreateCommandBuffers();
bool RecordCommandBuffers();
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout(); bool Draw() override;
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers ); private:
VulkanTutorial03Parameters Vulkan;
void ChildClear() override;
bool ChildOnWindowSizeChanged() override; Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
};
} // namespace ApiWithoutSecrets
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout(); Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();

View File

@@ -1,53 +1,49 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "Tutorial03.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
int main( int argc, char **argv ) { // See the License for the specific language governing permissions and
ApiWithoutSecrets::OS::Window window; // limitations under the License.
ApiWithoutSecrets::Tutorial03 tutorial03; /////////////////////////////////////////////////////////////////////////////////////////////
// Window creation #include "Tutorial03.h"
if( !window.Create( "03 - First Triangle" ) ) {
return -1; int main( int argc, char **argv ) {
} ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial03 tutorial03;
// Vulkan preparations and initialization
if( !tutorial03.PrepareVulkan( window.GetParameters() ) ) { // Window creation
return -1; if( !window.Create( "03 - First Triangle" ) ) {
} return -1;
}
// Tutorial 03
if( !tutorial03.CreateRenderPass() ) { // Vulkan preparations and initialization
return -1; if( !tutorial03.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
if( !tutorial03.CreateFramebuffers() ) { }
return -1;
} // Tutorial 03
if( !tutorial03.CreatePipeline() ) { if( !tutorial03.CreateRenderPass() ) {
return -1; return -1;
} }
if( !tutorial03.CreateSemaphores() ) { if( !tutorial03.CreateFramebuffers() ) {
return -1; return -1;
} }
if( !tutorial03.CreateCommandBuffers() ) { if( !tutorial03.CreatePipeline() ) {
return -1; return -1;
} }
if( !tutorial03.RecordCommandBuffers() ) { if( !tutorial03.CreateSemaphores() ) {
return -1; return -1;
} }
if( !tutorial03.CreateCommandBuffers() ) {
// Rendering loop return -1;
if( !window.RenderingLoop( tutorial03 ) ) { }
return -1; if( !tutorial03.RecordCommandBuffers() ) {
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,127 +1,123 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TUTORIAL_04_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TUTORIAL_04_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include "VulkanCommon.h" // limitations under the License.
#include "Tools.h" /////////////////////////////////////////////////////////////////////////////////////////////
namespace ApiWithoutSecrets { #if !defined(TUTORIAL_04_HEADER)
#define TUTORIAL_04_HEADER
// ************************************************************ //
// BufferParameters // #include "VulkanCommon.h"
// // #include "Tools.h"
// Vulkan Buffer's parameters container class //
// ************************************************************ // namespace ApiWithoutSecrets {
struct BufferParameters {
VkBuffer Handle; // ************************************************************ //
VkDeviceMemory Memory; // BufferParameters //
uint32_t Size; // //
// Vulkan Buffer's parameters container class //
BufferParameters() : // ************************************************************ //
Handle( VK_NULL_HANDLE ), struct BufferParameters {
Memory( VK_NULL_HANDLE ), VkBuffer Handle;
Size( 0 ) { VkDeviceMemory Memory;
} uint32_t Size;
};
BufferParameters() :
// ************************************************************ // Handle( VK_NULL_HANDLE ),
// VertexData // Memory( VK_NULL_HANDLE ),
// // Size( 0 ) {
// Struct describing data type and format of vertex attributes // }
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float r, g, b, a; // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct VertexData {
// // float x, y, z, w;
// Struct containing data used during rendering process // float r, g, b, a;
// ************************************************************ // };
struct RenderingResourcesData {
VkFramebuffer Framebuffer; // ************************************************************ //
VkCommandBuffer CommandBuffer; // RenderingResourcesData //
VkSemaphore ImageAvailableSemaphore; // //
VkSemaphore FinishedRenderingSemaphore; // Struct containing data used during rendering process //
VkFence Fence; // ************************************************************ //
struct RenderingResourcesData {
RenderingResourcesData() : VkFramebuffer Framebuffer;
Framebuffer( VK_NULL_HANDLE ), VkCommandBuffer CommandBuffer;
CommandBuffer( VK_NULL_HANDLE ), VkSemaphore ImageAvailableSemaphore;
ImageAvailableSemaphore( VK_NULL_HANDLE ), VkSemaphore FinishedRenderingSemaphore;
FinishedRenderingSemaphore( VK_NULL_HANDLE ), VkFence Fence;
Fence( VK_NULL_HANDLE ) {
} RenderingResourcesData() :
}; Framebuffer( VK_NULL_HANDLE ),
CommandBuffer( VK_NULL_HANDLE ),
// ************************************************************ // ImageAvailableSemaphore( VK_NULL_HANDLE ),
// VulkanTutorial04Parameters // FinishedRenderingSemaphore( VK_NULL_HANDLE ),
// // Fence( VK_NULL_HANDLE ) {
// Vulkan specific parameters // }
// ************************************************************ // };
struct VulkanTutorial04Parameters {
VkRenderPass RenderPass; // ************************************************************ //
VkPipeline GraphicsPipeline; // VulkanTutorial04Parameters //
BufferParameters VertexBuffer; // //
VkCommandPool CommandPool; // Vulkan specific parameters //
std::vector<RenderingResourcesData> RenderingResources; // ************************************************************ //
struct VulkanTutorial04Parameters {
static const size_t ResourcesCount = 3; VkRenderPass RenderPass;
VkPipeline GraphicsPipeline;
VulkanTutorial04Parameters() : BufferParameters VertexBuffer;
RenderPass( VK_NULL_HANDLE ), VkCommandPool CommandPool;
GraphicsPipeline( VK_NULL_HANDLE ), std::vector<RenderingResourcesData> RenderingResources;
VertexBuffer(),
CommandPool( VK_NULL_HANDLE ), static const size_t ResourcesCount = 3;
RenderingResources( ResourcesCount ) {
} VulkanTutorial04Parameters() :
}; RenderPass( VK_NULL_HANDLE ),
GraphicsPipeline( VK_NULL_HANDLE ),
// ************************************************************ // VertexBuffer(),
// Tutorial04 // CommandPool( VK_NULL_HANDLE ),
// // RenderingResources( ResourcesCount ) {
// Class for presenting Vulkan usage topics // }
// ************************************************************ // };
class Tutorial04 : public VulkanCommon {
public: // ************************************************************ //
Tutorial04(); // Tutorial04 //
~Tutorial04(); // //
// Class for presenting Vulkan usage topics //
bool CreateRenderPass(); // ************************************************************ //
bool CreatePipeline(); class Tutorial04 : public VulkanCommon {
bool CreateVertexBuffer(); public:
bool CreateRenderingResources(); Tutorial04();
~Tutorial04();
bool Draw() override;
bool CreateRenderPass();
private: bool CreatePipeline();
VulkanTutorial04Parameters Vulkan; bool CreateVertexBuffer();
bool CreateRenderingResources();
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout(); bool Draw() override;
bool AllocateBufferMemory( VkBuffer buffer, VkDeviceMemory *memory );
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool ); private:
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers ); VulkanTutorial04Parameters Vulkan;
bool CreateCommandBuffers();
bool CreateSemaphores(); Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
bool CreateFences(); Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool AllocateBufferMemory( VkBuffer buffer, VkDeviceMemory *memory );
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
void ChildClear() override; bool CreateCommandBuffers();
bool ChildOnWindowSizeChanged() override; bool CreateSemaphores();
};
} // namespace ApiWithoutSecrets
bool CreateFences(); bool CreateFences();

View File

@@ -1,47 +1,43 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "Tutorial04.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
int main( int argc, char **argv ) { // See the License for the specific language governing permissions and
ApiWithoutSecrets::OS::Window window; // limitations under the License.
ApiWithoutSecrets::Tutorial04 tutorial04; /////////////////////////////////////////////////////////////////////////////////////////////
// Window creation #include "Tutorial04.h"
if( !window.Create( "04 - Vertex Attributes" ) ) {
return -1; int main( int argc, char **argv ) {
} ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial04 tutorial04;
// Vulkan preparations and initialization
if( !tutorial04.PrepareVulkan( window.GetParameters() ) ) { // Window creation
return -1; if( !window.Create( "04 - Vertex Attributes" ) ) {
} return -1;
}
// Tutorial 04
if( !tutorial04.CreateRenderPass() ) { // Vulkan preparations and initialization
return -1; if( !tutorial04.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
if( !tutorial04.CreatePipeline() ) { }
return -1;
} // Tutorial 04
if( !tutorial04.CreateVertexBuffer() ) { if( !tutorial04.CreateRenderPass() ) {
return -1; return -1;
} }
if( !tutorial04.CreateRenderingResources() ) { if( !tutorial04.CreatePipeline() ) {
return -1; return -1;
} }
if( !tutorial04.CreateVertexBuffer() ) {
// Rendering loop return -1;
if( !window.RenderingLoop( tutorial04 ) ) { }
return -1; if( !tutorial04.CreateRenderingResources() ) {
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,133 +1,129 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TUTORIAL_05_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TUTORIAL_05_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include "VulkanCommon.h" // limitations under the License.
#include "Tools.h" /////////////////////////////////////////////////////////////////////////////////////////////
namespace ApiWithoutSecrets { #if !defined(TUTORIAL_05_HEADER)
#define TUTORIAL_05_HEADER
// ************************************************************ //
// BufferParameters // #include "VulkanCommon.h"
// // #include "Tools.h"
// Vulkan Buffer's parameters container class //
// ************************************************************ // namespace ApiWithoutSecrets {
struct BufferParameters {
VkBuffer Handle; // ************************************************************ //
VkDeviceMemory Memory; // BufferParameters //
uint32_t Size; // //
// Vulkan Buffer's parameters container class //
BufferParameters() : // ************************************************************ //
Handle( VK_NULL_HANDLE ), struct BufferParameters {
Memory( VK_NULL_HANDLE ), VkBuffer Handle;
Size( 0 ) { VkDeviceMemory Memory;
} uint32_t Size;
};
BufferParameters() :
// ************************************************************ // Handle( VK_NULL_HANDLE ),
// VertexData // Memory( VK_NULL_HANDLE ),
// // Size( 0 ) {
// Struct describing data type and format of vertex attributes // }
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float r, g, b, a; // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct VertexData {
// // float x, y, z, w;
// Struct containing data used during rendering process // float r, g, b, a;
// ************************************************************ // };
struct RenderingResourcesData {
VkFramebuffer Framebuffer; // ************************************************************ //
VkCommandBuffer CommandBuffer; // RenderingResourcesData //
VkSemaphore ImageAvailableSemaphore; // //
VkSemaphore FinishedRenderingSemaphore; // Struct containing data used during rendering process //
VkFence Fence; // ************************************************************ //
struct RenderingResourcesData {
RenderingResourcesData() : VkFramebuffer Framebuffer;
Framebuffer( VK_NULL_HANDLE ), VkCommandBuffer CommandBuffer;
CommandBuffer( VK_NULL_HANDLE ), VkSemaphore ImageAvailableSemaphore;
ImageAvailableSemaphore( VK_NULL_HANDLE ), VkSemaphore FinishedRenderingSemaphore;
FinishedRenderingSemaphore( VK_NULL_HANDLE ), VkFence Fence;
Fence( VK_NULL_HANDLE ) {
} RenderingResourcesData() :
}; Framebuffer( VK_NULL_HANDLE ),
CommandBuffer( VK_NULL_HANDLE ),
// ************************************************************ // ImageAvailableSemaphore( VK_NULL_HANDLE ),
// VulkanTutorial04Parameters // FinishedRenderingSemaphore( VK_NULL_HANDLE ),
// // Fence( VK_NULL_HANDLE ) {
// Vulkan specific parameters // }
// ************************************************************ // };
struct VulkanTutorial05Parameters {
VkRenderPass RenderPass; // ************************************************************ //
VkPipeline GraphicsPipeline; // VulkanTutorial04Parameters //
BufferParameters VertexBuffer; // //
BufferParameters StagingBuffer; // Vulkan specific parameters //
VkCommandPool CommandPool; // ************************************************************ //
std::vector<RenderingResourcesData> RenderingResources; struct VulkanTutorial05Parameters {
VkRenderPass RenderPass;
static const size_t ResourcesCount = 3; VkPipeline GraphicsPipeline;
BufferParameters VertexBuffer;
VulkanTutorial05Parameters() : BufferParameters StagingBuffer;
RenderPass( VK_NULL_HANDLE ), VkCommandPool CommandPool;
GraphicsPipeline( VK_NULL_HANDLE ), std::vector<RenderingResourcesData> RenderingResources;
VertexBuffer(),
StagingBuffer(), static const size_t ResourcesCount = 3;
CommandPool( VK_NULL_HANDLE ),
RenderingResources( ResourcesCount ) { VulkanTutorial05Parameters() :
} RenderPass( VK_NULL_HANDLE ),
}; GraphicsPipeline( VK_NULL_HANDLE ),
VertexBuffer(),
// ************************************************************ // StagingBuffer(),
// Tutorial04 // CommandPool( VK_NULL_HANDLE ),
// // RenderingResources( ResourcesCount ) {
// Class for presenting Vulkan usage topics // }
// ************************************************************ // };
class Tutorial05 : public VulkanCommon {
public: // ************************************************************ //
Tutorial05(); // Tutorial04 //
~Tutorial05(); // //
// Class for presenting Vulkan usage topics //
bool CreateRenderingResources(); // ************************************************************ //
bool CreateRenderPass(); class Tutorial05 : public VulkanCommon {
bool CreatePipeline(); public:
bool CreateVertexBuffer(); Tutorial05();
bool CreateStagingBuffer(); ~Tutorial05();
bool CopyVertexData();
bool CreateRenderingResources();
bool Draw() override; bool CreateRenderPass();
bool CreatePipeline();
private: bool CreateVertexBuffer();
VulkanTutorial05Parameters Vulkan; bool CreateStagingBuffer();
bool CopyVertexData();
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers ); bool Draw() override;
bool CreateSemaphore( VkSemaphore *semaphore );
bool CreateFence( VkFenceCreateFlags flags, VkFence *fence ); private:
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename ); VulkanTutorial05Parameters Vulkan;
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
bool CreateBuffer( VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer ); bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
bool AllocateBufferMemory( VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory ); bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
const std::vector<float>& GetVertexData() const; bool CreateSemaphore( VkSemaphore *semaphore );
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool CreateFence( VkFenceCreateFlags flags, VkFence *fence );
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
void DestroyBuffer( BufferParameters& buffer ); Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
bool CreateBuffer( VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer );
void ChildClear() override; bool AllocateBufferMemory( VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
bool ChildOnWindowSizeChanged() override; const std::vector<float>& GetVertexData() const;
};
} // namespace ApiWithoutSecrets
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );

View File

@@ -1,53 +1,49 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "Tutorial05.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
int main( int argc, char **argv ) { // See the License for the specific language governing permissions and
ApiWithoutSecrets::OS::Window window; // limitations under the License.
ApiWithoutSecrets::Tutorial05 tutorial05; /////////////////////////////////////////////////////////////////////////////////////////////
// Window creation #include "Tutorial05.h"
if( !window.Create( "05 - Staging Resources" ) ) {
return -1; int main( int argc, char **argv ) {
} ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial05 tutorial05;
// Vulkan preparations and initialization
if( !tutorial05.PrepareVulkan( window.GetParameters() ) ) { // Window creation
return -1; if( !window.Create( "05 - Staging Resources" ) ) {
} return -1;
}
// Tutorial 05
if( !tutorial05.CreateRenderingResources() ) { // Vulkan preparations and initialization
return -1; if( !tutorial05.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
if( !tutorial05.CreateRenderPass() ) { }
return -1;
} // Tutorial 05
if( !tutorial05.CreatePipeline() ) { if( !tutorial05.CreateRenderingResources() ) {
return -1; return -1;
} }
if( !tutorial05.CreateVertexBuffer() ) { if( !tutorial05.CreateRenderPass() ) {
return -1; return -1;
} }
if( !tutorial05.CreateStagingBuffer() ) { if( !tutorial05.CreatePipeline() ) {
return -1; return -1;
} }
if( !tutorial05.CopyVertexData() ) { if( !tutorial05.CreateVertexBuffer() ) {
return -1; return -1;
} }
if( !tutorial05.CreateStagingBuffer() ) {
// Rendering loop return -1;
if( !window.RenderingLoop( tutorial05 ) ) { }
return -1; if( !tutorial05.CopyVertexData() ) {
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,167 +1,163 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TUTORIAL_06_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TUTORIAL_06_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include "VulkanCommon.h" // limitations under the License.
#include "Tools.h" /////////////////////////////////////////////////////////////////////////////////////////////
namespace ApiWithoutSecrets { #if !defined(TUTORIAL_06_HEADER)
#define TUTORIAL_06_HEADER
// ************************************************************ //
// BufferParameters // #include "VulkanCommon.h"
// // #include "Tools.h"
// Vulkan Buffer's parameters container class //
// ************************************************************ // namespace ApiWithoutSecrets {
struct BufferParameters {
VkBuffer Handle; // ************************************************************ //
VkDeviceMemory Memory; // BufferParameters //
uint32_t Size; // //
// Vulkan Buffer's parameters container class //
BufferParameters() : // ************************************************************ //
Handle( VK_NULL_HANDLE ), struct BufferParameters {
Memory( VK_NULL_HANDLE ), VkBuffer Handle;
Size( 0 ) { VkDeviceMemory Memory;
} uint32_t Size;
};
BufferParameters() :
// ************************************************************ // Handle( VK_NULL_HANDLE ),
// DescriptorParameters // Memory( VK_NULL_HANDLE ),
// // Size( 0 ) {
// Container class for descriptor related resources // }
// ************************************************************ // };
struct DescriptorSetParameters {
VkDescriptorPool Pool; // ************************************************************ //
VkDescriptorSetLayout Layout; // DescriptorParameters //
VkDescriptorSet Handle; // //
// Container class for descriptor related resources //
DescriptorSetParameters() : // ************************************************************ //
Pool( VK_NULL_HANDLE ), struct DescriptorSetParameters {
Layout( VK_NULL_HANDLE ), VkDescriptorPool Pool;
Handle( VK_NULL_HANDLE ) { VkDescriptorSetLayout Layout;
} VkDescriptorSet Handle;
};
DescriptorSetParameters() :
// ************************************************************ // Pool( VK_NULL_HANDLE ),
// VertexData // Layout( VK_NULL_HANDLE ),
// // Handle( VK_NULL_HANDLE ) {
// Struct describing data type and format of vertex attributes // }
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float u, v; // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct VertexData {
// // float x, y, z, w;
// Struct containing data used during rendering process // float u, v;
// ************************************************************ // };
struct RenderingResourcesData {
VkFramebuffer Framebuffer; // ************************************************************ //
VkCommandBuffer CommandBuffer; // RenderingResourcesData //
VkSemaphore ImageAvailableSemaphore; // //
VkSemaphore FinishedRenderingSemaphore; // Struct containing data used during rendering process //
VkFence Fence; // ************************************************************ //
struct RenderingResourcesData {
RenderingResourcesData() : VkFramebuffer Framebuffer;
Framebuffer( VK_NULL_HANDLE ), VkCommandBuffer CommandBuffer;
CommandBuffer( VK_NULL_HANDLE ), VkSemaphore ImageAvailableSemaphore;
ImageAvailableSemaphore( VK_NULL_HANDLE ), VkSemaphore FinishedRenderingSemaphore;
FinishedRenderingSemaphore( VK_NULL_HANDLE ), VkFence Fence;
Fence( VK_NULL_HANDLE ) {
} RenderingResourcesData() :
}; Framebuffer( VK_NULL_HANDLE ),
CommandBuffer( VK_NULL_HANDLE ),
// ************************************************************ // ImageAvailableSemaphore( VK_NULL_HANDLE ),
// VulkanTutorial04Parameters // FinishedRenderingSemaphore( VK_NULL_HANDLE ),
// // Fence( VK_NULL_HANDLE ) {
// Vulkan specific parameters // }
// ************************************************************ // };
struct VulkanTutorial06Parameters {
VkRenderPass RenderPass; // ************************************************************ //
ImageParameters Image; // VulkanTutorial04Parameters //
DescriptorSetParameters DescriptorSet; // //
VkPipelineLayout PipelineLayout; // Vulkan specific parameters //
VkPipeline GraphicsPipeline; // ************************************************************ //
BufferParameters VertexBuffer; struct VulkanTutorial06Parameters {
BufferParameters StagingBuffer; VkRenderPass RenderPass;
VkCommandPool CommandPool; ImageParameters Image;
std::vector<RenderingResourcesData> RenderingResources; DescriptorSetParameters DescriptorSet;
VkPipelineLayout PipelineLayout;
static const size_t ResourcesCount = 3; VkPipeline GraphicsPipeline;
BufferParameters VertexBuffer;
VulkanTutorial06Parameters() : BufferParameters StagingBuffer;
RenderPass( VK_NULL_HANDLE ), VkCommandPool CommandPool;
Image(), std::vector<RenderingResourcesData> RenderingResources;
DescriptorSet(),
PipelineLayout(), static const size_t ResourcesCount = 3;
GraphicsPipeline( VK_NULL_HANDLE ),
VertexBuffer(), VulkanTutorial06Parameters() :
StagingBuffer(), RenderPass( VK_NULL_HANDLE ),
CommandPool( VK_NULL_HANDLE ), Image(),
RenderingResources( ResourcesCount ) { DescriptorSet(),
} PipelineLayout(),
}; GraphicsPipeline( VK_NULL_HANDLE ),
VertexBuffer(),
// ************************************************************ // StagingBuffer(),
// Tutorial04 // CommandPool( VK_NULL_HANDLE ),
// // RenderingResources( ResourcesCount ) {
// Class for presenting Vulkan usage topics // }
// ************************************************************ // };
class Tutorial06 : public VulkanCommon {
public: // ************************************************************ //
Tutorial06(); // Tutorial04 //
~Tutorial06(); // //
// Class for presenting Vulkan usage topics //
bool CreateRenderingResources(); // ************************************************************ //
bool CreateStagingBuffer(); class Tutorial06 : public VulkanCommon {
bool CreateTexture(); public:
bool CreateDescriptorSetLayout(); Tutorial06();
bool CreateDescriptorPool(); ~Tutorial06();
bool AllocateDescriptorSet();
bool UpdateDescriptorSet(); bool CreateRenderingResources();
bool CreateRenderPass(); bool CreateStagingBuffer();
bool CreatePipelineLayout(); bool CreateTexture();
bool CreatePipeline(); bool CreateDescriptorSetLayout();
bool CreateVertexBuffer(); bool CreateDescriptorPool();
bool AllocateDescriptorSet();
bool Draw() override; bool UpdateDescriptorSet();
bool CreateRenderPass();
private: bool CreatePipelineLayout();
VulkanTutorial06Parameters Vulkan; bool CreatePipeline();
bool CreateVertexBuffer();
bool CreateCommandBuffers();
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool); bool Draw() override;
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
bool CreateSemaphores(); private:
bool CreateFences(); VulkanTutorial06Parameters Vulkan;
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory); bool CreateCommandBuffers();
bool CreateImage( uint32_t width, uint32_t height, VkImage *image ); bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory ); bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
bool CreateImageView( ImageParameters &image_parameters ); bool CreateSemaphores();
bool CreateSampler( VkSampler *sampler ); bool CreateFences();
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height ); bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename ); bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
const std::vector<float>& GetVertexData() const; bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
bool CopyVertexData(); bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool CreateImageView( ImageParameters &image_parameters );
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); bool CreateSampler( VkSampler *sampler );
void DestroyBuffer( BufferParameters& buffer ); bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
bool ChildOnWindowSizeChanged() override; const std::vector<float>& GetVertexData() const;
void ChildClear() override; bool CopyVertexData();
};
} // namespace ApiWithoutSecrets
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );

View File

@@ -1,68 +1,64 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "Tutorial06.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
int main( int argc, char **argv ) { // See the License for the specific language governing permissions and
ApiWithoutSecrets::OS::Window window; // limitations under the License.
ApiWithoutSecrets::Tutorial06 tutorial06; /////////////////////////////////////////////////////////////////////////////////////////////
// Window creation #include "Tutorial06.h"
if( !window.Create( "06 - Descriptor Sets" ) ) {
return -1; int main( int argc, char **argv ) {
} ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial06 tutorial06;
// Vulkan preparations and initialization
if( !tutorial06.PrepareVulkan( window.GetParameters() ) ) { // Window creation
return -1; if( !window.Create( "06 - Descriptor Sets" ) ) {
} return -1;
}
// Tutorial 06
if( !tutorial06.CreateRenderingResources() ) { // Vulkan preparations and initialization
return -1; if( !tutorial06.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
if( !tutorial06.CreateStagingBuffer() ) { }
return -1;
} // Tutorial 06
if( !tutorial06.CreateTexture() ) { if( !tutorial06.CreateRenderingResources() ) {
return -1; return -1;
} }
if( !tutorial06.CreateDescriptorSetLayout() ) { if( !tutorial06.CreateStagingBuffer() ) {
return -1; return -1;
} }
if( !tutorial06.CreateDescriptorPool() ) { if( !tutorial06.CreateTexture() ) {
return -1; return -1;
} }
if( !tutorial06.AllocateDescriptorSet() ) { if( !tutorial06.CreateDescriptorSetLayout() ) {
return -1; return -1;
} }
if( !tutorial06.UpdateDescriptorSet() ) { if( !tutorial06.CreateDescriptorPool() ) {
return -1; return -1;
} }
if( !tutorial06.CreateRenderPass() ) { if( !tutorial06.AllocateDescriptorSet() ) {
return -1; return -1;
} }
if( !tutorial06.CreatePipelineLayout() ) { if( !tutorial06.UpdateDescriptorSet() ) {
return -1; return -1;
} }
if( !tutorial06.CreatePipeline() ) { if( !tutorial06.CreateRenderPass() ) {
return -1; return -1;
} }
if( !tutorial06.CreateVertexBuffer() ) { if( !tutorial06.CreatePipelineLayout() ) {
return -1; return -1;
} }
if( !tutorial06.CreatePipeline() ) {
// Rendering loop return -1;
if( !window.RenderingLoop( tutorial06 ) ) { }
return -1; if( !tutorial06.CreateVertexBuffer() ) {
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,171 +1,167 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#if !defined(TUTORIAL_07_HEADER) // distributed under the License is distributed on an "AS IS" BASIS,
#define TUTORIAL_07_HEADER // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
#include "VulkanCommon.h" // limitations under the License.
#include "Tools.h" /////////////////////////////////////////////////////////////////////////////////////////////
namespace ApiWithoutSecrets { #if !defined(TUTORIAL_07_HEADER)
#define TUTORIAL_07_HEADER
// ************************************************************ //
// BufferParameters // #include "VulkanCommon.h"
// // #include "Tools.h"
// Vulkan Buffer's parameters container class //
// ************************************************************ // namespace ApiWithoutSecrets {
struct BufferParameters {
VkBuffer Handle; // ************************************************************ //
VkDeviceMemory Memory; // BufferParameters //
uint32_t Size; // //
// Vulkan Buffer's parameters container class //
BufferParameters() : // ************************************************************ //
Handle( VK_NULL_HANDLE ), struct BufferParameters {
Memory( VK_NULL_HANDLE ), VkBuffer Handle;
Size( 0 ) { VkDeviceMemory Memory;
} uint32_t Size;
};
BufferParameters() :
// ************************************************************ // Handle( VK_NULL_HANDLE ),
// DescriptorParameters // Memory( VK_NULL_HANDLE ),
// // Size( 0 ) {
// Container class for descriptor related resources // }
// ************************************************************ // };
struct DescriptorSetParameters {
VkDescriptorPool Pool; // ************************************************************ //
VkDescriptorSetLayout Layout; // DescriptorParameters //
VkDescriptorSet Handle; // //
// Container class for descriptor related resources //
DescriptorSetParameters() : // ************************************************************ //
Pool( VK_NULL_HANDLE ), struct DescriptorSetParameters {
Layout( VK_NULL_HANDLE ), VkDescriptorPool Pool;
Handle( VK_NULL_HANDLE ) { VkDescriptorSetLayout Layout;
} VkDescriptorSet Handle;
};
DescriptorSetParameters() :
// ************************************************************ // Pool( VK_NULL_HANDLE ),
// VertexData // Layout( VK_NULL_HANDLE ),
// // Handle( VK_NULL_HANDLE ) {
// Struct describing data type and format of vertex attributes // }
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float u, v; // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct VertexData {
// // float x, y, z, w;
// Struct containing data used during rendering process // float u, v;
// ************************************************************ // };
struct RenderingResourcesData {
VkFramebuffer Framebuffer; // ************************************************************ //
VkCommandBuffer CommandBuffer; // RenderingResourcesData //
VkSemaphore ImageAvailableSemaphore; // //
VkSemaphore FinishedRenderingSemaphore; // Struct containing data used during rendering process //
VkFence Fence; // ************************************************************ //
struct RenderingResourcesData {
RenderingResourcesData() : VkFramebuffer Framebuffer;
Framebuffer( VK_NULL_HANDLE ), VkCommandBuffer CommandBuffer;
CommandBuffer( VK_NULL_HANDLE ), VkSemaphore ImageAvailableSemaphore;
ImageAvailableSemaphore( VK_NULL_HANDLE ), VkSemaphore FinishedRenderingSemaphore;
FinishedRenderingSemaphore( VK_NULL_HANDLE ), VkFence Fence;
Fence( VK_NULL_HANDLE ) {
} RenderingResourcesData() :
}; Framebuffer( VK_NULL_HANDLE ),
CommandBuffer( VK_NULL_HANDLE ),
// ************************************************************ // ImageAvailableSemaphore( VK_NULL_HANDLE ),
// VulkanTutorial04Parameters // FinishedRenderingSemaphore( VK_NULL_HANDLE ),
// // Fence( VK_NULL_HANDLE ) {
// Vulkan specific parameters // }
// ************************************************************ // };
struct VulkanTutorial07Parameters {
VkRenderPass RenderPass; // ************************************************************ //
ImageParameters Image; // VulkanTutorial04Parameters //
BufferParameters UniformBuffer; // //
DescriptorSetParameters DescriptorSet; // Vulkan specific parameters //
VkPipelineLayout PipelineLayout; // ************************************************************ //
VkPipeline GraphicsPipeline; struct VulkanTutorial07Parameters {
BufferParameters VertexBuffer; VkRenderPass RenderPass;
BufferParameters StagingBuffer; ImageParameters Image;
VkCommandPool CommandPool; BufferParameters UniformBuffer;
std::vector<RenderingResourcesData> RenderingResources; DescriptorSetParameters DescriptorSet;
VkPipelineLayout PipelineLayout;
static const size_t ResourcesCount = 3; VkPipeline GraphicsPipeline;
BufferParameters VertexBuffer;
VulkanTutorial07Parameters() : BufferParameters StagingBuffer;
RenderPass( VK_NULL_HANDLE ), VkCommandPool CommandPool;
Image(), std::vector<RenderingResourcesData> RenderingResources;
DescriptorSet(),
PipelineLayout(), static const size_t ResourcesCount = 3;
GraphicsPipeline( VK_NULL_HANDLE ),
VertexBuffer(), VulkanTutorial07Parameters() :
StagingBuffer(), RenderPass( VK_NULL_HANDLE ),
CommandPool( VK_NULL_HANDLE ), Image(),
RenderingResources( ResourcesCount ) { DescriptorSet(),
} PipelineLayout(),
}; GraphicsPipeline( VK_NULL_HANDLE ),
VertexBuffer(),
// ************************************************************ // StagingBuffer(),
// Tutorial04 // CommandPool( VK_NULL_HANDLE ),
// // RenderingResources( ResourcesCount ) {
// Class for presenting Vulkan usage topics // }
// ************************************************************ // };
class Tutorial07 : public VulkanCommon {
public: // ************************************************************ //
Tutorial07(); // Tutorial04 //
~Tutorial07(); // //
// Class for presenting Vulkan usage topics //
bool CreateRenderingResources(); // ************************************************************ //
bool CreateStagingBuffer(); class Tutorial07 : public VulkanCommon {
bool CreateTexture(); public:
bool CreateUniformBuffer(); Tutorial07();
bool CreateDescriptorSetLayout(); ~Tutorial07();
bool CreateDescriptorPool();
bool AllocateDescriptorSet(); bool CreateRenderingResources();
bool UpdateDescriptorSet(); bool CreateStagingBuffer();
bool CreateRenderPass(); bool CreateTexture();
bool CreatePipelineLayout(); bool CreateUniformBuffer();
bool CreatePipeline(); bool CreateDescriptorSetLayout();
bool CreateVertexBuffer(); bool CreateDescriptorPool();
bool AllocateDescriptorSet();
bool Draw() override; bool UpdateDescriptorSet();
bool CreateRenderPass();
private: bool CreatePipelineLayout();
VulkanTutorial07Parameters Vulkan; bool CreatePipeline();
bool CreateVertexBuffer();
bool CreateCommandBuffers();
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool); bool Draw() override;
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
bool CreateSemaphores(); private:
bool CreateFences(); VulkanTutorial07Parameters Vulkan;
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory); bool CreateCommandBuffers();
bool CreateImage( uint32_t width, uint32_t height, VkImage *image ); bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory ); bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
bool CreateImageView( ImageParameters &image_parameters ); bool CreateSemaphores();
bool CreateSampler( VkSampler *sampler ); bool CreateFences();
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height ); bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
const std::array<float, 16> GetUniformBufferData() const; bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
bool CopyUniformBufferData(); bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename ); bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
const std::vector<float>& GetVertexData() const; bool CreateImageView( ImageParameters &image_parameters );
bool CopyVertexData(); bool CreateSampler( VkSampler *sampler );
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); const std::array<float, 16> GetUniformBufferData() const;
void DestroyBuffer( BufferParameters& buffer ); bool CopyUniformBufferData();
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
bool ChildOnWindowSizeChanged() override; const std::vector<float>& GetVertexData() const;
void ChildClear() override; bool CopyVertexData();
};
} // namespace ApiWithoutSecrets
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );

View File

@@ -1,71 +1,67 @@
// Copyright 2016 Intel Corporation All Rights Reserved /////////////////////////////////////////////////////////////////////////////////////////////
// // Copyright 2017 Intel Corporation
// Intel makes no representations about the suitability of this software for any purpose. //
// THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, // Licensed under the Apache License, Version 2.0 (the "License");
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, // you may not use this file except in compliance with the License.
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY // You may obtain a copy of the License at
// 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 // http://www.apache.org/licenses/LICENSE-2.0
// nor any responsibility to update it. //
// Unless required by applicable law or agreed to in writing, software
#include "Tutorial07.h" // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
int main( int argc, char **argv ) { // See the License for the specific language governing permissions and
ApiWithoutSecrets::OS::Window window; // limitations under the License.
ApiWithoutSecrets::Tutorial07 tutorial07; /////////////////////////////////////////////////////////////////////////////////////////////
// Window creation #include "Tutorial07.h"
if( !window.Create( "07 - Uniform Buffers" ) ) {
return -1; int main( int argc, char **argv ) {
} ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial07 tutorial07;
// Vulkan preparations and initialization
if( !tutorial07.PrepareVulkan( window.GetParameters() ) ) { // Window creation
return -1; if( !window.Create( "07 - Uniform Buffers" ) ) {
} return -1;
}
// Tutorial 06
if( !tutorial07.CreateRenderingResources() ) { // Vulkan preparations and initialization
return -1; if( !tutorial07.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
if( !tutorial07.CreateStagingBuffer() ) { }
return -1;
} // Tutorial 06
if( !tutorial07.CreateTexture() ) { if( !tutorial07.CreateRenderingResources() ) {
return -1; return -1;
} }
if( !tutorial07.CreateUniformBuffer() ) { if( !tutorial07.CreateStagingBuffer() ) {
return -1; return -1;
} }
if( !tutorial07.CreateDescriptorSetLayout() ) { if( !tutorial07.CreateTexture() ) {
return -1; return -1;
} }
if( !tutorial07.CreateDescriptorPool() ) { if( !tutorial07.CreateUniformBuffer() ) {
return -1; return -1;
} }
if( !tutorial07.AllocateDescriptorSet() ) { if( !tutorial07.CreateDescriptorSetLayout() ) {
return -1; return -1;
} }
if( !tutorial07.UpdateDescriptorSet() ) { if( !tutorial07.CreateDescriptorPool() ) {
return -1; return -1;
} }
if( !tutorial07.CreateRenderPass() ) { if( !tutorial07.AllocateDescriptorSet() ) {
return -1; return -1;
} }
if( !tutorial07.CreatePipelineLayout() ) { if( !tutorial07.UpdateDescriptorSet() ) {
return -1; return -1;
} }
if( !tutorial07.CreatePipeline() ) { if( !tutorial07.CreateRenderPass() ) {
return -1; return -1;
} }
if( !tutorial07.CreateVertexBuffer() ) { if( !tutorial07.CreatePipelineLayout() ) {
return -1; return -1;
} }
if( !tutorial07.CreatePipeline() ) {
// Rendering loop return -1;
if( !window.RenderingLoop( tutorial07 ) ) { }
return -1; if( !tutorial07.CreateVertexBuffer() ) {
}
return 0;
}

View File

@@ -1,14 +1,20 @@
@ECHO OFF @ECHO OFF
REM Copyright 2016 Intel Corporation All Rights Reserved REM /////////////////////////////////////////////////////////////////////////////////////////////
REM REM // Copyright 2017 Intel Corporation
REM Intel makes no representations about the suitability of this software for any purpose. REM //
REM THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, REM // Licensed under the Apache License, Version 2.0 (the "License");
REM EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, REM // you may not use this file except in compliance with the License.
REM FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY REM // You may obtain a copy of the License at
REM RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. REM //
REM Intel does not assume any responsibility for any errors which may appear in this software REM // http://www.apache.org/licenses/LICENSE-2.0
REM nor any responsibility to update it. 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... echo Preparing 'IntroductionToVulkan' solution...

View File

@@ -1,46 +1,42 @@
@ECHO OFF @ECHO OFF
SETLOCAL SETLOCAL
REM Copyright 2016 Intel Corporation All Rights Reserved REM /////////////////////////////////////////////////////////////////////////////////////////////
REM REM // Copyright 2017 Intel Corporation
REM Intel makes no representations about the suitability of this software for any purpose. REM //
REM THIS SOFTWARE IS PROVIDED ""AS IS."" INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, REM // Licensed under the Apache License, Version 2.0 (the "License");
REM EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, REM // you may not use this file except in compliance with the License.
REM FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY REM // You may obtain a copy of the License at
REM RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. REM //
REM Intel does not assume any responsibility for any errors which may appear in this software REM // http://www.apache.org/licenses/LICENSE-2.0
REM nor any responsibility to update it. REM //
REM // Unless required by applicable law or agreed to in writing, software
if [%1] == [] ( REM // distributed under the License is distributed on an "AS IS" BASIS,
echo No arguments provided! Please specify folder number. REM // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
echo Example usage: compile_shaders.bat 03 REM // See the License for the specific language governing permissions and
goto end REM // limitations under the License.
) REM /////////////////////////////////////////////////////////////////////////////////////////////
if exist glslangValidator.exe ( if [%1] == [] (
goto convert echo No arguments provided! Please specify folder number.
) echo Example usage: compile_shaders.bat 03
for %%X in (glslangValidator.exe) do (set glslangValidator=%%~$PATH:X) goto end
if defined glslangValidator ( )
goto convert
) if exist glslangValidator.exe (
goto convert
echo Could not find "glslangValidator.exe" file. )
goto end for %%X in (glslangValidator.exe) do (set glslangValidator=%%~$PATH:X)
if defined glslangValidator (
:convert goto convert
)
set folder=Tutorial%1/Data%1
echo Converting GLSL shaders into SPIR-V assembly in the "%folder%" folder. echo Could not find "glslangValidator.exe" file.
goto end
if exist %folder%/shader.vert (
glslangValidator.exe -V -H -o %folder%/vert.spv %folder%/shader.vert > %folder%/vert.spv.txt :convert
)
set folder=Tutorial%1/Data%1
if exist %folder%/shader.frag ( echo Converting GLSL shaders into SPIR-V assembly in the "%folder%" folder.
glslangValidator.exe -V -H -o %folder%/frag.spv %folder%/shader.frag > %folder%/frag.spv.txt
)
:end
if exist %folder%/shader.vert ( if exist %folder%/shader.vert (

View File

@@ -1,258 +1,181 @@
Code Samples License Agreement (Version December 2015)
IMPORTANT - READ BEFORE COPYING, INSTALLING OR USING. Do not copy, install or Apache License
use the Materials (as defined below) provided under this license agreement Version 2.0, January 2004
("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.
If You are agreeing to the terms and conditions of this Agreement on behalf of a http://www.apache.org/licenses/
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.
By agreeing to this Agreement, You affirm that You are of legal age (18 years TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
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.
Third Party Programs (as defined below), even if included with the distribution 1. Definitions.
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. 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 "Licensor" shall mean the copyright owner or entity authorized by the copyright
necessarily and directly infringed by the reproduction and distribution of the owner that is granting the License.
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.
"Materials" means Sample Source Code, Redistributables, and End-User "Legal Entity" shall mean the union of the acting entity and all other entities
Documentation but do not include Third Party Programs. 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 "You" (or "Your") shall mean an individual or Legal Entity exercising
and which may include example interface or application source code, and any permissions granted by this License.
updates, provided under this Agreement.
"Source Code" is defined as the software (and not documentation or text) portion "Source" form shall mean the preferred form for making modifications, including
of the Materials provided in human readable format, and includes modifications but not limited to software source code, documentation source, and configuration
that You make or are made on Your behalf as expressly permitted under the terms files.
of this Agreement.
"Redistributables" means header, library, and dynamically linkable library "Object" form shall mean any form resulting from mechanical transformation or
files, and any updates, provided under this Agreement. 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 "Work" shall mean the work of authorship, whether in Source or Object form, made
included with the Materials for the applicable software that include a separate available under the License, as indicated by a copyright notice that is included
third party license agreement in an attached text file. 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 "Derivative Works" shall mean any work, whether in Source or Object form, that
to the Materials. 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 "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
non-exclusive, worldwide, non-assignable, royalty-free limited right and of whom a Contribution has been received by Licensor and subsequently
license: incorporated within the Work.
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.
B. Under its patents, to: 2. Grant of Copyright License. Subject to the terms and conditions of this
1) make copies of the Materials internally only; License, each Contributor hereby grants to You a perpetual, worldwide,
2) use the Materials internally only; and 3) offer to distribute, and non-exclusive, no-charge, royalty-free, irrevocable copyright license to
distribute, but not sell, the Materials only as part of or with Your reproduce, prepare Derivative Works of, publicly display, publicly perform,
products, under Intel's copyright license granted in Section 2(A) but only sublicense, and distribute the Work and such Derivative Works in Source or
under the terms of that copyright license and not as a sale (but this Object form.
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).
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: 4. Redistribution. You may reproduce and distribute copies of the Work or
i. use, copy, distribute or publicly display the Materials; Derivative Works thereof in any medium, with or without modifications, and in
ii. reverse-assemble, reverse-compile, or otherwise reverse-engineer any Source or Object form, provided that You meet the following conditions:
software provided solely in binary form, You must give any other recipients of the Work or Derivative Works a copy of
iii. rent or lease the Materials to any third party; this License; and
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.
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 must cause any modified files to carry prominent notices stating that You
You: changed the files; and
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.
4. OWNERSHIP:
Title to the Materials and all copies thereof remain with Intel or its You must retain, in the Source form of any Derivative Works that You
suppliers. The Materials are copyrighted and are protected by United States distribute, all copyright, patent, trademark, and attribution notices from the
copyright laws and international treaty provisions. You will not remove any Source form of the Work, excluding those notices that do not pertain to any
copyright notice from the Materials. You agree to prevent unauthorized copying part of the Derivative Works; and
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.
5. NO WARRANTY AND NO SUPPORT:
Disclaimer. Intel disclaims all warranties of any kind and the terms and If the Work includes a "NOTICE" text file as part of its distribution, then
remedies provided in this Agreement are instead of any other warranty or any Derivative Works that You distribute must include a readable copy of the
condition, express, implied or statutory, including those regarding attribution notices contained within such NOTICE file, excluding those notices
merchantability, fitness for any particular purpose, non-infringement or any that do not pertain to any part of the Derivative Works, in at least one of
warranty arising out of any course of dealing, usage of trade, proposal, the following places: within a NOTICE text file distributed as part of the
specification or sample. Intel does not assume (and does not authorize any Derivative Works; within the Source form or documentation, if provided along
person to assume on its behalf) any other liability. 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 5. Submission of Contributions. Unless You explicitly state otherwise, any
time without notice, but is not obligated to support, update or provide training Contribution intentionally submitted for inclusion in the Work by You to the
for the Materials. Intel may in its sole discretion offer such support, update Licensor shall be under the terms and conditions of this License, without any
or training services under separate terms at Intel's then-current rates. You additional terms or conditions. Notwithstanding the above, nothing herein shall
may request additional information on Intel's service offerings from an Intel supersede or modify the terms of any separate license agreement you may have
sales representative. 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 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
data, images, sounds, text, and other things embodied therein, you transmit or writing, Licensor provides the Work (and each Contributor provides its
post to an Intel website will be considered non-confidential ("Communications"). Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Intel will have no confidentiality obligations with respect to the KIND, either express or implied, including, without limitation, any warranties
Communications. You agree that Intel and its designees will be free to copy, or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
modify, create derivative works, publicly display, disclose, distribute, license PARTICULAR PURPOSE. You are solely responsible for determining the
and sublicense through multiple tiers of distribution and licensees, appropriateness of using or redistributing the Work and assume any risks
incorporate, and otherwise use the Communications, including derivative works associated with Your exercise of permissions under this License.
thereto, for any and all commercial or non-commercial purposes.
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 9. Accepting Warranty or Additional Liability. While redistributing the Work or
(including, without limitation, damages for loss of business profits, business Derivative Works thereof, You may choose to offer, and charge a fee for,
interruption, loss of business information, or other loss) arising out of the acceptance of support, warranty, indemnity, or other liability obligations
use of or inability to use the Materials, even if Intel has been advised of the and/or rights consistent with this License. However, in accepting such
possibility of such damages. Because some jurisdictions prohibit the exclusion obligations, You may act only on Your own behalf and on Your sole
or limitation of liability for consequential or incidental damages, the above responsibility, not on behalf of any other Contributor, and only if You agree to
limitation may not apply to You. 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 APPENDIX: How to apply the Apache License to your work
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.
9. U.S. GOVERNMENT RESTRICTED RIGHTS: To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
The technical data and computer software covered by this license is a identifying information. (Don't include the brackets!) The text should be
"Commercial Item", as such term is defined by the FAR 2.101 (48 C.F.R. 2.101) enclosed in the appropriate comment syntax for the file format. We also
and is "commercial computer software" and "commercial computer software recommend that a file or class name and description of purpose be included on
documentation" as specified under FAR 12.212 (48 C.F.R. 12.212) or DFARS the same "printed page" as the copyright notice for easier identification within
227.7202 (48 C.F.R. 227.7202), as applicable. This commercial computer software third-party archives.
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.
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.