Flutter Engine
The Flutter Engine
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  ThreadSafe : bool { kNo = false , kYes = true }
 
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)
 
SkBitmap CreateIntegralTable (int width)
 
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)
 
const SkRuntimeEffectGetBlur2DEffect (const SkISize &radii)
 
const SkRuntimeEffectGetLinearBlur1DEffect (int radius)
 
void Compute2DBlurKernel (SkSize sigma, SkISize radius, SkSpan< float > kernel)
 
void Compute2DBlurKernel (SkSize sigma, SkISize radius, std::array< SkV4, kMaxBlurSamples/4 > &kernel)
 
void Compute1DBlurKernel (float sigma, int radius, SkSpan< float > kernel)
 
void Compute2DBlurOffsets (SkISize radius, std::array< SkV4, kMaxBlurSamples/2 > &offsets)
 
void Compute1DBlurLinearKernel (float sigma, int radius, std::array< SkV4, kMaxBlurSamples/2 > &offsetsAndKernel)
 
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 SkSLToHLSL (const SkSL::ShaderCaps *caps, const std::string &sksl, SkSL::ProgramKind programKind, const SkSL::ProgramSettings &settings, std::string *hlsl, SkSL::ProgramInterface *outInterface, ShaderErrorHandler *errorHandler)
 
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 = SkShaderBlurAlgorithm::kMaxSamples
 
static constexpr float kMaxLinearBlurSigma = SkShaderBlurAlgorithm::kMaxLinearSigma
 
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 19 of file VulkanMemory.cpp.

◆ PlotList

Definition at line 538 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 32 of file VulkanTypes.h.

◆ VulkanDeviceLostContext

Definition at line 121 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 122 of file VulkanTypes.h.

◆ VulkanGetProc

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

Definition at line 26 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
80 kLast = kIllegal,
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,
34 kOverlay,
35 kDarken,
36 kLighten,
37 kColorDodge,
38 kColorBurn,
39 kHardLight,
40 kSoftLight,
41 kDifference,
42 kExclusion,
43 kMultiply,
44 kHSLHue,
48
50
51 kFirstAdvanced = kScreen,
52 kLast = kIllegal,
53};
@ kAdd
Definition: embedder.h:990

◆ 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};

◆ ThreadSafe

enum class skgpu::ThreadSafe : bool
strong
Enumerator
kNo 
kYes 

Definition at line 25 of file VulkanAMDMemoryAllocator.h.

25 : bool {
26 kNo = false,
27 kYes = true,
28};

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 120 of file BlurUtils.cpp.

125 {
126 float x = firstX;
127 for (int i = 0; i < numSteps; ++i, x += 1.0f) {
128 if (x < -circleR || x > circleR) {
129 results[i] = 0;
130 continue;
131 }
132 float y = sqrtf(circleR * circleR - x * x);
133 // In the column at x we exit the circle at +y and -y
134 // The summed table entry j is actually reflects an offset of j + 0.5.
135 y -= 0.5f;
136 int yInt = SkScalarFloorToInt(y);
137 SkASSERT(yInt >= -1);
138 if (y < 0) {
139 results[i] = (y + 0.5f) * summedHalfKernelTable[0];
140 } else if (yInt >= halfKernelSize - 1) {
141 results[i] = 0.5f;
142 } else {
143 float yFrac = y - yInt;
144 results[i] = (1.0f - yFrac) * summedHalfKernelTable[yInt] +
145 yFrac * summedHalfKernelTable[yInt + 1];
146 }
147 }
148}
#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)
@ kExclusion
rc = s + d - two(s*d), ra = kSrcOver
@ kSaturation
saturation of source with hue and luminosity of destination
@ kColorBurn
darken destination to reflect source
@ kPlus
r = min(s + d, 1)
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kHue
hue of source with saturation and luminosity of destination
@ kDstIn
r = d * sa
@ kModulate
r = s*d
@ kMultiply
r = s*(1-da) + d*(1-sa) + s*d
@ kColorDodge
brighten destination to reflect source
@ kScreen
r = s + d - 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
@ 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
@ 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
@ kHardLight
multiply or screen, depending on source
@ kDstOut
r = d * (1-sa)
@ kDarken
rc = s + d - max(s*da, d*sa), ra = kSrcOver
@ kSrcIn
r = s * da
@ kClear
r = 0
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 mode
Definition: switches.h:228

◆ 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 30 of file BlurUtils.h.

30 {
32}
static constexpr bool IsEffectivelyIdentity(float sigma)
Definition: SkBlurEngine.h:63

◆ BlurKernelWidth()

constexpr int skgpu::BlurKernelWidth ( int  radius)
constexpr

Definition at line 26 of file BlurUtils.h.

26{ return SkShaderBlurAlgorithm::KernelWidth(radius); }
static constexpr int KernelWidth(int radius)
Definition: SkBlurEngine.h:154

◆ BlurLinearKernelWidth()

constexpr int skgpu::BlurLinearKernelWidth ( int  radius)
constexpr

Definition at line 27 of file BlurUtils.h.

27 {
29}
static constexpr int LinearKernelWidth(int radius)
Definition: SkBlurEngine.h:158

◆ BlurSigmaRadius()

int skgpu::BlurSigmaRadius ( float  sigma)
inline

Definition at line 33 of file BlurUtils.h.

33{ return SkBlurEngine::SigmaToRadius(sigma); }
static int SigmaToRadius(float sigma)
Definition: SkBlurEngine.h:67

◆ 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}
GLenum type
SkISize CompressedDimensionsInBlocks(SkTextureCompressionType type, SkISize baseDimensions)
Definition: DataUtils.cpp:210
Definition: SkSize.h:16
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)
Definition: DataUtils.cpp:121
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 56 of file BlurUtils.h.

56 {
57 SkShaderBlurAlgorithm::Compute1DBlurKernel(sigma, radius, kernel);
58}
static void Compute1DBlurKernel(float sigma, int radius, SkSpan< float > kernel)
Definition: SkBlurEngine.h:235

◆ Compute1DBlurLinearKernel()

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

Definition at line 64 of file BlurUtils.h.

66 {
67 SkShaderBlurAlgorithm::Compute1DBlurLinearKernel(sigma, radius, offsetsAndKernel);
68}
static void Compute1DBlurLinearKernel(float sigma, int radius, std::array< SkV4, kMaxSamples/2 > &offsetsAndKernel)

◆ Compute2DBlurKernel() [1/2]

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

Definition at line 46 of file BlurUtils.h.

46 {
47 SkShaderBlurAlgorithm::Compute2DBlurKernel(sigma, radius, kernel);
48}
static void Compute2DBlurKernel(SkSize sigma, SkISize radius, SkSpan< float > kernel)

◆ Compute2DBlurKernel() [2/2]

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

Definition at line 50 of file BlurUtils.h.

52 {
53 SkShaderBlurAlgorithm::Compute2DBlurKernel(sigma, radius, kernel);
54}

◆ Compute2DBlurOffsets()

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

Definition at line 60 of file BlurUtils.h.

60 {
62}
static void Compute2DBlurOffsets(SkISize radius, std::array< SkV4, kMaxSamples/2 > &offsets)
list offsets
Definition: mskp_parser.py:37

◆ ComputeIntegralTableWidth()

int skgpu::ComputeIntegralTableWidth ( float  sixSigma)

Definition at line 62 of file BlurUtils.cpp.

62 {
63 // Check for NaN/infinity
64 if (!SkIsFinite(sixSigma)) {
65 return 0;
66 }
67 // Avoid overflow, covers both multiplying by 2 and finding next power of 2:
68 // 2*((2^31-1)/4 + 1) = 2*(2^29-1) + 2 = 2^30 and SkNextPow2(2^30) = 2^30
69 if (sixSigma > SK_MaxS32 / 4 + 1) {
70 return 0;
71 }
72 // The texture we're producing represents the integral of a normal distribution over a
73 // six-sigma range centered at zero. We want enough resolution so that the linear
74 // interpolation done in texture lookup doesn't introduce noticeable artifacts. We
75 // conservatively choose to have 2 texels for each dst pixel.
76 int minWidth = 2 * ((int)std::ceil(sixSigma));
77 // Bin by powers of 2 with a minimum so we get good profile reuse.
78 return std::max(SkNextPow2(minWidth), 32);
79}
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
static float max(float r, float g, float b)
Definition: hsl.cpp:49
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition: SkVx.h:702

◆ ContextTypeName()

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

Definition at line 13 of file ContextType.cpp.

13 {
14 switch (type) {
16 return "OpenGL";
18 return "OpenGLES";
20 return "ANGLE D3D9 ES2";
22 return "ANGLE D3D11 ES2";
24 return "ANGLE D3D11 ES3";
26 return "ANGLE GL ES2";
28 return "ANGLE GL ES3";
30 return "ANGLE Metal ES2";
32 return "ANGLE Metal ES3";
34 return "Vulkan";
36 return "Metal";
38 return "Direct3D";
40 return "Dawn D3D11";
42 return "Dawn D3D12";
44 return "Dawn Metal";
46 return "Dawn Vulkan";
48 return "Dawn OpenGL";
50 return "Dawn OpenGLES";
52 return "Mock";
53 }
55}
@ kVulkan
ANGLE on Metal ES 3 context.
@ kMock
Dawn on OpenGL ES.

◆ 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)
uint16_t fColor0
Definition: DataUtils.cpp:133
uint32_t fIndices
Definition: DataUtils.cpp:135
uint16_t fColor1
Definition: DataUtils.cpp:134

◆ 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
uint32_t fHigh
Definition: DataUtils.cpp:30

◆ CreateCircleProfile()

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

Definition at line 188 of file BlurUtils.cpp.

188 {
190 if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(profileWidth, 1))) {
191 return bitmap;
192 }
193
194 uint8_t* profile = bitmap.getAddr8(0, 0);
195
196 const int numSteps = profileWidth;
197
198 // The full kernel is 6 sigmas wide.
199 int halfKernelSize = SkScalarCeilToInt(6.0f * sigma);
200 // Round up to next multiple of 2 and then divide by 2.
201 halfKernelSize = ((halfKernelSize + 1) & ~1) >> 1;
202
203 // Number of x steps at which to apply kernel in y to cover all the profile samples in x.
204 const int numYSteps = numSteps + 2 * halfKernelSize;
205
206 skia_private::AutoTArray<float> bulkAlloc(halfKernelSize + halfKernelSize + numYSteps);
207 float* halfKernel = bulkAlloc.get();
208 float* summedKernel = bulkAlloc.get() + halfKernelSize;
209 float* yEvals = bulkAlloc.get() + 2 * halfKernelSize;
210 make_half_kernel_and_summed_table(halfKernel, summedKernel, halfKernelSize, sigma);
211
212 float firstX = -halfKernelSize + 0.5f;
213 apply_kernel_in_y(yEvals, numYSteps, firstX, radius, halfKernelSize, summedKernel);
214
215 for (int i = 0; i < numSteps - 1; ++i) {
216 float evalX = i + 0.5f;
217 profile[i] = eval_at(evalX, radius, halfKernel, halfKernelSize, yEvals + i);
218 }
219 // Ensure the tail of the Gaussian goes to zero.
220 profile[numSteps - 1] = 0;
221
222 bitmap.setImmutable();
223 return bitmap;
224}
#define SkScalarCeilToInt(x)
Definition: SkScalar.h:36
Definition: bitmap.py:1
static uint8_t eval_at(float evalX, float circleR, const float *halfKernel, int halfKernelSize, const float *yKernelEvaluations)
Definition: BlurUtils.cpp:154
static void apply_kernel_in_y(float *results, int numSteps, float firstX, float circleR, int halfKernelSize, const float *summedHalfKernelTable)
Definition: BlurUtils.cpp:120
static void make_half_kernel_and_summed_table(float *halfKernel, float *summedHalfKernel, int halfKernelSize, float sigma)
Definition: BlurUtils.cpp:104
static SkImageInfo MakeA8(int width, int height)

◆ CreateHalfPlaneProfile()

SkBitmap skgpu::CreateHalfPlaneProfile ( int  profileWidth)

Definition at line 226 of file BlurUtils.cpp.

