Skip to content

Commit

Permalink
Merge branch 'ava-11' of https://github.com/IsaacMarovitz/Ryujinx int…
Browse files Browse the repository at this point in the history
…o pr/4362
  • Loading branch information
emmauss committed Apr 27, 2023
2 parents 270366d + c6bd062 commit 7fbaf4e
Show file tree
Hide file tree
Showing 64 changed files with 1,992 additions and 1,775 deletions.
2 changes: 1 addition & 1 deletion Ryujinx.Ava/UI/Controls/GameGridView.axaml
Expand Up @@ -158,7 +158,7 @@
VerticalAlignment="Stretch"
IsVisible="{ReflectionBinding $parent[UserControl].DataContext.ShowNames}">
<TextBlock
HorizontalAlignment="Stretch"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{ReflectionBinding TitleName}"
TextAlignment="Center"
Expand Down
10 changes: 5 additions & 5 deletions Ryujinx.Ava/UI/ViewModels/MainWindowViewModel.cs
Expand Up @@ -1095,23 +1095,23 @@ private async Task HandleFirmwareInstallation(string filename)
}));
}

private async void ExtractLogo()
public async void ExtractLogo()
{
if (SelectedApplication != null)
{
await ApplicationHelper.ExtractSection(NcaSectionType.Logo, SelectedApplication.Path, SelectedApplication.TitleName, StorageProvider);
}
}

private async void ExtractRomFs()
public async void ExtractRomFs()
{
if (SelectedApplication != null)
{
await ApplicationHelper.ExtractSection(NcaSectionType.Data, SelectedApplication.Path, SelectedApplication.TitleName, StorageProvider);
}
}

private async void ExtractExeFs()
public async void ExtractExeFs()
{
if (SelectedApplication != null)
{
Expand Down Expand Up @@ -1307,12 +1307,12 @@ public async void InstallFirmwareFromFolder()
}
}

public static void OpenRyujinxFolder()
public void OpenRyujinxFolder()
{
OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
}

