Add support for shader constant buffer slot indexing (#1608)

* Add support for shader constant buffer slot indexing

* Fix typo
This commit is contained in:
gdkchan 2020-10-12 21:40:50 -03:00 committed by GitHub
parent 14fd9aa640
commit b066cfc1a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 207 additions and 66 deletions

View file

@ -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());
context.Info.CBuffers.Add(slot.Value);
for (int index = 0; index < cbCount; index++)
{
context.Info.CBuffers.Add(index);
}
context.Info.UsesCbIndexing = true;
}
}
else if (UsesStorage(inst))
{