226 {
227 SkASSERT(!(profileWidth & 0x1));
228
230 if (!bitmap.tryAllocPixels(SkImageInfo::MakeA8(profileWidth, 1))) {
231 return bitmap;
232 }
233
234 uint8_t* profile = bitmap.getAddr8(0, 0);
235
236 // The full kernel is 6 sigmas wide.
237 const float sigma = profileWidth / 6.0f;
238 const int halfKernelSize = profileWidth / 2;
239
240 skia_private::AutoTArray<float> halfKernel(halfKernelSize);
241
242 // The half kernel should sum to 0.5.
243 const float tot = 2.0f * make_unnormalized_half_kernel(halfKernel.get(), halfKernelSize, sigma);
244 float sum = 0.0f;
245 // Populate the profile from the right edge to the middle.
246 for (int i = 0; i < halfKernelSize; ++i) {
247 halfKernel[halfKernelSize - i - 1] /= tot;
248 sum += halfKernel[halfKernelSize - i - 1];
249 profile[profileWidth - i - 1] = SkUnitScalarClampToByte(sum);
250 }
251 // Populate the profile from the middle to the left edge (by flipping the half kernel and
252 // continuing the summation).
253 for (int i = 0; i < halfKernelSize; ++i) {
254 sum += halfKernel[i];
255 profile[halfKernelSize - i - 1] = SkUnitScalarClampToByte(sum);
256 }
257 // Ensure the tail of the Gaussian goes to zero.
258 profile[profileWidth - 1] = 0;
259
260 bitmap.setImmutable();
261 return bitmap;
262}
static U8CPU SkUnitScalarClampToByte(SkScalar x)
Definition: SkColorPriv.h:36
static float make_unnormalized_half_kernel(float *halfKernel, int halfKernelSize, float sigma)
Definition: BlurUtils.cpp:87

◆ CreateIntegralTable()

SkBitmap skgpu::CreateIntegralTable ( int  width)

Definition at line 38 of file BlurUtils.cpp.

38 {
40
41 if (width <= 0) {
42 return table;
43 }
44
45 if (!table.tryAllocPixels(SkImageInfo::MakeA8(width, 1))) {
46 return table;
47 }
48 *table.getAddr8(0, 0) = 255;
49 const float invWidth = 1.f / width;
50 for (int i = 1; i < width - 1; ++i) {
51 float x = (i + 0.5f) * invWidth;
52 x = (-6 * x + 3) * SK_ScalarRoot2Over2;
53 float integral = 0.5f * (std::erf(x) + 1.f);
54 *table.getAddr8(i, 0) = SkToU8(sk_float_round2int(255.f * integral));
55 }
56
57 *table.getAddr8(width - 1, 0) = 0;
58 table.setImmutable();
59 return table;
60}
#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)

◆ CreateRRectBlurMask()

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

Definition at line 316 of file BlurUtils.cpp.

316 {
318 int radius = skgpu::BlurSigmaRadius(sigma);
319 int kernelSize = skgpu::BlurKernelWidth(radius);
320
321 SkASSERT(kernelSize % 2);
322 SkASSERT(dimensions.width() % 2);
323 SkASSERT(dimensions.height() % 2);
324
325 SkVector radii = rrectToDraw.getSimpleRadii();
326 SkASSERT(SkScalarNearlyEqual(radii.fX, radii.fY));
327
328 const int halfWidthPlus1 = (dimensions.width() / 2) + 1;
329 const int halfHeightPlus1 = (dimensions.height() / 2) + 1;
330
331 std::unique_ptr<float[]> kernel(new float[kernelSize]);
332 skgpu::Compute1DBlurKernel(sigma, radius, SkSpan<float>(kernel.get(), kernelSize));
333
334 const int tableWidth = ComputeIntegralTableWidth(6.0f * sigma);
335 SkBitmap integral = CreateIntegralTable(tableWidth);
336 if (integral.empty()) {
337 return {};
338 }
339
341 if (!result.tryAllocPixels(SkImageInfo::MakeA8(dimensions.width(), dimensions.height()))) {
342 return {};
343 }
344
345 std::vector<float> topVec;
346 topVec.reserve(dimensions.width());
347 for (int x = 0; x < dimensions.width(); ++x) {
348 if (x < rrectToDraw.rect().fLeft || x > rrectToDraw.rect().fRight) {
349 topVec.push_back(-1);
350 } else {
351 if (x + 0.5f < rrectToDraw.rect().fLeft + radii.fX) { // in the circular section
352 float xDist = rrectToDraw.rect().fLeft + radii.fX - x - 0.5f;
353 float h = sqrtf(radii.fX * radii.fX - xDist * xDist);
354 SkASSERT(0 <= h && h < radii.fY);
355 topVec.push_back(rrectToDraw.rect().fTop + radii.fX - h + 3 * sigma);
356 } else {
357 topVec.push_back(rrectToDraw.rect().fTop + 3 * sigma);
358 }
359 }
360 }
361
362 for (int y = 0; y < halfHeightPlus1; ++y) {
363 uint8_t* scanline = result.getAddr8(0, y);
364
365 for (int x = 0; x < halfWidthPlus1; ++x) {
366 scanline[x] = eval_H(x,
367 y,
368 topVec,
369 kernel.get(),
370 kernelSize,
371 integral.getAddr8(0, 0),
372 integral.width(),
373 6.0f * sigma);
374 scanline[dimensions.width() - x - 1] = scanline[x];
375 }
376
377 memcpy(result.getAddr8(0, dimensions.height() - y - 1), scanline, result.rowBytes());
378 }
379
380 result.setImmutable();
381 return result;
382}
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
constexpr bool BlurIsEffectivelyIdentity(float sigma)
Definition: BlurUtils.h:30
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)
Definition: BlurUtils.cpp:291
int ComputeIntegralTableWidth(float sixSigma)
Definition: BlurUtils.cpp:62
void Compute1DBlurKernel(float sigma, int radius, SkSpan< float > kernel)
Definition: BlurUtils.h:56
int BlurSigmaRadius(float sigma)
Definition: BlurUtils.h:33
constexpr int BlurKernelWidth(int radius)
Definition: BlurUtils.h:26
SkBitmap CreateIntegralTable(int width)
Definition: BlurUtils.cpp:38
SkScalar h
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
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 {
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 154 of file BlurUtils.cpp.

158 {
159 float acc = 0;
160
161 float x = evalX - halfKernelSize;
162 for (int i = 0; i < halfKernelSize; ++i, x += 1.0f) {
163 if (x < -circleR || x > circleR) {
164 continue;
165 }
166 float verticalEval = yKernelEvaluations[i];
167 acc += verticalEval * halfKernel[halfKernelSize - i - 1];
168 }
169 for (int i = 0; i < halfKernelSize; ++i, x += 1.0f) {
170 if (x < -circleR || x > circleR) {
171 continue;
172 }
173 float verticalEval = yKernelEvaluations[i + halfKernelSize];
174 acc += verticalEval * halfKernel[i];
175 }
176 // Since we applied a half kernel in y we multiply acc by 2 (the circle is symmetric about
177 // the x axis).
178 return SkUnitScalarClampToByte(2.0f * acc);
179}

◆ 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 291 of file BlurUtils.cpp.

298 {
299 SkASSERT(0 <= x && x < (int)topVec.size());
300 SkASSERT(kernelSize % 2);
301
302 float accum = 0.0f;
303
304 int xSampleLoc = x - (kernelSize / 2);
305 for (int i = 0; i < kernelSize; ++i, ++xSampleLoc) {
306 if (xSampleLoc < 0 || xSampleLoc >= (int)topVec.size()) {
307 continue;
308 }
309
310 accum += kernel[i] * eval_V(topVec[xSampleLoc], y, integral, integralSize, sixSigma);
311 }
312
313 return accum + 0.5f;
314}
static uint8_t eval_V(float top, int y, const uint8_t *integral, int integralSize, float sixSigma)
Definition: BlurUtils.cpp:270

◆ eval_V()

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

Definition at line 270 of file BlurUtils.cpp.

270 {
271 if (top < 0) {
272 return 0; // an empty column
273 }
274
275 float fT = (top - y - 0.5f) * (integralSize / sixSigma);
276 if (fT < 0) {
277 return 255;
278 } else if (fT >= integralSize - 1) {
279 return 0;
280 }
281
282 int lower = (int)fT;
283 float frac = fT - lower;
284
285 SkASSERT(lower + 1 < integralSize);
286
287 return integral[lower] * (1.0f - frac) + integral[lower + 1] * frac;
288}

◆ 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}
uint32_t SkColor
Definition: SkColor.h:37
static void create_BC1_block(BC1Block *block, bool transparent)
DlColor color
static int num_ETC1_blocks(int w, int h)
Definition: DataUtils.cpp:125
dest
Definition: zip.py:79

