Updated License to Apache 2.0

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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