misc: chore: Fix object creation in Shader project

This commit is contained in:
Evan Husted 2025-01-26 15:22:30 -06:00
parent 7f5a356c3d
commit ccef0b49eb
10 changed files with 37 additions and 37 deletions

View File

@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isArray = (texOp.Type & SamplerType.Array) != 0;
StringBuilder texCallBuilder = new StringBuilder(); StringBuilder texCallBuilder = new();
if (texOp.Inst == Instruction.ImageAtomic) if (texOp.Inst == Instruction.ImageAtomic)
{ {

View File

@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isArray = (texOp.Type & SamplerType.Array) != 0;
StringBuilder texCallBuilder = new StringBuilder(); StringBuilder texCallBuilder = new();
int srcIndex = 0; int srcIndex = 0;
@ -194,7 +194,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
texCallBuilder.Append('('); texCallBuilder.Append('(');
StringBuilder coordsBuilder = new StringBuilder(); StringBuilder coordsBuilder = new();
int coordsCount = texOp.Type.GetDimensions(); int coordsCount = texOp.Type.GetDimensions();
@ -352,7 +352,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isArray = (texOp.Type & SamplerType.Array) != 0;
bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; bool isShadow = (texOp.Type & SamplerType.Shadow) != 0;
StringBuilder texCallBuilder = new StringBuilder(); StringBuilder texCallBuilder = new();
bool colorIsVector = isGather || !isShadow; bool colorIsVector = isGather || !isShadow;
@ -589,7 +589,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
{ {
AstTextureOperation texOp = (AstTextureOperation)operation; AstTextureOperation texOp = (AstTextureOperation)operation;
StringBuilder texCallBuilder = new StringBuilder(); StringBuilder texCallBuilder = new();
int srcIndex = 0; int srcIndex = 0;

View File

@ -176,7 +176,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
} }
string funcPrefix = $"{funcKeyword} {returnType} {funcName ?? function.Name}("; string funcPrefix = $"{funcKeyword} {returnType} {funcName ?? function.Name}(";
string indent = new string(' ', funcPrefix.Length); string indent = new(' ', funcPrefix.Length);
return $"{funcPrefix}{string.Join($", \n{indent}", args)})"; return $"{funcPrefix}{string.Join($", \n{indent}", args)})";
} }

View File

@ -147,7 +147,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
public Instruction[] GetMainInterface() public Instruction[] GetMainInterface()
{ {
List<Instruction> mainInterface = new List<Instruction>(); List<Instruction> mainInterface = new();
mainInterface.AddRange(Inputs.Values); mainInterface.AddRange(Inputs.Values);
mainInterface.AddRange(Outputs.Values); mainInterface.AddRange(Outputs.Values);

View File

@ -1327,7 +1327,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
compIdx = Src(AggregateType.S32); compIdx = Src(AggregateType.S32);
} }
List<SpvInstruction> operandsList = new List<SpvInstruction>(); List<SpvInstruction> operandsList = new();
ImageOperandsMask operandsMask = ImageOperandsMask.MaskNone; ImageOperandsMask operandsMask = ImageOperandsMask.MaskNone;
if (hasLodBias) if (hasLodBias)
@ -1754,7 +1754,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
storageClass = isOutput ? StorageClass.Output : StorageClass.Input; storageClass = isOutput ? StorageClass.Output : StorageClass.Input;
IoDefinition ioDefinition = new IoDefinition(storageKind, ioVariable, location, component); IoDefinition ioDefinition = new(storageKind, ioVariable, location, component);
Dictionary<IoDefinition, SpvInstruction> dict = isPerPatch Dictionary<IoDefinition, SpvInstruction> dict = isPerPatch
? (isOutput ? context.OutputsPerPatch : context.InputsPerPatch) ? (isOutput ? context.OutputsPerPatch : context.InputsPerPatch)
: (isOutput ? context.Outputs : context.Inputs); : (isOutput ? context.Outputs : context.Inputs);
@ -1843,7 +1843,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
(_, AggregateType varType) = IoMap.GetSpirvBuiltIn(ioVariable); (_, AggregateType varType) = IoMap.GetSpirvBuiltIn(ioVariable);
varType &= AggregateType.ElementTypeMask; varType &= AggregateType.ElementTypeMask;
IoDefinition ioDefinition = new IoDefinition(StorageKind.Input, ioVariable); IoDefinition ioDefinition = new(StorageKind.Input, ioVariable);
return context.Load(context.GetType(varType), context.Inputs[ioDefinition]); return context.Load(context.GetType(varType), context.Inputs[ioDefinition]);
} }

View File

@ -307,7 +307,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
{ {
AstBlockVisitor visitor = new(block); AstBlockVisitor visitor = new(block);
Dictionary<AstBlock, (SpvInstruction, SpvInstruction)> loopTargets = new Dictionary<AstBlock, (SpvInstruction, SpvInstruction)>(); Dictionary<AstBlock, (SpvInstruction, SpvInstruction)> loopTargets = new();
context.LoopTargets = loopTargets; context.LoopTargets = loopTargets;

View File

@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
private static IReadOnlyDictionary<int, AttributeEntry> CreateMap() private static IReadOnlyDictionary<int, AttributeEntry> CreateMap()
{ {
Dictionary<int, AttributeEntry> map = new Dictionary<int, AttributeEntry>(); Dictionary<int, AttributeEntry> map = new();
Add(map, 0x060, AggregateType.S32, IoVariable.PrimitiveId, StagesMask.TessellationGeometryFragment, StagesMask.Geometry); Add(map, 0x060, AggregateType.S32, IoVariable.PrimitiveId, StagesMask.TessellationGeometryFragment, StagesMask.Geometry);
Add(map, 0x064, AggregateType.S32, IoVariable.Layer, StagesMask.Fragment, StagesMask.VertexTessellationGeometry); Add(map, 0x064, AggregateType.S32, IoVariable.Layer, StagesMask.Fragment, StagesMask.VertexTessellationGeometry);
@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
private static IReadOnlyDictionary<int, AttributeEntry> CreatePerPatchMap() private static IReadOnlyDictionary<int, AttributeEntry> CreatePerPatchMap()
{ {
Dictionary<int, AttributeEntry> map = new Dictionary<int, AttributeEntry>(); Dictionary<int, AttributeEntry> map = new();
Add(map, 0x000, AggregateType.Vector4 | AggregateType.FP32, IoVariable.TessellationLevelOuter, StagesMask.TessellationEvaluation, StagesMask.TessellationControl); Add(map, 0x000, AggregateType.Vector4 | AggregateType.FP32, IoVariable.TessellationLevelOuter, StagesMask.TessellationEvaluation, StagesMask.TessellationControl);
Add(map, 0x010, AggregateType.Vector2 | AggregateType.FP32, IoVariable.TessellationLevelInner, StagesMask.TessellationEvaluation, StagesMask.TessellationControl); Add(map, 0x010, AggregateType.Vector2 | AggregateType.FP32, IoVariable.TessellationLevelInner, StagesMask.TessellationEvaluation, StagesMask.TessellationControl);

View File

@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Shader.Translation
size = DefaultLocalMemorySize; size = DefaultLocalMemorySize;
} }
MemoryDefinition lmem = new MemoryDefinition("local_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint))); MemoryDefinition lmem = new("local_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint)));
LocalMemoryId = Properties.AddLocalMemory(lmem); LocalMemoryId = Properties.AddLocalMemory(lmem);
} }
@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Shader.Translation
size = DefaultSharedMemorySize; size = DefaultSharedMemorySize;
} }
MemoryDefinition smem = new MemoryDefinition("shared_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint))); MemoryDefinition smem = new("shared_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint)));
SharedMemoryId = Properties.AddSharedMemory(smem); SharedMemoryId = Properties.AddSharedMemory(smem);
} }
@ -315,8 +315,8 @@ namespace Ryujinx.Graphics.Shader.Translation
// For array textures, we also want to use type as key, // For array textures, we also want to use type as key,
// since we may have texture handles stores in the same buffer, but for textures with different types. // since we may have texture handles stores in the same buffer, but for textures with different types.
SamplerType keyType = arrayLength > 1 ? type : SamplerType.None; SamplerType keyType = arrayLength > 1 ? type : SamplerType.None;
TextureInfo info = new TextureInfo(cbufSlot, handle, arrayLength, separate, keyType, format); TextureInfo info = new(cbufSlot, handle, arrayLength, separate, keyType, format);
TextureMeta meta = new TextureMeta() TextureMeta meta = new()
{ {
AccurateType = accurateType, AccurateType = accurateType,
Type = type, Type = type,
@ -383,7 +383,7 @@ namespace Ryujinx.Graphics.Shader.Translation
nameSuffix = cbufSlot < 0 ? $"{prefix}_tcb_{handle:X}" : $"{prefix}_cb{cbufSlot}_{handle:X}"; nameSuffix = cbufSlot < 0 ? $"{prefix}_tcb_{handle:X}" : $"{prefix}_cb{cbufSlot}_{handle:X}";
} }
TextureDefinition definition = new TextureDefinition( TextureDefinition definition = new(
setIndex, setIndex,
binding, binding,
arrayLength, arrayLength,

View File

@ -192,7 +192,7 @@ namespace Ryujinx.Graphics.Shader.Translation
component = subIndex; component = subIndex;
} }
TransformFeedbackVariable transformFeedbackVariable = new TransformFeedbackVariable(ioVariable, location, component); TransformFeedbackVariable transformFeedbackVariable = new(ioVariable, location, component);
_transformFeedbackDefinitions.TryAdd(transformFeedbackVariable, transformFeedbackOutputs[wordOffset]); _transformFeedbackDefinitions.TryAdd(transformFeedbackVariable, transformFeedbackOutputs[wordOffset]);
} }
} }
@ -219,7 +219,7 @@ namespace Ryujinx.Graphics.Shader.Translation
return false; return false;
} }
TransformFeedbackVariable transformFeedbackVariable = new TransformFeedbackVariable(ioVariable, location, component); TransformFeedbackVariable transformFeedbackVariable = new(ioVariable, location, component);
return _transformFeedbackDefinitions.TryGetValue(transformFeedbackVariable, out transformFeedbackOutput); return _transformFeedbackDefinitions.TryGetValue(transformFeedbackVariable, out transformFeedbackOutput);
} }

