#include "dawn/native/Texture.h"
#include <algorithm>
#include <utility>
#include "absl/strings/str_format.h"
#include "dawn/common/Assert.h"
#include "dawn/common/Constants.h"
#include "dawn/common/Math.h"
#include "dawn/native/Adapter.h"
#include "dawn/native/BlitTextureToBuffer.h"
#include "dawn/native/ChainUtils.h"
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Device.h"
#include "dawn/native/EnumMaskIterator.h"
#include "dawn/native/ObjectType_autogen.h"
#include "dawn/native/PassResourceUsage.h"
#include "dawn/native/PhysicalDevice.h"
#include "dawn/native/SharedTextureMemory.h"
#include "dawn/native/ValidationUtils_autogen.h"
namespace dawn::native {
namespace {
MaybeError ValidateTextureViewFormatCompatibility(const DeviceBase* device,
const Format& format,
wgpu::TextureFormat viewFormatEnum) { … }
MaybeError ValidateCanViewTextureAs(const DeviceBase* device,
const TextureBase* texture,
const Format& viewFormat,
wgpu::TextureAspect aspect) { … }
bool IsTextureViewDimensionCompatibleWithTextureDimension(
wgpu::TextureViewDimension textureViewDimension,
wgpu::TextureDimension textureDimension) { … }
MaybeError ValidateDepthOrArrayLayersIsCompatibleWithTextureBindingViewDimension(
wgpu::TextureViewDimension textureBindingViewDimension,
uint32_t depthOrArrayLayers) { … }
bool IsArrayLayerValidForTextureViewDimension(wgpu::TextureViewDimension textureViewDimension,
uint32_t textureViewArrayLayer) { … }
MaybeError ValidateSampleCount(const TextureDescriptor* descriptor,
wgpu::TextureUsage usage,
const Format* format) { … }
MaybeError ValidateTextureViewDimensionCompatibility(
const DeviceBase* device,
const TextureBase* texture,
const UnpackedPtr<TextureViewDescriptor>& descriptor) { … }
MaybeError ValidateTextureSize(const DeviceBase* device,
const TextureDescriptor* descriptor,
const Format* format) { … }
MaybeError ValidateTextureUsage(const DeviceBase* device,
const TextureDescriptor* descriptor,
wgpu::TextureUsage usage,
const Format* format,
std::optional<wgpu::TextureUsage> allowedSharedTextureMemoryUsage) { … }
bool CopyDstNeedsInternalRenderAttachmentUsage(const DeviceBase* device, const Format& format) { … }
bool CopySrcNeedsInternalTextureBindingUsage(const DeviceBase* device, const Format& format) { … }
wgpu::TextureViewDimension ResolveDefaultCompatiblityTextureBindingViewDimension(
const DeviceBase* device,
const UnpackedPtr<TextureDescriptor>& descriptor) { … }
}
MaybeError ValidateTextureDescriptor(
const DeviceBase* device,
const UnpackedPtr<TextureDescriptor>& descriptor,
AllowMultiPlanarTextureFormat allowMultiPlanar,
std::optional<wgpu::TextureUsage> allowedSharedTextureMemoryUsage) { … }
MaybeError ValidateTextureViewDescriptor(const DeviceBase* device,
const TextureBase* texture,
const UnpackedPtr<TextureViewDescriptor>& descriptor) { … }
ResultOrError<TextureViewDescriptor> GetTextureViewDescriptorWithDefaults(
const TextureBase* texture,
const TextureViewDescriptor* descriptor) { … }
bool IsValidSampleCount(uint32_t sampleCount) { … }
TextureBase::TextureState::TextureState() : … { … }
TextureBase::TextureBase(DeviceBase* device, const UnpackedPtr<TextureDescriptor>& descriptor)
: … { … }
TextureBase::~TextureBase() = default;
static constexpr Format kUnusedFormat;
TextureBase::TextureBase(DeviceBase* device,
const TextureDescriptor* descriptor,
ObjectBase::ErrorTag tag)
: … { … }
void TextureBase::DestroyImpl() { … }
Ref<TextureBase> TextureBase::MakeError(DeviceBase* device, const TextureDescriptor* descriptor) { … }
ObjectType TextureBase::GetType() const { … }
void TextureBase::FormatLabel(absl::FormatSink* s) const { … }
std::string TextureBase::GetSizeLabel() const { … }
wgpu::TextureDimension TextureBase::GetDimension() const { … }
wgpu::TextureViewDimension TextureBase::GetCompatibilityTextureBindingViewDimension() const { … }
const Format& TextureBase::GetFormat() const { … }
const FormatSet& TextureBase::GetViewFormats() const { … }
const Extent3D& TextureBase::GetBaseSize() const { … }
Extent3D TextureBase::GetSize(Aspect aspect) const { … }
Extent3D TextureBase::GetSize(wgpu::TextureAspect textureAspect) const { … }
uint32_t TextureBase::GetWidth(Aspect aspect) const { … }
uint32_t TextureBase::GetHeight(Aspect aspect) const { … }
uint32_t TextureBase::GetDepth(Aspect aspect) const { … }
uint32_t TextureBase::GetArrayLayers() const { … }
uint32_t TextureBase::GetNumMipLevels() const { … }
SubresourceRange TextureBase::GetAllSubresources() const { … }
uint32_t TextureBase::GetSampleCount() const { … }
uint32_t TextureBase::GetSubresourceCount() const { … }
wgpu::TextureUsage TextureBase::GetUsage() const { … }
wgpu::TextureUsage TextureBase::GetInternalUsage() const { … }
void TextureBase::AddInternalUsage(wgpu::TextureUsage usage) { … }
bool TextureBase::IsDestroyed() const { … }
bool TextureBase::IsInitialized() const { … }
void TextureBase::SetInitialized(bool initialized) { … }
ExecutionSerial TextureBase::OnEndAccess() { … }
void TextureBase::OnBeginAccess() { … }
bool TextureBase::HasAccess() const { … }
uint32_t TextureBase::GetSubresourceIndex(uint32_t mipLevel,
uint32_t arraySlice,
Aspect aspect) const { … }
bool TextureBase::IsSubresourceContentInitialized(const SubresourceRange& range) const { … }
void TextureBase::SetIsSubresourceContentInitialized(bool isInitialized,
const SubresourceRange& range) { … }
MaybeError TextureBase::ValidateCanUseInSubmitNow() const { … }
bool TextureBase::IsMultisampledTexture() const { … }
bool TextureBase::IsReadOnly() const { … }
bool TextureBase::CoversFullSubresource(uint32_t mipLevel,
Aspect aspect,
const Extent3D& size) const { … }
Extent3D TextureBase::GetMipLevelSingleSubresourceVirtualSize(uint32_t level, Aspect aspect) const { … }
Extent3D TextureBase::GetMipLevelSingleSubresourcePhysicalSize(uint32_t level,
Aspect aspect) const { … }
Extent3D TextureBase::ClampToMipLevelVirtualSize(uint32_t level,
Aspect aspect,
const Origin3D& origin,
const Extent3D& extent) const { … }
Extent3D TextureBase::GetMipLevelSubresourceVirtualSize(uint32_t level, Aspect aspect) const { … }
ResultOrError<Ref<TextureViewBase>> TextureBase::CreateView(
const TextureViewDescriptor* descriptor) { … }
Ref<TextureViewBase> TextureBase::CreateErrorView(const TextureViewDescriptor* descriptor) { … }
ApiObjectList* TextureBase::GetViewTrackingList() { … }
TextureViewBase* TextureBase::APICreateView(const TextureViewDescriptor* descriptor) { … }
TextureViewBase* TextureBase::APICreateErrorView(const TextureViewDescriptor* descriptor) { … }
bool TextureBase::IsImplicitMSAARenderTextureViewSupported() const { … }
void TextureBase::SetSharedResourceMemoryContentsForTesting(
Ref<SharedResourceMemoryContents> contents) { … }
void TextureBase::DumpMemoryStatistics(dawn::native::MemoryDump* dump, const char* prefix) const { … }
uint64_t TextureBase::ComputeEstimatedByteSize() const { … }
void TextureBase::APIDestroy() { … }
uint32_t TextureBase::APIGetWidth() const { … }
uint32_t TextureBase::APIGetHeight() const { … }
uint32_t TextureBase::APIGetDepthOrArrayLayers() const { … }
uint32_t TextureBase::APIGetMipLevelCount() const { … }
uint32_t TextureBase::APIGetSampleCount() const { … }
wgpu::TextureDimension TextureBase::APIGetDimension() const { … }
wgpu::TextureFormat TextureBase::APIGetFormat() const { … }
wgpu::TextureUsage TextureBase::APIGetUsage() const { … }
TextureViewBase::TextureViewBase(TextureBase* texture,
const UnpackedPtr<TextureViewDescriptor>& descriptor)
: … { … }
TextureViewBase::TextureViewBase(DeviceBase* device, ObjectBase::ErrorTag tag, const char* label)
: … { … }
TextureViewBase::~TextureViewBase() = default;
void TextureViewBase::DestroyImpl() { … }
Ref<TextureViewBase> TextureViewBase::MakeError(DeviceBase* device, const char* label) { … }
ObjectType TextureViewBase::GetType() const { … }
void TextureViewBase::FormatLabel(absl::FormatSink* s) const { … }
const TextureBase* TextureViewBase::GetTexture() const { … }
TextureBase* TextureViewBase::GetTexture() { … }
Aspect TextureViewBase::GetAspects() const { … }
const Format& TextureViewBase::GetFormat() const { … }
wgpu::TextureViewDimension TextureViewBase::GetDimension() const { … }
uint32_t TextureViewBase::GetBaseMipLevel() const { … }
uint32_t TextureViewBase::GetLevelCount() const { … }
uint32_t TextureViewBase::GetBaseArrayLayer() const { … }
uint32_t TextureViewBase::GetLayerCount() const { … }
const SubresourceRange& TextureViewBase::GetSubresourceRange() const { … }
Extent3D TextureViewBase::GetSingleSubresourceVirtualSize() const { … }
ApiObjectList* TextureViewBase::GetObjectTrackingList() { … }
}