#include "dawn/native/CommandEncoder.h"
#include <string_view>
#include <utility>
#include <vector>
#include "absl/container/inlined_vector.h"
#include "dawn/common/BitSetIterator.h"
#include "dawn/common/Enumerator.h"
#include "dawn/common/Math.h"
#include "dawn/common/NonMovable.h"
#include "dawn/native/ApplyClearColorValueWithDrawHelper.h"
#include "dawn/native/BindGroup.h"
#include "dawn/native/BlitBufferToDepthStencil.h"
#include "dawn/native/BlitDepthToDepth.h"
#include "dawn/native/BlitTextureToBuffer.h"
#include "dawn/native/Buffer.h"
#include "dawn/native/ChainUtils.h"
#include "dawn/native/CommandBuffer.h"
#include "dawn/native/CommandBufferStateTracker.h"
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Commands.h"
#include "dawn/native/ComputePassEncoder.h"
#include "dawn/native/Device.h"
#include "dawn/native/ErrorData.h"
#include "dawn/native/ObjectType_autogen.h"
#include "dawn/native/QueryHelper.h"
#include "dawn/native/QuerySet.h"
#include "dawn/native/Queue.h"
#include "dawn/native/RenderPassEncoder.h"
#include "dawn/native/RenderPassWorkaroundsHelper.h"
#include "dawn/native/RenderPipeline.h"
#include "dawn/native/ValidationUtils_autogen.h"
#include "dawn/native/utils/WGPUHelpers.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
namespace dawn::native {
namespace {
struct RecordedAttachment { … };
enum class AttachmentType : uint8_t { … };
std::string_view GetAttachmentTypeStr(AttachmentType type) { … }
class RenderPassValidationState final : public NonMovable { … };
MaybeError ValidateB2BCopyAlignment(uint64_t dataSize, uint64_t srcOffset, uint64_t dstOffset) { … }
MaybeError ValidateTextureSampleCountInBufferCopyCommands(const TextureBase* texture) { … }
MaybeError ValidateLinearTextureCopyOffset(const TextureDataLayout& layout,
const TexelBlockInfo& blockInfo,
const bool hasDepthOrStencil) { … }
MaybeError ValidateTextureFormatForTextureToBufferCopyInCompatibilityMode(
const TextureBase* texture) { … }
MaybeError ValidateSourceTextureFormatForTextureToTextureCopyInCompatibilityMode(
const TextureBase* texture) { … }
MaybeError ValidateTextureDepthStencilToBufferCopyRestrictions(const ImageCopyTexture& src) { … }
MaybeError ValidateAttachmentArrayLayersAndLevelCount(const TextureViewBase* attachment) { … }
MaybeError ValidateResolveTarget(const DeviceBase* device,
const RenderPassColorAttachment& colorAttachment,
UsageValidationMode usageValidationMode) { … }
MaybeError ValidateColorAttachmentDepthSlice(const TextureViewBase* attachment,
uint32_t depthSlice) { … }
MaybeError ValidateColorAttachmentRenderToSingleSampled(
const DeviceBase* device,
const RenderPassColorAttachment& colorAttachment,
const DawnRenderPassColorAttachmentRenderToSingleSampled* msaaRenderToSingleSampledDesc) { … }
MaybeError ValidateExpandResolveTextureLoadOp(const DeviceBase* device,
const RenderPassColorAttachment& colorAttachment,
RenderPassValidationState* validationState) { … }
MaybeError ValidateRenderPassColorAttachment(DeviceBase* device,
const RenderPassColorAttachment& colorAttachment,
UsageValidationMode usageValidationMode,
RenderPassValidationState* validationState) { … }
MaybeError ValidateRenderPassDepthStencilAttachment(
DeviceBase* device,
const RenderPassDepthStencilAttachment* depthStencilAttachment,
UsageValidationMode usageValidationMode,
RenderPassValidationState* validationState) { … }
MaybeError ValidateRenderPassPLS(DeviceBase* device,
const RenderPassPixelLocalStorage* pls,
UsageValidationMode usageValidationMode,
RenderPassValidationState* validationState) { … }
ResultOrError<UnpackedPtr<RenderPassDescriptor>> ValidateRenderPassDescriptor(
DeviceBase* device,
const RenderPassDescriptor* rawDescriptor,
UsageValidationMode usageValidationMode,
RenderPassValidationState* validationState) { … }
MaybeError ValidateComputePassDescriptor(const DeviceBase* device,
const ComputePassDescriptor* descriptor) { … }
MaybeError ValidateQuerySetResolve(const QuerySetBase* querySet,
uint32_t firstQuery,
uint32_t queryCount,
const BufferBase* destination,
uint64_t destinationOffset) { … }
MaybeError EncodeTimestampsToNanosecondsConversion(CommandEncoder* encoder,
QuerySetBase* querySet,
uint32_t firstQuery,
uint32_t queryCount,
BufferBase* destination,
uint64_t destinationOffset) { … }
bool ShouldUseTextureToBufferBlit(const DeviceBase* device,
const Format& format,
const Aspect& aspect) { … }
bool ShouldUseT2B2TForT2T(const DeviceBase* device,
const Format& srcFormat,
const Format& dstFormat) { … }
}
Color ClampClearColorValueToLegalRange(const Color& originalColor, const Format& format) { … }
ResultOrError<UnpackedPtr<CommandEncoderDescriptor>> ValidateCommandEncoderDescriptor(
const DeviceBase* device,
const CommandEncoderDescriptor* descriptor) { … }
Ref<CommandEncoder> CommandEncoder::Create(
DeviceBase* device,
const UnpackedPtr<CommandEncoderDescriptor>& descriptor) { … }
Ref<CommandEncoder> CommandEncoder::MakeError(DeviceBase* device, const char* label) { … }
CommandEncoder::CommandEncoder(DeviceBase* device,
const UnpackedPtr<CommandEncoderDescriptor>& descriptor)
: … { … }
CommandEncoder::CommandEncoder(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: … { … }
ObjectType CommandEncoder::GetType() const { … }
void CommandEncoder::DestroyImpl() { … }
CommandBufferResourceUsage CommandEncoder::AcquireResourceUsages() { … }
CommandIterator CommandEncoder::AcquireCommands() { … }
void CommandEncoder::TrackUsedQuerySet(QuerySetBase* querySet) { … }
void CommandEncoder::TrackQueryAvailability(QuerySetBase* querySet, uint32_t queryIndex) { … }
ComputePassEncoder* CommandEncoder::APIBeginComputePass(const ComputePassDescriptor* descriptor) { … }
Ref<ComputePassEncoder> CommandEncoder::BeginComputePass(const ComputePassDescriptor* descriptor) { … }
RenderPassEncoder* CommandEncoder::APIBeginRenderPass(const RenderPassDescriptor* descriptor) { … }
Ref<RenderPassEncoder> CommandEncoder::BeginRenderPass(const RenderPassDescriptor* rawDescriptor) { … }
void CommandEncoder::APICopyBufferToBuffer(BufferBase* source,
uint64_t sourceOffset,
BufferBase* destination,
uint64_t destinationOffset,
uint64_t size) { … }
void CommandEncoder::InternalCopyBufferToBufferWithAllocatedSize(BufferBase* source,
uint64_t sourceOffset,
BufferBase* destination,
uint64_t destinationOffset,
uint64_t size) { … }
void CommandEncoder::APICopyBufferToTexture(const ImageCopyBuffer* source,
const ImageCopyTexture* destinationOrig,
const Extent3D* copySize) { … }
void CommandEncoder::APICopyTextureToBuffer(const ImageCopyTexture* sourceOrig,
const ImageCopyBuffer* destination,
const Extent3D* copySize) { … }
void CommandEncoder::APICopyTextureToTexture(const ImageCopyTexture* sourceOrig,
const ImageCopyTexture* destinationOrig,
const Extent3D* copySize) { … }
void CommandEncoder::APIClearBuffer(BufferBase* buffer, uint64_t offset, uint64_t size) { … }
void CommandEncoder::APIInjectValidationError2(std::string_view message) { … }
void CommandEncoder::APIInsertDebugMarker2(std::string_view groupLabel) { … }
void CommandEncoder::APIPopDebugGroup() { … }
void CommandEncoder::APIPushDebugGroup2(std::string_view groupLabel) { … }
void CommandEncoder::APIResolveQuerySet(QuerySetBase* querySet,
uint32_t firstQuery,
uint32_t queryCount,
BufferBase* destination,
uint64_t destinationOffset) { … }
void CommandEncoder::APIWriteBuffer(BufferBase* buffer,
uint64_t bufferOffset,
const uint8_t* data,
uint64_t size) { … }
void CommandEncoder::APIWriteTimestamp(QuerySetBase* querySet, uint32_t queryIndex) { … }
CommandBufferBase* CommandEncoder::APIFinish(const CommandBufferDescriptor* descriptor) { … }
ResultOrError<Ref<CommandBufferBase>> CommandEncoder::Finish(
const CommandBufferDescriptor* descriptor) { … }
MaybeError CommandEncoder::ValidateFinish() const { … }
CommandEncoder::InternalUsageScope CommandEncoder::MakeInternalUsageScope() { … }
CommandEncoder::InternalUsageScope::InternalUsageScope(CommandEncoder* encoder)
: … { … }
CommandEncoder::InternalUsageScope::~InternalUsageScope() { … }
}