diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2020-10-12 21:40:50 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-12 21:40:50 -0300 |
| commit | b066cfc1a3e31bf7197ddbd0f4d774b886cd9d65 (patch) | |
| tree | 95a1d0bb640948c184857fd1bccb56cad90839fb /Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs | |
| parent | 14fd9aa640936d2455c9f0929fc904a5bdb2fada (diff) | |
Add support for shader constant buffer slot indexing (#1608)
* Add support for shader constant buffer slot indexing
* Fix typo
Diffstat (limited to 'Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs')
| -rw-r--r-- | Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs index f1dd08f2..65de5218 100644 --- a/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs +++ b/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs @@ -2,6 +2,7 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System; using System.Collections.Generic; +using System.Numerics; namespace Ryujinx.Graphics.Shader.StructuredIr { @@ -73,12 +74,24 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { Operand slot = operation.GetSource(0); - if (slot.Type != OperandType.Constant) + if (slot.Type == OperandType.Constant) { - throw new InvalidOperationException("Found load with non-constant constant buffer slot."); + context.Info.CBuffers.Add(slot.Value); } + else + { + // If the value is not constant, then we don't know + // how many constant buffers are used, so we assume + // all of them are used. + int cbCount = 32 - BitOperations.LeadingZeroCount(context.Config.GpuAccessor.QueryConstantBufferUse()); + + for (int index = 0; index < cbCount; index++) + { + context.Info.CBuffers.Add(index); + } - context.Info.CBuffers.Add(slot.Value); + context.Info.UsesCbIndexing = true; + } } else if (UsesStorage(inst)) { |
