Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
skgpu Namespace Reference

Namespaces

namespace  ganesh
 
namespace  graphite
 
namespace  MutableTextureStates
 
namespace  tess
 
namespace  VulkanMemory
 
namespace  wangs_formula
 

Classes

class  AtlasGenerationCounter
 
class  AtlasLocator
 
class  AtlasToken
 
struct  BC1Block
 
class  BlendFormula
 
struct  BlendInfo
 
struct  BufferWriter
 
class  BulkUsePlotUpdater
 
struct  ETC1Block
 
struct  IndexWriter
 
struct  IRect16
 
class  KeyBuilder
 
class  MtlMemoryAllocatorImpl
 
class  MutableTextureState
 
class  MutableTextureStateData
 
class  MutableTextureStatePriv
 
class  Plot
 
class  PlotEvictionCallback
 
class  PlotLocator
 
class  Rectanizer
 
class  RectanizerPow2
 
class  RectanizerSkyline
 
struct  ReducedBlendModeInfo
 
class  RefCntedCallback
 
class  ResourceKey
 
class  ScratchKey
 
class  ShaderErrorHandler
 
class  SingleOwner
 
class  StringKeyBuilder
 
class  Swizzle
 
class  SwizzleCtorAccessor
 
class  TAsyncReadResult
 
class  TClientMappedBufferManager
 
struct  TextureUploadWriter
 
class  TiledTextureUtils
 
class  TokenTracker
 
struct  UniformWriter
 
class  UniqueKey
 
class  UniqueKeyInvalidatedMessage
 
class  UniqueKeyInvalidatedMsg_Graphite
 
class  VertexColor
 
struct  VertexWriter
 
struct  VulkanAlloc
 
class  VulkanAMDMemoryAllocator
 
struct  VulkanBackendContext
 
class  VulkanExtensions
 
struct  VulkanInterface
 
class  VulkanMemoryAllocator
 
struct  VulkanYcbcrConversionInfo
 

Typedefs

using VulkanGetProc = std::function< PFN_vkVoidFunction(const char *, VkInstance, VkDevice)>
 
typedef intptr_t VulkanBackendMemory
 
typedef void * VulkanDeviceLostContext
 
typedef void(* VulkanDeviceLostProc) (VulkanDeviceLostContext faultContext, const std::string &description, const std::vector< VkDeviceFaultAddressInfoEXT > &addressInfos, const std::vector< VkDeviceFaultVendorInfoEXT > &vendorInfos, const std::vector< std::byte > &vendorBinaryData)
 
typedef SkTInternalLList< PlotPlotList
 
using StdSteadyClock = std::chrono::steady_clock
 
using BufferUsage = VulkanMemoryAllocator::BufferUsage
 

Enumerations

enum class  BackendApi : unsigned {
  kDawn , kMetal , kVulkan , kMock ,
  kUnsupported
}
 
enum class  Budgeted : bool { kNo = false , kYes = true }
 
enum class  CallbackResult : bool { kFailed = false , kSuccess = true }
 
enum class  Mipmapped : bool { kNo = false , kYes = true }
 
enum class  Protected : bool { kNo = false , kYes = true }
 
enum class  Renderable : bool { kNo = false , kYes = true }
 
enum class  Origin : unsigned { kTopLeft , kBottomLeft }
 
enum class  MaskFormat : int { kA8 , kA565 , kARGB , kLast = kARGB }
 
enum class  BlendEquation : uint8_t {
  kAdd , kSubtract , kReverseSubtract , kScreen ,
  kOverlay , kDarken , kLighten , kColorDodge ,
  kColorBurn , kHardLight , kSoftLight , kDifference ,
  kExclusion , kMultiply , kHSLHue , kHSLSaturation ,
  kHSLColor , kHSLLuminosity , kIllegal , kFirstAdvanced = kScreen ,
  kLast = kIllegal
}
 
enum class  BlendCoeff : uint8_t {
  kZero , kOne , kSC , kISC ,
  kDC , kIDC , kSA , kISA ,
  kDA , kIDA , kConstC , kIConstC ,
  kS2C , kIS2C , kS2A , kIS2A ,
  kIllegal , kLast = kIllegal
}
 
enum class  ContextType {
  kGL , kGLES , kANGLE_D3D9_ES2 , kANGLE_D3D11_ES2 ,
  kANGLE_D3D11_ES3 , kANGLE_GL_ES2 , kANGLE_GL_ES3 , kANGLE_Metal_ES2 ,
  kANGLE_Metal_ES3 , kVulkan , kMetal , kDirect3D ,
  kDawn_D3D11 , kDawn_D3D12 , kDawn_Metal , kDawn_Vulkan ,
  kDawn_OpenGL , kDawn_OpenGLES , kMock , kLastContextType = kMock
}
 

Functions

void Flush (SkSurface *surface)
 
void FlushAndSubmit (SkSurface *surface)
 
ShaderErrorHandlerDefaultShaderErrorHandler ()
 
constexpr int MaskFormatBytesPerPixel (MaskFormat format)
 
static constexpr SkColorType MaskFormatToColorType (MaskFormat format)
 
const char * BlendFuncName (SkBlendMode mode)
 
SkSpan< const float > GetPorterDuffBlendConstants (SkBlendMode mode)
 
ReducedBlendModeInfo GetReducedBlendModeInfo (SkBlendMode mode)
 
static constexpr bool BlendCoeffRefsSrc (const BlendCoeff coeff)
 
static constexpr bool BlendCoeffRefsDst (const BlendCoeff coeff)
 
static constexpr bool BlendCoeffRefsSrc2 (const BlendCoeff coeff)
 
static constexpr bool BlendCoeffsUseSrcColor (BlendCoeff srcCoeff, BlendCoeff dstCoeff)
 
static constexpr bool BlendCoeffsUseDstColor (BlendCoeff srcCoeff, BlendCoeff dstCoeff, bool srcColorIsOpaque)
 
static constexpr bool BlendEquationIsAdvanced (BlendEquation equation)
 
static constexpr bool BlendModifiesDst (BlendEquation equation, BlendCoeff srcCoeff, BlendCoeff dstCoeff)
 
static constexpr bool BlendCoeffRefsConstant (const BlendCoeff coeff)
 
static constexpr bool BlendShouldDisable (BlendEquation equation, BlendCoeff srcCoeff, BlendCoeff dstCoeff)
 
static constexpr bool BlendAllowsCoverageAsAlpha (BlendEquation equation, BlendCoeff srcCoeff, BlendCoeff dstCoeff)
 
BlendFormula GetBlendFormula (bool isOpaque, bool hasCoverage, SkBlendMode xfermode)
 
BlendFormula GetLCDBlendFormula (SkBlendMode xfermode)
 
void Compute2DBlurKernel (SkSize sigma, SkISize radius, SkSpan< float > kernel)
 
void Compute2DBlurKernel (SkSize sigma, SkISize radii, std::array< SkV4, kMaxBlurSamples/4 > &kernel)
 
void Compute2DBlurOffsets (SkISize radius, std::array< SkV4, kMaxBlurSamples/2 > &offsets)
 
void Compute1DBlurLinearKernel (float sigma, int radius, std::array< SkV4, kMaxBlurSamples/2 > &offsetsAndKernel)
 
static SkKnownRuntimeEffects::StableKey to_stablekey (int kernelWidth, uint32_t baseKey)
 
const SkRuntimeEffectGetLinearBlur1DEffect (int radius)
 
const SkRuntimeEffectGetBlur2DEffect (const SkISize &radii)
 
SkBitmap CreateIntegralTable (float sixSigma)
 
int ComputeIntegralTableWidth (float sixSigma)
 
static float make_unnormalized_half_kernel (float *halfKernel, int halfKernelSize, float sigma)
 
static void make_half_kernel_and_summed_table (float *halfKernel, float *summedHalfKernel, int halfKernelSize, float sigma)
 
static void apply_kernel_in_y (float *results, int numSteps, float firstX, float circleR, int halfKernelSize, const float *summedHalfKernelTable)
 
static uint8_t eval_at (float evalX, float circleR, const float *halfKernel, int halfKernelSize, const float *yKernelEvaluations)
 
SkBitmap CreateCircleProfile (float sigma, float radius, int profileWidth)
 
SkBitmap CreateHalfPlaneProfile (int profileWidth)
 
static uint8_t eval_V (float top, int y, const uint8_t *integral, int integralSize, float sixSigma)
 
static uint8_t eval_H (int x, int y, const std::vector< float > &topVec, const float *kernel, int kernelSize, const uint8_t *integral, int integralSize, float sixSigma)
 
SkBitmap CreateRRectBlurMask (const SkRRect &rrectToDraw, const SkISize &dimensions, float sigma)
 
constexpr int BlurKernelWidth (int radius)
 
constexpr int BlurLinearKernelWidth (int radius)
 
constexpr bool BlurIsEffectivelyIdentity (float sigma)
 
int BlurSigmaRadius (float sigma)
 
void Compute1DBlurKernel (float sigma, int radius, SkSpan< float > kernel)
 
template<typename T >
VertexWriteroperator<< (VertexWriter &w, const T &val)
 
template<typename T >
VertexWriteroperator<< (VertexWriter &w, const VertexWriter::Conditional< T > &val)
 
template<typename T >
VertexWriteroperator<< (VertexWriter &w, const VertexWriter::Skip< T > &val)
 
template<typename T >
VertexWriteroperator<< (VertexWriter &w, const VertexWriter::ArrayDesc< T > &array)
 
template<int kCount, typename T >
VertexWriteroperator<< (VertexWriter &w, const VertexWriter::RepeatDesc< kCount, T > &repeat)
 
template<>
VertexWriteroperator<< (VertexWriter &w, const skvx::float4 &vector)
 
template<typename T >
VertexWriteroperator<< (VertexWriter &&w, const T &val)
 
template<>
VertexWriteroperator<< (VertexWriter &w, const VertexColor &color)
 
IndexWriteroperator<< (IndexWriter &w, uint16_t val)
 
IndexWriteroperator<< (IndexWriter &w, int val)
 
template<typename T >
IndexWriteroperator<< (IndexWriter &&w, const T &val)
 
static int extend_5To8bits (int b)
 
static int test_table_entry (int rOrig, int gOrig, int bOrig, int r8, int g8, int b8, int table, int offset)
 
static void create_etc1_block (SkColor col, ETC1Block *block)
 
static int num_4x4_blocks (int size)
 
static int num_ETC1_blocks (int w, int h)
 
static uint16_t to565 (SkColor col)
 
static void create_BC1_block (SkColor col0, SkColor col1, BC1Block *block)
 
size_t NumCompressedBlocks (SkTextureCompressionType type, SkISize baseDimensions)
 
size_t CompressedRowBytes (SkTextureCompressionType type, int width)
 
SkISize CompressedDimensions (SkTextureCompressionType type, SkISize baseDimensions)
 
SkISize CompressedDimensionsInBlocks (SkTextureCompressionType type, SkISize baseDimensions)
 
static void fillin_ETC1_with_color (SkISize dimensions, const SkColor4f &colorf, char *dest)
 
static void fillin_BC1_with_color (SkISize dimensions, const SkColor4f &colorf, char *dest)
 
void FillInCompressedData (SkTextureCompressionType type, SkISize dimensions, skgpu::Mipmapped mipmapped, char *dstPixels, const SkColor4f &colorf)
 
float DitherRangeForConfig (SkColorType dstColorType)
 
SkBitmap MakeDitherLUT ()
 
bool SkSLToGLSL (const SkSL::ShaderCaps *caps, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *glsl, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
 
static constexpr SkColorType CompressionTypeToSkColorType (SkTextureCompressionType compression)
 
static constexpr const char * CompressionTypeToStr (SkTextureCompressionType compression)
 
bool SkSLToWGSL (const SkSL::ShaderCaps *caps, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *wgsl, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
 
bool MtlFormatIsDepthOrStencil (MTLPixelFormat format)
 
bool MtlFormatIsDepth (MTLPixelFormat format)
 
bool MtlFormatIsStencil (MTLPixelFormat format)
 
bool MtlFormatIsCompressed (MTLPixelFormat mtlFormat)
 
const char * MtlFormatToString (MTLPixelFormat mtlFormat)
 
uint32_t MtlFormatChannels (MTLPixelFormat mtlFormat)
 
size_t MtlFormatBytesPerBlock (MTLPixelFormat mtlFormat)
 
SkTextureCompressionType MtlFormatToCompressionType (MTLPixelFormat mtlFormat)
 
bool SkSLToMSL (const SkSL::ShaderCaps *caps, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *msl, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
 
bool SkSLToBackend (const SkSL::ShaderCaps *caps, bool(*toBackend)(SkSL::Program &, const SkSL::ShaderCaps *, std::string *), const char *backendLabel, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *output, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
 
uint32_t ResourceKeyHash (const uint32_t *data, size_t size)
 
static void skgpu_init_static_unique_key_once (SkAlignedSTStorage< 1, UniqueKey > *keyStorage)
 
static bool SkShouldPostMessageToBus (const UniqueKeyInvalidatedMessage &msg, uint32_t msgBusUniqueID)
 
static bool SkShouldPostMessageToBus (const UniqueKeyInvalidatedMsg_Graphite &msg, uint32_t msgBusUniqueID)
 
SkISize GetApproxSize (SkISize size)
 
static int find_info (const TArray< VulkanExtensions::Info > &infos, const char ext[])
 
void SetupSamplerYcbcrConversionInfo (VkSamplerYcbcrConversionCreateInfo *outInfo, const VulkanYcbcrConversionInfo &conversionInfo)
 
void InvokeDeviceLostCallback (const skgpu::VulkanInterface *vulkanInterface, VkDevice vkDevice, skgpu::VulkanDeviceLostContext deviceLostContext, skgpu::VulkanDeviceLostProc deviceLostProc, bool supportsDeviceFaultInfoExtension)
 
bool SkSLToSPIRV (const SkSL::ShaderCaps *caps, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *spirv, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
 
static constexpr uint32_t VkFormatChannels (VkFormat vkFormat)
 
static constexpr size_t VkFormatBytesPerBlock (VkFormat vkFormat)
 
static constexpr SkTextureCompressionType VkFormatToCompressionType (VkFormat vkFormat)
 
static constexpr int VkFormatIsStencil (VkFormat format)
 
static constexpr int VkFormatIsDepth (VkFormat format)
 
static constexpr int VkFormatStencilBits (VkFormat format)
 
static constexpr bool VkFormatNeedsYcbcrSampler (VkFormat format)
 
static constexpr bool SampleCountToVkSampleCount (uint32_t samples, VkSampleCountFlagBits *vkSamples)
 
static constexpr bool VkFormatIsCompressed (VkFormat vkFormat)
 
template<typename T >
TGetExtensionFeatureStruct (const VkPhysicalDeviceFeatures2 &features, VkStructureType type)
 
static constexpr const char * VkFormatToStr (VkFormat vkFormat)
 
const char * ContextTypeName (skgpu::ContextType type)
 
bool IsNativeBackend (skgpu::ContextType type)
 
bool IsDawnBackend (skgpu::ContextType type)
 
bool IsRenderingContext (skgpu::ContextType type)
 

Variables

static const int kMaskFormatCount = static_cast<int>(MaskFormat::kLast) + 1
 
static const int kBlendEquationCnt = static_cast<int>(BlendEquation::kLast) + 1
 
static const int kBlendCoeffCnt = static_cast<int>(BlendCoeff::kLast) + 1
 
static constexpr int kMaxBlurSamples = 28
 
static constexpr float kMaxLinearBlurSigma = 4.f
 
constexpr uint32_t kDiffBit = 0x2
 
static const int kNumETC1ModifierTables = 8
 
static const int kNumETC1PixelIndices = 4
 
static const int kETC1ModifierTables [kNumETC1ModifierTables][kNumETC1PixelIndices]
 
constexpr int kIsDebug = 0
 
static const int kContextTypeCount = (int)ContextType::kLastContextType + 1
 

Detailed Description

This file includes numerous public types that are used by all of our gpu backends.

This file includes internal types that are used by all of our gpu backends for atlases.

Typedef Documentation

◆ BufferUsage

Definition at line 14 of file VulkanMemory.cpp.

◆ PlotList

Definition at line 535 of file AtlasTypes.h.

◆ StdSteadyClock

using skgpu::StdSteadyClock = typedef std::chrono::steady_clock

Definition at line 25 of file GpuTypesPriv.h.

◆ VulkanBackendMemory

typedef intptr_t skgpu::VulkanBackendMemory

Definition at line 31 of file VulkanTypes.h.

◆ VulkanDeviceLostContext

Definition at line 171 of file VulkanTypes.h.

◆ VulkanDeviceLostProc

typedef void(* skgpu::VulkanDeviceLostProc) (VulkanDeviceLostContext faultContext, const std::string &description, const std::vector< VkDeviceFaultAddressInfoEXT > &addressInfos, const std::vector< VkDeviceFaultVendorInfoEXT > &vendorInfos, const std::vector< std::byte > &vendorBinaryData)

Definition at line 172 of file VulkanTypes.h.

◆ VulkanGetProc

using skgpu::VulkanGetProc = typedef std::function<PFN_vkVoidFunction( const char*, VkInstance, VkDevice )>

Definition at line 25 of file VulkanTypes.h.

Enumeration Type Documentation

◆ BackendApi

enum class skgpu::BackendApi : unsigned
strong

Possible 3D APIs that may be used by Graphite.

Enumerator
kDawn 
kMetal 
kVulkan 
kMock 
kUnsupported 

Graphite doesn't support some context types (e.g. Direct3D) and will return Unsupported.

Definition at line 22 of file GpuTypes.h.

22 : unsigned {
23 kDawn,
24 kMetal,
25 kVulkan,
26 kMock,
27
28 /**
29 * Graphite doesn't support some context types (e.g. Direct3D) and will return Unsupported.
30 */
32};
@ kVulkan
Definition embedder.h:86
@ kMetal
Definition embedder.h:85

◆ BlendCoeff

enum class skgpu::BlendCoeff : uint8_t
strong

Coefficients for alpha-blending.

Enumerator
kZero 
kOne 
kSC 
kISC 
kDC 
kIDC 
kSA 
kISA 
kDA 
kIDA 
kConstC 
kIConstC 
kS2C 
kIS2C 
kS2A 
kIS2A 
kIllegal 
kLast 

Definition at line 60 of file Blend.h.

60 : uint8_t {
61 kZero, //<! 0
62 kOne, //<! 1
63 kSC, //<! src color
64 kISC, //<! one minus src color
65 kDC, //<! dst color
66 kIDC, //<! one minus dst color
67 kSA, //<! src alpha
68 kISA, //<! one minus src alpha
69 kDA, //<! dst alpha
70 kIDA, //<! one minus dst alpha
71 kConstC, //<! constant color
72 kIConstC, //<! one minus constant color
73 kS2C,
74 kIS2C,
75 kS2A,
76 kIS2A,
77
79
81};

◆ BlendEquation

enum class skgpu::BlendEquation : uint8_t
strong

Equations for alpha-blending.

Enumerator
kAdd 
kSubtract 
kReverseSubtract 
kScreen 
kOverlay 
kDarken 
kLighten 
kColorDodge 
kColorBurn 
kHardLight 
kSoftLight 
kDifference 
kExclusion 
kMultiply 
kHSLHue 
kHSLSaturation 
kHSLColor 
kHSLLuminosity 
kIllegal 
kFirstAdvanced 
kLast 

Definition at line 26 of file Blend.h.

26 : uint8_t {
27 // Basic blend equations.
28 kAdd, //<! Cs*S + Cd*D
29 kSubtract, //<! Cs*S - Cd*D
30 kReverseSubtract, //<! Cd*D - Cs*S
31
32 // Advanced blend equations. These are described in the SVG and PDF specs.
33 kScreen,
35 kDarken,
44 kHSLHue,
48
50
53};
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kColorBurn
darken destination to reflect source
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kScreen
r = s + d - s*d
@ kSoftLight
lighten or darken, depending on source
@ kDifference
rc = s + d - 2*(min(s*da, d*sa)), ra = kSrcOver
@ kOverlay
multiply or screen, depending on destination
@ kHardLight
multiply or screen, depending on source
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kAdd
Definition embedder.h:988

◆ Budgeted

enum class skgpu::Budgeted : bool
strong

Indicates whether an allocation should count against a cache budget.

Enumerator
kNo 
kYes 

Definition at line 35 of file GpuTypes.h.

35 : bool {
36 kNo = false,
37 kYes = true,
38};
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.

◆ CallbackResult

enum class skgpu::CallbackResult : bool
strong

Value passed into various callbacks to tell the client the result of operations connected to a specific callback. The actual interpretation of kFailed and kSuccess are dependent on the specific callbacks and are documented with the callback itself.

Enumerator
kFailed 
kSuccess 

Definition at line 45 of file GpuTypes.h.

45 : bool {
46 kFailed = false,
47 kSuccess = true,
48};
@ kSuccess
Definition embedder.h:73

◆ ContextType

enum class skgpu::ContextType
strong
Enumerator
kGL 
kGLES 

OpenGL context.

kANGLE_D3D9_ES2 

OpenGL ES context.

kANGLE_D3D11_ES2 

ANGLE on Direct3D9 OpenGL ES 2 context.

kANGLE_D3D11_ES3 

ANGLE on Direct3D11 OpenGL ES 2 context.

kANGLE_GL_ES2 

ANGLE on Direct3D11 OpenGL ES 3 context.

kANGLE_GL_ES3 

ANGLE on OpenGL OpenGL ES 2 context.

kANGLE_Metal_ES2 

ANGLE on OpenGL OpenGL ES 3 context.

kANGLE_Metal_ES3 

ANGLE on Metal ES 2 context.

kVulkan 

ANGLE on Metal ES 3 context.

kMetal 

Vulkan.

kDirect3D 

Metal.

kDawn_D3D11 

Direct3D 12.

kDawn_D3D12 

Dawn on Direct3D11.

kDawn_Metal 

Dawn on Direct3D12.

kDawn_Vulkan 

Dawn on Metal.

kDawn_OpenGL 

Dawn on Vulkan.

kDawn_OpenGLES 

Dawn on OpenGL.

kMock 

Dawn on OpenGL ES.

kLastContextType 

Mock context that does not draw.

Definition at line 19 of file ContextType.h.

19 {
20 kGL, //! OpenGL context.
21 kGLES, //! OpenGL ES context.
22 kANGLE_D3D9_ES2, //! ANGLE on Direct3D9 OpenGL ES 2 context.
23 kANGLE_D3D11_ES2, //! ANGLE on Direct3D11 OpenGL ES 2 context.
24 kANGLE_D3D11_ES3, //! ANGLE on Direct3D11 OpenGL ES 3 context.
25 kANGLE_GL_ES2, //! ANGLE on OpenGL OpenGL ES 2 context.
26 kANGLE_GL_ES3, //! ANGLE on OpenGL OpenGL ES 3 context.
27 kANGLE_Metal_ES2, //! ANGLE on Metal ES 2 context.
28 kANGLE_Metal_ES3, //! ANGLE on Metal ES 3 context.
29 kVulkan, //! Vulkan
30 kMetal, //! Metal
31 kDirect3D, //! Direct3D 12
32 kDawn_D3D11, //! Dawn on Direct3D11
33 kDawn_D3D12, //! Dawn on Direct3D12
34 kDawn_Metal, //! Dawn on Metal
35 kDawn_Vulkan, //! Dawn on Vulkan
36 kDawn_OpenGL, //! Dawn on OpenGL
37 kDawn_OpenGLES, //! Dawn on OpenGL ES
38 kMock, //! Mock context that does not draw.
40};
@ kDawn_OpenGLES
Dawn on OpenGL.
@ kDawn_Metal
Dawn on Direct3D12.
@ kGLES
OpenGL context.
@ kANGLE_GL_ES2
ANGLE on Direct3D11 OpenGL ES 3 context.
@ kDawn_D3D12
Dawn on Direct3D11.
@ kANGLE_GL_ES3
ANGLE on OpenGL OpenGL ES 2 context.
@ kANGLE_D3D11_ES2
ANGLE on Direct3D9 OpenGL ES 2 context.
@ kLastContextType
Mock context that does not draw.
@ kDawn_Vulkan
Dawn on Metal.
@ kDawn_OpenGL
Dawn on Vulkan.
@ kDawn_D3D11
Direct3D 12.
@ kANGLE_D3D11_ES3
ANGLE on Direct3D11 OpenGL ES 2 context.
@ kANGLE_D3D9_ES2
OpenGL ES context.
@ kANGLE_Metal_ES2
ANGLE on OpenGL OpenGL ES 3 context.
@ kANGLE_Metal_ES3
ANGLE on Metal ES 2 context.

◆ MaskFormat

enum class skgpu::MaskFormat : int
strong

Formats for masks, used by the font cache. Important that these are 0-based.

Enumerator
kA8 

1-byte per pixel

kA565 

2-bytes per pixel, RGB represent 3-channel LCD coverage

kARGB 

4-bytes per pixel, color format

kLast 

Definition at line 98 of file AtlasTypes.h.

98 : int {
99 kA8, //!< 1-byte per pixel
100 kA565, //!< 2-bytes per pixel, RGB represent 3-channel LCD coverage
101 kARGB, //!< 4-bytes per pixel, color format
102
103 kLast = kARGB
104};
@ kA565
2-bytes per pixel, RGB represent 3-channel LCD coverage
@ kA8
1-byte per pixel
@ kARGB
4-bytes per pixel, color format

◆ Mipmapped

enum class skgpu::Mipmapped : bool
strong

Is the texture mipmapped or not

Enumerator
kNo 
kYes 

Definition at line 53 of file GpuTypes.h.

53 : bool {
54 kNo = false,
55 kYes = true,
56};

◆ Origin

enum class skgpu::Origin : unsigned
strong

What is the logical origin of a BackendTexture passed into Skia

Enumerator
kTopLeft 
kBottomLeft 

Definition at line 77 of file GpuTypes.h.

77 : unsigned {
80};

◆ Protected

enum class skgpu::Protected : bool
strong

Is the data protected on the GPU or not.

Enumerator
kNo 
kYes 

Definition at line 61 of file GpuTypes.h.

61 : bool {
62 kNo = false,
63 kYes = true,
64};

◆ Renderable

enum class skgpu::Renderable : bool
strong

Is a texture renderable or not

Enumerator
kNo 
kYes 

Definition at line 69 of file GpuTypes.h.

69 : bool {
70 kNo = false,
71 kYes = true,
72};

Function Documentation

◆ apply_kernel_in_y()

static void skgpu::apply_kernel_in_y ( float *  results,
int  numSteps,
float  firstX,
float  circleR,
int  halfKernelSize,
const float *  summedHalfKernelTable 
)
static

Definition at line 339 of file BlurUtils.cpp.

344 {
345 float x = firstX;
346 for (int i = 0; i < numSteps; ++i, x += 1.0f) {
347 if (x < -circleR || x > circleR) {
348 results[i] = 0;
349 continue;
350 }
351 float y = sqrtf(circleR * circleR - x * x);
352 // In the column at x we exit the circle at +y and -y
353 // The summed table entry j is actually reflects an offset of j + 0.5.
354 y -= 0.5f;
355 int yInt = SkScalarFloorToInt(y);
356 SkASSERT(yInt >= -1);
357 if (y < 0) {
358 results[i] = (y + 0.5f) * summedHalfKernelTable[0];
359 } else if (yInt >= halfKernelSize - 1) {
360 results[i] = 0.5f;
361 } else {
362 float yFrac = y - yInt;
363 results[i] = (1.0f - yFrac) * summedHalfKernelTable[yInt] +
364 yFrac * summedHalfKernelTable[yInt + 1];
365 }
366 }
367}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkScalarFloorToInt(x)
Definition SkScalar.h:35
double y
double x

◆ BlendAllowsCoverageAsAlpha()

static constexpr bool skgpu::BlendAllowsCoverageAsAlpha ( BlendEquation  equation,
BlendCoeff  srcCoeff,
BlendCoeff  dstCoeff 
)
staticconstexpr

Advanced blend equations can always tweak alpha for coverage. (See GrCustomXfermode.cpp)

For "add" and "reverse subtract" the blend equation with f=coverage is:

D' = f * (S * srcCoeff + D * dstCoeff) + (1-f) * D = f * S * srcCoeff + D * (f * dstCoeff + (1 - f))

(Let srcCoeff be negative for reverse subtract.) We can tweak alpha for coverage when the following relationship holds:

(f*S) * srcCoeff' + D * dstCoeff' == f * S * srcCoeff + D * (f * dstCoeff + (1 - f))

(Where srcCoeff' and dstCoeff' have any reference to S pre-multiplied by f.)

It's easy to see this works for the src term as long as srcCoeff' == srcCoeff (meaning srcCoeff does not reference S). For the dst term, this will work as long as the following is true: | dstCoeff' == f * dstCoeff + (1 - f) dstCoeff' == 1 - f * (1 - dstCoeff)

By inspection we can see this will work as long as dstCoeff has a 1, and any other term in dstCoeff references S.

Moreover, if the blend doesn't modify the dst at all then it is ok to arbitrarily modify the src color so folding in coverage is allowed.

Definition at line 179 of file Blend.h.

181 {
182 return BlendEquationIsAdvanced(equation) ||
183 !BlendModifiesDst(equation, srcCoeff, dstCoeff) ||
184 ((BlendEquation::kAdd == equation || BlendEquation::kReverseSubtract == equation) &&
185 !BlendCoeffRefsSrc(srcCoeff) &&
186 (BlendCoeff::kOne == dstCoeff || BlendCoeff::kISC == dstCoeff ||
187 BlendCoeff::kISA == dstCoeff));
188}
static constexpr bool BlendEquationIsAdvanced(BlendEquation equation)
Definition Blend.h:129
static constexpr bool BlendCoeffRefsSrc(const BlendCoeff coeff)
Definition Blend.h:103
static constexpr bool BlendModifiesDst(BlendEquation equation, BlendCoeff srcCoeff, BlendCoeff dstCoeff)
Definition Blend.h:134

◆ BlendCoeffRefsConstant()

static constexpr bool skgpu::BlendCoeffRefsConstant ( const BlendCoeff  coeff)
staticconstexpr

Definition at line 141 of file Blend.h.

141 {
142 return coeff == BlendCoeff::kConstC || coeff == BlendCoeff::kIConstC;
143}

◆ BlendCoeffRefsDst()

static constexpr bool skgpu::BlendCoeffRefsDst ( const BlendCoeff  coeff)
staticconstexpr

Definition at line 108 of file Blend.h.

108 {
109 return BlendCoeff::kDC == coeff || BlendCoeff::kIDC == coeff || BlendCoeff::kDA == coeff ||
110 BlendCoeff::kIDA == coeff;
111}

◆ BlendCoeffRefsSrc()

static constexpr bool skgpu::BlendCoeffRefsSrc ( const BlendCoeff  coeff)
staticconstexpr

Definition at line 103 of file Blend.h.

103 {
104 return BlendCoeff::kSC == coeff || BlendCoeff::kISC == coeff || BlendCoeff::kSA == coeff ||
105 BlendCoeff::kISA == coeff;
106}

◆ BlendCoeffRefsSrc2()

static constexpr bool skgpu::BlendCoeffRefsSrc2 ( const BlendCoeff  coeff)
staticconstexpr

Definition at line 113 of file Blend.h.

113 {
114 return BlendCoeff::kS2C == coeff || BlendCoeff::kIS2C == coeff ||
115 BlendCoeff::kS2A == coeff || BlendCoeff::kIS2A == coeff;
116}

◆ BlendCoeffsUseDstColor()

static constexpr bool skgpu::BlendCoeffsUseDstColor ( BlendCoeff  srcCoeff,
BlendCoeff  dstCoeff,
bool  srcColorIsOpaque 
)
staticconstexpr

Definition at line 122 of file Blend.h.

124 {
125 return BlendCoeffRefsDst(srcCoeff) ||
126 (dstCoeff != BlendCoeff::kZero && !(dstCoeff == BlendCoeff::kISA && srcColorIsOpaque));
127}
static constexpr bool BlendCoeffRefsDst(const BlendCoeff coeff)
Definition Blend.h:108

◆ BlendCoeffsUseSrcColor()

static constexpr bool skgpu::BlendCoeffsUseSrcColor ( BlendCoeff  srcCoeff,
BlendCoeff  dstCoeff 
)
staticconstexpr

Definition at line 118 of file Blend.h.

118 {
119 return BlendCoeff::kZero != srcCoeff || BlendCoeffRefsSrc(dstCoeff);
120}

◆ BlendEquationIsAdvanced()

static constexpr bool skgpu::BlendEquationIsAdvanced ( BlendEquation  equation)
staticconstexpr

Definition at line 129 of file Blend.h.

129 {
130 return equation >= BlendEquation::kFirstAdvanced &&
131 equation != BlendEquation::kIllegal;
132}

◆ BlendFuncName()

const char * skgpu::BlendFuncName ( SkBlendMode  mode)

Returns the name of the SkSL built-in blend function for a SkBlendMode.

Definition at line 18 of file Blend.cpp.

18 {
19 switch (mode) {
20 case SkBlendMode::kClear: return "blend_clear";
21 case SkBlendMode::kSrc: return "blend_src";
22 case SkBlendMode::kDst: return "blend_dst";
23 case SkBlendMode::kSrcOver: return "blend_src_over";
24 case SkBlendMode::kDstOver: return "blend_dst_over";
25 case SkBlendMode::kSrcIn: return "blend_src_in";
26 case SkBlendMode::kDstIn: return "blend_dst_in";
27 case SkBlendMode::kSrcOut: return "blend_src_out";
28 case SkBlendMode::kDstOut: return "blend_dst_out";
29 case SkBlendMode::kSrcATop: return "blend_src_atop";
30 case SkBlendMode::kDstATop: return "blend_dst_atop";
31 case SkBlendMode::kXor: return "blend_xor";
32 case SkBlendMode::kPlus: return "blend_plus";
33 case SkBlendMode::kModulate: return "blend_modulate";
34 case SkBlendMode::kScreen: return "blend_screen";
35 case SkBlendMode::kOverlay: return "blend_overlay";
36 case SkBlendMode::kDarken: return "blend_darken";
37 case SkBlendMode::kLighten: return "blend_lighten";
38 case SkBlendMode::kColorDodge: return "blend_color_dodge";
39 case SkBlendMode::kColorBurn: return "blend_color_burn";
40 case SkBlendMode::kHardLight: return "blend_hard_light";
41 case SkBlendMode::kSoftLight: return "blend_soft_light";
42 case SkBlendMode::kDifference: return "blend_difference";
43 case SkBlendMode::kExclusion: return "blend_exclusion";
44 case SkBlendMode::kMultiply: return "blend_multiply";
45 case SkBlendMode::kHue: return "blend_hue";
46 case SkBlendMode::kSaturation: return "blend_saturation";
47 case SkBlendMode::kColor: return "blend_color";
48 case SkBlendMode::kLuminosity: return "blend_luminosity";
49 }
51}
#define SkUNREACHABLE
Definition SkAssert.h:135
@ kSrcOut
r = s * (1-da)
@ kSaturation
saturation of source with hue and luminosity of destination
@ kPlus
r = min(s + d, 1)
@ kHue
hue of source with saturation and luminosity of destination
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kLuminosity
luminosity of source with hue and saturation of destination
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kColor
hue and saturation of source with luminosity of destination
@ kDstOut
r = d * (1-sa)
@ kSrcIn
r = s * da
@ kClear
r = 0

◆ BlendModifiesDst()

static constexpr bool skgpu::BlendModifiesDst ( BlendEquation  equation,
BlendCoeff  srcCoeff,
BlendCoeff  dstCoeff 
)
staticconstexpr

Definition at line 134 of file Blend.h.

136 {
137 return (BlendEquation::kAdd != equation && BlendEquation::kReverseSubtract != equation) ||
138 BlendCoeff::kZero != srcCoeff || BlendCoeff::kOne != dstCoeff;
139}

◆ BlendShouldDisable()

static constexpr bool skgpu::BlendShouldDisable ( BlendEquation  equation,
BlendCoeff  srcCoeff,
BlendCoeff  dstCoeff 
)
staticconstexpr

Definition at line 145 of file Blend.h.

147 {
148 return (BlendEquation::kAdd == equation || BlendEquation::kSubtract == equation) &&
149 BlendCoeff::kOne == srcCoeff && BlendCoeff::kZero == dstCoeff;
150}

◆ BlurIsEffectivelyIdentity()

constexpr bool skgpu::BlurIsEffectivelyIdentity ( float  sigma)
constexpr

Definition at line 37 of file BlurUtils.h.

37{ return sigma <= 0.03f; }

◆ BlurKernelWidth()

constexpr int skgpu::BlurKernelWidth ( int  radius)
constexpr

Definition at line 28 of file BlurUtils.h.

28{ return 2 * radius + 1; }

◆ BlurLinearKernelWidth()

constexpr int skgpu::BlurLinearKernelWidth ( int  radius)
constexpr

Definition at line 32 of file BlurUtils.h.

32{ return radius + 1; }

◆ BlurSigmaRadius()

int skgpu::BlurSigmaRadius ( float  sigma)
inline

Definition at line 41 of file BlurUtils.h.

41 {
42 // sk_float_ceil2int is not constexpr
43 return BlurIsEffectivelyIdentity(sigma) ? 0 : sk_float_ceil2int(3.f * sigma);
44}
#define sk_float_ceil2int(x)
constexpr bool BlurIsEffectivelyIdentity(float sigma)
Definition BlurUtils.h:37

◆ CompressedDimensions()

SkISize skgpu::CompressedDimensions ( SkTextureCompressionType  type,
SkISize  baseDimensions 
)

Definition at line 195 of file DataUtils.cpp.

195 {
196 switch (type) {
198 return baseDimensions;
202 SkISize blockDims = CompressedDimensionsInBlocks(type, baseDimensions);
203 // Each BC1_RGB8_UNORM and ETC1 block has 16 pixels
204 return { 4 * blockDims.fWidth, 4 * blockDims.fHeight };
205 }
206 }
208}
SkISize CompressedDimensionsInBlocks(SkTextureCompressionType type, SkISize baseDimensions)
int32_t fHeight
Definition SkSize.h:18
int32_t fWidth
Definition SkSize.h:17

◆ CompressedDimensionsInBlocks()

SkISize skgpu::CompressedDimensionsInBlocks ( SkTextureCompressionType  type,
SkISize  baseDimensions 
)

Definition at line 210 of file DataUtils.cpp.

210 {
211 switch (type) {
213 return baseDimensions;
217 int numBlocksWidth = num_4x4_blocks(baseDimensions.width());
218 int numBlocksHeight = num_4x4_blocks(baseDimensions.height());
219
220 // Each BC1_RGB8_UNORM and ETC1 block has 16 pixels
221 return { numBlocksWidth, numBlocksHeight };
222 }
223 }
225}
static int num_4x4_blocks(int size)
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

◆ CompressedRowBytes()

size_t skgpu::CompressedRowBytes ( SkTextureCompressionType  type,
int  width 
)

Definition at line 179 of file DataUtils.cpp.

179 {
180 switch (type) {
182 return 0;
186 int numBlocksWidth = num_4x4_blocks(width);
187
188 static_assert(sizeof(ETC1Block) == sizeof(BC1Block));
189 return numBlocksWidth * sizeof(ETC1Block);
190 }
191 }
193}
int32_t width

◆ CompressionTypeToSkColorType()

static constexpr SkColorType skgpu::CompressionTypeToSkColorType ( SkTextureCompressionType  compression)
staticconstexpr

Definition at line 30 of file GpuTypesPriv.h.

30 {
31 switch (compression) {
36 }
37
39}
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:25
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20

◆ CompressionTypeToStr()

static constexpr const char * skgpu::CompressionTypeToStr ( SkTextureCompressionType  compression)
staticconstexpr

Definition at line 41 of file GpuTypesPriv.h.

41 {
42 switch (compression) {
43 case SkTextureCompressionType::kNone: return "kNone";
44 case SkTextureCompressionType::kETC2_RGB8_UNORM: return "kETC2_RGB8_UNORM";
45 case SkTextureCompressionType::kBC1_RGB8_UNORM: return "kBC1_RGB8_UNORM";
46 case SkTextureCompressionType::kBC1_RGBA8_UNORM: return "kBC1_RGBA8_UNORM";
47 }
49}

◆ Compute1DBlurKernel()

void skgpu::Compute1DBlurKernel ( float  sigma,
int  radius,
SkSpan< float >  kernel 
)
inline

Definition at line 118 of file BlurUtils.h.

118 {
119 Compute2DBlurKernel(SkSize{sigma, 0.f}, SkISize{radius, 0}, kernel);
120}
void Compute2DBlurKernel(SkSize sigma, SkISize radius, SkSpan< float > kernel)
Definition BlurUtils.cpp:35

◆ Compute1DBlurLinearKernel()

void skgpu::Compute1DBlurLinearKernel ( float  sigma,
int  radius,
std::array< SkV4, kMaxBlurSamples/2 > &  offsetsAndKernel 
)

Definition at line 115 of file BlurUtils.cpp.

117 {
118 SkASSERT(sigma <= kMaxLinearBlurSigma);
119 SkASSERT(radius == BlurSigmaRadius(sigma));
120 SkASSERT(BlurLinearKernelWidth(radius) <= kMaxBlurSamples);
121
122 // Given 2 adjacent gaussian points, they are blended as: Wi * Ci + Wj * Cj.
123 // The GPU will mix Ci and Cj as Ci * (1 - x) + Cj * x during sampling.
124 // Compute W', x such that W' * (Ci * (1 - x) + Cj * x) = Wi * Ci + Wj * Cj.
125 // Solving W' * x = Wj, W' * (1 - x) = Wi:
126 // W' = Wi + Wj
127 // x = Wj / (Wi + Wj)
128 auto get_new_weight = [](float* new_w, float* offset, float wi, float wj) {
129 *new_w = wi + wj;
130 *offset = wj / (wi + wj);
131 };
132
133 // Create a temporary standard kernel. The maximum blur radius that can be passed to this
134 // function is (kMaxBlurSamples-1), so make an array large enough to hold the full kernel width.
135 static constexpr int kMaxKernelWidth = BlurKernelWidth(kMaxBlurSamples - 1);
136 SkASSERT(BlurKernelWidth(radius) <= kMaxKernelWidth);
137 std::array<float, kMaxKernelWidth> fullKernel;
138 Compute1DBlurKernel(sigma, radius, SkSpan<float>{fullKernel.data(), BlurKernelWidth(radius)});
139
140 std::array<float, kMaxBlurSamples> kernel;
141 std::array<float, kMaxBlurSamples> offsets;
142 // Note that halfsize isn't just size / 2, but radius + 1. This is the size of the output array.
143 int halfSize = skgpu::BlurLinearKernelWidth(radius);
144 int halfRadius = halfSize / 2;
145 int lowIndex = halfRadius - 1;
146
147 // Compute1DGaussianKernel produces a full 2N + 1 kernel. Since the kernel can be mirrored,
148 // compute only the upper half and mirror to the lower half.
149
150 int index = radius;
151 if (radius & 1) {
152 // If N is odd, then use two samples.
153 // The centre texel gets sampled twice, so halve its influence for each sample.
154 // We essentially sample like this:
155 // Texel edges
156 // v v v v
157 // | | | |
158 // \-----^---/ Lower sample
159 // \---^-----/ Upper sample
160 get_new_weight(&kernel[halfRadius],
161 &offsets[halfRadius],
162 fullKernel[index] * 0.5f,
163 fullKernel[index + 1]);
164 kernel[lowIndex] = kernel[halfRadius];
165 offsets[lowIndex] = -offsets[halfRadius];
166 index++;
167 lowIndex--;
168 } else {
169 // If N is even, then there are an even number of texels on either side of the centre texel.
170 // Sample the centre texel directly.
171 kernel[halfRadius] = fullKernel[index];
172 offsets[halfRadius] = 0.0f;
173 }
174 index++;
175
176 // Every other pair gets one sample.
177 for (int i = halfRadius + 1; i < halfSize; index += 2, i++, lowIndex--) {
178 get_new_weight(&kernel[i], &offsets[i], fullKernel[index], fullKernel[index + 1]);
179 offsets[i] += static_cast<float>(index - radius);
180
181 // Mirror to lower half.
182 kernel[lowIndex] = kernel[i];
183 offsets[lowIndex] = -offsets[i];
184 }
185
186 // Zero out remaining values in the kernel
187 memset(kernel.data() + halfSize, 0, sizeof(float)*(kMaxBlurSamples - halfSize));
188 // But copy the last valid offset into the remaining offsets, to increase the chance that
189 // over-iteration in a fragment shader will have a cache hit.
190 for (int i = halfSize; i < kMaxBlurSamples; ++i) {
191 offsets[i] = offsets[halfSize - 1];
192 }
193
194 // Interleave into the output array to match the 1D SkSL effect
195 for (int i = 0; i < skgpu::kMaxBlurSamples / 2; ++i) {
196 offsetsAndKernel[i] = SkV4{offsets[2*i], kernel[2*i], offsets[2*i+1], kernel[2*i+1]};
197 }
198}
constexpr T * data() const
Definition SkSpan_impl.h:94
static constexpr int kMaxBlurSamples
Definition BlurUtils.h:52
int BlurSigmaRadius(float sigma)
Definition BlurUtils.h:41
constexpr int BlurLinearKernelWidth(int radius)
Definition BlurUtils.h:32
Point offset
Definition SkM44.h:98

◆ Compute2DBlurKernel() [1/2]

void skgpu::Compute2DBlurKernel ( SkSize  sigma,
SkISize  radii,
std::array< SkV4, kMaxBlurSamples/4 > &  kernel 
)

Definition at line 84 of file BlurUtils.cpp.

86 {
87 static_assert(sizeof(kernel) == sizeof(std::array<float, kMaxBlurSamples>));
88 static_assert(alignof(float) == alignof(SkV4));
89 float* data = kernel[0].ptr();
90 Compute2DBlurKernel(sigma, radii, SkSpan<float>(data, kMaxBlurSamples));
91}

◆ Compute2DBlurKernel() [2/2]

void skgpu::Compute2DBlurKernel ( SkSize  sigma,
SkISize  radius,
SkSpan< float >  kernel 
)

Definition at line 35 of file BlurUtils.cpp.

37 {
38 // Callers likely had to calculate the radius prior to filling out the kernel value, which is
39 // why it's provided; but make sure it's consistent with expectations.
40 SkASSERT(BlurSigmaRadius(sigma.width()) == radius.width() &&
41 BlurSigmaRadius(sigma.height()) == radius.height());
42
43 // Callers are responsible for downscaling large sigmas to values that can be processed by the
44 // effects, so ensure the radius won't overflow 'kernel'
45 const int width = BlurKernelWidth(radius.width());
46 const int height = BlurKernelWidth(radius.height());
47 const size_t kernelSize = SkTo<size_t>(sk_64_mul(width, height));
48 SkASSERT(kernelSize <= kernel.size());
49
50 // And the definition of an identity blur should be sufficient that 2sigma^2 isn't near zero
51 // when there's a non-trivial radius.
52 const float twoSigmaSqrdX = 2.0f * sigma.width() * sigma.width();
53 const float twoSigmaSqrdY = 2.0f * sigma.height() * sigma.height();
54 SkASSERT((radius.width() == 0 || !SkScalarNearlyZero(twoSigmaSqrdX)) &&
55 (radius.height() == 0 || !SkScalarNearlyZero(twoSigmaSqrdY)));
56
57 // Setting the denominator to 1 when the radius is 0 automatically converts the remaining math
58 // to the 1D Gaussian distribution. When both radii are 0, it correctly computes a weight of 1.0
59 const float sigmaXDenom = radius.width() > 0 ? 1.0f / twoSigmaSqrdX : 1.f;
60 const float sigmaYDenom = radius.height() > 0 ? 1.0f / twoSigmaSqrdY : 1.f;
61
62 float sum = 0.0f;
63 for (int x = 0; x < width; x++) {
64 float xTerm = static_cast<float>(x - radius.width());
65 xTerm = xTerm * xTerm * sigmaXDenom;
66 for (int y = 0; y < height; y++) {
67 float yTerm = static_cast<float>(y - radius.height());
68 float xyTerm = std::exp(-(xTerm + yTerm * yTerm * sigmaYDenom));
69 // Note that the constant term (1/(sqrt(2*pi*sigma^2)) of the Gaussian
70 // is dropped here, since we renormalize the kernel below.
71 kernel[y * width + x] = xyTerm;
72 sum += xyTerm;
73 }
74 }
75 // Normalize the kernel
76 float scale = 1.0f / sum;
77 for (size_t i = 0; i < kernelSize; ++i) {
78 kernel[i] *= scale;
79 }
80 // Zero remainder of the array
81 memset(kernel.data() + kernelSize, 0, sizeof(float)*(kernel.size() - kernelSize));
82}
static int64_t sk_64_mul(int64_t a, int64_t b)
Definition SkMath.h:33
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:101
constexpr size_t size() const
Definition SkSpan_impl.h:95
constexpr int BlurKernelWidth(int radius)
Definition BlurUtils.h:28
int32_t height
const Scalar scale
SkScalar width() const
Definition SkSize.h:76
SkScalar height() const
Definition SkSize.h:77

◆ Compute2DBlurOffsets()

void skgpu::Compute2DBlurOffsets ( SkISize  radius,
std::array< SkV4, kMaxBlurSamples/2 > &  offsets 
)

Definition at line 93 of file BlurUtils.cpp.

93 {
94 const int kernelArea = BlurKernelWidth(radius.width()) * BlurKernelWidth(radius.height());
95 SkASSERT(kernelArea <= kMaxBlurSamples);
96
97 SkSpan<float> offsetView{offsets[0].ptr(), kMaxBlurSamples*2};
98
99 int i = 0;
100 for (int y = -radius.height(); y <= radius.height(); ++y) {
101 for (int x = -radius.width(); x <= radius.width(); ++x) {
102 offsetView[2*i] = x;
103 offsetView[2*i+1] = y;
104 ++i;
105 }
106 }
107 SkASSERT(i == kernelArea);
108 const int lastValidOffset = 2*(kernelArea - 1);
109 for (; i < kMaxBlurSamples; ++i) {
110 offsetView[2*i] = offsetView[lastValidOffset];
111 offsetView[2*i+1] = offsetView[lastValidOffset+1];
112 }
113}

◆ ComputeIntegralTableWidth()

int skgpu::ComputeIntegralTableWidth ( float  sixSigma)

Definition at line 281 of file BlurUtils.cpp.

281 {
282 // Check for NaN/infinity
283 if (!SkIsFinite(sixSigma)) {
284 return 0;
285 }
286 // Avoid overflow, covers both multiplying by 2 and finding next power of 2:
287 // 2*((2^31-1)/4 + 1) = 2*(2^29-1) + 2 = 2^30 and SkNextPow2(2^30) = 2^30
288 if (sixSigma > SK_MaxS32 / 4 + 1) {
289 return 0;
290 }
291 // The texture we're producing represents the integral of a normal distribution over a
292 // six-sigma range centered at zero. We want enough resolution so that the linear
293 // interpolation done in texture lookup doesn't introduce noticeable artifacts. We
294 // conservatively choose to have 2 texels for each dst pixel.
295 int minWidth = 2 * ((int)std::ceil(sixSigma));
296 // Bin by powers of 2 with a minimum so we get good profile reuse.
297 return std::max(SkNextPow2(minWidth), 32);
298}
static bool SkIsFinite(T x, Pack... values)
static int SkNextPow2(int value)
Definition SkMathPriv.h:272
static constexpr int32_t SK_MaxS32
Definition SkMath.h:21
Type::kYUV Type::kRGBA() int(0.7 *637)

◆ ContextTypeName()

const char * skgpu::ContextTypeName ( skgpu::ContextType  type)

Definition at line 13 of file ContextType.cpp.

13 {
14 switch (type) {
15 case skgpu::ContextType::kGL:
16 return "OpenGL";
17 case skgpu::ContextType::kGLES:
18 return "OpenGLES";
19 case skgpu::ContextType::kANGLE_D3D9_ES2:
20 return "ANGLE D3D9 ES2";
21 case skgpu::ContextType::kANGLE_D3D11_ES2:
22 return "ANGLE D3D11 ES2";
23 case skgpu::ContextType::kANGLE_D3D11_ES3:
24 return "ANGLE D3D11 ES3";
25 case skgpu::ContextType::kANGLE_GL_ES2:
26 return "ANGLE GL ES2";
27 case skgpu::ContextType::kANGLE_GL_ES3:
28 return "ANGLE GL ES3";
29 case skgpu::ContextType::kANGLE_Metal_ES2:
30 return "ANGLE Metal ES2";
31 case skgpu::ContextType::kANGLE_Metal_ES3:
32 return "ANGLE Metal ES3";
33 case skgpu::ContextType::kVulkan:
34 return "Vulkan";
35 case skgpu::ContextType::kMetal:
36 return "Metal";
37 case skgpu::ContextType::kDirect3D:
38 return "Direct3D";
39 case skgpu::ContextType::kDawn_D3D11:
40 return "Dawn D3D11";
41 case skgpu::ContextType::kDawn_D3D12:
42 return "Dawn D3D12";
43 case skgpu::ContextType::kDawn_Metal:
44 return "Dawn Metal";
45 case skgpu::ContextType::kDawn_Vulkan:
46 return "Dawn Vulkan";
47 case skgpu::ContextType::kDawn_OpenGL:
48 return "Dawn OpenGL";
49 case skgpu::ContextType::kDawn_OpenGLES:
50 return "Dawn OpenGLES";
51 case skgpu::ContextType::kMock:
52 return "Mock";
53 }
55}

◆ create_BC1_block()

static void skgpu::create_BC1_block ( SkColor  col0,
SkColor  col1,
BC1Block block 
)
static

Definition at line 147 of file DataUtils.cpp.

147 {
148 block->fColor0 = to565(col0);
149 block->fColor1 = to565(col1);
150 SkASSERT(block->fColor0 <= block->fColor1); // we always assume transparent blocks
151
152 if (col0 == SK_ColorTRANSPARENT) {
153 // This sets all 16 pixels to just use color3 (under the assumption
154 // that this is a kBC1_RGBA8_UNORM texture. Note that in this case
155 // fColor0 will be opaque black.
156 block->fIndices = 0xFFFFFFFF;
157 } else {
158 // This sets all 16 pixels to just use 'fColor0'
159 block->fIndices = 0;
160 }
161}
constexpr SkColor SK_ColorTRANSPARENT
Definition SkColor.h:99
static uint16_t to565(SkColor col)
uint32_t fIndices

◆ create_etc1_block()

static void skgpu::create_etc1_block ( SkColor  col,
ETC1Block block 
)
static

Definition at line 73 of file DataUtils.cpp.

73 {
74 uint32_t high = 0;
75 uint32_t low = 0;
76
77 int rOrig = SkColorGetR(col);
78 int gOrig = SkColorGetG(col);
79 int bOrig = SkColorGetB(col);
80
81 int r5 = SkMulDiv255Round(31, rOrig);
82 int g5 = SkMulDiv255Round(31, gOrig);
83 int b5 = SkMulDiv255Round(31, bOrig);
84
85 int r8 = extend_5To8bits(r5);
86 int g8 = extend_5To8bits(g5);
87 int b8 = extend_5To8bits(b5);
88
89 // We always encode solid color textures in differential mode (i.e., with a 555 base color) but
90 // with zero diffs (i.e., bits 26-24, 18-16 and 10-8 are left 0).
91 high |= (r5 << 27) | (g5 << 19) | (b5 << 11) | kDiffBit;
92
93 int bestTableIndex = 0, bestPixelIndex = 0;
94 int bestSoFar = 1024;
95 for (int tableIndex = 0; tableIndex < kNumETC1ModifierTables; ++tableIndex) {
96 for (int pixelIndex = 0; pixelIndex < kNumETC1PixelIndices; ++pixelIndex) {
97 int score = test_table_entry(rOrig, gOrig, bOrig, r8, g8, b8,
98 tableIndex, pixelIndex);
99
100 if (bestSoFar > score) {
101 bestSoFar = score;
102 bestTableIndex = tableIndex;
103 bestPixelIndex = pixelIndex;
104 }
105 }
106 }
107
108 high |= (bestTableIndex << 5) | (bestTableIndex << 2);
109
110 if (bestPixelIndex & 0x1) {
111 low |= 0xFFFF;
112 }
113 if (bestPixelIndex & 0x2) {
114 low |= 0xFFFF0000;
115 }
116
117 block->fHigh = SkBSwap32(high);
118 block->fLow = SkBSwap32(low);
119}
#define SkColorGetR(color)
Definition SkColor.h:65
#define SkColorGetG(color)
Definition SkColor.h:69
#define SkColorGetB(color)
Definition SkColor.h:73
static int extend_5To8bits(int b)
static const int kNumETC1PixelIndices
constexpr uint32_t kDiffBit
static const int kNumETC1ModifierTables
static uint32_t SkBSwap32(uint32_t v)
Definition SkMathPriv.h:123
static U8CPU SkMulDiv255Round(U16CPU a, U16CPU b)
Definition SkMath.h:73
static int test_table_entry(int rOrig, int gOrig, int bOrig, int r8, int g8, int b8, int table, int offset)
Definition DataUtils.cpp:59

◆ CreateCircleProfile()

SkBitmap skgpu::CreateCircleProfile ( float  sigma,
float  radius,
int  profileWidth 
)

Definition at line 407 of file BlurUtils.cpp.

407 {
409 if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(profileWidth, 1))) {
410 return bitmap;
411 }
412
413 uint8_t* profile = bitmap.getAddr8(0, 0);
414
415 const int numSteps = profileWidth;
416
417 // The full kernel is 6 sigmas wide.
418 int halfKernelSize = SkScalarCeilToInt(6.0f * sigma);
419 // Round up to next multiple of 2 and then divide by 2.
420 halfKernelSize = ((halfKernelSize + 1) & ~1) >> 1;
421
422 // Number of x steps at which to apply kernel in y to cover all the profile samples in x.
423 const int numYSteps = numSteps + 2 * halfKernelSize;
424
425 skia_private::AutoTArray<float> bulkAlloc(halfKernelSize + halfKernelSize + numYSteps);
426 float* halfKernel = bulkAlloc.get();
427 float* summedKernel = bulkAlloc.get() + halfKernelSize;
428 float* yEvals = bulkAlloc.get() + 2 * halfKernelSize;
429 make_half_kernel_and_summed_table(halfKernel, summedKernel, halfKernelSize, sigma);
430
431 float firstX = -halfKernelSize + 0.5f;
432 apply_kernel_in_y(yEvals, numYSteps, firstX, radius, halfKernelSize, summedKernel);
433
434 for (int i = 0; i < numSteps - 1; ++i) {
435 float evalX = i + 0.5f;
436 profile[i] = eval_at(evalX, radius, halfKernel, halfKernelSize, yEvals + i);
437 }
438 // Ensure the tail of the Gaussian goes to zero.
439 profile[numSteps - 1] = 0;
440
441 bitmap.setImmutable();
442 return bitmap;
443}
#define SkScalarCeilToInt(x)
Definition SkScalar.h:36
static SkImageInfo MakeA8(int width, int height)

◆ CreateHalfPlaneProfile()

SkBitmap skgpu::CreateHalfPlaneProfile ( int  profileWidth)

Definition at line 445 of file BlurUtils.cpp.

445 {
446 SkASSERT(!(profileWidth & 0x1));
447
449 if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(profileWidth, 1))) {
450 return bitmap;
451 }
452
453 uint8_t* profile = bitmap.getAddr8(0, 0);
454
455 // The full kernel is 6 sigmas wide.
456 const float sigma = profileWidth / 6.0f;
457 const int halfKernelSize = profileWidth / 2;
458
459 skia_private::AutoTArray<float> halfKernel(halfKernelSize);
460
461 // The half kernel should sum to 0.5.
462 const float tot = 2.0f * make_unnormalized_half_kernel(halfKernel.get(), halfKernelSize, sigma);
463 float sum = 0.0f;
464 // Populate the profile from the right edge to the middle.
465 for (int i = 0; i < halfKernelSize; ++i) {
466 halfKernel[halfKernelSize - i - 1] /= tot;
467 sum += halfKernel[halfKernelSize - i - 1];
468 profile[profileWidth - i - 1] = SkUnitScalarClampToByte(sum);
469 }
470 // Populate the profile from the middle to the left edge (by flipping the half kernel and
471 // continuing the summation).
472 for (int i = 0; i < halfKernelSize; ++i) {
473 sum += halfKernel[i];
474 profile[halfKernelSize - i - 1] = SkUnitScalarClampToByte(sum);
475 }
476 // Ensure the tail of the Gaussian goes to zero.
477 profile[profileWidth - 1] = 0;
478
479 bitmap.setImmutable();
480 return bitmap;
481}
static U8CPU SkUnitScalarClampToByte(SkScalar x)
Definition SkColorPriv.h:36

◆ CreateIntegralTable()

SkBitmap skgpu::CreateIntegralTable ( float  sixSigma)

Definition at line 256 of file BlurUtils.cpp.

256 {
258
259 int width = ComputeIntegralTableWidth(sixSigma);
260 if (width == 0) {
261 return table;
262 }
263
264 if (!table.tryAllocPixels(SkImageInfo::MakeA8(width, 1))) {
265 return table;
266 }
267 *table.getAddr8(0, 0) = 255;
268 const float invWidth = 1.f / width;
269 for (int i = 1; i < width - 1; ++i) {
270 float x = (i + 0.5f) * invWidth;
271 x = (-6 * x + 3) * SK_ScalarRoot2Over2;
272 float integral = 0.5f * (std::erf(x) + 1.f);
273 *table.getAddr8(i, 0) = SkToU8(sk_float_round2int(255.f * integral));
274 }
275
276 *table.getAddr8(width - 1, 0) = 0;
277 table.setImmutable();
278 return table;
279}
#define sk_float_round2int(x)
#define SK_ScalarRoot2Over2
Definition SkScalar.h:23
constexpr uint8_t SkToU8(S x)
Definition SkTo.h:22
SI F table(const skcms_Curve *curve, F v)
int ComputeIntegralTableWidth(float sixSigma)

◆ CreateRRectBlurMask()

SkBitmap skgpu::CreateRRectBlurMask ( const SkRRect rrectToDraw,
const SkISize dimensions,
float  sigma 
)

Definition at line 535 of file BlurUtils.cpp.

535 {
537 int radius = skgpu::BlurSigmaRadius(sigma);
538 int kernelSize = skgpu::BlurKernelWidth(radius);
539
540 SkASSERT(kernelSize % 2);
541 SkASSERT(dimensions.width() % 2);
542 SkASSERT(dimensions.height() % 2);
543
544 SkVector radii = rrectToDraw.getSimpleRadii();
545 SkASSERT(SkScalarNearlyEqual(radii.fX, radii.fY));
546
547 const int halfWidthPlus1 = (dimensions.width() / 2) + 1;
548 const int halfHeightPlus1 = (dimensions.height() / 2) + 1;
549
550 std::unique_ptr<float[]> kernel(new float[kernelSize]);
551 skgpu::Compute1DBlurKernel(sigma, radius, SkSpan<float>(kernel.get(), kernelSize));
552
553 SkBitmap integral = CreateIntegralTable(6.0f * sigma);
554 if (integral.empty()) {
555 return {};
556 }
557
559 if (!result.tryAllocPixels(SkImageInfo::MakeA8(dimensions.width(), dimensions.height()))) {
560 return {};
561 }
562
563 std::vector<float> topVec;
564 topVec.reserve(dimensions.width());
565 for (int x = 0; x < dimensions.width(); ++x) {
566 if (x < rrectToDraw.rect().fLeft || x > rrectToDraw.rect().fRight) {
567 topVec.push_back(-1);
568 } else {
569 if (x + 0.5f < rrectToDraw.rect().fLeft + radii.fX) { // in the circular section
570 float xDist = rrectToDraw.rect().fLeft + radii.fX - x - 0.5f;
571 float h = sqrtf(radii.fX * radii.fX - xDist * xDist);
572 SkASSERT(0 <= h && h < radii.fY);
573 topVec.push_back(rrectToDraw.rect().fTop + radii.fX - h + 3 * sigma);
574 } else {
575 topVec.push_back(rrectToDraw.rect().fTop + 3 * sigma);
576 }
577 }
578 }
579
580 for (int y = 0; y < halfHeightPlus1; ++y) {
581 uint8_t* scanline = result.getAddr8(0, y);
582
583 for (int x = 0; x < halfWidthPlus1; ++x) {
584 scanline[x] = eval_H(x,
585 y,
586 topVec,
587 kernel.get(),
588 kernelSize,
589 integral.getAddr8(0, 0),
590 integral.width(),
591 6.0f * sigma);
592 scanline[dimensions.width() - x - 1] = scanline[x];
593 }
594
595 memcpy(result.getAddr8(0, dimensions.height() - y - 1), scanline, result.rowBytes());
596 }
597
598 result.setImmutable();
599 return result;
600}
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
bool empty() const
Definition SkBitmap.h:210
uint8_t * getAddr8(int x, int y) const
Definition SkBitmap.h:1270
int width() const
Definition SkBitmap.h:149
SkVector getSimpleRadii() const
Definition SkRRect.h:111
const SkRect & rect() const
Definition SkRRect.h:264
GAsyncResult * result
static uint8_t eval_H(int x, int y, const std::vector< float > &topVec, const float *kernel, int kernelSize, const uint8_t *integral, int integralSize, float sixSigma)
SkBitmap CreateIntegralTable(float sixSigma)
void Compute1DBlurKernel(float sigma, int radius, SkSpan< float > kernel)
Definition BlurUtils.h:118
SkScalar h
float fX
x-axis value
float fY
y-axis value
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ DefaultShaderErrorHandler()

ShaderErrorHandler * skgpu::DefaultShaderErrorHandler ( )

Used when no error handler is set. Will report failures via SkDebugf and asserts.

Definition at line 18 of file ShaderErrorHandler.cpp.

18 {
20 public:
21 void compileError(const char* shader, const char* errors) override {
22 std::string message = SkShaderUtils::BuildShaderErrorMessage(shader, errors);
23 SkShaderUtils::VisitLineByLine(message, [](int, const char* lineText) {
24 SkDebugf("%s\n", lineText);
25 });
26 SkDEBUGFAILF("Shader compilation failed!\n\n%s", message.c_str());
27 }
28 };
29
30 static DefaultShaderErrorHandler gHandler;
31 return &gHandler;
32}
#define SkDEBUGFAILF(fmt,...)
Definition SkAssert.h:119
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
virtual void compileError(const char *shader, const char *errors)
Win32Message message
void VisitLineByLine(const std::string &text, const std::function< void(int lineNumber, const char *lineText)> &visitFn)
std::string BuildShaderErrorMessage(const char *shader, const char *errors)
ShaderErrorHandler * DefaultShaderErrorHandler()

◆ DitherRangeForConfig()

float skgpu::DitherRangeForConfig ( SkColorType  dstColorType)

Definition at line 20 of file DitherUtils.cpp.

20 {
21 SkASSERT(dstColorType != kUnknown_SkColorType);
22
23 // We use 1 / (2^bitdepth-1) as the range since each channel can hold 2^bitdepth values
24 switch (dstColorType) {
25 // 4 bit
27 return 1 / 15.f;
28
29 // 6 bit
31 return 1 / 63.f;
32
33 // 8 bit
42 return 1 / 255.f;
43
44 // 10 bit
52 return 1 / 1023.f;
53
54 // 16 bit
58 return 1 / 32767.f;
59
60 // Unknown
62 // Half
67 // Float
69 return 0.f; // no dithering
70 }
72}
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
Definition SkColorType.h:50
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
Definition SkColorType.h:33
@ kR8_unorm_SkColorType
Definition SkColorType.h:54
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
Definition SkColorType.h:30
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition SkColorType.h:23
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
Definition SkColorType.h:43
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
Definition SkColorType.h:48
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition SkColorType.h:21
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:29
@ kSRGBA_8888_SkColorType
Definition SkColorType.h:53
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
Definition SkColorType.h:32
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:28
@ kA16_float_SkColorType
pixel with a half float for alpha
Definition SkColorType.h:45
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition SkColorType.h:40
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:27
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition SkColorType.h:31
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
Definition SkColorType.h:49
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition SkColorType.h:36
@ kR16G16_float_SkColorType
pixel with a half float for red and green
Definition SkColorType.h:46

◆ eval_at()

static uint8_t skgpu::eval_at ( float  evalX,
float  circleR,
const float *  halfKernel,
int  halfKernelSize,
const float *  yKernelEvaluations 
)
static

Definition at line 373 of file BlurUtils.cpp.

377 {
378 float acc = 0;
379
380 float x = evalX - halfKernelSize;
381 for (int i = 0; i < halfKernelSize; ++i, x += 1.0f) {
382 if (x < -circleR || x > circleR) {
383 continue;
384 }
385 float verticalEval = yKernelEvaluations[i];
386 acc += verticalEval * halfKernel[halfKernelSize - i - 1];
387 }
388 for (int i = 0; i < halfKernelSize; ++i, x += 1.0f) {
389 if (x < -circleR || x > circleR) {
390 continue;
391 }
392 float verticalEval = yKernelEvaluations[i + halfKernelSize];
393 acc += verticalEval * halfKernel[i];
394 }
395 // Since we applied a half kernel in y we multiply acc by 2 (the circle is symmetric about
396 // the x axis).
397 return SkUnitScalarClampToByte(2.0f * acc);
398}

◆ eval_H()

static uint8_t skgpu::eval_H ( int  x,
int  y,
const std::vector< float > &  topVec,
const float *  kernel,
int  kernelSize,
const uint8_t *  integral,
int  integralSize,
float  sixSigma 
)
static

Definition at line 510 of file BlurUtils.cpp.

517 {
518 SkASSERT(0 <= x && x < (int)topVec.size());
519 SkASSERT(kernelSize % 2);
520
521 float accum = 0.0f;
522
523 int xSampleLoc = x - (kernelSize / 2);
524 for (int i = 0; i < kernelSize; ++i, ++xSampleLoc) {
525 if (xSampleLoc < 0 || xSampleLoc >= (int)topVec.size()) {
526 continue;
527 }
528
529 accum += kernel[i] * eval_V(topVec[xSampleLoc], y, integral, integralSize, sixSigma);
530 }
531
532 return accum + 0.5f;
533}

◆ eval_V()

static uint8_t skgpu::eval_V ( float  top,
int  y,
const uint8_t *  integral,
int  integralSize,
float  sixSigma 
)
static

Definition at line 489 of file BlurUtils.cpp.

489 {
490 if (top < 0) {
491 return 0; // an empty column
492 }
493
494 float fT = (top - y - 0.5f) * (integralSize / sixSigma);
495 if (fT < 0) {
496 return 255;
497 } else if (fT >= integralSize - 1) {
498 return 0;
499 }
500
501 int lower = (int)fT;
502 float frac = fT - lower;
503
504 SkASSERT(lower + 1 < integralSize);
505
506 return integral[lower] * (1.0f - frac) + integral[lower + 1] * frac;
507}

◆ extend_5To8bits()

static int skgpu::extend_5To8bits ( int  b)
inlinestatic

Definition at line 36 of file DataUtils.cpp.

36 {
37 int c = b & 0x1f;
38 return (c << 3) | (c >> 2);
39}
static bool b

◆ fillin_BC1_with_color()

static void skgpu::fillin_BC1_with_color ( SkISize  dimensions,
const SkColor4f colorf,
char *  dest 
)
static

Definition at line 243 of file DataUtils.cpp.

243 {
244 SkColor color = colorf.toSkColor();
245
246 BC1Block block;
247 create_BC1_block(color, color, &block);
248
249 int numBlocks = num_ETC1_blocks(dimensions.width(), dimensions.height());
250
251 for (int i = 0; i < numBlocks; ++i) {
252 memcpy(dest, &block, sizeof(BC1Block));
253 dest += sizeof(BC1Block);
254 }
255}
SkColor4f color
uint32_t SkColor
Definition SkColor.h:37
static void create_BC1_block(BC1Block *block, bool transparent)
static int num_ETC1_blocks(int w, int h)

◆ fillin_ETC1_with_color()

static void skgpu::fillin_ETC1_with_color ( SkISize  dimensions,
const SkColor4f colorf,
char *  dest 
)
static

Definition at line 228 of file DataUtils.cpp.

228 {
229 SkColor color = colorf.toSkColor();
230
231 ETC1Block block;
232 create_etc1_block(color, &block);
233
234 int numBlocks = num_ETC1_blocks(dimensions.width(), dimensions.height());
235
236 for (int i = 0; i < numBlocks; ++i) {
237 memcpy(dest, &block, sizeof(ETC1Block));
238 dest += sizeof(ETC1Block);
239 }
240}
static void create_etc1_block(SkColor col, ETC1Block *block)
Definition DataUtils.cpp:73

◆ FillInCompressedData()

void skgpu::FillInCompressedData ( SkTextureCompressionType  type,
SkISize  dimensions,
skgpu::Mipmapped  mipmapped,
char *  dstPixels,
const SkColor4f colorf 
)

Definition at line 257 of file DataUtils.cpp.

261 {
262 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
263
264 int numMipLevels = 1;
265 if (mipmapped == skgpu::Mipmapped::kYes) {
266 numMipLevels = SkMipmap::ComputeLevelCount(dimensions.width(), dimensions.height()) + 1;
267 }
268
269 size_t offset = 0;
270
271 for (int i = 0; i < numMipLevels; ++i) {
272 size_t levelSize = SkCompressedDataSize(type, dimensions, nullptr, false);
273
275 fillin_ETC1_with_color(dimensions, colorf, &dstPixels[offset]);
276 } else {
279 fillin_BC1_with_color(dimensions, colorf, &dstPixels[offset]);
280 }
281
282 offset += levelSize;
283 dimensions = {std::max(1, dimensions.width()/2), std::max(1, dimensions.height()/2)};
284 }
285}
size_t SkCompressedDataSize(SkTextureCompressionType type, SkISize dimensions, TArray< size_t > *individualMipOffsets, bool mipmapped)
#define TRACE_FUNC
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition SkMipmap.cpp:134
static void fillin_BC1_with_color(SkISize dimensions, const SkColor4f &colorf, char *dest)
#define TRACE_EVENT0(category_group, name)

◆ find_info()

static int skgpu::find_info ( const TArray< VulkanExtensions::Info > &  infos,
const char  ext[] 
)
static

Definition at line 18 of file VulkanExtensions.cpp.

18 {
19 if (infos.empty()) {
20 return -1;
21 }
22 SkString extensionStr(ext);
23 VulkanExtensions::Info::Less less;
24 int idx = SkTSearch<VulkanExtensions::Info, SkString, VulkanExtensions::Info::Less>(
25 &infos.front(), infos.size(), extensionStr, sizeof(VulkanExtensions::Info),
26 less);
27 return idx;
28}
bool empty() const
Definition SkTArray.h:194
int size() const
Definition SkTArray.h:416

◆ Flush()

void skgpu::Flush ( SkSurface surface)
inline

Definition at line 25 of file GpuTools.h.

25 {
26#if defined(SK_GANESH)
28#endif
29#if defined(SK_GRAPHITE)
31#endif
32}
VkSurfaceKHR surface
Definition main.cc:49
SK_API GrSemaphoresSubmitted Flush(sk_sp< SkSurface >)
void Flush(sk_sp< SkSurface > surface)

◆ FlushAndSubmit()

void skgpu::FlushAndSubmit ( SkSurface surface)
inline

Definition at line 34 of file GpuTools.h.

34 {
35#if defined(SK_GANESH)
37#endif
38#if defined(SK_GRAPHITE)
39 // Graphite doesn't have a "flush and submit" equivilent
41#endif
42}
SK_API void FlushAndSubmit(sk_sp< SkSurface >)

◆ GetApproxSize()

SkISize skgpu::GetApproxSize ( SkISize  )

Map dimensions to larger powers of 2. Above a certain tolerance, dimensions can also map to the midpoints between powers of 2.

Definition at line 17 of file SkBackingFit.cpp.

17 {
18 // Map 'value' to a larger multiple of 2. Values <= 'kMagicTol' will pop up to
19 // the next power of 2. Those above 'kMagicTol' will only go up half the floor power of 2.
20 auto adjust = [](int value) {
21 constexpr int kMinApproxSize = 16;
22 constexpr int kMagicTol = 1024;
23
24 value = std::max(kMinApproxSize, value);
25
26 if (SkIsPow2(value)) {
27 return value;
28 }
29
30 int ceilPow2 = SkNextPow2(value);
31 if (value <= kMagicTol) {
32 return ceilPow2;
33 }
34
35 int floorPow2 = ceilPow2 >> 1;
36 int mid = floorPow2 + (floorPow2 >> 1);
37
38 if (value <= mid) {
39 return mid;
40 }
41 return ceilPow2;
42 };
43
44 return {adjust(size.width()), adjust(size.height())};
45}
constexpr bool SkIsPow2(T value)
Definition SkMath.h:51
uint8_t value
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ GetBlendFormula()

BlendFormula skgpu::GetBlendFormula ( bool  isOpaque,
bool  hasCoverage,
SkBlendMode  xfermode 
)

Definition at line 216 of file BlendFormula.cpp.

216 {
217 SkASSERT((unsigned)xfermode <= (unsigned)SkBlendMode::kLastCoeffMode);
218 return gBlendTable[isOpaque][hasCoverage][(int)xfermode];
219}
@ kLastCoeffMode
last porter duff blend mode

◆ GetBlur2DEffect()

const SkRuntimeEffect * skgpu::GetBlur2DEffect ( const SkISize radii)

Definition at line 243 of file BlurUtils.cpp.

243 {
244 int kernelArea = BlurKernelWidth(radii.width()) * BlurKernelWidth(radii.height());
245 return GetKnownRuntimeEffect(
246 to_stablekey(kernelArea,
247 static_cast<uint32_t>(SkKnownRuntimeEffects::StableKey::k2DBlurBase)));
248}
static SkKnownRuntimeEffects::StableKey to_stablekey(int kernelWidth, uint32_t baseKey)

◆ GetExtensionFeatureStruct()

template<typename T >
T * skgpu::GetExtensionFeatureStruct ( const VkPhysicalDeviceFeatures2 features,
VkStructureType  type 
)

Returns a ptr to the requested extension feature struct or nullptr if it is not present.

Definition at line 208 of file VulkanUtilsPriv.h.

209 {
210 // All Vulkan structs that could be part of the features chain will start with the
211 // structure type followed by the pNext pointer. We cast to the CommonVulkanHeader
212 // so we can get access to the pNext for the next struct.
213 struct CommonVulkanHeader {
214 VkStructureType sType;
215 void* pNext;
216 };
217
218 void* pNext = features.pNext;
219 while (pNext) {
220 CommonVulkanHeader* header = static_cast<CommonVulkanHeader*>(pNext);
221 if (header->sType == type) {
222 return static_cast<T*>(pNext);
223 }
224 pNext = header->pNext;
225 }
226 return nullptr;
227}
#define T
static const char header[]
Definition skpbench.cpp:88
VkStructureType

◆ GetLCDBlendFormula()

BlendFormula skgpu::GetLCDBlendFormula ( SkBlendMode  xfermode)

Definition at line 221 of file BlendFormula.cpp.

221 {
222 SkASSERT((unsigned)xfermode <= (unsigned)SkBlendMode::kLastCoeffMode);
223 return gLCDBlendTable[(int)xfermode];
224}

◆ GetLinearBlur1DEffect()

const SkRuntimeEffect * skgpu::GetLinearBlur1DEffect ( int  radius)

Definition at line 237 of file BlurUtils.cpp.

237 {
238 return GetKnownRuntimeEffect(
240 static_cast<uint32_t>(SkKnownRuntimeEffects::StableKey::k1DBlurBase)));
241}

◆ GetPorterDuffBlendConstants()

SkSpan< const float > skgpu::GetPorterDuffBlendConstants ( SkBlendMode  mode)

If a blend can be represented by blend_porter_duff, returns the associated blend constants as an array of four floats. If not, returns an empty span.

Definition at line 53 of file Blend.cpp.

