MethodClear.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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(GpuState state, int argument)
  8. {
  9. UpdateRenderTargetState(state, useControl: false);
  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 = 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 = state.Get<float>(MethodOffset.ClearDepthValue);
  28. int stencilValue = state.Get<int> (MethodOffset.ClearStencilValue);
  29. int stencilMask = 0;
  30. if (clearStencil)
  31. {
  32. stencilMask = state.Get<StencilTestState>(MethodOffset.StencilTestState).FrontMask;
  33. }
  34. _context.Renderer.Pipeline.ClearRenderTargetDepthStencil(
  35. depthValue,
  36. clearDepth,
  37. stencilValue,
  38. stencilMask);
  39. }
  40. UpdateRenderTargetState(state, useControl: true);
  41. }
  42. }
  43. }