// // Copyright 2020 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // #ifndef PXR_IMAGING_HGI_GRAPHICS_PIPELINE_H #define PXR_IMAGING_HGI_GRAPHICS_PIPELINE_H #include "pxr/pxr.h" #include "pxr/imaging/hgi/api.h" #include "pxr/imaging/hgi/attachmentDesc.h" #include "pxr/imaging/hgi/enums.h" #include "pxr/imaging/hgi/handle.h" #include "pxr/imaging/hgi/resourceBindings.h" #include "pxr/imaging/hgi/shaderProgram.h" #include "pxr/imaging/hgi/types.h" #include #include PXR_NAMESPACE_OPEN_SCOPE /// \struct HgiVertexAttributeDesc /// /// Describes one attribute of a vertex. /// /// /// struct HgiVertexAttributeDesc { HGI_API HgiVertexAttributeDesc(); HgiFormat format; uint32_t offset; uint32_t shaderBindLocation; }; using HgiVertexAttributeDescVector = std::vector; HGI_API bool operator==( const HgiVertexAttributeDesc& lhs, const HgiVertexAttributeDesc& rhs); HGI_API inline bool operator!=( const HgiVertexAttributeDesc& lhs, const HgiVertexAttributeDesc& rhs); /// \struct HgiVertexBufferDesc /// /// Describes the attributes of a vertex buffer. /// ///
    ///
  • bindingIndex: /// Binding location for this vertex buffer.
  • ///
  • vertexAttributes: /// List of vertex attributes (in vertex buffer).
  • ///
  • vertexStride: /// The byte size of a vertex (distance between two vertices).
  • ///
/// struct HgiVertexBufferDesc { HGI_API HgiVertexBufferDesc(); uint32_t bindingIndex; HgiVertexAttributeDescVector vertexAttributes; uint32_t vertexStride; }; using HgiVertexBufferDescVector = std::vector; HGI_API bool operator==( const HgiVertexBufferDesc& lhs, const HgiVertexBufferDesc& rhs); HGI_API inline bool operator!=( const HgiVertexBufferDesc& lhs, const HgiVertexBufferDesc& rhs); /// \struct HgiMultiSampleState /// /// Properties to configure multi sampling. /// ///
    ///
  • alphaToCoverageEnable: /// Fragment’s color.a determines coverage (screen door transparency).
  • /// struct HgiMultiSampleState { HGI_API HgiMultiSampleState(); bool alphaToCoverageEnable; }; HGI_API bool operator==( const HgiMultiSampleState& lhs, const HgiMultiSampleState& rhs); HGI_API bool operator!=( const HgiMultiSampleState& lhs, const HgiMultiSampleState& rhs); /// \struct HgiRasterizationState /// /// Properties to configure multi sampling. /// ///
      ///
    • polygonMode: /// Determines the rasterization draw mode of primitve (triangles).
    • ///
    • lineWidth: /// The width of lines when polygonMode is set to line drawing.
    • ///
    • cullMode: /// Determines the culling rules for primitives (triangles).
    • ///
    • winding: /// The rule that determines what makes a front-facing primitive.
    • ///
    • rasterizationEnabled: /// When false all primitives are discarded before rasterization stage.
    • ///
    /// struct HgiRasterizationState { HGI_API HgiRasterizationState(); HgiPolygonMode polygonMode; float lineWidth; HgiCullMode cullMode; HgiWinding winding; bool rasterizerEnabled; }; HGI_API bool operator==( const HgiRasterizationState& lhs, const HgiRasterizationState& rhs); HGI_API bool operator!=( const HgiRasterizationState& lhs, const HgiRasterizationState& rhs); /// \struct HgiDepthStencilState /// /// Properties to configure depth and stencil test. /// ///
      ///
    • depthTestEnabled: /// When enabled uses `depthCompareFn` to test if a fragment passes the /// depth test. Note that depth writes are automatically disabled when /// depthTestEnabled is false.
    • ///
    • depthWriteEnabled: /// When enabled uses `depthCompareFn` to test if a fragment passes the /// depth test. Note that depth writes are automatically disabled when /// depthTestEnabled is false.
    • ///
    • stencilTestEnabled: /// Enables the stencil test.
    • ///
    /// struct HgiDepthStencilState { HGI_API HgiDepthStencilState(); bool depthTestEnabled; bool depthWriteEnabled; HgiCompareFunction depthCompareFn; bool stencilTestEnabled; }; HGI_API bool operator==( const HgiDepthStencilState& lhs, const HgiDepthStencilState& rhs); HGI_API bool operator!=( const HgiDepthStencilState& lhs, const HgiDepthStencilState& rhs); /// \struct HgiPipelineDesc /// /// Describes the properties needed to create a GPU pipeline. /// ///
      ///
    • resourceBindings: /// The resource bindings that will be bound when the pipeline is used. /// Primarily used to query the vertex attributes.
    • ///
    • shaderProgram: /// Shader functions/stages used in this pipeline.
    • ///
    • depthState: /// (Graphics pipeline only) /// Describes depth state for a pipeline.
    • ///
    • multiSampleState: /// (Graphics pipeline only) /// Various settings to control multi-sampling.
    • ///
    • rasterizationState: /// (Graphics pipeline only) /// Various settings to control rasterization.
    • ///
    • vertexBuffers: /// Description of the vertex buffers (per-vertex attributes). /// The actual VBOs are bound via GraphicsCmds.
    • ///
    • colorAttachmentDescs: /// Describes each of the color attachments.
    • ///
    • depthAttachmentDesc: /// Describes the depth attachment (optional)
    • ///
    /// struct HgiGraphicsPipelineDesc { HGI_API HgiGraphicsPipelineDesc(); std::string debugName; HgiResourceBindingsHandle resourceBindings; HgiShaderProgramHandle shaderProgram; HgiDepthStencilState depthState; HgiMultiSampleState multiSampleState; HgiRasterizationState rasterizationState; HgiVertexBufferDescVector vertexBuffers; HgiAttachmentDescVector colorAttachmentDescs; HgiAttachmentDesc depthAttachmentDesc; }; HGI_API bool operator==( const HgiGraphicsPipelineDesc& lhs, const HgiGraphicsPipelineDesc& rhs); HGI_API bool operator!=( const HgiGraphicsPipelineDesc& lhs, const HgiGraphicsPipelineDesc& rhs); /// /// \class HgiGraphicsPipeline /// /// Represents a graphics platform independent GPU graphics pipeline /// resource. /// /// Base class for Hgi pipelines. /// To the client (HdSt) pipeline resources are referred to via /// opaque, stateless handles (HgiPipelineHandle). /// class HgiGraphicsPipeline { public: HGI_API virtual ~HgiGraphicsPipeline(); /// The descriptor describes the object. HGI_API HgiGraphicsPipelineDesc const& GetDescriptor() const; protected: HGI_API HgiGraphicsPipeline(HgiGraphicsPipelineDesc const& desc); HgiGraphicsPipelineDesc _descriptor; private: HgiGraphicsPipeline() = delete; HgiGraphicsPipeline & operator=(const HgiGraphicsPipeline&) = delete; HgiGraphicsPipeline(const HgiGraphicsPipeline&) = delete; }; /// Explicitly instantiate and define pipeline handle template class HgiHandle; using HgiGraphicsPipelineHandle = HgiHandle; using HgiGraphicsPipelineHandleVector = std::vector; PXR_NAMESPACE_CLOSE_SCOPE #endif