Flutter Impeller
impeller::TextureDescriptor Struct Reference

A lightweight object that describes the attributes of a texture that can then used an allocator to create that texture. More...

#include <texture_descriptor.h>

Public Member Functions

constexpr size_t GetByteSizeForDimensions (int64_t width, int64_t height) const
 The number of bytes required to store an image of the given texel dimensions in this format. Block-compressed formats round the dimensions up to whole blocks. More...
 
constexpr size_t GetByteSizeOfBaseMipLevel () const
 
constexpr size_t GetByteSizeOfAllMipLevels () const
 
constexpr size_t GetBytesPerRow () const
 
constexpr bool SamplingOptionsAreValid () const
 
constexpr bool operator== (const TextureDescriptor &other) const =default
 
constexpr bool IsValid () const
 

Public Attributes

StorageMode storage_mode = StorageMode::kDeviceTransient
 
TextureType type = TextureType::kTexture2D
 
PixelFormat format = PixelFormat::kUnknown
 
ISize size
 
size_t mip_count = 1u
 
TextureUsageMask usage = TextureUsage::kShaderRead
 
SampleCount sample_count = SampleCount::kCount1
 
CompressionType compression_type = CompressionType::kLossless
 

Detailed Description

A lightweight object that describes the attributes of a texture that can then used an allocator to create that texture.

Definition at line 38 of file texture_descriptor.h.

Member Function Documentation

◆ GetByteSizeForDimensions()

constexpr size_t impeller::TextureDescriptor::GetByteSizeForDimensions ( int64_t  width,
int64_t  height 
) const
inlineconstexpr

The number of bytes required to store an image of the given texel dimensions in this format. Block-compressed formats round the dimensions up to whole blocks.

Definition at line 51 of file texture_descriptor.h.

52  {
53  return BytesForTextureRegion(format, width, height);
54  }
constexpr size_t BytesForTextureRegion(PixelFormat format, int64_t width, int64_t height)
The number of bytes required to store a width x height texel region in format. Block-compressed forma...
Definition: formats.h:727

References impeller::BytesForTextureRegion(), and format.

Referenced by GetByteSizeOfAllMipLevels(), and GetByteSizeOfBaseMipLevel().

◆ GetByteSizeOfAllMipLevels()

constexpr size_t impeller::TextureDescriptor::GetByteSizeOfAllMipLevels ( ) const
inlineconstexpr

Definition at line 63 of file texture_descriptor.h.

63  {
64  if (!IsValid()) {
65  return 0u;
66  }
67  size_t result = 0u;
68  int64_t width = size.width;
69  int64_t height = size.height;
70  for (auto i = 0u; i < mip_count; i++) {
71  result += GetByteSizeForDimensions(width, height);
72  width /= 2;
73  height /= 2;
74  }
75  return result;
76  }
Type height
Definition: size.h:29
Type width
Definition: size.h:28
constexpr size_t GetByteSizeForDimensions(int64_t width, int64_t height) const
The number of bytes required to store an image of the given texel dimensions in this format....
constexpr bool IsValid() const

References GetByteSizeForDimensions(), impeller::TSize< T >::height, IsValid(), mip_count, size, and impeller::TSize< T >::width.

◆ GetByteSizeOfBaseMipLevel()

constexpr size_t impeller::TextureDescriptor::GetByteSizeOfBaseMipLevel ( ) const
inlineconstexpr

◆ GetBytesPerRow()

constexpr size_t impeller::TextureDescriptor::GetBytesPerRow ( ) const
inlineconstexpr

Definition at line 78 of file texture_descriptor.h.

78  {
79  if (!IsValid()) {
80  return 0u;
81  }
83  }
constexpr size_t BytesPerRowForTextureWidth(PixelFormat format, int64_t width)
The number of bytes in a single row of texel blocks for a texture of the given width in format.
Definition: formats.h:741

References impeller::BytesPerRowForTextureWidth(), format, IsValid(), size, and impeller::TSize< T >::width.

Referenced by impeller::testing::TEST().

◆ IsValid()

constexpr bool impeller::TextureDescriptor::IsValid ( ) const
inlineconstexpr

Definition at line 92 of file texture_descriptor.h.

