Skip to content

Commit

Permalink
print device info (gpu name, driver info)
Browse files Browse the repository at this point in the history
  • Loading branch information
K1ngst0m committed Oct 23, 2023
1 parent e656848 commit e014f64
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 25 deletions.
30 changes: 17 additions & 13 deletions engine/api/vulkan/physicalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ PhysicalDevice::PhysicalDevice(HandleType handle) : ResourceHandle(handle)
#endif
vkGetPhysicalDeviceFeatures2(getHandle(), &m_features2);

m_driverProperties = {};
m_driverProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES;
// Get device properties
VkPhysicalDeviceSubgroupProperties subgroupProperties = {};
subgroupProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
subgroupProperties.pNext = nullptr;
subgroupProperties.pNext = &m_driverProperties;

m_properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
// subgroupProperties.pNext = m_properties2.pNext;
m_properties2.pNext = &subgroupProperties;
vkGetPhysicalDeviceProperties2(getHandle(), &m_properties2);

Expand All @@ -68,16 +70,16 @@ PhysicalDevice::PhysicalDevice(HandleType handle) : ResourceHandle(handle)
}

{
auto* gpuProperties = &m_properties2;
auto* gpuProperties2 = &m_properties2;
auto* gpuSettings = &m_settings;
auto* gpuFeatures = &m_features2;
gpuSettings->uniformBufferAlignment =
(uint32_t)gpuProperties->properties.limits.minUniformBufferOffsetAlignment;
(uint32_t)gpuProperties2->properties.limits.minUniformBufferOffsetAlignment;
gpuSettings->uploadBufferTextureAlignment =
(uint32_t)gpuProperties->properties.limits.optimalBufferCopyOffsetAlignment;
(uint32_t)gpuProperties2->properties.limits.optimalBufferCopyOffsetAlignment;
gpuSettings->uploadBufferTextureRowAlignment =
(uint32_t)gpuProperties->properties.limits.optimalBufferCopyRowPitchAlignment;
gpuSettings->maxVertexInputBindings = gpuProperties->properties.limits.maxVertexInputBindings;
(uint32_t)gpuProperties2->properties.limits.optimalBufferCopyRowPitchAlignment;
gpuSettings->maxVertexInputBindings = gpuProperties2->properties.limits.maxVertexInputBindings;
gpuSettings->multiDrawIndirect = gpuFeatures->features.multiDrawIndirect;
gpuSettings->indirectRootConstant = false;
gpuSettings->builtinDrawID = true;
Expand Down Expand Up @@ -111,13 +113,15 @@ PhysicalDevice::PhysicalDevice(HandleType handle) : ResourceHandle(handle)
gpuSettings->samplerAnisotropySupported = gpuFeatures->features.samplerAnisotropy;

// save vendor and model Id as string
sprintf(gpuSettings->GpuVendorPreset.modelId.data(), "%#x", gpuProperties->properties.deviceID);
sprintf(gpuSettings->GpuVendorPreset.vendorId.data(), "%#x", gpuProperties->properties.vendorID);
strncpy(gpuSettings->GpuVendorPreset.gpuName.data(), gpuProperties->properties.deviceName,
MAX_GPU_VENDOR_STRING_LENGTH);
gpuSettings->GpuVendorPreset.modelId = std::format("{:#x}", gpuProperties2->properties.deviceID);
gpuSettings->GpuVendorPreset.vendorId = std::format("{:#x}", gpuProperties2->properties.vendorID);
gpuSettings->GpuVendorPreset.gpuName = gpuProperties2->properties.deviceName;

// driver info
gpuSettings->GpuVendorPreset.gpuDriverVersion = std::format("{} - {}", m_driverProperties.driverInfo, m_driverProperties.driverName);

// TODO: Fix once vulkan adds support for revision ID
strncpy(gpuSettings->GpuVendorPreset.revisionId.data(), "0x00", MAX_GPU_VENDOR_STRING_LENGTH);
gpuSettings->GpuVendorPreset.revisionId = "0x00";
}
}

Expand Down Expand Up @@ -282,7 +286,7 @@ VkPipelineStageFlags utils::determinePipelineStageFlags(PhysicalDevice* pGPU, Vk
{
VkPipelineStageFlags flags = 0;

auto* gpuSupport = pGPU->getSettings();
auto* gpuSupport = &pGPU->getSettings();
switch(queueType)
{
case aph::QueueType::GRAPHICS:
Expand Down
26 changes: 14 additions & 12 deletions engine/api/vulkan/physicalDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,27 @@ class PhysicalDevice : public ResourceHandle<VkPhysicalDevice>
VkFormatFeatureFlags features) const;
size_t padUniformBufferSize(size_t originalSize) const;
const VkPhysicalDeviceProperties* getProperties() const { return &m_properties; }
const GPUSettings* getSettings() const { return &m_settings; }
const GPUSettings& getSettings() const { return m_settings; }

private:
GPUSettings m_settings;
VkPhysicalDeviceProperties m_properties;
VkPhysicalDeviceProperties2 m_properties2;
VkPhysicalDeviceFeatures m_features;
VkPhysicalDeviceFeatures2 m_features2;
VkPhysicalDeviceMemoryProperties m_memoryProperties;
std::vector<std::string> m_supportedExtensions;
std::vector<VkQueueFamilyProperties> m_queueFamilyProperties;
std::unordered_map<QueueType, std::vector<uint32_t>> m_queueFamilyMap;
GPUSettings m_settings = {};
VkPhysicalDeviceDriverProperties m_driverProperties = {};
VkPhysicalDeviceProperties m_properties = {};
VkPhysicalDeviceProperties2 m_properties2 = {};
VkPhysicalDeviceFeatures m_features = {};
VkPhysicalDeviceFeatures2 m_features2 = {};
VkPhysicalDeviceMemoryProperties m_memoryProperties = {};
std::vector<std::string> m_supportedExtensions = {};
std::vector<VkQueueFamilyProperties> m_queueFamilyProperties = {};
std::unordered_map<QueueType, std::vector<uint32_t>> m_queueFamilyMap = {};
};

} // namespace aph::vk

namespace aph::vk::utils {
namespace aph::vk::utils
{
// Determines pipeline stages involved for given accesses
VkPipelineStageFlags determinePipelineStageFlags(PhysicalDevice* pGPU, VkAccessFlags accessFlags, QueueType queueType);
}
} // namespace aph::vk::utils

#endif // PHYSICALDEVICE_H_
7 changes: 7 additions & 0 deletions engine/renderer/api/vulkan/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ Renderer::Renderer(WSI* wsi, const RenderConfig& config) : IRenderer(wsi, config
};

m_pDevice = Device::Create(createInfo);
// output device info
{
const GPUSettings& setting = m_pDevice->getPhysicalDevice()->getSettings();
VK_LOG_INFO(" == Device creation ==");
VK_LOG_INFO("Device Name: %s", setting.GpuVendorPreset.gpuName);
VK_LOG_INFO("Driver Version: %s", setting.GpuVendorPreset.gpuDriverVersion);
}
APH_ASSERT(m_pDevice != nullptr);

// get 3 type queue
Expand Down

0 comments on commit e014f64

Please sign in to comment.