chromium/third_party/dawn/src/dawn/native/RenderPipeline.cpp

// Copyright 2017 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#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{};

        // clang-format off
        table[wgpu::VertexFormat::Uint8x2        ] =;

const VertexFormatInfo& GetVertexFormatInfo(wgpu::VertexFormat format) {}

// Helper functions
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) {}
}  // anonymous namespace

// Helper functions
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::RenderPipelineBase(DeviceBase* device,
                                       const UnpackedPtr<RenderPipelineDescriptor>& descriptor)
    :{}

RenderPipelineBase::RenderPipelineBase(DeviceBase* device,
                                       ObjectBase::ErrorTag tag,
                                       const char* label)
    :{}

RenderPipelineBase::~RenderPipelineBase() = default;

void RenderPipelineBase::DestroyImpl() {}

// static
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 {}

}  // namespace dawn::native