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,26 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if(!MSVC)
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.2)
project(RAII_PhysicalDeviceMemoryProperties)
project(RAII_PhysicalDeviceMemoryProperties)
set(HEADERS
)
set(HEADERS
)
set(SOURCES
PhysicalDeviceMemoryProperties.cpp
)
set(SOURCES
PhysicalDeviceMemoryProperties.cpp
)
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
add_executable(RAII_PhysicalDeviceMemoryProperties
${HEADERS}
${SOURCES}
)
add_executable(RAII_PhysicalDeviceMemoryProperties
${HEADERS}
${SOURCES}
)
set_target_properties(RAII_PhysicalDeviceMemoryProperties PROPERTIES FOLDER "RAIISamples")
target_link_libraries(RAII_PhysicalDeviceMemoryProperties PRIVATE utils)
endif(!MSVC)
set_target_properties(RAII_PhysicalDeviceMemoryProperties PROPERTIES FOLDER "RAII_Samples")
target_link_libraries(RAII_PhysicalDeviceMemoryProperties PRIVATE utils)

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,26 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if(!MSVC)
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.2)
project(PhysicalDeviceMemoryProperties)
project(PhysicalDeviceMemoryProperties)
set(HEADERS
)
set(HEADERS
)
set(SOURCES
PhysicalDeviceMemoryProperties.cpp
)
set(SOURCES
PhysicalDeviceMemoryProperties.cpp
)
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
source_group(headers FILES ${HEADERS})
source_group(sources FILES ${SOURCES})
add_executable(PhysicalDeviceMemoryProperties
${HEADERS}
${SOURCES}
)
add_executable(PhysicalDeviceMemoryProperties
${HEADERS}
${SOURCES}
)
set_target_properties(PhysicalDeviceMemoryProperties PROPERTIES FOLDER "Samples")
target_link_libraries(PhysicalDeviceMemoryProperties PRIVATE utils)
endif(!MSVC)
set_target_properties(PhysicalDeviceMemoryProperties PROPERTIES FOLDER "Samples")
target_link_libraries(PhysicalDeviceMemoryProperties PRIVATE utils)

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 )
{