Update samples on PhysicalDeviceMemoryProperties

This commit is contained in:
asuessenbach 2022-02-03 10:42:57 +01:00
parent bac1a58f80
commit d38980d592
4 changed files with 47 additions and 47 deletions

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if(!MSVC)
cmake_minimum_required(VERSION 3.2)
project(RAII_PhysicalDeviceMemoryProperties)
@ -32,6 +31,5 @@ if(!MSVC)
${SOURCES}
)
set_target_properties(RAII_PhysicalDeviceMemoryProperties PROPERTIES FOLDER "RAIISamples")
set_target_properties(RAII_PhysicalDeviceMemoryProperties PROPERTIES FOLDER "RAII_Samples")
target_link_libraries(RAII_PhysicalDeviceMemoryProperties PRIVATE utils)
endif(!MSVC)

View File

@ -50,30 +50,28 @@ int main( int /*argc*/, char ** /*argv*/ )
{
try
{
std::unique_ptr<vk::ContextHandle<>> contextHandle = std::make_unique<vk::ContextHandle<>>();
std::unique_ptr<vk::InstanceHandle<>> instanceHandle =
vk::su::makeUniqueInstanceHandle( *contextHandle, AppName, EngineName, {}, {}, VK_API_VERSION_1_1 );
vk::raii::Context context;
vk::raii::Instance instance =
vk::raii::su::makeInstance( context, AppName, EngineName, {}, {}, VK_API_VERSION_1_1 );
#if !defined( NDEBUG )
std::unique_ptr<vk::DebugUtilsMessengerEXTHandle<>> debugUtilsMessenger =
vk::su::makeUniqueDebugUtilsMessengerEXTHandle( *instanceHandle );
vk::raii::DebugUtilsMessengerEXT debugUtilsMessenger( instance, vk::su::makeDebugUtilsMessengerCreateInfoEXT() );
#endif
// enumerate the physicalDevices
std::unique_ptr<vk::PhysicalDeviceHandles<>> physicalDeviceHandles =
std::make_unique<vk::PhysicalDeviceHandles<>>( *instanceHandle );
vk::raii::PhysicalDevices physicalDevices( instance );
/* VULKAN_KEY_START */
for ( size_t i = 0; i < physicalDeviceHandles->size(); i++ )
for ( size_t i = 0; i < physicalDevices.size(); i++ )
{
// some properties are only valid, if a corresponding extension is available!
std::vector<vk::ExtensionProperties> extensionProperties =
(*physicalDeviceHandles)[i].enumerateDeviceExtensionProperties();
physicalDevices[i].enumerateDeviceExtensionProperties();
bool containsMemoryBudget = vk::su::contains( extensionProperties, "VK_EXT_memory_budget" );
std::cout << "PhysicalDevice " << i << " :\n";
auto memoryProperties2 =
(*physicalDeviceHandles)[i]
physicalDevices[i]
.getMemoryProperties2<vk::PhysicalDeviceMemoryProperties2, vk::PhysicalDeviceMemoryBudgetPropertiesEXT>();
vk::PhysicalDeviceMemoryProperties const & memoryProperties =
memoryProperties2.get<vk::PhysicalDeviceMemoryProperties2>().memoryProperties;

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if(!MSVC)
cmake_minimum_required(VERSION 3.2)
project(PhysicalDeviceMemoryProperties)
@ -34,4 +33,3 @@ if(!MSVC)
set_target_properties(PhysicalDeviceMemoryProperties PROPERTIES FOLDER "Samples")
target_link_libraries(PhysicalDeviceMemoryProperties PRIVATE utils)
endif(!MSVC)

View File

@ -50,13 +50,14 @@ int main( int /*argc*/, char ** /*argv*/ )
{
try
{
vk::UniqueInstance instance = vk::su::createInstance( AppName, EngineName, {}, {}, VK_API_VERSION_1_1 );
vk::Instance instance = vk::su::createInstance( AppName, EngineName, {}, {}, VK_API_VERSION_1_1 );
#if !defined( NDEBUG )
vk::UniqueDebugUtilsMessengerEXT debugUtilsMessenger = vk::su::createDebugUtilsMessenger( instance );
vk::DebugUtilsMessengerEXT debugUtilsMessenger =
instance.createDebugUtilsMessengerEXT( vk::su::makeDebugUtilsMessengerCreateInfoEXT() );
#endif
// enumerate the physicalDevices
std::vector<vk::PhysicalDevice> physicalDevices = instance->enumeratePhysicalDevices();
std::vector<vk::PhysicalDevice> physicalDevices = instance.enumeratePhysicalDevices();
/* VULKAN_KEY_START */
@ -95,6 +96,11 @@ int main( int /*argc*/, char ** /*argv*/ )
}
/* VULKAN_KEY_END */
#if !defined( NDEBUG )
instance.destroyDebugUtilsMessengerEXT( debugUtilsMessenger );
#endif
instance.destroy();
}
catch ( vk::SystemError & err )
{