PipelineHelperShader.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Silk.NET.Vulkan;
  2. using VkFormat = Silk.NET.Vulkan.Format;
  3. namespace Ryujinx.Graphics.Vulkan
  4. {
  5. class PipelineHelperShader : PipelineBase
  6. {
  7. public PipelineHelperShader(VulkanRenderer gd, Device device) : base(gd, device)
  8. {
  9. }
  10. public void SetRenderTarget(Auto<DisposableImageView> view, uint width, uint height, bool isDepthStencil, VkFormat format)
  11. {
  12. SetRenderTarget(view, width, height, 1u, isDepthStencil, format);
  13. }
  14. public void SetRenderTarget(Auto<DisposableImageView> view, uint width, uint height, uint samples, bool isDepthStencil, VkFormat format)
  15. {
  16. CreateFramebuffer(view, width, height, samples, isDepthStencil, format);
  17. CreateRenderPass();
  18. SignalStateChange();
  19. }
  20. private void CreateFramebuffer(Auto<DisposableImageView> view, uint width, uint height, uint samples, bool isDepthStencil, VkFormat format)
  21. {
  22. FramebufferParams = new FramebufferParams(Device, view, width, height, samples, isDepthStencil, format);
  23. UpdatePipelineAttachmentFormats();
  24. }
  25. public void SetCommandBuffer(CommandBufferScoped cbs)
  26. {
  27. CommandBuffer = (Cbs = cbs).CommandBuffer;
  28. // Restore per-command buffer state.
  29. if (Pipeline != null)
  30. {
  31. Gd.Api.CmdBindPipeline(CommandBuffer, Pbp, Pipeline.Get(CurrentCommandBuffer).Value);
  32. }
  33. SignalCommandBufferChange();
  34. }
  35. public void Finish()
  36. {
  37. EndRenderPass();
  38. }
  39. public void Finish(VulkanRenderer gd, CommandBufferScoped cbs)
  40. {
  41. Finish();
  42. if (gd.PipelineInternal.IsCommandBufferActive(cbs.CommandBuffer))
  43. {
  44. gd.PipelineInternal.Restore();
  45. }
  46. }
  47. }
  48. }