◆ 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
Definition: SkTraceEvent.h:30
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition: SkMipmap.cpp:134
static void fillin_ETC1_with_color(SkISize dimensions, const SkColor4f &colorf, char *dest)
Definition: DataUtils.cpp:228
static void fillin_BC1_with_color(SkISize dimensions, const SkColor4f &colorf, char *dest)
Definition: DataUtils.cpp:243
SeparatedVector2 offset
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ find_info()

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

Definition at line 21 of file VulkanExtensions.cpp.

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

◆ 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" equivalent
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)
inline

Definition at line 38 of file BlurUtils.h.

38 {
40}
static const SkRuntimeEffect * GetBlur2DEffect(const SkISize &radii)

◆ 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 216 of file VulkanUtilsPriv.h.

217 {
218 // All Vulkan structs that could be part of the features chain will start with the
219 // structure type followed by the pNext pointer. We cast to the CommonVulkanHeader
220 // so we can get access to the pNext for the next struct.
221 struct CommonVulkanHeader {
222 VkStructureType sType;
223 void* pNext;
224 };
225
226 void* pNext = features.pNext;
227 while (pNext) {
228 CommonVulkanHeader* header = static_cast<CommonVulkanHeader*>(pNext);
229 if (header->sType == type) {
230 return static_cast<T*>(pNext);
231 }
232 pNext = header->pNext;
233 }
234 return nullptr;
235}
#define T
Definition: precompiler.cc:65
static const char header[]
Definition: skpbench.cpp:88
VkStructureType
Definition: vulkan_core.h:201

◆ 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)
inline

Definition at line 42 of file BlurUtils.h.

42 {
44}
static const SkRuntimeEffect * GetLinearBlur1DEffect(int radius)

◆ 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);
72 case SkBlendMode::kSrcOver: return SkSpan(kSrcOver);
73 case SkBlendMode::kDstOver: return SkSpan(kDstOver);
74 case SkBlendMode::kSrcIn: return SkSpan(kSrcIn);
75 case SkBlendMode::kDstIn: return SkSpan(kDstIn);
76 case SkBlendMode::kSrcOut: return SkSpan(kSrcOut);
77 case SkBlendMode::kDstOut: return SkSpan(kDstOut);
78 case SkBlendMode::kSrcATop: return SkSpan(kSrcATop);
79 case SkBlendMode::kDstATop: return SkSpan(kDstATop);
80 case SkBlendMode::kXor: return SkSpan(kXor);
81 case SkBlendMode::kPlus: return SkSpan(kPlus);
82 default: return {};
83 }
84}
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
@ kSrcOut
r = s * (1-da)
@ kPlus
r = min(s + d, 1)
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
@ kDstOut
r = d * (1-sa)

◆ 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
Definition: CanvasTest.cpp:265
@ kLighten
rc = s + d - min(s*da, d*sa), ra = kSrcOver
@ kLuminosity
luminosity of source with hue and saturation of destination
@ 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
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 210 of file VulkanUtilsPriv.cpp.