public static void OpenLogsFolder()
public void OpenLogsFolder()
{
string logPath = Path.Combine(ReleaseInformation.GetBaseApplicationDirectory(), "Logs");

Expand Down
2 changes: 1 addition & 1 deletion Ryujinx.Ava/UI/Views/User/UserSelectorView.axaml
Expand Up @@ -78,7 +78,7 @@
VerticalAlignment="Top"
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
<TextBlock
HorizontalAlignment="Stretch"
HorizontalAlignment="Center"
MaxWidth="90"
Text="{Binding Name}"
TextAlignment="Center"
Expand Down
9 changes: 6 additions & 3 deletions Ryujinx.Graphics.GAL/Capabilities.cs
Expand Up @@ -35,7 +35,8 @@ namespace Ryujinx.Graphics.GAL
public readonly bool SupportsNonConstantTextureOffset;
public readonly bool SupportsShaderBallot;
public readonly bool SupportsTextureShadowLod;
public readonly bool SupportsViewportIndex;
public readonly bool SupportsViewportIndexVertexTessellation;
public readonly bool SupportsViewportMask;
public readonly bool SupportsViewportSwizzle;
public readonly bool SupportsIndirectParameters;

Expand Down Expand Up @@ -80,7 +81,8 @@ namespace Ryujinx.Graphics.GAL
bool supportsNonConstantTextureOffset,
bool supportsShaderBallot,
bool supportsTextureShadowLod,
bool supportsViewportIndex,
bool supportsViewportIndexVertexTessellation,
bool supportsViewportMask,
bool supportsViewportSwizzle,
bool supportsIndirectParameters,
uint maximumUniformBuffersPerStage,
Expand Down Expand Up @@ -121,7 +123,8 @@ namespace Ryujinx.Graphics.GAL
SupportsNonConstantTextureOffset = supportsNonConstantTextureOffset;
SupportsShaderBallot = supportsShaderBallot;
SupportsTextureShadowLod = supportsTextureShadowLod;
SupportsViewportIndex = supportsViewportIndex;
SupportsViewportIndexVertexTessellation = supportsViewportIndexVertexTessellation;
SupportsViewportMask = supportsViewportMask;
SupportsViewportSwizzle = supportsViewportSwizzle;
SupportsIndirectParameters = supportsIndirectParameters;
MaximumUniformBuffersPerStage = maximumUniformBuffersPerStage;
Expand Down
Expand Up @@ -22,7 +22,7 @@ class DiskCacheHostStorage
private const ushort FileFormatVersionMajor = 1;
private const ushort FileFormatVersionMinor = 2;
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
private const uint CodeGenVersion = 4707;
private const uint CodeGenVersion = 4735;

private const string SharedTocFileName = "shared.toc";
private const string SharedDataFileName = "shared.data";
Expand Down
4 changes: 3 additions & 1 deletion Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
Expand Up @@ -144,7 +144,9 @@ private int GetStageIndex()

public bool QueryHostSupportsTextureShadowLod() => _context.Capabilities.SupportsTextureShadowLod;

public bool QueryHostSupportsViewportIndex() => _context.Capabilities.SupportsViewportIndex;
public bool QueryHostSupportsViewportIndexVertexTessellation() => _context.Capabilities.SupportsViewportIndexVertexTessellation;

public bool QueryHostSupportsViewportMask() => _context.Capabilities.SupportsViewportMask;

/// <summary>
/// Converts a packed Maxwell texture format to the shader translator texture format.
Expand Down
2 changes: 2 additions & 0 deletions Ryujinx.Graphics.OpenGL/HwCapabilities.cs
Expand Up @@ -20,6 +20,7 @@ static class HwCapabilities
private static readonly Lazy<bool> _supportsSeamlessCubemapPerTexture = new Lazy<bool>(() => HasExtension("GL_ARB_seamless_cubemap_per_texture"));
private static readonly Lazy<bool> _supportsShaderBallot = new Lazy<bool>(() => HasExtension("GL_ARB_shader_ballot"));
private static readonly Lazy<bool> _supportsShaderViewportLayerArray = new Lazy<bool>(() => HasExtension("GL_ARB_shader_viewport_layer_array"));
private static readonly Lazy<bool> _supportsViewportArray2 = new Lazy<bool>(() => HasExtension("GL_NV_viewport_array2"));
private static readonly Lazy<bool> _supportsTextureCompressionBptc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_bptc"));
private static readonly Lazy<bool> _supportsTextureCompressionRgtc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_rgtc"));
private static readonly Lazy<bool> _supportsTextureCompressionS3tc = new Lazy<bool>(() => HasExtension("GL_EXT_texture_compression_s3tc"));
Expand Down Expand Up @@ -65,6 +66,7 @@ public enum GpuVendor
public static bool SupportsSeamlessCubemapPerTexture => _supportsSeamlessCubemapPerTexture.Value;
public static bool SupportsShaderBallot => _supportsShaderBallot.Value;
public static bool SupportsShaderViewportLayerArray => _supportsShaderViewportLayerArray.Value;
public static bool SupportsViewportArray2 => _supportsViewportArray2.Value;
public static bool SupportsTextureCompressionBptc => _supportsTextureCompressionBptc.Value;
public static bool SupportsTextureCompressionRgtc => _supportsTextureCompressionRgtc.Value;
public static bool SupportsTextureCompressionS3tc => _supportsTextureCompressionS3tc.Value;
Expand Down
3 changes: 2 additions & 1 deletion Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs
Expand Up @@ -136,7 +136,8 @@ public Capabilities GetCapabilities()
supportsNonConstantTextureOffset: HwCapabilities.SupportsNonConstantTextureOffset,
supportsShaderBallot: HwCapabilities.SupportsShaderBallot,
supportsTextureShadowLod: HwCapabilities.SupportsTextureShadowLod,
supportsViewportIndex: HwCapabilities.SupportsShaderViewportLayerArray,
supportsViewportIndexVertexTessellation: HwCapabilities.SupportsShaderViewportLayerArray,
supportsViewportMask: HwCapabilities.SupportsViewportArray2,
supportsViewportSwizzle: HwCapabilities.SupportsViewportSwizzle,
supportsIndirectParameters: HwCapabilities.SupportsIndirectParameters,
maximumUniformBuffersPerStage: 13, // TODO: Avoid hardcoding those limits here and get from driver?
Expand Down
35 changes: 26 additions & 9 deletions Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs
Expand Up @@ -59,6 +59,11 @@ public static void Declare(CodeGenContext context, StructuredProgramInfo info)
context.AppendLine("#extension GL_NV_geometry_shader_passthrough : enable");
}

if (context.Config.GpuAccessor.QueryHostSupportsViewportMask())
{
context.AppendLine("#extension GL_NV_viewport_array2 : enable");
}

context.AppendLine("#pragma optionNV(fastmath off)");
context.AppendLine();

Expand Down Expand Up @@ -215,7 +220,7 @@ public static void Declare(CodeGenContext context, StructuredProgramInfo info)

