PipelineHelperShader.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. CreateFramebuffer(view, width, height, isDepthStencil, format);
  13. CreateRenderPass();
  14. SignalStateChange();
  15. }
  16. private void CreateFramebuffer(Auto<DisposableImageView> view, uint width, uint height, bool isDepthStencil, VkFormat format)
  17. {
  18. FramebufferParams = new FramebufferParams(Device, view, width, height, isDepthStencil, format);
  19. UpdatePipelineAttachmentFormats();
  20. }
  21. public void SetCommandBuffer(CommandBufferScoped cbs)
  22. {
  23. CommandBuffer = (Cbs = cbs).CommandBuffer;
  24. // Restore per-command buffer state.
  25. if (Pipeline != null)
  26. {
  27. Gd.Api.CmdBindPipeline(CommandBuffer, Pbp, Pipeline.Get(CurrentCommandBuffer).Value);
  28. }
  29. SignalCommandBufferChange();
  30. }
  31. public void Finish()
  32. {
  33. EndRenderPass();
  34. }
  35. public void Finish(VulkanRenderer gd, CommandBufferScoped cbs)
  36. {
  37. Finish();
  38. if (gd.PipelineInternal.IsCommandBufferActive(cbs.CommandBuffer))
  39. {
  40. gd.PipelineInternal.Restore();
  41. }
  42. }
  43. }
  44. }