Renderer: Add RenderDevice::GetDeviceInfo()
This commit is contained in:
@@ -26,6 +26,35 @@ namespace Nz
|
||||
if (!m_referenceContext)
|
||||
throw std::runtime_error("failed to create reference context");
|
||||
|
||||
if (!GL::Context::SetCurrentContext(m_referenceContext.get()))
|
||||
throw std::runtime_error("failed to activate reference context");
|
||||
|
||||
const GLubyte* vendorStr = m_referenceContext->glGetString(GL_VENDOR);
|
||||
const GLubyte* rendererStr = m_referenceContext->glGetString(GL_RENDERER);
|
||||
|
||||
m_deviceInfo.name = "OpenGL Device (";
|
||||
|
||||
if (vendorStr)
|
||||
m_deviceInfo.name.append(reinterpret_cast<const char*>(vendorStr));
|
||||
|
||||
if (rendererStr)
|
||||
{
|
||||
if (vendorStr)
|
||||
m_deviceInfo.name += " - ";
|
||||
|
||||
m_deviceInfo.name.append(reinterpret_cast<const char*>(rendererStr));
|
||||
}
|
||||
|
||||
m_deviceInfo.name += ')';
|
||||
|
||||
m_deviceInfo.type = RenderDeviceType::Unknown;
|
||||
|
||||
GLint minUboOffsetAlignment;
|
||||
m_referenceContext->glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &minUboOffsetAlignment);
|
||||
|
||||
assert(minUboOffsetAlignment >= 1);
|
||||
m_deviceInfo.limits.minUniformBufferOffsetAlignment = static_cast<UInt64>(minUboOffsetAlignment);
|
||||
|
||||
m_contexts.insert(m_referenceContext.get());
|
||||
}
|
||||
|
||||
@@ -50,6 +79,11 @@ namespace Nz
|
||||
return contextPtr;
|
||||
}
|
||||
|
||||
const RenderDeviceInfo& OpenGLDevice::GetDeviceInfo() const
|
||||
{
|
||||
return m_deviceInfo;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbstractBuffer> OpenGLDevice::InstantiateBuffer(BufferType type)
|
||||
{
|
||||
return std::make_shared<OpenGLBuffer>(*this, type);
|
||||
|
||||
@@ -16,6 +16,42 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
RenderDeviceInfo Vulkan::BuildRenderDeviceInfo(const Vk::PhysicalDevice& physDevice)
|
||||
{
|
||||
RenderDeviceInfo deviceInfo;
|
||||
deviceInfo.name = physDevice.properties.deviceName;
|
||||
|
||||
deviceInfo.limits.minUniformBufferOffsetAlignment = physDevice.properties.limits.minUniformBufferOffsetAlignment;
|
||||
|
||||
switch (physDevice.properties.deviceType)
|
||||
{
|
||||
case VK_PHYSICAL_DEVICE_TYPE_CPU:
|
||||
deviceInfo.type = RenderDeviceType::Software;
|
||||
break;
|
||||
|
||||
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
|
||||
deviceInfo.type = RenderDeviceType::Dedicated;
|
||||
break;
|
||||
|
||||
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
|
||||
deviceInfo.type = RenderDeviceType::Integrated;
|
||||
break;
|
||||
|
||||
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
|
||||
deviceInfo.type = RenderDeviceType::Virtual;
|
||||
break;
|
||||
|
||||
default:
|
||||
NazaraWarning("Device " + deviceInfo.name + " has handled device type (0x" + NumberToString(physDevice.properties.deviceType, 16) + ')');
|
||||
// fallthrough
|
||||
case VK_PHYSICAL_DEVICE_TYPE_OTHER:
|
||||
deviceInfo.type = RenderDeviceType::Unknown;
|
||||
break;
|
||||
}
|
||||
|
||||
return deviceInfo;
|
||||
}
|
||||
|
||||
Vk::Instance& Vulkan::GetInstance()
|
||||
{
|
||||
return s_instance;
|
||||
@@ -508,7 +544,7 @@ namespace Nz
|
||||
nullptr
|
||||
};
|
||||
|
||||
std::shared_ptr<VulkanDevice> device = std::make_shared<VulkanDevice>(s_instance);
|
||||
std::shared_ptr<VulkanDevice> device = std::make_shared<VulkanDevice>(s_instance, BuildRenderDeviceInfo(deviceInfo));
|
||||
if (!device->Create(deviceInfo, createInfo))
|
||||
{
|
||||
NazaraError("Failed to create Vulkan Device: " + TranslateVulkanError(device->GetLastErrorCode()));
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace Nz
|
||||
{
|
||||
VulkanDevice::~VulkanDevice() = default;
|
||||
|
||||
const RenderDeviceInfo& VulkanDevice::GetDeviceInfo() const
|
||||
{
|
||||
return m_renderDeviceInfo;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbstractBuffer> VulkanDevice::InstantiateBuffer(BufferType type)
|
||||
{
|
||||
return std::make_shared<VulkanBuffer>(*this, type);
|
||||
|
||||
@@ -69,36 +69,7 @@ namespace Nz
|
||||
devices.reserve(physDevices.size());
|
||||
|
||||
for (const Vk::PhysicalDevice& physDevice : physDevices)
|
||||
{
|
||||
RenderDeviceInfo& device = devices.emplace_back();
|
||||
device.name = physDevice.properties.deviceName;
|
||||
|
||||
switch (physDevice.properties.deviceType)
|
||||
{
|
||||
case VK_PHYSICAL_DEVICE_TYPE_CPU:
|
||||
device.type = RenderDeviceType::Software;
|
||||
break;
|
||||
|
||||
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
|
||||
device.type = RenderDeviceType::Dedicated;
|
||||
break;
|
||||
|
||||
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
|
||||
device.type = RenderDeviceType::Integrated;
|
||||
break;
|
||||
|
||||
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
|
||||
device.type = RenderDeviceType::Virtual;
|
||||
break;
|
||||
|
||||
default:
|
||||
NazaraWarning("Device " + device.name + " has handled device type (0x" + NumberToString(physDevice.properties.deviceType, 16) + ')');
|
||||
// fallthrough
|
||||
case VK_PHYSICAL_DEVICE_TYPE_OTHER:
|
||||
device.type = RenderDeviceType::Unknown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
devices.push_back(Vulkan::BuildRenderDeviceInfo(physDevice));
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user