2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-07-14 14:58:07 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-07-24 14:42:33 +00:00
|
|
|
#ifndef DAWNNATIVE_RENDERPIPELINE_H_
|
|
|
|
#define DAWNNATIVE_RENDERPIPELINE_H_
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2020-09-17 19:07:00 +00:00
|
|
|
#include "common/TypedInteger.h"
|
2019-07-26 19:08:18 +00:00
|
|
|
#include "dawn_native/AttachmentState.h"
|
2020-09-17 19:07:00 +00:00
|
|
|
#include "dawn_native/IntegerTypes.h"
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/Pipeline.h"
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2018-07-25 15:03:23 +00:00
|
|
|
#include "dawn_native/dawn_platform.h"
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2017-07-26 20:59:53 +00:00
|
|
|
#include <array>
|
|
|
|
#include <bitset>
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
namespace dawn_native {
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2019-02-18 08:56:03 +00:00
|
|
|
struct BeginRenderPassCmd;
|
|
|
|
|
2018-12-10 19:47:22 +00:00
|
|
|
class DeviceBase;
|
2020-09-02 15:57:39 +00:00
|
|
|
struct EntryPointMetadata;
|
2019-11-13 17:00:37 +00:00
|
|
|
class RenderBundleEncoder;
|
2018-12-10 19:47:22 +00:00
|
|
|
|
2020-09-01 18:32:49 +00:00
|
|
|
MaybeError ValidateRenderPipelineDescriptor(DeviceBase* device,
|
2018-12-10 19:47:22 +00:00
|
|
|
const RenderPipelineDescriptor* descriptor);
|
2019-10-23 11:57:41 +00:00
|
|
|
size_t IndexFormatSize(wgpu::IndexFormat format);
|
|
|
|
uint32_t VertexFormatNumComponents(wgpu::VertexFormat format);
|
|
|
|
size_t VertexFormatComponentSize(wgpu::VertexFormat format);
|
|
|
|
size_t VertexFormatSize(wgpu::VertexFormat format);
|
2020-09-01 18:32:49 +00:00
|
|
|
bool IsStripPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology);
|
2019-03-27 18:08:50 +00:00
|
|
|
|
2019-01-04 04:28:37 +00:00
|
|
|
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState);
|
2019-02-16 02:27:30 +00:00
|
|
|
bool BlendEnabled(const ColorStateDescriptor* mColorState);
|
2018-12-10 19:47:22 +00:00
|
|
|
|
2019-06-06 01:56:57 +00:00
|
|
|
struct VertexAttributeInfo {
|
2019-10-23 11:57:41 +00:00
|
|
|
wgpu::VertexFormat format;
|
2019-11-07 22:23:29 +00:00
|
|
|
uint64_t offset;
|
2020-09-17 19:07:00 +00:00
|
|
|
VertexAttributeLocation shaderLocation;
|
|
|
|
VertexBufferSlot vertexBufferSlot;
|
2019-06-06 01:56:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct VertexBufferInfo {
|
2019-11-07 22:23:29 +00:00
|
|
|
uint64_t arrayStride;
|
2019-10-23 11:57:41 +00:00
|
|
|
wgpu::InputStepMode stepMode;
|
2019-06-06 01:56:57 +00:00
|
|
|
};
|
|
|
|
|
2018-10-15 12:54:30 +00:00
|
|
|
class RenderPipelineBase : public PipelineBase {
|
2017-11-24 18:59:42 +00:00
|
|
|
public:
|
2019-10-30 00:20:03 +00:00
|
|
|
RenderPipelineBase(DeviceBase* device, const RenderPipelineDescriptor* descriptor);
|
2019-05-02 15:30:56 +00:00
|
|
|
~RenderPipelineBase() override;
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2019-02-13 13:09:18 +00:00
|
|
|
static RenderPipelineBase* MakeError(DeviceBase* device);
|
|
|
|
|
2019-11-07 22:23:29 +00:00
|
|
|
const VertexStateDescriptor* GetVertexStateDescriptor() const;
|
2020-09-17 19:07:00 +00:00
|
|
|
const ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes>&
|
|
|
|
GetAttributeLocationsUsed() const;
|
|
|
|
const VertexAttributeInfo& GetAttribute(VertexAttributeLocation location) const;
|
|
|
|
const ityp::bitset<VertexBufferSlot, kMaxVertexBuffers>& GetVertexBufferSlotsUsed() const;
|
|
|
|
const VertexBufferInfo& GetVertexBuffer(VertexBufferSlot slot) const;
|
2019-03-27 18:08:50 +00:00
|
|
|
|
2020-09-09 00:08:38 +00:00
|
|
|
const ColorStateDescriptor* GetColorStateDescriptor(
|
|
|
|
ColorAttachmentIndex attachmentSlot) const;
|
2019-05-02 15:30:56 +00:00
|
|
|
const DepthStencilStateDescriptor* GetDepthStencilStateDescriptor() const;
|
2019-10-23 11:57:41 +00:00
|
|
|
wgpu::PrimitiveTopology GetPrimitiveTopology() const;
|
|
|
|
wgpu::CullMode GetCullMode() const;
|
|
|
|
wgpu::FrontFace GetFrontFace() const;
|
2020-10-06 08:12:29 +00:00
|
|
|
bool IsDepthBiasEnabled() const;
|
|
|
|
int32_t GetDepthBias() const;
|
|
|
|
float GetDepthBiasSlopeScale() const;
|
|
|
|
float GetDepthBiasClamp() const;
|
2018-05-02 22:10:13 +00:00
|
|
|
|
2020-09-09 00:08:38 +00:00
|
|
|
ityp::bitset<ColorAttachmentIndex, kMaxColorAttachments> GetColorAttachmentsMask() const;
|
2018-05-02 22:10:13 +00:00
|
|
|
bool HasDepthStencilAttachment() const;
|
2020-09-09 00:08:38 +00:00
|
|
|
wgpu::TextureFormat GetColorAttachmentFormat(ColorAttachmentIndex attachment) const;
|
2019-10-23 11:57:41 +00:00
|
|
|
wgpu::TextureFormat GetDepthStencilFormat() const;
|
2019-03-28 14:18:11 +00:00
|
|
|
uint32_t GetSampleCount() const;
|
2020-07-23 11:30:56 +00:00
|
|
|
uint32_t GetSampleMask() const;
|
2020-07-29 11:44:41 +00:00
|
|
|
bool IsAlphaToCoverageEnabled() const;
|
2018-05-02 22:10:13 +00:00
|
|
|
|
2019-08-13 00:22:28 +00:00
|
|
|
const AttachmentState* GetAttachmentState() const;
|
|
|
|
|
2020-12-03 18:42:13 +00:00
|
|
|
// Functions necessary for the unordered_set<RenderPipelineBase*>-based cache.
|
|
|
|
size_t ComputeContentHash() override;
|
|
|
|
|
2019-05-02 15:30:56 +00:00
|
|
|
struct EqualityFunc {
|
|
|
|
bool operator()(const RenderPipelineBase* a, const RenderPipelineBase* b) const;
|
|
|
|
};
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
private:
|
2019-02-13 13:09:18 +00:00
|
|
|
RenderPipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
|
|
|
|
2019-11-07 22:23:29 +00:00
|
|
|
// Vertex state
|
|
|
|
VertexStateDescriptor mVertexState;
|
2020-09-17 19:07:00 +00:00
|
|
|
ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes> mAttributeLocationsUsed;
|
|
|
|
ityp::array<VertexAttributeLocation, VertexAttributeInfo, kMaxVertexAttributes>
|
|
|
|
mAttributeInfos;
|
|
|
|
ityp::bitset<VertexBufferSlot, kMaxVertexBuffers> mVertexBufferSlotsUsed;
|
|
|
|
ityp::array<VertexBufferSlot, VertexBufferInfo, kMaxVertexBuffers> mVertexBufferInfos;
|
2018-05-02 22:10:13 +00:00
|
|
|
|
2019-05-02 15:30:56 +00:00
|
|
|
// Attachments
|
2019-07-26 19:08:18 +00:00
|
|
|
Ref<AttachmentState> mAttachmentState;
|
2019-05-02 15:30:56 +00:00
|
|
|
DepthStencilStateDescriptor mDepthStencilState;
|
2020-09-09 00:08:38 +00:00
|
|
|
ityp::array<ColorAttachmentIndex, ColorStateDescriptor, kMaxColorAttachments> mColorStates;
|
2019-03-19 01:12:01 +00:00
|
|
|
|
2019-05-02 15:30:56 +00:00
|
|
|
// Other state
|
2019-10-23 11:57:41 +00:00
|
|
|
wgpu::PrimitiveTopology mPrimitiveTopology;
|
2019-05-02 15:30:56 +00:00
|
|
|
RasterizationStateDescriptor mRasterizationState;
|
2019-07-15 20:47:56 +00:00
|
|
|
uint32_t mSampleMask;
|
|
|
|
bool mAlphaToCoverageEnabled;
|
2017-07-14 14:58:07 +00:00
|
|
|
};
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
} // namespace dawn_native
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2018-07-24 14:42:33 +00:00
|
|
|
#endif // DAWNNATIVE_RENDERPIPELINE_H_
|