214 {
215 if (!deviceLostProc) {
216 return;
217 }
218
219 std::vector<VkDeviceFaultAddressInfoEXT> addressInfos = {};
220 std::vector<VkDeviceFaultVendorInfoEXT> vendorInfos = {};
221 std::vector<std::byte> vendorBinaryData = {};
222
223 if (!supportsDeviceFaultInfoExtension) {
224 deviceLostProc(deviceLostContext,
225 "No details: VK_EXT_device_fault not available/enabled.",
226 addressInfos,
227 vendorInfos,
228 vendorBinaryData);
229 return;
230 }
231
232 // Query counts
233 VkDeviceFaultCountsEXT faultCounts = {};
235 VkResult result = SHARED_GR_VULKAN_CALL(vulkanInterface,
236 GetDeviceFaultInfo(vkDevice, &faultCounts, NULL));
237 if (result != VK_SUCCESS) {
238 deviceLostProc(
239 deviceLostContext,
240 "No details: VK_EXT_device_fault error counting failed: " + std::to_string(result),
241 addressInfos,
242 vendorInfos,
243 vendorBinaryData);
244 return;
245 }
246
247 // Prepare storage
248 addressInfos.resize(faultCounts.addressInfoCount);
249 vendorInfos.resize(faultCounts.vendorInfoCount);
250 vendorBinaryData.resize(faultCounts.vendorBinarySize);
251
252 // Query fault info
253 VkDeviceFaultInfoEXT faultInfo = {};
255 faultInfo.pAddressInfos = addressInfos.data();
256 faultInfo.pVendorInfos = vendorInfos.data();
257 faultInfo.pVendorBinaryData =
258 faultCounts.vendorBinarySize > 0 ? vendorBinaryData.data() : nullptr;
259 result = SHARED_GR_VULKAN_CALL(vulkanInterface,
260 GetDeviceFaultInfo(vkDevice, &faultCounts, &faultInfo));
261 if (result != VK_SUCCESS) {
262 deviceLostProc(
263 deviceLostContext,
264 "No details: VK_EXT_device_fault info dumping failed: " + std::to_string(result),
265 addressInfos,
266 vendorInfos,
267 vendorBinaryData);
268 return;
269 }
270
271 deviceLostProc(deviceLostContext,
272 std::string(faultInfo.description),
273 addressInfos,
274 vendorInfos,
275 vendorBinaryData);
276}
#define SHARED_GR_VULKAN_CALL(IFACE, X)
static SkString to_string(int n)
Definition: nanobench.cpp:119
VkStructureType sType
VkDeviceSize vendorBinarySize
VkStructureType sType
char description[VK_MAX_DESCRIPTION_SIZE]
VkDeviceFaultAddressInfoEXT * pAddressInfos
VkDeviceFaultVendorInfoEXT * pVendorInfos
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
@ VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT
Definition: vulkan_core.h:960
@ VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT
Definition: vulkan_core.h:959

◆ 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:
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 104 of file BlurUtils.cpp.

107 {
108 // The half kernel should sum to 0.5 not 1.0.
109 const float tot = 2.0f * make_unnormalized_half_kernel(halfKernel, halfKernelSize, sigma);
110 float sum = 0.0f;
111 for (int i = 0; i < halfKernelSize; ++i) {
112 halfKernel[i] /= tot;
113 sum += halfKernel[i];
114 summedHalfKernel[i] = sum;
115 }
116}

◆ make_unnormalized_half_kernel()

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

Definition at line 87 of file BlurUtils.cpp.

87 {
88 const float invSigma = 1.0f / sigma;
89 const float b = -0.5f * invSigma * invSigma;
90 float tot = 0.0f;
91 // Compute half kernel values at half pixel steps out from the center.
92 float t = 0.5f;
93 for (int i = 0; i < halfKernelSize; ++i) {
94 float value = expf(t * t * b);
95 tot += value;
96 halfKernel[i] = value;
97 t += 1.0f;
98 }
99 return tot;
100}

◆ 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
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ 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
static const int kMaskFormatCount
Definition: AtlasTypes.h:105

◆ 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 130 of file MtlUtils.mm.

130 {
131 switch (mtlFormat) {
132 case MTLPixelFormatInvalid: return 0;
133 case MTLPixelFormatRGBA8Unorm: return 4;
134 case MTLPixelFormatR8Unorm: return 1;
135 case MTLPixelFormatA8Unorm: return 1;
136 case MTLPixelFormatBGRA8Unorm: return 4;
137 case MTLPixelFormatB5G6R5Unorm: return 2;
138 case MTLPixelFormatRGBA16Float: return 8;
139 case MTLPixelFormatR16Float: return 2;
140 case MTLPixelFormatRG8Unorm: return 2;
141 case MTLPixelFormatRGB10A2Unorm: return 4;
142 case MTLPixelFormatBGR10A2Unorm: return 4;
143 case MTLPixelFormatABGR4Unorm: return 2;
144 case MTLPixelFormatRGBA8Unorm_sRGB: return 4;
145 case MTLPixelFormatR16Unorm: return 2;
146 case MTLPixelFormatRG16Unorm: return 4;
147 case MTLPixelFormatETC2_RGB8: return 8;
148#ifdef SK_BUILD_FOR_MAC
149 case MTLPixelFormatBC1_RGBA: return 8;
150#endif
151 case MTLPixelFormatRGBA16Unorm: return 8;
152 case MTLPixelFormatRG16Float: return 4;
153 case MTLPixelFormatStencil8: return 1;
154
155 default: return 0;
156 }
157}

◆ MtlFormatChannels()

uint32_t skgpu::MtlFormatChannels ( MTLPixelFormat  mtlFormat)

Definition at line 102 of file MtlUtils.mm.

102 {
103 switch (mtlFormat) {
104 case MTLPixelFormatRGBA8Unorm: return kRGBA_SkColorChannelFlags;
105 case MTLPixelFormatR8Unorm: return kRed_SkColorChannelFlag;
106 case MTLPixelFormatA8Unorm: return kAlpha_SkColorChannelFlag;
107 case MTLPixelFormatBGRA8Unorm: return kRGBA_SkColorChannelFlags;
108 case MTLPixelFormatB5G6R5Unorm: return kRGB_SkColorChannelFlags;
109 case MTLPixelFormatRGBA16Float: return kRGBA_SkColorChannelFlags;
110 case MTLPixelFormatR16Float: return kRed_SkColorChannelFlag;
111 case MTLPixelFormatRG8Unorm: return kRG_SkColorChannelFlags;
112 case MTLPixelFormatRGB10A2Unorm: return kRGBA_SkColorChannelFlags;
113 case MTLPixelFormatBGR10A2Unorm: return kRGBA_SkColorChannelFlags;
114 case MTLPixelFormatABGR4Unorm: return kRGBA_SkColorChannelFlags;
115 case MTLPixelFormatRGBA8Unorm_sRGB: return kRGBA_SkColorChannelFlags;
116 case MTLPixelFormatR16Unorm: return kRed_SkColorChannelFlag;
117 case MTLPixelFormatRG16Unorm: return kRG_SkColorChannelFlags;
118 case MTLPixelFormatETC2_RGB8: return kRGB_SkColorChannelFlags;
119#ifdef SK_BUILD_FOR_MAC
120 case MTLPixelFormatBC1_RGBA: return kRGBA_SkColorChannelFlags;
121#endif
122 case MTLPixelFormatRGBA16Unorm: return kRGBA_SkColorChannelFlags;
123 case MTLPixelFormatRG16Float: return kRG_SkColorChannelFlags;
124 case MTLPixelFormatStencil8: return 0;
125
126 default: return 0;
127 }
128}
@ 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 60 of file MtlUtils.mm.

