Only enable clip distance if written to on shader (#2217)
* Only enable clip distance if written to on shader * Signal InstanceId use through FeatureFlags * Shader cache version bump
This commit is contained in:
parent
89791ba68d
commit
4770cfa920
12 changed files with 79 additions and 23 deletions
|
@ -55,7 +55,11 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
public void FlagAttributeRead(int attribute)
|
||||
{
|
||||
if (Config.Stage == ShaderStage.Fragment)
|
||||
if (Config.Stage == ShaderStage.Vertex && attribute == AttributeConsts.InstanceId)
|
||||
{
|
||||
Config.SetUsedFeature(FeatureFlags.InstanceId);
|
||||
}
|
||||
else if (Config.Stage == ShaderStage.Fragment)
|
||||
{
|
||||
switch (attribute)
|
||||
{
|
||||
|
@ -67,6 +71,26 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
}
|
||||
}
|
||||
|
||||
public void FlagAttributeWritten(int attribute)
|
||||
{
|
||||
if (Config.Stage == ShaderStage.Vertex)
|
||||
{
|
||||
switch (attribute)
|
||||
{
|
||||
case AttributeConsts.ClipDistance0:
|
||||
case AttributeConsts.ClipDistance1:
|
||||
case AttributeConsts.ClipDistance2:
|
||||
case AttributeConsts.ClipDistance3:
|
||||
case AttributeConsts.ClipDistance4:
|
||||
case AttributeConsts.ClipDistance5:
|
||||
case AttributeConsts.ClipDistance6:
|
||||
case AttributeConsts.ClipDistance7:
|
||||
Config.SetClipDistanceWritten((attribute - AttributeConsts.ClipDistance0) / 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkLabel(Operand label)
|
||||
{
|
||||
Add(Instruction.MarkLabel, label);
|
||||
|
|
|
@ -12,9 +12,11 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
None = 0,
|
||||
|
||||
// Affected by resolution scaling.
|
||||
FragCoordXY = 1 << 1,
|
||||
IntegerSampling = 1 << 0,
|
||||
FragCoordXY = 1 << 1,
|
||||
|
||||
Bindless = 1 << 2,
|
||||
Bindless = 1 << 2,
|
||||
|
||||
InstanceId = 1 << 3
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
public int Size { get; private set; }
|
||||
|
||||
public byte ClipDistancesWritten { get; private set; }
|
||||
|
||||
public FeatureFlags UsedFeatures { get; private set; }
|
||||
|
||||
public HashSet<int> TextureHandlesForCache { get; }
|
||||
|
@ -115,6 +117,11 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
Size += size;
|
||||
}
|
||||
|
||||
public void SetClipDistanceWritten(int index)
|
||||
{
|
||||
ClipDistancesWritten |= (byte)(1 << index);
|
||||
}
|
||||
|
||||
public void SetUsedFeature(FeatureFlags flags)
|
||||
{
|
||||
UsedFeatures |= flags;
|
||||
|
|
|
@ -94,7 +94,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
program.SBufferDescriptors,
|
||||
program.TextureDescriptors,
|
||||
program.ImageDescriptors,
|
||||
sInfo.UsesInstanceId);
|
||||
config.UsedFeatures.HasFlag(FeatureFlags.InstanceId),
|
||||
config.ClipDistancesWritten);
|
||||
|
||||
string glslCode = program.Code;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue