Fix SpirV parse failure (#3597)

* Added .ToString overrides, to help diagnose and debug SpirV generated code.

* Added Spirv to team shared dictionary, so the word will not show up as a warning.

* Fixed bug where we were creating invalid constants (bool 0i and float 0i)

* Update Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Update Spv.Generator/Instruction.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Adjusted spacing to match style of the rest of the code.

* Added handler for FP64(double) as well, for undefined aggregate types.

* Made the operand labels a static dictionary, to avoid re-allocation on each call.
Replaced Contains/Get with a TryGetValue, to reduce the number of dictionary lookups.

* Added newline between AllOperands and ToString().

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
This commit is contained in:
Nicholas Rodine 2022-08-17 18:49:43 -05:00 committed by GitHub
parent 2197f41506
commit 80a879cb44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 1 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -228,5 +229,19 @@ namespace Spv.Generator
{
return obj is Instruction instruction && Equals(instruction);
}
private static readonly Dictionary<Specification.Op, string[]> _operandLabels = new()
{
{ Specification.Op.OpConstant, new [] { "Value" } },
{ Specification.Op.OpTypeInt, new [] { "Width", "Signed" } },
{ Specification.Op.OpTypeFloat, new [] { "Width" } }
};
public override string ToString()
{
var labels = _operandLabels.TryGetValue(Opcode, out var opLabels) ? opLabels : Array.Empty<string>();
var result = _resultType == null ? string.Empty : $"{_resultType} ";
return $"{result}{Opcode}{_operands.ToString(labels)}";
}
}
}