mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-12 21:59:12 +00:00
Make GSE and TFE work with SetBindingPair
This commit is contained in:
parent
0d79a84bcf
commit
53440e2e21
5 changed files with 44 additions and 26 deletions
|
@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
if (VertexAsCompute)
|
||||
{
|
||||
int vertexInfoCbBinding = ResourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = ResourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
int countFieldIndex = TranslatorContext.Stage == ShaderStage.Vertex
|
||||
? (int)VertexInfoBufferField.VertexCounts
|
||||
: (int)VertexInfoBufferField.GeometryCounts;
|
||||
|
@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
this.TextureSample(
|
||||
SamplerType.TextureBuffer,
|
||||
TextureFlags.IntCoords,
|
||||
ResourceManager.Reservations.IndexBufferTextureBinding,
|
||||
ResourceManager.Reservations.IndexBufferTextureSetBinding,
|
||||
1,
|
||||
new[] { vertexIndexVr },
|
||||
new[] { this.IAdd(ibBaseOffset, outputVertexOffset) });
|
||||
|
@ -144,7 +144,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
this.TextureSample(
|
||||
SamplerType.TextureBuffer,
|
||||
TextureFlags.IntCoords,
|
||||
ResourceManager.Reservations.TopologyRemapBufferTextureBinding,
|
||||
ResourceManager.Reservations.TopologyRemapBufferTextureSetBinding,
|
||||
1,
|
||||
new[] { vertexIndex },
|
||||
new[] { this.IAdd(baseVertex, Const(index)) });
|
||||
|
@ -283,7 +283,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
Operand offset = this.IAdd(baseOffset, Const(j));
|
||||
Operand value = Instructions.AttributeMap.GenerateAttributeLoad(this, null, location * 4, isOutput: true, isPerPatch: false);
|
||||
|
||||
int binding = ResourceManager.Reservations.GetTfeBufferStorageBufferBinding(tfbIndex);
|
||||
int binding = ResourceManager.Reservations.GetTfeBufferStorageBufferSetBinding(tfbIndex);
|
||||
|
||||
this.Store(StorageKind.StorageBuffer, binding, Const(0), offset, value);
|
||||
}
|
||||
|
@ -528,8 +528,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
{
|
||||
if (TranslatorContext.Stage == ShaderStage.Vertex)
|
||||
{
|
||||
int vertexInfoCbBinding = ResourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexOutputSbBinding = ResourceManager.Reservations.VertexOutputStorageBufferBinding;
|
||||
int vertexInfoCbBinding = ResourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
int vertexOutputSbBinding = ResourceManager.Reservations.VertexOutputStorageBufferSetBinding;
|
||||
int stride = ResourceManager.Reservations.OutputSizePerInvocation;
|
||||
|
||||
Operand vertexCount = this.Load(StorageKind.ConstantBuffer, vertexInfoCbBinding, Const((int)VertexInfoBufferField.VertexCounts), Const(0));
|
||||
|
@ -563,7 +563,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
this.BranchIfTrue(lblExit, this.ICompareGreaterOrEqualUnsigned(writtenIndices, Const(maxIndicesPerPrimitiveInvocation)));
|
||||
|
||||
int vertexInfoCbBinding = ResourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = ResourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
|
||||
Operand primitiveIndex = this.Load(StorageKind.Input, IoVariable.GlobalId, Const(0));
|
||||
Operand instanceIndex = this.Load(StorageKind.Input, IoVariable.GlobalId, Const(1));
|
||||
|
@ -574,7 +574,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
ibOffset = this.IAdd(ibOffset, this.IMultiply(invocationId, Const(maxIndicesPerPrimitiveInvocation)));
|
||||
ibOffset = this.IAdd(ibOffset, writtenIndices);
|
||||
|
||||
this.Store(StorageKind.StorageBuffer, ResourceManager.Reservations.GeometryIndexOutputStorageBufferBinding, Const(0), ibOffset, Const(-1));
|
||||
this.Store(StorageKind.StorageBuffer, ResourceManager.Reservations.GeometryIndexOutputStorageBufferSetBinding, Const(0), ibOffset, Const(-1));
|
||||
this.Store(StorageKind.LocalMemory, ResourceManager.LocalGeometryOutputIndexCountMemoryId, this.IAdd(writtenIndices, Const(1)));
|
||||
|
||||
this.Branch(lblLoopHead);
|
||||
|
|
|
@ -18,6 +18,13 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
public int IndexBufferTextureBinding { get; }
|
||||
public int TopologyRemapBufferTextureBinding { get; }
|
||||
|
||||
public int VertexInfoConstantBufferSetBinding => SetBindingPair.Pack(Constants.VkConstantBufferSetIndex, VertexInfoConstantBufferBinding);
|
||||
public int VertexOutputStorageBufferSetBinding => SetBindingPair.Pack(Constants.VkStorageBufferSetIndex, VertexOutputStorageBufferBinding);
|
||||
public int GeometryVertexOutputStorageBufferSetBinding => SetBindingPair.Pack(Constants.VkStorageBufferSetIndex, GeometryVertexOutputStorageBufferBinding);
|
||||
public int GeometryIndexOutputStorageBufferSetBinding => SetBindingPair.Pack(Constants.VkStorageBufferSetIndex, GeometryIndexOutputStorageBufferBinding);
|
||||
public int IndexBufferTextureSetBinding => SetBindingPair.Pack(Constants.VkTextureSetIndex, IndexBufferTextureBinding);
|
||||
public int TopologyRemapBufferTextureSetBinding => SetBindingPair.Pack(Constants.VkTextureSetIndex, TopologyRemapBufferTextureBinding);
|
||||
|
||||
public int ReservedConstantBuffers { get; }
|
||||
public int ReservedStorageBuffers { get; }
|
||||
public int ReservedTextures { get; }
|
||||
|
@ -149,7 +156,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return variable switch
|
||||
{
|
||||
IoVariable.ClipDistance or
|
||||
IoVariable.Position => true,
|
||||
IoVariable.Position or
|
||||
IoVariable.ViewportMask => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
@ -159,11 +167,21 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
return _tfeBufferSbBaseBinding + bufferIndex;
|
||||
}
|
||||
|
||||
public int GetTfeBufferStorageBufferSetBinding(int bufferIndex)
|
||||
{
|
||||
return SetBindingPair.Pack(Constants.VkStorageBufferSetIndex, _tfeBufferSbBaseBinding + bufferIndex);
|
||||
}
|
||||
|
||||
public int GetVertexBufferTextureBinding(int vaLocation)
|
||||
{
|
||||
return _vertexBufferTextureBaseBinding + vaLocation;
|
||||
}
|
||||
|
||||
public int GetVertexBufferTextureSetBinding(int vaLocation)
|
||||
{
|
||||
return SetBindingPair.Pack(Constants.VkTextureSetIndex, _vertexBufferTextureBaseBinding + vaLocation);
|
||||
}
|
||||
|
||||
internal bool TryGetOffset(StorageKind storageKind, int location, int component, out int offset)
|
||||
{
|
||||
return _offsets.TryGetValue(new IoDefinition(storageKind, IoVariable.UserDefined, location, component), out offset);
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
Instruction.Load,
|
||||
StorageKind.StorageBuffer,
|
||||
operation.Dest,
|
||||
new[] { Const(context.ResourceManager.Reservations.VertexOutputStorageBufferBinding), Const(0), vertexElemOffset }));
|
||||
new[] { Const(context.ResourceManager.Reservations.VertexOutputStorageBufferSetBinding), Const(0), vertexElemOffset }));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -123,8 +123,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
|
||||
private static LinkedListNode<INode> GenerateEmitVertex(ShaderDefinitions definitions, ResourceManager resourceManager, LinkedListNode<INode> node)
|
||||
{
|
||||
int vbOutputBinding = resourceManager.Reservations.GeometryVertexOutputStorageBufferBinding;
|
||||
int ibOutputBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferBinding;
|
||||
int vbOutputBinding = resourceManager.Reservations.GeometryVertexOutputStorageBufferSetBinding;
|
||||
int ibOutputBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferSetBinding;
|
||||
int stride = resourceManager.Reservations.OutputSizePerInvocation;
|
||||
|
||||
Operand outputPrimVertex = IncrementLocalMemory(node, resourceManager.LocalGeometryOutputVertexCountMemoryId);
|
||||
|
@ -189,7 +189,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
|
||||
private static LinkedListNode<INode> GenerateEndPrimitive(ShaderDefinitions definitions, ResourceManager resourceManager, LinkedListNode<INode> node)
|
||||
{
|
||||
int ibOutputBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferBinding;
|
||||
int ibOutputBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferSetBinding;
|
||||
|
||||
Operand outputPrimIndex = IncrementLocalMemory(node, resourceManager.LocalGeometryOutputIndexCountMemoryId);
|
||||
Operand baseIndexOffset = GenerateBaseOffset(
|
||||
|
@ -250,7 +250,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
int elementOffset,
|
||||
Operand primVertex)
|
||||
{
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
|
||||
Operand vertexCount = Local();
|
||||
node.List.AddBefore(node, new Operation(
|
||||
|
@ -303,7 +303,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
|
||||
private static LinkedListNode<INode> GeneratePrimitiveId(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
|
||||
{
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
|
||||
Operand vertexCount = Local();
|
||||
node.List.AddBefore(node, new Operation(
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
SamplerType.TextureBuffer,
|
||||
TextureFormat.Unknown,
|
||||
TextureFlags.IntCoords,
|
||||
context.ResourceManager.Reservations.GetVertexBufferTextureBinding(location),
|
||||
context.ResourceManager.Reservations.GetVertexBufferTextureSetBinding(location),
|
||||
1 << component,
|
||||
new[] { temp },
|
||||
new[] { vertexElemOffset }));
|
||||
|
@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
SamplerType.TextureBuffer,
|
||||
TextureFormat.Unknown,
|
||||
TextureFlags.IntCoords,
|
||||
context.ResourceManager.Reservations.GetVertexBufferTextureBinding(location),
|
||||
context.ResourceManager.Reservations.GetVertexBufferTextureSetBinding(location),
|
||||
1,
|
||||
new[] { temp },
|
||||
new[] { vertexElemOffset }));
|
||||
|
@ -151,7 +151,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
|
||||
private static Operand GenerateVertexOffset(ResourceManager resourceManager, LinkedListNode<INode> node, int location, int component)
|
||||
{
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
|
||||
Operand vertexIdVr = Local();
|
||||
GenerateVertexIdVertexRateLoad(resourceManager, node, vertexIdVr);
|
||||
|
@ -244,7 +244,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
Operand src)
|
||||
{
|
||||
Operand componentExists = Local();
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
node = node.List.AddAfter(node, new Operation(
|
||||
Instruction.Load,
|
||||
StorageKind.ConstantBuffer,
|
||||
|
@ -259,7 +259,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
|
||||
private static LinkedListNode<INode> GenerateBaseVertexLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
|
||||
{
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
|
||||
return node.List.AddBefore(node, new Operation(
|
||||
Instruction.Load,
|
||||
|
@ -270,7 +270,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Transforms
|
|||
|
||||
private static LinkedListNode<INode> GenerateBaseInstanceLoad(ResourceManager resourceManager, LinkedListNode<INode> node, Operand dest)
|
||||
{
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferBinding;
|
||||
int vertexInfoCbBinding = resourceManager.Reservations.VertexInfoConstantBufferSetBinding;
|
||||
|
||||
return node.List.AddBefore(node, new Operation(
|
||||
Instruction.Load,
|
||||
|
|
|
@ -505,11 +505,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
var reservations = GetResourceReservations();
|
||||
|
||||
int vertexInfoCbBinding = reservations.VertexInfoConstantBufferBinding;
|
||||
|
||||
if (Stage == ShaderStage.Vertex)
|
||||
{
|
||||
BufferDefinition vertexInfoBuffer = new(BufferLayout.Std140, 0, vertexInfoCbBinding, "vb_info", VertexInfoBuffer.GetStructureType());
|
||||
BufferDefinition vertexInfoBuffer = new(BufferLayout.Std140, 0, reservations.VertexInfoConstantBufferBinding, "vb_info", VertexInfoBuffer.GetStructureType());
|
||||
resourceManager.Properties.AddOrUpdateConstantBuffer(vertexInfoBuffer);
|
||||
}
|
||||
|
||||
|
@ -518,10 +516,12 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0)
|
||||
});
|
||||
|
||||
int vertexDataSbBinding = reservations.VertexOutputStorageBufferBinding;
|
||||
BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexDataSbBinding, "vb_input", vertexInputStruct);
|
||||
BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, reservations.VertexOutputStorageBufferBinding, "vb_input", vertexInputStruct);
|
||||
resourceManager.Properties.AddOrUpdateStorageBuffer(vertexOutputBuffer);
|
||||
|
||||
int vertexInfoCbBinding = reservations.VertexInfoConstantBufferSetBinding;
|
||||
int vertexDataSbBinding = reservations.VertexOutputStorageBufferSetBinding;
|
||||
|
||||
var context = new EmitterContext();
|
||||
|
||||
Operand vertexIndex = Options.TargetApi == TargetApi.OpenGL
|
||||
|
|
Loading…
Reference in a new issue