chromium/third_party/dawn/src/dawn/native/CommandBufferStateTracker.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/CommandBufferStateTracker.h"

#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include <variant>

#include "absl/container/flat_hash_map.h"
#include "absl/container/inlined_vector.h"
#include "dawn/common/Assert.h"
#include "dawn/common/BitSetIterator.h"
#include "dawn/native/BindGroup.h"
#include "dawn/native/ComputePassEncoder.h"
#include "dawn/native/ComputePipeline.h"
#include "dawn/native/Forward.h"
#include "dawn/native/ObjectType_autogen.h"
#include "dawn/native/PipelineLayout.h"
#include "dawn/native/RenderPipeline.h"

// TODO(dawn:563): None of the error messages in this file include the buffer objects they are
// validating against. It would be nice to improve that, but difficult to do without incurring
// additional tracking costs.

namespace dawn::native {

namespace {
// Returns nullopt if all buffers in unverifiedBufferSizes are at least large enough to satisfy the
// minimum listed in pipelineMinBufferSizes, or the index of the first detected failing buffer
// otherwise.
std::optional<uint32_t> FindFirstUndersizedBuffer(
    const ityp::span<uint32_t, uint64_t> unverifiedBufferSizes,
    const std::vector<uint64_t>& pipelineMinBufferSizes) {}

struct BufferAliasing {};

struct TextureAliasing {};

WritableBindingAliasingResult;

template <typename Return>
Return FindStorageBufferBindingAliasing(const PipelineLayoutBase* pipelineLayout,
                                        const PerBindGroup<BindGroupBase*>& bindGroups,
                                        const PerBindGroup<std::vector<uint32_t>>& dynamicOffsets) {}

bool TextureViewsMatch(const TextureViewBase* a, const TextureViewBase* b) {}

VectorOfTextureViews;

bool TextureViewsAllMatch(const VectorOfTextureViews& views) {}

}  // namespace

enum ValidationAspect {};
static_assert;

static constexpr CommandBufferStateTracker::ValidationAspects kDispatchAspects =;

static constexpr CommandBufferStateTracker::ValidationAspects kDrawAspects =;

static constexpr CommandBufferStateTracker::ValidationAspects kDrawIndexedAspects =;

static constexpr CommandBufferStateTracker::ValidationAspects kLazyAspects =;

CommandBufferStateTracker::CommandBufferStateTracker() = default;

CommandBufferStateTracker::CommandBufferStateTracker(const CommandBufferStateTracker&) = default;

CommandBufferStateTracker::CommandBufferStateTracker(CommandBufferStateTracker&&) = default;

CommandBufferStateTracker::~CommandBufferStateTracker() = default;

CommandBufferStateTracker& CommandBufferStateTracker::operator=(const CommandBufferStateTracker&) =
    default;

CommandBufferStateTracker& CommandBufferStateTracker::operator=(CommandBufferStateTracker&&) =
    default;

MaybeError CommandBufferStateTracker::ValidateCanDispatch() {}

MaybeError CommandBufferStateTracker::ValidateCanDraw() {}

MaybeError CommandBufferStateTracker::ValidateCanDrawIndexed() {}

MaybeError CommandBufferStateTracker::ValidateNoDifferentTextureViewsOnSameTexture() {}

MaybeError CommandBufferStateTracker::ValidateBufferInRangeForVertexBuffer(uint32_t vertexCount,
                                                                           uint32_t firstVertex) {}

MaybeError CommandBufferStateTracker::ValidateBufferInRangeForInstanceBuffer(
    uint32_t instanceCount,
    uint32_t firstInstance) {}

MaybeError CommandBufferStateTracker::ValidateIndexBufferInRange(uint32_t indexCount,
                                                                 uint32_t firstIndex) {}

MaybeError CommandBufferStateTracker::ValidateOperation(ValidationAspects requiredAspects) {}

void CommandBufferStateTracker::RecomputeLazyAspects(ValidationAspects aspects) {}

MaybeError CommandBufferStateTracker::CheckMissingAspects(ValidationAspects aspects) {}

void CommandBufferStateTracker::SetComputePipeline(ComputePipelineBase* pipeline) {}

void CommandBufferStateTracker::SetRenderPipeline(RenderPipelineBase* pipeline) {}

void CommandBufferStateTracker::UnsetBindGroup(BindGroupIndex index) {}
void CommandBufferStateTracker::SetBindGroup(BindGroupIndex index,
                                             BindGroupBase* bindgroup,
                                             uint32_t dynamicOffsetCount,
                                             const uint32_t* dynamicOffsets) {}

void CommandBufferStateTracker::SetIndexBuffer(BufferBase* buffer,
                                               wgpu::IndexFormat format,
                                               uint64_t offset,
                                               uint64_t size) {}

void CommandBufferStateTracker::UnsetVertexBuffer(VertexBufferSlot slot) {}

void CommandBufferStateTracker::SetVertexBuffer(VertexBufferSlot slot, uint64_t size) {}

void CommandBufferStateTracker::SetPipelineCommon(PipelineBase* pipeline) {}

BindGroupBase* CommandBufferStateTracker::GetBindGroup(BindGroupIndex index) const {}

const std::vector<uint32_t>& CommandBufferStateTracker::GetDynamicOffsets(
    BindGroupIndex index) const {}

bool CommandBufferStateTracker::HasPipeline() const {}

bool CommandBufferStateTracker::IndexBufferSet() const {}

RenderPipelineBase* CommandBufferStateTracker::GetRenderPipeline() const {}

ComputePipelineBase* CommandBufferStateTracker::GetComputePipeline() const {}

PipelineLayoutBase* CommandBufferStateTracker::GetPipelineLayout() const {}

BufferBase* CommandBufferStateTracker::GetIndexBuffer() const {}

wgpu::IndexFormat CommandBufferStateTracker::GetIndexFormat() const {}

uint64_t CommandBufferStateTracker::GetIndexBufferSize() const {}

uint64_t CommandBufferStateTracker::GetIndexBufferOffset() const {}

void CommandBufferStateTracker::End() {}

}  // namespace dawn::native