Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
skgpu::graphite::SamplerDesc Struct Reference

#include <ResourceTypes.h>

Public Member Functions

 SamplerDesc (const SkSamplingOptions &samplingOptions, const SkTileMode tileModes[2], const ImmutableSamplerInfo info={})
 
 SamplerDesc ()=default
 
 SamplerDesc (const SamplerDesc &)=default
 
bool operator== (const SamplerDesc &o) const
 
bool operator!= (const SamplerDesc &o) const
 
SkTileMode tileModeX () const
 
SkTileMode tileModeY () const
 
uint32_t desc () const
 
uint32_t format () const
 
uint32_t externalFormatMSBs () const
 
bool isImmutable () const
 
bool usesExternalFormat () const
 
SkSamplingOptions samplingOptions () const
 
SkSpan< const uint32_t > asSpan () const
 

Static Public Attributes

static constexpr int kNumTileModeBits = SkNextLog2_portable(int(SkTileMode::kLastTileMode)+1)
 
static constexpr int kNumFilterModeBits = SkNextLog2_portable(int(SkFilterMode::kLast)+1)
 
static constexpr int kNumMipmapModeBits = SkNextLog2_portable(int(SkMipmapMode::kLast)+1)
 
static constexpr int kMaxNumConversionInfoBits
 
static constexpr int kTileModeXShift = 0
 
static constexpr int kTileModeYShift = kTileModeXShift + kNumTileModeBits
 
static constexpr int kFilterModeShift = kTileModeYShift + kNumTileModeBits
 
static constexpr int kMipmapModeShift = kFilterModeShift + kNumFilterModeBits
 
static constexpr int kImmutableSamplerInfoShift = kMipmapModeShift + kNumMipmapModeBits
 

Detailed Description

Struct used to describe how a Texture/TextureProxy/TextureProxyView is sampled.

Definition at line 212 of file ResourceTypes.h.

Constructor & Destructor Documentation

◆ SamplerDesc() [1/3]

skgpu::graphite::SamplerDesc::SamplerDesc ( const SkSamplingOptions samplingOptions,
const SkTileMode  tileModes[2],
const ImmutableSamplerInfo  info = {} 
)
inline

Definition at line 215 of file ResourceTypes.h.

217 {})
218 : fDesc((static_cast<int>(tileModes[0]) << kTileModeXShift ) |
219 (static_cast<int>(tileModes[1]) << kTileModeYShift ) |
220 (static_cast<int>(samplingOptions.filter) << kFilterModeShift ) |
221 (static_cast<int>(samplingOptions.mipmap) << kMipmapModeShift ) |
222 (info.fNonFormatYcbcrConversionInfo << kImmutableSamplerInfoShift) )
223 , fFormat(info.fFormat)
224 , fExternalFormatMostSignificantBits(info.fFormat >> 32) {
225
226 // Cubic sampling is handled in a shader, with the actual texture sampled by with NN,
227 // but that is what a cubic SkSamplingOptions is set to if you ignore 'cubic', which let's
228 // us simplify how we construct SamplerDec's from the options passed to high-level draws.
231
232 // TODO: Add aniso value when used.
233
234 // Assert that fYcbcrConversionInfo does not exceed kMaxNumConversionInfoBits such that
235 // the conversion information can fit within an uint32.
236 SkASSERT(info.fNonFormatYcbcrConversionInfo >> kMaxNumConversionInfoBits == 0);
237 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
#define SkASSERT(cond)
Definition: SkAssert.h:116
const SkFilterMode filter
const SkMipmapMode mipmap
static constexpr int kTileModeXShift
static constexpr int kTileModeYShift
static constexpr int kMipmapModeShift
SkSamplingOptions samplingOptions() const
static constexpr int kMaxNumConversionInfoBits
static constexpr int kImmutableSamplerInfoShift
static constexpr int kFilterModeShift

◆ SamplerDesc() [2/3]

skgpu::graphite::SamplerDesc::SamplerDesc ( )
default

◆ SamplerDesc() [3/3]

skgpu::graphite::SamplerDesc::SamplerDesc ( const SamplerDesc )
default

Member Function Documentation

◆ asSpan()

SkSpan< const uint32_t > skgpu::graphite::SamplerDesc::asSpan ( ) const
inline

Definition at line 265 of file ResourceTypes.h.

265 {
266 // Span length depends upon whether the sampler is immutable and if it uses a known format
267 return {&fDesc, 1 + this->isImmutable() + this->usesExternalFormat()};
268 }

◆ desc()

uint32_t skgpu::graphite::SamplerDesc::desc ( ) const
inline

Definition at line 250 of file ResourceTypes.h.

250{ return fDesc; }

◆ externalFormatMSBs()

uint32_t skgpu::graphite::SamplerDesc::externalFormatMSBs ( ) const
inline

Definition at line 252 of file ResourceTypes.h.

252{ return fExternalFormatMostSignificantBits; }

◆ format()

uint32_t skgpu::graphite::SamplerDesc::format ( ) const
inline

Definition at line 251 of file ResourceTypes.h.

251{ return fFormat; }

◆ isImmutable()

bool skgpu::graphite::SamplerDesc::isImmutable ( ) const
inline

Definition at line 253 of file ResourceTypes.h.

253{ return (fDesc >> kImmutableSamplerInfoShift) != 0; }

◆ operator!=()

bool skgpu::graphite::SamplerDesc::operator!= ( const SamplerDesc o) const
inline

Definition at line 246 of file ResourceTypes.h.

246{ return !(*this == o); }

◆ operator==()

bool skgpu::graphite::SamplerDesc::operator== ( const SamplerDesc o) const
inline

Definition at line 241 of file ResourceTypes.h.

241 {
242 return o.fDesc == fDesc && o.fFormat == fFormat &&
243 o.fExternalFormatMostSignificantBits == fExternalFormatMostSignificantBits;
244 }

◆ samplingOptions()

SkSamplingOptions skgpu::graphite::SamplerDesc::samplingOptions ( ) const
inline

Definition at line 258 of file ResourceTypes.h.

258 {
259 // TODO: Add support for anisotropic filtering
260 SkFilterMode filter = static_cast<SkFilterMode>((fDesc >> 4) & 0b01);
261 SkMipmapMode mipmap = static_cast<SkMipmapMode>((fDesc >> 5) & 0b11);
262 return SkSamplingOptions(filter, mipmap);
263 }
SkFilterMode
SkMipmapMode
SkSamplingOptions(SkFilterMode::kLinear))

◆ tileModeX()

SkTileMode skgpu::graphite::SamplerDesc::tileModeX ( ) const
inline

Definition at line 248 of file ResourceTypes.h.

248{ return static_cast<SkTileMode>((fDesc >> 0) & 0b11); }
SkTileMode
Definition: SkTileMode.h:13

◆ tileModeY()

SkTileMode skgpu::graphite::SamplerDesc::tileModeY ( ) const
inline

Definition at line 249 of file ResourceTypes.h.

249{ return static_cast<SkTileMode>((fDesc >> 2) & 0b11); }

◆ usesExternalFormat()

bool skgpu::graphite::SamplerDesc::usesExternalFormat ( ) const
inline

Definition at line 254 of file ResourceTypes.h.

254{ return (fDesc >> kImmutableSamplerInfoShift) & 0b1; }

Member Data Documentation

◆ kFilterModeShift

constexpr int skgpu::graphite::SamplerDesc::kFilterModeShift = kTileModeYShift + kNumTileModeBits
staticconstexpr

Definition at line 280 of file ResourceTypes.h.

◆ kImmutableSamplerInfoShift

constexpr int skgpu::graphite::SamplerDesc::kImmutableSamplerInfoShift = kMipmapModeShift + kNumMipmapModeBits
staticconstexpr

Definition at line 282 of file ResourceTypes.h.

◆ kMaxNumConversionInfoBits

constexpr int skgpu::graphite::SamplerDesc::kMaxNumConversionInfoBits
staticconstexpr
Initial value:
=
static constexpr int kNumTileModeBits
static constexpr int kNumMipmapModeBits
static constexpr int kNumFilterModeBits

Definition at line 275 of file ResourceTypes.h.

◆ kMipmapModeShift

constexpr int skgpu::graphite::SamplerDesc::kMipmapModeShift = kFilterModeShift + kNumFilterModeBits
staticconstexpr

Definition at line 281 of file ResourceTypes.h.

◆ kNumFilterModeBits

constexpr int skgpu::graphite::SamplerDesc::kNumFilterModeBits = SkNextLog2_portable(int(SkFilterMode::kLast)+1)
staticconstexpr

Definition at line 273 of file ResourceTypes.h.

◆ kNumMipmapModeBits

constexpr int skgpu::graphite::SamplerDesc::kNumMipmapModeBits = SkNextLog2_portable(int(SkMipmapMode::kLast)+1)
staticconstexpr

Definition at line 274 of file ResourceTypes.h.

◆ kNumTileModeBits

constexpr int skgpu::graphite::SamplerDesc::kNumTileModeBits = SkNextLog2_portable(int(SkTileMode::kLastTileMode)+1)
staticconstexpr

Definition at line 272 of file ResourceTypes.h.

◆ kTileModeXShift

constexpr int skgpu::graphite::SamplerDesc::kTileModeXShift = 0
staticconstexpr

Definition at line 278 of file ResourceTypes.h.

◆ kTileModeYShift

constexpr int skgpu::graphite::SamplerDesc::kTileModeYShift = kTileModeXShift + kNumTileModeBits
staticconstexpr

Definition at line 279 of file ResourceTypes.h.


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