Cleanup on Samples (#295)
- introduced samples/utils functions in namespace vk::su (vulkan sample utils) - introduced usage of debugReportCallback
This commit is contained in:
committed by
Markus Tavenrath
parent
018ebdd87f
commit
f0dc8d6f38
@@ -1,4 +1,4 @@
|
||||
// Copyright(c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||
// Copyright(c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,7 @@
|
||||
// VulkanHpp Samples : 04_InitCommandBuffer
|
||||
// Create command buffer
|
||||
|
||||
#include "..\utils\utils.hpp"
|
||||
#include "vulkan/vulkan.hpp"
|
||||
#include <iostream>
|
||||
|
||||
@@ -25,24 +26,21 @@ int main(int /*argc*/, char * /*argv[]*/)
|
||||
{
|
||||
try
|
||||
{
|
||||
vk::ApplicationInfo appInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1);
|
||||
vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo({}, &appInfo));
|
||||
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName);
|
||||
#if !defined(NDEBUG)
|
||||
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
|
||||
#endif
|
||||
|
||||
std::vector<vk::PhysicalDevice> physicalDevices = instance->enumeratePhysicalDevices();
|
||||
assert(!physicalDevices.empty());
|
||||
std::vector<vk::QueueFamilyProperties> queueFamilyProperties = physicalDevices[0].getQueueFamilyProperties();
|
||||
size_t graphicsQueueFamilyIndex = std::distance(queueFamilyProperties.begin(),
|
||||
std::find_if(queueFamilyProperties.begin(),
|
||||
queueFamilyProperties.end(),
|
||||
[](vk::QueueFamilyProperties const& qfp) { return qfp.queueFlags & vk::QueueFlagBits::eGraphics; }));
|
||||
assert(graphicsQueueFamilyIndex < queueFamilyProperties.size());
|
||||
float queuePriority = 0.0f;
|
||||
vk::DeviceQueueCreateInfo deviceQueueCreateInfo({}, static_cast<uint32_t>(graphicsQueueFamilyIndex), 1, &queuePriority);
|
||||
vk::UniqueDevice device = physicalDevices[0].createDeviceUnique(vk::DeviceCreateInfo({}, 1, &deviceQueueCreateInfo));
|
||||
|
||||
uint32_t graphicsQueueFamilyIndex = vk::su::findGraphicsQueueFamilyIndex(physicalDevices[0].getQueueFamilyProperties());
|
||||
vk::UniqueDevice device = vk::su::createDevice(physicalDevices[0], graphicsQueueFamilyIndex);
|
||||
|
||||
/* VULKAN_HPP_KEY_START */
|
||||
|
||||
// create a UniqueCommandPool to allocate a CommandBuffer from
|
||||
vk::UniqueCommandPool commandPool = device->createCommandPoolUnique(vk::CommandPoolCreateInfo(vk::CommandPoolCreateFlags(), deviceQueueCreateInfo.queueFamilyIndex));
|
||||
vk::UniqueCommandPool commandPool = device->createCommandPoolUnique(vk::CommandPoolCreateInfo(vk::CommandPoolCreateFlags(), graphicsQueueFamilyIndex));
|
||||
|
||||
// allocate a CommandBuffer from the CommandPool
|
||||
std::vector<vk::UniqueCommandBuffer> commandBuffers = device->allocateCommandBuffersUnique(vk::CommandBufferAllocateInfo(commandPool.get(), vk::CommandBufferLevel::ePrimary, 1));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright(c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||
# Copyright(c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,10 +17,12 @@ cmake_minimum_required(VERSION 3.2)
|
||||
project(04_InitCommandBuffer)
|
||||
|
||||
set(HEADERS
|
||||
../utils/utils.hpp
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
04_InitCommandBuffer.cpp
|
||||
../utils/utils.cpp
|
||||
)
|
||||
|
||||
source_group(headers FILES ${HEADERS})
|
||||
|
||||
Reference in New Issue
Block a user