53 {
54 static constexpr float kClear[] = {0, 0, 0, 0};
55 static constexpr float kSrc[] = {1, 0, 0, 0};
56 static constexpr float kDst[] = {0, 1, 0, 0};
57 static constexpr float kSrcOver[] = {1, 0, 0, -1};
58 static constexpr float kDstOver[] = {0, 1, -1, 0};
59 static constexpr float kSrcIn[] = {0, 0, 1, 0};
60 static constexpr float kDstIn[] = {0, 0, 0, 1};
61 static constexpr float kSrcOut[] = {0, 0, -1, 0};
62 static constexpr float kDstOut[] = {0, 0, 0, -1};
63 static constexpr float kSrcATop[] = {0, 0, 1, -1};
64 static constexpr float kDstATop[] = {0, 0, -1, 1};
65 static constexpr float kXor[] = {0, 0, -1, -1};
66 static constexpr float kPlus[] = {1, 1, 0, 0};
67
68 switch (mode) {
69 case SkBlendMode::kClear: return SkSpan(kClear);
70 case SkBlendMode::kSrc: return SkSpan(kSrc);
71 case SkBlendMode::kDst: return SkSpan(kDst);
74 case SkBlendMode::kSrcIn: return SkSpan(kSrcIn);
75 case SkBlendMode::kDstIn: return SkSpan(kDstIn);
80 case SkBlendMode::kXor: return SkSpan(kXor);
81 case SkBlendMode::kPlus: return SkSpan(kPlus);
82 default: return {};
83 }
84}

◆ GetReducedBlendModeInfo()

ReducedBlendModeInfo skgpu::GetReducedBlendModeInfo ( SkBlendMode  mode)

Definition at line 86 of file Blend.cpp.

86 {
87 static constexpr float kHue[] = {0, 1};
88 static constexpr float kSaturation[] = {1, 1};
89 static constexpr float kColor[] = {0, 0};
90 static constexpr float kLuminosity[] = {1, 0};
91
92 static constexpr float kOverlay[] = {0};
93 static constexpr float kHardLight[] = {1};
94
95 static constexpr float kDarken[] = {1};
96 static constexpr float kLighten[] = {-1};
97
98 switch (mode) {
99 // Clear/src/dst are intentionally omitted; using the built-in blend_xxxxx functions is
100 // preferable, since that gives us an opportunity to eliminate the src/dst entirely.
101
111 case SkBlendMode::kPlus: return {"blend_porter_duff", GetPorterDuffBlendConstants(mode)};
112
113 case SkBlendMode::kHue: return {"blend_hslc", SkSpan(kHue)};
114 case SkBlendMode::kSaturation: return {"blend_hslc", SkSpan(kSaturation)};
115 case SkBlendMode::kColor: return {"blend_hslc", SkSpan(kColor)};
116 case SkBlendMode::kLuminosity: return {"blend_hslc", SkSpan(kLuminosity)};
117
118 case SkBlendMode::kOverlay: return {"blend_overlay", SkSpan(kOverlay)};
119 case SkBlendMode::kHardLight: return {"blend_overlay", SkSpan(kHardLight)};
120
121 case SkBlendMode::kDarken: return {"blend_darken", SkSpan(kDarken)};
122 case SkBlendMode::kLighten: return {"blend_darken", SkSpan(kLighten)};
123
124 default: return {BlendFuncName(mode), {}};
125 }
126}
static constexpr SkColor kColor
const char * BlendFuncName(SkBlendMode mode)
Definition Blend.cpp:18
SkSpan< const float > GetPorterDuffBlendConstants(SkBlendMode mode)
Definition Blend.cpp:53

◆ InvokeDeviceLostCallback()

void skgpu::InvokeDeviceLostCallback ( const skgpu::VulkanInterface vulkanInterface,
VkDevice  vkDevice,
skgpu::VulkanDeviceLostContext  faultContext,
skgpu::VulkanDeviceLostProc  faultProc,
bool  supportsDeviceFaultInfoExtension 
)

Calls faultProc with faultContext; passes debug info if VK_EXT_device_fault is supported/enabled.

Note: must only be called after receiving VK_ERROR_DEVICE_LOST.

Definition at line 194 of file VulkanUtilsPriv.cpp.

198 {
199 if (!deviceLostProc) {
200 return;
201 }
202
203 std::vector<VkDeviceFaultAddressInfoEXT> addressInfos = {};
204 std::vector<VkDeviceFaultVendorInfoEXT> vendorInfos = {};
205 std::vector<std::byte> vendorBinaryData = {};
206
207 if (!supportsDeviceFaultInfoExtension) {
208 deviceLostProc(deviceLostContext,
209 "No details: VK_EXT_device_fault not available/enabled.",
210 addressInfos,
211 vendorInfos,
212 vendorBinaryData);
213 return;
214 }
215
216 // Query counts
217 VkDeviceFaultCountsEXT faultCounts = {};
219 VkResult result = SHARED_GR_VULKAN_CALL(vulkanInterface,
220 GetDeviceFaultInfo(vkDevice, &faultCounts, NULL));
221 if (result != VK_SUCCESS) {
222 deviceLostProc(
223 deviceLostContext,
224 "No details: VK_EXT_device_fault error counting failed: " + std::to_string(result),
225 addressInfos,
226 vendorInfos,
227 vendorBinaryData);
228 return;
229 }
230
231 // Prepare storage
232 addressInfos.resize(faultCounts.addressInfoCount);
233 vendorInfos.resize(faultCounts.vendorInfoCount);
234 vendorBinaryData.resize(faultCounts.vendorBinarySize);
235
236 // Query fault info
237 VkDeviceFaultInfoEXT faultInfo = {};
239 faultInfo.pAddressInfos = addressInfos.data();
240 faultInfo.pVendorInfos = vendorInfos.data();
241 faultInfo.pVendorBinaryData =
242 faultCounts.vendorBinarySize > 0 ? vendorBinaryData.data() : nullptr;
243 result = SHARED_GR_VULKAN_CALL(vulkanInterface,
244 GetDeviceFaultInfo(vkDevice, &faultCounts, &faultInfo));
245 if (result != VK_SUCCESS) {
246 deviceLostProc(
247 deviceLostContext,
248 "No details: VK_EXT_device_fault info dumping failed: " + std::to_string(result),
249 addressInfos,
250 vendorInfos,
251 vendorBinaryData);
252 return;
253 }
254
255 deviceLostProc(deviceLostContext,
256 std::string(faultInfo.description),
257 addressInfos,
258 vendorInfos,
259 vendorBinaryData);
260}
#define SHARED_GR_VULKAN_CALL(IFACE, X)
VkStructureType sType
VkDeviceSize vendorBinarySize
VkStructureType sType
char description[VK_MAX_DESCRIPTION_SIZE]
VkDeviceFaultAddressInfoEXT * pAddressInfos
VkDeviceFaultVendorInfoEXT * pVendorInfos
VkResult
@ VK_SUCCESS
@ VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT
@ VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT

◆ IsDawnBackend()

bool skgpu::IsDawnBackend ( skgpu::ContextType  type)

Definition at line 73 of file ContextType.cpp.

73 {
74 switch (type) {
75 case ContextType::kDawn_D3D11:
76 case ContextType::kDawn_D3D12:
77 case ContextType::kDawn_Metal:
78 case ContextType::kDawn_OpenGL:
79 case ContextType::kDawn_OpenGLES:
80 case ContextType::kDawn_Vulkan:
81 return true;
82
83 default:
84 return false;
85 }
86}

◆ IsNativeBackend()

bool skgpu::IsNativeBackend ( skgpu::ContextType  type)

Definition at line 57 of file ContextType.cpp.

57 {
58 switch (type) {
59 case ContextType::kDirect3D:
60 case ContextType::kGL:
61 case ContextType::kGLES:
62 case ContextType::kMetal:
63 case ContextType::kVulkan:
64 return true;
65
66 default:
67 // Mock doesn't use the GPU, and Dawn and ANGLE add a layer between Skia and the native
68 // GPU backend.
69 return false;
70 }
71}

◆ IsRenderingContext()

bool skgpu::IsRenderingContext ( skgpu::ContextType  type)

Definition at line 88 of file ContextType.cpp.

88 {
89 return type != ContextType::kMock;
90}

◆ make_half_kernel_and_summed_table()

static void skgpu::make_half_kernel_and_summed_table ( float *  halfKernel,
float *  summedHalfKernel,
int  halfKernelSize,
float  sigma 
)
static

Definition at line 323 of file BlurUtils.cpp.

326 {
327 // The half kernel should sum to 0.5 not 1.0.
328 const float tot = 2.0f * make_unnormalized_half_kernel(halfKernel, halfKernelSize, sigma);
329 float sum = 0.0f;
330 for (int i = 0; i < halfKernelSize; ++i) {
331 halfKernel[i] /= tot;
332 sum += halfKernel[i];
333 summedHalfKernel[i] = sum;
334 }
335}
static float make_unnormalized_half_kernel(float *halfKernel, int halfKernelSize, float sigma)

◆ make_unnormalized_half_kernel()

static float skgpu::make_unnormalized_half_kernel ( float *  halfKernel,
int  halfKernelSize,
float  sigma 
)
static

Definition at line 306 of file BlurUtils.cpp.

306 {
307 const float invSigma = 1.0f / sigma;
308 const float b = -0.5f * invSigma * invSigma;
309 float tot = 0.0f;
310 // Compute half kernel values at half pixel steps out from the center.
311 float t = 0.5f;
312 for (int i = 0; i < halfKernelSize; ++i) {
313 float value = expf(t * t * b);
314 tot += value;
315 halfKernel[i] = value;
316 t += 1.0f;
317 }
318 return tot;
319}

◆ MakeDitherLUT()

SkBitmap skgpu::MakeDitherLUT ( )

Definition at line 74 of file DitherUtils.cpp.

74 {
75 static constexpr struct DitherTable {
76 constexpr DitherTable() : data() {
77 constexpr int kImgSize = 8; // if changed, also change value in sk_dither_shader
78
79 for (int x = 0; x < kImgSize; ++x) {
80 for (int y = 0; y < kImgSize; ++y) {
81 // The computation of 'm' and 'value' is lifted from CPU backend.
82 unsigned int m = (y & 1) << 5 | (x & 1) << 4 |
83 (y & 2) << 2 | (x & 2) << 1 |
84 (y & 4) >> 1 | (x & 4) >> 2;
85 float value = float(m) * 1.0 / 64.0 - 63.0 / 128.0;
86 // Bias by 0.5 to be in 0..1, mul by 255 and round to nearest int to make byte.
87 data[y * 8 + x] = (uint8_t)((value + 0.5) * 255.f + 0.5f);
88 }
89 }
90 }
91 uint8_t data[64];
92 } gTable;
93
94 SkBitmap bmp;
96 bmp.setPixels(const_cast<uint8_t*>(gTable.data));
97 bmp.setImmutable();
98 return bmp;
99}
void setImmutable()
Definition SkBitmap.cpp:400
void setPixels(void *pixels)
Definition SkBitmap.cpp:207
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
Definition SkBitmap.cpp:114
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ MaskFormatBytesPerPixel()

constexpr int skgpu::MaskFormatBytesPerPixel ( MaskFormat  format)
inlineconstexpr

Return the number of bytes-per-pixel for the specified mask format.

Definition at line 110 of file AtlasTypes.h.

110 {
111 SkASSERT(static_cast<int>(format) < kMaskFormatCount);
112 // kA8 (0) -> 1
113 // kA565 (1) -> 2
114 // kARGB (2) -> 4
115 static_assert(static_cast<int>(MaskFormat::kA8) == 0, "enum_order_dependency");
116 static_assert(static_cast<int>(MaskFormat::kA565) == 1, "enum_order_dependency");
117 static_assert(static_cast<int>(MaskFormat::kARGB) == 2, "enum_order_dependency");
118
119 return SkTo<int>(1u << static_cast<int>(format));
120}
uint32_t uint32_t * format

◆ MaskFormatToColorType()

static constexpr SkColorType skgpu::MaskFormatToColorType ( MaskFormat  format)
staticconstexpr

Definition at line 122 of file AtlasTypes.h.

122 {
123 switch (format) {
124 case MaskFormat::kA8:
126 case MaskFormat::kA565:
128 case MaskFormat::kARGB:
130 }
132}

◆ MtlFormatBytesPerBlock()

size_t skgpu::MtlFormatBytesPerBlock ( MTLPixelFormat  mtlFormat)

Definition at line 119 of file MtlUtils.mm.

119 {
120 switch (mtlFormat) {
121 case MTLPixelFormatInvalid: return 0;
122 case MTLPixelFormatRGBA8Unorm: return 4;
123 case MTLPixelFormatR8Unorm: return 1;
124 case MTLPixelFormatA8Unorm: return 1;
125 case MTLPixelFormatBGRA8Unorm: return 4;
126 case MTLPixelFormatB5G6R5Unorm: return 2;
127 case MTLPixelFormatRGBA16Float: return 8;
128 case MTLPixelFormatR16Float: return 2;
129 case MTLPixelFormatRG8Unorm: return 2;
130 case MTLPixelFormatRGB10A2Unorm: return 4;
131 case MTLPixelFormatBGR10A2Unorm: return 4;
132 case MTLPixelFormatABGR4Unorm: return 2;
133 case MTLPixelFormatRGBA8Unorm_sRGB: return 4;
134 case MTLPixelFormatR16Unorm: return 2;
135 case MTLPixelFormatRG16Unorm: return 4;
136 case MTLPixelFormatETC2_RGB8: return 8;
137#ifdef SK_BUILD_FOR_MAC
138 case MTLPixelFormatBC1_RGBA: return 8;
139#endif
140 case MTLPixelFormatRGBA16Unorm: return 8;
141 case MTLPixelFormatRG16Float: return 4;
142 case MTLPixelFormatStencil8: return 1;
143
144 default: return 0;
145 }
146}

◆ MtlFormatChannels()

uint32_t skgpu::MtlFormatChannels ( MTLPixelFormat  mtlFormat)

Definition at line 91 of file MtlUtils.mm.

91 {
92 switch (mtlFormat) {
93 case MTLPixelFormatRGBA8Unorm: return kRGBA_SkColorChannelFlags;
94 case MTLPixelFormatR8Unorm: return kRed_SkColorChannelFlag;
95 case MTLPixelFormatA8Unorm: return kAlpha_SkColorChannelFlag;
96 case MTLPixelFormatBGRA8Unorm: return kRGBA_SkColorChannelFlags;
97 case MTLPixelFormatB5G6R5Unorm: return kRGB_SkColorChannelFlags;
98 case MTLPixelFormatRGBA16Float: return kRGBA_SkColorChannelFlags;
99 case MTLPixelFormatR16Float: return kRed_SkColorChannelFlag;
100 case MTLPixelFormatRG8Unorm: return kRG_SkColorChannelFlags;
101 case MTLPixelFormatRGB10A2Unorm: return kRGBA_SkColorChannelFlags;
102 case MTLPixelFormatBGR10A2Unorm: return kRGBA_SkColorChannelFlags;
103 case MTLPixelFormatABGR4Unorm: return kRGBA_SkColorChannelFlags;
104 case MTLPixelFormatRGBA8Unorm_sRGB: return kRGBA_SkColorChannelFlags;
105 case MTLPixelFormatR16Unorm: return kRed_SkColorChannelFlag;
106 case MTLPixelFormatRG16Unorm: return kRG_SkColorChannelFlags;
107 case MTLPixelFormatETC2_RGB8: return kRGB_SkColorChannelFlags;
108#ifdef SK_BUILD_FOR_MAC
109 case MTLPixelFormatBC1_RGBA: return kRGBA_SkColorChannelFlags;
110#endif
111 case MTLPixelFormatRGBA16Unorm: return kRGBA_SkColorChannelFlags;
112 case MTLPixelFormatRG16Float: return kRG_SkColorChannelFlags;
113 case MTLPixelFormatStencil8: return 0;
114
115 default: return 0;
116 }
117}
@ kRGB_SkColorChannelFlags
Definition SkColor.h:247
@ kRGBA_SkColorChannelFlags
Definition SkColor.h:248
@ kRed_SkColorChannelFlag
Definition SkColor.h:239
@ kRG_SkColorChannelFlags
Definition SkColor.h:246
@ kAlpha_SkColorChannelFlag
Definition SkColor.h:242

◆ MtlFormatIsCompressed()

bool skgpu::MtlFormatIsCompressed ( MTLPixelFormat  mtlFormat)

Definition at line 49 of file MtlUtils.mm.

49 {
50 switch (mtlFormat) {
51 case MTLPixelFormatETC2_RGB8:
52 return true;
53#ifdef SK_BUILD_FOR_MAC
54 case MTLPixelFormatBC1_RGBA:
55 return true;
56#endif
57 default:
58 return false;
59 }
60}

◆ MtlFormatIsDepth()

bool skgpu::MtlFormatIsDepth ( MTLPixelFormat  format)

Definition at line 29 of file MtlUtils.mm.

29 {
30 switch (format) {
31 case MTLPixelFormatDepth32Float:
32 case MTLPixelFormatDepth32Float_Stencil8:
33 return true;
34 default:
35 return false;
36 }
37}

◆ MtlFormatIsDepthOrStencil()

bool skgpu::MtlFormatIsDepthOrStencil ( MTLPixelFormat  format)

Definition at line 18 of file MtlUtils.mm.

18 {
19 switch (format) {
20 case MTLPixelFormatStencil8: // fallthrough
21 case MTLPixelFormatDepth32Float:
22 case MTLPixelFormatDepth32Float_Stencil8:
23 return true;
24 default:
25 return false;
26 }
27}

◆ MtlFormatIsStencil()

bool skgpu::MtlFormatIsStencil ( MTLPixelFormat  format)

Definition at line 39 of file MtlUtils.mm.

39 {
40 switch (format) {
41 case MTLPixelFormatStencil8: // fallthrough
42 case MTLPixelFormatDepth32Float_Stencil8:
43 return true;
44 default:
45 return false;
46 }
47}

◆ MtlFormatToCompressionType()

SkTextureCompressionType skgpu::MtlFormatToCompressionType ( MTLPixelFormat  mtlFormat)

Definition at line 148 of file MtlUtils.mm.

148 {
149 switch (mtlFormat) {
150 case MTLPixelFormatETC2_RGB8: return SkTextureCompressionType::kETC2_RGB8_UNORM;
151#ifdef SK_BUILD_FOR_MAC
152 case MTLPixelFormatBC1_RGBA: return SkTextureCompressionType::kBC1_RGBA8_UNORM;
153#endif
154 default: return SkTextureCompressionType::kNone;
155 }
156}

◆ MtlFormatToString()

const char * skgpu::MtlFormatToString ( MTLPixelFormat  mtlFormat)

Definition at line 62 of file MtlUtils.mm.

62 {
63 switch (mtlFormat) {
64 case MTLPixelFormatInvalid: return "Invalid";
65 case MTLPixelFormatRGBA8Unorm: return "RGBA8Unorm";
66 case MTLPixelFormatR8Unorm: return "R8Unorm";
67 case MTLPixelFormatA8Unorm: return "A8Unorm";
68 case MTLPixelFormatBGRA8Unorm: return "BGRA8Unorm";
69 case MTLPixelFormatB5G6R5Unorm: return "B5G6R5Unorm";
70 case MTLPixelFormatRGBA16Float: return "RGBA16Float";
71 case MTLPixelFormatR16Float: return "R16Float";
72 case MTLPixelFormatRG8Unorm: return "RG8Unorm";
73 case MTLPixelFormatRGB10A2Unorm: return "RGB10A2Unorm";
74 case MTLPixelFormatBGR10A2Unorm: return "BGR10A2Unorm";
75 case MTLPixelFormatABGR4Unorm: return "ABGR4Unorm";
76 case MTLPixelFormatRGBA8Unorm_sRGB: return "RGBA8Unorm_sRGB";
77 case MTLPixelFormatR16Unorm: return "R16Unorm";
78 case MTLPixelFormatRG16Unorm: return "RG16Unorm";
79 case MTLPixelFormatETC2_RGB8: return "ETC2_RGB8";
80#ifdef SK_BUILD_FOR_MAC
81 case MTLPixelFormatBC1_RGBA: return "BC1_RGBA";
82#endif
83 case MTLPixelFormatRGBA16Unorm: return "RGBA16Unorm";
84 case MTLPixelFormatRG16Float: return "RG16Float";
85 case MTLPixelFormatStencil8: return "Stencil8";
86
87 default: return "Unknown";
88 }
89}

◆ num_4x4_blocks()

static int skgpu::num_4x4_blocks ( int  size)
static

Definition at line 121 of file DataUtils.cpp.

121 {
122 return ((size + 3) & ~3) >> 2;
123}

◆ num_ETC1_blocks()

static int skgpu::num_ETC1_blocks ( int  w,
int  h 
)
static

Definition at line 125 of file DataUtils.cpp.

125 {
126 w = num_4x4_blocks(w);
127 h = num_4x4_blocks(h);
128
129 return w * h;
130}
SkScalar w

◆ NumCompressedBlocks()

size_t skgpu::NumCompressedBlocks ( SkTextureCompressionType  type,
SkISize  baseDimensions 
)

Definition at line 163 of file DataUtils.cpp.

163 {
164 switch (type) {
166 return baseDimensions.width() * baseDimensions.height();
170 int numBlocksWidth = num_4x4_blocks(baseDimensions.width());
171 int numBlocksHeight = num_4x4_blocks(baseDimensions.height());
172
173 return numBlocksWidth * numBlocksHeight;
174 }
175 }
177}

◆ operator<<() [1/11]

template<typename T >
IndexWriter & skgpu::operator<< ( IndexWriter &&  w,
const T val 
)
inline

Definition at line 420 of file BufferWriter.h.

420{ return w << val; }

◆ operator<<() [2/11]

IndexWriter & skgpu::operator<< ( IndexWriter w,
int  val 
)
inline

Definition at line 417 of file BufferWriter.h.

417{ return (w << SkTo<uint16_t>(val)); }

◆ operator<<() [3/11]

IndexWriter & skgpu::operator<< ( IndexWriter w,
uint16_t  val 
)
inline

Definition at line 410 of file BufferWriter.h.

410 {
411 w.validate(sizeof(uint16_t));
412 memcpy(w.fPtr, &val, sizeof(uint16_t));
413 w = w.makeOffset(1);
414 return w;
415}

◆ operator<<() [4/11]

template<typename T >
VertexWriter & skgpu::operator<< ( VertexWriter &&  w,
const T val 
)
inline

Definition at line 327 of file BufferWriter.h.

327{ return w << val; }

◆ operator<<() [5/11]

template<>
VertexWriter & skgpu::operator<< ( VertexWriter w,
const skvx::float4 vector 
)
inline

Definition at line 318 of file BufferWriter.h.

318 {
319 w.validate(sizeof(vector));
320 vector.store(w.fPtr);
321 w = w.makeOffset(sizeof(vector));
322 return w;
323}
SKVX_ALWAYS_INLINE void store(void *ptr) const
Definition SkVx.h:112

◆ operator<<() [6/11]

template<typename T >
VertexWriter & skgpu::operator<< ( VertexWriter w,
const T val 
)
inline

Definition at line 277 of file BufferWriter.h.

277 {
278 static_assert(std::is_trivially_copyable<T>::value, "");
279 w.validate(sizeof(T));
280 memcpy(w.fPtr, &val, sizeof(T));
281 w = w.makeOffset(sizeof(T));
282 return w;
283}

◆ operator<<() [7/11]

template<>
VertexWriter & skgpu::operator<< ( VertexWriter w,
const VertexColor color 
)
inline

Definition at line 368 of file BufferWriter.h.

368 {
369 w << color.fColor[0];
370 if (color.fWideColor) {
371 w << color.fColor[1]
372 << color.fColor[2]
373 << color.fColor[3];
374 }
375 return w;
376}

◆ operator<<() [8/11]

template<typename T >
VertexWriter & skgpu::operator<< ( VertexWriter w,
const VertexWriter::ArrayDesc< T > &  array 
)
inline

Definition at line 301 of file BufferWriter.h.

301 {
302 static_assert(std::is_trivially_copyable<T>::value, "");
303 w.validate(array.fCount * sizeof(T));
304 memcpy(w.fPtr, array.fArray, array.fCount * sizeof(T));
305 w = w.makeOffset(sizeof(T) * array.fCount);
306 return w;
307}

◆ operator<<() [9/11]

template<typename T >
VertexWriter & skgpu::operator<< ( VertexWriter w,
const VertexWriter::Conditional< T > &  val 
)
inline

Definition at line 286 of file BufferWriter.h.

286 {
287 static_assert(std::is_trivially_copyable<T>::value, "");
288 if (val.fCondition) {
289 w << val.fValue;
290 }
291 return w;
292}

◆ operator<<() [10/11]

template<int kCount, typename T >
VertexWriter & skgpu::operator<< ( VertexWriter w,
const VertexWriter::RepeatDesc< kCount, T > &  repeat 
)
inline

Definition at line 310 of file BufferWriter.h.

310 {
311 for (int i = 0; i < kCount; ++i) {
312 w << repeat.fVal;
313 }
314 return w;
315}
static unsigned repeat(SkFixed fx, int max)

◆ operator<<() [11/11]

template<typename T >
VertexWriter & skgpu::operator<< ( VertexWriter w,
const VertexWriter::Skip< T > &  val 
)
inline

Definition at line 295 of file BufferWriter.h.

295 {
296 w = w.makeOffset(sizeof(T));
297 return w;
298}

◆ ResourceKeyHash()

uint32_t skgpu::ResourceKeyHash ( const uint32_t *  data,
size_t  size 
)

Definition at line 38 of file ResourceKey.cpp.

38 {
39 return SkChecksum::Hash32(data, size);
40}
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)

◆ SampleCountToVkSampleCount()

static constexpr bool skgpu::SampleCountToVkSampleCount ( uint32_t  samples,
VkSampleCountFlagBits vkSamples 
)
staticconstexpr

Definition at line 166 of file VulkanUtilsPriv.h.

167 {
168 SkASSERT(samples >= 1);
169 switch (samples) {
170 case 1:
171 *vkSamples = VK_SAMPLE_COUNT_1_BIT;
172 return true;
173 case 2:
174 *vkSamples = VK_SAMPLE_COUNT_2_BIT;
175 return true;
176 case 4:
177 *vkSamples = VK_SAMPLE_COUNT_4_BIT;
178 return true;
179 case 8:
180 *vkSamples = VK_SAMPLE_COUNT_8_BIT;
181 return true;
182 case 16:
183 *vkSamples = VK_SAMPLE_COUNT_16_BIT;
184 return true;
185 default:
186 return false;
187 }
188}
@ VK_SAMPLE_COUNT_8_BIT
@ VK_SAMPLE_COUNT_2_BIT
@ VK_SAMPLE_COUNT_1_BIT
@ VK_SAMPLE_COUNT_4_BIT
@ VK_SAMPLE_COUNT_16_BIT

◆ SetupSamplerYcbcrConversionInfo()

void skgpu::SetupSamplerYcbcrConversionInfo ( VkSamplerYcbcrConversionCreateInfo outInfo,
const VulkanYcbcrConversionInfo conversionInfo 
)

Returns a populated VkSamplerYcbcrConversionCreateInfo object based on VulkanYcbcrConversionInfo

Definition at line 23 of file VulkanUtilsPriv.cpp.

