#include "dawn/native/CommandValidation.h"
#include <algorithm>
#include <array>
#include <limits>
#include <sstream>
#include <string>
#include <utility>
#include "dawn/common/BitSetIterator.h"
#include "dawn/common/Numeric.h"
#include "dawn/native/BindGroup.h"
#include "dawn/native/Buffer.h"
#include "dawn/native/CommandBufferStateTracker.h"
#include "dawn/native/Commands.h"
#include "dawn/native/Device.h"
#include "dawn/native/Instance.h"
#include "dawn/native/PassResourceUsage.h"
#include "dawn/native/PhysicalDevice.h"
#include "dawn/native/QuerySet.h"
#include "dawn/native/RenderBundle.h"
#include "dawn/native/RenderPipeline.h"
#include "dawn/native/ValidationUtils_autogen.h"
#include "dawn/native/webgpu_absl_format.h"
namespace dawn::native {
namespace {
std::string ToBufferSyncScopeResourceUsage(wgpu::BufferUsage syncScopeBufferUsage) { … }
std::string ToTextureSyncScopeResourceUsage(wgpu::TextureUsage syncScopeTextureUsage) { … }
}
MaybeError ValidateSyncScopeResourceUsage(const SyncScopeResourceUsage& scope) { … }
MaybeError ValidateTimestampQuery(const DeviceBase* device,
const QuerySetBase* querySet,
uint32_t queryIndex,
Feature requiredFeature) { … }
MaybeError ValidatePassTimestampWrites(const DeviceBase* device,
const QuerySetBase* querySet,
uint32_t beginningOfPassWriteIndex,
uint32_t endOfPassWriteIndex) { … }
MaybeError ValidateWriteBuffer(const DeviceBase* device,
const BufferBase* buffer,
uint64_t bufferOffset,
uint64_t size) { … }
bool IsRangeOverlapped(uint32_t startA, uint32_t startB, uint32_t length) { … }
ResultOrError<uint64_t> ComputeRequiredBytesInCopy(const TexelBlockInfo& blockInfo,
const Extent3D& copySize,
uint32_t bytesPerRow,
uint32_t rowsPerImage) { … }
MaybeError ValidateCopySizeFitsInBuffer(const Ref<BufferBase>& buffer,
uint64_t offset,
uint64_t size,
BufferSizeType checkBufferSizeType) { … }
void ApplyDefaultTextureDataLayoutOptions(TextureDataLayout* layout,
const TexelBlockInfo& blockInfo,
const Extent3D& copyExtent) { … }
MaybeError ValidateLinearTextureData(const TextureDataLayout& layout,
uint64_t byteSize,
const TexelBlockInfo& blockInfo,
const Extent3D& copyExtent) { … }
MaybeError ValidateImageCopyBuffer(DeviceBase const* device,
const ImageCopyBuffer& imageCopyBuffer) { … }
MaybeError ValidateImageCopyTexture(DeviceBase const* device,
const ImageCopyTexture& textureCopy,
const Extent3D& copySize) { … }
MaybeError ValidateTextureCopyRange(DeviceBase const* device,
const ImageCopyTexture& textureCopy,
const Extent3D& copySize) { … }
ResultOrError<Aspect> SingleAspectUsedByImageCopyTexture(const ImageCopyTexture& view) { … }
MaybeError ValidateLinearToDepthStencilCopyRestrictions(const ImageCopyTexture& dst) { … }
MaybeError ValidateTextureToTextureCopyCommonRestrictions(DeviceBase const* device,
const ImageCopyTexture& src,
const ImageCopyTexture& dst,
const Extent3D& copySize) { … }
MaybeError ValidateTextureToTextureCopyRestrictions(DeviceBase const* device,
const ImageCopyTexture& src,
const ImageCopyTexture& dst,
const Extent3D& copySize) { … }
MaybeError ValidateCanUseAs(const TextureBase* texture,
wgpu::TextureUsage usage,
UsageValidationMode mode) { … }
MaybeError ValidateCanUseAs(const BufferBase* buffer, wgpu::BufferUsage usage) { … }
MaybeError ValidateCanUseAsInternal(const BufferBase* buffer, wgpu::BufferUsage usage) { … }
namespace {
std::string TextureFormatsToString(const ColorAttachmentFormats& formats) { … }
}
MaybeError ValidateColorAttachmentBytesPerSample(DeviceBase* device,
const ColorAttachmentFormats& formats) { … }
MaybeError ValidatePLSInfo(
const DeviceBase* device,
uint64_t totalSize,
ityp::span<size_t, StorageAttachmentInfoForValidation> storageAttachments) { … }
}