mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 05:45:38 +00:00
VulkanDevice: Work around some mobile driver issues
This commit is contained in:
parent
4f84a98864
commit
c20805f2be
|
@ -110,17 +110,12 @@ MaxValue = 10.0
|
|||
StepAmount = 0.05
|
||||
DefaultValue = 2.0
|
||||
|
||||
[OptionBool]
|
||||
GUIName = Scale in Linear Gamma
|
||||
OptionName = scaleInLinearGamma
|
||||
DefaultValue = true
|
||||
|
||||
[/configuration]
|
||||
*/
|
||||
|
||||
//Uncomment to reduce instructions with simpler linearization
|
||||
//(fixes HD3000 Sandy Bridge IGP)
|
||||
//#define SIMPLE_LINEAR_GAMMA
|
||||
#define SIMPLE_LINEAR_GAMMA
|
||||
#define DO_BLOOM
|
||||
|
||||
// ------------- //
|
||||
|
@ -143,17 +138,11 @@ float3 ToSrgb(float3 c)
|
|||
#else
|
||||
float ToLinear1(float c)
|
||||
{
|
||||
if (!OptionEnabled(scaleInLinearGamma))
|
||||
return c;
|
||||
|
||||
return(c<=0.04045) ? c/12.92 : pow((c + 0.055)/1.055, 2.4);
|
||||
}
|
||||
|
||||
float3 ToLinear(float3 c)
|
||||
{
|
||||
if (!OptionEnabled(scaleInLinearGamma))
|
||||
return c;
|
||||
|
||||
return float3(ToLinear1(c.r), ToLinear1(c.g), ToLinear1(c.b));
|
||||
}
|
||||
|
||||
|
@ -161,17 +150,11 @@ float3 ToLinear(float3 c)
|
|||
// Assuming using sRGB typed textures this should not be needed.
|
||||
float ToSrgb1(float c)
|
||||
{
|
||||
if (!OptionEnabled(scaleInLinearGamma))
|
||||
return c;
|
||||
|
||||
return(c<0.0031308 ? c*12.92 : 1.055*pow(c, 0.41666) - 0.055);
|
||||
}
|
||||
|
||||
float3 ToSrgb(float3 c)
|
||||
{
|
||||
if (!OptionEnabled(scaleInLinearGamma))
|
||||
return c;
|
||||
|
||||
return float3(ToSrgb1(c.r), ToSrgb1(c.g), ToSrgb1(c.b));
|
||||
}
|
||||
#endif
|
||||
|
@ -391,15 +374,8 @@ void main()
|
|||
outColor.rgb += Bloom(pos)*GetOption(bloomAmount);
|
||||
#endif
|
||||
|
||||
if (GetOption(shadowMask) > 0.0)
|
||||
if (GetOption(shadowMask) > 0)
|
||||
outColor.rgb *= Mask(gl_FragCoord.xy * 1.000001);
|
||||
|
||||
#ifdef GL_ES /* TODO/FIXME - hacky clamp fix */
|
||||
float2 bordertest = (pos);
|
||||
if ( bordertest.x > 0.0001 && bordertest.x < 0.9999 && bordertest.y > 0.0001 && bordertest.y < 0.9999)
|
||||
outColor.rgb = outColor.rgb;
|
||||
else
|
||||
outColor.rgb = float3(0.0);
|
||||
#endif
|
||||
SetOutput(float4(ToSrgb(outColor.rgb), 1.0));
|
||||
}
|
||||
|
|
|
@ -1451,6 +1451,14 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUTexture* final
|
|||
GL_SCOPE_FMT("Draw pass {}", pass.name.c_str());
|
||||
DebugAssert(!pass.render_targets.empty());
|
||||
|
||||
// Sucks doing this twice, but we need to set the RT first (for DX11), and transition layouts (for VK).
|
||||
for (const Sampler& sampler : pass.samplers)
|
||||
{
|
||||
GPUTexture* const tex = GetTextureByID(sampler.texture_id, input, final_target);
|
||||
if (tex)
|
||||
tex->MakeReadyForSampling();
|
||||
}
|
||||
|
||||
if (pass.render_targets.size() == 1 && pass.render_targets[0] == OUTPUT_COLOR_TEXTURE && !final_target)
|
||||
{
|
||||
// Special case: drawing to final buffer.
|
||||
|
|
|
@ -93,7 +93,7 @@ const std::array<VkFormat, static_cast<u32>(GPUTexture::Format::MaxCount)> Vulka
|
|||
static constexpr VkClearValue s_present_clear_color = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
|
||||
|
||||
// Handles are always 64-bit, even on 32-bit platforms.
|
||||
static const VkRenderPass DYNAMIC_RENDERING_RENDER_PASS = ((VkRenderPass)static_cast<s64>(-1LL));
|
||||
static const VkRenderPass DYNAMIC_RENDERING_RENDER_PASS = ((VkRenderPass) static_cast<s64>(-1LL));
|
||||
|
||||
#ifdef _DEBUG
|
||||
static u32 s_debug_scope_depth = 0;
|
||||
|
@ -602,6 +602,21 @@ void VulkanDevice::ProcessDeviceExtensions()
|
|||
|
||||
m_optional_extensions.vk_khr_push_descriptor &= (push_descriptor_properties.maxPushDescriptors >= 1);
|
||||
|
||||
if (IsBrokenMobileDriver())
|
||||
{
|
||||
// Push descriptor is broken on Adreno v502.. don't want to think about dynamic rendending.
|
||||
if (m_optional_extensions.vk_khr_dynamic_rendering)
|
||||
{
|
||||
m_optional_extensions.vk_khr_dynamic_rendering = false;
|
||||
Log_WarningPrint("Disabling VK_KHR_dynamic_rendering on broken mobile driver.");
|
||||
}
|
||||
if (m_optional_extensions.vk_khr_push_descriptor)
|
||||
{
|
||||
m_optional_extensions.vk_khr_push_descriptor = false;
|
||||
Log_WarningPrint("Disabling VK_KHR_push_descriptor on broken mobile driver.");
|
||||
}
|
||||
}
|
||||
|
||||
Log_InfoPrintf("VK_EXT_memory_budget is %s",
|
||||
m_optional_extensions.vk_ext_memory_budget ? "supported" : "NOT supported");
|
||||
Log_InfoPrintf("VK_EXT_rasterization_order_attachment_access is %s",
|
||||
|
@ -700,7 +715,8 @@ bool VulkanDevice::CreateCommandBuffers()
|
|||
LOG_VULKAN_ERROR(res, "vkCreateCommandPool failed: ");
|
||||
return false;
|
||||
}
|
||||
Vulkan::SetObjectName(m_device, resources.command_pool, TinyString::from_format("Frame Command Pool {}", frame_index));
|
||||
Vulkan::SetObjectName(m_device, resources.command_pool,
|
||||
TinyString::from_format("Frame Command Pool {}", frame_index));
|
||||
|
||||
VkCommandBufferAllocateInfo buffer_info = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, nullptr,
|
||||
resources.command_pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
||||
|
@ -1497,6 +1513,31 @@ void VulkanDevice::DisableDebugUtils()
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
VkAttachmentReference color_reference;
|
||||
|
@ -3344,6 +3385,10 @@ bool VulkanDevice::UpdateDescriptorSetsForLayout(bool new_layout, bool new_dynam
|
|||
ds[num_ds++] = m_ubo_descriptor_set;
|
||||
new_dynamic_offsets = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
first_ds++;
|
||||
}
|
||||
}
|
||||
|
||||
if constexpr (layout == GPUPipeline::Layout::SingleTextureAndUBO ||
|
||||
|
|
|
@ -292,6 +292,12 @@ private:
|
|||
bool EnableDebugUtils();
|
||||
void DisableDebugUtils();
|
||||
|
||||
// Vendor queries.
|
||||
bool IsDeviceAdreno() const;
|
||||
bool IsDeviceMali() const;
|
||||
bool IsDeviceImgTec() const;
|
||||
bool IsBrokenMobileDriver() const;
|
||||
|
||||
void SubmitCommandBuffer(VulkanSwapChain* present_swap_chain = nullptr, bool submit_on_thread = false);
|
||||
void MoveToNextCommandBuffer();
|
||||
void WaitForPresentComplete();
|
||||
|
|
Loading…
Reference in a new issue