60 {
61 switch (mtlFormat) {
62 case MTLPixelFormatETC2_RGB8:
63 return true;
64#ifdef SK_BUILD_FOR_MAC
65 case MTLPixelFormatBC1_RGBA:
66 return true;
67#endif
68 default:
69 return false;
70 }
71}

◆ MtlFormatIsDepth()

bool skgpu::MtlFormatIsDepth ( MTLPixelFormat  format)

Definition at line 33 of file MtlUtils.mm.

33 {
34 switch (format) {
35 case MTLPixelFormatDepth16Unorm:
36 case MTLPixelFormatDepth32Float:
37#if defined(SK_BUILD_FOR_MAC)
38 case MTLPixelFormatDepth24Unorm_Stencil8:
39#endif
40 case MTLPixelFormatDepth32Float_Stencil8:
41 return true;
42 default:
43 return false;
44 }
45}

◆ MtlFormatIsDepthOrStencil()

bool skgpu::MtlFormatIsDepthOrStencil ( MTLPixelFormat  format)

Definition at line 18 of file MtlUtils.mm.

18 {
19 switch (format) {
20 case MTLPixelFormatStencil8: // fallthrough
21 case MTLPixelFormatDepth16Unorm:
22 case MTLPixelFormatDepth32Float:
23#if defined(SK_BUILD_FOR_MAC)
24 case MTLPixelFormatDepth24Unorm_Stencil8:
25#endif
26 case MTLPixelFormatDepth32Float_Stencil8:
27 return true;
28 default:
29 return false;
30 }
31}

◆ MtlFormatIsStencil()

bool skgpu::MtlFormatIsStencil ( MTLPixelFormat  format)

Definition at line 47 of file MtlUtils.mm.

47 {
48 switch (format) {
49 case MTLPixelFormatStencil8: // fallthrough
50#if defined(SK_BUILD_FOR_MAC)
51 case MTLPixelFormatDepth24Unorm_Stencil8:
52#endif
53 case MTLPixelFormatDepth32Float_Stencil8:
54 return true;
55 default:
56 return false;
57 }
58}

◆ MtlFormatToCompressionType()

SkTextureCompressionType skgpu::MtlFormatToCompressionType ( MTLPixelFormat  mtlFormat)

Definition at line 159 of file MtlUtils.mm.

159 {
160 switch (mtlFormat) {
161 case MTLPixelFormatETC2_RGB8: return SkTextureCompressionType::kETC2_RGB8_UNORM;
162#ifdef SK_BUILD_FOR_MAC
163 case MTLPixelFormatBC1_RGBA: return SkTextureCompressionType::kBC1_RGBA8_UNORM;
164#endif
165 default: return SkTextureCompressionType::kNone;
166 }
167}

◆ MtlFormatToString()

const char * skgpu::MtlFormatToString ( MTLPixelFormat  mtlFormat)

Definition at line 73 of file MtlUtils.mm.

73 {
74 switch (mtlFormat) {
75 case MTLPixelFormatInvalid: return "Invalid";
76 case MTLPixelFormatRGBA8Unorm: return "RGBA8Unorm";
77 case MTLPixelFormatR8Unorm: return "R8Unorm";
78 case MTLPixelFormatA8Unorm: return "A8Unorm";
79 case MTLPixelFormatBGRA8Unorm: return "BGRA8Unorm";
80 case MTLPixelFormatB5G6R5Unorm: return "B5G6R5Unorm";
81 case MTLPixelFormatRGBA16Float: return "RGBA16Float";
82 case MTLPixelFormatR16Float: return "R16Float";
83 case MTLPixelFormatRG8Unorm: return "RG8Unorm";
84 case MTLPixelFormatRGB10A2Unorm: return "RGB10A2Unorm";
85 case MTLPixelFormatBGR10A2Unorm: return "BGR10A2Unorm";
86 case MTLPixelFormatABGR4Unorm: return "ABGR4Unorm";
87 case MTLPixelFormatRGBA8Unorm_sRGB: return "RGBA8Unorm_sRGB";
88 case MTLPixelFormatR16Unorm: return "R16Unorm";
89 case MTLPixelFormatRG16Unorm: return "RG16Unorm";
90 case MTLPixelFormatETC2_RGB8: return "ETC2_RGB8";
91#ifdef SK_BUILD_FOR_MAC
92 case MTLPixelFormatBC1_RGBA: return "BC1_RGBA";
93#endif
94 case MTLPixelFormatRGBA16Unorm: return "RGBA16Unorm";
95 case MTLPixelFormatRG16Float: return "RG16Float";
96 case MTLPixelFormatStencil8: return "Stencil8";
97
98 default: return "Unknown";
99 }
100}

◆ 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 {
40}
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Definition: SkChecksum.cpp:113

◆ SampleCountToVkSampleCount()

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

Definition at line 174 of file VulkanUtilsPriv.h.

175 {
176 SkASSERT(samples >= 1);
177 switch (samples) {
178 case 1:
179 *vkSamples = VK_SAMPLE_COUNT_1_BIT;
180 return true;
181 case 2:
182 *vkSamples = VK_SAMPLE_COUNT_2_BIT;
183 return true;
184 case 4:
185 *vkSamples = VK_SAMPLE_COUNT_4_BIT;
186 return true;
187 case 8:
188 *vkSamples = VK_SAMPLE_COUNT_8_BIT;
189 return true;
190 case 16:
191 *vkSamples = VK_SAMPLE_COUNT_16_BIT;
192 return true;
193 default:
194 return false;
195 }
196}
@ VK_SAMPLE_COUNT_8_BIT
Definition: vulkan_core.h:2343
@ VK_SAMPLE_COUNT_2_BIT
Definition: vulkan_core.h:2341
@ VK_SAMPLE_COUNT_1_BIT
Definition: vulkan_core.h:2340
@ VK_SAMPLE_COUNT_4_BIT
Definition: vulkan_core.h:2342
@ VK_SAMPLE_COUNT_16_BIT
Definition: vulkan_core.h:2344

◆ SetupSamplerYcbcrConversionInfo()

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

Returns a populated VkSamplerYcbcrConversionCreateInfo object based on VulkanYcbcrConversionInfo

Definition at line 26 of file VulkanUtilsPriv.cpp.