92  {
93  return format != PixelFormat::kUnknown && //
94  !size.IsEmpty() && //
95  mip_count >= 1u && //
97  }
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
Definition: size.h:123
constexpr bool SamplingOptionsAreValid() const

References format, impeller::TSize< T >::IsEmpty(), impeller::kUnknown, mip_count, SamplingOptionsAreValid(), and size.

Referenced by GetByteSizeOfAllMipLevels(), GetByteSizeOfBaseMipLevel(), GetBytesPerRow(), impeller::TextureMTL::TextureMTL(), and impeller::ToMTLTextureDescriptor().

◆ operator==()

constexpr bool impeller::TextureDescriptor::operator== ( const TextureDescriptor &  other) const
constexprdefault

◆ SamplingOptionsAreValid()

constexpr bool impeller::TextureDescriptor::SamplingOptionsAreValid ( ) const
inlineconstexpr

Definition at line 85 of file texture_descriptor.h.

85  {
86  const auto count = static_cast<uint64_t>(sample_count);
87  return IsMultisampleCapable(type) ? count > 1 : count == 1;
88  }
constexpr bool IsMultisampleCapable(TextureType type)
Definition: formats.h:471

References impeller::IsMultisampleCapable(), sample_count, and type.

Referenced by IsValid().

Member Data Documentation

◆ compression_type

◆ format

PixelFormat impeller::TextureDescriptor::format = PixelFormat::kUnknown

Definition at line 41 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::ContentContext::ContentContext(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::CreateGradientTexture(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::RenderPassGLESCommandTest::CreateRenderPassGLESContext(), impeller::testing::CreateTestCanvas(), impeller::testing::CreateTestYUVTextures(), impeller::Allocator::CreateTexture(), impeller::Playground::CreateTextureCubeForFixture(), impeller::CreateTextureForDecompressedImage(), GetByteSizeForDimensions(), GetBytesPerRow(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), ImGui_ImplImpeller_Init(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), IsValid(), impeller::KHRSwapchainImageVK::KHRSwapchainImageVK(), impeller::TextureSourceVK::SetLayout(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::ToMTLTextureDescriptor(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), impeller::WrapTextureMTL(), and impeller::WrapTextureWithRenderTarget().

◆ mip_count

◆ sample_count

◆ size

ISize impeller::TextureDescriptor::size

Definition at line 42 of file texture_descriptor.h.

Referenced by impeller::AllocatedTextureSourceVK::AllocatedTextureSourceVK(), impeller::glvk::Trampoline::BlitTextureOpenGLToVulkan(), impeller::ContentContext::ContentContext(), impeller::TypographerContextSkia::CreateGlyphAtlas(), impeller::CreateGradientTexture(), impeller::RenderTargetAllocator::CreateOffscreen(), impeller::RenderTargetAllocator::CreateOffscreenMSAA(), impeller::testing::RenderPassGLESCommandTest::CreateRenderPassGLESContext(), impeller::testing::CreateTestCanvas(), impeller::testing::CreateTestYUVTextures(), impeller::Allocator::CreateTexture(), impeller::Playground::CreateTextureCubeForFixture(), impeller::CreateTextureForDecompressedImage(), impeller::EntityPassTarget::Flip(), GetByteSizeOfAllMipLevels(), GetByteSizeOfBaseMipLevel(), GetBytesPerRow(), impeller::SwapchainTransientsMTL::GetDepthStencilTexture(), impeller::SwapchainTransientsMTL::GetMSAATexture(), impeller::SwapchainTransientsMTL::GetResolveTexture(), impeller::TextureVK::GetSize(), ImGui_ImplImpeller_Init(), impeller::interop::ImpellerTextureCreateWithContentsNew(), impeller::interop::ImpellerTextureCreateWithOpenGLTextureHandleNew(), IsValid(), impeller::RenderTarget::SetupDepthStencilAttachments(), impeller::testing::TEST(), impeller::TEST(), impeller::testing::TEST_P(), impeller::TextureDescriptorToString(), impeller::TextureMTL::TextureMTL(), impeller::ToMTLTextureDescriptor(), impeller::ToSwapchainTextureDescriptor(), impeller::SurfaceGLES::WrapFBO(), impeller::SurfaceVK::WrapSwapchainImage(), and impeller::WrapTextureWithRenderTarget().

◆ storage_mode

◆ type

◆ usage


The documentation for this struct was generated from the following file: