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
+15 -9
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" )
+174 -178
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // ************************************************************ //
// Intel does not assume any responsibility for any errors which may appear in this software // Exported functions //
// nor any responsibility to update it. // //
// These functions are always exposed by vulkan libraries. //
// ************************************************************ // // ************************************************************ //
// Exported functions //
// // #if !defined(VK_EXPORTED_FUNCTION)
// These functions are always exposed by vulkan libraries. // #define VK_EXPORTED_FUNCTION( fun )
// ************************************************************ // #endif
#if !defined(VK_EXPORTED_FUNCTION) VK_EXPORTED_FUNCTION( vkGetInstanceProcAddr )
#define VK_EXPORTED_FUNCTION( fun )
#endif #undef VK_EXPORTED_FUNCTION
VK_EXPORTED_FUNCTION( vkGetInstanceProcAddr )
// ************************************************************ //
#undef VK_EXPORTED_FUNCTION // Global level functions //
// //
// They allow checking what instance extensions are available //
// ************************************************************ // // and allow creation of a Vulkan Instance. //
// Global level functions // // ************************************************************ //
// //
// They allow checking what instance extensions are available // #if !defined(VK_GLOBAL_LEVEL_FUNCTION)
// and allow creation of a Vulkan Instance. // #define VK_GLOBAL_LEVEL_FUNCTION( fun )
// ************************************************************ // #endif
#if !defined(VK_GLOBAL_LEVEL_FUNCTION) // Tutorial 01
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) VK_GLOBAL_LEVEL_FUNCTION( vkCreateInstance )
#endif
// Tutorial 02
// Tutorial 01 VK_GLOBAL_LEVEL_FUNCTION( vkEnumerateInstanceExtensionProperties )
VK_GLOBAL_LEVEL_FUNCTION( vkCreateInstance )
#undef VK_GLOBAL_LEVEL_FUNCTION
// Tutorial 02
VK_GLOBAL_LEVEL_FUNCTION( vkEnumerateInstanceExtensionProperties )
// ************************************************************ //
#undef VK_GLOBAL_LEVEL_FUNCTION // Instance level functions //
// //
// These functions allow for device queries and creation. //
// ************************************************************ // // They help choose which device is well suited for our needs. //
// Instance level functions // // ************************************************************ //
// //
// These functions allow for device queries and creation. // #if !defined(VK_INSTANCE_LEVEL_FUNCTION)
// They help choose which device is well suited for our needs. // #define VK_INSTANCE_LEVEL_FUNCTION( fun )
// ************************************************************ // #endif
#if !defined(VK_INSTANCE_LEVEL_FUNCTION) // Tutorial 01
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) VK_INSTANCE_LEVEL_FUNCTION( vkEnumeratePhysicalDevices )
#endif VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceProperties )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceFeatures )
// Tutorial 01 VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceQueueFamilyProperties )
VK_INSTANCE_LEVEL_FUNCTION( vkEnumeratePhysicalDevices ) VK_INSTANCE_LEVEL_FUNCTION( vkCreateDevice )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceProperties ) VK_INSTANCE_LEVEL_FUNCTION( vkGetDeviceProcAddr )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceFeatures ) VK_INSTANCE_LEVEL_FUNCTION( vkDestroyInstance )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceQueueFamilyProperties )
VK_INSTANCE_LEVEL_FUNCTION( vkCreateDevice ) // Tutorial 02
VK_INSTANCE_LEVEL_FUNCTION( vkGetDeviceProcAddr ) VK_INSTANCE_LEVEL_FUNCTION( vkEnumerateDeviceExtensionProperties )
VK_INSTANCE_LEVEL_FUNCTION( vkDestroyInstance ) #if defined(USE_SWAPCHAIN_EXTENSIONS)
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceSupportKHR )
// Tutorial 02 VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceCapabilitiesKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkEnumerateDeviceExtensionProperties ) VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceFormatsKHR )
#if defined(USE_SWAPCHAIN_EXTENSIONS) VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfacePresentModesKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceSupportKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkDestroySurfaceKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceCapabilitiesKHR ) #if defined(VK_USE_PLATFORM_WIN32_KHR)
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfaceFormatsKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkCreateWin32SurfaceKHR )
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceSurfacePresentModesKHR ) #elif defined(VK_USE_PLATFORM_XCB_KHR)
VK_INSTANCE_LEVEL_FUNCTION( vkDestroySurfaceKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkCreateXcbSurfaceKHR )
#if defined(VK_USE_PLATFORM_WIN32_KHR) #elif defined(VK_USE_PLATFORM_XLIB_KHR)
VK_INSTANCE_LEVEL_FUNCTION( vkCreateWin32SurfaceKHR ) VK_INSTANCE_LEVEL_FUNCTION( vkCreateXlibSurfaceKHR )
#elif defined(VK_USE_PLATFORM_XCB_KHR) #endif
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXcbSurfaceKHR ) #endif
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
VK_INSTANCE_LEVEL_FUNCTION( vkCreateXlibSurfaceKHR ) // Tutorial 04
#endif VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceMemoryProperties )
#endif
#undef VK_INSTANCE_LEVEL_FUNCTION
// Tutorial 04
VK_INSTANCE_LEVEL_FUNCTION( vkGetPhysicalDeviceMemoryProperties )
// ************************************************************ //
#undef VK_INSTANCE_LEVEL_FUNCTION // Device level functions //
// //
// These functions are used mainly for drawing //
// ************************************************************ // // ************************************************************ //
// Device level functions //
// // #if !defined(VK_DEVICE_LEVEL_FUNCTION)
// These functions are used mainly for drawing // #define VK_DEVICE_LEVEL_FUNCTION( fun )
// ************************************************************ // #endif
#if !defined(VK_DEVICE_LEVEL_FUNCTION) // Tutorial 01
#define VK_DEVICE_LEVEL_FUNCTION( fun ) VK_DEVICE_LEVEL_FUNCTION( vkGetDeviceQueue )
#endif VK_DEVICE_LEVEL_FUNCTION( vkDeviceWaitIdle )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDevice )
// Tutorial 01
VK_DEVICE_LEVEL_FUNCTION( vkGetDeviceQueue ) // Tutorial 02
VK_DEVICE_LEVEL_FUNCTION( vkDeviceWaitIdle ) VK_DEVICE_LEVEL_FUNCTION( vkCreateSemaphore )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDevice ) VK_DEVICE_LEVEL_FUNCTION( vkCreateCommandPool )
VK_DEVICE_LEVEL_FUNCTION( vkAllocateCommandBuffers )
// Tutorial 02 VK_DEVICE_LEVEL_FUNCTION( vkBeginCommandBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkCreateSemaphore ) VK_DEVICE_LEVEL_FUNCTION( vkCmdPipelineBarrier )
VK_DEVICE_LEVEL_FUNCTION( vkCreateCommandPool ) VK_DEVICE_LEVEL_FUNCTION( vkCmdClearColorImage )
VK_DEVICE_LEVEL_FUNCTION( vkAllocateCommandBuffers ) VK_DEVICE_LEVEL_FUNCTION( vkEndCommandBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkBeginCommandBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkQueueSubmit )
VK_DEVICE_LEVEL_FUNCTION( vkCmdPipelineBarrier ) VK_DEVICE_LEVEL_FUNCTION( vkFreeCommandBuffers )
VK_DEVICE_LEVEL_FUNCTION( vkCmdClearColorImage ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyCommandPool )
VK_DEVICE_LEVEL_FUNCTION( vkEndCommandBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkDestroySemaphore )
VK_DEVICE_LEVEL_FUNCTION( vkQueueSubmit ) #if defined(USE_SWAPCHAIN_EXTENSIONS)
VK_DEVICE_LEVEL_FUNCTION( vkFreeCommandBuffers ) VK_DEVICE_LEVEL_FUNCTION( vkCreateSwapchainKHR )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyCommandPool ) VK_DEVICE_LEVEL_FUNCTION( vkGetSwapchainImagesKHR )
VK_DEVICE_LEVEL_FUNCTION( vkDestroySemaphore ) VK_DEVICE_LEVEL_FUNCTION( vkAcquireNextImageKHR )
#if defined(USE_SWAPCHAIN_EXTENSIONS) VK_DEVICE_LEVEL_FUNCTION( vkQueuePresentKHR )
VK_DEVICE_LEVEL_FUNCTION( vkCreateSwapchainKHR ) VK_DEVICE_LEVEL_FUNCTION( vkDestroySwapchainKHR )
VK_DEVICE_LEVEL_FUNCTION( vkGetSwapchainImagesKHR ) #endif
VK_DEVICE_LEVEL_FUNCTION( vkAcquireNextImageKHR )
VK_DEVICE_LEVEL_FUNCTION( vkQueuePresentKHR ) // Tutorial 03
VK_DEVICE_LEVEL_FUNCTION( vkDestroySwapchainKHR ) VK_DEVICE_LEVEL_FUNCTION( vkCreateImageView )
#endif VK_DEVICE_LEVEL_FUNCTION( vkCreateRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkCreateFramebuffer )
// Tutorial 03 VK_DEVICE_LEVEL_FUNCTION( vkCreateShaderModule )
VK_DEVICE_LEVEL_FUNCTION( vkCreateImageView ) VK_DEVICE_LEVEL_FUNCTION( vkCreatePipelineLayout )
VK_DEVICE_LEVEL_FUNCTION( vkCreateRenderPass ) VK_DEVICE_LEVEL_FUNCTION( vkCreateGraphicsPipelines )
VK_DEVICE_LEVEL_FUNCTION( vkCreateFramebuffer ) VK_DEVICE_LEVEL_FUNCTION( vkCmdBeginRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkCreateShaderModule ) VK_DEVICE_LEVEL_FUNCTION( vkCmdBindPipeline )
VK_DEVICE_LEVEL_FUNCTION( vkCreatePipelineLayout ) VK_DEVICE_LEVEL_FUNCTION( vkCmdDraw )
VK_DEVICE_LEVEL_FUNCTION( vkCreateGraphicsPipelines ) VK_DEVICE_LEVEL_FUNCTION( vkCmdEndRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBeginRenderPass ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyShaderModule )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindPipeline ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipelineLayout )
VK_DEVICE_LEVEL_FUNCTION( vkCmdDraw ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipeline )
VK_DEVICE_LEVEL_FUNCTION( vkCmdEndRenderPass ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyRenderPass )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyShaderModule ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyFramebuffer )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipelineLayout ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyImageView )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyPipeline )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyRenderPass ) // Tutorial 04
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFramebuffer ) VK_DEVICE_LEVEL_FUNCTION( vkCreateFence )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyImageView ) VK_DEVICE_LEVEL_FUNCTION( vkCreateBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkGetBufferMemoryRequirements )
// Tutorial 04 VK_DEVICE_LEVEL_FUNCTION( vkAllocateMemory )
VK_DEVICE_LEVEL_FUNCTION( vkCreateFence ) VK_DEVICE_LEVEL_FUNCTION( vkBindBufferMemory )
VK_DEVICE_LEVEL_FUNCTION( vkCreateBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkMapMemory )
VK_DEVICE_LEVEL_FUNCTION( vkGetBufferMemoryRequirements ) VK_DEVICE_LEVEL_FUNCTION( vkFlushMappedMemoryRanges )
VK_DEVICE_LEVEL_FUNCTION( vkAllocateMemory ) VK_DEVICE_LEVEL_FUNCTION( vkUnmapMemory )
VK_DEVICE_LEVEL_FUNCTION( vkBindBufferMemory ) VK_DEVICE_LEVEL_FUNCTION( vkCmdSetViewport )
VK_DEVICE_LEVEL_FUNCTION( vkMapMemory ) VK_DEVICE_LEVEL_FUNCTION( vkCmdSetScissor )
VK_DEVICE_LEVEL_FUNCTION( vkFlushMappedMemoryRanges ) VK_DEVICE_LEVEL_FUNCTION( vkCmdBindVertexBuffers )
VK_DEVICE_LEVEL_FUNCTION( vkUnmapMemory ) VK_DEVICE_LEVEL_FUNCTION( vkWaitForFences )
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetViewport ) VK_DEVICE_LEVEL_FUNCTION( vkResetFences )
VK_DEVICE_LEVEL_FUNCTION( vkCmdSetScissor ) VK_DEVICE_LEVEL_FUNCTION( vkFreeMemory )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindVertexBuffers ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkWaitForFences ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyFence )
VK_DEVICE_LEVEL_FUNCTION( vkResetFences )
VK_DEVICE_LEVEL_FUNCTION( vkFreeMemory ) // Tutorial 05
VK_DEVICE_LEVEL_FUNCTION( vkDestroyBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBuffer )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyFence )
// Tutorial 06
// Tutorial 05 VK_DEVICE_LEVEL_FUNCTION( vkCreateImage )
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBuffer ) VK_DEVICE_LEVEL_FUNCTION( vkGetImageMemoryRequirements )
VK_DEVICE_LEVEL_FUNCTION( vkBindImageMemory )
// Tutorial 06 VK_DEVICE_LEVEL_FUNCTION( vkCreateSampler )
VK_DEVICE_LEVEL_FUNCTION( vkCreateImage ) VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBufferToImage )
VK_DEVICE_LEVEL_FUNCTION( vkGetImageMemoryRequirements ) VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorSetLayout )
VK_DEVICE_LEVEL_FUNCTION( vkBindImageMemory ) VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorPool )
VK_DEVICE_LEVEL_FUNCTION( vkCreateSampler ) VK_DEVICE_LEVEL_FUNCTION( vkAllocateDescriptorSets )
VK_DEVICE_LEVEL_FUNCTION( vkCmdCopyBufferToImage ) VK_DEVICE_LEVEL_FUNCTION( vkUpdateDescriptorSets )
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorSetLayout ) VK_DEVICE_LEVEL_FUNCTION( vkCmdBindDescriptorSets )
VK_DEVICE_LEVEL_FUNCTION( vkCreateDescriptorPool ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorPool )
VK_DEVICE_LEVEL_FUNCTION( vkAllocateDescriptorSets ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorSetLayout )
VK_DEVICE_LEVEL_FUNCTION( vkUpdateDescriptorSets ) VK_DEVICE_LEVEL_FUNCTION( vkDestroySampler )
VK_DEVICE_LEVEL_FUNCTION( vkCmdBindDescriptorSets ) VK_DEVICE_LEVEL_FUNCTION( vkDestroyImage )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorPool )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyDescriptorSetLayout )
VK_DEVICE_LEVEL_FUNCTION( vkDestroySampler )
VK_DEVICE_LEVEL_FUNCTION( vkDestroyImage )
#undef VK_DEVICE_LEVEL_FUNCTION #undef VK_DEVICE_LEVEL_FUNCTION
+375 -379
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include <thread>
// Intel does not assume any responsibility for any errors which may appear in this software #include <chrono>
// nor any responsibility to update it. #include "OperatingSystem.h"
#include <thread> namespace ApiWithoutSecrets {
#include <chrono>
#include "OperatingSystem.h" namespace OS {
namespace ApiWithoutSecrets { Window::Window() :
Parameters() {
namespace OS { }
Window::Window() : WindowParameters Window::GetParameters() const {
Parameters() { return Parameters;
} }
WindowParameters Window::GetParameters() const { #if defined(VK_USE_PLATFORM_WIN32_KHR)
return Parameters;
} #define TUTORIAL_NAME "API without Secrets: Introduction to Vulkan"
#if defined(VK_USE_PLATFORM_WIN32_KHR) LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) {
switch( message ) {
#define TUTORIAL_NAME "API without Secrets: Introduction to Vulkan" case WM_SIZE:
case WM_EXITSIZEMOVE:
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { PostMessage( hWnd, WM_USER + 1, wParam, lParam );
switch( message ) { break;
case WM_SIZE: case WM_KEYDOWN:
case WM_EXITSIZEMOVE: case WM_CLOSE:
PostMessage( hWnd, WM_USER + 1, wParam, lParam ); PostMessage( hWnd, WM_USER + 2, wParam, lParam );
break; break;
case WM_KEYDOWN: default:
case WM_CLOSE: return DefWindowProc( hWnd, message, wParam, lParam );
PostMessage( hWnd, WM_USER + 2, wParam, lParam ); }
break; return 0;
default: }
return DefWindowProc( hWnd, message, wParam, lParam );
} Window::~Window() {
return 0; if( Parameters.Handle ) {
} DestroyWindow( Parameters.Handle );
}
Window::~Window() {
if( Parameters.Handle ) { if( Parameters.Instance ) {
DestroyWindow( Parameters.Handle ); UnregisterClass( TUTORIAL_NAME, Parameters.Instance );
} }
}
if( Parameters.Instance ) {
UnregisterClass( TUTORIAL_NAME, Parameters.Instance ); bool Window::Create( const char *title ) {
} Parameters.Instance = GetModuleHandle( nullptr );
}
// Register window class
bool Window::Create( const char *title ) { WNDCLASSEX wcex;
Parameters.Instance = GetModuleHandle( nullptr );
wcex.cbSize = sizeof(WNDCLASSEX);
// Register window class
WNDCLASSEX wcex; wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbSize = sizeof(WNDCLASSEX); wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.hInstance = Parameters.Instance;
wcex.lpfnWndProc = WndProc; wcex.hIcon = NULL;
wcex.cbClsExtra = 0; wcex.hCursor = LoadCursor( NULL, IDC_ARROW );
wcex.cbWndExtra = 0; wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.hInstance = Parameters.Instance; wcex.lpszMenuName = NULL;
wcex.hIcon = NULL; wcex.lpszClassName = TUTORIAL_NAME;
wcex.hCursor = LoadCursor( NULL, IDC_ARROW ); wcex.hIconSm = NULL;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL; if( !RegisterClassEx( &wcex ) ) {
wcex.lpszClassName = TUTORIAL_NAME; return false;
wcex.hIconSm = NULL; }
if( !RegisterClassEx( &wcex ) ) { // Create window
return false; Parameters.Handle = CreateWindow( TUTORIAL_NAME, title, WS_OVERLAPPEDWINDOW, 20, 20, 500, 500, nullptr, nullptr, Parameters.Instance, nullptr );
} if( !Parameters.Handle ) {
return false;
// Create window }
Parameters.Handle = CreateWindow( TUTORIAL_NAME, title, WS_OVERLAPPEDWINDOW, 20, 20, 500, 500, nullptr, nullptr, Parameters.Instance, nullptr );
if( !Parameters.Handle ) { return true;
return false; }
}
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
return true; // Display window
} ShowWindow( Parameters.Handle, SW_SHOWNORMAL );
UpdateWindow( Parameters.Handle );
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
// Display window // Main message loop
ShowWindow( Parameters.Handle, SW_SHOWNORMAL ); MSG message;
UpdateWindow( Parameters.Handle ); bool loop = true;
bool resize = false;
// Main message loop bool result = true;
MSG message;
bool loop = true; while( loop ) {
bool resize = false; if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) ) {
bool result = true; // Process events
switch( message.message ) {
while( loop ) { // Resize
if( PeekMessage( &message, NULL, 0, 0, PM_REMOVE ) ) { case WM_USER + 1:
// Process events resize = true;
switch( message.message ) { break;
// Resize // Close
case WM_USER + 1: case WM_USER + 2:
resize = true; loop = false;
break; break;
// Close }
case WM_USER + 2: TranslateMessage( &message );
loop = false; DispatchMessage( &message );
break; } else {
} // Draw
TranslateMessage( &message ); if( resize ) {
DispatchMessage( &message ); resize = false;
} else { if( !tutorial.OnWindowSizeChanged() ) {
// Draw result = false;
if( resize ) { break;
resize = false; }
if( !tutorial.OnWindowSizeChanged() ) { }
result = false; if( tutorial.ReadyToDraw() ) {
break; if( !tutorial.Draw() ) {
} result = false;
} break;
if( tutorial.ReadyToDraw() ) { }
if( !tutorial.Draw() ) { } else {
result = false; std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
break; }
} }
} else { }
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
} return result;
} }
}
#elif defined(VK_USE_PLATFORM_XCB_KHR)
return result;
} Window::~Window() {
xcb_destroy_window( Parameters.Connection, Parameters.Handle );
#elif defined(VK_USE_PLATFORM_XCB_KHR) xcb_disconnect( Parameters.Connection );
}
Window::~Window() {
xcb_destroy_window( Parameters.Connection, Parameters.Handle ); bool Window::Create( const char *title ) {
xcb_disconnect( Parameters.Connection ); int screen_index;
} Parameters.Connection = xcb_connect( nullptr, &screen_index );
bool Window::Create( const char *title ) { if( !Parameters.Connection ) {
int screen_index; return false;
Parameters.Connection = xcb_connect( nullptr, &screen_index ); }
if( !Parameters.Connection ) { const xcb_setup_t *setup = xcb_get_setup( Parameters.Connection );
return false; xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator( setup );
}
while( screen_index-- > 0 ) {
const xcb_setup_t *setup = xcb_get_setup( Parameters.Connection ); xcb_screen_next( &screen_iterator );
xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator( setup ); }
while( screen_index-- > 0 ) { xcb_screen_t *screen = screen_iterator.data;
xcb_screen_next( &screen_iterator );
} Parameters.Handle = xcb_generate_id( Parameters.Connection );
xcb_screen_t *screen = screen_iterator.data; uint32_t value_list[] = {
screen->white_pixel,
Parameters.Handle = xcb_generate_id( Parameters.Connection ); XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_STRUCTURE_NOTIFY
};
uint32_t value_list[] = {
screen->white_pixel, xcb_create_window(
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_STRUCTURE_NOTIFY Parameters.Connection,
}; XCB_COPY_FROM_PARENT,
Parameters.Handle,
xcb_create_window( screen->root,
Parameters.Connection, 20,
XCB_COPY_FROM_PARENT, 20,
Parameters.Handle, 500,
screen->root, 500,
20, 0,
20, XCB_WINDOW_CLASS_INPUT_OUTPUT,
500, screen->root_visual,
500, XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
0, value_list );
XCB_WINDOW_CLASS_INPUT_OUTPUT,
screen->root_visual, xcb_flush( Parameters.Connection );
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
value_list ); xcb_change_property(
Parameters.Connection,
xcb_flush( Parameters.Connection ); XCB_PROP_MODE_REPLACE,
Parameters.Handle,
xcb_change_property( XCB_ATOM_WM_NAME,
Parameters.Connection, XCB_ATOM_STRING,
XCB_PROP_MODE_REPLACE, 8,
Parameters.Handle, strlen( title ),
XCB_ATOM_WM_NAME, title );
XCB_ATOM_STRING,
8, return true;
strlen( title ), }
title );
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
return true; // Prepare notification for window destruction
} xcb_intern_atom_cookie_t protocols_cookie = xcb_intern_atom( Parameters.Connection, 1, 12, "WM_PROTOCOLS" );
xcb_intern_atom_reply_t *protocols_reply = xcb_intern_atom_reply( Parameters.Connection, protocols_cookie, 0 );
bool Window::RenderingLoop( TutorialBase &tutorial ) const { xcb_intern_atom_cookie_t delete_cookie = xcb_intern_atom( Parameters.Connection, 0, 16, "WM_DELETE_WINDOW" );
// Prepare notification for window destruction xcb_intern_atom_reply_t *delete_reply = xcb_intern_atom_reply( Parameters.Connection, delete_cookie, 0 );
xcb_intern_atom_cookie_t protocols_cookie = xcb_intern_atom( Parameters.Connection, 1, 12, "WM_PROTOCOLS" ); xcb_change_property( Parameters.Connection, XCB_PROP_MODE_REPLACE, Parameters.Handle, (*protocols_reply).atom, 4, 32, 1, &(*delete_reply).atom );
xcb_intern_atom_reply_t *protocols_reply = xcb_intern_atom_reply( Parameters.Connection, protocols_cookie, 0 ); free( protocols_reply );
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 ); // Display window
xcb_change_property( Parameters.Connection, XCB_PROP_MODE_REPLACE, Parameters.Handle, (*protocols_reply).atom, 4, 32, 1, &(*delete_reply).atom ); xcb_map_window( Parameters.Connection, Parameters.Handle );
free( protocols_reply ); xcb_flush( Parameters.Connection );
// Display window // Main message loop
xcb_map_window( Parameters.Connection, Parameters.Handle ); xcb_generic_event_t *event;
xcb_flush( Parameters.Connection ); bool loop = true;
bool resize = false;
// Main message loop bool result = true;
xcb_generic_event_t *event;
bool loop = true; while( loop ) {
bool resize = false; event = xcb_poll_for_event( Parameters.Connection );
bool result = true;
if( event ) {
while( loop ) { // Process events
event = xcb_poll_for_event( Parameters.Connection ); switch (event->response_type & 0x7f) {
// Resize
if( event ) { case XCB_CONFIGURE_NOTIFY: {
// Process events xcb_configure_notify_event_t *configure_event = (xcb_configure_notify_event_t*)event;
switch (event->response_type & 0x7f) { static uint16_t width = configure_event->width;
// Resize static uint16_t height = configure_event->height;
case XCB_CONFIGURE_NOTIFY: {
xcb_configure_notify_event_t *configure_event = (xcb_configure_notify_event_t*)event; if( ((configure_event->width > 0) && (width != configure_event->width)) ||
static uint16_t width = configure_event->width; ((configure_event->height > 0) && (height != configure_event->height)) ) {
static uint16_t height = configure_event->height; resize = true;
width = configure_event->width;
if( ((configure_event->width > 0) && (width != configure_event->width)) || height = configure_event->height;
((configure_event->height > 0) && (height != configure_event->height)) ) { }
resize = true; }
width = configure_event->width; break;
height = configure_event->height; // Close
} case XCB_CLIENT_MESSAGE:
} if( (*(xcb_client_message_event_t*)event).data.data32[0] == (*delete_reply).atom ) {
break; loop = false;
// Close free( delete_reply );
case XCB_CLIENT_MESSAGE: }
if( (*(xcb_client_message_event_t*)event).data.data32[0] == (*delete_reply).atom ) { break;
loop = false; case XCB_KEY_PRESS:
free( delete_reply ); loop = false;
} break;
break; }
case XCB_KEY_PRESS: free( event );
loop = false; } else {
break; // Draw
} if( resize ) {
free( event ); resize = false;
} else { if( !tutorial.OnWindowSizeChanged() ) {
// Draw result = false;
if( resize ) { break;
resize = false; }
if( !tutorial.OnWindowSizeChanged() ) { }
result = false; if( tutorial.ReadyToDraw() ) {
break; if( !tutorial.Draw() ) {
} result = false;
} break;
if( tutorial.ReadyToDraw() ) { }
if( !tutorial.Draw() ) { } else {
result = false; std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
break; }
} }
} else { }
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
} return result;
} }
}
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
return result;
} Window::~Window() {
XDestroyWindow( Parameters.DisplayPtr, Parameters.Handle );
#elif defined(VK_USE_PLATFORM_XLIB_KHR) XCloseDisplay( Parameters.DisplayPtr );
}
Window::~Window() {
XDestroyWindow( Parameters.DisplayPtr, Parameters.Handle ); bool Window::Create( const char *title ) {
XCloseDisplay( Parameters.DisplayPtr ); Parameters.DisplayPtr = XOpenDisplay( nullptr );
} if( !Parameters.DisplayPtr ) {
return false;
bool Window::Create( const char *title ) { }
Parameters.DisplayPtr = XOpenDisplay( nullptr );
if( !Parameters.DisplayPtr ) { int default_screen = DefaultScreen( Parameters.DisplayPtr );
return false;
} Parameters.Handle = XCreateSimpleWindow(
Parameters.DisplayPtr,
int default_screen = DefaultScreen( Parameters.DisplayPtr ); DefaultRootWindow( Parameters.DisplayPtr ),
20,
Parameters.Handle = XCreateSimpleWindow( 20,
Parameters.DisplayPtr, 500,
DefaultRootWindow( Parameters.DisplayPtr ), 500,
20, 1,
20, BlackPixel( Parameters.DisplayPtr, default_screen ),
500, WhitePixel( Parameters.DisplayPtr, default_screen ) );
500,
1, // XSync( Parameters.DisplayPtr, false );
BlackPixel( Parameters.DisplayPtr, default_screen ), XSetStandardProperties( Parameters.DisplayPtr, Parameters.Handle, title, title, None, nullptr, 0, nullptr );
WhitePixel( Parameters.DisplayPtr, default_screen ) ); XSelectInput( Parameters.DisplayPtr, Parameters.Handle, ExposureMask | KeyPressMask | StructureNotifyMask );
// XSync( Parameters.DisplayPtr, false ); return true;
XSetStandardProperties( Parameters.DisplayPtr, Parameters.Handle, title, title, None, nullptr, 0, nullptr ); }
XSelectInput( Parameters.DisplayPtr, Parameters.Handle, ExposureMask | KeyPressMask | StructureNotifyMask );
bool Window::RenderingLoop( TutorialBase &tutorial ) const {
return true; // Prepare notification for window destruction
} Atom delete_window_atom;
delete_window_atom = XInternAtom( Parameters.DisplayPtr, "WM_DELETE_WINDOW", false );
bool Window::RenderingLoop( TutorialBase &tutorial ) const { XSetWMProtocols( Parameters.DisplayPtr, Parameters.Handle, &delete_window_atom, 1);
// Prepare notification for window destruction
Atom delete_window_atom; // Display window
delete_window_atom = XInternAtom( Parameters.DisplayPtr, "WM_DELETE_WINDOW", false ); XClearWindow( Parameters.DisplayPtr, Parameters.Handle );
XSetWMProtocols( Parameters.DisplayPtr, Parameters.Handle, &delete_window_atom, 1); XMapWindow( Parameters.DisplayPtr, Parameters.Handle );
// Display window // Main message loop
XClearWindow( Parameters.DisplayPtr, Parameters.Handle ); XEvent event;
XMapWindow( Parameters.DisplayPtr, Parameters.Handle ); bool loop = true;
bool resize = false;
// Main message loop bool result = true;
XEvent event;
bool loop = true; while( loop ) {
bool resize = false; if( XPending( Parameters.DisplayPtr ) ) {
bool result = true; XNextEvent( Parameters.DisplayPtr, &event );
switch( event.type ) {
while( loop ) { //Process events
if( XPending( Parameters.DisplayPtr ) ) { case ConfigureNotify: {
XNextEvent( Parameters.DisplayPtr, &event ); static int width = event.xconfigure.width;
switch( event.type ) { static int height = event.xconfigure.height;
//Process events
case ConfigureNotify: { if( ((event.xconfigure.width > 0) && (event.xconfigure.width != width)) ||
static int width = event.xconfigure.width; ((event.xconfigure.height > 0) && (event.xconfigure.width != height)) ) {
static int height = event.xconfigure.height; width = event.xconfigure.width;
height = event.xconfigure.height;
if( ((event.xconfigure.width > 0) && (event.xconfigure.width != width)) || resize = true;
((event.xconfigure.height > 0) && (event.xconfigure.width != height)) ) { }
width = event.xconfigure.width; }
height = event.xconfigure.height; break;
resize = true; case KeyPress:
} loop = false;
} break;
break; case DestroyNotify:
case KeyPress: loop = false;
loop = false; break;
break; case ClientMessage:
case DestroyNotify: if( static_cast<unsigned int>(event.xclient.data.l[0]) == delete_window_atom ) {
loop = false; loop = false;
break; }
case ClientMessage: break;
if( static_cast<unsigned int>(event.xclient.data.l[0]) == delete_window_atom ) { }
loop = false; } else {
} // Draw
break; if( resize ) {
} resize = false;
} else { if( !tutorial.OnWindowSizeChanged() ) {
// Draw result = false;
if( resize ) { break;
resize = false; }
if( !tutorial.OnWindowSizeChanged() ) { }
result = false; if( tutorial.ReadyToDraw() ) {
break; if( !tutorial.Draw() ) {
} result = false;
} break;
if( tutorial.ReadyToDraw() ) { }
if( !tutorial.Draw() ) { } else {
result = false; std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
break; }
} }
} else { }
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
} return result;
} }
}
#endif
return result;
} } // namespace OS
#endif } // namespace ApiWithoutSecrets
} // namespace OS
} // namespace ApiWithoutSecrets
+129 -133
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(OPERATING_SYSTEM_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define OPERATING_SYSTEM_HEADER
// nor any responsibility to update it.
#if defined(VK_USE_PLATFORM_WIN32_KHR)
#if !defined(OPERATING_SYSTEM_HEADER) #include <Windows.h>
#define OPERATING_SYSTEM_HEADER
#elif defined(VK_USE_PLATFORM_XCB_KHR)
#if defined(VK_USE_PLATFORM_WIN32_KHR) #include <xcb/xcb.h>
#include <Windows.h> #include <dlfcn.h>
#include <cstdlib>
#elif defined(VK_USE_PLATFORM_XCB_KHR)
#include <xcb/xcb.h> #elif defined(VK_USE_PLATFORM_XLIB_KHR)
#include <dlfcn.h> #include <X11/Xlib.h>
#include <cstdlib> #include <X11/Xutil.h>
#include <dlfcn.h>
#elif defined(VK_USE_PLATFORM_XLIB_KHR) #include <cstdlib>
#include <X11/Xlib.h>
#include <X11/Xutil.h> #endif
#include <dlfcn.h>
#include <cstdlib> #include <cstring>
#include <iostream>
#endif
namespace ApiWithoutSecrets {
#include <cstring>
#include <iostream> namespace OS {
namespace ApiWithoutSecrets { // ************************************************************ //
// LibraryHandle //
namespace OS { // //
// Dynamic Library OS dependent type //
// ************************************************************ // // ************************************************************ //
// LibraryHandle // //
// // #if defined(VK_USE_PLATFORM_WIN32_KHR)
// Dynamic Library OS dependent type // typedef HMODULE LibraryHandle;
// ************************************************************ //
// #elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
#if defined(VK_USE_PLATFORM_WIN32_KHR) typedef void* LibraryHandle;
typedef HMODULE LibraryHandle;
#endif
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
typedef void* LibraryHandle; // ************************************************************ //
// OnWindowSizeChanged //
#endif // //
// Base class for handling window size changes //
// ************************************************************ // // ************************************************************ //
// OnWindowSizeChanged // class TutorialBase {
// // public:
// Base class for handling window size changes // virtual bool OnWindowSizeChanged() = 0;
// ************************************************************ // virtual bool Draw() = 0;
class TutorialBase {
public: virtual bool ReadyToDraw() const final {
virtual bool OnWindowSizeChanged() = 0; return CanRender;
virtual bool Draw() = 0; }
virtual bool ReadyToDraw() const final { TutorialBase() :
return CanRender; CanRender( false ) {
} }
TutorialBase() : virtual ~TutorialBase() {
CanRender( false ) { }
}
protected:
virtual ~TutorialBase() { bool CanRender;
} };
protected: // ************************************************************ //
bool CanRender; // WindowParameters //
}; // //
// OS dependent window parameters //
// ************************************************************ // // ************************************************************ //
// WindowParameters // struct WindowParameters {
// // #if defined(VK_USE_PLATFORM_WIN32_KHR)
// OS dependent window parameters // HINSTANCE Instance;
// ************************************************************ // HWND Handle;
struct WindowParameters {
#if defined(VK_USE_PLATFORM_WIN32_KHR) WindowParameters() :
HINSTANCE Instance; Instance(),
HWND Handle; Handle() {
}
WindowParameters() :
Instance(), #elif defined(VK_USE_PLATFORM_XCB_KHR)
Handle() { xcb_connection_t *Connection;
} xcb_window_t Handle;
#elif defined(VK_USE_PLATFORM_XCB_KHR) WindowParameters() :
xcb_connection_t *Connection; Connection(),
xcb_window_t Handle; Handle() {
}
WindowParameters() :
Connection(), #elif defined(VK_USE_PLATFORM_XLIB_KHR)
Handle() { Display *DisplayPtr;
} Window Handle;
#elif defined(VK_USE_PLATFORM_XLIB_KHR) WindowParameters() :
Display *DisplayPtr; DisplayPtr(),
Window Handle; Handle() {
}
WindowParameters() :
DisplayPtr(), #endif
Handle() { };
}
// ************************************************************ //
#endif // Window //
}; // //
// OS dependent window creation and destruction class //
// ************************************************************ // // ************************************************************ //
// Window // class Window {
// // public:
// OS dependent window creation and destruction class // Window();
// ************************************************************ // ~Window();
class Window {
public: bool Create( const char *title );
Window(); bool RenderingLoop( TutorialBase &tutorial ) const;
~Window(); WindowParameters GetParameters() const;
bool Create( const char *title ); private:
bool RenderingLoop( TutorialBase &tutorial ) const; WindowParameters Parameters;
WindowParameters GetParameters() const; };
private: } // namespace OS
WindowParameters Parameters;
}; } // namespace ApiWithoutSecrets
} // namespace OS
} // namespace ApiWithoutSecrets
#endif // OPERATING_SYSTEM_HEADER #endif // OPERATING_SYSTEM_HEADER
+147 -151
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include <cmath>
// Intel does not assume any responsibility for any errors which may appear in this software #include <fstream>
// nor any responsibility to update it. #include <iostream>
#include "Tools.h"
#include <cmath> #define STB_IMAGE_IMPLEMENTATION
#include <fstream> #include "stb_image.h"
#include <iostream>
#include "Tools.h" namespace ApiWithoutSecrets {
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" namespace Tools {
namespace ApiWithoutSecrets { // ************************************************************ //
// GetBinaryFileContents //
namespace Tools { // //
// Function reading binary contents of a file //
// ************************************************************ // // ************************************************************ //
// GetBinaryFileContents // std::vector<char> GetBinaryFileContents( std::string const &filename ) {
// //
// Function reading binary contents of a file // std::ifstream file( filename, std::ios::binary );
// ************************************************************ // if( file.fail() ) {
std::vector<char> GetBinaryFileContents( std::string const &filename ) { std::cout << "Could not open \"" << filename << "\" file!" << std::endl;
return std::vector<char>();
std::ifstream file( filename, std::ios::binary ); }
if( file.fail() ) {
std::cout << "Could not open \"" << filename << "\" file!" << std::endl; std::streampos begin, end;
return std::vector<char>(); begin = file.tellg();
} file.seekg( 0, std::ios::end );
end = file.tellg();
std::streampos begin, end;
begin = file.tellg(); std::vector<char> result( static_cast<size_t>(end - begin) );
file.seekg( 0, std::ios::end ); file.seekg( 0, std::ios::beg );
end = file.tellg(); file.read( &result[0], end - begin );
file.close();
std::vector<char> result( static_cast<size_t>(end - begin) );
file.seekg( 0, std::ios::beg ); return result;
file.read( &result[0], end - begin ); }
file.close();
// ************************************************************ //
return result; // GetImageData //
} // //
// Function loading image (texture) data from a specified file //
// ************************************************************ // // ************************************************************ //
// GetImageData // 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 );
// Function loading image (texture) data from a specified file // if( file_data.size() == 0 ) {
// ************************************************************ // return std::vector<char>();
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 ) { 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 tmp_width = 0, tmp_height = 0, tmp_components = 0; (tmp_height <= 0) ||
unsigned char *image_data = stbi_load_from_memory( reinterpret_cast<unsigned char*>(&file_data[0]), static_cast<int>(file_data.size()), &tmp_width, &tmp_height, &tmp_components, requested_components ); (tmp_components <= 0) ) {
if( (image_data == nullptr) || std::cout << "Could not read image data!" << std::endl;
(tmp_width <= 0) || return std::vector<char>();
(tmp_height <= 0) || }
(tmp_components <= 0) ) {
std::cout << "Could not read image data!" << std::endl; int size = (tmp_width) * (tmp_height) * (requested_components <= 0 ? tmp_components : requested_components);
return std::vector<char>(); if( data_size ) {
} *data_size = size;
}
int size = (tmp_width) * (tmp_height) * (requested_components <= 0 ? tmp_components : requested_components); if( width ) {
if( data_size ) { *width = tmp_width;
*data_size = size; }
} if( height ) {
if( width ) { *height = tmp_height;
*width = tmp_width; }
} if( components ) {
if( height ) { *components = tmp_components;
*height = tmp_height; }
}
if( components ) { std::vector<char> output(size);
*components = tmp_components; memcpy( &output[0], image_data, size );
}
stbi_image_free( image_data );
std::vector<char> output(size); return output;
memcpy( &output[0], image_data, size ); }
stbi_image_free( image_data ); // ************************************************************ //
return output; // GetPerspectiveProjectionMatrix //
} // //
// Function calculating perspective projection matrix //
// ************************************************************ // // ************************************************************ //
// GetPerspectiveProjectionMatrix // 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 );
// Function calculating perspective projection matrix //
// ************************************************************ // return {
std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip ) { f / aspect_ratio,
float f = 1.0f / std::tan( field_of_view * 0.5f * 0.01745329251994329576923690768489f ); 0.0f,
0.0f,
return { 0.0f,
f / aspect_ratio,
0.0f, 0.0f,
0.0f, f,
0.0f, 0.0f,
0.0f,
0.0f,
f, 0.0f,
0.0f, 0.0f,
0.0f, (near_clip + far_clip) / (near_clip - far_clip),
-1.0f,
0.0f,
0.0f, 0.0f,
(near_clip + far_clip) / (near_clip - far_clip), 0.0f,
-1.0f, (2.0f * near_clip * far_clip) / (near_clip - far_clip),
0.0f
0.0f, };
0.0f, }
(2.0f * near_clip * far_clip) / (near_clip - far_clip),
0.0f // ************************************************************ //
}; // GetOrthographicsProjectionMatrix //
} // //
// Function calculating orthographic projection matrix //
// ************************************************************ // // ************************************************************ //
// GetOrthographicsProjectionMatrix // 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 {
// Function calculating orthographic projection matrix // 2.0f / (right_plane - left_plane),
// ************************************************************ // 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 { 0.0f,
2.0f / (right_plane - left_plane),
0.0f, 0.0f,
0.0f, 2.0f / (bottom_plane - top_plane),
0.0f, 0.0f,
0.0f,
0.0f,
2.0f / (bottom_plane - top_plane), 0.0f,
0.0f, 0.0f,
0.0f, -2.0f / (far_plane - near_plane),
0.0f,
0.0f,
0.0f, -(right_plane + left_plane) / (right_plane - left_plane),
-2.0f / (far_plane - near_plane), -(bottom_plane + top_plane) / (bottom_plane - top_plane),
0.0f, -(far_plane + near_plane) / (far_plane - near_plane),
1.0f
-(right_plane + left_plane) / (right_plane - left_plane), };
-(bottom_plane + top_plane) / (bottom_plane - top_plane), }
-(far_plane + near_plane) / (far_plane - near_plane),
1.0f } // namespace Tools
};
}
} // namespace Tools
} // namespace ApiWithoutSecrets } // namespace ApiWithoutSecrets
+108 -112
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TOOLS_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TOOLS_HEADER
// nor any responsibility to update it.
#include <string>
#if !defined(TOOLS_HEADER) #include <vector>
#define TOOLS_HEADER #include <array>
#include "vulkan.h"
#include <string>
#include <vector> namespace ApiWithoutSecrets {
#include <array>
#include "vulkan.h" namespace Tools {
namespace ApiWithoutSecrets { // ************************************************************ //
// AutoDeleter //
namespace Tools { // //
// Auto-deleter helper template class responsible for calling //
// ************************************************************ // // provided function which deletes given object of type T //
// AutoDeleter // // ************************************************************ //
// // template<class T, class F>
// Auto-deleter helper template class responsible for calling // class AutoDeleter {
// provided function which deletes given object of type T // public:
// ************************************************************ // AutoDeleter() :
template<class T, class F> Object( VK_NULL_HANDLE ),
class AutoDeleter { Deleter( nullptr ),
public: Device( VK_NULL_HANDLE ) {
AutoDeleter() : }
Object( VK_NULL_HANDLE ),
Deleter( nullptr ), AutoDeleter( T object, F deleter, VkDevice device ) :
Device( VK_NULL_HANDLE ) { Object( object ),
} Deleter( deleter ),
Device( device ) {
AutoDeleter( T object, F deleter, VkDevice device ) : }
Object( object ),
Deleter( deleter ), AutoDeleter( AutoDeleter&& other ) {
Device( device ) { *this = std::move( other );
} }
AutoDeleter( AutoDeleter&& other ) { ~AutoDeleter() {
*this = std::move( other ); if( (Object != VK_NULL_HANDLE) && (Deleter != nullptr) && (Device != VK_NULL_HANDLE) ) {
} Deleter( Device, Object, nullptr );
}
~AutoDeleter() { }
if( (Object != VK_NULL_HANDLE) && (Deleter != nullptr) && (Device != VK_NULL_HANDLE) ) {
Deleter( Device, Object, nullptr ); AutoDeleter& operator=(AutoDeleter&& other) {
} if( this != &other ) {
} Object = other.Object;
Deleter = other.Deleter;
AutoDeleter& operator=(AutoDeleter&& other) { Device = other.Device;
if( this != &other ) { other.Object = VK_NULL_HANDLE;
Object = other.Object; }
Deleter = other.Deleter; return *this;
Device = other.Device; }
other.Object = VK_NULL_HANDLE;
} T Get() {
return *this; return Object;
} }
T Get() { bool operator !() const {
return Object; return Object == VK_NULL_HANDLE;
} }
bool operator !() const { private:
return Object == VK_NULL_HANDLE; AutoDeleter( const AutoDeleter& );
} AutoDeleter& operator=( const AutoDeleter& );
T Object;
private: F Deleter;
AutoDeleter( const AutoDeleter& ); VkDevice Device;
AutoDeleter& operator=( const AutoDeleter& ); };
T Object;
F Deleter; // ************************************************************ //
VkDevice Device; // GetBinaryFileContents //
}; // //
// Function reading binary contents of a file //
// ************************************************************ // // ************************************************************ //
// GetBinaryFileContents // std::vector<char> GetBinaryFileContents( std::string const &filename );
// //
// Function reading binary contents of a file // // ************************************************************ //
// ************************************************************ // // GetImageData //
std::vector<char> GetBinaryFileContents( std::string const &filename ); // //
// Function loading image (texture) data from a specified file //
// ************************************************************ // // ************************************************************ //
// GetImageData // std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size );
// //
// Function loading image (texture) data from a specified file // // ************************************************************ //
// ************************************************************ // // GetPerspectiveProjectionMatrix //
std::vector<char> GetImageData( std::string const &filename, int requested_components, int *width, int *height, int *components, int *data_size ); // //
// Function calculating perspective projection matrix //
// ************************************************************ // // ************************************************************ //
// GetPerspectiveProjectionMatrix // std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip );
// //
// Function calculating perspective projection matrix // // ************************************************************ //
// ************************************************************ // // GetOrthographicsProjectionMatrix //
std::array<float, 16> GetPerspectiveProjectionMatrix( float const aspect_ratio, float const field_of_view, float const near_clip, float const far_clip ); // //
// Function calculating orthographic projection matrix //
// ************************************************************ // // ************************************************************ //
// GetOrthographicsProjectionMatrix // 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 );
// //
// Function calculating orthographic projection matrix // } // namespace Tools
// ************************************************************ //
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 ApiWithoutSecrets
} // namespace Tools
} // namespace ApiWithoutSecrets
#endif // TOOLS_HEADER #endif // TOOLS_HEADER
File diff suppressed because it is too large Load Diff
+146 -150
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(VULKAN_COMMON_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define VULKAN_COMMON_HEADER
// nor any responsibility to update it.
#include <vector>
#if !defined(VULKAN_COMMON_HEADER) #include "vulkan.h"
#define VULKAN_COMMON_HEADER #include "OperatingSystem.h"
#include <vector> namespace ApiWithoutSecrets {
#include "vulkan.h"
#include "OperatingSystem.h" // ************************************************************ //
// QueueParameters //
namespace ApiWithoutSecrets { // //
// Vulkan Queue's parameters container class //
// ************************************************************ // // ************************************************************ //
// QueueParameters // struct QueueParameters {
// // VkQueue Handle;
// Vulkan Queue's parameters container class // uint32_t FamilyIndex;
// ************************************************************ //
struct QueueParameters { QueueParameters() :
VkQueue Handle; Handle( VK_NULL_HANDLE ),
uint32_t FamilyIndex; FamilyIndex( 0 ) {
}
QueueParameters() : };
Handle( VK_NULL_HANDLE ),
FamilyIndex( 0 ) { // ************************************************************ //
} // ImageParameters //
}; // //
// Vulkan Image's parameters container class //
// ************************************************************ // // ************************************************************ //
// ImageParameters // struct ImageParameters {
// // VkImage Handle;
// Vulkan Image's parameters container class // VkImageView View;
// ************************************************************ // VkSampler Sampler;
struct ImageParameters { VkDeviceMemory Memory;
VkImage Handle;
VkImageView View; ImageParameters() :
VkSampler Sampler; Handle( VK_NULL_HANDLE ),
VkDeviceMemory Memory; View( VK_NULL_HANDLE ),
Sampler( VK_NULL_HANDLE ),
ImageParameters() : Memory( VK_NULL_HANDLE ) {
Handle( VK_NULL_HANDLE ), }
View( VK_NULL_HANDLE ), };
Sampler( VK_NULL_HANDLE ),
Memory( VK_NULL_HANDLE ) { // ************************************************************ //
} // SwapChainParameters //
}; // //
// Vulkan SwapChain's parameters container class //
// ************************************************************ // // ************************************************************ //
// SwapChainParameters // struct SwapChainParameters {
// // VkSwapchainKHR Handle;
// Vulkan SwapChain's parameters container class // VkFormat Format;
// ************************************************************ // std::vector<ImageParameters> Images;
struct SwapChainParameters { VkExtent2D Extent;
VkSwapchainKHR Handle;
VkFormat Format; SwapChainParameters() :
std::vector<ImageParameters> Images; Handle( VK_NULL_HANDLE ),
VkExtent2D Extent; Format( VK_FORMAT_UNDEFINED ),
Images(),
SwapChainParameters() : Extent() {
Handle( VK_NULL_HANDLE ), }
Format( VK_FORMAT_UNDEFINED ), };
Images(),
Extent() { // ************************************************************ //
} // VulkanCommonParameters //
}; // //
// General Vulkan parameters' container class //
// ************************************************************ // // ************************************************************ //
// VulkanCommonParameters // struct VulkanCommonParameters {
// // VkInstance Instance;
// General Vulkan parameters' container class // VkPhysicalDevice PhysicalDevice;
// ************************************************************ // VkDevice Device;
struct VulkanCommonParameters { QueueParameters GraphicsQueue;
VkInstance Instance; QueueParameters PresentQueue;
VkPhysicalDevice PhysicalDevice; VkSurfaceKHR PresentationSurface;
VkDevice Device; SwapChainParameters SwapChain;
QueueParameters GraphicsQueue;
QueueParameters PresentQueue; VulkanCommonParameters() :
VkSurfaceKHR PresentationSurface; Instance( VK_NULL_HANDLE ),
SwapChainParameters SwapChain; PhysicalDevice( VK_NULL_HANDLE ),
Device( VK_NULL_HANDLE ),
VulkanCommonParameters() : GraphicsQueue(),
Instance( VK_NULL_HANDLE ), PresentQueue(),
PhysicalDevice( VK_NULL_HANDLE ), PresentationSurface( VK_NULL_HANDLE ),
Device( VK_NULL_HANDLE ), SwapChain() {
GraphicsQueue(), }
PresentQueue(), };
PresentationSurface( VK_NULL_HANDLE ),
SwapChain() { // ************************************************************ //
} // VulkanCommon //
}; // //
// Base class for Vulkan more advanced tutorial classes //
// ************************************************************ // // ************************************************************ //
// VulkanCommon // class VulkanCommon : public OS::TutorialBase {
// // public:
// Base class for Vulkan more advanced tutorial classes // VulkanCommon();
// ************************************************************ // virtual ~VulkanCommon();
class VulkanCommon : public OS::TutorialBase {
public: bool PrepareVulkan( OS::WindowParameters parameters );
VulkanCommon(); virtual bool OnWindowSizeChanged() final override;
virtual ~VulkanCommon();
protected:
bool PrepareVulkan( OS::WindowParameters parameters ); VkPhysicalDevice GetPhysicalDevice() const;
virtual bool OnWindowSizeChanged() final override; VkDevice GetDevice() const;
protected: const QueueParameters GetGraphicsQueue() const;
VkPhysicalDevice GetPhysicalDevice() const; const QueueParameters GetPresentQueue() const;
VkDevice GetDevice() const;
const SwapChainParameters GetSwapChain() const;
const QueueParameters GetGraphicsQueue() const;
const QueueParameters GetPresentQueue() const; private:
OS::LibraryHandle VulkanLibrary;
const SwapChainParameters GetSwapChain() const; OS::WindowParameters Window;
VulkanCommonParameters Vulkan;
private:
OS::LibraryHandle VulkanLibrary; bool LoadVulkanLibrary();
OS::WindowParameters Window; bool LoadExportedEntryPoints();
VulkanCommonParameters Vulkan; bool LoadGlobalLevelEntryPoints();
bool CreateInstance();
bool LoadVulkanLibrary(); bool LoadInstanceLevelEntryPoints();
bool LoadExportedEntryPoints(); bool CreatePresentationSurface();
bool LoadGlobalLevelEntryPoints(); bool CreateDevice();
bool CreateInstance(); bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
bool LoadInstanceLevelEntryPoints(); bool LoadDeviceLevelEntryPoints();
bool CreatePresentationSurface(); bool GetDeviceQueue();
bool CreateDevice(); bool CreateSwapChain();
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index ); bool CreateSwapChainImageViews();
bool LoadDeviceLevelEntryPoints(); virtual bool ChildOnWindowSizeChanged() = 0;
bool GetDeviceQueue(); virtual void ChildClear() = 0;
bool CreateSwapChain();
bool CreateSwapChainImageViews(); bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
virtual bool ChildOnWindowSizeChanged() = 0; uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );
virtual void ChildClear() = 0; VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats );
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities );
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions ); VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities );
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities ); VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities );
VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats ); VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes );
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities ); };
VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities );
VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities ); } // namespace ApiWithoutSecrets
VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes );
};
} // namespace ApiWithoutSecrets
#endif // VULKAN_COMMON_HEADER #endif // VULKAN_COMMON_HEADER
+17 -21
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "vulkan.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. namespace ApiWithoutSecrets {
#include "vulkan.h" #define VK_EXPORTED_FUNCTION( fun ) PFN_##fun fun;
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) PFN_##fun fun;
namespace ApiWithoutSecrets { #define VK_INSTANCE_LEVEL_FUNCTION( fun ) PFN_##fun fun;
#define VK_DEVICE_LEVEL_FUNCTION( fun ) PFN_##fun fun;
#define VK_EXPORTED_FUNCTION( fun ) PFN_##fun fun;
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) PFN_##fun fun; #include "ListOfFunctions.inl"
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) PFN_##fun fun;
#define VK_DEVICE_LEVEL_FUNCTION( fun ) PFN_##fun fun;
#include "ListOfFunctions.inl"
} // namespace ApiWithoutSecrets } // namespace ApiWithoutSecrets
+22 -26
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(VULKAN_FUNCTIONS_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define VULKAN_FUNCTIONS_HEADER
// nor any responsibility to update it.
#include "vulkan.h"
#if !defined(VULKAN_FUNCTIONS_HEADER)
#define VULKAN_FUNCTIONS_HEADER namespace ApiWithoutSecrets {
#include "vulkan.h" #define VK_EXPORTED_FUNCTION( fun ) extern PFN_##fun fun;
#define VK_GLOBAL_LEVEL_FUNCTION( fun) extern PFN_##fun fun;
namespace ApiWithoutSecrets { #define VK_INSTANCE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun;
#define VK_DEVICE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun;
#define VK_EXPORTED_FUNCTION( fun ) extern PFN_##fun fun;
#define VK_GLOBAL_LEVEL_FUNCTION( fun) extern PFN_##fun fun; #include "ListOfFunctions.inl"
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun;
#define VK_DEVICE_LEVEL_FUNCTION( fun ) extern PFN_##fun fun; } // namespace ApiWithoutSecrets
#include "ListOfFunctions.inl"
} // namespace ApiWithoutSecrets
#endif #endif
+271 -275
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include <vector>
// Intel does not assume any responsibility for any errors which may appear in this software #include "Tutorial01.h"
// nor any responsibility to update it. #include "VulkanFunctions.h"
#include <vector> namespace ApiWithoutSecrets {
#include "Tutorial01.h"
#include "VulkanFunctions.h" Tutorial01::Tutorial01() :
VulkanLibrary(),
namespace ApiWithoutSecrets { Vulkan() {
}
Tutorial01::Tutorial01() :
VulkanLibrary(), bool Tutorial01::OnWindowSizeChanged() {
Vulkan() { return true;
} }
bool Tutorial01::OnWindowSizeChanged() { bool Tutorial01::Draw() {
return true; return true;
} }
bool Tutorial01::Draw() { bool Tutorial01::PrepareVulkan() {
return true; if( !LoadVulkanLibrary() ) {
} return false;
}
bool Tutorial01::PrepareVulkan() { if( !LoadExportedEntryPoints() ) {
if( !LoadVulkanLibrary() ) { return false;
return false; }
} if( !LoadGlobalLevelEntryPoints() ) {
if( !LoadExportedEntryPoints() ) { return false;
return false; }
} if( !CreateInstance() ) {
if( !LoadGlobalLevelEntryPoints() ) { return false;
return false; }
} if( !LoadInstanceLevelEntryPoints() ) {
if( !CreateInstance() ) { return false;
return false; }
} if( !CreateDevice() ) {
if( !LoadInstanceLevelEntryPoints() ) { return false;
return false; }
} if( !LoadDeviceLevelEntryPoints() ) {
if( !CreateDevice() ) { return false;
return false; }
} if( !GetDeviceQueue() ) {
if( !LoadDeviceLevelEntryPoints() ) { return false;
return false; }
} return true;
if( !GetDeviceQueue() ) { }
return false;
} bool Tutorial01::LoadVulkanLibrary() {
return true; #if defined(VK_USE_PLATFORM_WIN32_KHR)
} VulkanLibrary = LoadLibrary( "vulkan-1.dll" );
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
bool Tutorial01::LoadVulkanLibrary() { VulkanLibrary = dlopen( "libvulkan.so.1", RTLD_NOW );
#if defined(VK_USE_PLATFORM_WIN32_KHR) #endif
VulkanLibrary = LoadLibrary( "vulkan-1.dll" );
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) if( VulkanLibrary == nullptr ) {
VulkanLibrary = dlopen( "libvulkan.so.1", RTLD_NOW ); std::cout << "Could not load Vulkan library!" << std::endl;
#endif return false;
}
if( VulkanLibrary == nullptr ) { return true;
std::cout << "Could not load Vulkan library!" << std::endl; }
return false;
} bool Tutorial01::LoadExportedEntryPoints() {
return true; #if defined(VK_USE_PLATFORM_WIN32_KHR)
} #define LoadProcAddress GetProcAddress
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
bool Tutorial01::LoadExportedEntryPoints() { #define LoadProcAddress dlsym
#if defined(VK_USE_PLATFORM_WIN32_KHR) #endif
#define LoadProcAddress GetProcAddress
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) #define VK_EXPORTED_FUNCTION( fun ) \
#define LoadProcAddress dlsym if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
#endif std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \
return false; \
#define VK_EXPORTED_FUNCTION( fun ) \ }
if( !(fun = (PFN_##fun)LoadProcAddress( VulkanLibrary, #fun )) ) { \
std::cout << "Could not load exported function: " << #fun << "!" << std::endl; \ #include "ListOfFunctions.inl"
return false; \
} return true;
}
#include "ListOfFunctions.inl"
bool Tutorial01::LoadGlobalLevelEntryPoints() {
return true; #define VK_GLOBAL_LEVEL_FUNCTION( fun ) \
} if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \
bool Tutorial01::LoadGlobalLevelEntryPoints() { return false; \
#define VK_GLOBAL_LEVEL_FUNCTION( fun ) \ }
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( nullptr, #fun )) ) { \
std::cout << "Could not load global level function: " << #fun << "!" << std::endl; \ #include "ListOfFunctions.inl"
return false; \
} return true;
}
#include "ListOfFunctions.inl"
bool Tutorial01::CreateInstance() {
return true; VkApplicationInfo application_info = {
} VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType
nullptr, // const void *pNext
bool Tutorial01::CreateInstance() { "API without Secrets: Introduction to Vulkan", // const char *pApplicationName
VkApplicationInfo application_info = { VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t applicationVersion
VK_STRUCTURE_TYPE_APPLICATION_INFO, // VkStructureType sType "Vulkan Tutorial by Intel", // const char *pEngineName
nullptr, // const void *pNext VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t engineVersion
"API without Secrets: Introduction to Vulkan", // const char *pApplicationName VK_MAKE_VERSION( 1, 0, 0 ) // uint32_t apiVersion
VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t applicationVersion };
"Vulkan Tutorial by Intel", // const char *pEngineName
VK_MAKE_VERSION( 1, 0, 0 ), // uint32_t engineVersion VkInstanceCreateInfo instance_create_info = {
VK_MAKE_VERSION( 1, 0, 0 ) // uint32_t apiVersion VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType
}; nullptr, // const void* pNext
0, // VkInstanceCreateFlags flags
VkInstanceCreateInfo instance_create_info = { &application_info, // const VkApplicationInfo *pApplicationInfo
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType 0, // uint32_t enabledLayerCount
nullptr, // const void* pNext nullptr, // const char * const *ppEnabledLayerNames
0, // VkInstanceCreateFlags flags 0, // uint32_t enabledExtensionCount
&application_info, // const VkApplicationInfo *pApplicationInfo nullptr // const char * const *ppEnabledExtensionNames
0, // uint32_t enabledLayerCount };
nullptr, // const char * const *ppEnabledLayerNames
0, // uint32_t enabledExtensionCount if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) {
nullptr // const char * const *ppEnabledExtensionNames std::cout << "Could not create Vulkan instance!" << std::endl;
}; return false;
}
if( vkCreateInstance( &instance_create_info, nullptr, &Vulkan.Instance ) != VK_SUCCESS ) { return true;
std::cout << "Could not create Vulkan instance!" << std::endl; }
return false;
} bool Tutorial01::LoadInstanceLevelEntryPoints() {
return true; #define VK_INSTANCE_LEVEL_FUNCTION( fun ) \
} if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \
bool Tutorial01::LoadInstanceLevelEntryPoints() { return false; \
#define VK_INSTANCE_LEVEL_FUNCTION( fun ) \ }
if( !(fun = (PFN_##fun)vkGetInstanceProcAddr( Vulkan.Instance, #fun )) ) { \
std::cout << "Could not load instance level function: " << #fun << "!" << std::endl; \ #include "ListOfFunctions.inl"
return false; \
} return true;
}
#include "ListOfFunctions.inl"
bool Tutorial01::CreateDevice() {
return true; uint32_t num_devices = 0;
} if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) ||
(num_devices == 0) ) {
bool Tutorial01::CreateDevice() { std::cout << "Error occurred during physical devices enumeration!" << std::endl;
uint32_t num_devices = 0; return false;
if( (vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, nullptr ) != VK_SUCCESS) || }
(num_devices == 0) ) {
std::cout << "Error occurred during physical devices enumeration!" << std::endl; std::vector<VkPhysicalDevice> physical_devices( num_devices );
return false; if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
} std::cout << "Error occurred during physical devices enumeration!" << std::endl;
return false;
std::vector<VkPhysicalDevice> physical_devices( num_devices ); }
if( vkEnumeratePhysicalDevices( Vulkan.Instance, &num_devices, &physical_devices[0] ) != VK_SUCCESS ) {
std::cout << "Error occurred during physical devices enumeration!" << std::endl; VkPhysicalDevice selected_physical_device = VK_NULL_HANDLE;
return false; uint32_t selected_queue_family_index = UINT32_MAX;
} for( uint32_t i = 0; i < num_devices; ++i ) {
if( CheckPhysicalDeviceProperties( physical_devices[i], selected_queue_family_index ) ) {
VkPhysicalDevice selected_physical_device = VK_NULL_HANDLE; selected_physical_device = physical_devices[i];
uint32_t selected_queue_family_index = UINT32_MAX; }
for( uint32_t i = 0; i < num_devices; ++i ) { }
if( CheckPhysicalDeviceProperties( physical_devices[i], selected_queue_family_index ) ) { if( selected_physical_device == VK_NULL_HANDLE ) {
selected_physical_device = physical_devices[i]; std::cout << "Could not select physical device based on the chosen properties!" << std::endl;
} return false;
} }
if( selected_physical_device == VK_NULL_HANDLE ) {
std::cout << "Could not select physical device based on the chosen properties!" << std::endl; std::vector<float> queue_priorities = { 1.0f };
return false;
} VkDeviceQueueCreateInfo queue_create_info = {
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType
std::vector<float> queue_priorities = { 1.0f }; nullptr, // const void *pNext
0, // VkDeviceQueueCreateFlags flags
VkDeviceQueueCreateInfo queue_create_info = { selected_queue_family_index, // uint32_t queueFamilyIndex
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType static_cast<uint32_t>(queue_priorities.size()), // uint32_t queueCount
nullptr, // const void *pNext &queue_priorities[0] // const float *pQueuePriorities
0, // VkDeviceQueueCreateFlags flags };
selected_queue_family_index, // uint32_t queueFamilyIndex
static_cast<uint32_t>(queue_priorities.size()), // uint32_t queueCount VkDeviceCreateInfo device_create_info = {
&queue_priorities[0] // const float *pQueuePriorities VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType
}; nullptr, // const void *pNext
0, // VkDeviceCreateFlags flags
VkDeviceCreateInfo device_create_info = { 1, // uint32_t queueCreateInfoCount
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // VkStructureType sType &queue_create_info, // const VkDeviceQueueCreateInfo *pQueueCreateInfos
nullptr, // const void *pNext 0, // uint32_t enabledLayerCount
0, // VkDeviceCreateFlags flags nullptr, // const char * const *ppEnabledLayerNames
1, // uint32_t queueCreateInfoCount 0, // uint32_t enabledExtensionCount
&queue_create_info, // const VkDeviceQueueCreateInfo *pQueueCreateInfos nullptr, // const char * const *ppEnabledExtensionNames
0, // uint32_t enabledLayerCount nullptr // const VkPhysicalDeviceFeatures *pEnabledFeatures
nullptr, // const char * const *ppEnabledLayerNames };
0, // uint32_t enabledExtensionCount
nullptr, // const char * const *ppEnabledExtensionNames if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
nullptr // const VkPhysicalDeviceFeatures *pEnabledFeatures std::cout << "Could not create Vulkan device!" << std::endl;
}; return false;
}
if( vkCreateDevice( selected_physical_device, &device_create_info, nullptr, &Vulkan.Device ) != VK_SUCCESS ) {
std::cout << "Could not create Vulkan device!" << std::endl; Vulkan.QueueFamilyIndex = selected_queue_family_index;
return false; return true;
} }
Vulkan.QueueFamilyIndex = selected_queue_family_index; bool Tutorial01::CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index ) {
return true; VkPhysicalDeviceProperties device_properties;
} VkPhysicalDeviceFeatures device_features;
bool Tutorial01::CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index ) { vkGetPhysicalDeviceProperties( physical_device, &device_properties );
VkPhysicalDeviceProperties device_properties; vkGetPhysicalDeviceFeatures( physical_device, &device_features );
VkPhysicalDeviceFeatures device_features;
uint32_t major_version = VK_VERSION_MAJOR( device_properties.apiVersion );
vkGetPhysicalDeviceProperties( physical_device, &device_properties ); uint32_t minor_version = VK_VERSION_MINOR( device_properties.apiVersion );
vkGetPhysicalDeviceFeatures( physical_device, &device_features ); uint32_t patch_version = VK_VERSION_PATCH( device_properties.apiVersion );
uint32_t major_version = VK_VERSION_MAJOR( device_properties.apiVersion ); if( (major_version < 1) ||
uint32_t minor_version = VK_VERSION_MINOR( device_properties.apiVersion ); (device_properties.limits.maxImageDimension2D < 4096) ) {
uint32_t patch_version = VK_VERSION_PATCH( device_properties.apiVersion ); std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl;
return false;
if( (major_version < 1) || }
(device_properties.limits.maxImageDimension2D < 4096) ) {
std::cout << "Physical device " << physical_device << " doesn't support required parameters!" << std::endl; uint32_t queue_families_count = 0;
return false; vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr );
} if( queue_families_count == 0 ) {
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl;
uint32_t queue_families_count = 0; return false;
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, nullptr ); }
if( queue_families_count == 0 ) {
std::cout << "Physical device " << physical_device << " doesn't have any queue families!" << std::endl; std::vector<VkQueueFamilyProperties> queue_family_properties( queue_families_count );
return false; 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::vector<VkQueueFamilyProperties> queue_family_properties( queue_families_count ); (queue_family_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) ) {
vkGetPhysicalDeviceQueueFamilyProperties( physical_device, &queue_families_count, &queue_family_properties[0] ); queue_family_index = i;
for( uint32_t i = 0; i < queue_families_count; ++i ) { return true;
if( (queue_family_properties[i].queueCount > 0) && }
(queue_family_properties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) ) { }
queue_family_index = i;
return true; std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl;
} return false;
} }
std::cout << "Could not find queue family with required properties on physical device " << physical_device << "!" << std::endl; bool Tutorial01::LoadDeviceLevelEntryPoints() {
return false; #define VK_DEVICE_LEVEL_FUNCTION( fun ) \
} if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \
bool Tutorial01::LoadDeviceLevelEntryPoints() { return false; \
#define VK_DEVICE_LEVEL_FUNCTION( fun ) \ }
if( !(fun = (PFN_##fun)vkGetDeviceProcAddr( Vulkan.Device, #fun )) ) { \
std::cout << "Could not load device level function: " << #fun << "!" << std::endl; \ #include "ListOfFunctions.inl"
return false; \
} return true;
}
#include "ListOfFunctions.inl"
bool Tutorial01::GetDeviceQueue() {
return true; vkGetDeviceQueue( Vulkan.Device, Vulkan.QueueFamilyIndex, 0, &Vulkan.Queue );
} return true;
}
bool Tutorial01::GetDeviceQueue() {
vkGetDeviceQueue( Vulkan.Device, Vulkan.QueueFamilyIndex, 0, &Vulkan.Queue ); Tutorial01::~Tutorial01() {
return true; if( Vulkan.Device != VK_NULL_HANDLE ) {
} vkDeviceWaitIdle( Vulkan.Device );
vkDestroyDevice( Vulkan.Device, nullptr );
Tutorial01::~Tutorial01() { }
if( Vulkan.Device != VK_NULL_HANDLE ) {
vkDeviceWaitIdle( Vulkan.Device ); if( Vulkan.Instance != VK_NULL_HANDLE ) {
vkDestroyDevice( Vulkan.Device, nullptr ); vkDestroyInstance( Vulkan.Instance, nullptr );
} }
if( Vulkan.Instance != VK_NULL_HANDLE ) { if( VulkanLibrary ) {
vkDestroyInstance( Vulkan.Instance, nullptr ); #if defined(VK_USE_PLATFORM_WIN32_KHR)
} FreeLibrary( VulkanLibrary );
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
if( VulkanLibrary ) { dlclose( VulkanLibrary );
#if defined(VK_USE_PLATFORM_WIN32_KHR) #endif
FreeLibrary( VulkanLibrary ); }
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) }
dlclose( VulkanLibrary );
#endif
}
}
} // namespace ApiWithoutSecrets } // namespace ApiWithoutSecrets
+65 -69
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TUTORIAL_01_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TUTORIAL_01_HEADER
// nor any responsibility to update it.
#include "vulkan.h"
#if !defined(TUTORIAL_01_HEADER) #include "OperatingSystem.h"
#define TUTORIAL_01_HEADER
namespace ApiWithoutSecrets {
#include "vulkan.h"
#include "OperatingSystem.h" // ************************************************************ //
// VulkanTutorial01Parameters //
namespace ApiWithoutSecrets { // //
// Vulkan specific parameters //
// ************************************************************ // // ************************************************************ //
// VulkanTutorial01Parameters // struct VulkanTutorial01Parameters {
// // VkInstance Instance;
// Vulkan specific parameters // VkDevice Device;
// ************************************************************ // uint32_t QueueFamilyIndex;
struct VulkanTutorial01Parameters { VkQueue Queue;
VkInstance Instance;
VkDevice Device; VulkanTutorial01Parameters() :
uint32_t QueueFamilyIndex; Instance( VK_NULL_HANDLE ),
VkQueue Queue; Device( VK_NULL_HANDLE ),
QueueFamilyIndex( 0 ),
VulkanTutorial01Parameters() : Queue( VK_NULL_HANDLE ) {
Instance( VK_NULL_HANDLE ), }
Device( VK_NULL_HANDLE ), };
QueueFamilyIndex( 0 ),
Queue( VK_NULL_HANDLE ) { // ************************************************************ //
} // Tutorial01 //
}; // //
// Class for presenting Vulkan usage topics //
// ************************************************************ // // ************************************************************ //
// Tutorial01 // class Tutorial01 : public OS::TutorialBase {
// // public:
// Class for presenting Vulkan usage topics // Tutorial01();
// ************************************************************ // ~Tutorial01();
class Tutorial01 : public OS::TutorialBase {
public: bool OnWindowSizeChanged() override;
Tutorial01(); bool Draw() override;
~Tutorial01();
bool PrepareVulkan();
bool OnWindowSizeChanged() override;
bool Draw() override; private:
OS::LibraryHandle VulkanLibrary;
bool PrepareVulkan(); VulkanTutorial01Parameters Vulkan;
private: bool LoadVulkanLibrary();
OS::LibraryHandle VulkanLibrary; bool LoadExportedEntryPoints();
VulkanTutorial01Parameters Vulkan; bool LoadGlobalLevelEntryPoints();
bool CreateInstance();
bool LoadVulkanLibrary(); bool LoadInstanceLevelEntryPoints();
bool LoadExportedEntryPoints(); bool CreateDevice();
bool LoadGlobalLevelEntryPoints(); bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index );
bool CreateInstance(); bool LoadDeviceLevelEntryPoints();
bool LoadInstanceLevelEntryPoints(); bool GetDeviceQueue();
bool CreateDevice(); };
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &queue_family_index );
bool LoadDeviceLevelEntryPoints(); } // namespace ApiWithoutSecrets
bool GetDeviceQueue();
};
} // namespace ApiWithoutSecrets
#endif // TUTORIAL_01_HEADER #endif // TUTORIAL_01_HEADER
+29 -33
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "Tutorial01.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. int main( int argc, char **argv ) {
ApiWithoutSecrets::OS::Window window;
#include "Tutorial01.h" ApiWithoutSecrets::Tutorial01 tutorial01;
int main( int argc, char **argv ) { // Window creation
ApiWithoutSecrets::OS::Window window; if( !window.Create( "01 - The Beginning" ) ) {
ApiWithoutSecrets::Tutorial01 tutorial01; return -1;
}
// Window creation
if( !window.Create( "01 - The Beginning" ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial01.PrepareVulkan() ) {
} return -1;
}
// Vulkan preparations and initialization
if( !tutorial01.PrepareVulkan() ) { // Rendering loop
return -1; if( !window.RenderingLoop( tutorial01 ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial01 ) ) { return 0;
return -1; }
}
return 0;
}
File diff suppressed because it is too large Load Diff
+96 -100
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TUTORIAL_02_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TUTORIAL_02_HEADER
// nor any responsibility to update it.
#include <vector>
#if !defined(TUTORIAL_02_HEADER) #include "vulkan.h"
#define TUTORIAL_02_HEADER #include "OperatingSystem.h"
#include <vector> namespace ApiWithoutSecrets {
#include "vulkan.h"
#include "OperatingSystem.h" // ************************************************************ //
// VulkanTutorial02Parameters //
namespace ApiWithoutSecrets { // //
// Vulkan specific parameters //
// ************************************************************ // // ************************************************************ //
// VulkanTutorial02Parameters // struct VulkanTutorial02Parameters {
// // VkInstance Instance;
// Vulkan specific parameters // VkPhysicalDevice PhysicalDevice;
// ************************************************************ // VkDevice Device;
struct VulkanTutorial02Parameters { VkQueue GraphicsQueue;
VkInstance Instance; VkQueue PresentQueue;
VkPhysicalDevice PhysicalDevice; uint32_t GraphicsQueueFamilyIndex;
VkDevice Device; uint32_t PresentQueueFamilyIndex;
VkQueue GraphicsQueue; VkSurfaceKHR PresentationSurface;
VkQueue PresentQueue; VkSwapchainKHR SwapChain;
uint32_t GraphicsQueueFamilyIndex; std::vector<VkCommandBuffer> PresentQueueCmdBuffers;
uint32_t PresentQueueFamilyIndex; VkCommandPool PresentQueueCmdPool;
VkSurfaceKHR PresentationSurface; VkSemaphore ImageAvailableSemaphore;
VkSwapchainKHR SwapChain; VkSemaphore RenderingFinishedSemaphore;
std::vector<VkCommandBuffer> PresentQueueCmdBuffers;
VkCommandPool PresentQueueCmdPool; VulkanTutorial02Parameters() :
VkSemaphore ImageAvailableSemaphore; Instance( VK_NULL_HANDLE ),
VkSemaphore RenderingFinishedSemaphore; PhysicalDevice( VK_NULL_HANDLE ),
Device( VK_NULL_HANDLE ),
VulkanTutorial02Parameters() : GraphicsQueue( VK_NULL_HANDLE ),
Instance( VK_NULL_HANDLE ), PresentQueue( VK_NULL_HANDLE ),
PhysicalDevice( VK_NULL_HANDLE ), GraphicsQueueFamilyIndex( 0 ),
Device( VK_NULL_HANDLE ), PresentQueueFamilyIndex( 0 ),
GraphicsQueue( VK_NULL_HANDLE ), PresentationSurface( VK_NULL_HANDLE ),
PresentQueue( VK_NULL_HANDLE ), SwapChain( VK_NULL_HANDLE ),
GraphicsQueueFamilyIndex( 0 ), PresentQueueCmdBuffers( 0 ),
PresentQueueFamilyIndex( 0 ), PresentQueueCmdPool( VK_NULL_HANDLE ) {
PresentationSurface( VK_NULL_HANDLE ), }
SwapChain( VK_NULL_HANDLE ), };
PresentQueueCmdBuffers( 0 ),
PresentQueueCmdPool( VK_NULL_HANDLE ) { // ************************************************************ //
} // Tutorial02 //
}; // //
// Class for presenting Vulkan usage topics //
// ************************************************************ // // ************************************************************ //
// Tutorial02 // class Tutorial02 : public OS::TutorialBase {
// // public:
// Class for presenting Vulkan usage topics // Tutorial02();
// ************************************************************ // ~Tutorial02();
class Tutorial02 : public OS::TutorialBase {
public: bool PrepareVulkan( OS::WindowParameters parameters );
Tutorial02(); bool CreateSwapChain();
~Tutorial02(); bool OnWindowSizeChanged() override;
bool CreateCommandBuffers();
bool PrepareVulkan( OS::WindowParameters parameters ); bool Draw() override;
bool CreateSwapChain();
bool OnWindowSizeChanged() override; private:
bool CreateCommandBuffers(); OS::LibraryHandle VulkanLibrary;
bool Draw() override; OS::WindowParameters Window;
VulkanTutorial02Parameters Vulkan;
private:
OS::LibraryHandle VulkanLibrary; bool LoadVulkanLibrary();
OS::WindowParameters Window; bool LoadExportedEntryPoints();
VulkanTutorial02Parameters Vulkan; bool LoadGlobalLevelEntryPoints();
bool CreateInstance();
bool LoadVulkanLibrary(); bool LoadInstanceLevelEntryPoints();
bool LoadExportedEntryPoints(); bool CreatePresentationSurface();
bool LoadGlobalLevelEntryPoints(); bool CreateDevice();
bool CreateInstance(); bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index );
bool LoadInstanceLevelEntryPoints(); bool LoadDeviceLevelEntryPoints();
bool CreatePresentationSurface(); bool GetDeviceQueue();
bool CreateDevice(); bool CreateSemaphores();
bool CheckPhysicalDeviceProperties( VkPhysicalDevice physical_device, uint32_t &graphics_queue_family_index, uint32_t &present_queue_family_index ); bool RecordCommandBuffers();
bool LoadDeviceLevelEntryPoints(); void Clear();
bool GetDeviceQueue();
bool CreateSemaphores(); bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions );
bool RecordCommandBuffers(); uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities );
void Clear(); VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats );
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities );
bool CheckExtensionAvailability( const char *extension_name, const std::vector<VkExtensionProperties> &available_extensions ); VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities );
uint32_t GetSwapChainNumImages( VkSurfaceCapabilitiesKHR &surface_capabilities ); VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities );
VkSurfaceFormatKHR GetSwapChainFormat( std::vector<VkSurfaceFormatKHR> &surface_formats ); VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes );
VkExtent2D GetSwapChainExtent( VkSurfaceCapabilitiesKHR &surface_capabilities ); };
VkImageUsageFlags GetSwapChainUsageFlags( VkSurfaceCapabilitiesKHR &surface_capabilities );
VkSurfaceTransformFlagBitsKHR GetSwapChainTransform( VkSurfaceCapabilitiesKHR &surface_capabilities ); } // namespace ApiWithoutSecrets
VkPresentModeKHR GetSwapChainPresentMode( std::vector<VkPresentModeKHR> &present_modes );
};
} // namespace ApiWithoutSecrets
#endif // TUTORIAL_02_HEADER #endif // TUTORIAL_02_HEADER
+35 -39
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "Tutorial02.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. int main( int argc, char **argv ) {
ApiWithoutSecrets::OS::Window window;
#include "Tutorial02.h" ApiWithoutSecrets::Tutorial02 tutorial02;
int main( int argc, char **argv ) { // Window creation
ApiWithoutSecrets::OS::Window window; if( !window.Create( "02 - Swap chain" ) ) {
ApiWithoutSecrets::Tutorial02 tutorial02; return -1;
}
// Window creation
if( !window.Create( "02 - Swap chain" ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial02.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
}
// Vulkan preparations and initialization if( !tutorial02.CreateSwapChain() ) {
if( !tutorial02.PrepareVulkan( window.GetParameters() ) ) { return -1;
return -1; }
} if( !tutorial02.CreateCommandBuffers() ) {
if( !tutorial02.CreateSwapChain() ) { return -1;
return -1; }
}
if( !tutorial02.CreateCommandBuffers() ) { // Rendering loop
return -1; if( !window.RenderingLoop( tutorial02 ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial02 ) ) { return 0;
return -1; }
}
return 0;
}
File diff suppressed because it is too large Load Diff
+72 -76
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TUTORIAL_03_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TUTORIAL_03_HEADER
// nor any responsibility to update it.
#include "VulkanCommon.h"
#if !defined(TUTORIAL_03_HEADER) #include "Tools.h"
#define TUTORIAL_03_HEADER
namespace ApiWithoutSecrets {
#include "VulkanCommon.h"
#include "Tools.h" // ************************************************************ //
// VulkanTutorial03Parameters //
namespace ApiWithoutSecrets { // //
// Vulkan specific parameters //
// ************************************************************ // // ************************************************************ //
// VulkanTutorial03Parameters // struct VulkanTutorial03Parameters {
// // VkRenderPass RenderPass;
// Vulkan specific parameters // std::vector<VkFramebuffer> Framebuffers;
// ************************************************************ // VkPipeline GraphicsPipeline;
struct VulkanTutorial03Parameters { VkSemaphore ImageAvailableSemaphore;
VkRenderPass RenderPass; VkSemaphore RenderingFinishedSemaphore;
std::vector<VkFramebuffer> Framebuffers; VkCommandPool GraphicsCommandPool;
VkPipeline GraphicsPipeline; std::vector<VkCommandBuffer> GraphicsCommandBuffers;
VkSemaphore ImageAvailableSemaphore;
VkSemaphore RenderingFinishedSemaphore; VulkanTutorial03Parameters() :
VkCommandPool GraphicsCommandPool; RenderPass( VK_NULL_HANDLE ),
std::vector<VkCommandBuffer> GraphicsCommandBuffers; Framebuffers(),
GraphicsCommandPool( VK_NULL_HANDLE ),
VulkanTutorial03Parameters() : GraphicsCommandBuffers(),
RenderPass( VK_NULL_HANDLE ), GraphicsPipeline( VK_NULL_HANDLE ),
Framebuffers(), ImageAvailableSemaphore( VK_NULL_HANDLE ),
GraphicsCommandPool( VK_NULL_HANDLE ), RenderingFinishedSemaphore( VK_NULL_HANDLE ) {
GraphicsCommandBuffers(), }
GraphicsPipeline( VK_NULL_HANDLE ), };
ImageAvailableSemaphore( VK_NULL_HANDLE ),
RenderingFinishedSemaphore( VK_NULL_HANDLE ) { // ************************************************************ //
} // Tutorial03 //
}; // //
// Class for presenting Vulkan usage topics //
// ************************************************************ // // ************************************************************ //
// Tutorial03 // class Tutorial03 : public VulkanCommon {
// // public:
// Class for presenting Vulkan usage topics // Tutorial03();
// ************************************************************ // ~Tutorial03();
class Tutorial03 : public VulkanCommon {
public: bool CreateRenderPass();
Tutorial03(); bool CreateFramebuffers();
~Tutorial03(); bool CreatePipeline();
bool CreateSemaphores();
bool CreateRenderPass(); bool CreateCommandBuffers();
bool CreateFramebuffers(); bool RecordCommandBuffers();
bool CreatePipeline();
bool CreateSemaphores(); bool Draw() override;
bool CreateCommandBuffers();
bool RecordCommandBuffers(); private:
VulkanTutorial03Parameters Vulkan;
bool Draw() override;
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
private: Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
VulkanTutorial03Parameters Vulkan; bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout(); void ChildClear() override;
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool ); bool ChildOnWindowSizeChanged() override;
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers ); };
void ChildClear() override; } // namespace ApiWithoutSecrets
bool ChildOnWindowSizeChanged() override;
};
} // namespace ApiWithoutSecrets
#endif // TUTORIAL_03_HEADER #endif // TUTORIAL_03_HEADER
+49 -53
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "Tutorial03.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. int main( int argc, char **argv ) {
ApiWithoutSecrets::OS::Window window;
#include "Tutorial03.h" ApiWithoutSecrets::Tutorial03 tutorial03;
int main( int argc, char **argv ) { // Window creation
ApiWithoutSecrets::OS::Window window; if( !window.Create( "03 - First Triangle" ) ) {
ApiWithoutSecrets::Tutorial03 tutorial03; return -1;
}
// Window creation
if( !window.Create( "03 - First Triangle" ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial03.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
}
// Vulkan preparations and initialization
if( !tutorial03.PrepareVulkan( window.GetParameters() ) ) { // Tutorial 03
return -1; if( !tutorial03.CreateRenderPass() ) {
} return -1;
}
// Tutorial 03 if( !tutorial03.CreateFramebuffers() ) {
if( !tutorial03.CreateRenderPass() ) { return -1;
return -1; }
} if( !tutorial03.CreatePipeline() ) {
if( !tutorial03.CreateFramebuffers() ) { return -1;
return -1; }
} if( !tutorial03.CreateSemaphores() ) {
if( !tutorial03.CreatePipeline() ) { return -1;
return -1; }
} if( !tutorial03.CreateCommandBuffers() ) {
if( !tutorial03.CreateSemaphores() ) { return -1;
return -1; }
} if( !tutorial03.RecordCommandBuffers() ) {
if( !tutorial03.CreateCommandBuffers() ) { return -1;
return -1; }
}
if( !tutorial03.RecordCommandBuffers() ) { // Rendering loop
return -1; if( !window.RenderingLoop( tutorial03 ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial03 ) ) { return 0;
return -1; }
}
return 0;
}
File diff suppressed because it is too large Load Diff
+122 -126
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TUTORIAL_04_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TUTORIAL_04_HEADER
// nor any responsibility to update it.
#include "VulkanCommon.h"
#if !defined(TUTORIAL_04_HEADER) #include "Tools.h"
#define TUTORIAL_04_HEADER
namespace ApiWithoutSecrets {
#include "VulkanCommon.h"
#include "Tools.h" // ************************************************************ //
// BufferParameters //
namespace ApiWithoutSecrets { // //
// Vulkan Buffer's parameters container class //
// ************************************************************ // // ************************************************************ //
// BufferParameters // struct BufferParameters {
// // VkBuffer Handle;
// Vulkan Buffer's parameters container class // VkDeviceMemory Memory;
// ************************************************************ // uint32_t Size;
struct BufferParameters {
VkBuffer Handle; BufferParameters() :
VkDeviceMemory Memory; Handle( VK_NULL_HANDLE ),
uint32_t Size; Memory( VK_NULL_HANDLE ),
Size( 0 ) {
BufferParameters() : }
Handle( VK_NULL_HANDLE ), };
Memory( VK_NULL_HANDLE ),
Size( 0 ) { // ************************************************************ //
} // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// VertexData // struct VertexData {
// // float x, y, z, w;
// Struct describing data type and format of vertex attributes // float r, g, b, a;
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float r, g, b, a; // RenderingResourcesData //
}; // //
// Struct containing data used during rendering process //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct RenderingResourcesData {
// // VkFramebuffer Framebuffer;
// Struct containing data used during rendering process // VkCommandBuffer CommandBuffer;
// ************************************************************ // VkSemaphore ImageAvailableSemaphore;
struct RenderingResourcesData { VkSemaphore FinishedRenderingSemaphore;
VkFramebuffer Framebuffer; VkFence Fence;
VkCommandBuffer CommandBuffer;
VkSemaphore ImageAvailableSemaphore; RenderingResourcesData() :
VkSemaphore FinishedRenderingSemaphore; Framebuffer( VK_NULL_HANDLE ),
VkFence Fence; CommandBuffer( VK_NULL_HANDLE ),
ImageAvailableSemaphore( VK_NULL_HANDLE ),
RenderingResourcesData() : FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Framebuffer( VK_NULL_HANDLE ), Fence( VK_NULL_HANDLE ) {
CommandBuffer( VK_NULL_HANDLE ), }
ImageAvailableSemaphore( VK_NULL_HANDLE ), };
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Fence( VK_NULL_HANDLE ) { // ************************************************************ //
} // VulkanTutorial04Parameters //
}; // //
// Vulkan specific parameters //
// ************************************************************ // // ************************************************************ //
// VulkanTutorial04Parameters // struct VulkanTutorial04Parameters {
// // VkRenderPass RenderPass;
// Vulkan specific parameters // VkPipeline GraphicsPipeline;
// ************************************************************ // BufferParameters VertexBuffer;
struct VulkanTutorial04Parameters { VkCommandPool CommandPool;
VkRenderPass RenderPass; std::vector<RenderingResourcesData> RenderingResources;
VkPipeline GraphicsPipeline;
BufferParameters VertexBuffer; static const size_t ResourcesCount = 3;
VkCommandPool CommandPool;
std::vector<RenderingResourcesData> RenderingResources; VulkanTutorial04Parameters() :
RenderPass( VK_NULL_HANDLE ),
static const size_t ResourcesCount = 3; GraphicsPipeline( VK_NULL_HANDLE ),
VertexBuffer(),
VulkanTutorial04Parameters() : CommandPool( VK_NULL_HANDLE ),
RenderPass( VK_NULL_HANDLE ), RenderingResources( ResourcesCount ) {
GraphicsPipeline( VK_NULL_HANDLE ), }
VertexBuffer(), };
CommandPool( VK_NULL_HANDLE ),
RenderingResources( ResourcesCount ) { // ************************************************************ //
} // Tutorial04 //
}; // //
// Class for presenting Vulkan usage topics //
// ************************************************************ // // ************************************************************ //
// Tutorial04 // class Tutorial04 : public VulkanCommon {
// // public:
// Class for presenting Vulkan usage topics // Tutorial04();
// ************************************************************ // ~Tutorial04();
class Tutorial04 : public VulkanCommon {
public: bool CreateRenderPass();
Tutorial04(); bool CreatePipeline();
~Tutorial04(); bool CreateVertexBuffer();
bool CreateRenderingResources();
bool CreateRenderPass();
bool CreatePipeline(); bool Draw() override;
bool CreateVertexBuffer();
bool CreateRenderingResources(); private:
VulkanTutorial04Parameters Vulkan;
bool Draw() override;
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
private: Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
VulkanTutorial04Parameters Vulkan; bool AllocateBufferMemory( VkBuffer buffer, VkDeviceMemory *memory );
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename ); bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout(); bool CreateCommandBuffers();
bool AllocateBufferMemory( VkBuffer buffer, VkDeviceMemory *memory ); bool CreateSemaphores();
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool ); bool CreateFences();
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers ); bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
bool CreateCommandBuffers(); bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
bool CreateSemaphores();
bool CreateFences(); void ChildClear() override;
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool ChildOnWindowSizeChanged() override;
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); };
void ChildClear() override; } // namespace ApiWithoutSecrets
bool ChildOnWindowSizeChanged() override;
};
} // namespace ApiWithoutSecrets
#endif // TUTORIAL_04_HEADER #endif // TUTORIAL_04_HEADER
+43 -47
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "Tutorial04.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. int main( int argc, char **argv ) {
ApiWithoutSecrets::OS::Window window;
#include "Tutorial04.h" ApiWithoutSecrets::Tutorial04 tutorial04;
int main( int argc, char **argv ) { // Window creation
ApiWithoutSecrets::OS::Window window; if( !window.Create( "04 - Vertex Attributes" ) ) {
ApiWithoutSecrets::Tutorial04 tutorial04; return -1;
}
// Window creation
if( !window.Create( "04 - Vertex Attributes" ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial04.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
}
// Vulkan preparations and initialization
if( !tutorial04.PrepareVulkan( window.GetParameters() ) ) { // Tutorial 04
return -1; if( !tutorial04.CreateRenderPass() ) {
} return -1;
}
// Tutorial 04 if( !tutorial04.CreatePipeline() ) {
if( !tutorial04.CreateRenderPass() ) { return -1;
return -1; }
} if( !tutorial04.CreateVertexBuffer() ) {
if( !tutorial04.CreatePipeline() ) { return -1;
return -1; }
} if( !tutorial04.CreateRenderingResources() ) {
if( !tutorial04.CreateVertexBuffer() ) { return -1;
return -1; }
}
if( !tutorial04.CreateRenderingResources() ) { // Rendering loop
return -1; if( !window.RenderingLoop( tutorial04 ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial04 ) ) { return 0;
return -1; }
}
return 0;
}
File diff suppressed because it is too large Load Diff
+128 -132
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TUTORIAL_05_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TUTORIAL_05_HEADER
// nor any responsibility to update it.
#include "VulkanCommon.h"
#if !defined(TUTORIAL_05_HEADER) #include "Tools.h"
#define TUTORIAL_05_HEADER
namespace ApiWithoutSecrets {
#include "VulkanCommon.h"
#include "Tools.h" // ************************************************************ //
// BufferParameters //
namespace ApiWithoutSecrets { // //
// Vulkan Buffer's parameters container class //
// ************************************************************ // // ************************************************************ //
// BufferParameters // struct BufferParameters {
// // VkBuffer Handle;
// Vulkan Buffer's parameters container class // VkDeviceMemory Memory;
// ************************************************************ // uint32_t Size;
struct BufferParameters {
VkBuffer Handle; BufferParameters() :
VkDeviceMemory Memory; Handle( VK_NULL_HANDLE ),
uint32_t Size; Memory( VK_NULL_HANDLE ),
Size( 0 ) {
BufferParameters() : }
Handle( VK_NULL_HANDLE ), };
Memory( VK_NULL_HANDLE ),
Size( 0 ) { // ************************************************************ //
} // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// VertexData // struct VertexData {
// // float x, y, z, w;
// Struct describing data type and format of vertex attributes // float r, g, b, a;
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float r, g, b, a; // RenderingResourcesData //
}; // //
// Struct containing data used during rendering process //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct RenderingResourcesData {
// // VkFramebuffer Framebuffer;
// Struct containing data used during rendering process // VkCommandBuffer CommandBuffer;
// ************************************************************ // VkSemaphore ImageAvailableSemaphore;
struct RenderingResourcesData { VkSemaphore FinishedRenderingSemaphore;
VkFramebuffer Framebuffer; VkFence Fence;
VkCommandBuffer CommandBuffer;
VkSemaphore ImageAvailableSemaphore; RenderingResourcesData() :
VkSemaphore FinishedRenderingSemaphore; Framebuffer( VK_NULL_HANDLE ),
VkFence Fence; CommandBuffer( VK_NULL_HANDLE ),
ImageAvailableSemaphore( VK_NULL_HANDLE ),
RenderingResourcesData() : FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Framebuffer( VK_NULL_HANDLE ), Fence( VK_NULL_HANDLE ) {
CommandBuffer( VK_NULL_HANDLE ), }
ImageAvailableSemaphore( VK_NULL_HANDLE ), };
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Fence( VK_NULL_HANDLE ) { // ************************************************************ //
} // VulkanTutorial04Parameters //
}; // //
// Vulkan specific parameters //
// ************************************************************ // // ************************************************************ //
// VulkanTutorial04Parameters // struct VulkanTutorial05Parameters {
// // VkRenderPass RenderPass;
// Vulkan specific parameters // VkPipeline GraphicsPipeline;
// ************************************************************ // BufferParameters VertexBuffer;
struct VulkanTutorial05Parameters { BufferParameters StagingBuffer;
VkRenderPass RenderPass; VkCommandPool CommandPool;
VkPipeline GraphicsPipeline; std::vector<RenderingResourcesData> RenderingResources;
BufferParameters VertexBuffer;
BufferParameters StagingBuffer; static const size_t ResourcesCount = 3;
VkCommandPool CommandPool;
std::vector<RenderingResourcesData> RenderingResources; VulkanTutorial05Parameters() :
RenderPass( VK_NULL_HANDLE ),
static const size_t ResourcesCount = 3; GraphicsPipeline( VK_NULL_HANDLE ),
VertexBuffer(),
VulkanTutorial05Parameters() : StagingBuffer(),
RenderPass( VK_NULL_HANDLE ), CommandPool( VK_NULL_HANDLE ),
GraphicsPipeline( VK_NULL_HANDLE ), RenderingResources( ResourcesCount ) {
VertexBuffer(), }
StagingBuffer(), };
CommandPool( VK_NULL_HANDLE ),
RenderingResources( ResourcesCount ) { // ************************************************************ //
} // Tutorial04 //
}; // //
// Class for presenting Vulkan usage topics //
// ************************************************************ // // ************************************************************ //
// Tutorial04 // class Tutorial05 : public VulkanCommon {
// // public:
// Class for presenting Vulkan usage topics // Tutorial05();
// ************************************************************ // ~Tutorial05();
class Tutorial05 : public VulkanCommon {
public: bool CreateRenderingResources();
Tutorial05(); bool CreateRenderPass();
~Tutorial05(); bool CreatePipeline();
bool CreateVertexBuffer();
bool CreateRenderingResources(); bool CreateStagingBuffer();
bool CreateRenderPass(); bool CopyVertexData();
bool CreatePipeline();
bool CreateVertexBuffer(); bool Draw() override;
bool CreateStagingBuffer();
bool CopyVertexData(); private:
VulkanTutorial05Parameters Vulkan;
bool Draw() override;
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool );
private: bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers );
VulkanTutorial05Parameters Vulkan; bool CreateSemaphore( VkSemaphore *semaphore );
bool CreateFence( VkFenceCreateFlags flags, VkFence *fence );
bool CreateCommandPool( uint32_t queue_family_index, VkCommandPool *pool ); Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
bool AllocateCommandBuffers( VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers ); Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout();
bool CreateSemaphore( VkSemaphore *semaphore ); bool CreateBuffer( VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer );
bool CreateFence( VkFenceCreateFlags flags, VkFence *fence ); bool AllocateBufferMemory( VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename ); const std::vector<float>& GetVertexData() const;
Tools::AutoDeleter<VkPipelineLayout, PFN_vkDestroyPipelineLayout> CreatePipelineLayout(); bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
bool CreateBuffer( VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer ); bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
bool AllocateBufferMemory( VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory ); void DestroyBuffer( BufferParameters& buffer );
const std::vector<float>& GetVertexData() const;
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); void ChildClear() override;
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); bool ChildOnWindowSizeChanged() override;
void DestroyBuffer( BufferParameters& buffer ); };
void ChildClear() override; } // namespace ApiWithoutSecrets
bool ChildOnWindowSizeChanged() override;
};
} // namespace ApiWithoutSecrets
#endif // TUTORIAL_05_HEADER #endif // TUTORIAL_05_HEADER
+49 -53
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "Tutorial05.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. int main( int argc, char **argv ) {
ApiWithoutSecrets::OS::Window window;
#include "Tutorial05.h" ApiWithoutSecrets::Tutorial05 tutorial05;
int main( int argc, char **argv ) { // Window creation
ApiWithoutSecrets::OS::Window window; if( !window.Create( "05 - Staging Resources" ) ) {
ApiWithoutSecrets::Tutorial05 tutorial05; return -1;
}
// Window creation
if( !window.Create( "05 - Staging Resources" ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial05.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
}
// Vulkan preparations and initialization
if( !tutorial05.PrepareVulkan( window.GetParameters() ) ) { // Tutorial 05
return -1; if( !tutorial05.CreateRenderingResources() ) {
} return -1;
}
// Tutorial 05 if( !tutorial05.CreateRenderPass() ) {
if( !tutorial05.CreateRenderingResources() ) { return -1;
return -1; }
} if( !tutorial05.CreatePipeline() ) {
if( !tutorial05.CreateRenderPass() ) { return -1;
return -1; }
} if( !tutorial05.CreateVertexBuffer() ) {
if( !tutorial05.CreatePipeline() ) { return -1;
return -1; }
} if( !tutorial05.CreateStagingBuffer() ) {
if( !tutorial05.CreateVertexBuffer() ) { return -1;
return -1; }
} if( !tutorial05.CopyVertexData() ) {
if( !tutorial05.CreateStagingBuffer() ) { return -1;
return -1; }
}
if( !tutorial05.CopyVertexData() ) { // Rendering loop
return -1; if( !window.RenderingLoop( tutorial05 ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial05 ) ) { return 0;
return -1; }
}
return 0;
}
File diff suppressed because it is too large Load Diff
+162 -166
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TUTORIAL_06_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TUTORIAL_06_HEADER
// nor any responsibility to update it.
#include "VulkanCommon.h"
#if !defined(TUTORIAL_06_HEADER) #include "Tools.h"
#define TUTORIAL_06_HEADER
namespace ApiWithoutSecrets {
#include "VulkanCommon.h"
#include "Tools.h" // ************************************************************ //
// BufferParameters //
namespace ApiWithoutSecrets { // //
// Vulkan Buffer's parameters container class //
// ************************************************************ // // ************************************************************ //
// BufferParameters // struct BufferParameters {
// // VkBuffer Handle;
// Vulkan Buffer's parameters container class // VkDeviceMemory Memory;
// ************************************************************ // uint32_t Size;
struct BufferParameters {
VkBuffer Handle; BufferParameters() :
VkDeviceMemory Memory; Handle( VK_NULL_HANDLE ),
uint32_t Size; Memory( VK_NULL_HANDLE ),
Size( 0 ) {
BufferParameters() : }
Handle( VK_NULL_HANDLE ), };
Memory( VK_NULL_HANDLE ),
Size( 0 ) { // ************************************************************ //
} // DescriptorParameters //
}; // //
// Container class for descriptor related resources //
// ************************************************************ // // ************************************************************ //
// DescriptorParameters // struct DescriptorSetParameters {
// // VkDescriptorPool Pool;
// Container class for descriptor related resources // VkDescriptorSetLayout Layout;
// ************************************************************ // VkDescriptorSet Handle;
struct DescriptorSetParameters {
VkDescriptorPool Pool; DescriptorSetParameters() :
VkDescriptorSetLayout Layout; Pool( VK_NULL_HANDLE ),
VkDescriptorSet Handle; Layout( VK_NULL_HANDLE ),
Handle( VK_NULL_HANDLE ) {
DescriptorSetParameters() : }
Pool( VK_NULL_HANDLE ), };
Layout( VK_NULL_HANDLE ),
Handle( VK_NULL_HANDLE ) { // ************************************************************ //
} // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// VertexData // struct VertexData {
// // float x, y, z, w;
// Struct describing data type and format of vertex attributes // float u, v;
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float u, v; // RenderingResourcesData //
}; // //
// Struct containing data used during rendering process //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct RenderingResourcesData {
// // VkFramebuffer Framebuffer;
// Struct containing data used during rendering process // VkCommandBuffer CommandBuffer;
// ************************************************************ // VkSemaphore ImageAvailableSemaphore;
struct RenderingResourcesData { VkSemaphore FinishedRenderingSemaphore;
VkFramebuffer Framebuffer; VkFence Fence;
VkCommandBuffer CommandBuffer;
VkSemaphore ImageAvailableSemaphore; RenderingResourcesData() :
VkSemaphore FinishedRenderingSemaphore; Framebuffer( VK_NULL_HANDLE ),
VkFence Fence; CommandBuffer( VK_NULL_HANDLE ),
ImageAvailableSemaphore( VK_NULL_HANDLE ),
RenderingResourcesData() : FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Framebuffer( VK_NULL_HANDLE ), Fence( VK_NULL_HANDLE ) {
CommandBuffer( VK_NULL_HANDLE ), }
ImageAvailableSemaphore( VK_NULL_HANDLE ), };
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Fence( VK_NULL_HANDLE ) { // ************************************************************ //
} // VulkanTutorial04Parameters //
}; // //
// Vulkan specific parameters //
// ************************************************************ // // ************************************************************ //
// VulkanTutorial04Parameters // struct VulkanTutorial06Parameters {
// // VkRenderPass RenderPass;
// Vulkan specific parameters // ImageParameters Image;
// ************************************************************ // DescriptorSetParameters DescriptorSet;
struct VulkanTutorial06Parameters { VkPipelineLayout PipelineLayout;
VkRenderPass RenderPass; VkPipeline GraphicsPipeline;
ImageParameters Image; BufferParameters VertexBuffer;
DescriptorSetParameters DescriptorSet; BufferParameters StagingBuffer;
VkPipelineLayout PipelineLayout; VkCommandPool CommandPool;
VkPipeline GraphicsPipeline; std::vector<RenderingResourcesData> RenderingResources;
BufferParameters VertexBuffer;
BufferParameters StagingBuffer; static const size_t ResourcesCount = 3;
VkCommandPool CommandPool;
std::vector<RenderingResourcesData> RenderingResources; VulkanTutorial06Parameters() :
RenderPass( VK_NULL_HANDLE ),
static const size_t ResourcesCount = 3; Image(),
DescriptorSet(),
VulkanTutorial06Parameters() : PipelineLayout(),
RenderPass( VK_NULL_HANDLE ), GraphicsPipeline( VK_NULL_HANDLE ),
Image(), VertexBuffer(),
DescriptorSet(), StagingBuffer(),
PipelineLayout(), CommandPool( VK_NULL_HANDLE ),
GraphicsPipeline( VK_NULL_HANDLE ), RenderingResources( ResourcesCount ) {
VertexBuffer(), }
StagingBuffer(), };
CommandPool( VK_NULL_HANDLE ),
RenderingResources( ResourcesCount ) { // ************************************************************ //
} // Tutorial04 //
}; // //
// Class for presenting Vulkan usage topics //
// ************************************************************ // // ************************************************************ //
// Tutorial04 // class Tutorial06 : public VulkanCommon {
// // public:
// Class for presenting Vulkan usage topics // Tutorial06();
// ************************************************************ // ~Tutorial06();
class Tutorial06 : public VulkanCommon {
public: bool CreateRenderingResources();
Tutorial06(); bool CreateStagingBuffer();
~Tutorial06(); bool CreateTexture();
bool CreateDescriptorSetLayout();
bool CreateRenderingResources(); bool CreateDescriptorPool();
bool CreateStagingBuffer(); bool AllocateDescriptorSet();
bool CreateTexture(); bool UpdateDescriptorSet();
bool CreateDescriptorSetLayout(); bool CreateRenderPass();
bool CreateDescriptorPool(); bool CreatePipelineLayout();
bool AllocateDescriptorSet(); bool CreatePipeline();
bool UpdateDescriptorSet(); bool CreateVertexBuffer();
bool CreateRenderPass();
bool CreatePipelineLayout(); bool Draw() override;
bool CreatePipeline();
bool CreateVertexBuffer(); private:
VulkanTutorial06Parameters Vulkan;
bool Draw() override;
bool CreateCommandBuffers();
private: bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
VulkanTutorial06Parameters Vulkan; bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
bool CreateSemaphores();
bool CreateCommandBuffers(); bool CreateFences();
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool); bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers); bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
bool CreateSemaphores(); bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
bool CreateFences(); bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer); bool CreateImageView( ImageParameters &image_parameters );
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory); bool CreateSampler( VkSampler *sampler );
bool CreateImage( uint32_t width, uint32_t height, VkImage *image ); bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory ); Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
bool CreateImageView( ImageParameters &image_parameters ); const std::vector<float>& GetVertexData() const;
bool CreateSampler( VkSampler *sampler ); bool CopyVertexData();
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height ); bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename ); bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
const std::vector<float>& GetVertexData() const; void DestroyBuffer( BufferParameters& buffer );
bool CopyVertexData();
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool ChildOnWindowSizeChanged() override;
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); void ChildClear() override;
void DestroyBuffer( BufferParameters& buffer ); };
bool ChildOnWindowSizeChanged() override; } // namespace ApiWithoutSecrets
void ChildClear() override;
};
} // namespace ApiWithoutSecrets
#endif // TUTORIAL_06_HEADER #endif // TUTORIAL_06_HEADER
+64 -68
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "Tutorial06.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. int main( int argc, char **argv ) {
ApiWithoutSecrets::OS::Window window;
#include "Tutorial06.h" ApiWithoutSecrets::Tutorial06 tutorial06;
int main( int argc, char **argv ) { // Window creation
ApiWithoutSecrets::OS::Window window; if( !window.Create( "06 - Descriptor Sets" ) ) {
ApiWithoutSecrets::Tutorial06 tutorial06; return -1;
}
// Window creation
if( !window.Create( "06 - Descriptor Sets" ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial06.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
}
// Vulkan preparations and initialization
if( !tutorial06.PrepareVulkan( window.GetParameters() ) ) { // Tutorial 06
return -1; if( !tutorial06.CreateRenderingResources() ) {
} return -1;
}
// Tutorial 06 if( !tutorial06.CreateStagingBuffer() ) {
if( !tutorial06.CreateRenderingResources() ) { return -1;
return -1; }
} if( !tutorial06.CreateTexture() ) {
if( !tutorial06.CreateStagingBuffer() ) { return -1;
return -1; }
} if( !tutorial06.CreateDescriptorSetLayout() ) {
if( !tutorial06.CreateTexture() ) { return -1;
return -1; }
} if( !tutorial06.CreateDescriptorPool() ) {
if( !tutorial06.CreateDescriptorSetLayout() ) { return -1;
return -1; }
} if( !tutorial06.AllocateDescriptorSet() ) {
if( !tutorial06.CreateDescriptorPool() ) { return -1;
return -1; }
} if( !tutorial06.UpdateDescriptorSet() ) {
if( !tutorial06.AllocateDescriptorSet() ) { return -1;
return -1; }
} if( !tutorial06.CreateRenderPass() ) {
if( !tutorial06.UpdateDescriptorSet() ) { return -1;
return -1; }
} if( !tutorial06.CreatePipelineLayout() ) {
if( !tutorial06.CreateRenderPass() ) { return -1;
return -1; }
} if( !tutorial06.CreatePipeline() ) {
if( !tutorial06.CreatePipelineLayout() ) { return -1;
return -1; }
} if( !tutorial06.CreateVertexBuffer() ) {
if( !tutorial06.CreatePipeline() ) { return -1;
return -1; }
}
if( !tutorial06.CreateVertexBuffer() ) { // Rendering loop
return -1; if( !window.RenderingLoop( tutorial06 ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial06 ) ) { return 0;
return -1; }
}
return 0;
}
File diff suppressed because it is too large Load Diff
+166 -170
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #if !defined(TUTORIAL_07_HEADER)
// Intel does not assume any responsibility for any errors which may appear in this software #define TUTORIAL_07_HEADER
// nor any responsibility to update it.
#include "VulkanCommon.h"
#if !defined(TUTORIAL_07_HEADER) #include "Tools.h"
#define TUTORIAL_07_HEADER
namespace ApiWithoutSecrets {
#include "VulkanCommon.h"
#include "Tools.h" // ************************************************************ //
// BufferParameters //
namespace ApiWithoutSecrets { // //
// Vulkan Buffer's parameters container class //
// ************************************************************ // // ************************************************************ //
// BufferParameters // struct BufferParameters {
// // VkBuffer Handle;
// Vulkan Buffer's parameters container class // VkDeviceMemory Memory;
// ************************************************************ // uint32_t Size;
struct BufferParameters {
VkBuffer Handle; BufferParameters() :
VkDeviceMemory Memory; Handle( VK_NULL_HANDLE ),
uint32_t Size; Memory( VK_NULL_HANDLE ),
Size( 0 ) {
BufferParameters() : }
Handle( VK_NULL_HANDLE ), };
Memory( VK_NULL_HANDLE ),
Size( 0 ) { // ************************************************************ //
} // DescriptorParameters //
}; // //
// Container class for descriptor related resources //
// ************************************************************ // // ************************************************************ //
// DescriptorParameters // struct DescriptorSetParameters {
// // VkDescriptorPool Pool;
// Container class for descriptor related resources // VkDescriptorSetLayout Layout;
// ************************************************************ // VkDescriptorSet Handle;
struct DescriptorSetParameters {
VkDescriptorPool Pool; DescriptorSetParameters() :
VkDescriptorSetLayout Layout; Pool( VK_NULL_HANDLE ),
VkDescriptorSet Handle; Layout( VK_NULL_HANDLE ),
Handle( VK_NULL_HANDLE ) {
DescriptorSetParameters() : }
Pool( VK_NULL_HANDLE ), };
Layout( VK_NULL_HANDLE ),
Handle( VK_NULL_HANDLE ) { // ************************************************************ //
} // VertexData //
}; // //
// Struct describing data type and format of vertex attributes //
// ************************************************************ // // ************************************************************ //
// VertexData // struct VertexData {
// // float x, y, z, w;
// Struct describing data type and format of vertex attributes // float u, v;
// ************************************************************ // };
struct VertexData {
float x, y, z, w; // ************************************************************ //
float u, v; // RenderingResourcesData //
}; // //
// Struct containing data used during rendering process //
// ************************************************************ // // ************************************************************ //
// RenderingResourcesData // struct RenderingResourcesData {
// // VkFramebuffer Framebuffer;
// Struct containing data used during rendering process // VkCommandBuffer CommandBuffer;
// ************************************************************ // VkSemaphore ImageAvailableSemaphore;
struct RenderingResourcesData { VkSemaphore FinishedRenderingSemaphore;
VkFramebuffer Framebuffer; VkFence Fence;
VkCommandBuffer CommandBuffer;
VkSemaphore ImageAvailableSemaphore; RenderingResourcesData() :
VkSemaphore FinishedRenderingSemaphore; Framebuffer( VK_NULL_HANDLE ),
VkFence Fence; CommandBuffer( VK_NULL_HANDLE ),
ImageAvailableSemaphore( VK_NULL_HANDLE ),
RenderingResourcesData() : FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Framebuffer( VK_NULL_HANDLE ), Fence( VK_NULL_HANDLE ) {
CommandBuffer( VK_NULL_HANDLE ), }
ImageAvailableSemaphore( VK_NULL_HANDLE ), };
FinishedRenderingSemaphore( VK_NULL_HANDLE ),
Fence( VK_NULL_HANDLE ) { // ************************************************************ //
} // VulkanTutorial04Parameters //
}; // //
// Vulkan specific parameters //
// ************************************************************ // // ************************************************************ //
// VulkanTutorial04Parameters // struct VulkanTutorial07Parameters {
// // VkRenderPass RenderPass;
// Vulkan specific parameters // ImageParameters Image;
// ************************************************************ // BufferParameters UniformBuffer;
struct VulkanTutorial07Parameters { DescriptorSetParameters DescriptorSet;
VkRenderPass RenderPass; VkPipelineLayout PipelineLayout;
ImageParameters Image; VkPipeline GraphicsPipeline;
BufferParameters UniformBuffer; BufferParameters VertexBuffer;
DescriptorSetParameters DescriptorSet; BufferParameters StagingBuffer;
VkPipelineLayout PipelineLayout; VkCommandPool CommandPool;
VkPipeline GraphicsPipeline; std::vector<RenderingResourcesData> RenderingResources;
BufferParameters VertexBuffer;
BufferParameters StagingBuffer; static const size_t ResourcesCount = 3;
VkCommandPool CommandPool;
std::vector<RenderingResourcesData> RenderingResources; VulkanTutorial07Parameters() :
RenderPass( VK_NULL_HANDLE ),
static const size_t ResourcesCount = 3; Image(),
DescriptorSet(),
VulkanTutorial07Parameters() : PipelineLayout(),
RenderPass( VK_NULL_HANDLE ), GraphicsPipeline( VK_NULL_HANDLE ),
Image(), VertexBuffer(),
DescriptorSet(), StagingBuffer(),
PipelineLayout(), CommandPool( VK_NULL_HANDLE ),
GraphicsPipeline( VK_NULL_HANDLE ), RenderingResources( ResourcesCount ) {
VertexBuffer(), }
StagingBuffer(), };
CommandPool( VK_NULL_HANDLE ),
RenderingResources( ResourcesCount ) { // ************************************************************ //
} // Tutorial04 //
}; // //
// Class for presenting Vulkan usage topics //
// ************************************************************ // // ************************************************************ //
// Tutorial04 // class Tutorial07 : public VulkanCommon {
// // public:
// Class for presenting Vulkan usage topics // Tutorial07();
// ************************************************************ // ~Tutorial07();
class Tutorial07 : public VulkanCommon {
public: bool CreateRenderingResources();
Tutorial07(); bool CreateStagingBuffer();
~Tutorial07(); bool CreateTexture();
bool CreateUniformBuffer();
bool CreateRenderingResources(); bool CreateDescriptorSetLayout();
bool CreateStagingBuffer(); bool CreateDescriptorPool();
bool CreateTexture(); bool AllocateDescriptorSet();
bool CreateUniformBuffer(); bool UpdateDescriptorSet();
bool CreateDescriptorSetLayout(); bool CreateRenderPass();
bool CreateDescriptorPool(); bool CreatePipelineLayout();
bool AllocateDescriptorSet(); bool CreatePipeline();
bool UpdateDescriptorSet(); bool CreateVertexBuffer();
bool CreateRenderPass();
bool CreatePipelineLayout(); bool Draw() override;
bool CreatePipeline();
bool CreateVertexBuffer(); private:
VulkanTutorial07Parameters Vulkan;
bool Draw() override;
bool CreateCommandBuffers();
private: bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool);
VulkanTutorial07Parameters Vulkan; bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers);
bool CreateSemaphores();
bool CreateCommandBuffers(); bool CreateFences();
bool CreateCommandPool(uint32_t queue_family_index, VkCommandPool *pool); bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer);
bool AllocateCommandBuffers(VkCommandPool pool, uint32_t count, VkCommandBuffer *command_buffers); bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory);
bool CreateSemaphores(); bool CreateImage( uint32_t width, uint32_t height, VkImage *image );
bool CreateFences(); bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory );
bool CreateBuffer(VkBufferUsageFlags usage, VkMemoryPropertyFlagBits memoryProperty, BufferParameters &buffer); bool CreateImageView( ImageParameters &image_parameters );
bool AllocateBufferMemory(VkBuffer buffer, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory); bool CreateSampler( VkSampler *sampler );
bool CreateImage( uint32_t width, uint32_t height, VkImage *image ); bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height );
bool AllocateImageMemory( VkImage image, VkMemoryPropertyFlagBits property, VkDeviceMemory *memory ); const std::array<float, 16> GetUniformBufferData() const;
bool CreateImageView( ImageParameters &image_parameters ); bool CopyUniformBufferData();
bool CreateSampler( VkSampler *sampler ); Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename );
bool CopyTextureData( char *texture_data, uint32_t data_size, uint32_t width, uint32_t height ); const std::vector<float>& GetVertexData() const;
const std::array<float, 16> GetUniformBufferData() const; bool CopyVertexData();
bool CopyUniformBufferData(); bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer );
Tools::AutoDeleter<VkShaderModule, PFN_vkDestroyShaderModule> CreateShaderModule( const char* filename ); bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view );
const std::vector<float>& GetVertexData() const; void DestroyBuffer( BufferParameters& buffer );
bool CopyVertexData();
bool PrepareFrame( VkCommandBuffer command_buffer, const ImageParameters &image_parameters, VkFramebuffer &framebuffer ); bool ChildOnWindowSizeChanged() override;
bool CreateFramebuffer( VkFramebuffer &framebuffer, VkImageView image_view ); void ChildClear() override;
void DestroyBuffer( BufferParameters& buffer ); };
bool ChildOnWindowSizeChanged() override; } // namespace ApiWithoutSecrets
void ChildClear() override;
};
} // namespace ApiWithoutSecrets
#endif // TUTORIAL_07_HEADER #endif // TUTORIAL_07_HEADER
+67 -71
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");␍// 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.
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, /////////////////////////////////////////////////////////////////////////////////////////////
// FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
// RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. #include "Tutorial07.h"
// Intel does not assume any responsibility for any errors which may appear in this software
// nor any responsibility to update it. int main( int argc, char **argv ) {
ApiWithoutSecrets::OS::Window window;
#include "Tutorial07.h" ApiWithoutSecrets::Tutorial07 tutorial07;
int main( int argc, char **argv ) { // Window creation
ApiWithoutSecrets::OS::Window window; if( !window.Create( "07 - Uniform Buffers" ) ) {
ApiWithoutSecrets::Tutorial07 tutorial07; return -1;
}
// Window creation
if( !window.Create( "07 - Uniform Buffers" ) ) { // Vulkan preparations and initialization
return -1; if( !tutorial07.PrepareVulkan( window.GetParameters() ) ) {
} return -1;
}
// Vulkan preparations and initialization
if( !tutorial07.PrepareVulkan( window.GetParameters() ) ) { // Tutorial 06
return -1; if( !tutorial07.CreateRenderingResources() ) {
} return -1;
}
// Tutorial 06 if( !tutorial07.CreateStagingBuffer() ) {
if( !tutorial07.CreateRenderingResources() ) { return -1;
return -1; }
} if( !tutorial07.CreateTexture() ) {
if( !tutorial07.CreateStagingBuffer() ) { return -1;
return -1; }
} if( !tutorial07.CreateUniformBuffer() ) {
if( !tutorial07.CreateTexture() ) { return -1;
return -1; }
} if( !tutorial07.CreateDescriptorSetLayout() ) {
if( !tutorial07.CreateUniformBuffer() ) { return -1;
return -1; }
} if( !tutorial07.CreateDescriptorPool() ) {
if( !tutorial07.CreateDescriptorSetLayout() ) { return -1;
return -1; }
} if( !tutorial07.AllocateDescriptorSet() ) {
if( !tutorial07.CreateDescriptorPool() ) { return -1;
return -1; }
} if( !tutorial07.UpdateDescriptorSet() ) {
if( !tutorial07.AllocateDescriptorSet() ) { return -1;
return -1; }
} if( !tutorial07.CreateRenderPass() ) {
if( !tutorial07.UpdateDescriptorSet() ) { return -1;
return -1; }
} if( !tutorial07.CreatePipelineLayout() ) {
if( !tutorial07.CreateRenderPass() ) { return -1;
return -1; }
} if( !tutorial07.CreatePipeline() ) {
if( !tutorial07.CreatePipelineLayout() ) { return -1;
return -1; }
} if( !tutorial07.CreateVertexBuffer() ) {
if( !tutorial07.CreatePipeline() ) { return -1;
return -1; }
}
if( !tutorial07.CreateVertexBuffer() ) { // Rendering loop
return -1; if( !window.RenderingLoop( tutorial07 ) ) {
} return -1;
}
// Rendering loop
if( !window.RenderingLoop( tutorial07 ) ) { return 0;
return -1; }
}
return 0;
}
+15 -9
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...
+41 -45
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 // you may not use this file except in compliance with the License.␍REM // You may obtain a copy of the License at ␍REM // ␍REM // http://www.apache.org/licenses/LICENSE-2.0 ␍REM // ␍REM // Unless required by applicable law or agreed to in writing, software␍REM // distributed under the License is distributed on an "AS IS" BASIS,␍REM // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.␍REM // See the License for the specific language governing permissions and␍REM // limitations under the License.
REM EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, REM /////////////////////////////////////////////////////////////////////////////////////////////
REM FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY
REM RIGHTS, AND INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. if [%1] == [] (
REM Intel does not assume any responsibility for any errors which may appear in this software echo No arguments provided! Please specify folder number.
REM nor any responsibility to update it. echo Example usage: compile_shaders.bat 03
goto end
if [%1] == [] ( )
echo No arguments provided! Please specify folder number.
echo Example usage: compile_shaders.bat 03 if exist glslangValidator.exe (
goto end goto convert
) )
for %%X in (glslangValidator.exe) do (set glslangValidator=%%~$PATH:X)
if exist glslangValidator.exe ( if defined glslangValidator (
goto convert goto convert
) )
for %%X in (glslangValidator.exe) do (set glslangValidator=%%~$PATH:X)
if defined glslangValidator ( echo Could not find "glslangValidator.exe" file.
goto convert goto end
)
:convert
echo Could not find "glslangValidator.exe" file.
goto end set folder=Tutorial%1/Data%1
echo Converting GLSL shaders into SPIR-V assembly in the "%folder%" folder.
:convert
if exist %folder%/shader.vert (
set folder=Tutorial%1/Data%1 glslangValidator.exe -V -H -o %folder%/vert.spv %folder%/shader.vert > %folder%/vert.spv.txt
echo Converting GLSL shaders into SPIR-V assembly in the "%folder%" folder. )
if exist %folder%/shader.vert ( if exist %folder%/shader.frag (
glslangValidator.exe -V -H -o %folder%/vert.spv %folder%/shader.vert > %folder%/vert.spv.txt glslangValidator.exe -V -H -o %folder%/frag.spv %folder%/shader.frag > %folder%/frag.spv.txt
) )
if exist %folder%/shader.frag ( :end
glslangValidator.exe -V -H -o %folder%/frag.spv %folder%/shader.frag > %folder%/frag.spv.txt
)
:end
ENDLOCAL ENDLOCAL
+149 -226
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.