27 {
28#ifdef SK_DEBUG
29 const VkFormatFeatureFlags& featureFlags = conversionInfo.fFormatFeatures;
30 if (conversionInfo.fXChromaOffset == VK_CHROMA_LOCATION_MIDPOINT ||
33 }
34 if (conversionInfo.fXChromaOffset == VK_CHROMA_LOCATION_COSITED_EVEN ||
37 }
38 if (conversionInfo.fChromaFilter == VK_FILTER_LINEAR) {
40 }
41 if (conversionInfo.fForceExplicitReconstruction) {
42 SkASSERT(featureFlags &
44 }
45#endif
46
47 VkFilter chromaFilter = conversionInfo.fChromaFilter;
49 if (!(conversionInfo.fFormatFeatures &
51 // Because we don't have have separate reconstruction filter, the min, mag and
52 // chroma filter must all match. However, we also don't support linear sampling so
53 // the min/mag filter have to be nearest. Therefore, we force the chrome filter to
54 // be nearest regardless of support for the feature
55 // VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT.
56 chromaFilter = VK_FILTER_NEAREST;
57 }
58 }
59
61 outInfo->pNext = nullptr;
62 outInfo->format = conversionInfo.fFormat;
63 outInfo->ycbcrModel = conversionInfo.fYcbcrModel;
64 outInfo->ycbcrRange = conversionInfo.fYcbcrRange;
65 outInfo->components = conversionInfo.fComponents;
66 outInfo->xChromaOffset = conversionInfo.fXChromaOffset;
67 outInfo->yChromaOffset = conversionInfo.fYChromaOffset;
68 outInfo->chromaFilter = chromaFilter;
70}
VkSamplerYcbcrModelConversion ycbcrModel
Definition: vulkan_core.h:5426
VkSamplerYcbcrRange fYcbcrRange
Definition: VulkanTypes.h:104
VkSamplerYcbcrModelConversion fYcbcrModel
Definition: VulkanTypes.h:103
VkComponentMapping fComponents
Definition: VulkanTypes.h:115
VkFormatFeatureFlags fFormatFeatures
Definition: VulkanTypes.h:112
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
Definition: vulkan_core.h:2271
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT
Definition: vulkan_core.h:2278
@ VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT
Definition: vulkan_core.h:2280
@ VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT
Definition: vulkan_core.h:2274
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT
Definition: vulkan_core.h:2275
@ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT
Definition: vulkan_core.h:2276
@ VK_CHROMA_LOCATION_COSITED_EVEN
Definition: vulkan_core.h:4968
@ VK_CHROMA_LOCATION_MIDPOINT
Definition: vulkan_core.h:4969
VkFlags VkFormatFeatureFlags
Definition: vulkan_core.h:2307
VkFilter
Definition: vulkan_core.h:2100
@ VK_FILTER_NEAREST
Definition: vulkan_core.h:2101
@ VK_FILTER_LINEAR
Definition: vulkan_core.h:2102
@ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO
Definition: vulkan_core.h:292

◆ 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)
Definition: SkShaderUtils.h:27
string programKind
Definition: minify_sksl.py:40
compiler
Definition: malisc.py:17

◆ 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)

◆ SkSLToHLSL()

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

Definition at line 85 of file GrD3DPipelineStateBuilder.h.

91 {
92 return SkSLToBackend(caps, &SkSL::ToHLSL, "HLSL",
93 sksl, programKind, settings, hlsl, outInterface, errorHandler);
94}
bool ToHLSL(Program &program, const ShaderCaps *caps, OutputStream &out)

◆ 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 41 of file VulkanUtilsPriv.h.

47 {
48 return SkSLToBackend(caps, &SkSL::ToSPIRV, /*backendLabel=*/nullptr,
49 sksl, programKind, settings, spirv, outInterface, errorHandler);
50}
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}

◆ VkFormatBytesPerBlock()

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

Definition at line 84 of file VulkanUtilsPriv.h.

84 {
85 switch (vkFormat) {
86 case VK_FORMAT_R8G8B8A8_UNORM: return 4;
87 case VK_FORMAT_R8_UNORM: return 1;
88 case VK_FORMAT_B8G8R8A8_UNORM: return 4;
89 case VK_FORMAT_R5G6B5_UNORM_PACK16: return 2;
90 case VK_FORMAT_B5G6R5_UNORM_PACK16: return 2;
91 case VK_FORMAT_R16G16B16A16_SFLOAT: return 8;
92 case VK_FORMAT_R16_SFLOAT: return 2;
93 case VK_FORMAT_R8G8B8_UNORM: return 3;
94 case VK_FORMAT_R8G8_UNORM: return 2;
99 case VK_FORMAT_R8G8B8A8_SRGB: return 4;
101 case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return 8;
102 case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return 8;
103 case VK_FORMAT_R16_UNORM: return 2;
104 case VK_FORMAT_R16G16_UNORM: return 4;
105 case VK_FORMAT_R16G16B16A16_UNORM: return 8;
106 case VK_FORMAT_R16G16_SFLOAT: return 4;
107 // Currently we are just over estimating this value to be used in gpu size calculations even
108 // though the actually size is probably less. We should instead treat planar formats similar
109 // to compressed textures that go through their own special query for calculating size.
113 case VK_FORMAT_S8_UINT: return 1;
114 case VK_FORMAT_D16_UNORM: return 2;
115 case VK_FORMAT_D32_SFLOAT: return 4;
116 case VK_FORMAT_D24_UNORM_S8_UINT: return 4;
117 case VK_FORMAT_D32_SFLOAT_S8_UINT: return 8;
118
119 default: return 0;
120 }
121}
@ VK_FORMAT_R16G16B16A16_UNORM
Definition: vulkan_core.h:1550
@ VK_FORMAT_R8G8B8A8_SRGB
Definition: vulkan_core.h:1502
@ VK_FORMAT_R8G8B8_UNORM
Definition: vulkan_core.h:1482
@ VK_FORMAT_D24_UNORM_S8_UINT
Definition: vulkan_core.h:1588
@ VK_FORMAT_D32_SFLOAT
Definition: vulkan_core.h:1585
@ VK_FORMAT_B8G8R8A8_UNORM
Definition: vulkan_core.h:1503
@ VK_FORMAT_R16G16_SFLOAT
Definition: vulkan_core.h:1542
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
Definition: vulkan_core.h:1462
@ VK_FORMAT_R16_SFLOAT
Definition: vulkan_core.h:1535
@ VK_FORMAT_R8G8_UNORM
Definition: vulkan_core.h:1475
@ VK_FORMAT_S8_UINT
Definition: vulkan_core.h:1586
@ VK_FORMAT_R8_UNORM
Definition: vulkan_core.h:1468
@ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16
Definition: vulkan_core.h:1657
@ VK_FORMAT_R5G6B5_UNORM_PACK16
Definition: vulkan_core.h:1463
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
Definition: vulkan_core.h:1461
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
Definition: vulkan_core.h:1523
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496
@ VK_FORMAT_BC1_RGB_UNORM_BLOCK
Definition: vulkan_core.h:1590
@ VK_FORMAT_R16_UNORM
Definition: vulkan_core.h:1529
@ VK_FORMAT_D16_UNORM
Definition: vulkan_core.h:1583
@ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
Definition: vulkan_core.h:1646
@ VK_FORMAT_R16G16B16A16_SFLOAT
Definition: vulkan_core.h:1556
@ VK_FORMAT_R16G16_UNORM
Definition: vulkan_core.h:1536
@ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
Definition: vulkan_core.h:1606
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32
Definition: vulkan_core.h:1517
@ VK_FORMAT_BC1_RGBA_UNORM_BLOCK
Definition: vulkan_core.h:1592
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
Definition: vulkan_core.h:1647
@ VK_FORMAT_B5G6R5_UNORM_PACK16
Definition: vulkan_core.h:1464
@ VK_FORMAT_D32_SFLOAT_S8_UINT
Definition: vulkan_core.h:1589

