mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-23 10:51:21 -08:00
Implement alpha test using legacy functions (#1426)
This commit is contained in:
parent
938c06c652
commit
43c13057da
@ -31,6 +31,8 @@ namespace Ryujinx.Graphics.GAL
|
|||||||
|
|
||||||
void EndTransformFeedback();
|
void EndTransformFeedback();
|
||||||
|
|
||||||
|
void SetAlphaTest(bool enable, float reference, CompareOp op);
|
||||||
|
|
||||||
void SetBlendState(int index, BlendDescriptor blend);
|
void SetBlendState(int index, BlendDescriptor blend);
|
||||||
|
|
||||||
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
void SetDepthBias(PolygonModeMask enables, float factor, float units, float clamp);
|
||||||
@ -61,9 +63,7 @@ namespace Ryujinx.Graphics.GAL
|
|||||||
void SetRasterizerDiscard(bool discard);
|
void SetRasterizerDiscard(bool discard);
|
||||||
|
|
||||||
void SetRenderTargetScale(float scale);
|
void SetRenderTargetScale(float scale);
|
||||||
|
|
||||||
void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask);
|
void SetRenderTargetColorMasks(ReadOnlySpan<uint> componentMask);
|
||||||
|
|
||||||
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
|
void SetRenderTargets(ITexture[] colors, ITexture depthStencil);
|
||||||
|
|
||||||
void SetSampler(int index, ShaderStage stage, ISampler sampler);
|
void SetSampler(int index, ShaderStage stage, ISampler sampler);
|
||||||
|
@ -164,6 +164,13 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||||||
UpdateDepthClampState(state);
|
UpdateDepthClampState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.QueryModified(MethodOffset.AlphaTestEnable,
|
||||||
|
MethodOffset.AlphaTestRef,
|
||||||
|
MethodOffset.AlphaTestFunc))
|
||||||
|
{
|
||||||
|
UpdateAlphaTestState(state);
|
||||||
|
}
|
||||||
|
|
||||||
if (state.QueryModified(MethodOffset.DepthTestEnable,
|
if (state.QueryModified(MethodOffset.DepthTestEnable,
|
||||||
MethodOffset.DepthWriteEnable,
|
MethodOffset.DepthWriteEnable,
|
||||||
MethodOffset.DepthTestFunc))
|
MethodOffset.DepthTestFunc))
|
||||||
@ -372,7 +379,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||||||
if (dsEnable)
|
if (dsEnable)
|
||||||
{
|
{
|
||||||
var dsState = state.Get<RtDepthStencilState>(MethodOffset.RtDepthStencilState);
|
var dsState = state.Get<RtDepthStencilState>(MethodOffset.RtDepthStencilState);
|
||||||
var dsSize = state.Get<Size3D> (MethodOffset.RtDepthStencilSize);
|
var dsSize = state.Get<Size3D>(MethodOffset.RtDepthStencilSize);
|
||||||
|
|
||||||
depthStencil = TextureManager.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY);
|
depthStencil = TextureManager.FindOrCreateTexture(dsState, dsSize, samplesInX, samplesInY);
|
||||||
}
|
}
|
||||||
@ -450,6 +457,18 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||||||
_context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampDisabled) == 0);
|
_context.Renderer.Pipeline.SetDepthClamp((clip & ViewVolumeClipControl.DepthClampDisabled) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates host alpha test state based on current GPU state.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="state">Current GPU state</param>
|
||||||
|
private void UpdateAlphaTestState(GpuState state)
|
||||||
|
{
|
||||||
|
_context.Renderer.Pipeline.SetAlphaTest(
|
||||||
|
state.Get<Boolean32>(MethodOffset.AlphaTestEnable),
|
||||||
|
state.Get<float>(MethodOffset.AlphaTestRef),
|
||||||
|
state.Get<CompareOp>(MethodOffset.AlphaTestFunc));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates host depth test state based on current GPU state.
|
/// Updates host depth test state based on current GPU state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -577,8 +596,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||||||
/// <param name="state">Current GPU state</param>
|
/// <param name="state">Current GPU state</param>
|
||||||
private void UpdateStencilTestState(GpuState state)
|
private void UpdateStencilTestState(GpuState state)
|
||||||
{
|
{
|
||||||
var backMasks = state.Get<StencilBackMasks> (MethodOffset.StencilBackMasks);
|
var backMasks = state.Get<StencilBackMasks>(MethodOffset.StencilBackMasks);
|
||||||
var test = state.Get<StencilTestState> (MethodOffset.StencilTestState);
|
var test = state.Get<StencilTestState>(MethodOffset.StencilTestState);
|
||||||
var backTest = state.Get<StencilBackTestState>(MethodOffset.StencilBackTestState);
|
var backTest = state.Get<StencilBackTestState>(MethodOffset.StencilBackTestState);
|
||||||
|
|
||||||
CompareOp backFunc;
|
CompareOp backFunc;
|
||||||
|
@ -52,8 +52,11 @@ namespace Ryujinx.Graphics.Gpu.State
|
|||||||
DepthTestEnable = 0x4b3,
|
DepthTestEnable = 0x4b3,
|
||||||
BlendIndependent = 0x4b9,
|
BlendIndependent = 0x4b9,
|
||||||
DepthWriteEnable = 0x4ba,
|
DepthWriteEnable = 0x4ba,
|
||||||
|
AlphaTestEnable = 0x4bb,
|
||||||
VbElementU8 = 0x4c1,
|
VbElementU8 = 0x4c1,
|
||||||
DepthTestFunc = 0x4c3,
|
DepthTestFunc = 0x4c3,
|
||||||
|
AlphaTestRef = 0x4c4,
|
||||||
|
AlphaTestFunc = 0x4c5,
|
||||||
BlendConstant = 0x4c7,
|
BlendConstant = 0x4c7,
|
||||||
BlendStateCommon = 0x4cf,
|
BlendStateCommon = 0x4cf,
|
||||||
BlendEnableCommon = 0x4d7,
|
BlendEnableCommon = 0x4d7,
|
||||||
|
@ -157,7 +157,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
if (!_program.IsLinked)
|
if (!_program.IsLinked)
|
||||||
{
|
{
|
||||||
Logger.PrintDebug(LogClass.Gpu, "Dispatch error, shader not linked.");
|
Logger.PrintDebug(LogClass.Gpu, "Dispatch error, shader not linked.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +170,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
if (!_program.IsLinked)
|
if (!_program.IsLinked)
|
||||||
{
|
{
|
||||||
Logger.PrintDebug(LogClass.Gpu, "Draw error, shader not linked.");
|
Logger.PrintDebug(LogClass.Gpu, "Draw error, shader not linked.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +288,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
if (!_program.IsLinked)
|
if (!_program.IsLinked)
|
||||||
{
|
{
|
||||||
Logger.PrintDebug(LogClass.Gpu, "Draw error, shader not linked.");
|
Logger.PrintDebug(LogClass.Gpu, "Draw error, shader not linked.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,12 +524,23 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
_tfEnabled = false;
|
_tfEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetAlphaTest(bool enable, float reference, CompareOp op)
|
||||||
|
{
|
||||||
|
if (!enable)
|
||||||
|
{
|
||||||
|
GL.Disable(EnableCap.AlphaTest);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GL.AlphaFunc((AlphaFunction)op.Convert(), reference);
|
||||||
|
GL.Enable(EnableCap.AlphaTest);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetBlendState(int index, BlendDescriptor blend)
|
public void SetBlendState(int index, BlendDescriptor blend)
|
||||||
{
|
{
|
||||||
if (!blend.Enable)
|
if (!blend.Enable)
|
||||||
{
|
{
|
||||||
GL.Disable(IndexedEnableCap.Blend, index);
|
GL.Disable(IndexedEnableCap.Blend, index);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,7 +666,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
if (!enable)
|
if (!enable)
|
||||||
{
|
{
|
||||||
GL.Disable(EnableCap.CullFace);
|
GL.Disable(EnableCap.CullFace);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,7 +749,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
if (!enable)
|
if (!enable)
|
||||||
{
|
{
|
||||||
GL.Disable(EnableCap.PrimitiveRestart);
|
GL.Disable(EnableCap.PrimitiveRestart);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,7 +880,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
if (!stencilTest.TestEnable)
|
if (!stencilTest.TestEnable)
|
||||||
{
|
{
|
||||||
GL.Disable(EnableCap.StencilTest);
|
GL.Disable(EnableCap.StencilTest);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1077,7 +1082,6 @@ namespace Ryujinx.Graphics.OpenGL
|
|||||||
if (buffer.Handle == null)
|
if (buffer.Handle == null)
|
||||||
{
|
{
|
||||||
GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);
|
GL.BindBufferRange(target, bindingPoint, 0, IntPtr.Zero, 0);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user