24 {
25#ifdef SK_DEBUG
26 const VkFormatFeatureFlags& featureFlags = conversionInfo.fFormatFeatures;
27 if (conversionInfo.fXChromaOffset == VK_CHROMA_LOCATION_MIDPOINT ||
30 }
31 if (conversionInfo.fXChromaOffset == VK_CHROMA_LOCATION_COSITED_EVEN ||
34 }
35 if (conversionInfo.fChromaFilter == VK_FILTER_LINEAR) {
37 }
38 if (conversionInfo.fForceExplicitReconstruction) {
39 SkASSERT(featureFlags &
41 }
42#endif
43
45 outInfo->pNext = nullptr;
46 outInfo->format = conversionInfo.fFormat;
47 outInfo->ycbcrModel = conversionInfo.fYcbcrModel;
48 outInfo->ycbcrRange = conversionInfo.fYcbcrRange;
49 outInfo->components = conversionInfo.fComponents;
50 outInfo->xChromaOffset = conversionInfo.fXChromaOffset;
51 outInfo->yChromaOffset = conversionInfo.fYChromaOffset;
52 outInfo->chromaFilter = conversionInfo.fChromaFilter;
54}
VkSamplerYcbcrModelConversion ycbcrModel
VkSamplerYcbcrRange fYcbcrRange
VkSamplerYcbcrModelConversion fYcbcrModel
VkFormatFeatureFlags fFormatFeatures
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT
@ VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT
@ VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT
@ VK_CHROMA_LOCATION_COSITED_EVEN
@ VK_CHROMA_LOCATION_MIDPOINT
VkFlags VkFormatFeatureFlags
@ VK_FILTER_LINEAR
@ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO

◆ skgpu_init_static_unique_key_once()

static void skgpu::skgpu_init_static_unique_key_once ( SkAlignedSTStorage< 1, UniqueKey > *  keyStorage)
inlinestatic

Definition at line 330 of file ResourceKey.h.

330 {
331 UniqueKey* key = new (keyStorage->get()) UniqueKey;
332 UniqueKey::Builder builder(key, UniqueKey::GenerateDomain(), 0);
333}

◆ SkShouldPostMessageToBus() [1/2]

static bool skgpu::SkShouldPostMessageToBus ( const UniqueKeyInvalidatedMessage msg,
uint32_t  msgBusUniqueID 
)
inlinestatic

Definition at line 360 of file ResourceKey.h.

361 {
362 return msg.contextID() == msgBusUniqueID;
363}

◆ SkShouldPostMessageToBus() [2/2]

static bool skgpu::SkShouldPostMessageToBus ( const UniqueKeyInvalidatedMsg_Graphite msg,
uint32_t  msgBusUniqueID 
)
inlinestatic

Definition at line 385 of file ResourceKey.h.

386 {
387 return msg.recorderID() == msgBusUniqueID;
388}

◆ SkSLToBackend()

bool skgpu::SkSLToBackend ( const SkSL::ShaderCaps caps,
bool(*)(SkSL::Program &, const SkSL::ShaderCaps *, std::string *)  toBackend,
const char *  backendLabel,
const std::string &  sksl,
SkSL::ProgramKind  programKind,
const SkSL::ProgramSettings settings,
std::string *  output,
SkSL::ProgramInterface outInterface,
ShaderErrorHandler errorHandler 
)

Wrapper for the SkSL compiler with useful logging and error handling.

Definition at line 21 of file PipelineUtils.cpp.

29 {
30#ifdef SK_DEBUG
31 std::string src = SkShaderUtils::PrettyPrint(sksl);
32#else
33 const std::string& src = sksl;
34#endif
36 std::unique_ptr<SkSL::Program> program = compiler.convertProgram(programKind, src, settings);
37 if (!program || !(*toBackend)(*program, caps, output)) {
38 errorHandler->compileError(src.c_str(),
39 compiler.errorText().c_str(),
40 /*shaderWasCached=*/false);
41 return false;
42 }
43
44#if defined(SK_PRINT_SKSL_SHADERS)
45 const bool kPrintSkSL = true;
46#else
47 const bool kPrintSkSL = false;
48#endif
49 const bool kSkSLPostCompilation = false;
50#if defined(SK_PRINT_NATIVE_SHADERS)
51 const bool printBackendSL = (backendLabel != nullptr);
52#else
53 const bool printBackendSL = false;
54#endif
55
56 if (kPrintSkSL || kSkSLPostCompilation || printBackendSL) {
58 if (kPrintSkSL) {
59 SkDebugf("SkSL:\n");
61 }
62 if (kSkSLPostCompilation) {
63 SkDebugf("SkSL (post-compilation):\n");
65 }
66 if (printBackendSL) {
67 SkDebugf("%s:\n", backendLabel);
69 }
70 }
71
72 if (outInterface) {
73 *outInterface = program->fInterface;
74 }
75 return true;
76}
std::string PrettyPrint(const std::string &string)
void PrintShaderBanner(SkSL::ProgramKind programKind)
void PrintLineByLine(const std::string &text)

◆ SkSLToGLSL()

bool skgpu::SkSLToGLSL ( const SkSL::ShaderCaps caps,
const std::string &  sksl,
SkSL::ProgramKind  programKind,
const SkSL::ProgramSettings settings,
std::string *  glsl,
SkSL::ProgramInterface outInterface,
ShaderErrorHandler errorHandler 
)
inline

Definition at line 38 of file GrGLShaderStringBuilder.h.

44 {
45 return SkSLToBackend(caps, &SkSL::ToGLSL, "GLSL",
46 sksl, programKind, settings, glsl, outInterface, errorHandler);
47}
bool ToGLSL(Program &program, const ShaderCaps *caps, OutputStream &out)
bool SkSLToBackend(const SkSL::ShaderCaps *caps, bool(*toBackend)(SkSL::Program &, const SkSL::ShaderCaps *, std::string *), const char *backendLabel, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *output, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)

◆ SkSLToMSL()

bool skgpu::SkSLToMSL ( const SkSL::ShaderCaps caps,
const std::string &  sksl,
SkSL::ProgramKind  programKind,
const SkSL::ProgramSettings settings,
std::string *  msl,
SkSL::ProgramInterface outInterface,
ShaderErrorHandler errorHandler 
)
inline

Definition at line 30 of file MtlUtilsPriv.h.

36 {
37 return SkSLToBackend(caps, &SkSL::ToMetal, "MSL",
38 sksl, programKind, settings, msl, outInterface, errorHandler);
39}
bool ToMetal(Program &program, const ShaderCaps *caps, OutputStream &out)

◆ SkSLToSPIRV()

bool skgpu::SkSLToSPIRV ( const SkSL::ShaderCaps caps,
const std::string &  sksl,
SkSL::ProgramKind  programKind,
const SkSL::ProgramSettings settings,
std::string *  spirv,
SkSL::ProgramInterface outInterface,
ShaderErrorHandler errorHandler 
)
inline

Definition at line 39 of file VulkanUtilsPriv.h.

45 {
46 return SkSLToBackend(caps, &SkSL::ToSPIRV, /*backendLabel=*/nullptr,
47 sksl, programKind, settings, spirv, outInterface, errorHandler);
48}
bool ToSPIRV(Program &program, const ShaderCaps *caps, OutputStream &out)

◆ SkSLToWGSL()

bool skgpu::SkSLToWGSL ( const SkSL::ShaderCaps caps,
const std::string &  sksl,
SkSL::ProgramKind  programKind,
const SkSL::ProgramSettings settings,
std::string *  wgsl,
SkSL::ProgramInterface outInterface,
ShaderErrorHandler errorHandler 
)
inline

Definition at line 29 of file DawnUtilsPriv.h.

35 {
36 return SkSLToBackend(caps, &SkSL::ToWGSL, "WGSL",
37 sksl, programKind, settings, wgsl, outInterface, errorHandler);
38}
bool ToWGSL(Program &program, const ShaderCaps *caps, OutputStream &out)

◆ test_table_entry()

static int skgpu::test_table_entry ( int  rOrig,
int  gOrig,
int  bOrig,
int  r8,
int  g8,
int  b8,
int  table,
int  offset 
)
static

Definition at line 59 of file DataUtils.cpp.

61 {
62 SkASSERT(0 <= table && table < 8);
63 SkASSERT(0 <= offset && offset < 4);
64
65 r8 = SkTPin<int>(r8 + kETC1ModifierTables[table][offset], 0, 255);
66 g8 = SkTPin<int>(g8 + kETC1ModifierTables[table][offset], 0, 255);
67 b8 = SkTPin<int>(b8 + kETC1ModifierTables[table][offset], 0, 255);
68
69 return SkTAbs(rOrig - r8) + SkTAbs(gOrig - g8) + SkTAbs(bOrig - b8);
70}
static const int kETC1ModifierTables[kNumETC1ModifierTables][kNumETC1PixelIndices]
static T SkTAbs(T value)
Definition SkTemplates.h:43

◆ to565()

static uint16_t skgpu::to565 ( SkColor  col)
static

Definition at line 138 of file DataUtils.cpp.

138 {
139 int r5 = SkMulDiv255Round(31, SkColorGetR(col));
140 int g6 = SkMulDiv255Round(63, SkColorGetG(col));
141 int b5 = SkMulDiv255Round(31, SkColorGetB(col));
142
143 return (r5 << 11) | (g6 << 5) | b5;
144}

◆ to_stablekey()

static SkKnownRuntimeEffects::StableKey skgpu::to_stablekey ( int  kernelWidth,
uint32_t  baseKey 
)
static

Definition at line 200 of file BlurUtils.cpp.

200 {
201 SkASSERT(kernelWidth >= 2 && kernelWidth <= kMaxBlurSamples);
202 switch(kernelWidth) {
203 // Batch on multiples of 4 (skipping width=1, since that can't happen)
204 case 2: [[fallthrough]];
205 case 3: [[fallthrough]];
206 case 4: return static_cast<SkKnownRuntimeEffects::StableKey>(baseKey);
207 case 5: [[fallthrough]];
208 case 6: [[fallthrough]];
209 case 7: [[fallthrough]];
210 case 8: return static_cast<SkKnownRuntimeEffects::StableKey>(baseKey+1);
211 case 9: [[fallthrough]];
212 case 10: [[fallthrough]];
213 case 11: [[fallthrough]];
214 case 12: return static_cast<SkKnownRuntimeEffects::StableKey>(baseKey+2);
215 case 13: [[fallthrough]];
216 case 14: [[fallthrough]];
217 case 15: [[fallthrough]];
218 case 16: return static_cast<SkKnownRuntimeEffects::StableKey>(baseKey+3);
219 case 17: [[fallthrough]];
220 case 18: [[fallthrough]];
221 case 19: [[fallthrough]];
222 // With larger kernels, batch on multiples of eight so up to 7 wasted samples.
223 case 20: return static_cast<SkKnownRuntimeEffects::StableKey>(baseKey+4);
224 case 21: [[fallthrough]];
225 case 22: [[fallthrough]];
226 case 23: [[fallthrough]];
227 case 24: [[fallthrough]];
228 case 25: [[fallthrough]];
229 case 26: [[fallthrough]];
230 case 27: [[fallthrough]];
231 case 28: return static_cast<SkKnownRuntimeEffects::StableKey>(baseKey+5);
232 default:
234 }
235}

◆ VkFormatBytesPerBlock()

static constexpr size_t skgpu::VkFormatBytesPerBlock ( VkFormat  vkFormat)
staticconstexpr

Definition at line 80 of file VulkanUtilsPriv.h.

80 {
81 switch (vkFormat) {
82 case VK_FORMAT_R8G8B8A8_UNORM: return 4;
83 case VK_FORMAT_R8_UNORM: return 1;
84 case VK_FORMAT_B8G8R8A8_UNORM: return 4;
85 case VK_FORMAT_R5G6B5_UNORM_PACK16: return 2;
86 case VK_FORMAT_B5G6R5_UNORM_PACK16: return 2;
87 case VK_FORMAT_R16G16B16A16_SFLOAT: return 8;
88 case VK_FORMAT_R16_SFLOAT: return 2;
89 case VK_FORMAT_R8G8B8_UNORM: return 3;
90 case VK_FORMAT_R8G8_UNORM: return 2;
95 case VK_FORMAT_R8G8B8A8_SRGB: return 4;
97 case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return 8;
98 case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return 8;
99 case VK_FORMAT_R16_UNORM: return 2;
100 case VK_FORMAT_R16G16_UNORM: return 4;
101 case VK_FORMAT_R16G16B16A16_UNORM: return 8;
102 case VK_FORMAT_R16G16_SFLOAT: return 4;
103 // Currently we are just over estimating this value to be used in gpu size calculations even
104 // though the actually size is probably less. We should instead treat planar formats similar
105 // to compressed textures that go through their own special query for calculating size.
109 case VK_FORMAT_S8_UINT: return 1;
110 case VK_FORMAT_D24_UNORM_S8_UINT: return 4;
111 case VK_FORMAT_D32_SFLOAT_S8_UINT: return 8;
112
113 default: return 0;
114 }
115}
@ VK_FORMAT_R16G16B16A16_UNORM
@ VK_FORMAT_R8G8B8A8_SRGB
@ VK_FORMAT_R8G8B8_UNORM
@ VK_FORMAT_D24_UNORM_S8_UINT
@ VK_FORMAT_B8G8R8A8_UNORM
@ VK_FORMAT_R16G16_SFLOAT
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
@ VK_FORMAT_R16_SFLOAT
@ VK_FORMAT_R8G8_UNORM
@ VK_FORMAT_S8_UINT
@ VK_FORMAT_R8_UNORM
@ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16
@ VK_FORMAT_R5G6B5_UNORM_PACK16
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
@ VK_FORMAT_R8G8B8A8_UNORM
@ VK_FORMAT_BC1_RGB_UNORM_BLOCK
@ VK_FORMAT_R16_UNORM
@ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
@ VK_FORMAT_R16G16B16A16_SFLOAT
@ VK_FORMAT_R16G16_UNORM
@ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32
@ VK_FORMAT_BC1_RGBA_UNORM_BLOCK
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
@ VK_FORMAT_B5G6R5_UNORM_PACK16
@ VK_FORMAT_D32_SFLOAT_S8_UINT

◆ VkFormatChannels()

static constexpr uint32_t skgpu::VkFormatChannels ( VkFormat  vkFormat)
staticconstexpr

Definition at line 50 of file VulkanUtilsPriv.h.

50 {
51 switch (vkFormat) {
73 case VK_FORMAT_S8_UINT: return 0;
74 case VK_FORMAT_D24_UNORM_S8_UINT: return 0;
75 case VK_FORMAT_D32_SFLOAT_S8_UINT: return 0;
76 default: return 0;
77 }
78}

◆ VkFormatIsCompressed()

static constexpr bool skgpu::VkFormatIsCompressed ( VkFormat  vkFormat)
staticconstexpr

Returns true if the format is compressed.

Definition at line 193 of file VulkanUtilsPriv.h.

193 {
194 switch (vkFormat) {
198 return true;
199 default:
200 return false;
201 }
203}

◆ VkFormatIsDepth()

static constexpr int skgpu::VkFormatIsDepth ( VkFormat  format)
staticconstexpr

Definition at line 137 of file VulkanUtilsPriv.h.

137 {
138 switch (format) {
141 return true;
142 default:
143 return false;
144 }
145}

◆ VkFormatIsStencil()

static constexpr int skgpu::VkFormatIsStencil ( VkFormat  format)
staticconstexpr

Definition at line 126 of file VulkanUtilsPriv.h.

126 {
127 switch (format) {
131 return true;
132 default:
133 return false;
134 }
135}

◆ VkFormatNeedsYcbcrSampler()

static constexpr bool skgpu::VkFormatNeedsYcbcrSampler ( VkFormat  format)
staticconstexpr

◆ VkFormatStencilBits()

static constexpr int skgpu::VkFormatStencilBits ( VkFormat  format)
staticconstexpr

Definition at line 147 of file VulkanUtilsPriv.h.

147 {
148 switch (format) {
150 return 8;
152 return 8;
154 return 8;
155 default:
156 return 0;
157 }
158}

◆ VkFormatToCompressionType()

static constexpr SkTextureCompressionType skgpu::VkFormatToCompressionType ( VkFormat  vkFormat)
staticconstexpr

◆ VkFormatToStr()

static constexpr const char * skgpu::VkFormatToStr ( VkFormat  vkFormat)
staticconstexpr

Definition at line 235 of file VulkanUtilsPriv.h.

235 {
236 switch (vkFormat) {
237 case VK_FORMAT_R8G8B8A8_UNORM: return "R8G8B8A8_UNORM";
238 case VK_FORMAT_R8_UNORM: return "R8_UNORM";
239 case VK_FORMAT_B8G8R8A8_UNORM: return "B8G8R8A8_UNORM";
240 case VK_FORMAT_R5G6B5_UNORM_PACK16: return "R5G6B5_UNORM_PACK16";
241 case VK_FORMAT_B5G6R5_UNORM_PACK16: return "B5G6R5_UNORM_PACK16";
242 case VK_FORMAT_R16G16B16A16_SFLOAT: return "R16G16B16A16_SFLOAT";
243 case VK_FORMAT_R16_SFLOAT: return "R16_SFLOAT";
244 case VK_FORMAT_R8G8B8_UNORM: return "R8G8B8_UNORM";
245 case VK_FORMAT_R8G8_UNORM: return "R8G8_UNORM";
246 case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return "A2B10G10R10_UNORM_PACK32";
247 case VK_FORMAT_A2R10G10B10_UNORM_PACK32: return "A2R10G10B10_UNORM_PACK32";
248 case VK_FORMAT_B4G4R4A4_UNORM_PACK16: return "B4G4R4A4_UNORM_PACK16";
249 case VK_FORMAT_R4G4B4A4_UNORM_PACK16: return "R4G4B4A4_UNORM_PACK16";
250 case VK_FORMAT_R32G32B32A32_SFLOAT: return "R32G32B32A32_SFLOAT";
251 case VK_FORMAT_R8G8B8A8_SRGB: return "R8G8B8A8_SRGB";
252 case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return "ETC2_R8G8B8_UNORM_BLOCK";
253 case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return "BC1_RGB_UNORM_BLOCK";
254 case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return "BC1_RGBA_UNORM_BLOCK";
255 case VK_FORMAT_R16_UNORM: return "R16_UNORM";
256 case VK_FORMAT_R16G16_UNORM: return "R16G16_UNORM";
257 case VK_FORMAT_R16G16B16A16_UNORM: return "R16G16B16A16_UNORM";
258 case VK_FORMAT_R16G16_SFLOAT: return "R16G16_SFLOAT";
259 case VK_FORMAT_S8_UINT: return "S8_UINT";
260 case VK_FORMAT_D24_UNORM_S8_UINT: return "D24_UNORM_S8_UINT";
261 case VK_FORMAT_D32_SFLOAT_S8_UINT: return "D32_SFLOAT_S8_UINT";
262
263 default: return "Unknown";
264 }
265}
@ VK_FORMAT_R32G32B32A32_SFLOAT

Variable Documentation

◆ kBlendCoeffCnt

const int skgpu::kBlendCoeffCnt = static_cast<int>(BlendCoeff::kLast) + 1
static

Definition at line 101 of file Blend.h.

◆ kBlendEquationCnt

const int skgpu::kBlendEquationCnt = static_cast<int>(BlendEquation::kLast) + 1
static

Definition at line 55 of file Blend.h.

◆ kContextTypeCount

const int skgpu::kContextTypeCount = (int)ContextType::kLastContextType + 1
static

Definition at line 42 of file ContextType.h.

◆ kDiffBit

constexpr uint32_t skgpu::kDiffBit = 0x2
constexpr

Definition at line 34 of file DataUtils.cpp.

◆ kETC1ModifierTables

const int skgpu::kETC1ModifierTables[kNumETC1ModifierTables][kNumETC1PixelIndices]
static
Initial value:
= {
{ 2, 8, -2, -8 },
{ 5, 17, -5, -17 },
{ 9, 29, -9, -29 },
{ 13, 42, -13, -42 },
{ 18, 60, -18, -60 },
{ 24, 80, -24, -80 },
{ 33, 106, -33, -106 },
{ 47, 183, -47, -183 }
}

Definition at line 46 of file DataUtils.cpp.

46 {
47 /* 0 */ { 2, 8, -2, -8 },
48 /* 1 */ { 5, 17, -5, -17 },
49 /* 2 */ { 9, 29, -9, -29 },
50 /* 3 */ { 13, 42, -13, -42 },
51 /* 4 */ { 18, 60, -18, -60 },
52 /* 5 */ { 24, 80, -24, -80 },
53 /* 6 */ { 33, 106, -33, -106 },
54 /* 7 */ { 47, 183, -47, -183 }
55};

◆ kIsDebug

constexpr int skgpu::kIsDebug = 0
constexpr

Definition at line 261 of file VulkanInterface.cpp.

◆ kMaskFormatCount

const int skgpu::kMaskFormatCount = static_cast<int>(MaskFormat::kLast) + 1
static

Definition at line 105 of file AtlasTypes.h.

◆ kMaxBlurSamples

constexpr int skgpu::kMaxBlurSamples = 28
staticconstexpr

Definition at line 52 of file BlurUtils.h.

◆ kMaxLinearBlurSigma

constexpr float skgpu::kMaxLinearBlurSigma = 4.f
staticconstexpr

Definition at line 58 of file BlurUtils.h.

◆ kNumETC1ModifierTables

const int skgpu::kNumETC1ModifierTables = 8
static

Definition at line 41 of file DataUtils.cpp.

◆ kNumETC1PixelIndices

const int skgpu::kNumETC1PixelIndices = 4
static

Definition at line 42 of file DataUtils.cpp.