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 # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if(!MSVC)
cmake_minimum_required(VERSION 3.2) cmake_minimum_required(VERSION 3.2)
project(RAII_PhysicalDeviceMemoryProperties) project(RAII_PhysicalDeviceMemoryProperties)
@ -32,6 +31,5 @@ if(!MSVC)
${SOURCES} ${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) target_link_libraries(RAII_PhysicalDeviceMemoryProperties PRIVATE utils)
endif(!MSVC)

View File

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

View File

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

View File

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