|
@@ -110,7 +110,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|
|
Buffer.Clear(destination, offset, size, value);
|
|
Buffer.Clear(destination, offset, size, value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void ClearRenderTargetColor(int index, int layer, uint componentMask, ColorF color)
|
|
|
|
|
|
|
+ public void ClearRenderTargetColor(int index, int layer, int layerCount, uint componentMask, ColorF color)
|
|
|
{
|
|
{
|
|
|
GL.ColorMask(
|
|
GL.ColorMask(
|
|
|
index,
|
|
index,
|
|
@@ -119,18 +119,28 @@ namespace Ryujinx.Graphics.OpenGL
|
|
|
(componentMask & 4) != 0,
|
|
(componentMask & 4) != 0,
|
|
|
(componentMask & 8) != 0);
|
|
(componentMask & 8) != 0);
|
|
|
|
|
|
|
|
- _framebuffer.AttachColorLayerForClear(index, layer);
|
|
|
|
|
-
|
|
|
|
|
float[] colors = new float[] { color.Red, color.Green, color.Blue, color.Alpha };
|
|
float[] colors = new float[] { color.Red, color.Green, color.Blue, color.Alpha };
|
|
|
|
|
|
|
|
- GL.ClearBuffer(OpenTK.Graphics.OpenGL.ClearBuffer.Color, index, colors);
|
|
|
|
|
|
|
+ if (layer != 0 || layerCount != _framebuffer.GetColorLayerCount(index))
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int l = layer; l < layer + layerCount; l++)
|
|
|
|
|
+ {
|
|
|
|
|
+ _framebuffer.AttachColorLayerForClear(index, l);
|
|
|
|
|
+
|
|
|
|
|
+ GL.ClearBuffer(OpenTK.Graphics.OpenGL.ClearBuffer.Color, index, colors);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- _framebuffer.DetachColorLayerForClear(index);
|
|
|
|
|
|
|
+ _framebuffer.DetachColorLayerForClear(index);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ GL.ClearBuffer(OpenTK.Graphics.OpenGL.ClearBuffer.Color, index, colors);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
RestoreComponentMask(index);
|
|
RestoreComponentMask(index);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void ClearRenderTargetDepthStencil(int layer, float depthValue, bool depthMask, int stencilValue, int stencilMask)
|
|
|
|
|
|
|
+ public void ClearRenderTargetDepthStencil(int layer, int layerCount, float depthValue, bool depthMask, int stencilValue, int stencilMask)
|
|
|
{
|
|
{
|
|
|
bool stencilMaskChanged =
|
|
bool stencilMaskChanged =
|
|
|
stencilMask != 0 &&
|
|
stencilMask != 0 &&
|
|
@@ -148,23 +158,22 @@ namespace Ryujinx.Graphics.OpenGL
|
|
|
GL.DepthMask(depthMask);
|
|
GL.DepthMask(depthMask);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _framebuffer.AttachDepthStencilLayerForClear(layer);
|
|
|
|
|
-
|
|
|
|
|
- if (depthMask && stencilMask != 0)
|
|
|
|
|
- {
|
|
|
|
|
- GL.ClearBuffer(ClearBufferCombined.DepthStencil, 0, depthValue, stencilValue);
|
|
|
|
|
- }
|
|
|
|
|
- else if (depthMask)
|
|
|
|
|
|
|
+ if (layer != 0 || layerCount != _framebuffer.GetDepthStencilLayerCount())
|
|
|
{
|
|
{
|
|
|
- GL.ClearBuffer(OpenTK.Graphics.OpenGL.ClearBuffer.Depth, 0, ref depthValue);
|
|
|
|
|
|
|
+ for (int l = layer; l < layer + layerCount; l++)
|
|
|
|
|
+ {
|
|
|
|
|
+ _framebuffer.AttachDepthStencilLayerForClear(l);
|
|
|
|
|
+
|
|
|
|
|
+ ClearDepthStencil(depthValue, depthMask, stencilValue, stencilMask);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _framebuffer.DetachDepthStencilLayerForClear();
|
|
|
}
|
|
}
|
|
|
- else if (stencilMask != 0)
|
|
|
|
|
|
|
+ else
|
|
|
{
|
|
{
|
|
|
- GL.ClearBuffer(OpenTK.Graphics.OpenGL.ClearBuffer.Stencil, 0, ref stencilValue);
|
|
|
|
|
|
|
+ ClearDepthStencil(depthValue, depthMask, stencilValue, stencilMask);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _framebuffer.DetachDepthStencilLayerForClear();
|
|
|
|
|
-
|
|
|
|
|
if (stencilMaskChanged)
|
|
if (stencilMaskChanged)
|
|
|
{
|
|
{
|
|
|
GL.StencilMaskSeparate(StencilFace.Front, _stencilFrontMask);
|
|
GL.StencilMaskSeparate(StencilFace.Front, _stencilFrontMask);
|
|
@@ -176,6 +185,22 @@ namespace Ryujinx.Graphics.OpenGL
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static void ClearDepthStencil(float depthValue, bool depthMask, int stencilValue, int stencilMask)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (depthMask && stencilMask != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ GL.ClearBuffer(ClearBufferCombined.DepthStencil, 0, depthValue, stencilValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (depthMask)
|
|
|
|
|
+ {
|
|
|
|
|
+ GL.ClearBuffer(OpenTK.Graphics.OpenGL.ClearBuffer.Depth, 0, ref depthValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (stencilMask != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ GL.ClearBuffer(OpenTK.Graphics.OpenGL.ClearBuffer.Stencil, 0, ref stencilValue);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void CommandBufferBarrier()
|
|
public void CommandBufferBarrier()
|
|
|
{
|
|
{
|
|
|
GL.MemoryBarrier(MemoryBarrierFlags.CommandBarrierBit);
|
|
GL.MemoryBarrier(MemoryBarrierFlags.CommandBarrierBit);
|