MethodClear.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Ryujinx.Graphics.GAL.Color;
  2. using Ryujinx.Graphics.Gpu.State;
  3. namespace Ryujinx.Graphics.Gpu.Engine
  4. {
  5. partial class Methods
  6. {
  7. private void Clear(int argument)
  8. {
  9. UpdateState();
  10. bool clearDepth = (argument & 1) != 0;
  11. bool clearStencil = (argument & 2) != 0;
  12. uint componentMask = (uint)((argument >> 2) & 0xf);
  13. int index = (argument >> 6) & 0xf;
  14. if (componentMask != 0)
  15. {
  16. ClearColors clearColor = _context.State.GetClearColors();
  17. ColorF color = new ColorF(
  18. clearColor.Red,
  19. clearColor.Green,
  20. clearColor.Blue,
  21. clearColor.Alpha);
  22. _context.Renderer.GraphicsPipeline.ClearRenderTargetColor(
  23. index,
  24. componentMask,
  25. color);
  26. }
  27. if (clearDepth || clearStencil)
  28. {
  29. float depthValue = _context.State.GetClearDepthValue();
  30. int stencilValue = _context.State.GetClearStencilValue();
  31. int stencilMask = 0;
  32. if (clearStencil)
  33. {
  34. stencilMask = _context.State.GetStencilTestState().FrontMask;
  35. }
  36. _context.Renderer.GraphicsPipeline.ClearRenderTargetDepthStencil(
  37. depthValue,
  38. clearDepth,
  39. stencilValue,
  40. stencilMask);
  41. }
  42. }
  43. }
  44. }