if (context.Config.TransformFeedbackEnabled && context.Config.LastInVertexPipeline)
{
var tfOutput = context.Info.GetTransformFeedbackOutput(AttributeConsts.PositionX);
var tfOutput = context.Config.GetTransformFeedbackOutput(AttributeConsts.PositionX);
if (tfOutput.Valid)
{
context.AppendLine($"layout (xfb_buffer = {tfOutput.Buffer}, xfb_offset = {tfOutput.Offset}, xfb_stride = {tfOutput.Stride}) out gl_PerVertex");
Expand Down Expand Up @@ -552,7 +557,7 @@ private static void DeclareInputAttributesPerPatch(CodeGenContext context, HashS

private static void DeclareInputAttribute(CodeGenContext context, StructuredProgramInfo info, int attr)
{
string suffix = AttributeInfo.IsArrayAttributeGlsl(context.Config.Stage, isOutAttr: false) ? "[]" : string.Empty;
string suffix = IsArrayAttributeGlsl(context.Config.Stage, isOutAttr: false) ? "[]" : string.Empty;
string iq = string.Empty;

if (context.Config.Stage == ShaderStage.Fragment)
Expand All @@ -569,8 +574,7 @@ private static void DeclareInputAttribute(CodeGenContext context, StructuredProg

if (context.Config.TransformFeedbackEnabled && context.Config.Stage == ShaderStage.Fragment)
{
int attrOffset = AttributeConsts.UserAttributeBase + attr * 16;
int components = context.Info.GetTransformFeedbackOutputComponents(attrOffset);
int components = context.Config.GetTransformFeedbackOutputComponents(attr, 0);

if (components > 1)
{
Expand Down Expand Up @@ -652,13 +656,12 @@ private static void DeclareOutputAttributes(CodeGenContext context, StructuredPr

private static void DeclareOutputAttribute(CodeGenContext context, int attr)
{
string suffix = AttributeInfo.IsArrayAttributeGlsl(context.Config.Stage, isOutAttr: true) ? "[]" : string.Empty;
string suffix = IsArrayAttributeGlsl(context.Config.Stage, isOutAttr: true) ? "[]" : string.Empty;
string name = $"{DefaultNames.OAttributePrefix}{attr}{suffix}";

if (context.Config.TransformFeedbackEnabled && context.Config.LastInVertexPipeline)
{
int attrOffset = AttributeConsts.UserAttributeBase + attr * 16;
int components = context.Info.GetTransformFeedbackOutputComponents(attrOffset);
int components = context.Config.GetTransformFeedbackOutputComponents(attr, 0);

if (components > 1)
{
Expand All @@ -672,7 +675,7 @@ private static void DeclareOutputAttribute(CodeGenContext context, int attr)

string xfb = string.Empty;

var tfOutput = context.Info.GetTransformFeedbackOutput(attrOffset);
var tfOutput = context.Config.GetTransformFeedbackOutput(attr, 0);
if (tfOutput.Valid)
{
xfb = $", xfb_buffer = {tfOutput.Buffer}, xfb_offset = {tfOutput.Offset}, xfb_stride = {tfOutput.Stride}";
Expand All @@ -687,7 +690,7 @@ private static void DeclareOutputAttribute(CodeGenContext context, int attr)

string xfb = string.Empty;

var tfOutput = context.Info.GetTransformFeedbackOutput(attrOffset + c * 4);
var tfOutput = context.Config.GetTransformFeedbackOutput(attr, c);
if (tfOutput.Valid)
{
xfb = $", xfb_buffer = {tfOutput.Buffer}, xfb_offset = {tfOutput.Offset}, xfb_stride = {tfOutput.Stride}";
Expand Down Expand Up @@ -726,6 +729,20 @@ private static void DeclareOutputDualSourceBlendAttribute(CodeGenContext context
context.AppendLine($"layout (location = {attr}, index = 1) out vec4 {name2};");
}

private static bool IsArrayAttributeGlsl(ShaderStage stage, bool isOutAttr)
{
if (isOutAttr)
{
return stage == ShaderStage.TessellationControl;
}
else
{
return stage == ShaderStage.TessellationControl ||
stage == ShaderStage.TessellationEvaluation ||
stage == ShaderStage.Geometry;
}
}

private static void DeclareUsedOutputAttributesPerPatch(CodeGenContext context, HashSet<int> attrs)
{
foreach (int attr in attrs.Order())
Expand Down
16 changes: 2 additions & 14 deletions Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs
@@ -1,5 +1,4 @@
using Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions;
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
using Ryujinx.Graphics.Shader.StructuredIr;
using Ryujinx.Graphics.Shader.Translation;
using System;
Expand Down Expand Up @@ -126,21 +125,10 @@ private static void PrintBlock(CodeGenContext context, AstBlock block)
}
else if (node is AstAssignment assignment)
{
AggregateType dstType = OperandManager.GetNodeDestType(context, assignment.Destination);
AggregateType srcType = OperandManager.GetNodeDestType(context, assignment.Source);
AggregateType dstType = OperandManager.GetNodeDestType(context, assignment.Destination, isAsgDest: true);

string dest;

if (assignment.Destination is AstOperand operand && operand.Type.IsAttribute())
{
bool perPatch = operand.Type == OperandType.AttributePerPatch;
dest = OperandManager.GetOutAttributeName(context, operand.Value, perPatch);
}
else
{
dest = InstGen.GetExpression(context, assignment.Destination);
}

string dest = InstGen.GetExpression(context, assignment.Destination);
string src = ReinterpretCast(context, assignment.Source, srcType, dstType);

context.AppendLine(dest + " = " + src + ";");
Expand Down
20 changes: 9 additions & 11 deletions Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs
Expand Up @@ -73,7 +73,7 @@ private static string GetExpression(CodeGenContext context, AstOperation operati
// For shared memory access, the second argument is unused and should be ignored.
// It is there to make both storage and shared access have the same number of arguments.
// For storage, both inputs are consumed when the argument index is 0, so we should skip it here.
if (argIndex == 1 && (atomic || (inst & Instruction.MrMask) == Instruction.MrShared))
if (argIndex == 1 && (atomic || operation.StorageKind == StorageKind.SharedMemory))
{
continue;
}
Expand All @@ -85,14 +85,12 @@ private static string GetExpression(CodeGenContext context, AstOperation operati

if (argIndex == 0 && atomic)
{
Instruction memRegion = inst & Instruction.MrMask;

switch (memRegion)
switch (operation.StorageKind)
{
case Instruction.MrShared: args += LoadShared(context, operation); break;
case Instruction.MrStorage: args += LoadStorage(context, operation); break;
case StorageKind.SharedMemory: args += LoadShared(context, operation); break;
case StorageKind.StorageBuffer: args += LoadStorage(context, operation); break;

default: throw new InvalidOperationException($"Invalid memory region \"{memRegion}\".");
default: throw new InvalidOperationException($"Invalid storage kind \"{operation.StorageKind}\".");
}
}
else
Expand Down Expand Up @@ -166,8 +164,8 @@ private static string GetExpression(CodeGenContext context, AstOperation operati
case Instruction.ImageAtomic:
return ImageLoadOrStore(context, operation);

case Instruction.LoadAttribute:
return LoadAttribute(context, operation);
case Instruction.Load:
return Load(context, operation);

case Instruction.LoadConstant:
return LoadConstant(context, operation);
Expand All @@ -193,8 +191,8 @@ private static string GetExpression(CodeGenContext context, AstOperation operati
case Instruction.PackHalf2x16:
return PackHalf2x16(context, operation);

case Instruction.StoreAttribute:
return StoreAttribute(context, operation);
case Instruction.Store:
return Store(context, operation);

case Instruction.StoreLocal:
return StoreLocal(context, operation);
Expand Down
Expand Up @@ -82,7 +82,7 @@ static InstGenHelper()
Add(Instruction.ImageStore, InstType.Special);
Add(Instruction.ImageAtomic, InstType.Special);
Add(Instruction.IsNan, InstType.CallUnary, "isnan");
Add(Instruction.LoadAttribute, InstType.Special);
Add(Instruction.Load, InstType.Special);
Add(Instruction.LoadConstant, InstType.Special);
Add(Instruction.LoadLocal, InstType.Special);
Add(Instruction.LoadShared, InstType.Special);
Expand Down Expand Up @@ -118,7 +118,7 @@ static InstGenHelper()
Add(Instruction.ShuffleXor, InstType.CallQuaternary, HelperFunctionNames.ShuffleXor);
Add(Instruction.Sine, InstType.CallUnary, "sin");
Add(Instruction.SquareRoot, InstType.CallUnary, "sqrt");
Add(Instruction.StoreAttribute, InstType.Special);
Add(Instruction.Store, InstType.Special);
Add(Instruction.StoreLocal, InstType.Special);
Add(Instruction.StoreShared, InstType.Special);
Add(Instruction.StoreShared16, InstType.Special);
Expand Down

0 comments on commit 7fbaf4e

Please sign in to comment.