mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-04-21 05:13:14 +02:00
Merge branch 'feature/dsb-ub' into 'master'
Workaround undefined behavior in bad dual source blend states See merge request ryubing/ryujinx!4
This commit is contained in:
commit
0af62c0cda
2 changed files with 21 additions and 9 deletions
|
@ -512,14 +512,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
|||
if (context.Definitions.Stage == ShaderStage.Fragment && context.Definitions.DualSourceBlend)
|
||||
{
|
||||
IoDefinition firstOutput = outputs.ElementAtOrDefault(0);
|
||||
IoDefinition secondOutput = outputs.ElementAtOrDefault(1);
|
||||
|
||||
if (firstOutput.Location + 1 == secondOutput.Location)
|
||||
{
|
||||
DeclareOutputDualSourceBlendAttribute(context, firstOutput.Location);
|
||||
outputs = outputs.Skip(2);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (IoDefinition ioDefinition in outputs)
|
||||
{
|
||||
|
|
|
@ -181,13 +181,29 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||
|
||||
private static void EmitOutputsInitialization(EmitterContext context, AttributeUsage attributeUsage, IGpuAccessor gpuAccessor, ShaderStage stage)
|
||||
{
|
||||
// Compute has no output attributes, and fragment is the last stage, so we
|
||||
// don't need to initialize outputs on those stages.
|
||||
if (stage == ShaderStage.Compute || stage == ShaderStage.Fragment)
|
||||
// Compute has no output attributes, so we
|
||||
// don't need to initialize outputs on that stage.
|
||||
if (stage == ShaderStage.Compute)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stage == ShaderStage.Fragment)
|
||||
{
|
||||
// Fragment is the last stage, so we don't need to
|
||||
// initialize outputs unless we're using DSB, in which
|
||||
// we need to make sure the ouput has a valid value.
|
||||
if (gpuAccessor.QueryGraphicsState().DualSourceBlendEnable)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
context.Store(StorageKind.Output, IoVariable.FragmentOutputColor, null, Const(1), Const(i), ConstF(0));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (stage == ShaderStage.Vertex)
|
||||
{
|
||||
InitializeVertexOutputs(context);
|
||||
|
|
Loading…
Add table
Reference in a new issue