mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-19 06:12:02 +00:00
add: textures and samplers as shader arguments & fix: issue with casting
This commit is contained in:
parent
6295153a28
commit
320c317113
4 changed files with 15 additions and 9 deletions
|
@ -53,13 +53,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
Add(Instruction.ConditionalSelect, InstType.OpTernary, "?:", 12);
|
Add(Instruction.ConditionalSelect, InstType.OpTernary, "?:", 12);
|
||||||
Add(Instruction.ConvertFP32ToFP64, 0); // MSL does not have a 64-bit FP
|
Add(Instruction.ConvertFP32ToFP64, 0); // MSL does not have a 64-bit FP
|
||||||
Add(Instruction.ConvertFP64ToFP32, 0); // MSL does not have a 64-bit FP
|
Add(Instruction.ConvertFP64ToFP32, 0); // MSL does not have a 64-bit FP
|
||||||
Add(Instruction.ConvertFP32ToS32, InstType.Cast, "int");
|
Add(Instruction.ConvertFP32ToS32, InstType.CallUnary, "int");
|
||||||
Add(Instruction.ConvertFP32ToU32, InstType.Cast, "uint");
|
Add(Instruction.ConvertFP32ToU32, InstType.CallUnary, "uint");
|
||||||
Add(Instruction.ConvertFP64ToS32, 0); // MSL does not have a 64-bit FP
|
Add(Instruction.ConvertFP64ToS32, 0); // MSL does not have a 64-bit FP
|
||||||
Add(Instruction.ConvertFP64ToU32, 0); // MSL does not have a 64-bit FP
|
Add(Instruction.ConvertFP64ToU32, 0); // MSL does not have a 64-bit FP
|
||||||
Add(Instruction.ConvertS32ToFP32, InstType.Cast, "float");
|
Add(Instruction.ConvertS32ToFP32, InstType.CallUnary, "float");
|
||||||
Add(Instruction.ConvertS32ToFP64, 0); // MSL does not have a 64-bit FP
|
Add(Instruction.ConvertS32ToFP64, 0); // MSL does not have a 64-bit FP
|
||||||
Add(Instruction.ConvertU32ToFP32, InstType.Cast, "float");
|
Add(Instruction.ConvertU32ToFP32, InstType.CallUnary, "float");
|
||||||
Add(Instruction.ConvertU32ToFP64, 0); // MSL does not have a 64-bit FP
|
Add(Instruction.ConvertU32ToFP64, 0); // MSL does not have a 64-bit FP
|
||||||
Add(Instruction.Cosine, InstType.CallUnary, "cos");
|
Add(Instruction.Cosine, InstType.CallUnary, "cos");
|
||||||
Add(Instruction.Ddx, InstType.CallUnary, "dfdx");
|
Add(Instruction.Ddx, InstType.CallUnary, "dfdx");
|
||||||
|
|
|
@ -158,7 +158,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
|
|
||||||
bool colorIsVector = isGather || !isShadow;
|
bool colorIsVector = isGather || !isShadow;
|
||||||
|
|
||||||
string texCall = "texture.";
|
string samplerName = GetSamplerName(context.Properties, texOp);
|
||||||
|
string texCall = $"tex_{samplerName}";
|
||||||
|
texCall += ".";
|
||||||
|
|
||||||
int srcIndex = 0;
|
int srcIndex = 0;
|
||||||
|
|
||||||
|
@ -175,9 +177,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
{
|
{
|
||||||
texCall += "sample(";
|
texCall += "sample(";
|
||||||
|
|
||||||
string samplerName = GetSamplerName(context.Properties, texOp);
|
texCall += $"samp_{samplerName}";
|
||||||
|
|
||||||
texCall += samplerName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int coordsCount = texOp.Type.GetDimensions();
|
int coordsCount = texOp.Type.GetDimensions();
|
||||||
|
|
|
@ -29,7 +29,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
Call = 1 << 10,
|
Call = 1 << 10,
|
||||||
Atomic = 1 << 11,
|
Atomic = 1 << 11,
|
||||||
Special = 1 << 12,
|
Special = 1 << 12,
|
||||||
Cast = 1 << 13,
|
|
||||||
|
|
||||||
ArityMask = 0xff,
|
ArityMask = 0xff,
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl
|
||||||
{
|
{
|
||||||
args = args.Append($"device float4 *{storageBuffers.Name} [[buffer({storageBuffers.Binding})]]").ToArray();
|
args = args.Append($"device float4 *{storageBuffers.Name} [[buffer({storageBuffers.Binding})]]").ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var texture in context.Properties.Textures.Values)
|
||||||
|
{
|
||||||
|
// TODO: don't use always texture2d
|
||||||
|
args = args.Append($"texture2d<float> tex_{texture.Name} [[texture({texture.Binding})]]").ToArray();
|
||||||
|
args = args.Append($"sampler samp_{texture.Name} [[sampler({texture.Binding})]]").ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"{funcKeyword} {returnType} {funcName ?? function.Name}({string.Join(", ", args)})";
|
return $"{funcKeyword} {returnType} {funcName ?? function.Name}({string.Join(", ", args)})";
|
||||||
|
|
Loading…
Reference in a new issue