mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-12 16:31:06 +01:00
484eb645ae
* Initial implementation of Render Target Scaling Works with most games I have. No GUI option right now, it is hardcoded. Missing handling for texelFetch operation. * Realtime Configuration, refactoring. * texelFetch scaling on fragment shader (WIP) * Improve Shader-Side changes. * Fix potential crash when no color/depth bound * Workaround random uses of textures in compute. This was blacklisting textures in a few games despite causing no bugs. Will eventually add full support so this doesn't break anything. * Fix scales oscillating when changing between non-native scales. * Scaled textures on compute, cleanup, lazier uniform update. * Cleanup. * Fix stupidity * Address Thog Feedback. * Cover most of GDK's feedback (two comments remain) * Fix bad rename * Move IsDepthStencil to FormatExtensions, add docs. * Fix default config, square texture detection. * Three final fixes: - Nearest copy when texture is integer format. - Texture2D -> Texture3D copy correctly blacklists the texture before trying an unscaled copy (caused driver error) - Discount small textures. * Remove scale threshold. Not needed right now - we'll see if we run into problems. * All CPU modification blacklists scale. * Fix comment.
97 lines
3.1 KiB
C#
97 lines
3.1 KiB
C#
using System;
|
|
|
|
namespace Ryujinx.Graphics.Shader.Translation
|
|
{
|
|
struct ShaderConfig
|
|
{
|
|
public ShaderStage Stage { get; }
|
|
|
|
public OutputTopology OutputTopology { get; }
|
|
|
|
public int MaxOutputVertices { get; }
|
|
|
|
public int LocalMemorySize { get; }
|
|
|
|
public ImapPixelType[] ImapTypes { get; }
|
|
|
|
public OmapTarget[] OmapTargets { get; }
|
|
public bool OmapSampleMask { get; }
|
|
public bool OmapDepth { get; }
|
|
|
|
public IGpuAccessor GpuAccessor { get; }
|
|
|
|
public TranslationFlags Flags { get; }
|
|
|
|
public FeatureFlags UsedFeatures { get; set; }
|
|
|
|
public ShaderConfig(IGpuAccessor gpuAccessor, TranslationFlags flags)
|
|
{
|
|
Stage = ShaderStage.Compute;
|
|
OutputTopology = OutputTopology.PointList;
|
|
MaxOutputVertices = 0;
|
|
LocalMemorySize = 0;
|
|
ImapTypes = null;
|
|
OmapTargets = null;
|
|
OmapSampleMask = false;
|
|
OmapDepth = false;
|
|
GpuAccessor = gpuAccessor;
|
|
Flags = flags;
|
|
UsedFeatures = FeatureFlags.None;
|
|
}
|
|
|
|
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
|
{
|
|
Stage = header.Stage;
|
|
OutputTopology = header.OutputTopology;
|
|
MaxOutputVertices = header.MaxOutputVertexCount;
|
|
LocalMemorySize = header.ShaderLocalMemoryLowSize + header.ShaderLocalMemoryHighSize;
|
|
ImapTypes = header.ImapTypes;
|
|
OmapTargets = header.OmapTargets;
|
|
OmapSampleMask = header.OmapSampleMask;
|
|
OmapDepth = header.OmapDepth;
|
|
GpuAccessor = gpuAccessor;
|
|
Flags = flags;
|
|
UsedFeatures = FeatureFlags.None;
|
|
}
|
|
|
|
public int GetDepthRegister()
|
|
{
|
|
int count = 0;
|
|
|
|
for (int index = 0; index < OmapTargets.Length; index++)
|
|
{
|
|
for (int component = 0; component < 4; component++)
|
|
{
|
|
if (OmapTargets[index].ComponentEnabled(component))
|
|
{
|
|
count++;
|
|
}
|
|
}
|
|
}
|
|
|
|
// The depth register is always two registers after the last color output.
|
|
return count + 1;
|
|
}
|
|
|
|
public TextureFormat GetTextureFormat(int handle)
|
|
{
|
|
// When the formatted load extension is supported, we don't need to
|
|
// specify a format, we can just declare it without a format and the GPU will handle it.
|
|
if (GpuAccessor.QuerySupportsImageLoadFormatted())
|
|
{
|
|
return TextureFormat.Unknown;
|
|
}
|
|
|
|
var format = GpuAccessor.QueryTextureFormat(handle);
|
|
|
|
if (format == TextureFormat.Unknown)
|
|
{
|
|
GpuAccessor.Log($"Unknown format for texture {handle}.");
|
|
|
|
format = TextureFormat.R8G8B8A8Unorm;
|
|
}
|
|
|
|
return format;
|
|
}
|
|
}
|
|
} |