mirror of
https://github.com/stenzek/duckstation.git
synced 2025-07-13 21:50:09 +00:00
GPUDevice: Use driver type fields
This commit is contained in:
parent
ef26d5cb74
commit
e255f0df64
@ -358,42 +358,10 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
|||||||
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
const char* renderer = (const char*)glGetString(GL_RENDERER);
|
||||||
SetDriverType(GuessDriverType(0, vendor, renderer));
|
SetDriverType(GuessDriverType(0, vendor, renderer));
|
||||||
|
|
||||||
if (std::strstr(vendor, "Advanced Micro Devices") || std::strstr(vendor, "ATI Technologies Inc.") ||
|
|
||||||
std::strstr(vendor, "ATI"))
|
|
||||||
{
|
|
||||||
INFO_LOG("AMD GPU detected.");
|
|
||||||
vendor_id_amd = true;
|
|
||||||
}
|
|
||||||
else if (std::strstr(vendor, "NVIDIA Corporation"))
|
|
||||||
{
|
|
||||||
INFO_LOG("NVIDIA GPU detected.");
|
|
||||||
// vendor_id_nvidia = true;
|
|
||||||
}
|
|
||||||
else if (std::strstr(vendor, "Intel"))
|
|
||||||
{
|
|
||||||
INFO_LOG("Intel GPU detected.");
|
|
||||||
vendor_id_intel = true;
|
|
||||||
}
|
|
||||||
else if (std::strstr(vendor, "ARM"))
|
|
||||||
{
|
|
||||||
INFO_LOG("ARM GPU detected.");
|
|
||||||
vendor_id_arm = true;
|
|
||||||
}
|
|
||||||
else if (std::strstr(vendor, "Qualcomm"))
|
|
||||||
{
|
|
||||||
INFO_LOG("Qualcomm GPU detected.");
|
|
||||||
vendor_id_qualcomm = true;
|
|
||||||
}
|
|
||||||
else if (std::strstr(vendor, "Imagination Technologies") || std::strstr(renderer, "PowerVR"))
|
|
||||||
{
|
|
||||||
INFO_LOG("PowerVR GPU detected.");
|
|
||||||
vendor_id_powervr = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't use PBOs when we don't have ARB_buffer_storage, orphaning buffers probably ends up worse than just
|
// Don't use PBOs when we don't have ARB_buffer_storage, orphaning buffers probably ends up worse than just
|
||||||
// using the normal texture update routines and letting the driver take care of it. PBOs are also completely
|
// using the normal texture update routines and letting the driver take care of it. PBOs are also completely
|
||||||
// broken on mobile drivers.
|
// broken on mobile drivers.
|
||||||
const bool is_shitty_mobile_driver = (vendor_id_powervr || vendor_id_qualcomm || vendor_id_arm);
|
const bool is_shitty_mobile_driver = (m_driver_type & GPUDriverType::MobileFlag) == GPUDriverType::MobileFlag;
|
||||||
m_disable_pbo =
|
m_disable_pbo =
|
||||||
(!GLAD_GL_VERSION_4_4 && !GLAD_GL_ARB_buffer_storage && !GLAD_GL_EXT_buffer_storage) || is_shitty_mobile_driver;
|
(!GLAD_GL_VERSION_4_4 && !GLAD_GL_ARB_buffer_storage && !GLAD_GL_EXT_buffer_storage) || is_shitty_mobile_driver;
|
||||||
if (m_disable_pbo && !is_shitty_mobile_driver)
|
if (m_disable_pbo && !is_shitty_mobile_driver)
|
||||||
|
@ -623,7 +623,7 @@ bool VulkanDevice::EnableOptionalDeviceExtensions(VkPhysicalDevice physical_devi
|
|||||||
m_optional_extensions.vk_ext_external_memory_host &=
|
m_optional_extensions.vk_ext_external_memory_host &=
|
||||||
(external_memory_host_properties.minImportedHostPointerAlignment <= HOST_PAGE_SIZE);
|
(external_memory_host_properties.minImportedHostPointerAlignment <= HOST_PAGE_SIZE);
|
||||||
|
|
||||||
if (IsBrokenMobileDriver())
|
if ((m_driver_type & GPUDriverType::MobileFlag) == GPUDriverType::MobileFlag)
|
||||||
{
|
{
|
||||||
// Push descriptor is broken on Adreno v502.. don't want to think about dynamic rendending.
|
// Push descriptor is broken on Adreno v502.. don't want to think about dynamic rendending.
|
||||||
if (m_optional_extensions.vk_khr_dynamic_rendering)
|
if (m_optional_extensions.vk_khr_dynamic_rendering)
|
||||||
@ -639,7 +639,7 @@ bool VulkanDevice::EnableOptionalDeviceExtensions(VkPhysicalDevice physical_devi
|
|||||||
WARNING_LOG("Disabling VK_KHR_push_descriptor on broken mobile driver.");
|
WARNING_LOG("Disabling VK_KHR_push_descriptor on broken mobile driver.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (IsDeviceAMD())
|
else if (m_driver_type == GPUDriverType::AMDProprietary)
|
||||||
{
|
{
|
||||||
// VK_KHR_dynamic_rendering_local_read appears to be broken on RDNA3, like everything else...
|
// VK_KHR_dynamic_rendering_local_read appears to be broken on RDNA3, like everything else...
|
||||||
// Just causes GPU resets when you actually use a feedback loop. Assume Mesa is fine.
|
// Just causes GPU resets when you actually use a feedback loop. Assume Mesa is fine.
|
||||||
@ -1772,41 +1772,6 @@ void VulkanDevice::DisableDebugUtils()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VulkanDevice::IsDeviceNVIDIA() const
|
|
||||||
{
|
|
||||||
return (m_device_properties.vendorID == 0x10DE);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VulkanDevice::IsDeviceAMD() const
|
|
||||||
{
|
|
||||||
return (m_device_properties.vendorID == 0x1002);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VulkanDevice::IsDeviceAdreno() const
|
|
||||||
{
|
|
||||||
// Assume turnip is fine...
|
|
||||||
return ((m_device_properties.vendorID == 0x5143 ||
|
|
||||||
m_device_driver_properties.driverID == VK_DRIVER_ID_QUALCOMM_PROPRIETARY) &&
|
|
||||||
m_device_driver_properties.driverID != VK_DRIVER_ID_MESA_TURNIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VulkanDevice::IsDeviceMali() const
|
|
||||||
{
|
|
||||||
return (m_device_properties.vendorID == 0x13B5 ||
|
|
||||||
m_device_driver_properties.driverID == VK_DRIVER_ID_ARM_PROPRIETARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VulkanDevice::IsDeviceImgTec() const
|
|
||||||
{
|
|
||||||
return (m_device_properties.vendorID == 0x1010 ||
|
|
||||||
m_device_driver_properties.driverID == VK_DRIVER_ID_IMAGINATION_PROPRIETARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VulkanDevice::IsBrokenMobileDriver() const
|
|
||||||
{
|
|
||||||
return (IsDeviceAdreno() || IsDeviceMali() || IsDeviceImgTec());
|
|
||||||
}
|
|
||||||
|
|
||||||
VkRenderPass VulkanDevice::CreateCachedRenderPass(RenderPassCacheKey key)
|
VkRenderPass VulkanDevice::CreateCachedRenderPass(RenderPassCacheKey key)
|
||||||
{
|
{
|
||||||
std::array<VkAttachmentReference, MAX_RENDER_TARGETS> color_references;
|
std::array<VkAttachmentReference, MAX_RENDER_TARGETS> color_references;
|
||||||
@ -2747,7 +2712,7 @@ void VulkanDevice::ClearRenderTarget(GPUTexture* t, u32 c)
|
|||||||
{
|
{
|
||||||
VulkanTexture* T = static_cast<VulkanTexture*>(t);
|
VulkanTexture* T = static_cast<VulkanTexture*>(t);
|
||||||
|
|
||||||
if (IsDeviceNVIDIA())
|
if (m_driver_type == GPUDriverType::NVIDIAProprietary)
|
||||||
{
|
{
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
}
|
}
|
||||||
@ -2775,7 +2740,7 @@ void VulkanDevice::ClearDepth(GPUTexture* t, float d)
|
|||||||
// should be failing. Breaking/restarting the render pass isn't enough to work around the bug,
|
// should be failing. Breaking/restarting the render pass isn't enough to work around the bug,
|
||||||
// it needs an explicit pipeline barrier.
|
// it needs an explicit pipeline barrier.
|
||||||
VulkanTexture* T = static_cast<VulkanTexture*>(t);
|
VulkanTexture* T = static_cast<VulkanTexture*>(t);
|
||||||
if (IsDeviceNVIDIA())
|
if (m_driver_type == GPUDriverType::NVIDIAProprietary)
|
||||||
{
|
{
|
||||||
EndRenderPass();
|
EndRenderPass();
|
||||||
T->TransitionSubresourcesToLayout(GetCurrentCommandBuffer(), 0, 1, 0, 1, T->GetLayout(), T->GetLayout());
|
T->TransitionSubresourcesToLayout(GetCurrentCommandBuffer(), 0, 1, 0, 1, T->GetLayout(), T->GetLayout());
|
||||||
@ -3344,7 +3309,7 @@ void VulkanDevice::BeginRenderPass()
|
|||||||
|
|
||||||
// NVIDIA drivers appear to return random garbage when sampling the RT via a feedback loop, if the load op for
|
// NVIDIA drivers appear to return random garbage when sampling the RT via a feedback loop, if the load op for
|
||||||
// the render pass is CLEAR. Using vkCmdClearAttachments() doesn't work, so we have to clear the image instead.
|
// the render pass is CLEAR. Using vkCmdClearAttachments() doesn't work, so we have to clear the image instead.
|
||||||
if (m_current_render_pass_flags & GPUPipeline::ColorFeedbackLoop && IsDeviceNVIDIA())
|
if (m_current_render_pass_flags & GPUPipeline::ColorFeedbackLoop && m_driver_type == GPUDriverType::NVIDIAProprietary)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < m_num_current_render_targets; i++)
|
for (u32 i = 0; i < m_num_current_render_targets; i++)
|
||||||
{
|
{
|
||||||
|
@ -325,18 +325,6 @@ private:
|
|||||||
bool EnableDebugUtils();
|
bool EnableDebugUtils();
|
||||||
void DisableDebugUtils();
|
void DisableDebugUtils();
|
||||||
|
|
||||||
/// Returns true if running on an NVIDIA GPU.
|
|
||||||
bool IsDeviceNVIDIA() const;
|
|
||||||
|
|
||||||
/// Returns true if running on an AMD GPU.
|
|
||||||
bool IsDeviceAMD() const;
|
|
||||||
|
|
||||||
// Vendor queries.
|
|
||||||
bool IsDeviceAdreno() const;
|
|
||||||
bool IsDeviceMali() const;
|
|
||||||
bool IsDeviceImgTec() const;
|
|
||||||
bool IsBrokenMobileDriver() const;
|
|
||||||
|
|
||||||
using ExtensionList = std::vector<const char*>;
|
using ExtensionList = std::vector<const char*>;
|
||||||
static bool SelectInstanceExtensions(ExtensionList* extension_list, const WindowInfo& wi, OptionalExtensions* oe,
|
static bool SelectInstanceExtensions(ExtensionList* extension_list, const WindowInfo& wi, OptionalExtensions* oe,
|
||||||
bool enable_debug_utils);
|
bool enable_debug_utils);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user