Use explicit buffer and texture bindings on shaders (#1666)
* Use explicit buffer and texture bindings on shaders * More XML docs and other nits
This commit is contained in:
parent
5561a3b95e
commit
8d168574eb
20 changed files with 496 additions and 551 deletions
|
@ -20,11 +20,13 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
public TranslationFlags Flags { get; }
|
||||
|
||||
public TranslationCounts Counts { get; }
|
||||
|
||||
public int Size { get; private set; }
|
||||
|
||||
public FeatureFlags UsedFeatures { get; private set; }
|
||||
|
||||
public ShaderConfig(IGpuAccessor gpuAccessor, TranslationFlags flags)
|
||||
public ShaderConfig(IGpuAccessor gpuAccessor, TranslationFlags flags, TranslationCounts counts)
|
||||
{
|
||||
Stage = ShaderStage.Compute;
|
||||
OutputTopology = OutputTopology.PointList;
|
||||
|
@ -38,9 +40,10 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
Flags = flags;
|
||||
Size = 0;
|
||||
UsedFeatures = FeatureFlags.None;
|
||||
Counts = counts;
|
||||
}
|
||||
|
||||
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
||||
public ShaderConfig(ShaderHeader header, IGpuAccessor gpuAccessor, TranslationFlags flags, TranslationCounts counts)
|
||||
{
|
||||
Stage = header.Stage;
|
||||
OutputTopology = header.OutputTopology;
|
||||
|
@ -54,6 +57,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
Flags = flags;
|
||||
Size = 0;
|
||||
UsedFeatures = FeatureFlags.None;
|
||||
Counts = counts;
|
||||
}
|
||||
|
||||
public int GetDepthRegister()
|
||||
|
|
30
Ryujinx.Graphics.Shader/Translation/TranslationCounts.cs
Normal file
30
Ryujinx.Graphics.Shader/Translation/TranslationCounts.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
namespace Ryujinx.Graphics.Shader.Translation
|
||||
{
|
||||
public class TranslationCounts
|
||||
{
|
||||
public int UniformBuffersCount { get; private set; }
|
||||
public int StorageBuffersCount { get; private set; }
|
||||
public int TexturesCount { get; private set; }
|
||||
public int ImagesCount { get; private set; }
|
||||
|
||||
internal int IncrementUniformBuffersCount()
|
||||
{
|
||||
return UniformBuffersCount++;
|
||||
}
|
||||
|
||||
internal int IncrementStorageBuffersCount()
|
||||
{
|
||||
return StorageBuffersCount++;
|
||||
}
|
||||
|
||||
internal int IncrementTexturesCount()
|
||||
{
|
||||
return TexturesCount++;
|
||||
}
|
||||
|
||||
internal int IncrementImagesCount()
|
||||
{
|
||||
return ImagesCount++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,15 +24,28 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
}
|
||||
}
|
||||
|
||||
public static ShaderProgram Translate(ulong address, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
||||
public static ShaderProgram Translate(
|
||||
ulong address,
|
||||
IGpuAccessor gpuAccessor,
|
||||
TranslationFlags flags,
|
||||
TranslationCounts counts = null)
|
||||
{
|
||||
return Translate(DecodeShader(address, gpuAccessor, flags, out ShaderConfig config), config);
|
||||
counts ??= new TranslationCounts();
|
||||
|
||||
return Translate(DecodeShader(address, gpuAccessor, flags, counts, out ShaderConfig config), config);
|
||||
}
|
||||
|
||||
public static ShaderProgram Translate(ulong addressA, ulong addressB, IGpuAccessor gpuAccessor, TranslationFlags flags)
|
||||
public static ShaderProgram Translate(
|
||||
ulong addressA,
|
||||
ulong addressB,
|
||||
IGpuAccessor gpuAccessor,
|
||||
TranslationFlags flags,
|
||||
TranslationCounts counts = null)
|
||||
{
|
||||
FunctionCode[] funcA = DecodeShader(addressA, gpuAccessor, flags | TranslationFlags.VertexA, out ShaderConfig configA);
|
||||
FunctionCode[] funcB = DecodeShader(addressB, gpuAccessor, flags, out ShaderConfig config);
|
||||
counts ??= new TranslationCounts();
|
||||
|
||||
FunctionCode[] funcA = DecodeShader(addressA, gpuAccessor, flags | TranslationFlags.VertexA, counts, out ShaderConfig configA);
|
||||
FunctionCode[] funcB = DecodeShader(addressB, gpuAccessor, flags, counts, out ShaderConfig config);
|
||||
|
||||
config.SetUsedFeature(configA.UsedFeatures);
|
||||
|
||||
|
@ -105,19 +118,24 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return new ShaderProgram(spInfo, config.Stage, glslCode, config.Size, sizeA);
|
||||
}
|
||||
|
||||
private static FunctionCode[] DecodeShader(ulong address, IGpuAccessor gpuAccessor, TranslationFlags flags, out ShaderConfig config)
|
||||
private static FunctionCode[] DecodeShader(
|
||||
ulong address,
|
||||
IGpuAccessor gpuAccessor,
|
||||
TranslationFlags flags,
|
||||
TranslationCounts counts,
|
||||
out ShaderConfig config)
|
||||
{
|
||||
Block[][] cfg;
|
||||
|
||||
if ((flags & TranslationFlags.Compute) != 0)
|
||||
{
|
||||
config = new ShaderConfig(gpuAccessor, flags);
|
||||
config = new ShaderConfig(gpuAccessor, flags, counts);
|
||||
|
||||
cfg = Decoder.Decode(gpuAccessor, address);
|
||||
}
|
||||
else
|
||||
{
|
||||
config = new ShaderConfig(new ShaderHeader(gpuAccessor, address), gpuAccessor, flags);
|
||||
config = new ShaderConfig(new ShaderHeader(gpuAccessor, address), gpuAccessor, flags, counts);
|
||||
|
||||
cfg = Decoder.Decode(gpuAccessor, address + HeaderSize);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue