mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-02-22 17:10:19 +00:00
SPIR-V: Only use input attribute type for input attributes
Output vertex attributes should always be of type float.
This commit is contained in:
parent
cbeb40934f
commit
7882c0498b
3 changed files with 20 additions and 10 deletions
|
@ -213,14 +213,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
|
|
||||||
public Instruction GetAttributeVectorPointer(AstOperand operand, bool isOutAttr)
|
public Instruction GetAttributeVectorPointer(AstOperand operand, bool isOutAttr)
|
||||||
{
|
{
|
||||||
var attrInfo = AttributeInfo.From(Config, operand.Value);
|
var attrInfo = AttributeInfo.From(Config, operand.Value, isOutAttr);
|
||||||
|
|
||||||
return isOutAttr ? Outputs[attrInfo.BaseValue] : Inputs[attrInfo.BaseValue];
|
return isOutAttr ? Outputs[attrInfo.BaseValue] : Inputs[attrInfo.BaseValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instruction GetAttributeElemPointer(int attr, bool isOutAttr, Instruction index, out AggregateType elemType)
|
public Instruction GetAttributeElemPointer(int attr, bool isOutAttr, Instruction index, out AggregateType elemType)
|
||||||
{
|
{
|
||||||
var attrInfo = AttributeInfo.From(Config, attr);
|
var attrInfo = AttributeInfo.From(Config, attr, isOutAttr);
|
||||||
|
|
||||||
elemType = attrInfo.Type & AggregateType.ElementTypeMask;
|
elemType = attrInfo.Type & AggregateType.ElementTypeMask;
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
}
|
}
|
||||||
|
|
||||||
var dict = isOutAttr ? context.Outputs : context.Inputs;
|
var dict = isOutAttr ? context.Outputs : context.Inputs;
|
||||||
var attrInfo = AttributeInfo.From(context.Config, attr);
|
var attrInfo = AttributeInfo.From(context.Config, attr, isOutAttr);
|
||||||
|
|
||||||
if (dict.ContainsKey(attrInfo.BaseValue))
|
if (dict.ContainsKey(attrInfo.BaseValue))
|
||||||
{
|
{
|
||||||
|
@ -455,7 +455,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
private static void DeclareInputOrOutput(CodeGenContext context, int attr, int component, bool isOutAttr, PixelImap iq = PixelImap.Unused)
|
private static void DeclareInputOrOutput(CodeGenContext context, int attr, int component, bool isOutAttr, PixelImap iq = PixelImap.Unused)
|
||||||
{
|
{
|
||||||
var dict = isOutAttr ? context.Outputs : context.Inputs;
|
var dict = isOutAttr ? context.Outputs : context.Inputs;
|
||||||
var attrInfo = AttributeInfo.From(context.Config, attr);
|
var attrInfo = AttributeInfo.From(context.Config, attr, isOutAttr);
|
||||||
|
|
||||||
if (dict.ContainsKey(attr))
|
if (dict.ContainsKey(attr))
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,19 +70,29 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
return (Value - BaseValue) / 4;
|
return (Value - BaseValue) / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AttributeInfo From(ShaderConfig config, int value)
|
public static AttributeInfo From(ShaderConfig config, int value, bool isOutAttr)
|
||||||
{
|
{
|
||||||
value &= ~3;
|
value &= ~3;
|
||||||
|
|
||||||
if (value >= AttributeConsts.UserAttributeBase && value < AttributeConsts.UserAttributeEnd)
|
if (value >= AttributeConsts.UserAttributeBase && value < AttributeConsts.UserAttributeEnd)
|
||||||
{
|
{
|
||||||
int location = (value - AttributeConsts.UserAttributeBase) / 16;
|
int location = (value - AttributeConsts.UserAttributeBase) / 16;
|
||||||
var elemType = config.GpuAccessor.QueryAttributeType(location) switch
|
|
||||||
|
AggregateType elemType;
|
||||||
|
|
||||||
|
if (!isOutAttr)
|
||||||
|
{
|
||||||
|
elemType = config.GpuAccessor.QueryAttributeType(location) switch
|
||||||
{
|
{
|
||||||
AttributeType.Sint => AggregateType.S32,
|
AttributeType.Sint => AggregateType.S32,
|
||||||
AttributeType.Uint => AggregateType.U32,
|
AttributeType.Uint => AggregateType.U32,
|
||||||
_ => AggregateType.FP32
|
_ => AggregateType.FP32
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
elemType = AggregateType.FP32;
|
||||||
|
}
|
||||||
|
|
||||||
return new AttributeInfo(value & ~0xf, (value >> 2) & 3, 4, AggregateType.Vector | elemType, false);
|
return new AttributeInfo(value & ~0xf, (value >> 2) & 3, 4, AggregateType.Vector | elemType, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue