Skip to content

Commit

Permalink
Use draw clear on Adreno, instead of vkCmdClearAttachments (#7013)
Browse files Browse the repository at this point in the history
* Use draw clear on Adreno, instead of vkCmdClearAttachments

* Fix GTX TITAN detection
  • Loading branch information
gdkchan authored Jul 10, 2024
1 parent 1668ba9 commit 07435ad
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Ryujinx.Graphics.Vulkan/BackgroundResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public CommandBufferPool GetPool()
queue,
queueLock,
_gd.QueueFamilyIndex,
_gd.IsConcurrentFenceWaitUnsupported,
_gd.IsQualcommProprietary,
isLight: true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Graphics.Vulkan/PipelineBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ public void SetRasterizerDiscard(bool discard)
_newState.RasterizerDiscardEnable = discard;
SignalStateChange();

if (!discard && Gd.Vendor == Vendor.Qualcomm)
if (!discard && Gd.IsQualcommProprietary)
{
// On Adreno, enabling rasterizer discard somehow corrupts the viewport state.
// Force it to be updated on next use to work around this bug.
Expand Down
6 changes: 4 additions & 2 deletions src/Ryujinx.Graphics.Vulkan/PipelineFull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ public void ClearRenderTargetColor(int index, int layer, int layerCount, uint co
return;
}

if (componentMask != 0xf)
if (componentMask != 0xf || Gd.IsQualcommProprietary)
{
// We can't use CmdClearAttachments if not writing all components,
// because on Vulkan, the pipeline state does not affect clears.
// On proprietary Adreno drivers, CmdClearAttachments appears to execute out of order, so it's better to not use it at all.
var dstTexture = FramebufferParams.GetColorView(index);
if (dstTexture == null)
{
Expand Down Expand Up @@ -87,10 +88,11 @@ public void ClearRenderTargetDepthStencil(int layer, int layerCount, float depth
return;
}

if (stencilMask != 0 && stencilMask != 0xff)
if ((stencilMask != 0 && stencilMask != 0xff) || Gd.IsQualcommProprietary)
{
// We can't use CmdClearAttachments if not clearing all (mask is all ones, 0xFF) or none (mask is 0) of the stencil bits,
// because on Vulkan, the pipeline state does not affect clears.
// On proprietary Adreno drivers, CmdClearAttachments appears to execute out of order, so it's better to not use it at all.
var dstTexture = FramebufferParams.GetDepthStencilView();
if (dstTexture == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Ryujinx.Graphics.Vulkan/ShaderCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public ShaderCollection(
Templates = BuildTemplates(usePushDescriptors);

// Updating buffer texture bindings using template updates crashes the Adreno driver on Windows.
UpdateTexturesWithoutTemplate = gd.Vendor == Vendor.Qualcomm && usesBufferTextures;
UpdateTexturesWithoutTemplate = gd.IsQualcommProprietary && usesBufferTextures;

_compileTask = Task.CompletedTask;
_firstBackgroundUse = false;
Expand Down
12 changes: 6 additions & 6 deletions src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public sealed class VulkanRenderer : IRenderer
internal bool IsAmdGcn { get; private set; }
internal bool IsNvidiaPreTuring { get; private set; }
internal bool IsIntelArc { get; private set; }
internal bool IsQualcommProprietary { get; private set; }
internal bool IsMoltenVk { get; private set; }
internal bool IsTBDR { get; private set; }
internal bool IsSharedMemory { get; private set; }
internal bool IsConcurrentFenceWaitUnsupported { get; private set; }

public string GpuVendor { get; private set; }
public string GpuDriver { get; private set; }
Expand Down Expand Up @@ -325,8 +325,6 @@ private unsafe void LoadFeatures(uint maxQueueCount, uint queueFamilyIndex)
Vendor == Vendor.Broadcom ||
Vendor == Vendor.ImgTec;

IsConcurrentFenceWaitUnsupported = Vendor == Vendor.Qualcomm;

GpuVendor = VendorUtils.GetNameFromId(properties.VendorID);
GpuDriver = hasDriverProperties && !OperatingSystem.IsMacOS() ?
VendorUtils.GetFriendlyDriverName(driverProperties.DriverID) : GpuVendor; // Fallback to vendor name if driver is unavailable or on MacOS where vendor is preferred.
Expand All @@ -348,7 +346,7 @@ private unsafe void LoadFeatures(uint maxQueueCount, uint queueFamilyIndex)
{
IsNvidiaPreTuring = gpuNumber < 2000;
}
else if (GpuDriver.Contains("TITAN") && !GpuDriver.Contains("RTX"))
else if (GpuRenderer.Contains("TITAN") && !GpuRenderer.Contains("RTX"))
{
IsNvidiaPreTuring = true;
}
Expand All @@ -358,6 +356,8 @@ private unsafe void LoadFeatures(uint maxQueueCount, uint queueFamilyIndex)
IsIntelArc = GpuRenderer.StartsWith("Intel(R) Arc(TM)");
}

IsQualcommProprietary = hasDriverProperties && driverProperties.DriverID == DriverId.QualcommProprietary;

ulong minResourceAlignment = Math.Max(
Math.Max(
properties.Limits.MinStorageBufferOffsetAlignment,
Expand Down Expand Up @@ -415,7 +415,7 @@ private unsafe void LoadFeatures(uint maxQueueCount, uint queueFamilyIndex)
Api.TryGetDeviceExtension(_instance.Instance, _device, out ExtExternalMemoryHost hostMemoryApi);
HostMemoryAllocator = new HostMemoryAllocator(MemoryAllocator, Api, hostMemoryApi, _device);

CommandBufferPool = new CommandBufferPool(Api, _device, Queue, QueueLock, queueFamilyIndex, IsConcurrentFenceWaitUnsupported);
CommandBufferPool = new CommandBufferPool(Api, _device, Queue, QueueLock, queueFamilyIndex, IsQualcommProprietary);

PipelineLayoutCache = new PipelineLayoutCache();

Expand Down Expand Up @@ -692,7 +692,7 @@ public unsafe Capabilities GetCapabilities()
GpuVendor,
memoryType: memoryType,
hasFrontFacingBug: IsIntelWindows,
hasVectorIndexingBug: Vendor == Vendor.Qualcomm,
hasVectorIndexingBug: IsQualcommProprietary,
needsFragmentOutputSpecialization: IsMoltenVk,
reduceShaderPrecision: IsMoltenVk,
supportsAstcCompression: features2.Features.TextureCompressionAstcLdr && supportsAstcFormats,
Expand Down

0 comments on commit 07435ad

Please sign in to comment.