◆ VkFormatChannels()

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

Definition at line 52 of file VulkanUtilsPriv.h.

52 {
53 switch (vkFormat) {
75 case VK_FORMAT_S8_UINT: return 0;
76 case VK_FORMAT_D16_UNORM: return 0;
77 case VK_FORMAT_D32_SFLOAT: return 0;
78 case VK_FORMAT_D24_UNORM_S8_UINT: return 0;
79 case VK_FORMAT_D32_SFLOAT_S8_UINT: return 0;
80 default: return 0;
81 }
82}

◆ VkFormatIsCompressed()

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

Returns true if the format is compressed.

Definition at line 201 of file VulkanUtilsPriv.h.

201 {
202 switch (vkFormat) {
206 return true;
207 default:
208 return false;
209 }
211}

◆ VkFormatIsDepth()

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

Definition at line 143 of file VulkanUtilsPriv.h.

143 {
144 switch (format) {
149 return true;
150 default:
151 return false;
152 }
153}

◆ VkFormatIsStencil()

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

Definition at line 132 of file VulkanUtilsPriv.h.

132 {
133 switch (format) {
137 return true;
138 default:
139 return false;
140 }
141}

◆ VkFormatNeedsYcbcrSampler()

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

◆ VkFormatStencilBits()

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

Definition at line 155 of file VulkanUtilsPriv.h.

155 {
156 switch (format) {
158 return 8;
160 return 8;
162 return 8;
163 default:
164 return 0;
165 }
166}

◆ VkFormatToCompressionType()

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

◆ VkFormatToStr()

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

Definition at line 243 of file VulkanUtilsPriv.h.

243 {
244 switch (vkFormat) {
245 case VK_FORMAT_R8G8B8A8_UNORM: return "R8G8B8A8_UNORM";
246 case VK_FORMAT_R8_UNORM: return "R8_UNORM";
247 case VK_FORMAT_B8G8R8A8_UNORM: return "B8G8R8A8_UNORM";
248 case VK_FORMAT_R5G6B5_UNORM_PACK16: return "R5G6B5_UNORM_PACK16";
249 case VK_FORMAT_B5G6R5_UNORM_PACK16: return "B5G6R5_UNORM_PACK16";
250 case VK_FORMAT_R16G16B16A16_SFLOAT: return "R16G16B16A16_SFLOAT";
251 case VK_FORMAT_R16_SFLOAT: return "R16_SFLOAT";
252 case VK_FORMAT_R8G8B8_UNORM: return "R8G8B8_UNORM";
253 case VK_FORMAT_R8G8_UNORM: return "R8G8_UNORM";
254 case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return "A2B10G10R10_UNORM_PACK32";
255 case VK_FORMAT_A2R10G10B10_UNORM_PACK32: return "A2R10G10B10_UNORM_PACK32";
256 case VK_FORMAT_B4G4R4A4_UNORM_PACK16: return "B4G4R4A4_UNORM_PACK16";
257 case VK_FORMAT_R4G4B4A4_UNORM_PACK16: return "R4G4B4A4_UNORM_PACK16";
258 case VK_FORMAT_R32G32B32A32_SFLOAT: return "R32G32B32A32_SFLOAT";
259 case VK_FORMAT_R8G8B8A8_SRGB: return "R8G8B8A8_SRGB";
260 case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return "ETC2_R8G8B8_UNORM_BLOCK";
261 case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return "BC1_RGB_UNORM_BLOCK";
262 case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return "BC1_RGBA_UNORM_BLOCK";
263 case VK_FORMAT_R16_UNORM: return "R16_UNORM";
264 case VK_FORMAT_R16G16_UNORM: return "R16G16_UNORM";
265 case VK_FORMAT_R16G16B16A16_UNORM: return "R16G16B16A16_UNORM";
266 case VK_FORMAT_R16G16_SFLOAT: return "R16G16_SFLOAT";
267 case VK_FORMAT_S8_UINT: return "S8_UINT";
268 case VK_FORMAT_D16_UNORM: return "D16_UNORM";
269 case VK_FORMAT_D32_SFLOAT: return "D32_SFLOAT";
270 case VK_FORMAT_D24_UNORM_S8_UINT: return "D24_UNORM_S8_UINT";
271 case VK_FORMAT_D32_SFLOAT_S8_UINT: return "D32_SFLOAT_S8_UINT";
272
273 default: return "Unknown";
274 }
275}
@ VK_FORMAT_R32G32B32A32_SFLOAT
Definition: vulkan_core.h:1568

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.

◆ kIsDebug

constexpr int skgpu::kIsDebug = 0
constexpr

Definition at line 267 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 = SkShaderBlurAlgorithm::kMaxSamples
staticconstexpr

Definition at line 35 of file BlurUtils.h.

◆ kMaxLinearBlurSigma

constexpr float skgpu::kMaxLinearBlurSigma = SkShaderBlurAlgorithm::kMaxLinearSigma
staticconstexpr

Definition at line 36 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.