MethodClear.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. UpdateRenderTargetStateIfNeeded();
  10. _textureManager.CommitGraphicsBindings();
  11. bool clearDepth = (argument & 1) != 0;
  12. bool clearStencil = (argument & 2) != 0;
  13. uint componentMask = (uint)((argument >> 2) & 0xf);
  14. int index = (argument >> 6) & 0xf;
  15. if (componentMask != 0)
  16. {
  17. var clearColor = _context.State.Get<ClearColors>(MethodOffset.ClearColors);
  18. ColorF color = new ColorF(
  19. clearColor.Red,
  20. clearColor.Green,
  21. clearColor.Blue,
  22. clearColor.Alpha);
  23. _context.Renderer.Pipeline.ClearRenderTargetColor(index, componentMask, color);
  24. }
  25. if (clearDepth || clearStencil)
  26. {
  27. float depthValue = _context.State.Get<float>(MethodOffset.ClearDepthValue);
  28. int stencilValue = _context.State.Get<int> (MethodOffset.ClearStencilValue);
  29. int stencilMask = 0;
  30. if (clearStencil)
  31. {
  32. stencilMask = _context.State.Get<StencilTestState>(MethodOffset.StencilTestState).FrontMask;
  33. }
  34. _context.Renderer.Pipeline.ClearRenderTargetDepthStencil(
  35. depthValue,
  36. clearDepth,
  37. stencilValue,
  38. stencilMask);
  39. }
  40. }
  41. }
  42. }