#include "dawn/native/RenderPipeline.h"
#include <algorithm>
#include <cmath>
#include "dawn/common/BitSetIterator.h"
#include "dawn/common/Enumerator.h"
#include "dawn/common/ityp_array.h"
#include "dawn/common/ityp_span.h"
#include "dawn/native/ChainUtils.h"
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Commands.h"
#include "dawn/native/Device.h"
#include "dawn/native/InternalPipelineStore.h"
#include "dawn/native/ObjectContentHasher.h"
#include "dawn/native/ObjectType_autogen.h"
#include "dawn/native/ValidationUtils_autogen.h"
namespace dawn::native {
static constexpr ityp::array<wgpu::VertexFormat, VertexFormatInfo, 32> sVertexFormatTable = …::array<wgpu::VertexFormat, VertexFormatInfo, 32> table{ … };
table[wgpu::VertexFormat::Uint8x2 ] = …;
const VertexFormatInfo& GetVertexFormatInfo(wgpu::VertexFormat format) { … }
namespace {
MaybeError ValidateVertexAttribute(DeviceBase* device,
const VertexAttribute* attribute,
const EntryPointMetadata& metadata,
uint64_t vertexBufferStride,
VertexAttributeMask* attributesSetMask) { … }
MaybeError ValidateVertexBufferLayout(DeviceBase* device,
const VertexBufferLayout* buffer,
const EntryPointMetadata& metadata,
VertexAttributeMask* attributesSetMask) { … }
ResultOrError<ShaderModuleEntryPoint> ValidateVertexState(
DeviceBase* device,
const VertexState* descriptor,
const PipelineLayoutBase* layout,
wgpu::PrimitiveTopology primitiveTopology) { … }
MaybeError ValidatePrimitiveState(const DeviceBase* device, const PrimitiveState* rawDescriptor) { … }
MaybeError ValidateStencilFaceUnused(StencilFaceState face) { … }
MaybeError ValidateDepthStencilState(const DeviceBase* device,
const DepthStencilState* descriptor,
const wgpu::PrimitiveTopology topology) { … }
MaybeError ValidateMultisampleState(const DeviceBase* device, const MultisampleState* descriptor) { … }
MaybeError ValidateBlendComponent(BlendComponent blendComponent, bool dualSourceBlendingEnabled) { … }
MaybeError ValidateBlendState(DeviceBase* device, const BlendState* descriptor) { … }
bool BlendFactorContainsSrcAlpha(wgpu::BlendFactor blendFactor) { … }
bool BlendFactorContainsSrc1(wgpu::BlendFactor blendFactor) { … }
bool BlendStateUsesBlendFactorSrc1(const BlendState& blend) { … }
MaybeError ValidateColorTargetState(
DeviceBase* device,
const ColorTargetState& descriptor,
const Format* format,
bool fragmentWritten,
const EntryPointMetadata::FragmentRenderAttachmentInfo& fragmentOutputVariable,
const MultisampleState& multisample) { … }
MaybeError ValidateFramebufferInput(
DeviceBase* device,
const Format* format,
const EntryPointMetadata::FragmentRenderAttachmentInfo& inputVar) { … }
MaybeError ValidateColorTargetStatesMatch(ColorAttachmentIndex firstColorTargetIndex,
const ColorTargetState* const firstColorTargetState,
ColorAttachmentIndex targetIndex,
const ColorTargetState* target) { … }
ResultOrError<ShaderModuleEntryPoint> ValidateFragmentState(DeviceBase* device,
const FragmentState* descriptor,
const PipelineLayoutBase* layout,
const DepthStencilState* depthStencil,
const MultisampleState& multisample) { … }
MaybeError ValidateInterStageMatching(DeviceBase* device,
const VertexState& vertexState,
const ShaderModuleEntryPoint& vertexEntryPoint,
const FragmentState& fragmentState,
const ShaderModuleEntryPoint& fragmentEntryPoint) { … }
}
size_t IndexFormatSize(wgpu::IndexFormat format) { … }
bool IsStripPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) { … }
MaybeError ValidateRenderPipelineDescriptor(DeviceBase* device,
const RenderPipelineDescriptor* descriptor) { … }
std::vector<StageAndDescriptor> GetRenderStagesAndSetPlaceholderShader(
DeviceBase* device,
const RenderPipelineDescriptor* descriptor) { … }
RenderPipelineBase::RenderPipelineBase(DeviceBase* device,
const UnpackedPtr<RenderPipelineDescriptor>& descriptor)
: … { … }
RenderPipelineBase::RenderPipelineBase(DeviceBase* device,
ObjectBase::ErrorTag tag,
const char* label)
: … { … }
RenderPipelineBase::~RenderPipelineBase() = default;
void RenderPipelineBase::DestroyImpl() { … }
Ref<RenderPipelineBase> RenderPipelineBase::MakeError(DeviceBase* device, const char* label) { … }
ObjectType RenderPipelineBase::GetType() const { … }
const VertexAttributeMask& RenderPipelineBase::GetAttributeLocationsUsed() const { … }
const VertexAttributeInfo& RenderPipelineBase::GetAttribute(
VertexAttributeLocation location) const { … }
const VertexBufferMask& RenderPipelineBase::GetVertexBuffersUsed() const { … }
const VertexBufferMask& RenderPipelineBase::GetVertexBuffersUsedAsVertexBuffer() const { … }
const VertexBufferMask& RenderPipelineBase::GetVertexBuffersUsedAsInstanceBuffer() const { … }
const VertexBufferInfo& RenderPipelineBase::GetVertexBuffer(VertexBufferSlot slot) const { … }
uint32_t RenderPipelineBase::GetVertexBufferCount() const { … }
const ColorTargetState* RenderPipelineBase::GetColorTargetState(
ColorAttachmentIndex attachmentSlot) const { … }
const DepthStencilState* RenderPipelineBase::GetDepthStencilState() const { … }
bool RenderPipelineBase::UsesStencil() const { … }
wgpu::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const { … }
wgpu::IndexFormat RenderPipelineBase::GetStripIndexFormat() const { … }
wgpu::CullMode RenderPipelineBase::GetCullMode() const { … }
wgpu::FrontFace RenderPipelineBase::GetFrontFace() const { … }
bool RenderPipelineBase::IsDepthBiasEnabled() const { … }
int32_t RenderPipelineBase::GetDepthBias() const { … }
float RenderPipelineBase::GetDepthBiasSlopeScale() const { … }
float RenderPipelineBase::GetDepthBiasClamp() const { … }
bool RenderPipelineBase::HasUnclippedDepth() const { … }
ColorAttachmentMask RenderPipelineBase::GetColorAttachmentsMask() const { … }
bool RenderPipelineBase::HasDepthStencilAttachment() const { … }
wgpu::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(
ColorAttachmentIndex attachment) const { … }
wgpu::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const { … }
uint32_t RenderPipelineBase::GetSampleCount() const { … }
uint32_t RenderPipelineBase::GetSampleMask() const { … }
bool RenderPipelineBase::IsAlphaToCoverageEnabled() const { … }
const AttachmentState* RenderPipelineBase::GetAttachmentState() const { … }
bool RenderPipelineBase::WritesDepth() const { … }
bool RenderPipelineBase::WritesStencil() const { … }
bool RenderPipelineBase::UsesFragDepth() const { … }
bool RenderPipelineBase::UsesVertexIndex() const { … }
bool RenderPipelineBase::UsesInstanceIndex() const { … }
size_t RenderPipelineBase::ComputeContentHash() { … }
bool RenderPipelineBase::EqualityFunc::operator()(const RenderPipelineBase* a,
const RenderPipelineBase* b) const { … }
}