BsVulkanGpuPipelineState.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsVulkanPrerequisites.h"
  5. #include "BsVulkanResource.h"
  6. #include "BsGpuPipelineState.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Vulkan
  10. * @{
  11. */
  12. /** Wrapper around a Vulkan graphics pipeline that manages its usage and lifetime. */
  13. class VulkanPipeline : public VulkanResource
  14. {
  15. public:
  16. VulkanPipeline(VulkanResourceManager* owner, VkPipeline pipeline);
  17. ~VulkanPipeline();
  18. /** Returns the internal handle to the Vulkan object. */
  19. VkPipeline getHandle() const { return mPipeline; }
  20. private:
  21. VkPipeline mPipeline;
  22. };
  23. /** Vulkan implementation of a graphics pipeline state. */
  24. class VulkanGraphicsPipelineStateCore : public GraphicsPipelineStateCore
  25. {
  26. public:
  27. ~VulkanGraphicsPipelineStateCore();
  28. protected:
  29. friend class VulkanRenderStateCoreManager;
  30. VulkanGraphicsPipelineStateCore(const PIPELINE_STATE_CORE_DESC& desc, GpuDeviceFlags deviceMask);
  31. /** @copydoc GraphicsPipelineStateCore::initialize */
  32. void initialize() override;
  33. /**
  34. * Create a new Vulkan graphics pipeline.
  35. *
  36. * @param[in] deviceIdx Index of the device to create the pipeline for.
  37. * @param[in] framebuffer Framebuffer object that defines the surfaces this pipeline will render to.
  38. * @param[in] readOnlyDepth True if the pipeline is only allowed to read the depth buffer, without writes.
  39. * @param[in] drawOp Type of geometry that will be drawn using the pipeline.
  40. * @param[in] vertexInputState State describing inputs to the vertex program.
  41. * @return Vulkan graphics pipeline object.
  42. */
  43. VkPipeline createPipeline(UINT32 deviceIdx, VulkanFramebuffer* framebuffer, bool readOnlyDepth,
  44. DrawOperationType drawOp, VkPipelineVertexInputStateCreateInfo* vertexInputState);
  45. /** Contains pipeline data specific to a single Vulkan device. */
  46. struct PerDeviceData
  47. {
  48. VulkanDevice* device;
  49. VkPipelineLayout pipelineLayout;
  50. };
  51. VkPipelineShaderStageCreateInfo mShaderStageInfos[5];
  52. VkPipelineInputAssemblyStateCreateInfo mInputAssemblyInfo;
  53. VkPipelineTessellationStateCreateInfo mTesselationInfo;
  54. VkPipelineViewportStateCreateInfo mViewportInfo;
  55. VkPipelineRasterizationStateCreateInfo mRasterizationInfo;
  56. VkPipelineMultisampleStateCreateInfo mMultiSampleInfo;
  57. VkPipelineDepthStencilStateCreateInfo mDepthStencilInfo;
  58. VkPipelineColorBlendAttachmentState mAttachmentBlendStates[BS_MAX_MULTIPLE_RENDER_TARGETS];
  59. VkPipelineColorBlendStateCreateInfo mColorBlendStateInfo;
  60. VkPipelineDynamicStateCreateInfo mDynamicStateInfo;
  61. VkDynamicState mDynamicStates[3];
  62. VkGraphicsPipelineCreateInfo mPipelineInfo;
  63. GpuDeviceFlags mDeviceMask;
  64. PerDeviceData mPerDeviceData[BS_MAX_DEVICES];
  65. };
  66. /** Vulkan implementation of a compute pipeline state. */
  67. class VulkanComputePipelineStateCore : public ComputePipelineStateCore
  68. {
  69. public:
  70. ~VulkanComputePipelineStateCore();
  71. protected:
  72. friend class VulkanRenderStateCoreManager;
  73. VulkanComputePipelineStateCore(const SPtr<GpuProgramCore>& program, GpuDeviceFlags deviceMask);
  74. /** @copydoc ComputePipelineStateCore::initialize */
  75. void initialize() override;
  76. /** Contains pipeline data specific to a single Vulkan device. */
  77. struct PerDeviceData
  78. {
  79. VulkanDevice* device;
  80. VulkanPipeline* pipeline;
  81. };
  82. GpuDeviceFlags mDeviceMask;
  83. PerDeviceData mPerDeviceData[BS_MAX_DEVICES];
  84. };
  85. /** @} */
  86. }