View File

@ -342,7 +342,7 @@ namespace Ryujinx.Graphics.Shader.Translation
_ => 1 _ => 1
}; };
ShaderProgramInfo info = new ShaderProgramInfo( ShaderProgramInfo info = new(
resourceManager.GetConstantBufferDescriptors(), resourceManager.GetConstantBufferDescriptors(),
resourceManager.GetStorageBufferDescriptors(), resourceManager.GetStorageBufferDescriptors(),
resourceManager.GetTextureDescriptors(), resourceManager.GetTextureDescriptors(),
@ -358,7 +358,7 @@ namespace Ryujinx.Graphics.Shader.Translation
clipDistancesWritten, clipDistancesWritten,
originalDefinitions.OmapTargets); originalDefinitions.OmapTargets);
HostCapabilities hostCapabilities = new HostCapabilities( HostCapabilities hostCapabilities = new(
GpuAccessor.QueryHostReducedPrecision(), GpuAccessor.QueryHostReducedPrecision(),
GpuAccessor.QueryHostSupportsFragmentShaderInterlock(), GpuAccessor.QueryHostSupportsFragmentShaderInterlock(),
GpuAccessor.QueryHostSupportsFragmentShaderOrderingIntel(), GpuAccessor.QueryHostSupportsFragmentShaderOrderingIntel(),
@ -369,7 +369,7 @@ namespace Ryujinx.Graphics.Shader.Translation
GpuAccessor.QueryHostSupportsTextureShadowLod(), GpuAccessor.QueryHostSupportsTextureShadowLod(),
GpuAccessor.QueryHostSupportsViewportMask()); GpuAccessor.QueryHostSupportsViewportMask());
CodeGenParameters parameters = new CodeGenParameters(attributeUsage, definitions, resourceManager.Properties, hostCapabilities, GpuAccessor, Options.TargetApi); CodeGenParameters parameters = new(attributeUsage, definitions, resourceManager.Properties, hostCapabilities, GpuAccessor, Options.TargetApi);
return Options.TargetLanguage switch return Options.TargetLanguage switch
{ {
@ -388,7 +388,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{ {
StructureType tfeDataStruct = new(new StructureField[] StructureType tfeDataStruct = new(new StructureField[]
{ {
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0) new(AggregateType.Array | AggregateType.U32, "data", 0)
}); });
for (int i = 0; i < ResourceReservations.TfeBuffersCount; i++) for (int i = 0; i < ResourceReservations.TfeBuffersCount; i++)
@ -407,7 +407,7 @@ namespace Ryujinx.Graphics.Shader.Translation
StructureType vertexOutputStruct = new(new StructureField[] StructureType vertexOutputStruct = new(new StructureField[]
{ {
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0) new(AggregateType.Array | AggregateType.FP32, "data", 0)
}); });
int vertexOutputSbBinding = resourceManager.Reservations.VertexOutputStorageBufferBinding; int vertexOutputSbBinding = resourceManager.Reservations.VertexOutputStorageBufferBinding;
@ -444,7 +444,7 @@ namespace Ryujinx.Graphics.Shader.Translation
StructureType geometryIbOutputStruct = new(new StructureField[] StructureType geometryIbOutputStruct = new(new StructureField[]
{ {
new StructureField(AggregateType.Array | AggregateType.U32, "data", 0) new(AggregateType.Array | AggregateType.U32, "data", 0)
}); });
int geometryIbOutputSbBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferBinding; int geometryIbOutputSbBinding = resourceManager.Reservations.GeometryIndexOutputStorageBufferBinding;
@ -494,8 +494,8 @@ namespace Ryujinx.Graphics.Shader.Translation
public (ShaderProgram, ShaderProgramInfo) GenerateVertexPassthroughForCompute() public (ShaderProgram, ShaderProgramInfo) GenerateVertexPassthroughForCompute()
{ {
AttributeUsage attributeUsage = new AttributeUsage(GpuAccessor); AttributeUsage attributeUsage = new(GpuAccessor);
ResourceManager resourceManager = new ResourceManager(ShaderStage.Vertex, GpuAccessor); ResourceManager resourceManager = new(ShaderStage.Vertex, GpuAccessor);
ResourceReservations reservations = GetResourceReservations(); ResourceReservations reservations = GetResourceReservations();
@ -509,14 +509,14 @@ namespace Ryujinx.Graphics.Shader.Translation
StructureType vertexInputStruct = new(new StructureField[] StructureType vertexInputStruct = new(new StructureField[]
{ {
new StructureField(AggregateType.Array | AggregateType.FP32, "data", 0) new(AggregateType.Array | AggregateType.FP32, "data", 0)
}); });
int vertexDataSbBinding = reservations.VertexOutputStorageBufferBinding; int vertexDataSbBinding = reservations.VertexOutputStorageBufferBinding;
BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexDataSbBinding, "vb_input", vertexInputStruct); BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexDataSbBinding, "vb_input", vertexInputStruct);
resourceManager.AddVertexAsComputeStorageBuffer(vertexOutputBuffer); resourceManager.AddVertexAsComputeStorageBuffer(vertexOutputBuffer);
EmitterContext context = new EmitterContext(); EmitterContext context = new();
Operand vertexIndex = Options.TargetApi == TargetApi.OpenGL Operand vertexIndex = Options.TargetApi == TargetApi.OpenGL
? context.Load(StorageKind.Input, IoVariable.VertexId) ? context.Load(StorageKind.Input, IoVariable.VertexId)
@ -563,11 +563,11 @@ namespace Ryujinx.Graphics.Shader.Translation
Operation[] operations = context.GetOperations(); Operation[] operations = context.GetOperations();
ControlFlowGraph cfg = ControlFlowGraph.Create(operations); ControlFlowGraph cfg = ControlFlowGraph.Create(operations);
Function function = new Function(cfg.Blocks, "main", false, 0, 0); Function function = new(cfg.Blocks, "main", false, 0, 0);
TransformFeedbackOutput[] transformFeedbackOutputs = GetTransformFeedbackOutputs(GpuAccessor, out ulong transformFeedbackVecMap); TransformFeedbackOutput[] transformFeedbackOutputs = GetTransformFeedbackOutputs(GpuAccessor, out ulong transformFeedbackVecMap);
ShaderDefinitions definitions = new ShaderDefinitions(ShaderStage.Vertex, transformFeedbackVecMap, transformFeedbackOutputs) ShaderDefinitions definitions = new(ShaderStage.Vertex, transformFeedbackVecMap, transformFeedbackOutputs)
{ {
LastInVertexPipeline = true LastInVertexPipeline = true
}; };
@ -612,10 +612,10 @@ namespace Ryujinx.Graphics.Shader.Translation
break; break;
} }
AttributeUsage attributeUsage = new AttributeUsage(GpuAccessor); AttributeUsage attributeUsage = new(GpuAccessor);
ResourceManager resourceManager = new ResourceManager(ShaderStage.Geometry, GpuAccessor); ResourceManager resourceManager = new(ShaderStage.Geometry, GpuAccessor);
EmitterContext context = new EmitterContext(); EmitterContext context = new();
for (int v = 0; v < maxOutputVertices; v++) for (int v = 0; v < maxOutputVertices; v++)
{ {
@ -658,9 +658,9 @@ namespace Ryujinx.Graphics.Shader.Translation
Operation[] operations = context.GetOperations(); Operation[] operations = context.GetOperations();
ControlFlowGraph cfg = ControlFlowGraph.Create(operations); ControlFlowGraph cfg = ControlFlowGraph.Create(operations);
Function function = new Function(cfg.Blocks, "main", false, 0, 0); Function function = new(cfg.Blocks, "main", false, 0, 0);
ShaderDefinitions definitions = new ShaderDefinitions( ShaderDefinitions definitions = new(
ShaderStage.Geometry, ShaderStage.Geometry,
GpuAccessor.QueryGraphicsState(), GpuAccessor.QueryGraphicsState(),
false, false,