2018-09-19 11:49:43 +00:00
|
|
|
// Copyright(c) 2018, 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.
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// VulkanHpp Tests : StructureChain
|
|
|
|
// Compile-test for StructureChains
|
|
|
|
|
|
|
|
#include "vulkan/vulkan.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
static char const* AppName = "StructureChain";
|
|
|
|
static char const* EngineName = "Vulkan.hpp";
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#pragma warning( disable : 4189 )
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
|
|
|
#else
|
|
|
|
// unknow compiler... just ignore the warnings for yourselves ;)
|
|
|
|
#endif
|
|
|
|
|
2019-03-19 14:35:08 +00:00
|
|
|
int main(int /*argc*/, char ** /*argv*/)
|
2018-09-19 11:49:43 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
vk::ApplicationInfo appInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1);
|
|
|
|
vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo({}, &appInfo));
|
2019-06-25 07:47:27 +00:00
|
|
|
vk::PhysicalDevice physicalDevice = instance->enumeratePhysicalDevices().front();
|
2018-09-19 11:49:43 +00:00
|
|
|
|
2018-09-20 13:20:00 +00:00
|
|
|
// some valid StructureChains
|
|
|
|
vk::StructureChain<vk::PhysicalDeviceProperties2> sc0;
|
|
|
|
vk::StructureChain<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties> sc1;
|
|
|
|
vk::StructureChain<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceMaintenance3Properties> sc2;
|
|
|
|
vk::StructureChain<vk::PhysicalDeviceProperties2, vk::PhysicalDevicePushDescriptorPropertiesKHR> sc3;
|
|
|
|
vk::StructureChain<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties, vk::PhysicalDeviceMaintenance3Properties> sc4;
|
|
|
|
vk::StructureChain<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties, vk::PhysicalDevicePushDescriptorPropertiesKHR> sc6;
|
|
|
|
vk::StructureChain<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties, vk::PhysicalDeviceMaintenance3Properties, vk::PhysicalDevicePushDescriptorPropertiesKHR> sc7;
|
|
|
|
|
|
|
|
// some not valid StructureChains
|
|
|
|
//vk::StructureChain<vk::PhysicalDeviceIDProperties, vk::PhysicalDeviceMaintenance3Properties> x;
|
|
|
|
//vk::StructureChain<vk::PhysicalDeviceIDProperties, vk::PhysicalDeviceMaintenance3Properties, vk::PhysicalDevicePushDescriptorPropertiesKHR> x;
|
|
|
|
//vk::StructureChain<vk::PhysicalDeviceIDProperties, vk::PhysicalDevicePushDescriptorPropertiesKHR, vk::PhysicalDeviceMaintenance3Properties> x;
|
|
|
|
//vk::StructureChain<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceIDProperties, vk::PhysicalDeviceIDProperties> x;
|
|
|
|
//vk::StructureChain<vk::PhysicalDeviceIDProperties, vk::PhysicalDeviceProperties2> x;
|
|
|
|
|
2018-09-19 11:49:43 +00:00
|
|
|
// simple call, passing structures in
|
|
|
|
vk::PhysicalDeviceFeatures2 pdf;
|
2019-06-25 07:47:27 +00:00
|
|
|
physicalDevice.getFeatures2(&pdf);
|
2018-09-19 11:49:43 +00:00
|
|
|
|
|
|
|
// simple calls, getting structure back
|
2019-06-25 07:47:27 +00:00
|
|
|
vk::PhysicalDeviceFeatures2 a = physicalDevice.getFeatures2();
|
|
|
|
vk::PhysicalDeviceFeatures2 b = physicalDevice.getFeatures2(vk::DispatchLoaderStatic());
|
2018-09-19 11:49:43 +00:00
|
|
|
|
|
|
|
// complex calls, getting StructureChain back
|
2019-06-25 07:47:27 +00:00
|
|
|
auto c = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVariablePointerFeatures>();
|
2018-09-19 11:49:43 +00:00
|
|
|
vk::PhysicalDeviceFeatures2 & c0 = c.get<vk::PhysicalDeviceFeatures2>();
|
|
|
|
vk::PhysicalDeviceVariablePointerFeatures & c1 = c.get<vk::PhysicalDeviceVariablePointerFeatures>();
|
2019-03-12 08:32:39 +00:00
|
|
|
|
|
|
|
auto t0 = c.get<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVariablePointerFeatures>();
|
2018-09-19 11:49:43 +00:00
|
|
|
|
2019-06-25 07:47:27 +00:00
|
|
|
auto d = physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVariablePointerFeatures>(vk::DispatchLoaderStatic());
|
2018-09-19 11:49:43 +00:00
|
|
|
vk::PhysicalDeviceFeatures2 & d0 = d.get<vk::PhysicalDeviceFeatures2>();
|
|
|
|
vk::PhysicalDeviceVariablePointerFeatures & d1 = d.get<vk::PhysicalDeviceVariablePointerFeatures>();
|
2019-01-09 10:55:11 +00:00
|
|
|
|
2019-03-12 08:32:39 +00:00
|
|
|
auto t1 = d.get<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVariablePointerFeatures>();
|
|
|
|
|
2019-01-09 10:55:11 +00:00
|
|
|
using StructureChain = vk::StructureChain<vk::QueueFamilyProperties2, vk::QueueFamilyCheckpointPropertiesNV>;
|
|
|
|
using AllocatorType = std::vector<StructureChain>::allocator_type;
|
2019-06-25 07:47:27 +00:00
|
|
|
auto qfd = physicalDevice.getQueueFamilyProperties2<StructureChain, AllocatorType>(vk::DispatchLoaderStatic());
|
2018-09-19 11:49:43 +00:00
|
|
|
}
|
|
|
|
catch (vk::SystemError err)
|
|
|
|
{
|
|
|
|
std::cout << "vk::SystemError: " << err.what() << std::endl;
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
std::cout << "unknown error\n";
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|