Flutter Engine
The Flutter Engine
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
skgpu::graphite Namespace Reference

Namespaces

namespace  ContextFactory
 
namespace  DrawPassCommands
 
namespace  LayoutRules
 
namespace  PrecompileBlenders
 
namespace  PrecompileColorFilters
 
namespace  PrecompileColorFiltersPriv
 
namespace  PrecompileImageFilters
 
namespace  PrecompileMaskFilters
 
namespace  PrecompileShaders
 
namespace  PrecompileShadersPriv
 
namespace  ycbcrPackaging
 

Classes

struct  AlphaOnlyPaintColorBlock
 
class  AnalyticBlurMask
 
class  AnalyticBlurRenderStep
 
class  AnalyticRRectRenderStep
 
class  AtlasProvider
 
struct  AttachmentDesc
 
class  Attribute
 
class  AutoDeinstantiateTextureProxy
 
class  AutoLockBuilderAsKey
 
class  BackendSemaphore
 
class  BackendTexture
 
struct  BindBufferInfo
 
struct  BindUniformBufferInfo
 
class  BitmapTextRenderStep
 
struct  BlendModeBlenderBlock
 
struct  BlendShaderBlock
 
class  BoundsManager
 
class  BoundsManagerBench
 
class  BruteForceBoundsManager
 
class  Buffer
 
struct  BufferTextureCopyData
 
struct  BufferView
 
class  Caps
 
struct  ClearBufferInfo
 
class  ClearBuffersTask
 
class  ClientMappedBufferManager
 
class  Clip
 
struct  ClipShaderBlock
 
class  ClipStack
 
struct  CoeffBlenderBlock
 
struct  ColorSpaceTransformBlock
 
class  CommandBuffer
 
struct  ComposeBlock
 
struct  CompressedPaintersOrderSequence
 
class  ComputePathAtlas
 
class  ComputePipeline
 
class  ComputePipelineDesc
 
class  ComputeStep
 
class  ComputeTask
 
class  ConditionalUploadContext
 
class  Context
 
class  ContextCtorAccessor
 
struct  ContextOptions
 
struct  ContextOptionsPriv
 
class  ContextPriv
 
struct  CoordClampShaderBlock
 
class  CopyBufferToBufferTask
 
class  CopyTextureToBufferTask
 
class  CopyTextureToTextureTask
 
class  CoverageMaskRenderStep
 
class  CoverageMaskShape
 
class  CoverBoundsRenderStep
 
class  DawnAsyncResult
 
class  DawnAsyncWait
 
struct  DawnBackendContext
 
class  DawnBuffer
 
class  DawnCaps
 
class  DawnCommandBuffer
 
class  DawnComputePipeline
 
class  DawnErrorChecker
 
class  DawnGraphicsPipeline
 
class  DawnQueueManager
 
class  DawnResourceProvider
 
class  DawnSampler
 
class  DawnSharedContext
 
class  DawnTexture
 
struct  DawnTextureInfo
 
struct  DawnTextureSpec
 
class  DefaultImageProvider
 
struct  DepthStencilSettings
 
struct  DescriptorData
 
class  Device
 
struct  DisjointStencilIndexSequence
 
class  DispatchGroup
 
struct  DitherShaderBlock
 
class  DrawAtlas
 
class  DrawAtlasConfig
 
class  DrawBufferManager
 
class  DrawContext
 
class  DrawList
 
class  DrawOrder
 
class  DrawParams
 
class  DrawPass
 
class  DrawTask
 
class  DrawWriter
 
struct  DstReadSampleBlock
 
class  DynamicInstancesPatchAllocator
 
class  EdgeAAQuad
 
struct  Expectation
 
class  FileBoundsManagerBench
 
class  FileIntersectionBench
 
struct  FragSkSLInfo
 
class  Geometry
 
class  GlobalCache
 
class  GpuWorkSubmission
 
struct  GradientShaderBlocks
 
class  GraphicsPipeline
 
class  GraphicsPipelineDesc
 
class  GraphiteResourceKey
 
class  GridBoundsManager
 
class  HybridBoundsManager
 
class  Image
 
class  Image_Base
 
class  Image_YUVA
 
class  ImageProvider
 
struct  ImageShaderBlock
 
class  ImageUploadContext
 
struct  ImmutableSamplerInfo
 
struct  IndirectDispatchArgs
 
struct  InsertFinishInfo
 
struct  InsertRecordingInfo
 
class  IntersectionTree
 
class  IntersectionTreeBench
 
class  KeyContext
 
class  KeyContextWithColorInfo
 
class  KeyContextWithCoordClamp
 
class  KeyContextWithLocalMatrix
 
class  KeyContextWithScope
 
struct  LayoutTraits
 
struct  LocalMatrixShaderBlock
 
struct  MatrixColorFilterBlock
 
class  MiddleOutFanRenderStep
 
struct  MipLevel
 
class  MonotonicValue
 
struct  MtlBackendContext
 
class  MtlBlitCommandEncoder
 
class  MtlBuffer
 
class  MtlCaps
 
class  MtlCommandBuffer
 
class  MtlComputeCommandEncoder
 
class  MtlComputePipeline
 
class  MtlGraphicsPipeline
 
class  MtlQueueManager
 
class  MtlRenderCommandEncoder
 
class  MtlResourceProvider
 
class  MtlSampler
 
class  MtlSharedContext
 
class  MtlTexture
 
struct  MtlTextureInfo
 
struct  MtlTextureSpec
 
class  MtlWorkSubmission
 
class  NaiveBoundsManager
 
struct  PaintersDepthSequence
 
class  PaintOption
 
class  PaintOptions
 
class  PaintOptionsPriv
 
class  PaintParams
 
class  PaintParamsKey
 
class  PaintParamsKeyBuilder
 
class  PathAtlas
 
class  PerEdgeAAQuadRenderStep
 
struct  PerlinNoiseShaderBlock
 
class  PipelineDataCache
 
class  PipelineDataGatherer
 
class  PrecompileBase
 
class  PrecompileBasePriv
 
class  PrecompileBlender
 
class  PrecompileBlenderPriv
 
class  PrecompileBlendFilterImageFilter
 
class  PrecompileBlendModeBlender
 
class  PrecompileBlendModeColorFilter
 
class  PrecompileBlendShader
 
class  PrecompileBlurImageFilter
 
class  PrecompileBlurMaskFilter
 
class  PrecompileBlurShader
 
class  PrecompileChildPtr
 
class  PrecompileColorFilter
 
class  PrecompileColorFilterImageFilter
 
class  PrecompileColorFilterShader
 
class  PrecompileColorShader
 
class  PrecompileColorSpaceXformColorFilter
 
class  PrecompileComposeColorFilter
 
class  PrecompileCoordClampShader
 
class  PrecompileCTMShader
 
class  PrecompileDisplacementMapImageFilter
 
class  PrecompileDisplacementShader
 
class  PrecompileEmptyShader
 
class  PrecompileGaussianColorFilter
 
class  PrecompileGradientShader
 
class  PrecompileImageFilter
 
class  PrecompileImageShader
 
class  PrecompileLightingImageFilter
 
class  PrecompileLightingShader
 
class  PrecompileLocalMatrixShader
 
class  PrecompileMaskFilter
 
class  PrecompileMatrixColorFilter
 
class  PrecompileMatrixConvolutionImageFilter
 
class  PrecompileMatrixConvolutionShader
 
class  PrecompileMorphologyImageFilter
 
class  PrecompileMorphologyShader
 
class  PrecompilePerlinNoiseShader
 
class  PrecompileRTEffect
 
class  PrecompileShader
 
class  PrecompileShaderPriv
 
class  PrecompileTableColorFilter
 
class  PrecompileWithWorkingFormatColorFilter
 
class  PrecompileWorkingColorSpaceShader
 
class  PrecompileYUVImageShader
 
class  ProxyCache
 
class  ProxyReadCountMap
 
class  QueueManager
 
class  RandomBoundsManagerBench
 
class  RandomIntersectionBench
 
class  RasterMaskHelper
 
class  RasterPathAtlas
 
class  Recorder
 
struct  RecorderOptions
 
class  RecorderPriv
 
class  Recording
 
class  RecordingPriv
 
class  Rect
 
class  Renderer
 
class  RendererProvider
 
struct  RenderPassDesc
 
class  RenderPassTask
 
class  RenderStep
 
class  Resource
 
struct  ResourceBinding
 
struct  ResourceBindingRequirements
 
class  ResourceCache
 
class  ResourceProvider
 
struct  RGBPaintColorBlock
 
struct  RuntimeEffectBlock
 
class  RuntimeEffectDictionary
 
class  Sampler
 
struct  SamplerDesc
 
struct  SamplerIndex
 
class  ScratchBuffer
 
class  ScratchResourceManager
 
class  SDFTextLCDRenderStep
 
class  SDFTextRenderStep
 
class  ShaderCodeDictionary
 
class  ShaderInfo
 
class  ShaderNode
 
struct  ShaderSnippet
 
class  Shape
 
class  SharedContext
 
class  SimpleIntersectionTree
 
struct  SolidColorShaderBlock
 
class  SpecialImage
 
class  StaticBufferManager
 
class  StrokeStyle
 
class  SubRunData
 
class  Surface
 
class  SynchronizeToCpuTask
 
struct  TableColorFilterBlock
 
class  Task
 
class  TaskList
 
class  TessellateCurvesRenderStep
 
class  TessellateStrokesRenderStep
 
class  TessellateWedgesRenderStep
 
class  TestResource
 
class  TextAtlasManager
 
class  Texture
 
class  TextureAndSampler
 
class  TextureDataBlock
 
struct  TextureIndex
 
class  TextureInfo
 
class  TextureProxy
 
class  TextureProxyView
 
class  Transform
 
class  Uniform
 
class  UniformDataBlock
 
class  UniformManager
 
class  UniformOffsetCalculator
 
class  UniquePaintParamsID
 
class  UploadBufferManager
 
class  UploadInstance
 
class  UploadList
 
class  UploadTask
 
struct  Varying
 
class  VelloFineAreaAlpha8Step
 
class  VelloFineAreaStep
 
class  VelloFineMsaa16Alpha8Step
 
class  VelloFineMsaa16Step
 
class  VelloFineMsaa8Alpha8Step
 
class  VelloFineMsaa8Step
 
class  VelloFineMsaaStepBase
 
class  VelloFineStepBase
 
class  VelloRenderer
 
class  VelloScene
 
class  VelloStep
 
struct  Vertex
 
class  VerticesRenderStep
 
struct  VertSkSLInfo
 
class  VulkanBuffer
 
class  VulkanCaps
 
class  VulkanCommandBuffer
 
class  VulkanDescriptorPool
 
class  VulkanDescriptorSet
 
class  VulkanFramebuffer
 
class  VulkanGraphicsPipeline
 
class  VulkanImageView
 
class  VulkanQueueManager
 
class  VulkanRenderPass
 
class  VulkanResourceProvider
 
class  VulkanSampler
 
class  VulkanSharedContext
 
class  VulkanTexture
 
struct  VulkanTextureInfo
 
struct  VulkanTextureSpec
 
class  VulkanWorkSubmission
 
class  VulkanYcbcrConversion
 
struct  WorkgroupSize
 
class  YUVABackendTextureInfo
 
class  YUVABackendTextures
 
struct  YUVImageShaderBlock
 

Typedefs

using DawnTickFunction = void(const wgpu::Instance &device)
 
using GpuFinishedContext = void *
 
using GpuFinishedProc = void(*)(GpuFinishedContext finishedContext, CallbackResult)
 
using MtlPixelFormat = unsigned int
 
using MtlTextureUsage = unsigned int
 
using MtlStorageMode = unsigned int
 
using UniformDataCache = PipelineDataCache< UniformDataBlock >
 
using TextureDataCache = PipelineDataCache< TextureDataBlock >
 
using Builder = DispatchGroup::Builder
 
using BindingIndex = uint32_t
 
using DispatchResource = std::variant< BufferView, TextureIndex, SamplerIndex >
 
using DispatchResourceOptional = std::variant< std::monostate, BufferView, TextureIndex, SamplerIndex >
 
using CompressedPaintersOrder = MonotonicValue< CompressedPaintersOrderSequence >
 
using DisjointStencilIndex = MonotonicValue< DisjointStencilIndexSequence >
 
using PaintersDepth = MonotonicValue< PaintersDepthSequence >
 
using PrecompileChildOptions = SkSpan< const PrecompileChildPtr >
 
using AddToKeyFn = std::function< void()>
 
using AAFlags = EdgeAAQuad::Flags
 
using ResourceType = uint32_t
 
using Status = Task::Status
 
using DrawCallback = std::function< void(SkCanvas *)>
 

Enumerations

enum class  SyncToCpu : bool { kYes = true , kNo = false }
 
enum class  Volatile : bool { kNo = false , kYes = true }
 
enum  DrawTypeFlags : uint8_t {
  kNone = 0b0000 , kText = 0b0001 , kDrawVertices = 0b0010 , kSimpleShape = 0b0100 ,
  kNonSimpleShape = 0b1000 , kShape = kSimpleShape | kNonSimpleShape , kMostCommon = kText | kShape , kAll = kText | kDrawVertices | kShape
}
 
enum class  PathRendererStrategy {
  kDefault , kComputeAnalyticAA , kComputeMSAA16 , kComputeMSAA8 ,
  kRasterAA , kTessellation
}
 
enum class  BuiltInCodeSnippetID : int32_t {
  kError , kPriorOutput , kSolidColorShader , kRGBPaintColor ,
  kAlphaOnlyPaintColor , kLinearGradientShader4 , kLinearGradientShader8 , kLinearGradientShaderTexture ,
  kLinearGradientShaderBuffer , kRadialGradientShader4 , kRadialGradientShader8 , kRadialGradientShaderTexture ,
  kRadialGradientShaderBuffer , kSweepGradientShader4 , kSweepGradientShader8 , kSweepGradientShaderTexture ,
  kSweepGradientShaderBuffer , kConicalGradientShader4 , kConicalGradientShader8 , kConicalGradientShaderTexture ,
  kConicalGradientShaderBuffer , kLocalMatrixShader , kImageShader , kCubicImageShader ,
  kHWImageShader , kYUVImageShader , kCubicYUVImageShader , kHWYUVImageShader ,
  kCoordClampShader , kDitherShader , kPerlinNoiseShader , kRuntimeShader ,
  kMatrixColorFilter , kTableColorFilter , kGaussianColorFilter , kColorSpaceXformColorFilter ,
  kBlendShader , kBlendModeBlender , kCoeffBlender , kPrimitiveColor ,
  kDstReadSample , kDstReadFetch , kClipShader , kCompose ,
  kFixedFunctionClearBlendMode , kFixedFunctionSrcBlendMode , kFixedFunctionDstBlendMode , kFixedFunctionSrcOverBlendMode ,
  kFixedFunctionDstOverBlendMode , kFixedFunctionSrcInBlendMode , kFixedFunctionDstInBlendMode , kFixedFunctionSrcOutBlendMode ,
  kFixedFunctionDstOutBlendMode , kFixedFunctionSrcATopBlendMode , kFixedFunctionDstATopBlendMode , kFixedFunctionXorBlendMode ,
  kFixedFunctionPlusBlendMode , kFixedFunctionModulateBlendMode , kFixedFunctionScreenBlendMode , kFirstFixedFunctionBlendMode = kFixedFunctionClearBlendMode ,
  kLast = kFixedFunctionScreenBlendMode
}
 
enum class  DstReadRequirement { kNone , kTextureCopy , kTextureSample , kFramebufferFetch }
 
enum class  VelloAaConfig { kAnalyticArea , kMSAA16 , kMSAA8 }
 
enum class  DawnErrorType : uint32_t { kNoError = 0b00000000 , kValidation = 0b00000001 , kOutOfMemory = 0b00000010 , kInternal = 0b00000100 }
 
enum class  DescriptorType : uint8_t {
  kUniformBuffer = 0 , kTextureSampler , kTexture , kCombinedTextureSampler ,
  kStorageBuffer , kInputAttachment , kLast = kInputAttachment
}
 
enum class  PipelineStageFlags : uint8_t { kVertexShader = 0b001 , kFragmentShader = 0b010 , kCompute = 0b100 }
 
enum class  PrimitiveType : uint8_t { kTriangles , kTriangleStrip , kPoints }
 
enum class  VertexAttribType : uint8_t {
  kFloat = 0 , kFloat2 , kFloat3 , kFloat4 ,
  kHalf , kHalf2 , kHalf4 , kInt2 ,
  kInt3 , kInt4 , kByte , kByte2 ,
  kByte4 , kUByte , kUByte2 , kUByte4 ,
  kUByte_norm , kUByte4_norm , kShort2 , kShort4 ,
  kUShort2 , kUShort2_norm , kInt , kUInt ,
  kUShort_norm , kUShort4_norm , kLast = kUShort4_norm
}
 
enum class  UniformSlot { kRenderStep , kPaint , kGradient }
 
enum class  CompareOp : uint8_t {
  kAlways , kNever , kGreater , kGEqual ,
  kLess , kLEqual , kEqual , kNotEqual
}
 
enum class  StencilOp : uint8_t {
  kKeep , kZero , kReplace , kInvert ,
  kIncWrap , kDecWrap , kIncClamp , kDecClamp
}
 
enum class  DstColorType { kSurface , kPrimitive , kChildOutput }
 
enum class  Priority : int { kFatal = 0 , kError = 1 , kWarning = 2 , kDebug = 3 }
 
enum class  PrecompileImageShaderFlags { kNone = 0b00 , kExcludeAlpha = 0b01 , kExcludeCubic = 0b10 }
 
enum class  ReadSwizzle {
  kRGBA , kRGB1 , kRRR1 , kBGRA ,
  k000R
}
 
enum class  Coverage { kNone , kSingleChannel , kLCD }
 
enum class  DepthStencilFlags : int { kNone = 0b000 , kDepth = 0b001 , kStencil = 0b010 , kDepthStencil = kDepth | kStencil }
 
enum class  LoadOp : uint8_t { kLoad , kClear , kDiscard , kLast = kDiscard }
 
enum class  StoreOp : uint8_t { kStore , kDiscard , kLast = kDiscard }
 
enum class  BufferType : int {
  kVertex , kIndex , kXferCpuToGpu , kXferGpuToCpu ,
  kUniform , kStorage , kIndirect , kVertexStorage ,
  kIndexStorage , kLast = kIndexStorage
}
 
enum class  Layout { kInvalid = 0 , kStd140 , kStd430 , kMetal }
 
enum class  AccessPattern : int { kGpuOnly , kHostVisible }
 
enum class  ClearBuffer : bool { kNo = false , kYes = true }
 
enum class  Discardable : bool { kNo = false , kYes = true }
 
enum class  Ownership { kOwned , kWrapped }
 
enum class  Shareable : bool { kNo = false , kYes = true }
 
enum class  LastRemovedRef { kUsage , kCommandBuffer , kCache }
 
enum class  SnippetRequirementFlags : uint32_t {
  kNone = 0x0 , kLocalCoords = 0x1 , kPriorStageOutput = 0x2 , kBlenderDstColor = 0x4 ,
  kSurfaceColor = 0x8 , kGradientBuffer = 0x10 , kStoresData = 0x20
}
 

Functions

SK_API void DawnNativeProcessEventsFunction (const wgpu::Instance &instance)
 
void Precompile (Context *context, const PaintOptions &paintOptions, DrawTypeFlags drawTypes=kMostCommon)
 
DawnTextureInfo DawnTextureSpecToTextureInfo (const DawnTextureSpec &dawnSpec, uint32_t sampleCount, Mipmapped mipmapped)
 
DawnTextureInfo DawnTextureInfoFromWGPUTexture (WGPUTexture texture)
 
MtlTextureInfo MtlTextureSpecToTextureInfo (const MtlTextureSpec &mtlSpec, uint32_t sampleCount, Mipmapped mipmapped)
 
VulkanTextureInfo VulkanTextureSpecToTextureInfo (const VulkanTextureSpec &vkSpec, uint32_t sampleCount, Mipmapped mipmapped)
 
static SkColorType color_type_fallback (SkColorType ct)
 
bool SkShouldPostMessageToBus (const ClientMappedBufferManager::BufferFinishedMessage &, Context::ContextID potentialRecipient)
 
std::string_view VelloStageName (vello_cpp::ShaderStage stage)
 
WorkgroupSize VelloStageLocalSize (vello_cpp::ShaderStage stage)
 
skia_private::TArray< ComputeStep::WorkgroupBufferDescVelloWorkgroupBuffers (vello_cpp::ShaderStage stage)
 
ComputeStep::NativeShaderSource VelloNativeShaderSource (vello_cpp::ShaderStage stage, ComputeStep::NativeShaderFormat format)
 
 VELLO_COMPUTE_STEP (BackdropDyn)
 
 VELLO_COMPUTE_STEP (BboxClear)
 
 VELLO_COMPUTE_STEP (Binning)
 
 VELLO_COMPUTE_STEP (ClipLeaf)
 
 VELLO_COMPUTE_STEP (ClipReduce)
 
 VELLO_COMPUTE_STEP (Coarse)
 
 VELLO_COMPUTE_STEP (Flatten)
 
 VELLO_COMPUTE_STEP (DrawLeaf)
 
 VELLO_COMPUTE_STEP (DrawReduce)
 
 VELLO_COMPUTE_STEP (PathCount)
 
 VELLO_COMPUTE_STEP (PathCountSetup)
 
 VELLO_COMPUTE_STEP (PathTiling)
 
 VELLO_COMPUTE_STEP (PathTilingSetup)
 
 VELLO_COMPUTE_STEP (PathtagReduce)
 
 VELLO_COMPUTE_STEP (PathtagReduce2)
 
 VELLO_COMPUTE_STEP (PathtagScan1)
 
 VELLO_COMPUTE_STEP (PathtagScanLarge)
 
 VELLO_COMPUTE_STEP (PathtagScanSmall)
 
 VELLO_COMPUTE_STEP (TileAlloc)
 
std::tuple< UniquePaintParamsID, const UniformDataBlock *, const TextureDataBlock * > ExtractPaintData (Recorder *recorder, PipelineDataGatherer *gatherer, PaintParamsKeyBuilder *builder, const Layout layout, const SkM44 &local2Dev, const PaintParams &p, const Geometry &geometry, sk_sp< TextureProxy > dstTexture, SkIPoint dstOffset, const SkColorInfo &targetColorInfo)
 
std::tuple< const UniformDataBlock *, const TextureDataBlock * > ExtractRenderStepData (UniformDataCache *uniformDataCache, TextureDataCache *textureDataCache, PipelineDataGatherer *gatherer, const Layout layout, const RenderStep *step, const DrawParams &params)
 
DstReadRequirement GetDstReadRequirement (const Caps *caps, std::optional< SkBlendMode > blendMode, Coverage coverage)
 
std::string EmitPaintParamsUniforms (int bufferID, const Layout layout, SkSpan< const ShaderNode * > nodes, int *numUniforms, int *uniformsTotalBytes, bool *wrotePaintColor)
 
std::string EmitRenderStepUniforms (int bufferID, const Layout layout, SkSpan< const Uniform > uniforms, int *renderStepUniformsTotalBytes)
 
std::string EmitPaintParamsStorageBuffer (int bufferID, SkSpan< const ShaderNode * > nodes, int *numUniforms, bool *wrotePaintColor)
 
std::string EmitRenderStepStorageBuffer (int bufferID, SkSpan< const Uniform > uniforms)
 
std::string EmitUniformsFromStorageBuffer (const char *bufferNamePrefix, const char *ssboIndex, SkSpan< const Uniform > uniforms)
 
std::string EmitStorageBufferAccess (const char *bufferNamePrefix, const char *ssboIndex, const char *uniformName)
 
std::string EmitTexturesAndSamplers (const ResourceBindingRequirements &bindingReqs, SkSpan< const ShaderNode * > nodes, int *binding)
 
std::string EmitSamplerLayout (const ResourceBindingRequirements &bindingReqs, int *binding)
 
std::string EmitVaryings (const RenderStep *step, const char *direction, bool emitSsboIndicesVarying, bool emitLocalCoordsVarying)
 
VertSkSLInfo BuildVertexSkSL (const ResourceBindingRequirements &bindingReqs, const RenderStep *step, bool useStorageBuffers, bool defineLocalCoordsVarying)
 
FragSkSLInfo BuildFragmentSkSL (const Caps *caps, const ShaderCodeDictionary *dict, const RuntimeEffectDictionary *rteDict, const RenderStep *step, UniquePaintParamsID paintID, bool useStorageBuffers, skgpu::Swizzle writeSwizzle)
 
std::string GetPipelineLabel (const ShaderCodeDictionary *dict, const RenderPassDesc &renderPassDesc, const RenderStep *renderStep, UniquePaintParamsID paintID)
 
std::string BuildComputeSkSL (const Caps *caps, const ComputeStep *step)
 
 SK_MAKE_BITMASK_OPS (DawnErrorType)
 
bool DawnFormatIsDepthOrStencil (wgpu::TextureFormat format)
 
bool DawnFormatIsDepth (wgpu::TextureFormat format)
 
bool DawnFormatIsStencil (wgpu::TextureFormat format)
 
wgpu::TextureFormat DawnDepthStencilFlagsToFormat (SkEnumBitMask< DepthStencilFlags > mask)
 
static bool check_shader_module (const DawnSharedContext *sharedContext, wgpu::ShaderModule *module, const char *shaderText, ShaderErrorHandler *errorHandler)
 
bool DawnCompileWGSLShaderModule (const DawnSharedContext *sharedContext, const char *label, const std::string &wgsl, wgpu::ShaderModule *module, ShaderErrorHandler *errorHandler)
 
static wgpu::AddressMode tile_mode_to_dawn_address_mode (SkTileMode tileMode)
 
size_t DawnFormatBytesPerBlock (wgpu::TextureFormat format)
 
SkTextureCompressionType DawnFormatToCompressionType (wgpu::TextureFormat format)
 
uint32_t DawnFormatChannels (wgpu::TextureFormat format)
 
 SK_MAKE_BITMASK_OPS (PipelineStageFlags)
 
static uint32_t next_id ()
 
static constexpr size_t VertexAttribTypeSize (VertexAttribType type)
 
sk_sp< PrecompileShaderMakePrecompileShader (sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
 
sk_sp< PrecompileColorFilterMakePrecompileColorFilter (sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
 
sk_sp< PrecompileBlenderMakePrecompileBlender (sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
 
static float quantize (float deviceSpaceFloat)
 
static int write_color_and_offset_bufdata (int numStops, const SkPMColor4f *colors, const float *offsets, const SkGradientBaseShader *shader, PipelineDataGatherer *gatherer)
 
static bool can_do_yuv_tiling_in_hw (const Caps *caps, const YUVImageShaderBlock::ImageData &imgData)
 
void AddBlendModeColorFilter (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm, const SkPMColor4f &srcColor)
 
static bool skdata_matches (const SkData *a, const SkData *b)
 
static void gather_runtime_effect_uniforms (const KeyContext &keyContext, const SkRuntimeEffect *effect, SkSpan< const Uniform > graphiteUniforms, const SkData *uniformData, PipelineDataGatherer *gatherer)
 
void AddToKey (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkBlender *blender)
 
void NotifyImagesInUse (Recorder *recorder, DrawContext *drawContext, const SkBlender *blender)
 
static SkPMColor4f map_color (const SkColor4f &c, SkColorSpace *src, SkColorSpace *dst)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkBlendModeColorFilter *filter)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkColorSpaceXformColorFilter *filter)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *keyBuilder, PipelineDataGatherer *gatherer, const SkComposeColorFilter *filter)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkGaussianColorFilter *)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkMatrixColorFilter *filter)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkRuntimeColorFilter *filter)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkTableColorFilter *filter)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkWorkingFormatColorFilter *filter)
 
void AddToKey (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkColorFilter *filter)
 
void NotifyImagesInUse (Recorder *recorder, DrawContext *drawContext, const SkColorFilter *filter)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkBlendShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkBlendShader *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkCTMShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkCTMShader *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkColorShader *shader)
 
static void notify_in_use (Recorder *, DrawContext *, const SkColorShader *)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkColor4Shader *shader)
 
static void notify_in_use (Recorder *, DrawContext *, const SkColor4Shader *)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkColorFilterShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkColorFilterShader *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkCoordClampShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkCoordClampShader *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkEmptyShader *)
 
static void notify_in_use (Recorder *, DrawContext *, const SkEmptyShader *)
 
static void add_yuv_image_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkImageShader *origShader, sk_sp< const SkImage > imageToDraw, SkSamplingOptions sampling)
 
static skgpu::graphite::ReadSwizzle swizzle_class_to_read_enum (const skgpu::Swizzle &swizzle)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkImageShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkImageShader *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkLocalMatrixShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkLocalMatrixShader *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkPerlinNoiseShader *shader)
 
static void notify_in_use (Recorder *, DrawContext *, const SkPerlinNoiseShader *)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkPictureShader *shader)
 
static void notify_in_use (Recorder *, DrawContext *, const SkPictureShader *)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkRuntimeShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkRuntimeShader *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkTransformShader *shader)
 
static void notify_in_use (Recorder *, DrawContext *, const SkTransformShader *)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkTriColorShader *shader)
 
static void notify_in_use (Recorder *, DrawContext *, const SkTriColorShader *)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkWorkingColorSpaceShader *shader)
 
static void notify_in_use (Recorder *recorder, DrawContext *drawContext, const SkWorkingColorSpaceShader *shader)
 
static SkBitmap create_color_and_offset_bitmap (int numStops, const SkPMColor4f *colors, const float *offsets)
 
static void make_interpolated_to_dst (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const GradientShaderBlocks::GradientData &gradData, const SkGradientShader::Interpolation &interp, SkColorSpace *intermediateCS)
 
static void add_gradient_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkGradientBaseShader *shader, SkPoint point0, SkPoint point1, float radius0, float radius1, float bias, float scale)
 
static void add_gradient_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkConicalGradient *shader)
 
static void add_gradient_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkLinearGradient *shader)
 
static void add_gradient_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkRadialGradient *shader)
 
static void add_gradient_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkSweepGradient *shader)
 
static void add_to_key (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkGradientBaseShader *shader)
 
static void notify_in_use (Recorder *, DrawContext *, const SkGradientBaseShader *)
 
void AddToKey (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkShader *shader)
 
void NotifyImagesInUse (Recorder *recorder, DrawContext *drawContext, const SkShader *shader)
 
static MTLPrimitiveType graphite_to_mtl_primitive (PrimitiveType primitiveType)
 
static bool check_max_blit_width (int widthInPixels)
 
sk_cfp< id< MTLLibrary > > MtlCompileShaderLibrary (const MtlSharedContext *sharedContext, std::string_view label, std::string_view msl, ShaderErrorHandler *errorHandler)
 
size_t MtlFormatBytesPerBlock (MtlPixelFormat format)
 
SkTextureCompressionType MtlFormatToCompressionType (MtlPixelFormat format)
 
static MTLSamplerAddressMode tile_mode_to_mtl_sampler_address (SkTileMode tileMode, const Caps &caps)
 
void Blend (const KeyContext &keyContext, PaintParamsKeyBuilder *keyBuilder, PipelineDataGatherer *gatherer, AddToKeyFn addBlendToKey, AddToKeyFn addSrcToKey, AddToKeyFn addDstToKey)
 
void Compose (const KeyContext &keyContext, PaintParamsKeyBuilder *keyBuilder, PipelineDataGatherer *gatherer, AddToKeyFn addInnerToKey, AddToKeyFn addOuterToKey)
 
void AddKnownModeBlend (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)
 
void AddModeBlend (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)
 
void AddDstReadBlock (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, DstReadRequirement dstReadReq)
 
void AddDitherBlock (const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkColorType ct)
 
static int key_to_string (SkString *str, const ShaderCodeDictionary *dict, SkSpan< const uint32_t > keyData, int currentIndex, bool includeData)
 
void PrecompileCombinations (Context *context, const PaintOptions &options, const KeyContext &keyContext, DrawTypeFlags drawTypes, bool withPrimitiveBlender, Coverage coverage)
 
bool Precompile (Context *context, RuntimeEffectDictionary *rteDict, const GraphicsPipelineDesc &pipelineDesc, const RenderPassDesc &renderPassDesc)
 
skgpu::UniqueKey GeneratePathMaskKey (const Shape &shape, const Transform &transform, const SkStrokeRec &strokeRec, skvx::half2 maskSize)
 
static uint32_t next_id ()
 
static skvx::float4 load_x_radii (const SkRRect &rrect)
 
static skvx::float4 load_y_radii (const SkRRect &rrect)
 
static bool opposite_insets_intersect (const SkRRect &rrect, float strokeRadius, float aaRadius)
 
static bool opposite_insets_intersect (const Rect &rect, float strokeRadius, float aaRadius)
 
static bool opposite_insets_intersect (const Geometry &geometry, float strokeRadius, float aaRadius)
 
static bool is_clockwise (const EdgeAAQuad &quad)
 
static skvx::float2 quad_center (const EdgeAAQuad &quad)
 
static void write_index_buffer (VertexWriter writer)
 
static void write_vertex_buffer (VertexWriter writer)
 
static skvx::float2 get_device_translation (const SkM44 &localToDevice)
 
static bool is_clockwise (const EdgeAAQuad &quad)
 
static void write_index_buffer (VertexWriter writer)
 
static void write_vertex_buffer (VertexWriter writer)
 
static uint32_t next_id ()
 
static std::string to_str (const SharedContext *ctx, const GraphicsPipelineDesc &gpDesc, const RenderPassDesc &rpDesc)
 
static constexpr const char * LayoutString (Layout layout)
 
void append_color_output (std::string *mainBody, BlendFormula::OutputType outputType, const char *outColor, const char *inColor)
 
static SkSLType uniform_type_to_sksl_type (const SkRuntimeEffect::Uniform &u)
 
void Flush (sk_sp< SkSurface > surface)
 
void Flush (SkSurface *surface)
 
std::pair< size_t, size_t > compute_combined_buffer_size (const Caps *caps, int mipLevelCount, size_t bytesPerBlock, const SkISize &baseDimensions, SkTextureCompressionType compressionType, TArray< std::pair< size_t, size_t > > *levelOffsetsAndRowBytes)
 
template<typename INT_TYPE >
static void expand_bits (INT_TYPE *dst, const uint8_t *src, int width, int height, int dstRowBytes, int srcRowBytes)
 
static void get_packed_glyph_image (const SkGlyph &glyph, int dstRB, MaskFormat expectedMaskFormat, void *dst)
 
std::tuple< TextureProxyView, SkColorTypeMakeBitmapProxyView (Recorder *recorder, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmapsIn, Mipmapped mipmapped, Budgeted budgeted, std::string_view label)
 
sk_sp< TextureProxyMakePromiseImageLazyProxy (const Caps *caps, SkISize dimensions, TextureInfo textureInfo, Volatile isVolatile, sk_sp< RefCntedCallback > releaseHelper, GraphitePromiseTextureFulfillProc fulfillProc, GraphitePromiseTextureFulfillContext fulfillContext, GraphitePromiseTextureReleaseProc textureReleaseProc, std::string_view label)
 
sk_sp< SkImageMakeFromBitmap (Recorder *recorder, const SkColorInfo &colorInfo, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmaps, Budgeted budgeted, SkImage::RequiredProperties requiredProps, std::string_view label)
 
size_t ComputeSize (SkISize dimensions, const TextureInfo &info)
 
sk_sp< ImageCopyAsDraw (Recorder *recorder, const SkImage *image, const SkIRect &subset, const SkColorInfo &dstColorInfo, Budgeted budgeted, Mipmapped mipmapped, SkBackingFit backingFit, std::string_view label)
 
sk_sp< SkImageRescaleImage (Recorder *recorder, const SkImage *srcImage, SkIRect srcIRect, const SkImageInfo &dstInfo, SkImage::RescaleGamma rescaleGamma, SkImage::RescaleMode rescaleMode)
 
bool GenerateMipmaps (Recorder *recorder, sk_sp< TextureProxy > texture, const SkColorInfo &colorInfo)
 
std::pair< sk_sp< SkImage >, SkSamplingOptionsGetGraphiteBacked (Recorder *recorder, const SkImage *imageIn, SkSamplingOptions sampling)
 
TextureProxyView AsView (const SkImage *image)
 
SkColorType ComputeShaderCoverageMaskTargetFormat (const Caps *caps)
 
sk_sp< TextureProxyMakePromiseImageLazyProxy (const Caps *, SkISize dimensions, TextureInfo, Volatile, sk_sp< skgpu::RefCntedCallback > releaseHelper, SkImages::GraphitePromiseTextureFulfillProc, SkImages::GraphitePromiseTextureFulfillContext, SkImages::GraphitePromiseTextureReleaseProc, std::string_view label)
 
TextureProxyView AsView (sk_sp< SkImage > image)
 
static std::pair< SkSLType, intadjust_for_matrix_type (SkSLType type, int count)
 
static bool submit_to_queue (const VulkanSharedContext *sharedContext, VkQueue queue, VkFence fence, uint32_t waitCount, const VkSemaphore *waitSemaphores, const VkPipelineStageFlags *waitStages, uint32_t commandBufferCount, const VkCommandBuffer *commandBuffers, uint32_t signalCount, const VkSemaphore *signalSemaphores, Protected protectedContext)
 
static VkFormat attrib_type_to_vkformat (VertexAttribType type)
 
static void setup_vertex_input_state (const SkSpan< const Attribute > &vertexAttrs, const SkSpan< const Attribute > &instanceAttrs, VkPipelineVertexInputStateCreateInfo *vertexInputInfo, skia_private::STArray< 2, VkVertexInputBindingDescription, true > *bindingDescs, skia_private::STArray< 16, VkVertexInputAttributeDescription > *attributeDescs)
 
static VkPrimitiveTopology primitive_type_to_vk_topology (PrimitiveType primitiveType)
 
static void setup_input_assembly_state (PrimitiveType primitiveType, VkPipelineInputAssemblyStateCreateInfo *inputAssemblyInfo)
 
static VkStencilOp stencil_op_to_vk_stencil_op (StencilOp op)
 
static VkCompareOp compare_op_to_vk_compare_op (CompareOp op)
 
static void setup_stencil_op_state (VkStencilOpState *opState, const DepthStencilSettings::Face &face, uint32_t referenceValue)
 
static void setup_depth_stencil_state (const DepthStencilSettings &stencilSettings, VkPipelineDepthStencilStateCreateInfo *stencilInfo)
 
static void setup_viewport_scissor_state (VkPipelineViewportStateCreateInfo *viewportInfo)
 
static void setup_multisample_state (int numSamples, VkPipelineMultisampleStateCreateInfo *multisampleInfo)
 
static VkBlendFactor blend_coeff_to_vk_blend (skgpu::BlendCoeff coeff)
 
static VkBlendOp blend_equation_to_vk_blend_op (skgpu::BlendEquation equation)
 
static void setup_color_blend_state (const skgpu::BlendInfo &blendInfo, VkPipelineColorBlendStateCreateInfo *colorBlendInfo, VkPipelineColorBlendAttachmentState *attachmentState)
 
static void setup_raster_state (bool isWireframe, VkPipelineRasterizationStateCreateInfo *rasterInfo)
 
static void setup_shader_stage_info (VkShaderStageFlagBits stage, VkShaderModule shaderModule, VkPipelineShaderStageCreateInfo *shaderStageInfo)
 
static VkDescriptorSetLayout descriptor_data_to_layout (const VulkanSharedContext *sharedContext, const SkSpan< DescriptorData > &descriptorData)
 
static void destroy_desc_set_layouts (const VulkanSharedContext *sharedContext, skia_private::TArray< VkDescriptorSetLayout > &setLayouts)
 
static VkPipelineLayout setup_pipeline_layout (const VulkanSharedContext *sharedContext, bool usesIntrinsicConstantUbo, bool hasStepUniforms, int numPaintUniforms, int numTextureSamplers, int numInputAttachments)
 
static void destroy_shader_modules (const VulkanSharedContext *sharedContext, VkShaderModule vsModule, VkShaderModule fsModule)
 
static void setup_dynamic_state (VkPipelineDynamicStateCreateInfo *dynamicInfo, VkDynamicState *dynamicStates)
 
VkShaderModule createVulkanShaderModule (const VulkanSharedContext *context, const std::string &spirv, VkShaderStageFlagBits stage)
 
void DescriptorDataToVkDescSetLayout (const VulkanSharedContext *ctxt, const SkSpan< DescriptorData > &requestedDescriptors, VkDescriptorSetLayout *outLayout)
 
VkDescriptorType DsTypeEnumToVkDs (DescriptorType type)
 
bool vkFormatIsSupported (VkFormat format)
 
VkShaderStageFlags PipelineStageFlagsToVkShaderStageFlags (SkEnumBitMask< PipelineStageFlags > stageFlags)
 
static VkSamplerAddressMode tile_mode_to_vk_sampler_address (SkTileMode tileMode)
 
VkImageAspectFlags vk_format_to_aspect_flags (VkFormat format)
 
 DEF_TEST (BoundsManager, r)
 
 DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (BufferManagerGpuOnlyBufferTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (DeviceTestVertexTransparency, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (DrawPassTestFailedDstCopy, reporter, context, CtsEnforcement::kNextRelease)
 
static sk_sp< SkDatacreate_image_data (const SkImageInfo &info)
 
static skgpu::graphite::TextureProxytop_device_graphite_target_proxy (SkCanvas *canvas)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphiteBudgetedResourcesTest, reporter, context, testContext, true, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphitePurgeAsNeededResourcesTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphiteZeroSizedResourcesTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphitePurgeNotUsedSinceResourcesTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphitePurgeNotUsedOverBudgetTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphitePurgeResourcesTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (ImageOriginTest_drawImage_Graphite, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (ImageOriginTest_imageShader_Graphite, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (ImageShaderTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST (skgpu_IntersectionTree, reporter, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (MultisampleRetainTest, reporter, context, CtsEnforcement::kNever)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest1, r, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest2, r, context, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest4, r, context, testContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest5, r, context, testContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest6, r, context, testContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest7, r, context, testContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest8, r, context, testContext, true, CtsEnforcement::kNextRelease)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest9, r, context, testContext, true, CtsEnforcement::kNextRelease)
 
static sk_sp< TextureProxyfind_or_create_by_key (Recorder *recorder, int id, bool *regenerated)
 
 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest10, r, context, testContext, true, CtsEnforcement::kNextRelease)
 
void run_test (skiatest::Reporter *reporter, Context *context, SkISize surfaceSize, SkISize recordingSize, SkISize replayOffset, DrawCallback draw, const std::vector< Expectation > &expectations)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (RecordingSurfacesTestClear, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (RecordingSurfacesTestWritePixels, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (RecordingSurfacesTestWritePixelsOffscreen, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST (skgpu_Rect, reporter, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphiteTextureProxyTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphiteTextureTooLargeTest, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS (GraphiteLazyTextureInvalidDimensions, reporter, context, CtsEnforcement::kNextRelease)
 
 DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS (UploadBufferManagerTest, reporter, context, CtsEnforcement::kNextRelease)
 
skgpu::BackendApi ContextTypeBackend (skgpu::ContextType type)
 

Variables

static constexpr int kBuiltInCodeSnippetIDCount = static_cast<int>(BuiltInCodeSnippetID::kLast)+1
 
static constexpr int kFixedFunctionBlendModeIDOffset
 
static constexpr int kElementStackIncrement = 8
 
static constexpr int kSaveStackIncrement = 8
 
static constexpr ComputeStep::ResourceDesc kFineAreaResources []
 
static constexpr ComputeStep::ResourceDesc kFineMsaaResources []
 
constexpr int kVelloSlot_ConfigUniform = 0
 
constexpr int kVelloSlot_Scene = 1
 
constexpr int kVelloSlot_TagMonoid = 2
 
constexpr int kVelloSlot_PathtagReduceOutput = 3
 
constexpr int kVelloSlot_LargePathtagReduceFirstPassOutput = kVelloSlot_PathtagReduceOutput
 
constexpr int kVelloSlot_LargePathtagReduceSecondPassOutput = 4
 
constexpr int kVelloSlot_LargePathtagScanFirstPassOutput = 5
 
constexpr int kVelloSlot_PathBBoxes = 6
 
constexpr int kVelloSlot_Lines = 7
 
constexpr int kVelloSlot_DrawReduceOutput = 8
 
constexpr int kVelloSlot_DrawMonoid = 9
 
constexpr int kVelloSlot_InfoBinData = 10
 
constexpr int kVelloSlot_ClipInput = 11
 
constexpr int kVelloSlot_ClipBicyclic = 12
 
constexpr int kVelloSlot_ClipElement = 13
 
constexpr int kVelloSlot_ClipBBoxes = 14
 
constexpr int kVelloSlot_DrawBBoxes = 15
 
constexpr int kVelloSlot_BumpAlloc = 16
 
constexpr int kVelloSlot_BinHeader = 17
 
constexpr int kVelloSlot_Path = 18
 
constexpr int kVelloSlot_Tile = 19
 
constexpr int kVelloSlot_SegmentCounts = 20
 
constexpr int kVelloSlot_Segments = 21
 
constexpr int kVelloSlot_PTCL = 22
 
constexpr int kVelloSlot_OutputImage = 23
 
constexpr int kVelloSlot_GradientImage = 24
 
constexpr int kVelloSlot_ImageAtlas = 25
 
constexpr int kVelloSlot_IndirectCount = 26
 
constexpr int kVelloSlot_MaskLUT = 27
 
constexpr int kMaxComputeDataFlowSlots = 28
 
constexpr size_t kIndirectDispatchArgumentSize = sizeof(IndirectDispatchArgs)
 
static constexpr int kDescriptorTypeCount = (int)(DescriptorType::kLast) + 1
 
static constexpr int kGridCellSize = 16
 
static constexpr int kMaxBruteForceN = 64
 
static constexpr int kMaxGridSize = 32
 
static const constexpr bool kDumpAtlasData = false
 
static constexpr auto kPlotRecentlyUsedCount = 32
 
static constexpr auto kAtlasRecentlyUsedCount = 128
 
static const int kVertexAttribTypeCount = (int)(VertexAttribType::kLast) + 1
 
static constexpr int kCompareOpCount = 1 + (int)CompareOp::kNotEqual
 
static constexpr int kStencilOpCount = 1 + (int)StencilOp::kDecClamp
 
static constexpr MTLPixelFormat kMtlFormats []
 
static const skgpu::UniqueKey::Domain kGraphicsPipelineDomain = UniqueKey::GenerateDomain()
 
static const int kGraphicsPipelineKeyData32Count = 5
 
static constexpr int kDefaultOutstandingAllocCnt = 8
 
static constexpr uint32_t kDefaultAtlasDim = 4096
 
static constexpr uint32_t kSmallPathPlotWidth = 512
 
static constexpr uint32_t kSmallPathPlotHeight = 256
 
static constexpr float kSolidInterior = 1.f
 
static constexpr float kStrokeInterior = 0.f
 
static constexpr float kFilledStrokeInterior = -1.f
 
static constexpr float kComplexAAInsets = -1.f
 
static constexpr int kCornerVertexCount = 9
 
static constexpr int kVertexCount = 4 * kCornerVertexCount
 
static constexpr int kIndexCount = 69
 
static constexpr DepthStencilSettings kDirectDepthGreaterPass
 
static constexpr DepthStencilSettings kDirectDepthGEqualPass
 
constexpr DepthStencilSettings::Face kIncrementCW
 
constexpr DepthStencilSettings::Face kDecrementCCW
 
constexpr DepthStencilSettings::Face kToggle
 
constexpr DepthStencilSettings kWindingStencilPass
 
constexpr DepthStencilSettings kEvenOddStencilPass
 
constexpr DepthStencilSettings::Face kPassNonZero
 
constexpr DepthStencilSettings::Face kPassZero
 
constexpr DepthStencilSettings kRegularCoverPass
 
constexpr DepthStencilSettings kInverseCoverPass
 
static constexpr int kCornerVertexCount = 4
 
static constexpr int kVertexCount = 4 * kCornerVertexCount
 
static constexpr int kIndexCount = 29
 
static constexpr int kLoadOpCount = (int)(LoadOp::kLast) + 1
 
static constexpr int kStoreOpCount = (int)(StoreOp::kLast) + 1
 
static const int kBufferTypeCount = static_cast<int>(BufferType::kLast) + 1
 
static constexpr int kNoChildren = 0
 
static constexpr char kRuntimeShaderName [] = "RuntimeEffect"
 
static constexpr Uniform kRuntimeEffectColorSpaceTransformUniforms []
 
static constexpr size_t kReusedBufferSize = 64 << 10
 
static constexpr VkFormat kVkFormats []
 
static constexpr VkFormat kDepthStencilVkFormats []
 
static const VkAttachmentStoreOp vkStoreOp []
 
static const VkAttachmentLoadOp vkLoadOp []
 
constexpr int kMaxNumberOfCachedBufferDescSets = 1024
 

Typedef Documentation

◆ AAFlags

Definition at line 137 of file AnalyticRRectRenderStep.cpp.

◆ AddToKeyFn

using skgpu::graphite::AddToKeyFn = typedef std::function<void()>

Definition at line 97 of file PaintParams.h.

◆ BindingIndex

using skgpu::graphite::BindingIndex = typedef uint32_t

Definition at line 29 of file DispatchGroup.h.

◆ Builder

Definition at line 95 of file DispatchGroup.cpp.

◆ CompressedPaintersOrder

Definition at line 58 of file DrawOrder.h.

◆ DawnTickFunction

using skgpu::graphite::DawnTickFunction = typedef void(const wgpu::Instance& device)

WebGPU needs to allow the main thread loop to run to detect GPU progress. Dawn native has a function wgpu::Instance::ProcessEvents, not (currently) present in WebGPU, that can be used to detect GPU progress.

When compiling using Emscripten/WASM the -s ASYNCIFY option can be used to yield. E.g.:

EM_ASYNC_JS(void, asyncSleep, (), { await new Promise((resolve, _) = > { setTimeout(resolve, 0); }) });

WebGPUTickFunction(wgpu::Device&) { asyncSleep(); }

If no DawnTickFunction is provided then the graphite::Context will be "non-yielding". This implies the following restrictions on the Context:

1) SyncToCpu::kYes is disallowed as a parameter to Context::submit. 2) The client must guarantee that GPU work has completed before destroying Context as Context cannot await the work completion in its destructor. Context reports whether it is awaiting GPU work completion via Context::hasUnfinishedGpuWork().

Using a non-yielding Context makes it possible to build and run Graphite/Dawn on WebGPU without -s ASYNCIFY.

Definition at line 42 of file DawnBackendContext.h.

◆ DisjointStencilIndex

Definition at line 75 of file DrawOrder.h.

◆ DispatchResource

Definition at line 38 of file DispatchGroup.h.

◆ DispatchResourceOptional

using skgpu::graphite::DispatchResourceOptional = typedef std::variant<std::monostate, BufferView, TextureIndex, SamplerIndex>

Definition at line 39 of file DispatchGroup.h.

◆ DrawCallback

Definition at line 22 of file RecordingSurfacesTest.cpp.

◆ GpuFinishedContext

using skgpu::graphite::GpuFinishedContext = typedef void*

Definition at line 29 of file GraphiteTypes.h.

◆ GpuFinishedProc

using skgpu::graphite::GpuFinishedProc = typedef void (*)(GpuFinishedContext finishedContext, CallbackResult)

Definition at line 30 of file GraphiteTypes.h.

◆ MtlPixelFormat

using skgpu::graphite::MtlPixelFormat = typedef unsigned int

Declares typedefs for Metal types used in Graphite cpp code

Definition at line 35 of file MtlGraphiteTypes.h.

◆ MtlStorageMode

using skgpu::graphite::MtlStorageMode = typedef unsigned int

Definition at line 37 of file MtlGraphiteTypes.h.

◆ MtlTextureUsage

using skgpu::graphite::MtlTextureUsage = typedef unsigned int

Definition at line 36 of file MtlGraphiteTypes.h.

◆ PaintersDepth

Definition at line 86 of file DrawOrder.h.

◆ PrecompileChildOptions

Definition at line 110 of file FactoryFunctions.h.

◆ ResourceType

using skgpu::graphite::ResourceType = typedef uint32_t

Uniquely identifies the type of resource that is cached with a GraphiteResourceKey.

Definition at line 134 of file ResourceTypes.h.

◆ Status

Definition at line 15 of file TaskList.cpp.

◆ TextureDataCache

Definition at line 61 of file Recorder.h.

◆ UniformDataCache

Definition at line 60 of file Recorder.h.

Enumeration Type Documentation

◆ AccessPattern

enum class skgpu::graphite::AccessPattern : int
strong

Indicates the intended access pattern over resource memory. This is used to select the most efficient memory type during resource creation based on the capabilities of the platform.

This is only a hint and the actual memory type will be determined based on the resource type and backend capabilities.

Enumerator
kGpuOnly 
kHostVisible 

Definition at line 101 of file ResourceTypes.h.

101 : int {
102 // GPU-only memory does not need to support reads/writes from the CPU. GPU-private memory will
103 // be preferred if the backend supports an efficient private memory type.
104 kGpuOnly,
105
106 // The resource needs to be CPU visible, e.g. for read-back or as a copy/upload source.
107 kHostVisible,
108};

◆ BufferType

enum class skgpu::graphite::BufferType : int
strong

What a GPU buffer will be used for

Enumerator
kVertex 
kIndex 
kXferCpuToGpu 
kXferGpuToCpu 
kUniform 
kStorage 
kIndirect 
kVertexStorage 
kIndexStorage 
kLast 

Definition at line 57 of file ResourceTypes.h.

◆ BuiltInCodeSnippetID

enum class skgpu::graphite::BuiltInCodeSnippetID : int32_t
strong
Enumerator
kError 
kPriorOutput 
kSolidColorShader 
kRGBPaintColor 
kAlphaOnlyPaintColor 
kLinearGradientShader4 
kLinearGradientShader8 
kLinearGradientShaderTexture 
kLinearGradientShaderBuffer 
kRadialGradientShader4 
kRadialGradientShader8 
kRadialGradientShaderTexture 
kRadialGradientShaderBuffer 
kSweepGradientShader4 
kSweepGradientShader8 
kSweepGradientShaderTexture 
kSweepGradientShaderBuffer 
kConicalGradientShader4 
kConicalGradientShader8 
kConicalGradientShaderTexture 
kConicalGradientShaderBuffer 
kLocalMatrixShader 
kImageShader 
kCubicImageShader 
kHWImageShader 
kYUVImageShader 
kCubicYUVImageShader 
kHWYUVImageShader 
kCoordClampShader 
kDitherShader 
kPerlinNoiseShader 
kRuntimeShader 
kMatrixColorFilter 
kTableColorFilter 
kGaussianColorFilter 
kColorSpaceXformColorFilter 
kBlendShader 
kBlendModeBlender 
kCoeffBlender 
kPrimitiveColor 
kDstReadSample 
kDstReadFetch 
kClipShader 
kCompose 
kFixedFunctionClearBlendMode 
kFixedFunctionSrcBlendMode 
kFixedFunctionDstBlendMode 
kFixedFunctionSrcOverBlendMode 
kFixedFunctionDstOverBlendMode 
kFixedFunctionSrcInBlendMode 
kFixedFunctionDstInBlendMode 
kFixedFunctionSrcOutBlendMode 
kFixedFunctionDstOutBlendMode 
kFixedFunctionSrcATopBlendMode 
kFixedFunctionDstATopBlendMode 
kFixedFunctionXorBlendMode 
kFixedFunctionPlusBlendMode 
kFixedFunctionModulateBlendMode 
kFixedFunctionScreenBlendMode 
kFirstFixedFunctionBlendMode 
kLast 

Definition at line 15 of file BuiltInCodeSnippetID.h.

15 : int32_t {
16 // This isn't just a signal for a failure during paintparams key creation. It also actually
17 // implements the default behavior for an erroneous draw. Currently it just draws solid
18 // magenta.
19 kError,
20
21 // Snippet that passes through prior stage output
23
24 // SkShader code snippets
44
56
57 // SkColorFilter code snippets
62
63 // SkBlender code snippets
67
68 // Emits special variable holding the primitiveColor emitted by a RenderStep
70
71 // Dest Read code snippets
74
75 // Clip shader snippet
76 // TODO(b/238763003): Avoid incorporating clip shaders into the actual shader code.
78
79 kCompose,
80
81 // Fixed-function blend modes are used for the final blend with the dst buffer's color when the
82 // SkPaint is using a coefficient-based SkBlendMode. The actual coefficients are extracted into
83 // the SkBlendInfo associated with each pipeline, but a unique code snippet ID is assigned so
84 // that the pipeline keys remain distinct. They are ordered to match SkBlendMode such
85 // that (id - kFirstFixedFunctionBlendMode) == SkBlendMode).
86 //
87 // NOTE: Pipeline code generation depends on the fixed-function code IDs being contiguous and
88 // be defined last in the enum.
104
107};

◆ ClearBuffer

enum class skgpu::graphite::ClearBuffer : bool
strong

Determines whether the contents of a GPU buffer sub-allocation gets cleared to 0 before being used in a GPU command submission.

Enumerator
kNo 
kYes 

Definition at line 114 of file ResourceTypes.h.

114 : bool {
115 kNo = false,
116 kYes = true,
117};
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.

◆ CompareOp

enum class skgpu::graphite::CompareOp : uint8_t
strong
Enumerator
kAlways 
kNever 
kGreater 
kGEqual 
kLess 
kLEqual 
kEqual 
kNotEqual 

Definition at line 149 of file DrawTypes.h.

149 : uint8_t {
150 kAlways,
151 kNever,
152 kGreater,
153 kGEqual,
154 kLess,
155 kLEqual,
156 kEqual,
157 kNotEqual
158};
constexpr auto kNever
Definition: SkSLTest.cpp:963

◆ Coverage

enum class skgpu::graphite::Coverage
strong
Enumerator
kNone 
kSingleChannel 
kLCD 

Definition at line 43 of file Renderer.h.

◆ DawnErrorType

enum class skgpu::graphite::DawnErrorType : uint32_t
strong
Enumerator
kNoError 
kValidation 
kOutOfMemory 
kInternal 

Definition at line 21 of file DawnErrorChecker.h.

21 : uint32_t {
22 kNoError = 0b00000000,
23 kValidation = 0b00000001,
24 kOutOfMemory = 0b00000010,
25 kInternal = 0b00000100,
26};
const int kNoError

◆ DepthStencilFlags

Enumerator
kNone 
kDepth 
kStencil 
kDepthStencil 

Definition at line 23 of file ResourceTypes.h.

◆ DescriptorType

enum class skgpu::graphite::DescriptorType : uint8_t
strong

Types of descriptors supported within graphite

Enumerator
kUniformBuffer 
kTextureSampler 
kTexture 
kCombinedTextureSampler 
kStorageBuffer 
kInputAttachment 
kLast 

Definition at line 20 of file DescriptorData.h.

20 : uint8_t {
21 kUniformBuffer = 0,
23 kTexture,
25 kStorageBuffer,
26 kInputAttachment,
27
28 kLast = kInputAttachment,
29};

◆ Discardable

enum class skgpu::graphite::Discardable : bool
strong

Must the contents of the Resource be preserved af a render pass or can a more efficient representation be chosen when supported by hardware.

Enumerator
kNo 
kYes 

Definition at line 123 of file ResourceTypes.h.

123 : bool {
124 kNo = false,
125 kYes = true
126};

◆ DrawTypeFlags

Enumerator
kNone 
kText 
kDrawVertices 
kSimpleShape 
kNonSimpleShape 
kShape 
kMostCommon 
kAll 

Definition at line 110 of file GraphiteTypes.h.

110 : uint8_t {
111
112 kNone = 0b0000,
113
114 // SkCanvas:: drawSimpleText, drawString, drawGlyphs, drawTextBlob, drawSlug
115 kText = 0b0001,
116
117 // SkCanvas::drawVertices
118 kDrawVertices = 0b0010,
119
120 // SkCanvas::experimental_DrawEdgeAAQuad, experimental_DrawEdgeAAImageSet
121 // SkCanvas:: drawRect, drawRRect, drawLine for:
122 // regular filled and hairline [r]rects,
123 // stroked rects,
124 // stroked and hairline lines,
125 // stroked circular rrects
126 // Note: clipping can bump a draw out of the simple shape path
127 kSimpleShape = 0b0100,
128 // All other shapes (e.g., any strokeAndFill shape, non-circular-stroked RRects, SkPaths, ...)
129 kNonSimpleShape = 0b1000,
130
132
134 kAll = kText | kDrawVertices | kShape
135};

◆ DstColorType

enum class skgpu::graphite::DstColorType
strong
Enumerator
kSurface 
kPrimitive 
kChildOutput 

Definition at line 42 of file KeyHelpers.h.

42 {
43 // A color read from the framebuffer.
44 kSurface,
45 // A color provided by geometry.
47 // A color evaluated by a child shader.
49};

◆ DstReadRequirement

Enumerator
kNone 
kTextureCopy 
kTextureSample 
kFramebufferFetch 

Definition at line 64 of file Caps.h.

◆ LastRemovedRef

This enum is used to notify the ResourceCache which type of ref just dropped to zero on a Resource.

Enumerator
kUsage 
kCommandBuffer 
kCache 

Definition at line 149 of file ResourceTypes.h.

◆ Layout

enum class skgpu::graphite::Layout
strong

Data layout requirements on host-shareable buffer contents.

Enumerator
kInvalid 
kStd140 
kStd430 
kMetal 

Definition at line 77 of file ResourceTypes.h.

77 {
78 kInvalid = 0,
79 kStd140,
80 kStd430,
81 kMetal,
82};
@ kInvalid
@ kMetal
Definition: embedder.h:85

◆ LoadOp

enum class skgpu::graphite::LoadOp : uint8_t
strong

This enum is used to specify the load operation to be used when a RenderPass begins execution

Enumerator
kLoad 
kClear 
kDiscard 
kLast 

Definition at line 34 of file ResourceTypes.h.

34 : uint8_t {
35 kLoad,
36 kClear,
38
39 kLast = kDiscard
40};

◆ Ownership

enum class skgpu::graphite::Ownership
strong
Enumerator
kOwned 
kWrapped 

Definition at line 128 of file ResourceTypes.h.

◆ PathRendererStrategy

Used to include or exclude a specific path rendering technique for testing purposes.

Enumerator
kDefault 

Graphite selects the best path rendering technique for each shape. This is the default behavior.

kComputeAnalyticAA 

All paths are rasterized into coverage masks using a GPU compute approach. This method always uses analytic anti-aliasing.

kComputeMSAA16 

All paths are rasterized into coverage masks using a GPU compute approach. This method supports 16 and 8 sample multi-sampled anti-aliasing.

kComputeMSAA8 
kRasterAA 

All paths are rasterized into coverage masks using the CPU raster backend.

kTessellation 

Render paths using tessellation and stencil-and-cover.

Definition at line 16 of file ContextOptionsPriv.h.

16 {
17 /**
18 * Graphite selects the best path rendering technique for each shape. This is the default
19 * behavior.
20 */
22
23 /**
24 * All paths are rasterized into coverage masks using a GPU compute approach. This method
25 * always uses analytic anti-aliasing.
26 */
28
29 /**
30 * All paths are rasterized into coverage masks using a GPU compute approach. This method
31 * supports 16 and 8 sample multi-sampled anti-aliasing.
32 */
35
36 /**
37 * All paths are rasterized into coverage masks using the CPU raster backend.
38 */
40
41 /**
42 * Render paths using tessellation and stencil-and-cover.
43 */
45};
@ kDefault

◆ PipelineStageFlags

enum class skgpu::graphite::PipelineStageFlags : uint8_t
strong
Enumerator
kVertexShader 
kFragmentShader 
kCompute 

Definition at line 32 of file DescriptorData.h.

32 : uint8_t {
33 kVertexShader = 0b001,
34 kFragmentShader = 0b010,
35 kCompute = 0b100,
36};

◆ PrecompileImageShaderFlags

Enumerator
kNone 
kExcludeAlpha 
kExcludeCubic 

Definition at line 18 of file PrecompileShadersPriv.h.

◆ PrimitiveType

enum class skgpu::graphite::PrimitiveType : uint8_t
strong

Geometric primitives used for drawing.

Enumerator
kTriangles 
kTriangleStrip 
kPoints 

Definition at line 24 of file DrawTypes.h.

24 : uint8_t {
25 kTriangles,
26 kTriangleStrip,
27 kPoints,
28};
static const SkPoint kPoints[kNumLabels]
Definition: flippity.cpp:53

◆ Priority

enum class skgpu::graphite::Priority : int
strong
Enumerator
kFatal 
kError 
kWarning 
kDebug 

Definition at line 12 of file Log.h.

12 : int {
13 kFatal = 0,
14 kError = 1,
15 kWarning = 2,
16 kDebug = 3,
17};

◆ ReadSwizzle

enum class skgpu::graphite::ReadSwizzle
strong

Enumerate the few possible read and write swizzle options for smaller storage.

Enumerator
kRGBA 
kRGB1 
kRRR1 
kBGRA 
k000R 

Definition at line 15 of file ReadSwizzle.h.

◆ Shareable

enum class skgpu::graphite::Shareable : bool
strong

Can the resource be held by multiple users at the same time? For example, stencil buffers, pipelines, etc.

Enumerator
kNo 
kYes 

Definition at line 140 of file ResourceTypes.h.

140 : bool {
141 kNo = false,
142 kYes = true,
143};

◆ SnippetRequirementFlags

enum class skgpu::graphite::SnippetRequirementFlags : uint32_t
strong
Enumerator
kNone 
kLocalCoords 
kPriorStageOutput 
kBlenderDstColor 
kSurfaceColor 
kGradientBuffer 
kStoresData 

Definition at line 59 of file ShaderCodeDictionary.h.

59 : uint32_t {
60 kNone = 0x0,
61 kLocalCoords = 0x1,
62 kPriorStageOutput = 0x2, // AKA the "input" color, or the "src" argument for a blender
63 kBlenderDstColor = 0x4, // The "dst" argument for a blender
64 kSurfaceColor = 0x8,
65 kGradientBuffer = 0x10,
66 kStoresData = 0x20, // Indicates that the node stores numerical data
67};

◆ StencilOp

enum class skgpu::graphite::StencilOp : uint8_t
strong
Enumerator
kKeep 
kZero 
kReplace 
kInvert 
kIncWrap 
kDecWrap 
kIncClamp 
kDecClamp 

Definition at line 161 of file DrawTypes.h.

161 : uint8_t {
162 kKeep,
163 kZero,
164 kReplace, // Replace stencil value with reference (only the bits enabled in fWriteMask).
165 kInvert,
166 kIncWrap,
167 kDecWrap,
168 // NOTE: clamping occurs before the write mask. So if the MSB is zero and masked out, stencil
169 // values will still wrap when using clamping ops.
170 kIncClamp,
172};

◆ StoreOp

enum class skgpu::graphite::StoreOp : uint8_t
strong

This enum is used to specify the store operation to be used when a RenderPass ends execution.

Enumerator
kStore 
kDiscard 
kLast 

Definition at line 46 of file ResourceTypes.h.

46 : uint8_t {
47 kStore,
49
50 kLast = kDiscard
51};

◆ SyncToCpu

enum class skgpu::graphite::SyncToCpu : bool
strong

Actually submit work to the GPU and track its completion

Enumerator
kYes 
kNo 

Definition at line 92 of file GraphiteTypes.h.

92 : bool {
93 kYes = true,
94 kNo = false
95};

◆ UniformSlot

enum class skgpu::graphite::UniformSlot
strong
Enumerator
kRenderStep 
kPaint 
kGradient 

Definition at line 134 of file DrawTypes.h.

134 {
135 // TODO: Want this?
136 // Meant for uniforms that change rarely to never over the course of a render pass
137 // kStatic,
138 // Meant for uniforms that are defined and used by the RenderStep portion of the pipeline shader
140 // Meant for uniforms that are defined and used by the paint parameters (ie SkPaint subset)
141 kPaint,
142 // Meant for gradient storage buffer.
144};

◆ VelloAaConfig

enum class skgpu::graphite::VelloAaConfig
strong
Enumerator
kAnalyticArea 
kMSAA16 
kMSAA8 

Definition at line 65 of file VelloRenderer.h.

◆ VertexAttribType

enum class skgpu::graphite::VertexAttribType : uint8_t
strong

Types used to describe format of vertices in buffers.

Enumerator
kFloat 
kFloat2 
kFloat3 
kFloat4 
kHalf 
kHalf2 
kHalf4 
kInt2 
kInt3 
kInt4 
kByte 
kByte2 
kByte4 
kUByte 
kUByte2 
kUByte4 
kUByte_norm 
kUByte4_norm 
kShort2 
kShort4 
kUShort2 
kUShort2_norm 
kInt 
kUInt 
kUShort_norm 
kUShort4_norm 
kLast 

Definition at line 33 of file DrawTypes.h.

33 : uint8_t {
34 kFloat = 0,
35 kFloat2,
36 kFloat3,
37 kFloat4,
38 kHalf,
39 kHalf2,
40 kHalf4,
41
42 kInt2, // vector of 2 32-bit ints
43 kInt3, // vector of 3 32-bit ints
44 kInt4, // vector of 4 32-bit ints
45
46 kByte, // signed byte
47 kByte2, // vector of 2 8-bit signed bytes
48 kByte4, // vector of 4 8-bit signed bytes
49 kUByte, // unsigned byte
50 kUByte2, // vector of 2 8-bit unsigned bytes
51 kUByte4, // vector of 4 8-bit unsigned bytes
52
53 kUByte_norm, // unsigned byte, e.g. coverage, 0 -> 0.0f, 255 -> 1.0f.
54 kUByte4_norm, // vector of 4 unsigned bytes, e.g. colors, 0 -> 0.0f, 255 -> 1.0f.
55
56 kShort2, // vector of 2 16-bit shorts.
57 kShort4, // vector of 4 16-bit shorts.
58
59 kUShort2, // vector of 2 unsigned shorts. 0 -> 0, 65535 -> 65535.
60 kUShort2_norm, // vector of 2 unsigned shorts. 0 -> 0.0f, 65535 -> 1.0f.
61
62 kInt,
63 kUInt,
64
65 kUShort_norm, // unsigned short, e.g. depth, 0 -> 0.0f, 65535 -> 1.0f.
66
67 kUShort4_norm, // vector of 4 unsigned shorts. 0 -> 0.0f, 65535 -> 1.0f.
68
69 kLast = kUShort4_norm
70};

◆ Volatile

enum class skgpu::graphite::Volatile : bool
strong
Enumerator
kNo 
kYes 

Definition at line 101 of file GraphiteTypes.h.

101 : bool {
102 kNo = false, // only fulfilled once
103 kYes = true // fulfilled on every insertion call
104};

Function Documentation

◆ add_gradient_to_key() [1/5]

static void skgpu::graphite::add_gradient_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkConicalGradient shader 
)
static

Definition at line 2327 of file KeyHelpers.cpp.

2330 {
2331 SkScalar r0 = shader->getStartRadius();
2332 SkScalar r1 = shader->getEndRadius();
2333
2334 if (shader->getType() != SkConicalGradient::Type::kRadial) {
2335 // Since we map the centers to be (0,0) and (1,0) in the gradient matrix,
2336 // there is a scale of 1/distance-between-centers that has to be applied to the radii.
2337 r0 /= shader->getCenterX1();
2338 r1 /= shader->getCenterX1();
2339 } else {
2340 r0 /= shader->getDiffRadius();
2341 r1 /= shader->getDiffRadius();
2342 }
2343
2344 add_gradient_to_key(keyContext,
2345 builder,
2346 gatherer,
2347 shader,
2348 shader->getStartCenter(),
2349 shader->getEndCenter(),
2350 r0,
2351 r1,
2352 0.0f,
2353 0.0f);
2354}
const SkPoint & getEndCenter() const
SkScalar getEndRadius() const
const SkPoint & getStartCenter() const
Type getType() const
SkScalar getDiffRadius() const
SkScalar getCenterX1() const
SkScalar getStartRadius() const
float SkScalar
Definition: extension.cpp:12
static void add_gradient_to_key(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkSweepGradient *shader)

◆ add_gradient_to_key() [2/5]

static void skgpu::graphite::add_gradient_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkGradientBaseShader shader,
SkPoint  point0,
SkPoint  point1,
float  radius0,
float  radius1,
float  bias,
float  scale 
)
static

Definition at line 2262 of file KeyHelpers.cpp.

2271 {
2272 SkColor4fXformer xformedColors(shader, keyContext.dstColorInfo().colorSpace());
2273 const SkPMColor4f* colors = xformedColors.fColors.begin();
2274 const float* positions = xformedColors.fPositions;
2275 const int colorCount = xformedColors.fColors.size();
2276
2277 sk_sp<TextureProxy> proxy;
2278
2279 bool useStorageBuffer = keyContext.caps()->storageBufferSupport() &&
2280 keyContext.caps()->storageBufferPreferred();
2281 if (colorCount > GradientShaderBlocks::GradientData::kNumInternalStorageStops
2282 && !useStorageBuffer) {
2283 if (shader->cachedBitmap().empty()) {
2284 SkBitmap colorsAndOffsetsBitmap =
2285 create_color_and_offset_bitmap(colorCount, colors, positions);
2286 if (colorsAndOffsetsBitmap.empty()) {
2287 SKGPU_LOG_W("Couldn't create GradientShader's color and offset bitmap");
2289 return;
2290 }
2291 shader->setCachedBitmap(colorsAndOffsetsBitmap);
2292 }
2293
2294 proxy = RecorderPriv::CreateCachedProxy(keyContext.recorder(), shader->cachedBitmap(),
2295 "GradientTexture");
2296 if (!proxy) {
2297 SKGPU_LOG_W("Couldn't create GradientShader's color and offset bitmap proxy");
2299 return;
2300 }
2301 }
2302
2303 GradientShaderBlocks::GradientData data(shader->asGradient(),
2304 point0,
2305 point1,
2306 radius0,
2307 radius1,
2308 bias,
2309 scale,
2310 shader->getTileMode(),
2311 colorCount,
2312 colors,
2313 positions,
2314 shader,
2315 std::move(proxy),
2316 useStorageBuffer,
2317 shader->getInterpolation());
2318
2319 make_interpolated_to_dst(keyContext,
2320 builder,
2321 gatherer,
2322 data,
2323 shader->getInterpolation(),
2324 xformedColors.fIntermediateColorSpace.get());
2325}
static std::unique_ptr< GrFragmentProcessor > make_interpolated_to_dst(std::unique_ptr< GrFragmentProcessor > gradient, const SkGradientShader::Interpolation &interpolation, SkColorSpace *intermediateColorSpace, const GrColorInfo &dstInfo, bool allOpaque)
#define SKGPU_LOG_W(fmt,...)
Definition: Log.h:40
bool empty() const
Definition: SkBitmap.h:210
SkColorSpace * colorSpace() const
Definition: SkImageInfo.cpp:66
const Interpolation & getInterpolation() const
void setCachedBitmap(SkBitmap b) const
const SkBitmap & cachedBitmap() const
SkTileMode getTileMode() const
virtual GradientType asGradient(GradientInfo *info=nullptr, SkMatrix *localMatrix=nullptr) const
Definition: SkShaderBase.h:255
bool storageBufferPreferred() const
Definition: Caps.h:239
bool storageBufferSupport() const
Definition: Caps.h:235
Recorder * recorder() const
Definition: KeyContext.h:57
const SkColorInfo & dstColorInfo() const
Definition: KeyContext.h:67
const Caps * caps() const
Definition: KeyContext.h:59
PODArray< SkColor > colors
Definition: SkRecords.h:276
static SkBitmap create_color_and_offset_bitmap(int numStops, const SkPMColor4f *colors, const float *offsets)
const Scalar scale
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ add_gradient_to_key() [3/5]

static void skgpu::graphite::add_gradient_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkLinearGradient shader 
)
static

Definition at line 2356 of file KeyHelpers.cpp.

2359 {
2360 add_gradient_to_key(keyContext,
2361 builder,
2362 gatherer,
2363 shader,
2364 shader->start(),
2365 shader->end(),
2366 0.0f,
2367 0.0f,
2368 0.0f,
2369 0.0f);
2370}
const SkPoint & start() const
const SkPoint & end() const

◆ add_gradient_to_key() [4/5]

static void skgpu::graphite::add_gradient_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkRadialGradient shader 
)
static

Definition at line 2372 of file KeyHelpers.cpp.

2375 {
2376 add_gradient_to_key(keyContext,
2377 builder,
2378 gatherer,
2379 shader,
2380 shader->center(),
2381 { 0.0f, 0.0f },
2382 shader->radius(),
2383 0.0f,
2384 0.0f,
2385 0.0f);
2386}
SkScalar radius() const
const SkPoint & center() const

◆ add_gradient_to_key() [5/5]

static void skgpu::graphite::add_gradient_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkSweepGradient shader 
)
static

Definition at line 2388 of file KeyHelpers.cpp.

2391 {
2392 add_gradient_to_key(keyContext,
2393 builder,
2394 gatherer,
2395 shader,
2396 shader->center(),
2397 { 0.0f, 0.0f },
2398 0.0f,
2399 0.0f,
2400 shader->tBias(),
2401 shader->tScale());
2402}
SkScalar tBias() const
SkScalar tScale() const
const SkPoint & center() const

◆ add_to_key() [1/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkBlendModeColorFilter filter 
)
static

Definition at line 1307 of file KeyHelpers.cpp.

1310 {
1311 SkASSERT(filter);
1312
1314 keyContext.dstColorInfo().colorSpace());
1315
1316 AddBlendModeColorFilter(keyContext, builder, gatherer, filter->mode(), color);
1317}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static SkRGBA4f< kDstAT > map_color(const SkColor4f &c, SkColorSpace *src, SkColorSpace *dst)
SkColorSpace * sk_srgb_singleton()
DlColor color
void AddBlendModeColorFilter(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm, const SkPMColor4f &srcColor)

◆ add_to_key() [2/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkBlendShader shader 
)
static

Definition at line 1497 of file KeyHelpers.cpp.

1500 {
1501 SkASSERT(shader);
1502
1503 Blend(keyContext, builder, gatherer,
1504 /* addBlendToKey= */ [&] () -> void {
1505 AddModeBlend(keyContext, builder, gatherer, shader->mode());
1506 },
1507 /* addSrcToKey= */ [&]() -> void {
1508 AddToKey(keyContext, builder, gatherer, shader->src().get());
1509 },
1510 /* addDstToKey= */ [&]() -> void {
1511 AddToKey(keyContext, builder, gatherer, shader->dst().get());
1512 });
1513}
sk_sp< SkShader > dst() const
Definition: SkBlendShader.h:30
SkBlendMode mode() const
Definition: SkBlendShader.h:32
sk_sp< SkShader > src() const
Definition: SkBlendShader.h:31
T * get() const
Definition: SkRefCnt.h:303
void AddToKey(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkShader *shader)
void AddModeBlend(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)

◆ add_to_key() [3/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkColor4Shader shader 
)
static

Definition at line 1555 of file KeyHelpers.cpp.

1558 {
1559 SkASSERT(shader);
1560
1561 SkPMColor4f color = map_color(shader->color(), shader->colorSpace().get(),
1562 keyContext.dstColorInfo().colorSpace());
1563
1564 SolidColorShaderBlock::AddBlock(keyContext, builder, gatherer, color);
1565}
SkColor4f color() const
Definition: SkColorShader.h:67
sk_sp< SkColorSpace > colorSpace() const
Definition: SkColorShader.h:66

◆ add_to_key() [4/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkColorFilterShader shader 
)
static

Definition at line 1570 of file KeyHelpers.cpp.

1573 {
1574 SkASSERT(shader);
1575
1576 Compose(keyContext, builder, gatherer,
1577 /* addInnerToKey= */ [&]() -> void {
1578 AddToKey(keyContext, builder, gatherer, shader->shader().get());
1579 },
1580 /* addOuterToKey= */ [&]() -> void {
1581 AddToKey(keyContext, builder, gatherer, shader->filter().get());
1582 });
1583}
sk_sp< SkColorFilterBase > filter() const
sk_sp< SkShader > shader() const
SK_API sk_sp< PrecompileColorFilter > Compose(SkSpan< const sk_sp< PrecompileColorFilter > > outer, SkSpan< const sk_sp< PrecompileColorFilter > > inner)

◆ add_to_key() [5/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkColorShader shader 
)
static

Definition at line 1542 of file KeyHelpers.cpp.

1545 {
1546 SkASSERT(shader);
1547
1548 SolidColorShaderBlock::AddBlock(keyContext, builder, gatherer,
1549 SkColor4f::FromColor(shader->color()).premul());
1550}
SkColor color() const
Definition: SkColorShader.h:39

◆ add_to_key() [6/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkColorSpaceXformColorFilter filter 
)
static

Definition at line 1319 of file KeyHelpers.cpp.

1322 {
1323 SkASSERT(filter);
1324
1325 constexpr SkAlphaType kAlphaType = kPremul_SkAlphaType;
1326 ColorSpaceTransformBlock::ColorSpaceTransformData csData(filter->src().get(), kAlphaType,
1327 filter->dst().get(), kAlphaType);
1328 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, csData);
1329}
SkAlphaType
Definition: SkAlphaType.h:26
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
sk_sp< SkColorSpace > dst() const
sk_sp< SkColorSpace > src() const

◆ add_to_key() [7/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkCoordClampShader shader 
)
static

Definition at line 1591 of file KeyHelpers.cpp.

1594 {
1595 SkASSERT(shader);
1596
1598
1599 KeyContextWithCoordClamp childContext(keyContext);
1600 CoordClampShaderBlock::BeginBlock(keyContext, builder, gatherer, data);
1601 AddToKey(childContext, builder, gatherer, shader->shader().get());
1602 builder->endBlock();
1603}
SkRect subset() const
sk_sp< SkShader > shader() const

◆ add_to_key() [8/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkCTMShader shader 
)
static

Definition at line 1522 of file KeyHelpers.cpp.

1525 {
1526 // CTM shaders are always given device coordinates, so we don't have to modify the CTM itself
1527 // with keyContext's local transform.
1528 LocalMatrixShaderBlock::LMShaderData lmShaderData(shader->ctm());
1529
1530 KeyContextWithLocalMatrix newContext(keyContext, shader->ctm());
1531
1532 LocalMatrixShaderBlock::BeginBlock(newContext, builder, gatherer, lmShaderData);
1533
1534 AddToKey(newContext, builder, gatherer, shader->proxyShader().get());
1535
1536 builder->endBlock();
1537}
const SkMatrix & ctm() const
sk_sp< SkShader > proxyShader() const

◆ add_to_key() [9/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkEmptyShader  
)
static

Definition at line 1610 of file KeyHelpers.cpp.

1613 {
1614 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
1615}

◆ add_to_key() [10/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkGaussianColorFilter  
)
static

Definition at line 1346 of file KeyHelpers.cpp.

1349 {
1350 builder->addBlock(BuiltInCodeSnippetID::kGaussianColorFilter);
1351}

◆ add_to_key() [11/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkGradientBaseShader shader 
)
static

Definition at line 2404 of file KeyHelpers.cpp.

2407 {
2408 SkASSERT(shader);
2409 switch (shader->asGradient()) {
2410#define M(type) \
2411 case SkShaderBase::GradientType::k##type: \
2412 add_gradient_to_key(keyContext, \
2413 builder, \
2414 gatherer, \
2415 static_cast<const Sk##type##Gradient*>(shader)); \
2416 return;
2418#undef M
2420 SkDEBUGFAIL("Gradient shader says its type is none");
2421 return;
2422 }
2424}
#define M(type)
#define SkUNREACHABLE
Definition: SkAssert.h:135
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SK_ALL_GRADIENTS(M)
Definition: SkShaderBase.h:180

◆ add_to_key() [12/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkImageShader shader 
)
static

Definition at line 1775 of file KeyHelpers.cpp.

1778 {
1779 SkASSERT(shader);
1780
1781 auto [ imageToDraw, newSampling ] = GetGraphiteBacked(keyContext.recorder(),
1782 shader->image().get(),
1783 shader->sampling());
1784 if (!imageToDraw) {
1785 SKGPU_LOG_W("Couldn't convert ImageShader's image to a Graphite-backed image");
1787 return;
1788 }
1789 if (!as_IB(shader->image())->isGraphiteBacked()) {
1790 // GetGraphiteBacked() created a new image (or fetched a cached image) from the client
1791 // image provider. This image was not available when NotifyInUse() visited the shader tree,
1792 // so call notify again. These images shouldn't really be producing new tasks since it's
1793 // unlikely that a client will be fulfilling with a dynamic image that wraps a long-lived
1794 // SkSurface. However, the images can be linked to a surface that rendered the initial
1795 // content and not calling notifyInUse() prevents unlinking the image from the Device.
1796 // If the client image provider then holds on to many of these images, the leaked Device and
1797 // DrawContext memory can be surprisingly high. b/338453542.
1798 // TODO (b/330864257): Once paint keys are extracted at draw time, AddToKey() will be
1799 // fully responsible for notifyInUse() calls and then we can simply always call this on
1800 // `imageToDraw`. The DrawContext that samples the image will also be available to AddToKey
1801 // so we won't have to pass in nullptr.
1802 SkASSERT(as_IB(imageToDraw)->isGraphiteBacked());
1803 static_cast<Image_Base*>(imageToDraw.get())->notifyInUse(keyContext.recorder(),
1804 /*drawContext=*/nullptr);
1805 }
1806 if (as_IB(imageToDraw)->isYUVA()) {
1807 return add_yuv_image_to_key(keyContext,
1808 builder,
1809 gatherer,
1810 shader,
1811 std::move(imageToDraw),
1812 newSampling);
1813 }
1814
1815 auto view = AsView(imageToDraw.get());
1816 SkASSERT(newSampling.mipmap == SkMipmapMode::kNone || view.mipmapped() == Mipmapped::kYes);
1817
1818 ImageShaderBlock::ImageData imgData(shader->sampling(),
1819 shader->tileModeX(),
1820 shader->tileModeY(),
1821 view.proxy()->dimensions(),
1822 shader->subset(),
1824
1825 // Here we detect pixel aligned blit-like image draws. Some devices have low precision filtering
1826 // and will produce degraded (blurry) images unexpectedly for sequential exact pixel blits when
1827 // not using nearest filtering. This is common for canvas scrolling implementations. Forcing
1828 // nearest filtering when possible can also be a minor perf/power optimization depending on the
1829 // hardware.
1830 bool samplingHasNoEffect = false;
1831 // Cubic sampling is will not filter the same as nearest even when pixel aligned.
1832 if (keyContext.optimizeSampling() == KeyContext::OptimizeSampling::kYes &&
1833 !newSampling.useCubic) {
1834 SkMatrix totalM = keyContext.local2Dev().asM33();
1835 if (keyContext.localMatrix()) {
1836 totalM.preConcat(*keyContext.localMatrix());
1837 }
1838 totalM.normalizePerspective();
1839 // The matrix should be translation with only pixel aligned 2d translation.
1840 samplingHasNoEffect = totalM.isTranslate() && SkScalarIsInt(totalM.getTranslateX()) &&
1841 SkScalarIsInt(totalM.getTranslateY());
1842 }
1843
1844 imgData.fSampling = samplingHasNoEffect ? SkFilterMode::kNearest : newSampling;
1845 imgData.fTextureProxy = view.refProxy();
1846 skgpu::Swizzle readSwizzle = view.swizzle();
1847 // If the color type is alpha-only, propagate the alpha value to the other channels.
1848 if (imageToDraw->isAlphaOnly()) {
1849 readSwizzle = skgpu::Swizzle::Concat(readSwizzle, skgpu::Swizzle("000a"));
1850 }
1851 imgData.fReadSwizzle = swizzle_class_to_read_enum(readSwizzle);
1852
1853 if (!shader->isRaw()) {
1854 imgData.fSteps = SkColorSpaceXformSteps(imageToDraw->colorSpace(),
1855 imageToDraw->alphaType(),
1856 keyContext.dstColorInfo().colorSpace(),
1857 keyContext.dstColorInfo().alphaType());
1858
1859 if (imageToDraw->isAlphaOnly() && keyContext.scope() != KeyContext::Scope::kRuntimeEffect) {
1860 Blend(keyContext, builder, gatherer,
1861 /* addBlendToKey= */ [&] () -> void {
1862 AddKnownModeBlend(keyContext, builder, gatherer, SkBlendMode::kDstIn);
1863 },
1864 /* addSrcToKey= */ [&] () -> void {
1865 ImageShaderBlock::AddBlock(keyContext, builder, gatherer, imgData);
1866 },
1867 /* addDstToKey= */ [&]() -> void {
1868 RGBPaintColorBlock::AddBlock(keyContext, builder, gatherer);
1869 });
1870 return;
1871 }
1872 }
1873
1874 ImageShaderBlock::AddBlock(keyContext, builder, gatherer, imgData);
1875}
@ kDstIn
r = d * sa
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
static bool SkScalarIsInt(SkScalar x)
Definition: SkScalar.h:80
SkAlphaType alphaType() const
Definition: SkImageInfo.h:141
SkSamplingOptions sampling() const
Definition: SkImageShader.h:69
SkTileMode tileModeX() const
Definition: SkImageShader.h:66
sk_sp< SkImage > image() const
Definition: SkImageShader.h:68
bool isRaw() const
Definition: SkImageShader.h:71
SkTileMode tileModeY() const
Definition: SkImageShader.h:67
SkRect subset() const
Definition: SkImageShader.h:70
bool isYUVA() const
Definition: SkImage_Base.h:164
bool isGraphiteBacked() const
Definition: SkImage_Base.h:160
SkMatrix asM33() const
Definition: SkM44.h:409
SkScalar getTranslateY() const
Definition: SkMatrix.h:452
bool isTranslate() const
Definition: SkMatrix.h:248
SkMatrix & preConcat(const SkMatrix &other)
Definition: SkMatrix.cpp:674
void normalizePerspective()
Definition: SkMatrix.h:1270
SkScalar getTranslateX() const
Definition: SkMatrix.h:445
static constexpr Swizzle Concat(const Swizzle &a, const Swizzle &b)
Definition: Swizzle.h:156
const SkM44 & local2Dev() const
Definition: KeyContext.h:61
const SkMatrix * localMatrix() const
Definition: KeyContext.h:62
OptimizeSampling optimizeSampling() const
Definition: KeyContext.h:82
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
void AddKnownModeBlend(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)
static void add_yuv_image_to_key(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkImageShader *origShader, sk_sp< const SkImage > imageToDraw, SkSamplingOptions sampling)
std::pair< sk_sp< SkImage >, SkSamplingOptions > GetGraphiteBacked(Recorder *recorder, const SkImage *imageIn, SkSamplingOptions sampling)
static skgpu::graphite::ReadSwizzle swizzle_class_to_read_enum(const skgpu::Swizzle &swizzle)

◆ add_to_key() [13/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkLocalMatrixShader shader 
)
static

Definition at line 1888 of file KeyHelpers.cpp.

1891 {
1892 SkASSERT(shader);
1893 auto wrappedShader = shader->wrappedShader().get();
1894
1895 // Fold the texture's origin flip into the local matrix so that the image shader doesn't need
1896 // additional state
1898 SkShaderBase* wrappedShaderBase = as_SB(wrappedShader);
1899 if (wrappedShaderBase->type() == SkShaderBase::ShaderType::kImage) {
1900 auto imgShader = static_cast<const SkImageShader*>(wrappedShader);
1901 // If the image is not graphite backed then we can assume the origin will be TopLeft as we
1902 // require that in the ImageProvider utility. Also Graphite YUV images are assumed to be
1903 // TopLeft origin.
1904 // TODO (b/336788317): Fold YUVAImage's origin into this matrix as well.
1905 auto imgBase = as_IB(imgShader->image());
1906 if (imgBase->isGraphiteBacked() && !imgBase->isYUVA()) {
1907 auto imgGraphite = static_cast<Image*>(imgBase);
1908 SkASSERT(imgGraphite);
1909 const auto& view = imgGraphite->textureProxyView();
1910 if (view.origin() == Origin::kBottomLeft) {
1911 matrix.setScaleY(-1);
1912 matrix.setTranslateY(view.height());
1913 }
1914 }
1915 } else if (wrappedShaderBase->type() == SkShaderBase::ShaderType::kGradientBase) {
1916 auto gradShader = static_cast<const SkGradientBaseShader*>(wrappedShader);
1917 auto gradMatrix = gradShader->getGradientMatrix();
1918
1919 // Override the conical gradient matrix since graphite uses a different algorithm
1920 // than the ganesh and raster backends.
1921 if (gradShader->asGradient() == SkShaderBase::GradientType::kConical) {
1922 auto conicalShader = static_cast<const SkConicalGradient*>(gradShader);
1923
1924 SkMatrix conicalMatrix;
1925 if (conicalShader->getType() == SkConicalGradient::Type::kRadial) {
1926 SkPoint center = conicalShader->getStartCenter();
1927 conicalMatrix.postTranslate(-center.fX, -center.fY);
1928
1929 float scale = sk_ieee_float_divide(1, conicalShader->getDiffRadius());
1930 conicalMatrix.postScale(scale, scale);
1931 } else {
1932 SkAssertResult(SkConicalGradient::MapToUnitX(conicalShader->getStartCenter(),
1933 conicalShader->getEndCenter(),
1934 &conicalMatrix));
1935 }
1936 gradMatrix = conicalMatrix;
1937 }
1938
1939 SkMatrix invGradMatrix;
1940 SkAssertResult(gradMatrix.invert(&invGradMatrix));
1941
1942 matrix.postConcat(invGradMatrix);
1943 }
1944
1945 matrix.postConcat(shader->localMatrix());
1946 LocalMatrixShaderBlock::LMShaderData lmShaderData(matrix);
1947
1948 KeyContextWithLocalMatrix newContext(keyContext, matrix);
1949
1950 LocalMatrixShaderBlock::BeginBlock(newContext, builder, gatherer, lmShaderData);
1951
1952 AddToKey(newContext, builder, gatherer, wrappedShader);
1953
1954 builder->endBlock();
1955}
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
static constexpr float sk_ieee_float_divide(float numer, float denom)
SkShaderBase * as_SB(SkShader *shader)
Definition: SkShaderBase.h:412
static SkScalar center(float pos0, float pos1)
static bool MapToUnitX(const SkPoint &startCenter, const SkPoint &endCenter, SkMatrix *dstMatrix)
const SkMatrix & getGradientMatrix() const
const SkMatrix & localMatrix() const
sk_sp< SkShader > wrappedShader() const
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:281
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:360
virtual ShaderType type() const =0
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ add_to_key() [14/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkMatrixColorFilter filter 
)
static

Definition at line 1353 of file KeyHelpers.cpp.

1356 {
1357 SkASSERT(filter);
1358
1359 bool inHSLA = filter->domain() == SkMatrixColorFilter::Domain::kHSLA;
1360 MatrixColorFilterBlock::MatrixColorFilterData matrixCFData(filter->matrix(), inHSLA);
1361
1362 MatrixColorFilterBlock::AddBlock(keyContext, builder, gatherer, matrixCFData);
1363}
const float * matrix() const

◆ add_to_key() [15/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkPerlinNoiseShader shader 
)
static

Definition at line 1969 of file KeyHelpers.cpp.

1972 {
1973 SkASSERT(shader);
1974 SkASSERT(shader->numOctaves());
1975
1976 std::unique_ptr<SkPerlinNoiseShader::PaintingData> paintingData = shader->getPaintingData();
1977 paintingData->generateBitmaps();
1978
1979 sk_sp<TextureProxy> perm =
1980 RecorderPriv::CreateCachedProxy(keyContext.recorder(),
1981 paintingData->getPermutationsBitmap(),
1982 "PerlinNoisePermTable");
1983
1984 sk_sp<TextureProxy> noise =
1985 RecorderPriv::CreateCachedProxy(keyContext.recorder(), paintingData->getNoiseBitmap(),
1986 "PerlinNoiseNoiseTable");
1987
1988 if (!perm || !noise) {
1989 SKGPU_LOG_W("Couldn't create tables for PerlinNoiseShader");
1991 return;
1992 }
1993
1994 PerlinNoiseShaderBlock::PerlinNoiseData perlinData(
1995 static_cast<PerlinNoiseShaderBlock::Type>(shader->noiseType()),
1996 paintingData->fBaseFrequency,
1997 shader->numOctaves(),
1998 {paintingData->fStitchDataInit.fWidth, paintingData->fStitchDataInit.fHeight});
1999
2000 perlinData.fPermutationsProxy = std::move(perm);
2001 perlinData.fNoiseProxy = std::move(noise);
2002
2003 PerlinNoiseShaderBlock::AddBlock(keyContext, builder, gatherer, perlinData);
2004}
Type
Definition: SortBench.cpp:56
SkPerlinNoiseShaderType noiseType() const
std::unique_ptr< PaintingData > getPaintingData() const

◆ add_to_key() [16/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkPictureShader shader 
)
static

Definition at line 2009 of file KeyHelpers.cpp.

2012 {
2013 SkASSERT(shader);
2014
2015 Recorder* recorder = keyContext.recorder();
2016 const Caps* caps = recorder->priv().caps();
2017
2018 // TODO: We'll need additional plumbing to get the correct props from our callers. In
2019 // particular we'll need to expand the keyContext to have the surfaceProps.
2020 SkSurfaceProps props{};
2021
2022 SkMatrix totalM = keyContext.local2Dev().asM33();
2023 if (keyContext.localMatrix()) {
2024 totalM.preConcat(*keyContext.localMatrix());
2025 }
2027 totalM,
2028 keyContext.dstColorInfo().colorType(),
2029 keyContext.dstColorInfo().colorSpace(),
2030 caps->maxTextureSize(),
2031 props);
2032 if (!info.success) {
2033 SKGPU_LOG_W("Couldn't access PictureShaders' Image info");
2035 return;
2036 }
2037
2038 // NOTE: While this is intended to be a "scratch" surface, we don't use MakeScratch() because
2039 // the SkPicture could contain arbitrary operations that rely on the Recorder's atlases, which
2040 // means the Surface's device has to participate in flushing when the atlas fills up.
2041 // TODO: Can this be an approx-fit image that's generated?
2042 // TODO: right now we're explicitly not caching here. We could expand the ImageProvider
2043 // API to include already Graphite-backed images, add a Recorder-local cache or add
2044 // rendered-picture images to the global cache.
2046 info.imageInfo,
2047 "PictureShaderTexture",
2048 Budgeted::kYes,
2051 &info.props);
2052 if (!surface) {
2053 SKGPU_LOG_W("Could not create surface to render PictureShader");
2055 return;
2056 }
2057
2058 // NOTE: Don't call CachedImageInfo::makeImage() since that uses the legacy makeImageSnapshot()
2059 // API, which results in an extra texture copy on a Graphite Surface.
2060 surface->getCanvas()->concat(info.matrixForDraw);
2061 surface->getCanvas()->drawPicture(shader->picture().get());
2062 sk_sp<SkImage> img = SkSurfaces::AsImage(std::move(surface));
2063 // TODO: 'img' did not exist when notify_in_use() was called, but ideally the DrawTask to render
2064 // into 'surface' would be a child of the current device. While we push all tasks to the root
2065 // list this works out okay, but will need to be addressed before we move off that system.
2066 if (!img) {
2067 SKGPU_LOG_W("Couldn't create SkImage for PictureShader");
2069 return;
2070 }
2071
2072 const auto shaderLM = SkMatrix::Scale(1.f/info.tileScale.width(), 1.f/info.tileScale.height());
2073 sk_sp<SkShader> imgShader = img->makeShader(shader->tileModeX(), shader->tileModeY(),
2074 SkSamplingOptions(shader->filter()), &shaderLM);
2075 if (!imgShader) {
2076 SKGPU_LOG_W("Couldn't create SkImageShader for PictureShader");
2078 return;
2079 }
2080
2081 AddToKey(keyContext, builder, gatherer, imgShader.get());
2082}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkColorType colorType() const
Definition: SkImageInfo.h:140
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkImage.cpp:179
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
SkRect tile() const
SkTileMode tileModeY() const
SkTileMode tileModeX() const
SkFilterMode filter() const
sk_sp< SkPicture > picture() const
int maxTextureSize() const
Definition: Caps.h:141
const Caps * caps() const
Definition: RecorderPriv.h:31
VkSurfaceKHR surface
Definition: main.cc:49
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
SK_API sk_sp< SkImage > AsImage(sk_sp< const SkSurface >)
static CachedImageInfo Make(const SkRect &bounds, const SkMatrix &totalM, SkColorType dstColorType, SkColorSpace *dstColorSpace, const int maxTextureSize, const SkSurfaceProps &propsIn)

◆ add_to_key() [17/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkRuntimeColorFilter filter 
)
static

Definition at line 1365 of file KeyHelpers.cpp.

1368 {
1369 SkASSERT(filter);
1370
1371 sk_sp<SkRuntimeEffect> effect = filter->effect();
1373 effect->uniforms(), filter->uniforms(), keyContext.dstColorInfo().colorSpace());
1374 SkASSERT(uniforms);
1375
1376 RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer, {effect, std::move(uniforms)});
1377
1378 add_children_to_key(keyContext, builder, gatherer,
1379 filter->children(), effect->children());
1380
1381 builder->endBlock();
1382}
SkSpan< const SkRuntimeEffect::ChildPtr > children() const
sk_sp< SkRuntimeEffect > effect() const
sk_sp< const SkData > uniforms() const
static sk_sp< const SkData > TransformUniforms(SkSpan< const SkRuntimeEffect::Uniform > uniforms, sk_sp< const SkData > originalData, const SkColorSpaceXformSteps &)
SkSpan< const Child > children() const
SkSpan< const Uniform > uniforms() const

◆ add_to_key() [18/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkRuntimeShader shader 
)
static

Definition at line 2088 of file KeyHelpers.cpp.

2091 {
2092 SkASSERT(shader);
2093 sk_sp<SkRuntimeEffect> effect = shader->effect();
2095 effect->uniforms(),
2096 shader->uniformData(keyContext.dstColorInfo().colorSpace()),
2097 keyContext.dstColorInfo().colorSpace());
2098 SkASSERT(uniforms);
2099
2100 RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer,
2101 {effect, std::move(uniforms)});
2102
2103 add_children_to_key(keyContext, builder, gatherer,
2104 shader->children(), effect->children());
2105
2106 builder->endBlock();
2107}
SkSpan< const SkRuntimeEffect::ChildPtr > children() const
sk_sp< const SkData > uniformData(const SkColorSpace *dstCS) const
sk_sp< SkRuntimeEffect > effect() const

◆ add_to_key() [19/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkTableColorFilter filter 
)
static

Definition at line 1384 of file KeyHelpers.cpp.

1387 {
1388 SkASSERT(filter);
1389
1390 sk_sp<TextureProxy> proxy = RecorderPriv::CreateCachedProxy(keyContext.recorder(),
1391 filter->bitmap(),
1392 "TableColorFilterTexture");
1393 if (!proxy) {
1394 SKGPU_LOG_W("Couldn't create TableColorFilter's table");
1395
1396 // Return the input color as-is.
1397 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
1398 return;
1399 }
1400
1401 TableColorFilterBlock::TableColorFilterData data(std::move(proxy));
1402
1403 TableColorFilterBlock::AddBlock(keyContext, builder, gatherer, data);
1404}
const SkBitmap & bitmap() const

◆ add_to_key() [20/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkTransformShader shader 
)
static

Definition at line 2114 of file KeyHelpers.cpp.

2117 {
2118 SKGPU_LOG_W("Raster-only SkShader (SkTransformShader) encountered");
2120}

◆ add_to_key() [21/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkTriColorShader shader 
)
static

Definition at line 2125 of file KeyHelpers.cpp.

2128 {
2129 SKGPU_LOG_W("Raster-only SkShader (SkTriColorShader) encountered");
2131}

◆ add_to_key() [22/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkWorkingColorSpaceShader shader 
)
static

Definition at line 2136 of file KeyHelpers.cpp.

2139 {
2140 SkASSERT(shader);
2141
2142 const SkColorInfo& dstInfo = keyContext.dstColorInfo();
2143 const SkAlphaType dstAT = dstInfo.alphaType();
2144 sk_sp<SkColorSpace> dstCS = dstInfo.refColorSpace();
2145 if (!dstCS) {
2146 dstCS = SkColorSpace::MakeSRGB();
2147 }
2148
2149 sk_sp<SkColorSpace> workingCS = shader->workingSpace();
2150 SkColorInfo workingInfo(dstInfo.colorType(), dstAT, workingCS);
2151 KeyContextWithColorInfo workingContext(keyContext, workingInfo);
2152
2153 // Compose the inner shader (in the working space) with a (working->dst) transform:
2154 Compose(keyContext, builder, gatherer,
2155 /* addInnerToKey= */ [&]() -> void {
2156 AddToKey(workingContext, builder, gatherer, shader->shader().get());
2157 },
2158 /* addOuterToKey= */ [&]() -> void {
2159 ColorSpaceTransformBlock::ColorSpaceTransformData data(
2160 workingCS.get(), dstAT, dstCS.get(), dstAT);
2161 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data);
2162 });
2163}
sk_sp< SkColorSpace > refColorSpace() const
Definition: SkImageInfo.cpp:67
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkShader > shader() const
sk_sp< SkColorSpace > workingSpace() const

◆ add_to_key() [23/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkWorkingFormatColorFilter filter 
)
static

Definition at line 1406 of file KeyHelpers.cpp.

1409 {
1410 SkASSERT(filter);
1411
1412 const SkColorInfo& dstInfo = keyContext.dstColorInfo();
1413 const SkAlphaType dstAT = dstInfo.alphaType();
1414 sk_sp<SkColorSpace> dstCS = dstInfo.refColorSpace();
1415 if (!dstCS) {
1416 dstCS = SkColorSpace::MakeSRGB();
1417 }
1418
1419 SkAlphaType workingAT;
1420 sk_sp<SkColorSpace> workingCS = filter->workingFormat(dstCS, &workingAT);
1421 SkColorInfo workingInfo(dstInfo.colorType(), workingAT, workingCS);
1422 KeyContextWithColorInfo workingContext(keyContext, workingInfo);
1423
1424 // Use two nested compose blocks to chain (dst->working), child, and (working->dst) together
1425 // while appearing as one block to the parent node.
1426 Compose(keyContext, builder, gatherer,
1427 /* addInnerToKey= */ [&]() -> void {
1428 // Inner compose
1429 Compose(keyContext, builder, gatherer,
1430 /* addInnerToKey= */ [&]() -> void {
1431 // Innermost (inner of inner compose)
1432 ColorSpaceTransformBlock::ColorSpaceTransformData data1(
1433 dstCS.get(), dstAT, workingCS.get(), workingAT);
1434 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer,
1435 data1);
1436 },
1437 /* addOuterToKey= */ [&]() -> void {
1438 // Middle (outer of inner compose)
1439 AddToKey(workingContext, builder, gatherer, filter->child().get());
1440 });
1441 },
1442 /* addOuterToKey= */ [&]() -> void {
1443 // Outermost (outer of outer compose)
1444 ColorSpaceTransformBlock::ColorSpaceTransformData data2(
1445 workingCS.get(), workingAT, dstCS.get(), dstAT);
1446 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data2);
1447 });
1448}
sk_sp< SkColorFilter > child() const
sk_sp< SkColorSpace > workingFormat(const sk_sp< SkColorSpace > &dstCS, SkAlphaType *at) const

◆ add_to_key() [24/24]

static void skgpu::graphite::add_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder keyBuilder,
PipelineDataGatherer gatherer,
const SkComposeColorFilter filter 
)
static

Definition at line 1331 of file KeyHelpers.cpp.

1334 {
1335 SkASSERT(filter);
1336
1337 Compose(keyContext, keyBuilder, gatherer,
1338 /* addInnerToKey= */ [&]() -> void {
1339 AddToKey(keyContext, keyBuilder, gatherer, filter->inner().get());
1340 },
1341 /* addOuterToKey= */ [&]() -> void {
1342 AddToKey(keyContext, keyBuilder, gatherer, filter->outer().get());
1343 });
1344}
sk_sp< SkColorFilterBase > inner() const
sk_sp< SkColorFilterBase > outer() const

◆ add_yuv_image_to_key()

static void skgpu::graphite::add_yuv_image_to_key ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkImageShader origShader,
sk_sp< const SkImage imageToDraw,
SkSamplingOptions  sampling 
)
static

Definition at line 1620 of file KeyHelpers.cpp.

1625 {
1626 SkASSERT(!imageToDraw->isAlphaOnly());
1627
1628 const Image_YUVA* yuvaImage = static_cast<const Image_YUVA*>(imageToDraw.get());
1629 const SkYUVAInfo& yuvaInfo = yuvaImage->yuvaInfo();
1630 // We would want to add a translation to the local matrix to handle other sitings.
1634 origShader->tileModeX(),
1635 origShader->tileModeY(),
1636 imageToDraw->dimensions(),
1637 origShader->subset());
1638 for (int locIndex = 0; locIndex < SkYUVAInfo::kYUVAChannelCount; ++locIndex) {
1639 const TextureProxyView& view = yuvaImage->proxyView(locIndex);
1640 if (view) {
1641 imgData.fTextureProxies[locIndex] = view.refProxy();
1642 // The view's swizzle has the data channel for the YUVA location in all slots, so read
1643 // the 0th slot to determine fChannelSelect
1644 switch(view.swizzle()[0]) {
1645 case 'r': imgData.fChannelSelect[locIndex] = {1.f, 0.f, 0.f, 0.f}; break;
1646 case 'g': imgData.fChannelSelect[locIndex] = {0.f, 1.f, 0.f, 0.f}; break;
1647 case 'b': imgData.fChannelSelect[locIndex] = {0.f, 0.f, 1.f, 0.f}; break;
1648 case 'a': imgData.fChannelSelect[locIndex] = {0.f, 0.f, 0.f, 1.f}; break;
1649 default:
1650 imgData.fChannelSelect[locIndex] = {0.f, 0.f, 0.f, 0.f};
1651 SkDEBUGFAILF("Unexpected swizzle for YUVA data: %c", view.swizzle()[0]);
1652 break;
1653 }
1654 } else {
1655 // Only the A proxy view should be null, in which case we bind the Y proxy view to
1656 // pass validation and send all 1s for the channel selection to signal opaque alpha.
1657 SkASSERT(locIndex == 3);
1658 imgData.fTextureProxies[locIndex] = yuvaImage->proxyView(SkYUVAInfo::kY).refProxy();
1659 imgData.fChannelSelect[locIndex] = {1.f, 1.f, 1.f, 1.f};
1660 }
1661 }
1662
1663 auto [ssx, ssy] = yuvaImage->uvSubsampleFactors();
1664 if (ssx > 1 || ssy > 1) {
1665 // We need to adjust the image size we use for sampling to reflect the actual image size of
1666 // the UV planes. However, since our coordinates are in Y's texel space we need to scale
1667 // accordingly.
1668 const TextureProxyView& view = yuvaImage->proxyView(SkYUVAInfo::kU);
1669 imgData.fImgSizeUV = {view.dimensions().width()*ssx, view.dimensions().height()*ssy};
1670 // This promotion of nearest to linear filtering for UV planes exists to mimic
1671 // libjpeg[-turbo]'s do_fancy_upsampling option. We will filter the subsampled plane,
1672 // however we want to filter at a fixed point for each logical image pixel to simulate
1673 // nearest neighbor. In the shader we detect that the UV filtermode doesn't match the Y
1674 // filtermode, and snap to Y pixel centers.
1675 if (imgData.fSampling.filter == SkFilterMode::kNearest) {
1676 imgData.fSamplingUV = SkSamplingOptions(SkFilterMode::kLinear,
1677 imgData.fSampling.mipmap);
1678 // Consider a logical image pixel at the edge of the subset. When computing the logical
1679 // pixel color value we should use a blend of two values from the subsampled plane.
1680 // Depending on where the subset edge falls in actual subsampled plane, one of those
1681 // values may come from outside the subset. Hence, we will use the default inset
1682 // in Y texel space of 1/2. This applies the wrap mode to the subset but allows
1683 // linear filtering to read pixels that are just outside the subset.
1684 imgData.fLinearFilterUVInset.fX = 0.5f;
1685 imgData.fLinearFilterUVInset.fY = 0.5f;
1686 } else if (imgData.fSampling.filter == SkFilterMode::kLinear) {
1687 // We need to inset so that we aren't sampling outside the subset, but no farther.
1688 // Start by mapping the subset to UV texel space
1689 float scaleX = 1.f/ssx;
1690 float scaleY = 1.f/ssy;
1691 SkRect subsetUV = {imgData.fSubset.fLeft *scaleX,
1692 imgData.fSubset.fTop *scaleY,
1693 imgData.fSubset.fRight *scaleX,
1694 imgData.fSubset.fBottom*scaleY};
1695 // Round to UV texel borders
1696 SkIRect iSubsetUV = subsetUV.roundOut();
1697 // Inset in UV and map back to Y texel space. This gives us the largest possible
1698 // inset rectangle that will not sample outside of the subset texels in UV space.
1699 SkRect insetRectUV = {(iSubsetUV.fLeft +0.5f)*ssx,
1700 (iSubsetUV.fTop +0.5f)*ssy,
1701 (iSubsetUV.fRight -0.5f)*ssx,
1702 (iSubsetUV.fBottom-0.5f)*ssy};
1703 // Compute intersection with original inset
1704 SkRect insetRect = imgData.fSubset.makeOutset(-0.5f, -0.5f);
1705 (void) insetRect.intersect(insetRectUV);
1706 // Compute max inset values to ensure we always remain within the subset.
1707 imgData.fLinearFilterUVInset = {std::max(insetRect.fLeft - imgData.fSubset.fLeft,
1708 imgData.fSubset.fRight - insetRect.fRight),
1709 std::max(insetRect.fTop - imgData.fSubset.fTop,
1710 imgData.fSubset.fBottom - insetRect.fBottom)};
1711 }
1712 }
1713
1714 float yuvM[20];
1715 SkColorMatrix_YUV2RGB(yuvaInfo.yuvColorSpace(), yuvM);
1716 // We drop the fourth column entirely since the transformation
1717 // should not depend on alpha. The fifth column is sent as a separate
1718 // vector. The fourth row is also dropped entirely because alpha should
1719 // never be modified.
1720 SkASSERT(yuvM[3] == 0 && yuvM[8] == 0 && yuvM[13] == 0 && yuvM[18] == 1);
1721 SkASSERT(yuvM[15] == 0 && yuvM[16] == 0 && yuvM[17] == 0 && yuvM[19] == 0);
1722 imgData.fYUVtoRGBMatrix.setAll(
1723 yuvM[ 0], yuvM[ 1], yuvM[ 2],
1724 yuvM[ 5], yuvM[ 6], yuvM[ 7],
1725 yuvM[10], yuvM[11], yuvM[12]
1726 );
1727 imgData.fYUVtoRGBTranslate = {yuvM[4], yuvM[9], yuvM[14]};
1728
1729 // The YUV formats can encode their own origin including reflection and rotation,
1730 // so we need to wrap our block in an additional local matrix transform.
1731 SkMatrix originMatrix = yuvaInfo.originMatrix();
1732 LocalMatrixShaderBlock::LMShaderData lmShaderData(originMatrix);
1733
1734 KeyContextWithLocalMatrix newContext(keyContext, originMatrix);
1735
1737 SkASSERT(steps.flags.mask() == 0); // By default, the colorspace should have no effect
1738 if (!origShader->isRaw()) {
1739 steps = SkColorSpaceXformSteps(imageToDraw->colorSpace(),
1740 imageToDraw->alphaType(),
1741 keyContext.dstColorInfo().colorSpace(),
1742 keyContext.dstColorInfo().alphaType());
1743 }
1744 ColorSpaceTransformBlock::ColorSpaceTransformData data(steps);
1745
1746 Compose(keyContext, builder, gatherer,
1747 /* addInnerToKey= */ [&]() -> void {
1748 LocalMatrixShaderBlock::BeginBlock(newContext, builder, gatherer, lmShaderData);
1749 YUVImageShaderBlock::AddBlock(newContext, builder, gatherer, imgData);
1750 builder->endBlock();
1751 },
1752 /* addOuterToKey= */ [&]() -> void {
1753 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data);
1754 });
1755}
#define SkDEBUGFAILF(fmt,...)
Definition: SkAssert.h:119
void SkColorMatrix_YUV2RGB(SkYUVColorSpace cs, float m[20])
Definition: SkYUVMath.cpp:398
bool isAlphaOnly() const
Definition: SkImage.cpp:239
SkColorSpace * colorSpace() const
Definition: SkImage.cpp:156
SkISize dimensions() const
Definition: SkImage.h:297
SkAlphaType alphaType() const
Definition: SkImage.cpp:154
Siting sitingY() const
Definition: SkYUVAInfo.h:177
SkMatrix originMatrix() const
Definition: SkYUVAInfo.h:181
SkYUVColorSpace yuvColorSpace() const
Definition: SkYUVAInfo.h:175
static constexpr int kYUVAChannelCount
Definition: SkYUVAInfo.h:29
Siting sitingX() const
Definition: SkYUVAInfo.h:176
std::tuple< int, int > uvSubsampleFactors() const
const SkYUVAInfo & yuvaInfo() const
const TextureProxyView & proxyView(int channelIndex) const
sk_sp< TextureProxy > refProxy() const
static float max(float r, float g, float b)
Definition: hsl.cpp:49
SkSamplingOptions sampling
Definition: SkRecords.h:337
SkSamplingOptions(SkFilterMode::kLinear))
constexpr uint32_t mask() const
Definition: SkRect.h:32
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35
constexpr int32_t width() const
Definition: SkSize.h:36
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
bool intersect(const SkRect &r)
Definition: SkRect.cpp:114
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkRect makeOutset(float dx, float dy) const
Definition: SkRect.h:1002
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
void roundOut(SkIRect *dst) const
Definition: SkRect.h:1241
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ AddBlendModeColorFilter()

void skgpu::graphite::AddBlendModeColorFilter ( const KeyContext ,
PaintParamsKeyBuilder ,
PipelineDataGatherer ,
SkBlendMode  ,
const SkPMColor4f srcColor 
)

Blend mode color filters blend their input (as the dst color) with some given color (supplied via a uniform) as the src color.

Definition at line 1058 of file KeyHelpers.cpp.

1062 {
1063 Blend(keyContext, builder, gatherer,
1064 /* addBlendToKey= */ [&] () -> void {
1065 // Note, we're playing a bit of a game here. By explicitly adding a
1066 // BlendModeBlenderBlock we're always forcing the SkSL to call 'sk_blend'
1067 // rather than allowing it to sometimes call 'blend_porter_duff'. This reduces
1068 // the number of shader combinations and allows the pre-compilation system to more
1069 // easily match the rendering path.
1070 BlendModeBlenderBlock::AddBlock(keyContext, builder, gatherer, bm);
1071 },
1072 /* addSrcToKey= */ [&]() -> void {
1073 SolidColorShaderBlock::AddBlock(keyContext, builder, gatherer, srcColor);
1074 },
1075 /* addDstToKey= */ [&]() -> void {
1076 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
1077 });
1078}

◆ AddDitherBlock()

void skgpu::graphite::AddDitherBlock ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
SkColorType  ct 
)

Definition at line 168 of file PaintParams.cpp.

171 {
172 static const SkBitmap gLUT = skgpu::MakeDitherLUT();
173
174 sk_sp<TextureProxy> proxy = RecorderPriv::CreateCachedProxy(keyContext.recorder(), gLUT,
175 "DitherLUT");
176 if (keyContext.recorder() && !proxy) {
177 SKGPU_LOG_W("Couldn't create dither shader's LUT");
178 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
179 return;
180 }
181
182 DitherShaderBlock::DitherData data(skgpu::DitherRangeForConfig(ct), std::move(proxy));
183
184 DitherShaderBlock::AddBlock(keyContext, builder, gatherer, data);
185}
float DitherRangeForConfig(SkColorType dstColorType)
Definition: DitherUtils.cpp:20
SkBitmap MakeDitherLUT()
Definition: DitherUtils.cpp:74

◆ AddDstReadBlock()

void skgpu::graphite::AddDstReadBlock ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
DstReadRequirement  dstReadReq 
)

Definition at line 148 of file PaintParams.cpp.

151 {
152 switch(dstReadReq) {
154 SkASSERT(false); // This should never be reached
155 return;
156 case DstReadRequirement::kTextureCopy:
157 [[fallthrough]];
158 case DstReadRequirement::kTextureSample:
159 DstReadSampleBlock::AddBlock(keyContext, builder, gatherer, keyContext.dstTexture(),
160 keyContext.dstOffset());
161 break;
162 case DstReadRequirement::kFramebufferFetch:
163 builder->addBlock(BuiltInCodeSnippetID::kDstReadFetch);
164 break;
165 }
166}
SkIPoint dstOffset() const
Definition: KeyContext.h:72
sk_sp< TextureProxy > dstTexture() const
Definition: KeyContext.h:70

◆ AddKnownModeBlend()

void skgpu::graphite::AddKnownModeBlend ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
SkBlendMode  bm 
)

Definition at line 126 of file PaintParams.cpp.

129 {
132 static_cast<int>(bm));
133 builder->addBlock(id);
134}
@ kLastCoeffMode
last porter duff blend mode
static constexpr int kFixedFunctionBlendModeIDOffset

◆ AddModeBlend()

void skgpu::graphite::AddModeBlend ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
SkBlendMode  bm 
)

Definition at line 136 of file PaintParams.cpp.

139 {
141 if (!coeffs.empty()) {
142 CoeffBlenderBlock::AddBlock(keyContext, builder, gatherer, coeffs);
143 } else {
144 BlendModeBlenderBlock::AddBlock(keyContext, builder, gatherer, bm);
145 }
146}
SkSpan< const float > GetPorterDuffBlendConstants(SkBlendMode mode)
Definition: Blend.cpp:53

◆ AddToKey() [1/3]

void skgpu::graphite::AddToKey ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkBlender blender 
)

Definition at line 1269 of file KeyHelpers.cpp.

1272 {
1273 if (!blender) {
1274 return;
1275 }
1276 switch (as_BB(blender)->type()) {
1277#define M(type) \
1278 case SkBlenderBase::BlenderType::k##type: \
1279 add_to_key(keyContext, \
1280 builder, \
1281 gatherer, \
1282 static_cast<const Sk##type##Blender*>(blender)); \
1283 return;
1285#undef M
1286 }
1288}
#define SK_ALL_BLENDERS(M)
Definition: SkBlenderBase.h:30
SkBlenderBase * as_BB(SkBlender *blend)
Definition: SkBlenderBase.h:69
GLenum type

◆ AddToKey() [2/3]

void skgpu::graphite::AddToKey ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkColorFilter filter 
)

Add implementation details, for the specified backend, of this SkColorFilter to the provided key.

Parameters
keyContextbackend context for key creation
builderbuilder for creating the key for this SkShader
gathererif non-null, storage for this colorFilter's data
filterThis function is a no-op if filter is null.

Definition at line 1450 of file KeyHelpers.cpp.

1453 {
1454 if (!filter) {
1455 return;
1456 }
1457 switch (as_CFB(filter)->type()) {
1459 // Return the input color as-is.
1460 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
1461 return;
1462#define M(type) \
1463 case SkColorFilterBase::Type::k##type: \
1464 add_to_key(keyContext, \
1465 builder, \
1466 gatherer, \
1467 static_cast<const Sk##type##ColorFilter*>(filter)); \
1468 return;
1470#undef M
1471 }
1473}
#define SK_ALL_COLOR_FILTERS(M)
static SkColorFilterBase * as_CFB(SkColorFilter *filter)

◆ AddToKey() [3/3]

void skgpu::graphite::AddToKey ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const SkShader shader 
)

Add implementation details, for the specified backend, of this SkShader to the provided key.

Parameters
keyContextbackend context for key creation
builderbuilder for creating the key for this SkShader
gathererif non-null, storage for this colorFilter's data
shaderThis function is a no-op if shader is null.

Definition at line 2429 of file KeyHelpers.cpp.

2432 {
2433 if (!shader) {
2434 return;
2435 }
2436 switch (as_SB(shader)->type()) {
2437#define M(type) \
2438 case SkShaderBase::ShaderType::k##type: \
2439 add_to_key(keyContext, \
2440 builder, \
2441 gatherer, \
2442 static_cast<const Sk##type##Shader*>(shader)); \
2443 return;
2445#undef M
2446 }
2448}
#define SK_ALL_SHADERS(M)
Definition: SkShaderBase.h:162

◆ adjust_for_matrix_type()

static std::pair< SkSLType, int > skgpu::graphite::adjust_for_matrix_type ( SkSLType  type,
int  count 
)
static

Definition at line 74 of file UniformManager.cpp.

74 {
75 // All Layouts flatten matrices and arrays of matrices into arrays of columns, so update
76 // 'type' to be the column type and either multiply 'count' by the number of columns for
77 // arrays of matrices, or set to exactly the number of columns for a "non-array" matrix.
78 switch(type) {
82
86
87 // Otherwise leave type and count alone.
88 default: return {type, count};
89 }
90}
int count
Definition: FontMgrTest.cpp:50

◆ append_color_output()

void skgpu::graphite::append_color_output ( std::string *  mainBody,
BlendFormula::OutputType  outputType,
const char *  outColor,
const char *  inColor 
)

Definition at line 242 of file ShaderCodeDictionary.cpp.

245 {
246 switch (outputType) {
248 SkSL::String::appendf(mainBody, "%s = half4(0.0);", outColor);
249 break;
251 SkSL::String::appendf(mainBody, "%s = outputCoverage;", outColor);
252 break;
254 SkSL::String::appendf(mainBody, "%s = %s * outputCoverage;", outColor, inColor);
255 break;
257 SkSL::String::appendf(mainBody, "%s = %s.a * outputCoverage;", outColor, inColor);
258 break;
261 mainBody, "%s = (1.0 - %s.a) * outputCoverage;", outColor, inColor);
262 break;
265 mainBody, "%s = (half4(1.0) - %s) * outputCoverage;", outColor, inColor);
266 break;
267 default:
269 break;
270 }
271}
@ kISAModulate_OutputType
@ kSAModulate_OutputType
@ kModulate_OutputType
@ kISCModulate_OutputType
@ kNone_OutputType
@ kCoverage_OutputType
std::string void appendf(std::string *str, const char *fmt,...) SK_PRINTF_LIKE(2
Definition: SkSLString.cpp:92

◆ AsView() [1/2]

TextureProxyView skgpu::graphite::AsView ( const SkImage image)

Definition at line 839 of file TextureUtils.cpp.

839 {
840 if (!image) {
841 return {};
842 }
843 if (!as_IB(image)->isGraphiteBacked()) {
844 return {};
845 }
846 // A YUVA image (even if backed by graphite textures) is not a single texture
847 if (as_IB(image)->isYUVA()) {
848 return {};
849 }
850
851 auto gi = reinterpret_cast<const Image*>(image);
852 return gi->textureProxyView();
853}
sk_sp< const SkImage > image
Definition: SkRecords.h:269
CanvasImage Image
Definition: dart_ui.cc:55

◆ AsView() [2/2]

TextureProxyView skgpu::graphite::AsView ( sk_sp< SkImage image)
inline

Definition at line 88 of file TextureUtils.h.

88{ return AsView(image.get()); }
TextureProxyView AsView(sk_sp< SkImage > image)
Definition: TextureUtils.h:88

◆ attrib_type_to_vkformat()

static VkFormat skgpu::graphite::attrib_type_to_vkformat ( VertexAttribType  type)
inlinestatic

Definition at line 34 of file VulkanGraphicsPipeline.cpp.

34 {
35 switch (type) {
38 case VertexAttribType::kFloat2:
40 case VertexAttribType::kFloat3:
42 case VertexAttribType::kFloat4:
44 case VertexAttribType::kHalf:
46 case VertexAttribType::kHalf2:
48 case VertexAttribType::kHalf4:
50 case VertexAttribType::kInt2:
52 case VertexAttribType::kInt3:
54 case VertexAttribType::kInt4:
57 return VK_FORMAT_R8_SINT;
58 case VertexAttribType::kByte2:
60 case VertexAttribType::kByte4:
62 case VertexAttribType::kUByte:
63 return VK_FORMAT_R8_UINT;
64 case VertexAttribType::kUByte2:
66 case VertexAttribType::kUByte4:
68 case VertexAttribType::kUByte_norm:
69 return VK_FORMAT_R8_UNORM;
70 case VertexAttribType::kUByte4_norm:
72 case VertexAttribType::kShort2:
74 case VertexAttribType::kShort4:
76 case VertexAttribType::kUShort2:
78 case VertexAttribType::kUShort2_norm:
80 case VertexAttribType::kInt:
81 return VK_FORMAT_R32_SINT;
82 case VertexAttribType::kUInt:
83 return VK_FORMAT_R32_UINT;
84 case VertexAttribType::kUShort_norm:
86 case VertexAttribType::kUShort4_norm:
88 }
89 SK_ABORT("Unknown vertex attrib type");
90}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
@ VK_FORMAT_R16G16B16A16_UNORM
Definition: vulkan_core.h:1550
@ VK_FORMAT_R16G16_SFLOAT
Definition: vulkan_core.h:1542
@ VK_FORMAT_R32G32_SFLOAT
Definition: vulkan_core.h:1562
@ VK_FORMAT_R16_SFLOAT
Definition: vulkan_core.h:1535
@ VK_FORMAT_R32_SINT
Definition: vulkan_core.h:1558
@ VK_FORMAT_R16G16_UINT
Definition: vulkan_core.h:1540
@ VK_FORMAT_R8_UNORM
Definition: vulkan_core.h:1468
@ VK_FORMAT_R32G32B32A32_SFLOAT
Definition: vulkan_core.h:1568
@ VK_FORMAT_R32_SFLOAT
Definition: vulkan_core.h:1559
@ VK_FORMAT_R16G16B16A16_SINT
Definition: vulkan_core.h:1555
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan_core.h:1496
@ VK_FORMAT_R16G16_SINT
Definition: vulkan_core.h:1541
@ VK_FORMAT_R8G8_SINT
Definition: vulkan_core.h:1480
@ VK_FORMAT_R32G32B32_SINT
Definition: vulkan_core.h:1564
@ VK_FORMAT_R16_UNORM
Definition: vulkan_core.h:1529
@ VK_FORMAT_R8_SINT
Definition: vulkan_core.h:1473
@ VK_FORMAT_R8_UINT
Definition: vulkan_core.h:1472
@ VK_FORMAT_R16G16B16A16_SFLOAT
Definition: vulkan_core.h:1556
@ VK_FORMAT_R16G16_UNORM
Definition: vulkan_core.h:1536
@ VK_FORMAT_R8G8B8A8_SINT
Definition: vulkan_core.h:1501
@ VK_FORMAT_R32G32B32A32_SINT
Definition: vulkan_core.h:1567
@ VK_FORMAT_R32G32B32_SFLOAT
Definition: vulkan_core.h:1565
@ VK_FORMAT_R8G8B8A8_UINT
Definition: vulkan_core.h:1500
@ VK_FORMAT_R8G8_UINT
Definition: vulkan_core.h:1479
@ VK_FORMAT_R32G32_SINT
Definition: vulkan_core.h:1561
@ VK_FORMAT_R32_UINT
Definition: vulkan_core.h:1557

◆ Blend()

void skgpu::graphite::Blend ( const KeyContext keyContext,
PaintParamsKeyBuilder keyBuilder,
PipelineDataGatherer gatherer,
AddToKeyFn  addBlendToKey,
AddToKeyFn  addSrcToKey,
AddToKeyFn  addDstToKey 
)

Definition at line 95 of file PaintParams.cpp.

100 {
101 BlendShaderBlock::BeginBlock(keyContext, keyBuilder, gatherer);
102
103 addSrcToKey();
104
105 addDstToKey();
106
107 addBlendToKey();
108
109 keyBuilder->endBlock(); // BlendShaderBlock
110}

◆ blend_coeff_to_vk_blend()

static VkBlendFactor skgpu::graphite::blend_coeff_to_vk_blend ( skgpu::BlendCoeff  coeff)
static

Definition at line 288 of file VulkanGraphicsPipeline.cpp.

288 {
289 switch (coeff) {
293 return VK_BLEND_FACTOR_ONE;
324 }
326}
@ VK_BLEND_FACTOR_ONE
Definition: vulkan_core.h:1842
@ VK_BLEND_FACTOR_SRC1_ALPHA
Definition: vulkan_core.h:1858
@ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA
Definition: vulkan_core.h:1850
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR
Definition: vulkan_core.h:1857
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR
Definition: vulkan_core.h:1844
@ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
Definition: vulkan_core.h:1852
@ VK_BLEND_FACTOR_SRC_COLOR
Definition: vulkan_core.h:1843
@ VK_BLEND_FACTOR_CONSTANT_COLOR
Definition: vulkan_core.h:1851
@ VK_BLEND_FACTOR_SRC_ALPHA
Definition: vulkan_core.h:1847
@ VK_BLEND_FACTOR_DST_ALPHA
Definition: vulkan_core.h:1849
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA
Definition: vulkan_core.h:1859
@ VK_BLEND_FACTOR_ZERO
Definition: vulkan_core.h:1841
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
Definition: vulkan_core.h:1848
@ VK_BLEND_FACTOR_DST_COLOR
Definition: vulkan_core.h:1845
@ VK_BLEND_FACTOR_SRC1_COLOR
Definition: vulkan_core.h:1856
@ VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR
Definition: vulkan_core.h:1846

◆ blend_equation_to_vk_blend_op()

static VkBlendOp skgpu::graphite::blend_equation_to_vk_blend_op ( skgpu::BlendEquation  equation)
static

Definition at line 328 of file VulkanGraphicsPipeline.cpp.

328 {
329 static const VkBlendOp gTable[] = {
330 // Basic blend ops
334
335 // Advanced blend ops
351
352 // Illegal.
354 };
355 static_assert(0 == (int)skgpu::BlendEquation::kAdd);
356 static_assert(1 == (int)skgpu::BlendEquation::kSubtract);
357 static_assert(2 == (int)skgpu::BlendEquation::kReverseSubtract);
358 static_assert(3 == (int)skgpu::BlendEquation::kScreen);
359 static_assert(4 == (int)skgpu::BlendEquation::kOverlay);
360 static_assert(5 == (int)skgpu::BlendEquation::kDarken);
361 static_assert(6 == (int)skgpu::BlendEquation::kLighten);
362 static_assert(7 == (int)skgpu::BlendEquation::kColorDodge);
363 static_assert(8 == (int)skgpu::BlendEquation::kColorBurn);
364 static_assert(9 == (int)skgpu::BlendEquation::kHardLight);
365 static_assert(10 == (int)skgpu::BlendEquation::kSoftLight);
366 static_assert(11 == (int)skgpu::BlendEquation::kDifference);
367 static_assert(12 == (int)skgpu::BlendEquation::kExclusion);
368 static_assert(13 == (int)skgpu::BlendEquation::kMultiply);
369 static_assert(14 == (int)skgpu::BlendEquation::kHSLHue);
370 static_assert(15 == (int)skgpu::BlendEquation::kHSLSaturation);
371 static_assert(16 == (int)skgpu::BlendEquation::kHSLColor);
372 static_assert(17 == (int)skgpu::BlendEquation::kHSLLuminosity);
373 static_assert(std::size(gTable) == skgpu::kBlendEquationCnt);
374
375 SkASSERT((unsigned)equation < skgpu::kBlendEquationCnt);
376 return gTable[(int)equation];
377}
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
static const int kBlendEquationCnt
Definition: Blend.h:55
VkBlendOp
Definition: vulkan_core.h:1863
@ VK_BLEND_OP_MULTIPLY_EXT
Definition: vulkan_core.h:1881
@ VK_BLEND_OP_ADD
Definition: vulkan_core.h:1864
@ VK_BLEND_OP_HARDLIGHT_EXT
Definition: vulkan_core.h:1888
@ VK_BLEND_OP_OVERLAY_EXT
Definition: vulkan_core.h:1883
@ VK_BLEND_OP_COLORDODGE_EXT
Definition: vulkan_core.h:1886
@ VK_BLEND_OP_SUBTRACT
Definition: vulkan_core.h:1865
@ VK_BLEND_OP_HSL_COLOR_EXT
Definition: vulkan_core.h:1902
@ VK_BLEND_OP_DARKEN_EXT
Definition: vulkan_core.h:1884
@ VK_BLEND_OP_SOFTLIGHT_EXT
Definition: vulkan_core.h:1889
@ VK_BLEND_OP_LIGHTEN_EXT
Definition: vulkan_core.h:1885
@ VK_BLEND_OP_HSL_HUE_EXT
Definition: vulkan_core.h:1900
@ VK_BLEND_OP_HSL_SATURATION_EXT
Definition: vulkan_core.h:1901
@ VK_BLEND_OP_SCREEN_EXT
Definition: vulkan_core.h:1882
@ VK_BLEND_OP_HSL_LUMINOSITY_EXT
Definition: vulkan_core.h:1903
@ VK_BLEND_OP_EXCLUSION_EXT
Definition: vulkan_core.h:1891
@ VK_BLEND_OP_COLORBURN_EXT
Definition: vulkan_core.h:1887
@ VK_BLEND_OP_DIFFERENCE_EXT
Definition: vulkan_core.h:1890
@ VK_BLEND_OP_REVERSE_SUBTRACT
Definition: vulkan_core.h:1866

◆ BuildComputeSkSL()

std::string skgpu::graphite::BuildComputeSkSL ( const Caps caps,
const ComputeStep step 
)

Definition at line 605 of file ContextUtils.cpp.

605 {
606 std::string sksl =
607 SkSL::String::printf("layout(local_size_x=%u, local_size_y=%u, local_size_z=%u) in;\n",
608 step->localDispatchSize().fWidth,
609 step->localDispatchSize().fHeight,
610 step->localDispatchSize().fDepth);
611
612 const auto& bindingReqs = caps->resourceBindingRequirements();
613 bool distinctRanges = bindingReqs.fDistinctIndexRanges;
614 bool separateSampler = bindingReqs.fSeparateTextureAndSamplerBinding;
615
616 int index = 0;
617 int texIdx = 0;
618 // NOTE: SkSL Metal codegen always assigns the same binding index to a texture and its sampler.
619 // TODO: This could cause sampler indices to not be tightly packed if the sampler2D declaration
620 // comes after 1 or more storage texture declarations (which don't have samplers). An optional
621 // "layout(msl, sampler=T, texture=T)" syntax to count them separately (like we do for WGSL)
622 // could come in handy here but it's not supported in MSL codegen yet.
623
624 for (const ComputeStep::ResourceDesc& r : step->resources()) {
626 switch (r.fType) {
627 case Type::kUniformBuffer:
628 SkSL::String::appendf(&sksl, "layout(binding=%d) uniform ", index++);
629 sksl += r.fSkSL;
630 break;
631 case Type::kStorageBuffer:
632 case Type::kIndirectBuffer:
633 SkSL::String::appendf(&sksl, "layout(binding=%d) buffer ", index++);
634 sksl += r.fSkSL;
635 break;
636 case Type::kReadOnlyStorageBuffer:
637 SkSL::String::appendf(&sksl, "layout(binding=%d) readonly buffer ", index++);
638 sksl += r.fSkSL;
639 break;
640 case Type::kWriteOnlyStorageTexture:
641 SkSL::String::appendf(&sksl, "layout(binding=%d, rgba8) writeonly texture2D ",
642 distinctRanges ? texIdx++ : index++);
643 sksl += r.fSkSL;
644 break;
645 case Type::kReadOnlyTexture:
646 SkSL::String::appendf(&sksl, "layout(binding=%d, rgba8) readonly texture2D ",
647 distinctRanges ? texIdx++ : index++);
648 sksl += r.fSkSL;
649 break;
650 case Type::kSampledTexture:
651 if (distinctRanges) {
652 SkSL::String::appendf(&sksl, "layout(metal, binding=%d) ", texIdx++);
653 } else if (separateSampler) {
655 &sksl, "layout(webgpu, sampler=%d, texture=%d) ", index, index + 1);
656 index += 2;
657 } else {
658 SkSL::String::appendf(&sksl, "layout(binding=%d) ", index++);
659 }
660 sksl += "sampler2D ";
661 sksl += r.fSkSL;
662 break;
663 }
664 sksl += ";\n";
665 }
666
667 sksl += step->computeSkSL();
668 return sksl;
669}
static int step(int x, SkScalar min, SkScalar max)
Definition: BlurTest.cpp:215
const ResourceBindingRequirements & resourceBindingRequirements() const
Definition: Caps.h:150
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: SkSLString.cpp:83
uint32_t ResourceType

◆ BuildFragmentSkSL()

FragSkSLInfo skgpu::graphite::BuildFragmentSkSL ( const Caps caps,
const ShaderCodeDictionary dict,
const RuntimeEffectDictionary rteDict,
const RenderStep step,
UniquePaintParamsID  paintID,
bool  useStorageBuffers,
skgpu::Swizzle  writeSwizzle 
)

Definition at line 552 of file ContextUtils.cpp.

558 {
560 if (!paintID.isValid()) {
561 // Depth-only draw so no fragment shader to compile
562 return {};
563 }
564
565 const char* shadingSsboIndex =
566 useStorageBuffers && step->performsShading() ? "shadingSsboIndex" : nullptr;
567 ShaderInfo shaderInfo(paintID, dict, rteDict, shadingSsboIndex);
568
569 result.fSkSL = shaderInfo.toSkSL(caps,
570 step,
571 useStorageBuffers,
572 &result.fNumTexturesAndSamplers,
573 &result.fNumPaintUniforms,
574 &result.fRenderStepUniformsTotalBytes,
575 &result.fPaintUniformsTotalBytes,
576 &result.fHasGradientBuffer,
577 writeSwizzle);
578
579 // Extract blend info after integrating the RenderStep into the final fragment shader in case
580 // that changes the HW blending choice to handle analytic coverage.
581 result.fBlendInfo = shaderInfo.blendInfo();
582 result.fRequiresLocalCoords = shaderInfo.needsLocalCoords();
583 result.fData = {shaderInfo.data()};
584 result.fLabel = writeSwizzle.asString().c_str();
585 result.fLabel += " + ";
586 result.fLabel = step->name();
587 result.fLabel += " + ";
588 result.fLabel += dict->idToString(paintID).c_str();
589
590 return result;
591}
const char * c_str() const
Definition: SkString.h:133
SkString asString() const
Definition: Swizzle.cpp:46
SkString idToString(UniquePaintParamsID id) const
GAsyncResult * result

◆ BuildVertexSkSL()

VertSkSLInfo skgpu::graphite::BuildVertexSkSL ( const ResourceBindingRequirements bindingReqs,
const RenderStep step,
bool  useStorageBuffers,
bool  defineLocalCoordsVarying 
)

Definition at line 466 of file ContextUtils.cpp.

469 {
471
472 const bool hasStepUniforms = step->numUniforms() > 0;
473 const bool useStepStorageBuffer = useStorageBuffers && hasStepUniforms;
474 const bool useShadingStorageBuffer = useStorageBuffers && step->performsShading();
475
476 // TODO: To more completely support end-to-end rendering, this will need to be updated so that
477 // the RenderStep shader snippet can produce a device coord, a local coord, and depth.
478 // If the paint combination doesn't need the local coord it can be ignored, otherwise we need
479 // a varying for it. The fragment function's output will need to be updated to have a color and
480 // the depth, or when there's no combination, just the depth. Lastly, we also should add the
481 // static/intrinsic uniform binding point so that we can handle normalizing the device position
482 // produced by the RenderStep automatically.
483
484 // Fixed program header
485 std::string sksl =
486 "layout (binding=0) uniform intrinsicUniforms {\n"
487 " layout(offset=0) float4 rtAdjust;\n"
488 "};\n"
489 "\n";
490
491 if (step->numVertexAttributes() > 0 || step->numInstanceAttributes() > 0) {
492 sksl += emit_attributes(step->vertexAttributes(), step->instanceAttributes());
493 }
494
495 // Uniforms needed by RenderStep
496 // The uniforms are mangled by having their index in 'fEntries' as a suffix (i.e., "_%d")
497 // TODO: replace hard-coded bufferID with the backend's renderstep uniform-buffer index.
498 if (hasStepUniforms) {
499 if (useStepStorageBuffer) {
500 sksl += EmitRenderStepStorageBuffer(/* bufferID= */ 1, step->uniforms());
501 } else {
502 sksl += EmitRenderStepUniforms(/* bufferID= */ 1,
503 bindingReqs.fUniformBufferLayout,
504 step->uniforms(),
505 &result.fRenderStepUniformsTotalBytes);
506 }
507 }
508
509 // Varyings needed by RenderStep
510 sksl += EmitVaryings(step, "out", useShadingStorageBuffer, defineLocalCoordsVarying);
511
512 // Vertex shader function declaration
513 sksl += "void main() {";
514 // Create stepLocalCoords which render steps can write to.
515 sksl += "float2 stepLocalCoords = float2(0);";
516 // Vertex shader body
517 if (useStepStorageBuffer) {
518 // Extract out render step uniforms from SSBO, declaring local variables with the expected
519 // uniform names so that RenderStep SkSL is independent of storage choice.
521 &sksl, "uint stepSsboIndex = %s.x;\n", RenderStep::ssboIndicesAttribute());
522 sksl += EmitUniformsFromStorageBuffer("step", "stepSsboIndex", step->uniforms());
523 }
524
525 sksl += step->vertexSkSL();
526 sksl += "sk_Position = float4(devPosition.xy * rtAdjust.xy + devPosition.ww * rtAdjust.zw,"
527 "devPosition.zw);";
528
529 if (useShadingStorageBuffer) {
530 // Assign SSBO index values to the SSBO index varying.
532 "%s = %s;",
533 RenderStep::ssboIndicesVarying(),
534 RenderStep::ssboIndicesAttribute());
535 }
536
537 if (defineLocalCoordsVarying) {
538 // Assign Render Step's stepLocalCoords to the localCoordsVar varying.
539 sksl += "localCoordsVar = stepLocalCoords;";
540 }
541 sksl += "}";
542
543 result.fSkSL = std::move(sksl);
544 result.fLabel = step->name();
545 if (defineLocalCoordsVarying) {
546 result.fLabel += " (w/ local coords)";
547 }
548
549 return result;
550}
std::string EmitRenderStepStorageBuffer(int bufferID, SkSpan< const Uniform > uniforms)
std::string EmitRenderStepUniforms(int bufferID, const Layout layout, SkSpan< const Uniform > uniforms, int *renderStepUniformsTotalBytes)
std::string EmitVaryings(const RenderStep *step, const char *direction, bool emitSsboIndicesVarying, bool emitLocalCoordsVarying)
std::string EmitUniformsFromStorageBuffer(const char *bufferNamePrefix, const char *ssboIndex, SkSpan< const Uniform > uniforms)

◆ can_do_yuv_tiling_in_hw()

static bool skgpu::graphite::can_do_yuv_tiling_in_hw ( const Caps caps,
const YUVImageShaderBlock::ImageData imgData 
)
static

Definition at line 784 of file KeyHelpers.cpp.

785 {
786 if (!caps->clampToBorderSupport() && (imgData.fTileModes[0] == SkTileMode::kDecal ||
787 imgData.fTileModes[1] == SkTileMode::kDecal)) {
788 return false;
789 }
790 // We depend on the subset code to handle cases where the UV dimensions times the
791 // subsample factors are not equal to the Y dimensions.
792 if (imgData.fImgSize != imgData.fImgSizeUV) {
793 return false;
794 }
795 // For nearest filtering when the Y texture size is larger than the UV texture size,
796 // we use linear filtering for the UV texture. In this case we also adjust pixel centers
797 // which may affect dependent texture reads.
798 if (imgData.fSampling.filter != imgData.fSamplingUV.filter) {
799 return false;
800 }
801 return imgData.fSubset.contains(SkRect::Make(imgData.fImgSize));
802}
bool clampToBorderSupport() const
Definition: Caps.h:224
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
bool contains(SkScalar x, SkScalar y) const
Definition: extension.cpp:19
const SkFilterMode filter

◆ check_max_blit_width()

static bool skgpu::graphite::check_max_blit_width ( int  widthInPixels)
static

Definition at line 779 of file MtlCommandBuffer.mm.

779 {
780 if (widthInPixels > 32767) {
781 SkASSERT(false); // surfaces should not be this wide anyway
782 return false;
783 }
784 return true;
785}

◆ check_shader_module()

static bool skgpu::graphite::check_shader_module ( const DawnSharedContext sharedContext,
wgpu::ShaderModule *  module,
const char *  shaderText,
ShaderErrorHandler errorHandler 
)
static

Definition at line 94 of file DawnGraphiteUtils.cpp.

97 {
98 // Prior to emsdk 3.1.51 wgpu::ShaderModule::GetCompilationInfo is unimplemented.
99#if defined(__EMSCRIPTEN__) && \
100 ((__EMSCRIPTEN_major__ < 3 || \
101 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ < 1) || \
102 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ < 51)))
103 return true;
104#else
105 struct Handler {
106 static void Fn(WGPUCompilationInfoRequestStatus status,
107 const WGPUCompilationInfo* info,
108 void* userdata) {
109 Handler* self = reinterpret_cast<Handler*>(userdata);
110 SkASSERT(status == WGPUCompilationInfoRequestStatus_Success);
111
112 // Walk the message list and check for hard errors.
113 self->fSuccess = true;
114 for (size_t index = 0; index < info->messageCount; ++index) {
115 const WGPUCompilationMessage& entry = info->messages[index];
116 if (entry.type == WGPUCompilationMessageType_Error) {
117 self->fSuccess = false;
118 break;
119 }
120 }
121
122 // If we found a hard error, report the compilation messages to the error handler.
123 if (!self->fSuccess) {
124 std::string errors;
125 for (size_t index = 0; index < info->messageCount; ++index) {
126 const WGPUCompilationMessage& entry = info->messages[index];
127 errors += "line " +
128 std::to_string(entry.lineNum) + ':' +
129 std::to_string(entry.linePos) + ' ' +
130 entry.message + '\n';
131 }
132 self->fErrorHandler->compileError(
133 self->fShaderText, errors.c_str(), /*shaderWasCached=*/false);
134 }
135 }
136
137 const char* fShaderText;
138 ShaderErrorHandler* fErrorHandler;
139 bool fSuccess = false;
140 };
141
142 Handler handler;
143 handler.fShaderText = shaderText;
144 handler.fErrorHandler = errorHandler;
145#if defined(__EMSCRIPTEN__)
146 // Deprecated function.
147 module->GetCompilationInfo(&Handler::Fn, &handler);
148#else
149 // New API.
150 wgpu::FutureWaitInfo waitInfo{};
151 waitInfo.future = module->GetCompilationInfo(
152 wgpu::CallbackMode::WaitAnyOnly,
153 [handlerPtr = &handler](wgpu::CompilationInfoRequestStatus status,
154 const wgpu::CompilationInfo* info) {
155 Handler::Fn(static_cast<WGPUCompilationInfoRequestStatus>(status),
156 reinterpret_cast<const WGPUCompilationInfo*>(info),
157 handlerPtr);
158 });
159
160 const auto& instance = static_cast<const DawnSharedContext*>(sharedContext)
161 ->device()
162 .GetAdapter()
163 .GetInstance();
164 [[maybe_unused]] auto status =
165 instance.WaitAny(1, &waitInfo, /*timeoutNS=*/std::numeric_limits<uint64_t>::max());
166 SkASSERT(status == wgpu::WaitStatus::Success);
167#endif // defined(__EMSCRIPTEN__)
168
169 return handler.fSuccess;
170#endif
171}
VkDevice device
Definition: main.cc:53
VkInstance instance
Definition: main.cc:48
static SkString to_string(int n)
Definition: nanobench.cpp:119

◆ color_type_fallback()

static SkColorType skgpu::graphite::color_type_fallback ( SkColorType  ct)
inlinestatic

Definition at line 92 of file Caps.cpp.

92 {
93 switch (ct) {
94 // kRGBA_8888 is our default fallback for many color types that may not have renderable
95 // backend formats.
109 default:
111 }
112}
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ 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
@ 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
@ 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
@ 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_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition: SkColorType.h:27
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition: SkColorType.h:36
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20

◆ compare_op_to_vk_compare_op()

static VkCompareOp skgpu::graphite::compare_op_to_vk_compare_op ( CompareOp  op)
static

Definition at line 195 of file VulkanGraphicsPipeline.cpp.

195 {
196 static const VkCompareOp gTable[] = {
197 VK_COMPARE_OP_ALWAYS, // kAlways
198 VK_COMPARE_OP_NEVER, // kNever
199 VK_COMPARE_OP_GREATER, // kGreater
201 VK_COMPARE_OP_LESS, // kLess
203 VK_COMPARE_OP_EQUAL, // kEqual
204 VK_COMPARE_OP_NOT_EQUAL, // kNotEqual
205 };
206 static_assert(std::size(gTable) == kCompareOpCount);
207 static_assert(0 == (int)CompareOp::kAlways);
208 static_assert(1 == (int)CompareOp::kNever);
209 static_assert(2 == (int)CompareOp::kGreater);
210 static_assert(3 == (int)CompareOp::kGEqual);
211 static_assert(4 == (int)CompareOp::kLess);
212 static_assert(5 == (int)CompareOp::kLEqual);
213 static_assert(6 == (int)CompareOp::kEqual);
214 static_assert(7 == (int)CompareOp::kNotEqual);
216
217 return gTable[(int)op];
218}
static constexpr int kCompareOpCount
Definition: DrawTypes.h:159
VkCompareOp
Definition: vulkan_core.h:1918
@ VK_COMPARE_OP_LESS_OR_EQUAL
Definition: vulkan_core.h:1922
@ VK_COMPARE_OP_LESS
Definition: vulkan_core.h:1920
@ VK_COMPARE_OP_NOT_EQUAL
Definition: vulkan_core.h:1924
@ VK_COMPARE_OP_NEVER
Definition: vulkan_core.h:1919
@ VK_COMPARE_OP_ALWAYS
Definition: vulkan_core.h:1926
@ VK_COMPARE_OP_EQUAL
Definition: vulkan_core.h:1921
@ VK_COMPARE_OP_GREATER_OR_EQUAL
Definition: vulkan_core.h:1925
@ VK_COMPARE_OP_GREATER
Definition: vulkan_core.h:1923

◆ Compose()

void skgpu::graphite::Compose ( const KeyContext keyContext,
PaintParamsKeyBuilder keyBuilder,
PipelineDataGatherer gatherer,
AddToKeyFn  addInnerToKey,
AddToKeyFn  addOuterToKey 
)

Definition at line 112 of file PaintParams.cpp.

116 {
117 ComposeBlock::BeginBlock(keyContext, keyBuilder, gatherer);
118
119 addInnerToKey();
120
121 addOuterToKey();
122
123 keyBuilder->endBlock(); // ComposeBlock
124}

◆ compute_combined_buffer_size()

std::pair< size_t, size_t > skgpu::graphite::compute_combined_buffer_size ( const Caps caps,
int  mipLevelCount,
size_t  bytesPerBlock,
const SkISize baseDimensions,
SkTextureCompressionType  compressionType,
TArray< std::pair< size_t, size_t > > *  levelOffsetsAndRowBytes 
)

Definition at line 49 of file UploadTask.cpp.

55 {
56 SkASSERT(levelOffsetsAndRowBytes && !levelOffsetsAndRowBytes->size());
57 SkASSERT(mipLevelCount >= 1);
58
59 SkISize compressedBlockDimensions = CompressedDimensionsInBlocks(compressionType,
60 baseDimensions);
61
62 size_t minTransferBufferAlignment =
63 std::max(bytesPerBlock, caps->requiredTransferBufferAlignment());
64 size_t alignedBytesPerRow =
65 caps->getAlignedTextureDataRowBytes(compressedBlockDimensions.width() * bytesPerBlock);
66
67 levelOffsetsAndRowBytes->push_back({0, alignedBytesPerRow});
68 size_t combinedBufferSize = SkAlignTo(alignedBytesPerRow * baseDimensions.height(),
69 minTransferBufferAlignment);
70 SkISize levelDimensions = baseDimensions;
71
72 for (int currentMipLevel = 1; currentMipLevel < mipLevelCount; ++currentMipLevel) {
73 levelDimensions = {std::max(1, levelDimensions.width() / 2),
74 std::max(1, levelDimensions.height() / 2)};
75 compressedBlockDimensions = CompressedDimensionsInBlocks(compressionType, levelDimensions);
76 alignedBytesPerRow = caps->getAlignedTextureDataRowBytes(
77 compressedBlockDimensions.width() * bytesPerBlock);
78 size_t alignedSize = SkAlignTo(alignedBytesPerRow * compressedBlockDimensions.height(),
79 minTransferBufferAlignment);
80 SkASSERT(combinedBufferSize % minTransferBufferAlignment == 0);
81
82 levelOffsetsAndRowBytes->push_back({combinedBufferSize, alignedBytesPerRow});
83 combinedBufferSize += alignedSize;
84 }
85
86 SkASSERT(levelOffsetsAndRowBytes->size() == mipLevelCount);
87 SkASSERT(combinedBufferSize % minTransferBufferAlignment == 0);
88 return {combinedBufferSize, minTransferBufferAlignment};
89}
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
Definition: SkAlign.h:33
size_t getAlignedTextureDataRowBytes(size_t rowBytes) const
Definition: Caps.h:166
size_t requiredTransferBufferAlignment() const
Definition: Caps.h:163
int size() const
Definition: SkTArray.h:421
SkISize CompressedDimensionsInBlocks(SkTextureCompressionType type, SkISize baseDimensions)
Definition: DataUtils.cpp:210
Definition: SkSize.h:16
constexpr int32_t height() const
Definition: SkSize.h:37

◆ ComputeShaderCoverageMaskTargetFormat()

SkColorType skgpu::graphite::ComputeShaderCoverageMaskTargetFormat ( const Caps caps)

Definition at line 855 of file TextureUtils.cpp.

855 {
856 // GPU compute coverage mask renderers need to bind the mask texture as a storage binding, which
857 // support a limited set of color formats. In general, we use RGBA8 if Alpha8 can't be
858 // supported.
861 }
863}
virtual TextureInfo getDefaultStorageTextureInfo(SkColorType) const =0
virtual bool isStorage(const TextureInfo &) const =0

◆ ComputeSize()

size_t skgpu::graphite::ComputeSize ( SkISize  dimensions,
const TextureInfo info 
)

Definition at line 535 of file TextureUtils.cpp.

536 {
537
538 SkTextureCompressionType compression = info.compressionType();
539
540 size_t colorSize = 0;
541
542 if (compression != SkTextureCompressionType::kNone) {
543 colorSize = SkCompressedFormatDataSize(compression,
544 dimensions,
545 info.mipmapped() == Mipmapped::kYes);
546 } else {
547 // TODO: Should we make sure the backends return zero here if the TextureInfo is for a
548 // memoryless texture?
549 size_t bytesPerPixel = info.bytesPerPixel();
550
551 colorSize = (size_t)dimensions.width() * dimensions.height() * bytesPerPixel;
552 }
553
554 size_t finalSize = colorSize * info.numSamples();
555
556 if (info.mipmapped() == Mipmapped::kYes) {
557 finalSize += colorSize/3;
558 }
559 return finalSize;
560}
size_t SkCompressedFormatDataSize(SkTextureCompressionType compressionType, SkISize dimensions, bool mipmapped)
SkTextureCompressionType

◆ ContextTypeBackend()

skgpu::BackendApi skgpu::graphite::ContextTypeBackend ( skgpu::ContextType  type)

Definition at line 128 of file ContextType.cpp.

128 {
129 switch (type) {
140 return BackendApi::kUnsupported;
141
143 return BackendApi::kVulkan;
144
146 return BackendApi::kMetal;
147
148 case ContextType::kDawn_D3D11:
149 case ContextType::kDawn_D3D12:
150 case ContextType::kDawn_Metal:
151 case ContextType::kDawn_Vulkan:
152 case ContextType::kDawn_OpenGL:
153 case ContextType::kDawn_OpenGLES:
154 return BackendApi::kDawn;
155
156 case ContextType::kMock:
157 return BackendApi::kMock;
158 }
160}
@ kVulkan
Definition: embedder.h:86
@ kGLES
OpenGL context.
@ kANGLE_GL_ES2
ANGLE on Direct3D11 OpenGL ES 3 context.
@ kANGLE_GL_ES3
ANGLE on OpenGL OpenGL ES 2 context.
@ kANGLE_D3D11_ES2
ANGLE on Direct3D9 OpenGL ES 2 context.
@ kVulkan
ANGLE on Metal ES 3 context.
@ 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.

◆ CopyAsDraw()

sk_sp< Image > skgpu::graphite::CopyAsDraw ( Recorder recorder,
const SkImage image,
const SkIRect subset,
const SkColorInfo dstColorInfo,
Budgeted  budgeted,
Mipmapped  mipmapped,
SkBackingFit  backingFit,
std::string_view  label 
)

Definition at line 562 of file TextureUtils.cpp.

569 {
570 SkColorType ct = recorder->priv().caps()->getRenderableColorType(dstColorInfo.colorType());
571 if (ct == kUnknown_SkColorType) {
572 return nullptr;
573 }
574 SkImageInfo dstInfo = SkImageInfo::Make(subset.size(),
575 dstColorInfo.makeColorType(ct)
577 // The surface goes out of scope when we return, so it can be scratch, but it may or may
578 // not be budgeted depending on how the copied image is used (or returned to the client).
579 auto surface = Surface::MakeScratch(recorder,
580 dstInfo,
581 std::move(label),
582 budgeted,
583 mipmapped,
584 backingFit);
585 if (!surface) {
586 return nullptr;
587 }
588
590 paint.setBlendMode(SkBlendMode::kSrc);
591 surface->getCanvas()->drawImage(image, -subset.left(), -subset.top(),
593 // And the image draw into `surface` is flushed when it goes out of scope
594 return surface->asImage();
595}
SkColorType
Definition: SkColorType.h:19
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.cpp:76
SkColorInfo makeColorType(SkColorType newColorType) const
Definition: SkImageInfo.cpp:80
SkColorType getRenderableColorType(SkColorType) const
Definition: Caps.cpp:114
const Paint & paint
Definition: color_source.cc:38
constexpr int32_t top() const
Definition: SkRect.h:120
constexpr SkISize size() const
Definition: SkRect.h:172
constexpr int32_t left() const
Definition: SkRect.h:113
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ create_color_and_offset_bitmap()

static SkBitmap skgpu::graphite::create_color_and_offset_bitmap ( int  numStops,
const SkPMColor4f colors,
const float *  offsets 
)
static

Definition at line 2170 of file KeyHelpers.cpp.

2172 {
2173 SkBitmap colorsAndOffsetsBitmap;
2174
2175 colorsAndOffsetsBitmap.allocPixels(
2177
2178 for (int i = 0; i < numStops; i++) {
2179 // TODO: there should be a way to directly set a premul pixel in a bitmap with
2180 // a premul color.
2181 SkColor4f unpremulColor = colors[i].unpremul();
2182 colorsAndOffsetsBitmap.erase(unpremulColor, SkIRect::MakeXYWH(i, 0, 1, 1));
2183
2184 float offset = offsets ? offsets[i] : SkIntToFloat(i) / (numStops - 1);
2185 SkASSERT(offset >= 0.0f && offset <= 1.0f);
2186
2187 int exponent;
2188 float mantissa = frexp(offset, &exponent);
2189
2190 SkHalf halfE = SkFloatToHalf(exponent);
2191 if ((int)SkHalfToFloat(halfE) != exponent) {
2192 SKGPU_LOG_W("Encoding gradient to f16 failed");
2193 return {};
2194 }
2195
2196#if defined(SK_DEBUG)
2197 SkHalf halfM = SkFloatToHalf(mantissa);
2198
2199 float restored = ldexp(SkHalfToFloat(halfM), (int)SkHalfToFloat(halfE));
2200 float error = abs(restored - offset);
2201 SkASSERT(error < 0.001f);
2202#endif
2203
2204 // TODO: we're only using 2 of the f16s here. The encoding could be altered to better
2205 // preserve precision. This encoding yields < 0.001f error for 2^20 evenly spaced stops.
2206 colorsAndOffsetsBitmap.erase(SkColor4f{mantissa, (float)exponent, 0, 1},
2207 SkIRect::MakeXYWH(i, 1, 1, 1));
2208 }
2209
2210 return colorsAndOffsetsBitmap;
2211}
float SkHalfToFloat(SkHalf h)
Definition: SkHalf.cpp:24
SkHalf SkFloatToHalf(float f)
Definition: SkHalf.cpp:16
uint16_t SkHalf
Definition: SkHalf.h:16
#define SkIntToFloat(x)
Definition: SkScalar.h:58
void allocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:258
void erase(SkColor4f c, const SkIRect &area) const
Definition: SkBitmap.cpp:420
const uint8_t uint32_t uint32_t GError ** error
list offsets
Definition: mskp_parser.py:37
SIN Vec< N, float > abs(const Vec< N, float > &x)
Definition: SkVx.h:707
SeparatedVector2 offset
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition: SkRect.h:104

◆ create_image_data()

static sk_sp< SkData > skgpu::graphite::create_image_data ( const SkImageInfo info)
static

Definition at line 81 of file GraphiteResourceCacheTest.cpp.

81 {
82 const size_t rowBytes = info.minRowBytes();
84 {
85 SkBitmap bm;
86 bm.installPixels(info, data->writable_data(), rowBytes);
87 SkCanvas canvas(bm);
88 canvas.clear(SK_ColorRED);
89 }
90 return data;
91}
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition: SkBitmap.cpp:323
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition: SkData.cpp:116

◆ createVulkanShaderModule()

VkShaderModule skgpu::graphite::createVulkanShaderModule ( const VulkanSharedContext context,
const std::string &  spirv,
VkShaderStageFlagBits  stage 
)

Definition at line 44 of file VulkanGraphiteUtils.cpp.

46 {
47 TRACE_EVENT0("skia.shaders", "InstallVkShaderModule");
48 VkShaderModuleCreateInfo moduleCreateInfo;
49 memset(&moduleCreateInfo, 0, sizeof(VkShaderModuleCreateInfo));
51 moduleCreateInfo.pNext = nullptr;
52 moduleCreateInfo.flags = 0;
53 moduleCreateInfo.codeSize = spirv.size();
54 moduleCreateInfo.pCode = (const uint32_t*)spirv.c_str();
55
56 VkShaderModule shaderModule;
58 VULKAN_CALL_RESULT(context,
59 result,
60 CreateShaderModule(context->device(),
61 &moduleCreateInfo,
62 /*const VkAllocationCallbacks*=*/nullptr,
63 &shaderModule));
64 if (result != VK_SUCCESS) {
65 SKGPU_LOG_E("Failed to create VkShaderModule");
66 return VK_NULL_HANDLE;
67 }
68 return shaderModule;
69}
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
#define VULKAN_CALL_RESULT(SHARED_CONTEXT, RESULT, X)
VkShaderModuleCreateFlags flags
Definition: vulkan_core.h:3480
const uint32_t * pCode
Definition: vulkan_core.h:3482
VkStructureType sType
Definition: vulkan_core.h:3478
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131
VkResult
Definition: vulkan_core.h:140
@ VK_SUCCESS
Definition: vulkan_core.h:141
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
@ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
Definition: vulkan_core.h:218

◆ DawnCompileWGSLShaderModule()

bool skgpu::graphite::DawnCompileWGSLShaderModule ( const DawnSharedContext sharedContext,
const char *  label,
const std::string &  wgsl,
wgpu::ShaderModule *  module,
ShaderErrorHandler errorHandler 
)

Definition at line 173 of file DawnGraphiteUtils.cpp.

177 {
178 wgpu::ShaderModuleWGSLDescriptor wgslDesc;
179 wgslDesc.code = wgsl.c_str();
180
181 wgpu::ShaderModuleDescriptor desc;
182 desc.nextInChain = &wgslDesc;
183 if (sharedContext->caps()->setBackendLabels()) {
184 desc.label = label;
185 }
186
187 *module = sharedContext->device().CreateShaderModule(&desc);
188
189 return check_shader_module(sharedContext, module, wgsl.c_str(), errorHandler);
190}
bool setBackendLabels() const
Definition: Caps.h:297
const wgpu::Device & device() const
const Caps * caps() const
Definition: SharedContext.h:39
static bool check_shader_module(const DawnSharedContext *sharedContext, wgpu::ShaderModule *module, const char *shaderText, ShaderErrorHandler *errorHandler)

◆ DawnDepthStencilFlagsToFormat()

wgpu::TextureFormat skgpu::graphite::DawnDepthStencilFlagsToFormat ( SkEnumBitMask< DepthStencilFlags mask)

Definition at line 78 of file DawnGraphiteUtils.cpp.

78 {
79 // TODO: Decide if we want to change this to always return a combined depth and stencil format
80 // to allow more sharing of depth stencil allocations.
81 if (mask == DepthStencilFlags::kDepth) {
82 // If needed for workarounds or performance, Depth32Float is also available but requires 2x
83 // the amount of memory.
84 return wgpu::TextureFormat::Depth16Unorm;
85 } else if (mask == DepthStencilFlags::kStencil) {
86 return wgpu::TextureFormat::Stencil8;
87 } else if (mask == DepthStencilFlags::kDepthStencil) {
88 return wgpu::TextureFormat::Depth24PlusStencil8;
89 }
90 SkASSERT(false);
91 return wgpu::TextureFormat::Undefined;
92}

◆ DawnFormatBytesPerBlock()

size_t skgpu::graphite::DawnFormatBytesPerBlock ( wgpu::TextureFormat  format)

Definition at line 21 of file DawnUtils.cpp.

21 {
22 switch (format) {
23 case wgpu::TextureFormat::RGBA8Unorm: return 4;
24 case wgpu::TextureFormat::BGRA8Unorm: return 4;
25 case wgpu::TextureFormat::R8Unorm: return 1;
26 case wgpu::TextureFormat::RGBA16Float: return 8;
27 case wgpu::TextureFormat::R16Float: return 2;
28 case wgpu::TextureFormat::RG8Unorm: return 2;
29 case wgpu::TextureFormat::RGB10A2Unorm: return 4;
30 case wgpu::TextureFormat::RG16Float: return 4;
31 // The depth stencil values are not neccessarily correct in Dawn since Dawn is allowed to
32 // implement Stencil8 as a real stencil8 or depth24stencil8 format. Similarly the depth in
33 // Depth24PlusStencil8 can either be a 24 bit value or Depth32Float value. There is also
34 // currently no way to query this in WebGPU so we just use the highest values here.
35 case wgpu::TextureFormat::Stencil8: return 4; // could be backed by d24s8
36 case wgpu::TextureFormat::Depth16Unorm: return 2;
37 case wgpu::TextureFormat::Depth32Float: return 4;
38 case wgpu::TextureFormat::Depth32FloatStencil8: return 5;
39 case wgpu::TextureFormat::Depth24PlusStencil8: return 5; // could be backed by d32s8
40
41#if !defined(__EMSCRIPTEN__)
42 case wgpu::TextureFormat::R16Unorm: return 2;
43 case wgpu::TextureFormat::RG16Unorm: return 4;
44 // Note: We don't actually know the size of external formats, so this
45 // is an arbitrary value. We will see external formats only in wrapped
46 // SkImages, so this won't impact Skia's internal budgeting.
47 case wgpu::TextureFormat::External:
48 return 4;
49#endif
50 default:
52 }
53}
uint32_t uint32_t * format

◆ DawnFormatChannels()

uint32_t skgpu::graphite::DawnFormatChannels ( wgpu::TextureFormat  format)

Definition at line 63 of file DawnUtils.cpp.

63 {
64 switch (format) {
65 case wgpu::TextureFormat::RGBA8Unorm: return kRGBA_SkColorChannelFlags;
66 case wgpu::TextureFormat::BGRA8Unorm: return kRGBA_SkColorChannelFlags;
67 case wgpu::TextureFormat::R8Unorm: return kRed_SkColorChannelFlag;
68 case wgpu::TextureFormat::RGBA16Float: return kRGBA_SkColorChannelFlags;
69 case wgpu::TextureFormat::R16Float: return kRed_SkColorChannelFlag;
70 case wgpu::TextureFormat::RG8Unorm: return kRG_SkColorChannelFlags;
71 case wgpu::TextureFormat::RGB10A2Unorm: return kRGBA_SkColorChannelFlags;
72 case wgpu::TextureFormat::RG16Float: return kRG_SkColorChannelFlags;
73
74#if !defined(__EMSCRIPTEN__)
75 case wgpu::TextureFormat::R16Unorm: return kRed_SkColorChannelFlag;
76 case wgpu::TextureFormat::RG16Unorm: return kRG_SkColorChannelFlags;
77#endif
78
79 default: return 0;
80 }
82}
@ kRGBA_SkColorChannelFlags
Definition: SkColor.h:248
@ kRed_SkColorChannelFlag
Definition: SkColor.h:239
@ kRG_SkColorChannelFlags
Definition: SkColor.h:246

◆ DawnFormatIsDepth()

bool skgpu::graphite::DawnFormatIsDepth ( wgpu::TextureFormat  format)

Definition at line 55 of file DawnGraphiteUtils.cpp.

55 {
56 switch (format) {
57 case wgpu::TextureFormat::Depth16Unorm: [[fallthrough]];
58 case wgpu::TextureFormat::Depth32Float:
59 case wgpu::TextureFormat::Depth24PlusStencil8:
60 case wgpu::TextureFormat::Depth32FloatStencil8:
61 return true;
62 default:
63 return false;
64 }
65}

◆ DawnFormatIsDepthOrStencil()

bool skgpu::graphite::DawnFormatIsDepthOrStencil ( wgpu::TextureFormat  format)

Definition at line 42 of file DawnGraphiteUtils.cpp.

42 {
43 switch (format) {
44 case wgpu::TextureFormat::Stencil8: [[fallthrough]];
45 case wgpu::TextureFormat::Depth16Unorm:
46 case wgpu::TextureFormat::Depth32Float:
47 case wgpu::TextureFormat::Depth24PlusStencil8:
48 case wgpu::TextureFormat::Depth32FloatStencil8:
49 return true;
50 default:
51 return false;
52 }
53}

◆ DawnFormatIsStencil()

bool skgpu::graphite::DawnFormatIsStencil ( wgpu::TextureFormat  format)

Definition at line 67 of file DawnGraphiteUtils.cpp.

67 {
68 switch (format) {
69 case wgpu::TextureFormat::Stencil8: [[fallthrough]];
70 case wgpu::TextureFormat::Depth24PlusStencil8:
71 case wgpu::TextureFormat::Depth32FloatStencil8:
72 return true;
73 default:
74 return false;
75 }
76}

◆ DawnFormatToCompressionType()

SkTextureCompressionType skgpu::graphite::DawnFormatToCompressionType ( wgpu::TextureFormat  format)

Definition at line 55 of file DawnUtils.cpp.

55 {
56 switch (format) {
57 case wgpu::TextureFormat::ETC2RGB8Unorm: return SkTextureCompressionType::kETC2_RGB8_UNORM;
58 case wgpu::TextureFormat::BC1RGBAUnorm: return SkTextureCompressionType::kBC1_RGBA8_UNORM;
59 default: return SkTextureCompressionType::kNone;
60 }
61}

◆ DawnNativeProcessEventsFunction()

SK_API void skgpu::graphite::DawnNativeProcessEventsFunction ( const wgpu::Instance &  instance)
inline

Definition at line 45 of file DawnBackendContext.h.

45 {
46 instance.ProcessEvents();
47}

◆ DawnTextureInfoFromWGPUTexture()

DawnTextureInfo skgpu::graphite::DawnTextureInfoFromWGPUTexture ( WGPUTexture  texture)

Definition at line 21 of file DawnTypesPriv.cpp.

21 {
23 return DawnTextureInfo(
24 wgpuTextureGetSampleCount(texture),
25 wgpuTextureGetMipLevelCount(texture) > 1 ? Mipmapped::kYes : Mipmapped::kNo,
26 /*format=*/static_cast<wgpu::TextureFormat>(wgpuTextureGetFormat(texture)),
27 /*viewFormat=*/static_cast<wgpu::TextureFormat>(wgpuTextureGetFormat(texture)),
28 static_cast<wgpu::TextureUsage>(wgpuTextureGetUsage(texture)),
29 wgpu::TextureAspect::All, /*slice=*/0);
30}
FlTexture * texture
TextureUsage
Definition: formats.h:300

◆ DawnTextureSpecToTextureInfo()

DawnTextureInfo skgpu::graphite::DawnTextureSpecToTextureInfo ( const DawnTextureSpec dawnSpec,
uint32_t  sampleCount,
Mipmapped  mipmapped 
)

Definition at line 32 of file DawnTypesPriv.cpp.

34 {
36 // Shared info
37 info.fSampleCount = sampleCount;
38 info.fMipmapped = mipmapped;
39
40 // Dawn info
41 info.fFormat = dawnSpec.fFormat;
42 info.fViewFormat = dawnSpec.fViewFormat;
43 info.fUsage = dawnSpec.fUsage;
44 info.fAspect = dawnSpec.fAspect;
45#if !defined(__EMSCRIPTEN__)
46 info.fYcbcrVkDescriptor = dawnSpec.fYcbcrVkDescriptor;
47#endif
48
49 return info;
50}
wgpu::YCbCrVkDescriptor fYcbcrVkDescriptor
Definition: DawnTypesPriv.h:62
wgpu::TextureFormat fViewFormat
Definition: DawnTypesPriv.h:58

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [1/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphiteBudgetedResourcesTest  ,
reporter  ,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 100 of file GraphiteResourceCacheTest.cpp.

105 {
106 std::unique_ptr<Recorder> recorder = context->makeRecorder();
107 ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
108 ResourceCache* resourceCache = resourceProvider->resourceCache();
109 const SharedContext* sharedContext = resourceProvider->sharedContext();
110
111 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
112 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 0);
113
114 // Test making a non budgeted, non shareable resource.
116 sharedContext, Ownership::kOwned, skgpu::Budgeted::kNo, Shareable::kNo);
117 if (!resource) {
118 ERRORF(reporter, "Failed to make TestResource");
119 return;
120 }
121 Resource* resourcePtr = resource.get();
122
124 resourceCache->insertResource(resourcePtr);
125 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
126 // Resource is not shareable and we have a ref on it. Thus it shouldn't ben findable in the
127 // cache.
128 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 0);
129
130 // When we reset our TestResource it should go back into the cache since it can be used as a
131 // scratch texture (since it is not shareable). At that point the budget should be changed to
132 // skgpu::Budgeted::kYes.
133 resource.reset();
134 resourceCache->forceProcessReturnedResources();
135 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
136 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 1);
137 // Even though we reset our ref on the resource we still have the ptr to it and should be the
138 // resource in the cache. So in general this is dangerous it should be safe for this test to
139 // directly access the texture.
140 REPORTER_ASSERT(reporter, resourcePtr->budgeted() == skgpu::Budgeted::kYes);
141
142 GraphiteResourceKey key;
143 TestResource::CreateKey(&key, Shareable::kNo);
144 Resource* resourcePtr2 = resourceCache->findAndRefResource(key, skgpu::Budgeted::kNo);
145 REPORTER_ASSERT(reporter, resourcePtr == resourcePtr2);
146 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
147 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 0);
148 REPORTER_ASSERT(reporter, resourcePtr2->budgeted() == skgpu::Budgeted::kNo);
149 resourcePtr2->unref();
150 resourceCache->forceProcessReturnedResources();
151
152 // Test making a budgeted, shareable resource.
154 sharedContext, Ownership::kOwned, skgpu::Budgeted::kYes, Shareable::kYes);
155 if (!resource) {
156 ERRORF(reporter, "Failed to make TestResource");
157 return;
158 }
159 resourcePtr = resource.get();
161 resourceCache->insertResource(resourcePtr);
162 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
163 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 2);
164
165 resource.reset();
166 resourceCache->forceProcessReturnedResources();
167 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
168 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 2);
169 REPORTER_ASSERT(reporter, resourcePtr->budgeted() == skgpu::Budgeted::kYes);
170
171 TestResource::CreateKey(&key, Shareable::kYes);
172 resourcePtr2 = resourceCache->findAndRefResource(key, skgpu::Budgeted::kYes);
173 REPORTER_ASSERT(reporter, resourcePtr == resourcePtr2);
174 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
175 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 2);
176 REPORTER_ASSERT(reporter, resourcePtr2->budgeted() == skgpu::Budgeted::kYes);
177 resourcePtr2->unref();
178
179 ///////////////////////////////////////////////////////////////////////////////////////////////
180 // Test that SkImage's and SkSurface's underlying Resource's follow the expected budgeted
181 // system.
183
184 // First test SkImages. Since we can't directly create a Graphite SkImage we first have to make
185 // a raster SkImage than convert that to a Graphite SkImage via makeTextureImage.
187 sk_sp<SkImage> image = SkImages::RasterFromData(info, std::move(data), info.minRowBytes());
189
190 sk_sp<SkImage> imageGpu = SkImages::TextureFromImage(recorder.get(), image, {});
191 REPORTER_ASSERT(reporter, imageGpu);
192
193 TextureProxy* imageProxy = nullptr;
194 {
195 // We don't want the view holding a ref to the Proxy or else we can't send things back to
196 // the cache.
197 auto view = skgpu::graphite::AsView(imageGpu.get());
199 imageProxy = view.proxy();
200 }
201 // Make sure the proxy is instantiated
202 if (!imageProxy->instantiate(resourceProvider)) {
203 ERRORF(reporter, "Failed to instantiate Proxy");
204 return;
205 }
206 const Resource* imageResourcePtr = imageProxy->texture();
207 REPORTER_ASSERT(reporter, imageResourcePtr);
208 // There is an extra resource for the buffer that is uploading the data to the texture
209 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 4);
210 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 2);
211 REPORTER_ASSERT(reporter, imageResourcePtr->budgeted() == skgpu::Budgeted::kNo);
212
213 // Submit all upload work so we can drop refs to the image and get it returned to the cache.
214 std::unique_ptr<Recording> recording = recorder->snap();
215 if (!recording) {
216 ERRORF(reporter, "Failed to make recording");
217 return;
218 }
219 InsertRecordingInfo insertInfo;
220 insertInfo.fRecording = recording.get();
221 context->insertRecording(insertInfo);
222 testContext->syncedSubmit(context);
223 recording.reset();
224 imageGpu.reset();
225 resourceCache->forceProcessReturnedResources();
226
227 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 4);
228 // Remapping async buffers before returning them to the cache can extend buffer lifetime.
229 if (!context->priv().caps()->bufferMapsAreAsync()) {
230 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 4);
231 }
232 REPORTER_ASSERT(reporter, imageResourcePtr->budgeted() == skgpu::Budgeted::kYes);
233
234 // Now try an SkSurface. This is simpler since we can directly create Graphite SkSurface's.
236 if (!surface) {
237 ERRORF(reporter, "Failed to make surface");
238 return;
239 }
240
241 TextureProxy* surfaceProxy = top_device_graphite_target_proxy(surface->getCanvas());
242 if (!surfaceProxy) {
243 ERRORF(reporter, "Failed to get surface proxy");
244 return;
245 }
246
247 // Make sure the proxy is instantiated
248 if (!surfaceProxy->instantiate(resourceProvider)) {
249 ERRORF(reporter, "Failed to instantiate surface proxy");
250 return;
251 }
252 const Resource* surfaceResourcePtr = surfaceProxy->texture();
253
254 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 5);
255 // Remapping async buffers before returning them to the cache can extend buffer lifetime.
256 if (!context->priv().caps()->bufferMapsAreAsync()) {
257 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 4);
258 }
259 REPORTER_ASSERT(reporter, surfaceResourcePtr->budgeted() == skgpu::Budgeted::kNo);
260
261 // The creation of the surface may have added an initial clear to it. Thus if we just reset the
262 // surface it will flush the clean on the device and we don't be dropping all our refs to the
263 // surface. So we force all the work to happen first.
264 recording = recorder->snap();
265 insertInfo.fRecording = recording.get();
266 context->insertRecording(insertInfo);
267 testContext->syncedSubmit(context);
268 recording.reset();
269
270 surface.reset();
271 resourceCache->forceProcessReturnedResources();
272 REPORTER_ASSERT(reporter, surfaceResourcePtr->budgeted() == skgpu::Budgeted::kYes);
273}
reporter
Definition: FontMgrTest.cpp:39
static sk_sp< SkData > create_image_data(SkImageInfo *info)
Definition: ImageTest.cpp:145
static SkString resource(SkPDFResourceType type, int index)
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
#define ERRORF(r,...)
Definition: Test.h:293
void reset()
Definition: SkString.cpp:358
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310
Resource * findAndRefResource(const GraphiteResourceKey &key, skgpu::Budgeted)
SK_API sk_sp< SkImage > RasterFromData(const SkImageInfo &info, sk_sp< SkData > pixels, size_t rowBytes)
SK_API sk_sp< SkImage > TextureFromImage(GrDirectContext *, const SkImage *, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Budgeted=skgpu::Budgeted::kYes)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static skgpu::graphite::TextureProxy * top_device_graphite_target_proxy(SkCanvas *canvas)
TextureProxyView AsView(const SkImage *image)

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [2/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest10  ,
,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 446 of file ProxyCacheTest.cpp.

451 {
452 std::unique_ptr<Recorder> recorder = context->makeRecorder();
453 ProxyCache* proxyCache = recorder->priv().proxyCache();
454
455 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
456
457 bool regenerated;
458 sk_sp<TextureProxy> proxy1 = find_or_create_by_key(recorder.get(), 1, &regenerated);
459 REPORTER_ASSERT(r, proxy1 && proxy1->dimensions().width() == 32);
460 REPORTER_ASSERT(r, regenerated);
461
462 sk_sp<TextureProxy> proxy2 = find_or_create_by_key(recorder.get(), 2, &regenerated);
463 REPORTER_ASSERT(r, proxy2 && proxy2->dimensions().width() == 64);
464 REPORTER_ASSERT(r, regenerated);
465
466 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
467
468 // These cached proxies shouldn't be deleted because we hold local refs still
469 proxyCache->forceFreeUniquelyHeld();
470 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
471
472 // Cache hit should not invoke the bitmap generation function.
473 sk_sp<TextureProxy> proxy1b = find_or_create_by_key(recorder.get(), 1, &regenerated);
474 REPORTER_ASSERT(r, proxy1.get() == proxy1b.get());
475 REPORTER_ASSERT(r, !regenerated);
476
477 proxy1.reset();
478 proxy1b.reset();
479 proxy2.reset();
480 (void) recorder->snap(); // Dump pending commands to release internal refs to the cached proxies
481
482 // Now the cache should clean the cache entries up
483 proxyCache->forceFreeUniquelyHeld();
484 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
485
486 // And regeneration functions as expected
487 proxy1 = find_or_create_by_key(recorder.get(), 1, &regenerated);
488 REPORTER_ASSERT(r, proxy1 && proxy1->dimensions().width() == 32);
489 REPORTER_ASSERT(r, regenerated);
490}
static sk_sp< TextureProxy > find_or_create_by_key(Recorder *recorder, int id, bool *regenerated)

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [3/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest4  ,
,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 160 of file ProxyCacheTest.cpp.

165 {
166 std::unique_ptr<Recorder> recorder = context->makeRecorder();
167 ProxyCache* proxyCache = recorder->priv().proxyCache();
168
169 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
170 REPORTER_ASSERT(r, setup.valid());
171 if (!setup.valid()) {
172 return;
173 }
174
175 proxyCache->forceFreeUniquelyHeld();
176 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
177
178 setup.fProxy1.reset();
179 proxyCache->forceFreeUniquelyHeld();
180 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
181
182 setup.fProxy2.reset();
183 proxyCache->forceFreeUniquelyHeld();
184 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
185}
Definition: setup.py:1

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [4/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest5  ,
,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 188 of file ProxyCacheTest.cpp.

193 {
194 std::unique_ptr<Recorder> recorder = context->makeRecorder();
195 ProxyCache* proxyCache = recorder->priv().proxyCache();
196
197 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
198 REPORTER_ASSERT(r, setup.valid());
199 if (!setup.valid()) {
200 return;
201 }
202
203 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
204 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
205
206 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeBetweenProxyCreation);
207 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
208 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
209 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
210
211 sk_sp<TextureProxy> test = proxyCache->find(setup.fBitmap1);
212 REPORTER_ASSERT(r, !test); // proxy1 should've been purged
213
214 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeAfterAllProxyCreation);
215 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
216 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
217 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
218}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [5/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest6  ,
,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 222 of file ProxyCacheTest.cpp.

227 {
228 std::unique_ptr<Recorder> recorder = context->makeRecorder();
229 ProxyCache* proxyCache = recorder->priv().proxyCache();
230
231 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
232 REPORTER_ASSERT(r, setup.valid());
233 if (!setup.valid()) {
234 return;
235 }
236
237 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
238 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
239
240 // update proxy1's timestamp
241 sk_sp<TextureProxy> test = proxyCache->findOrCreateCachedProxy(recorder.get(), setup.fBitmap1,
242 "ProxyCacheTestTexture");
243 REPORTER_ASSERT(r, test == setup.fProxy1);
244
245 std::this_thread::sleep_for(std::chrono::milliseconds(2));
246 auto timeAfterProxy1Update = skgpu::StdSteadyClock::now();
247
248 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeBetweenProxyCreation);
249 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
250 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
251 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
252
253 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeAfterAllProxyCreation);
254 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
255 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
256 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
257
258 test = proxyCache->find(setup.fBitmap2);
259 REPORTER_ASSERT(r, !test); // proxy2 should've been purged
260
261 proxyCache->forcePurgeProxiesNotUsedSince(timeAfterProxy1Update);
262 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
263 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
264 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
265}
sk_sp< TextureProxy > findOrCreateCachedProxy(Recorder *, const SkBitmap &, std::string_view label)
Definition: ProxyCache.cpp:74

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [6/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest7  ,
,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 268 of file ProxyCacheTest.cpp.

273 {
274 std::unique_ptr<Recorder> recorder = context->makeRecorder();
275 ProxyCache* proxyCache = recorder->priv().proxyCache();
276
277 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
278 REPORTER_ASSERT(r, setup.valid());
279 if (!setup.valid()) {
280 return;
281 }
282
283 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
284 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
285
286 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeAfterAllProxyCreation);
287 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
288 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
289 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
290}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [7/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest8  ,
,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 293 of file ProxyCacheTest.cpp.

298 {
299 std::unique_ptr<Recorder> recorder = context->makeRecorder();
300 ResourceCache* resourceCache = recorder->priv().resourceCache();
301 ProxyCache* proxyCache = recorder->priv().proxyCache();
302
303 resourceCache->setMaxBudget(0);
304
305 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
306 REPORTER_ASSERT(r, setup.valid());
307 if (!setup.valid()) {
308 return;
309 }
310
311 resourceCache->forcePurgeAsNeeded();
312
313 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
314
315 setup.fProxy1.reset();
316 proxyCache->forceProcessInvalidKeyMsgs();
317
318 // unreffing fProxy1 and forcing message processing shouldn't purge proxy1 from the cache
319 sk_sp<TextureProxy> test = proxyCache->find(setup.fBitmap1);
321 test.reset();
322
323 resourceCache->forcePurgeAsNeeded();
324
325 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
326 test = proxyCache->find(setup.fBitmap1);
327 REPORTER_ASSERT(r, !test); // proxy1 should've been purged
328
329 setup.fProxy2.reset();
330 proxyCache->forceProcessInvalidKeyMsgs();
331
332 // unreffing fProxy2 and forcing message processing shouldn't purge proxy2 from the cache
333 test = proxyCache->find(setup.fBitmap2);
335 test.reset();
336
337 resourceCache->forcePurgeAsNeeded();
338
339 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
340}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [8/8]

skgpu::graphite::DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest9  ,
,
context  ,
testContext  ,
true  ,
CtsEnforcement::kNextRelease   
)

Definition at line 344 of file ProxyCacheTest.cpp.

349 {
350 std::unique_ptr<Recorder> recorder = context->makeRecorder();
351 ResourceCache* resourceCache = recorder->priv().resourceCache();
352 ProxyCache* proxyCache = recorder->priv().proxyCache();
353
354 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
355 REPORTER_ASSERT(r, setup.valid());
356 if (!setup.valid()) {
357 return;
358 }
359
360 REPORTER_ASSERT(r, setup.fProxy1->isInstantiated());
361 REPORTER_ASSERT(r, setup.fProxy2->isInstantiated());
362
363 if (!setup.fProxy1->texture() || !setup.fProxy2->texture()) {
364 return;
365 }
366
367 // Clear out resources used to setup bitmap proxies so we can track things easier.
368 resourceCache->setMaxBudget(0);
369 resourceCache->setMaxBudget(256 * (1 << 20));
370
371 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
372 int baselineResourceCount = resourceCache->getResourceCount();
373 // When buffer maps are async it can take extra time for buffers to be returned to the cache.
374 if (context->priv().caps()->bufferMapsAreAsync()) {
375 // We expect at least 2 textures (and possibly buffers).
376 REPORTER_ASSERT(r, baselineResourceCount >= 2);
377 } else {
378 REPORTER_ASSERT(r, baselineResourceCount == 2);
379 }
380 // Force a command buffer ref on the second proxy in the cache so it can't be purged immediately
381 setup.fProxy2->texture()->refCommandBuffer();
382
383 Resource* proxy2ResourcePtr = setup.fProxy2->texture();
384
385 setup.fProxy1.reset();
386 setup.fProxy2.reset();
387 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
388
389 auto timeAfterProxyCreation = skgpu::StdSteadyClock::now();
390
391 // This should trigger both proxies to be purged from the ProxyCache. The first proxy should
392 // immediately be purged from the ResourceCache as well since it has not other refs. The second
393 // proxy will not be purged from the ResourceCache since it still has a command buffer ref.
394 // However, that resource should have its deleteASAP flag set.
395 resourceCache->purgeResourcesNotUsedSince(timeAfterProxyCreation);
396
397 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
398 REPORTER_ASSERT(r, resourceCache->getResourceCount() == baselineResourceCount - 1);
399 REPORTER_ASSERT(r, resourceCache->topOfPurgeableQueue() == nullptr);
400 REPORTER_ASSERT(r, proxy2ResourcePtr->testingShouldDeleteASAP());
401
402 // Removing the command buffer ref and returning proxy2Resource to the cache should cause it to
403 // immediately get deleted without going in the purgeable queue.
404 proxy2ResourcePtr->unrefCommandBuffer();
405 resourceCache->forceProcessReturnedResources();
406
407 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
408 REPORTER_ASSERT(r, resourceCache->getResourceCount() == baselineResourceCount - 2);
409 REPORTER_ASSERT(r, resourceCache->topOfPurgeableQueue() == nullptr);
410}
void purgeResourcesNotUsedSince(StdSteadyClock::time_point purgeTime)

◆ DEF_GRAPHITE_TEST() [1/2]

skgpu::graphite::DEF_GRAPHITE_TEST ( skgpu_IntersectionTree  ,
reporter  ,
CtsEnforcement::kNextRelease   
)

Definition at line 32 of file IntersectionTreeTest.cpp.

32 {
33 SkRandom rand;
34 {
35 SimpleIntersectionTree simpleTree;
37 for (int i = 0; i < 1000; ++i) {
38 Rect rect = Rect::XYWH(rand.nextRangeF(0, 500),
39 rand.nextRangeF(0, 500),
40 rand.nextRangeF(0, 70),
41 rand.nextRangeF(0, 70));
42 CHECK(tree.add(rect) == simpleTree.add({rect.left(),
43 rect.top(),
44 rect.right(),
45 rect.bot()}));
46 }
47 }
48 {
49 SimpleIntersectionTree simpleTree;
50 IntersectionTree tree;
51 for (int i = 0; i < 100; ++i) {
52 Rect rect = Rect::XYWH(rand.nextRangeF(0, 500),
53 rand.nextRangeF(0, 500),
54 rand.nextRangeF(0, 200),
55 rand.nextRangeF(0, 200));
56 CHECK(tree.add(rect) == simpleTree.add({rect.left(),
57 rect.top(),
58 rect.right(),
59 rect.bot()}));
60 }
61 }
62 {
63 SimpleIntersectionTree simpleTree;
64 IntersectionTree tree;
65 CHECK(tree.add(Rect::Infinite()));
66 CHECK(!tree.add(Rect::WH(1,1)));
67 CHECK(!tree.add(Rect::WH(1,std::numeric_limits<float>::infinity())));
68 CHECK(tree.add(Rect::WH(0, 0)));
69 CHECK(tree.add(Rect::WH(-1, 1)));
70 CHECK(tree.add(Rect::WH(1, std::numeric_limits<float>::quiet_NaN())));
71 }
72}
#define CHECK(A)
float nextRangeF(float min, float max)
Definition: SkRandom.h:64
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
TRect< Scalar > Rect
Definition: rect.h:769

◆ DEF_GRAPHITE_TEST() [2/2]

skgpu::graphite::DEF_GRAPHITE_TEST ( skgpu_Rect  ,
reporter  ,
CtsEnforcement::kNextRelease   
)

Definition at line 15 of file RectTest.cpp.

15 {
16 using float2 = skvx::float2;
17 using float4 = skvx::float4;
18
19 const SkRect skRect = SkRect::MakeLTRB(1,-3,4,0);
20 const Rect rect = skRect;
21 CHECK(rect == rect);
22 CHECK(rect == skRect); // promotes 'skRect' to a Rect for ==
23 CHECK(rect.asSkRect() == skRect); // converts 'rect' to SkRect for ==
24
25 for (const float l : {0,1,2}) {
26 for (const float t : {-4,-3,-2}) {
27 for (const float r : {3,4,5}) {
28 for (const float b : {-1,0,1}) {
29 const Rect rect2(l,t,r,b);
30 const SkRect skRect2{l,t,r,b};
31
32 CHECK(rect2 == rect2);
33 CHECK(rect2 == Rect(float2(l,t), float2(r,b)));
34 CHECK(rect2 == Rect(skRect2));
35 CHECK(rect2.asSkRect() == skRect2);
36
37 CHECK((rect2 == rect) == (rect == rect2));
38 CHECK((rect2 != rect) == (rect != rect2));
39 CHECK((rect != rect2) == !(rect == rect2));
40
41 CHECK(rect2 == Rect::XYWH(l, t, r - l, b - t));
42 CHECK(rect2 == Rect::XYWH(float2(l, t), float2(r - l, b - t)));
43 if (l == 0 && t == 0) {
44 CHECK(rect2 == Rect::WH(r - l, b - t));
45 CHECK(rect2 == Rect::WH(float2(r - l, b - t)));
46 }
47 CHECK(rect2 == Rect::FromVals(rect2.vals()));
48
49 CHECK(rect2.x() == l);
50 CHECK(rect2.y() == t);
51 CHECK(rect2.left() == l);
52 CHECK(rect2.top() == t);
53 CHECK(rect2.right() == r);
54 CHECK(rect2.bot() == b);
55 CHECK(all(rect2.topLeft() == float2(l,t)));
56 CHECK(all(rect2.botRight() == float2(r,b)));
57 CHECK(all(rect2.ltrb() == float4(l,t,r,b)));
58 CHECK(all(rect2.vals() == float4(l,t,-r,-b)));
59
60 Rect setTest(-99,-99,99,99);
61 CHECK(setTest != rect2);
62 setTest.setLeft(l);
63 setTest.setTop(t);
64 setTest.setRight(r);
65 setTest.setBot(b);
66 CHECK(setTest == rect2);
67
68 setTest = Rect(-99,-99,99,99);
69 CHECK(setTest != rect2);
70 setTest.setTopLeft({l,t});
71 setTest.setBotRight({r,b});
72 CHECK(setTest == rect2);
73
74 for (int i = 0; i < 4; ++i) {
75 Rect rnan = rect2;
76 CHECK(!rnan.isEmptyNegativeOrNaN());
77 rnan.vals()[i] = std::numeric_limits<float>::quiet_NaN();
78 CHECK(rnan.isEmptyNegativeOrNaN());
79 }
80
81 CHECK(all(rect2.size() == float2(skRect2.width(), skRect2.height())));
82 CHECK(all(rect2.center() == float2(skRect2.centerX(), skRect2.centerY())));
83 CHECK(rect2.area() == skRect2.height() * skRect2.width());
84
85 CHECK(rect.intersects(rect2) == rect2.intersects(rect));
86 CHECK(rect.intersects(rect2) == skRect.intersects(skRect2));
87 CHECK(rect.contains(rect2) == skRect.contains(skRect2));
88 CHECK(rect2.contains(rect) == skRect2.contains(skRect));
89
90 CHECK(rect2.makeRoundIn() == SkRect::Make(skRect2.roundIn()));
91 CHECK(rect2.makeRoundOut() == SkRect::Make(skRect2.roundOut()));
92 CHECK(rect2.makeInset(.5f) == skRect2.makeInset(.5f, .5f));
93 CHECK(rect2.makeInset({.5f, -.25f}) == skRect2.makeInset(.5f, -.25f));
94 CHECK(rect2.makeOutset(.5f) == skRect2.makeOutset(.5f, .5f));
95 CHECK(rect2.makeOutset({.5f, -.25f}) == skRect2.makeOutset(.5f, -.25f));
96 CHECK(rect2.makeOffset({.5f, -.25f}) == skRect2.makeOffset(.5f, -.25f));
97
98 SkRect skJoin = skRect;
99 skJoin.join(skRect2);
100 CHECK(rect.makeJoin(rect2) == skJoin);
101 CHECK(rect.makeJoin(rect2) == rect2.makeJoin(rect));
102
103 CHECK(rect.intersects(rect2) == !rect.makeIntersect(rect2).isEmptyNegativeOrNaN());
104 CHECK(rect.makeIntersect(rect2) == rect2.makeIntersect(rect));
105 if (rect.intersects(rect2)) {
106 CHECK(skRect.intersects(skRect2));
107 SkRect skIsect;
108 CHECK(skIsect.intersect(skRect, skRect2));
109 CHECK(rect.makeIntersect(rect2) == Rect(skIsect));
110 }
111
112 const Rect rect3{r,b,l,t}; // intentionally out of order
113 const SkRect skRect3{r,b,l,t};
114 CHECK(rect3.isEmptyNegativeOrNaN());
115 CHECK(skRect3.isEmpty());
116 CHECK(rect3.makeSorted() == skRect3.makeSorted());
117 CHECK(rect3.makeSorted() == rect2);
118 }}}}
119}
skvx::float2 float2
static bool b
#define CHECK(A)
Definition: RectTest.cpp:13
Vec< 4, float > float4
Definition: SkVx.h:1146
SIT bool all(const Vec< 1, T > &x)
Definition: SkVx.h:582
Vec< 2, float > float2
Definition: SkVx.h:1145
bool intersects(const SkRect &r) const
Definition: SkRect.h:1121
void join(const SkRect &r)
Definition: SkRect.cpp:126
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646
Definition: SkVx.h:83

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [1/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( DeviceTestVertexTransparency  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 21 of file DeviceTest.cpp.

22 {
23 // Set up transparent vertices, in a 5px wide by 10px tall rectangle.
24 static constexpr int kVertexCount = 5;
25 SkPoint positions[kVertexCount];
26 positions[0].set(2.5, 5);
27 positions[1].set(0, 0);
28 positions[2].set(5, 0);
29 positions[3].set(5, 10);
30 positions[4].set(0, 10);
31
32 static constexpr int kIndexCount = 6;
33 static constexpr uint16_t kIndices[kIndexCount] = {0, 1, 2, 3, 4, 1};
34
36 for (size_t i = 0; i < kVertexCount; ++i) {
37 colors[i] = 0x7F00FF00;
38 }
39
42 positions,
43 nullptr,
44 colors,
46 kIndices);
47
48 // Draw vertices at x = 0.
49 std::unique_ptr<Recorder> recorder = context->makeRecorder();
54 SkCanvas* canvas = surface->getCanvas();
56
57 // Draw a square that will overlap both vertex draws.
58 SkPaint redPaint;
59 redPaint.setColor(SK_ColorRED);
60 canvas->drawRect(SkRect::MakeXYWH(0, 0, 10, 10), redPaint);
61
62 // Draw vertices at x = 5.
63 canvas->translate(5, 0);
65
66 // Read pixels.
68 SkPixmap pixmap;
69 bitmap.allocPixels(ii);
70 SkAssertResult(bitmap.peekPixels(&pixmap));
71 if (!surface->readPixels(pixmap, 0, 0)) {
72 ERRORF(reporter, "readPixels failed");
73 return;
74 }
75
76 // Check that draws weren't reordered to put vertex draws together.
77 // The second vertex draw should have been 50% green on top of red.
78 SkColor color = pixmap.getColor(9, 5);
79 SkColor expected = 0xFF807F00;
81 reporter, color == expected, "Wrong color, expected %08x, found %08x", expected, color);
82}
static const size_t kVertexCount
static const uint16_t kIndices[]
uint32_t SkColor
Definition: SkColor.h:37
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:1720
void setColor(SkColor color)
Definition: SkPaint.cpp:119
SkColor getColor(int x, int y) const
Definition: SkPixmap.cpp:187
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
Definition: SkVertices.cpp:200
@ kTriangleFan_VertexMode
Definition: SkVertices.h:33
Definition: bitmap.py:1
static constexpr int kIndexCount
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
void set(float x, float y)
Definition: SkPoint_impl.h:200
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [2/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( DrawPassTestFailedDstCopy  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 19 of file DrawPassTest.cpp.

22 {
23 const Caps* caps = context->priv().caps();
24 std::unique_ptr<Recorder> recorder = context->makeRecorder();
25
26 // Define a paint that requires a dst copy.
28 PaintParams paintParams{paint, nullptr, nullptr, DstReadRequirement::kTextureCopy, false};
29
30 // Define a draw that uses the paint, but is larger than the max texture size. In this case the
31 // dst copy will fail.
32 const SkIRect drawSize = SkIRect::MakeWH(caps->maxTextureSize() + 1, 1);
33 std::unique_ptr<DrawList> drawList = std::make_unique<DrawList>();
34 drawList->recordDraw(recorder->priv().rendererProvider()->analyticRRect(),
35 Transform::Identity(),
36 Geometry(Shape(SkRect::Make(drawSize))),
37 Clip(Rect::Infinite(), Rect::Infinite(), drawSize, nullptr),
38 DrawOrder(DrawOrder::kClearDepth.next()),
39 &paintParams,
40 nullptr);
41
42 // Attempt to make a draw pass with the draw.
43 static constexpr SkISize targetSize = SkISize::Make(1, 1);
44 static constexpr SkColorType targetColorType = kN32_SkColorType;
45 static constexpr SkAlphaType targetAlphaType = kPremul_SkAlphaType;
46 const SkImageInfo targetInfo = SkImageInfo::Make(targetSize, targetColorType, targetAlphaType);
48 caps,
49 recorder->priv().resourceProvider(),
50 targetSize,
52 targetColorType, Mipmapped::kNo,
53 recorder->priv().isProtected(), Renderable::kYes),
54 "DrawPassTestTargetProxy",
55 Budgeted::kYes);
56 std::unique_ptr<DrawPass> drawPass = DrawPass::Make(recorder.get(),
57 std::move(drawList),
58 target,
59 targetInfo,
60 {LoadOp::kClear, StoreOp::kStore},
61 {0.0f, 0.0f, 0.0f, 0.0f},
62 /*dstCopy=*/nullptr,
63 /*dstCopyOffset=*/{0,0});
64
65 // Make sure creating the draw pass failed.
66 REPORTER_ASSERT(reporter, !drawPass);
67}
static float next(float f)
Shape
Definition: aaxfermodes.cpp:43
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
uint32_t * target
Clip
Definition: layer.h:53
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [3/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphiteLazyTextureInvalidDimensions  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 223 of file TextureProxyTest.cpp.

224 {
225 class FulfillContext {
226 public:
227 FulfillContext(BackendTexture backendTexture) : fBackendTexture(backendTexture) {}
228
229 static std::tuple<BackendTexture, void*> Fulfill(void* ctx) {
230 FulfillContext* self = reinterpret_cast<FulfillContext*>(ctx);
231 return {self->fBackendTexture, nullptr};
232 }
233
234 BackendTexture fBackendTexture;
235 };
236
237 std::unique_ptr<Recorder> recorder = context->makeRecorder();
238 const Caps* caps = context->priv().caps();
239
240 // Try to create textures with invalid dimensions.
241 SkISize largeDimensions = SkISize::Make(caps->maxTextureSize() + 1, 1);
242 SkISize negativeDimensions = SkISize::Make(-1, -1);
243
244 for (const SkISize& dimensions : {largeDimensions, negativeDimensions}) {
245 SkImageInfo imageInfo = SkImageInfo::Make(
247 TextureInfo textureInfo = caps->getDefaultSampledTextureInfo(
249
250 // The created BackendTexture should be invalid, so an invalid texture would be used to
251 // fulfill the promise image created later, if we were to attempt to draw it.
252 BackendTexture backendTexture =
253 recorder->createBackendTexture(imageInfo.dimensions(), textureInfo);
254 FulfillContext fulfillContext(backendTexture);
255 REPORTER_ASSERT(reporter, !backendTexture.isValid());
256
257 // Drawing should still succeed, as no image draw should actually be attempted with this
258 // texture.
259 SkImageInfo surfaceImageInfo = SkImageInfo::Make(
261 sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(recorder.get(), surfaceImageInfo);
262 sk_sp<SkImage> promiseImage = SkImages::PromiseTextureFrom(recorder.get(),
263 imageInfo.dimensions(),
264 textureInfo,
265 imageInfo.colorInfo(),
266 Volatile::kNo,
267 FulfillContext::Fulfill,
268 nullptr,
269 nullptr,
270 &fulfillContext);
271
272 surface->getCanvas()->drawImage(promiseImage, 0.0f, 0.0f);
273 std::unique_ptr<Recording> recording = recorder->snap();
274 REPORTER_ASSERT(reporter, context->insertRecording({recording.get()}));
275 // Clean up backend texture
276 context->deleteBackendTexture(fulfillContext.fBackendTexture);
277 }
278}
SK_API sk_sp< SkImage > PromiseTextureFrom(skgpu::graphite::Recorder *, SkISize dimensions, const skgpu::graphite::TextureInfo &, const SkColorInfo &, skgpu::Origin origin, skgpu::graphite::Volatile, GraphitePromiseTextureFulfillProc, GraphitePromiseImageReleaseProc, GraphitePromiseTextureReleaseProc, GraphitePromiseImageContext, std::string_view label={})
const SkColorInfo & colorInfo() const
Definition: SkImageInfo.h:404
SkISize dimensions() const
Definition: SkImageInfo.h:421

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [4/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphitePurgeAsNeededResourcesTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 310 of file GraphiteResourceCacheTest.cpp.

311 {
312 std::unique_ptr<Recorder> recorder = context->makeRecorder();
313 ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
314 ResourceCache* resourceCache = resourceProvider->resourceCache();
315 const SharedContext* sharedContext = resourceProvider->sharedContext();
316
317 resourceCache->setMaxBudget(10);
318
319 auto resourceSize10 = add_new_resource(reporter,
320 sharedContext,
321 resourceCache,
322 /*gpuMemorySize=*/10);
323
324 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
325 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
326 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 10);
327
328 auto resourceSize1 = add_new_resource(reporter,
329 sharedContext,
330 resourceCache,
331 /*gpuMemorySize=*/1);
332
333 // We should now be over budget, but nothing should be purged since neither resource is
334 // purgeable.
335 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
336 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
337 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 11);
338
339 // Dropping the ref to the size 1 resource should cause it to get purged when we add a new
340 // resource to the cache.
341 resourceSize1.reset();
342
343 auto resourceSize2 = add_new_resource(reporter,
344 sharedContext,
345 resourceCache,
346 /*gpuMemorySize=*/2);
347
348 // The purging should have happened when we return the resource above so we also shouldn't
349 // see anything in the purgeable queue.
350 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
351 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
352 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 12);
353
354 // Reset the cache back to no resources by setting budget to 0.
355 resourceSize10.reset();
356 resourceSize2.reset();
357 resourceCache->forceProcessReturnedResources();
358 resourceCache->setMaxBudget(0);
359
360 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
361 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
362 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 0);
363
364 // Add a bunch of purgeable resources that keeps us under budget. Nothing should ever get purged.
365 resourceCache->setMaxBudget(10);
366 auto resourceSize1Ptr = add_new_purgeable_resource(reporter,
367 sharedContext,
368 resourceCache,
369 /*gpuMemorySize=*/1);
370 /*auto resourceSize2Ptr=*/ add_new_purgeable_resource(reporter,
371 sharedContext,
372 resourceCache,
373 /*gpuMemorySize=*/2);
374 auto resourceSize3Ptr = add_new_purgeable_resource(reporter,
375 sharedContext,
376 resourceCache,
377 /*gpuMemorySize=*/3);
378 auto resourceSize4Ptr = add_new_purgeable_resource(reporter,
379 sharedContext,
380 resourceCache,
381 /*gpuMemorySize=*/4);
382
383 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 4);
384 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == resourceSize1Ptr);
385 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 10);
386
387 // Now add some resources that should cause things to get purged.
388 // Add a size 2 resource should purge the original size 1 and size 2
389 add_new_purgeable_resource(reporter,
390 sharedContext,
391 resourceCache,
392 /*gpuMemorySize=*/2);
393
394 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 3);
395 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == resourceSize3Ptr);
396 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 9);
397
398 // Adding a non-purgeable resource should also trigger resources to be purged from purgeable
399 // queue.
400 resourceSize10 = add_new_resource(reporter,
401 sharedContext,
402 resourceCache,
403 /*gpuMemorySize=*/10);
404
405 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
406 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
407 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 10);
408
409 // Adding a resources that is purgeable back to the cache shouldn't trigger the previous
410 // non-purgeable resource or itself to be purged yet (since processing our return mailbox
411 // doesn't trigger the purgeAsNeeded call)
412 resourceSize4Ptr = add_new_purgeable_resource(reporter,
413 sharedContext,
414 resourceCache,
415 /*gpuMemorySize=*/4);
416
417 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
418 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == resourceSize4Ptr);
419 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 14);
420
421 // Resetting the budget to 0 should trigger purging the size 4 purgeable resource but should
422 // leave the non purgeable size 10 alone.
423 resourceCache->setMaxBudget(0);
424 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
425 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
426 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 10);
427
428 resourceSize10.reset();
429 resourceCache->forceProcessReturnedResources();
430 resourceCache->forcePurgeAsNeeded();
431
432 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
433 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
434 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 0);
435}
size_t currentBudgetedBytes() const
Definition: ResourceCache.h:83

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [5/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphitePurgeNotUsedOverBudgetTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 615 of file GraphiteResourceCacheTest.cpp.

616 {
617 std::unique_ptr<Recorder> recorder = context->makeRecorder();
618 ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
619 ResourceCache* resourceCache = resourceProvider->resourceCache();
620 const SharedContext* sharedContext = resourceProvider->sharedContext();
621
622 // set resourceCache budget to 10 for testing.
623 resourceCache->setMaxBudget(10);
624
625 // First make a purgeable resources
626 auto resourcePtr = add_new_purgeable_resource(reporter,
627 sharedContext,
628 resourceCache,
629 /*gpuMemorySize=*/1);
630 if (!resourcePtr) {
631 return;
632 }
633
634 // Now create a bunch of non purgeable (yet) resources that are not budgeted (i.e. in real world
635 // they would be wrapped in an SkSurface or SkImage), but will cause us to go over our budget
636 // limit when they do return to cache.
637
638 auto resource1 = add_new_resource(reporter,
639 sharedContext,
640 resourceCache,
641 /*gpuMemorySize=*/15,
643
644 auto resource2 = add_new_resource(reporter,
645 sharedContext,
646 resourceCache,
647 /*gpuMemorySize=*/16,
649
650 auto resource3 = add_new_resource(reporter,
651 sharedContext,
652 resourceCache,
653 /*gpuMemorySize=*/3,
655
656 auto resource1Ptr = resource1.get();
657 auto resource2Ptr = resource2.get();
658 auto resource3Ptr = resource3.get();
659
660 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 4);
661 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 1);
662
663 auto timeBeforeReturningToCache = skgpu::StdSteadyClock::now();
664
665 // Now reset all the non budgeted resources so they return to the cache and become budgeted.
666 // Returning to the cache will not immedidately trigger a purgeAsNeededCall.
667 resource1.reset();
668 resource2.reset();
669 resource3.reset();
670
671 resourceCache->forceProcessReturnedResources();
672
673 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 4);
674 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 35);
675 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resourcePtr));
676 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resource1Ptr));
677 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resource2Ptr));
678 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resource3Ptr));
679
680 // Now we call purgeNotUsedSince with timeBeforeReturnToCache. The original resource should get
681 // purged because it is older than this time. The three originally non budgeted resources are
682 // newer than this time so they won't be purged by the time on this call. However, since we are
683 // overbudget it should trigger us to purge the first two of these resources to get us back
684 // under.
685 resourceCache->purgeResourcesNotUsedSince(timeBeforeReturningToCache);
686 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
687 REPORTER_ASSERT(reporter, resourceCache->currentBudgetedBytes() == 3);
688 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resource3Ptr));
689}

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [6/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphitePurgeNotUsedSinceResourcesTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 524 of file GraphiteResourceCacheTest.cpp.

525 {
526 std::unique_ptr<Recorder> recorder = context->makeRecorder();
527 ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
528 ResourceCache* resourceCache = resourceProvider->resourceCache();
529 const SharedContext* sharedContext = resourceProvider->sharedContext();
530
531 // Basic test where we purge 1 resource
532 auto beforeTime = skgpu::StdSteadyClock::now();
533
534 auto resourcePtr = add_new_purgeable_resource(reporter,
535 sharedContext,
536 resourceCache,
537 /*gpuMemorySize=*/1);
538 if (!resourcePtr) {
539 return;
540 }
541
542 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
543
544 auto afterTime = skgpu::StdSteadyClock::now();
545
546 // purging beforeTime should not get rid of the resource
547 resourceCache->purgeResourcesNotUsedSince(beforeTime);
548
549 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
550
551 // purging at afterTime which is after resource became purgeable should purge it.
552 resourceCache->purgeResourcesNotUsedSince(afterTime);
553
554 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
555
556 // Test making 2 purgeable resources, but asking to purge on a time between the two.
557 Resource* resourcePtr1 = add_new_purgeable_resource(reporter,
558 sharedContext,
559 resourceCache,
560 /*gpuMemorySize=*/1);
561
562 auto betweenTime = skgpu::StdSteadyClock::now();
563
564 Resource* resourcePtr2 = add_new_purgeable_resource(reporter,
565 sharedContext,
566 resourceCache,
567 /*gpuMemorySize=*/1);
568
569 afterTime = skgpu::StdSteadyClock::now();
570
571 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
572 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resourcePtr1));
573 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resourcePtr2));
574
575 resourceCache->purgeResourcesNotUsedSince(betweenTime);
576
577 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
578 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resourcePtr2));
579
580 resourceCache->purgeResourcesNotUsedSince(afterTime);
581 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
582
583 // purgeResourcesNotUsedSince should have no impact on non-purgeable resources
584 auto resource = add_new_resource(reporter,
585 sharedContext,
586 resourceCache,
587 /*gpuMemorySize=*/1);
588 if (!resource) {
589 return;
590 }
591 resourcePtr = resource.get();
592
593 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
594
595 afterTime = skgpu::StdSteadyClock::now();
596 resourceCache->purgeResourcesNotUsedSince(afterTime);
597 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
598 REPORTER_ASSERT(reporter, !resourceCache->testingInPurgeableQueue(resourcePtr));
599
600 resource.reset();
601 // purgeResourcesNotUsedSince should check the mailbox for the returned resource. Though the
602 // time is set before that happens so nothing should purge.
603 resourceCache->purgeResourcesNotUsedSince(skgpu::StdSteadyClock::now());
604 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
605 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resourcePtr));
606
607 // Now it should be purged since it is already purgeable
608 resourceCache->purgeResourcesNotUsedSince(skgpu::StdSteadyClock::now());
609 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
610}

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [7/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphitePurgeResourcesTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 693 of file GraphiteResourceCacheTest.cpp.

694 {
695 std::unique_ptr<Recorder> recorder = context->makeRecorder();
696 ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
697 ResourceCache* resourceCache = resourceProvider->resourceCache();
698 const SharedContext* sharedContext = resourceProvider->sharedContext();
699
700 // set resourceCache budget to 10 for testing.
701 resourceCache->setMaxBudget(10);
702
703 // Basic test where we purge 1 resource
704 auto resourcePtr = add_new_purgeable_resource(reporter,
705 sharedContext,
706 resourceCache,
707 /*gpuMemorySize=*/1);
708 if (!resourcePtr) {
709 return;
710 }
711
712 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
713
714 // purging should purge the one unlocked resource.
715 resourceCache->purgeResources();
716 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
717
718 // Test making 2 purgeable resources
719 Resource* resourcePtr1 = add_new_purgeable_resource(reporter,
720 sharedContext,
721 resourceCache,
722 /*gpuMemorySize=*/1);
723
724 Resource* resourcePtr2 = add_new_purgeable_resource(reporter,
725 sharedContext,
726 resourceCache,
727 /*gpuMemorySize=*/1);
728 if (!resourcePtr1 || !resourcePtr2) {
729 return;
730 }
731
732 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
733 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resourcePtr1));
734 REPORTER_ASSERT(reporter, resourceCache->testingInPurgeableQueue(resourcePtr2));
735
736 resourceCache->purgeResources();
737 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
738
739 // purgeResources should have no impact on non-purgeable resources
740 auto resource = add_new_resource(reporter,
741 sharedContext,
742 resourceCache,
743 /*gpuMemorySize=*/1);
744 if (!resource) {
745 return;
746 }
747 resourcePtr = resource.get();
748
749 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
750
751 resourceCache->purgeResources();
752 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
753 REPORTER_ASSERT(reporter, !resourceCache->testingInPurgeableQueue(resourcePtr));
754
755 resource.reset();
756 resourceCache->purgeResources();
757 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
758}

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [8/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphiteTextureProxyTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 27 of file TextureProxyTest.cpp.

28 {
29 const Caps* caps = context->priv().caps();
30 constexpr SkISize kValidSize = SkISize::Make(1, 1);
31 constexpr SkISize kInvalidSize = SkISize::MakeEmpty();
32 constexpr SkColorType kValidColorType = kRGBA_8888_SkColorType;
33 constexpr SkColorType kInvalidColorType = kUnknown_SkColorType;
34
35 Protected isProtected = Protected(caps->protectedSupport());
36
37 std::unique_ptr<Recorder> recorder = context->makeRecorder();
38 ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
39 const TextureInfo textureInfo = caps->getDefaultSampledTextureInfo(
40 kValidColorType, Mipmapped::kNo, isProtected, Renderable::kNo);
41 BackendTexture backendTexture = recorder->createBackendTexture(kValidSize, textureInfo);
42 sk_sp<Texture> texture = resourceProvider->createWrappedTexture(backendTexture,
43 "TextureProxyTestWrappedTex");
44
45 auto makeProxy = [&](SkISize dimensions, SkColorType colorType, Mipmapped mipmapped,
46 Protected isProtected, Renderable renderable, Budgeted budgeted) {
47 auto textureInfo = caps->getDefaultSampledTextureInfo(colorType, mipmapped,
48 isProtected, renderable);
49 return TextureProxy::Make(caps, recorder->priv().resourceProvider(),
50 dimensions, textureInfo, "TextureProxyTestTexture", budgeted);
51 };
52
53 auto nullCallback = [](ResourceProvider*) -> sk_sp<Texture> { return nullptr; };
54 auto callback = [texture](ResourceProvider*) -> sk_sp<Texture> { return texture; };
55
56 // Assign to assignableTexture before instantiating with this callback.
57 sk_sp<Texture> assignableTexture;
58 auto assignableCallback = [&assignableTexture](ResourceProvider*) -> sk_sp<Texture> {
59 return assignableTexture;
60 };
61
62 // Invalid parameters.
63 sk_sp<TextureProxy> textureProxy;
64 textureProxy = makeProxy(kInvalidSize,
65 kValidColorType,
67 isProtected,
70 REPORTER_ASSERT(reporter, textureProxy == nullptr);
71 textureProxy = makeProxy(kValidSize,
72 kInvalidColorType,
74 isProtected,
77 REPORTER_ASSERT(reporter, textureProxy == nullptr);
78
79 // Non-budgeted, non-lazy TextureProxy is instantiated on return
80 textureProxy = makeProxy(kValidSize,
81 kValidColorType,
83 isProtected,
86 REPORTER_ASSERT(reporter, !textureProxy->isLazy());
87 REPORTER_ASSERT(reporter, !textureProxy->isFullyLazy());
88 REPORTER_ASSERT(reporter, !textureProxy->isVolatile());
89 REPORTER_ASSERT(reporter, textureProxy->isInstantiated());
90 REPORTER_ASSERT(reporter, textureProxy->dimensions() == kValidSize);
91
92 // Budgeted, non-lazy TextureProxy, successful instantiation later on
93 textureProxy = makeProxy(kValidSize,
94 kValidColorType,
96 isProtected,
99 REPORTER_ASSERT(reporter, !textureProxy->isLazy());
100 REPORTER_ASSERT(reporter, !textureProxy->isFullyLazy());
101 REPORTER_ASSERT(reporter, !textureProxy->isVolatile());
102 REPORTER_ASSERT(reporter, !textureProxy->isInstantiated());
103 REPORTER_ASSERT(reporter, textureProxy->dimensions() == kValidSize);
104
105 bool instantiateSuccess = textureProxy->instantiate(resourceProvider);
106 REPORTER_ASSERT(reporter, instantiateSuccess);
107 REPORTER_ASSERT(reporter, textureProxy->isInstantiated());
108 REPORTER_ASSERT(reporter, textureProxy->dimensions() == kValidSize);
109 const Texture* createdTexture = textureProxy->texture();
110
111 instantiateSuccess = textureProxy->instantiate(resourceProvider);
112 REPORTER_ASSERT(reporter, instantiateSuccess);
113 REPORTER_ASSERT(reporter, textureProxy->texture() == createdTexture);
114
115 // Lazy, non-volatile TextureProxy, unsuccessful instantiation.
116 textureProxy = TextureProxy::MakeLazy(
117 caps, kValidSize, textureInfo, skgpu::Budgeted::kNo, Volatile::kNo, nullCallback);
118 REPORTER_ASSERT(reporter, textureProxy->isLazy());
119 REPORTER_ASSERT(reporter, !textureProxy->isFullyLazy());
120 REPORTER_ASSERT(reporter, !textureProxy->isVolatile());
121
122 instantiateSuccess = textureProxy->lazyInstantiate(resourceProvider);
123 REPORTER_ASSERT(reporter, !instantiateSuccess);
124 REPORTER_ASSERT(reporter, !textureProxy->isInstantiated());
125
126 // Lazy, non-volatile TextureProxy, successful instantiation.
127 textureProxy = TextureProxy::MakeLazy(
128 caps, kValidSize, textureInfo, skgpu::Budgeted::kNo, Volatile::kNo, callback);
129
130 instantiateSuccess = textureProxy->lazyInstantiate(resourceProvider);
131 REPORTER_ASSERT(reporter, instantiateSuccess);
132 REPORTER_ASSERT(reporter, textureProxy->texture() == texture.get());
133
134 // Lazy, volatile TextureProxy, unsuccessful instantiation.
135 textureProxy = TextureProxy::MakeLazy(
136 caps, kValidSize, textureInfo, skgpu::Budgeted::kNo, Volatile::kYes, nullCallback);
137 REPORTER_ASSERT(reporter, textureProxy->isLazy());
138 REPORTER_ASSERT(reporter, !textureProxy->isFullyLazy());
139 REPORTER_ASSERT(reporter, textureProxy->isVolatile());
140
141 instantiateSuccess = textureProxy->lazyInstantiate(resourceProvider);
142 REPORTER_ASSERT(reporter, !instantiateSuccess);
143 REPORTER_ASSERT(reporter, !textureProxy->isInstantiated());
144
145 // Lazy, volatile TextureProxy, successful instantiation.
146 textureProxy = TextureProxy::MakeLazy(
147 caps, kValidSize, textureInfo, skgpu::Budgeted::kNo, Volatile::kYes, callback);
148
149 instantiateSuccess = textureProxy->lazyInstantiate(resourceProvider);
150 REPORTER_ASSERT(reporter, instantiateSuccess);
151 REPORTER_ASSERT(reporter, textureProxy->texture() == texture.get());
152
153 textureProxy->deinstantiate();
154 REPORTER_ASSERT(reporter, !textureProxy->isInstantiated());
155
156 // Fully-lazy TextureProxy.
157 textureProxy = TextureProxy::MakeFullyLazy(
158 textureInfo, skgpu::Budgeted::kNo, Volatile::kYes, assignableCallback);
159 REPORTER_ASSERT(reporter, textureProxy->isLazy());
160 REPORTER_ASSERT(reporter, textureProxy->isFullyLazy());
161 REPORTER_ASSERT(reporter, textureProxy->isVolatile());
162
163 assignableTexture = texture;
164 instantiateSuccess = textureProxy->lazyInstantiate(resourceProvider);
165 REPORTER_ASSERT(reporter, instantiateSuccess);
166 REPORTER_ASSERT(reporter, textureProxy->isInstantiated());
167 REPORTER_ASSERT(reporter, textureProxy->isFullyLazy());
168 REPORTER_ASSERT(reporter, textureProxy->dimensions() == kValidSize);
169
170 textureProxy->deinstantiate();
171 REPORTER_ASSERT(reporter, !textureProxy->isInstantiated());
172 REPORTER_ASSERT(reporter, textureProxy->isFullyLazy());
173
174 constexpr SkISize kLargerSize = SkISize::Make(2, 2);
175 BackendTexture largerBackendTexture =
176 recorder->createBackendTexture(kLargerSize, textureInfo);
177 assignableTexture = resourceProvider->createWrappedTexture(largerBackendTexture,
178 "TextureProxyTestWrappedTex");
179 instantiateSuccess = textureProxy->lazyInstantiate(resourceProvider);
180 REPORTER_ASSERT(reporter, instantiateSuccess);
181 REPORTER_ASSERT(reporter, textureProxy->dimensions() == kLargerSize);
182
183 // InstantiateIfNotLazy tests.
184 textureProxy = makeProxy(kValidSize,
185 kValidColorType,
187 isProtected,
190 instantiateSuccess = TextureProxy::InstantiateIfNotLazy(resourceProvider, textureProxy.get());
191 REPORTER_ASSERT(reporter, instantiateSuccess);
192
193 textureProxy = TextureProxy::MakeLazy(
194 caps, kValidSize, textureInfo, skgpu::Budgeted::kNo, Volatile::kNo, nullCallback);
195 instantiateSuccess = TextureProxy::InstantiateIfNotLazy(resourceProvider, textureProxy.get());
196 REPORTER_ASSERT(reporter, instantiateSuccess);
197 // Clean up the backend textures.
198 recorder->deleteBackendTexture(backendTexture);
199 recorder->deleteBackendTexture(largerBackendTexture);
200}
skgpu::Protected Protected
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
bool protectedSupport() const
Definition: Caps.h:226
sk_sp< Texture > createWrappedTexture(const BackendTexture &, std::string_view label)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
Budgeted
Definition: GpuTypes.h:35
Renderable
Definition: GpuTypes.h:69
Mipmapped
Definition: GpuTypes.h:53
Protected
Definition: GpuTypes.h:61
static constexpr SkISize MakeEmpty()
Definition: SkSize.h:22

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [9/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphiteTextureTooLargeTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 202 of file TextureProxyTest.cpp.

203 {
204 std::unique_ptr<Recorder> recorder = context->makeRecorder();
205 const Caps* caps = context->priv().caps();
206
207 // Try to create a texture that is too large for the backend.
209 SkISize dimensions = SkISize::Make(caps->maxTextureSize() + 1, 1);
210 bitmap.allocPixels(SkImageInfo::Make(
213 sk_sp<SkImage> graphiteImage =
214 SkImages::TextureFromImage(recorder.get(), rasterImage.get(), /*requiredProps=*/{});
215
216 // Image creation should have failed.
217 REPORTER_ASSERT(reporter, !graphiteImage);
218
219 // Snapping should still succeed, no texture upload should actually be attempted.
220 REPORTER_ASSERT(reporter, recorder->snap());
221}
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [10/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( GraphiteZeroSizedResourcesTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 437 of file GraphiteResourceCacheTest.cpp.

438 {
439 std::unique_ptr<Recorder> recorder = context->makeRecorder();
440 ResourceProvider* resourceProvider = recorder->priv().resourceProvider();
441 ResourceCache* resourceCache = resourceProvider->resourceCache();
442 const SharedContext* sharedContext = resourceProvider->sharedContext();
443
444 // First make a normal resource that has a non zero size
445 Resource* resourcePtr = add_new_purgeable_resource(reporter,
446 sharedContext,
447 resourceCache,
448 /*gpuMemorySize=*/1);
449 if (!resourcePtr) {
450 return;
451 }
452
453 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
454 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 1);
455 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == resourcePtr);
456
457 // First confirm if we set the max budget to zero, this sized resource is removed.
458 resourceCache->setMaxBudget(0);
459 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 0);
460 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 0);
461 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == nullptr);
462
463 // Set the budget back to something higher
464 resourceCache->setMaxBudget(100);
465
466 // Now create a zero sized resource and add it to the cache.
467 resourcePtr = add_new_purgeable_resource(reporter,
468 sharedContext,
469 resourceCache,
470 /*gpuMemorySize=*/0);
471 if (!resourcePtr) {
472 return;
473 }
474
475 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
476 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 1);
477 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == resourcePtr);
478
479 // Setting the budget down to 0 should not cause the zero sized resource to be purged
480 resourceCache->setMaxBudget(0);
481 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 1);
482 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 1);
483 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == resourcePtr);
484
485 // Now add a sized resource to cache. Set budget higher again so that it fits
486 resourceCache->setMaxBudget(100);
487
488 Resource* sizedResourcePtr = add_new_purgeable_resource(reporter,
489 sharedContext,
490 resourceCache,
491 /*gpuMemorySize=*/1);
492 if (!resourcePtr) {
493 return;
494 }
495
496 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
497 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 2);
498 // Even though the zero sized resource was added to the cache first, the top of the purgeable
499 // stack should be the sized resource.
500 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == sizedResourcePtr);
501
502 // Add another zero sized resource
503 resourcePtr = add_new_purgeable_resource(reporter,
504 sharedContext,
505 resourceCache,
506 /*gpuMemorySize=*/0);
507 if (!resourcePtr) {
508 return;
509 }
510
511 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 3);
512 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 3);
513 // Again the sized resource should still be the top of the purgeable queue
514 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue() == sizedResourcePtr);
515
516 // If we set the cache budget to 0, it should clear out the sized resource but leave the two
517 // zero-sized resources.
518 resourceCache->setMaxBudget(0);
519 REPORTER_ASSERT(reporter, resourceCache->getResourceCount() == 2);
520 REPORTER_ASSERT(reporter, resourceCache->numFindableResources() == 2);
521 REPORTER_ASSERT(reporter, resourceCache->topOfPurgeableQueue()->gpuMemorySize() == 0);
522}

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [11/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( MultisampleRetainTest  ,
reporter  ,
context  ,
CtsEnforcement::kNever   
)

Definition at line 25 of file MultisampleTest.cpp.

26 {
27 const SkImageInfo surfaceImageInfo = SkImageInfo::Make(
29
30 std::unique_ptr<Recorder> surfaceRecorder = context->makeRecorder();
31 sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(surfaceRecorder.get(), surfaceImageInfo);
32
33 // Clear entire surface to red
34 SkCanvas* surfaceCanvas = surface->getCanvas();
35 surfaceCanvas->clear(SkColors::kRed);
36 std::unique_ptr<Recording> surfaceRecording = surfaceRecorder->snap();
37 // Flush the clearing
38 context->insertRecording({surfaceRecording.get()});
39
40 // Draw a blue path. The old red background should be retained between recordings.
42 paint.setStrokeWidth(3);
43 paint.setColor(SkColors::kBlue);
44 paint.setStyle(SkPaint::Style::kStroke_Style);
45
47 constexpr int kPathPoints[][2] = {
48 {3, 2},
49 {3, 4},
50 {6, 8},
51 {3, 15},
52 };
53
54 for (size_t i = 0; i < std::size(kPathPoints); ++i) {
55 path.lineTo(kPathPoints[i][0], kPathPoints[i][1]);
56 }
57
58 surfaceCanvas->drawPath(path, paint);
59
60 std::unique_ptr<Recording> surfaceRecording2 = surfaceRecorder->snap();
61 // Play back recording.
62 context->insertRecording({surfaceRecording2.get()});
63
64 // Read pixels.
66 bitmap.allocPixels(surfaceImageInfo);
67 if (!surface->readPixels(bitmap, 0, 0)) {
68 ERRORF(reporter, "readPixels failed");
69 return;
70 }
71
72 // Verify recording was replayed.
73 REPORTER_ASSERT(reporter, bitmap.getColor4f(8, 0) == SkColors::kRed);
74 REPORTER_ASSERT(reporter, bitmap.getColor4f(0, 8) == SkColors::kRed);
75 REPORTER_ASSERT(reporter, bitmap.getColor4f(15, 14) == SkColors::kRed);
76
77 // Verify points on the path have blue color. We don't verify last point because it is on the
78 // edge of the path thus might have blurry color.
79 for (size_t i = 0; i < std::size(kPathPoints) - 1; ++i) {
81 bitmap.getColor4f(kPathPoints[i][0], kPathPoints[i][1]) == SkColors::kBlue);
82 }
83}
void clear(SkColor color)
Definition: SkCanvas.h:1199
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
Definition: SkPath.h:59
constexpr SkColor4f kRed
Definition: SkColor.h:440
constexpr SkColor4f kBlue
Definition: SkColor.h:442
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [12/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest1  ,
,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 32 of file ProxyCacheTest.cpp.

32 {
33 std::unique_ptr<Recorder> recorder = context->makeRecorder();
34 ProxyCache* proxyCache = recorder->priv().proxyCache();
35
37 bool success = ToolUtils::GetResourceAsBitmap("images/mandrill_128.png", &bitmap);
38 REPORTER_ASSERT(r, success);
39 if (!success) {
40 return;
41 }
42
43 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
44
45 sk_sp<TextureProxy> proxy = proxyCache->findOrCreateCachedProxy(recorder.get(), bitmap,
46 "ProxyCacheTestTexture");
47
48 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
49
50 bitmap.eraseColor(SK_ColorBLACK);
51
52 proxyCache->forceProcessInvalidKeyMsgs();
53
54 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
55}
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
bool GetResourceAsBitmap(const char *resource, SkBitmap *dst)
Definition: DecodeUtils.h:21

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [13/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( ProxyCacheTest2  ,
,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 59 of file ProxyCacheTest.cpp.

59 {
60 std::unique_ptr<Recorder> recorder1 = context->makeRecorder();
61 ProxyCache* proxyCache1 = recorder1->priv().proxyCache();
62 std::unique_ptr<Recorder> recorder2 = context->makeRecorder();
63 ProxyCache* proxyCache2 = recorder2->priv().proxyCache();
64
66 bool success = ToolUtils::GetResourceAsBitmap("images/mandrill_128.png", &bitmap);
67 REPORTER_ASSERT(r, success);
68 if (!success) {
69 return;
70 }
71
72 REPORTER_ASSERT(r, proxyCache1->numCached() == 0);
73 REPORTER_ASSERT(r, proxyCache2->numCached() == 0);
74
75 sk_sp<TextureProxy> proxy1 = proxyCache1->findOrCreateCachedProxy(recorder1.get(), bitmap,
76 "ProxyCacheTestTexture");
77 sk_sp<TextureProxy> proxy2 = proxyCache2->findOrCreateCachedProxy(recorder2.get(), bitmap,
78 "ProxyCacheTestTexture");
79
80 REPORTER_ASSERT(r, proxyCache1->numCached() == 1);
81 REPORTER_ASSERT(r, proxyCache2->numCached() == 1);
82
83 bitmap.eraseColor(SK_ColorBLACK);
84
85 proxyCache1->forceProcessInvalidKeyMsgs();
86 proxyCache2->forceProcessInvalidKeyMsgs();
87
88 REPORTER_ASSERT(r, proxyCache1->numCached() == 0);
89 REPORTER_ASSERT(r, proxyCache2->numCached() == 0);
90}

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [14/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( RecordingSurfacesTestClear  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 96 of file RecordingSurfacesTest.cpp.

97 {
98 SkISize surfaceSize = SkISize::Make(8, 4);
99 SkISize recordingSize = SkISize::Make(4, 4);
100 SkISize replayOffset = SkISize::Make(0, 0);
101
102 auto draw = [](SkCanvas* canvas) { canvas->clear(SkColors::kRed); };
103
104 std::vector<Expectation> expectations = {{0, 0, SkColors::kRed},
105 {4, 0, SkColors::kTransparent}};
106
107 run_test(reporter, context, surfaceSize, recordingSize, replayOffset, draw, expectations);
108}
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
constexpr SkColor4f kTransparent
Definition: SkColor.h:434
void run_test(skiatest::Reporter *reporter, Context *context, SkISize surfaceSize, SkISize recordingSize, SkISize replayOffset, DrawCallback draw, const std::vector< Expectation > &expectations)

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [15/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( RecordingSurfacesTestWritePixels  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 111 of file RecordingSurfacesTest.cpp.

112 {
114 bitmap.allocN32Pixels(4, 4, true);
115 SkCanvas bitmapCanvas(bitmap);
117 paint.setColor(SkColors::kRed);
118 bitmapCanvas.drawIRect(SkIRect::MakeXYWH(0, 0, 4, 4), paint);
119
120 SkISize surfaceSize = SkISize::Make(8, 4);
121 SkISize recordingSize = SkISize::Make(4, 4);
122 SkISize replayOffset = SkISize::Make(4, 0);
123
124 auto draw = [&bitmap](SkCanvas* canvas) { canvas->writePixels(bitmap, 0, 0); };
125
126 std::vector<Expectation> expectations = {{0, 0, SkColors::kTransparent},
127 {4, 0, SkColors::kRed}};
128
129 run_test(reporter, context, surfaceSize, recordingSize, replayOffset, draw, expectations);
130}

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [16/16]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS ( RecordingSurfacesTestWritePixelsOffscreen  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 133 of file RecordingSurfacesTest.cpp.

134 {
136 bitmap.allocN32Pixels(4, 4, true);
137 SkCanvas bitmapCanvas(bitmap);
139 paint.setColor(SkColors::kRed);
140 bitmapCanvas.drawIRect(SkIRect::MakeXYWH(0, 0, 4, 4), paint);
141 paint.setColor(SkColors::kGreen);
142 bitmapCanvas.drawIRect(SkIRect::MakeXYWH(2, 2, 2, 2), paint);
143
144 SkISize surfaceSize = SkISize::Make(4, 4);
145 SkISize recordingSize = SkISize::Make(4, 4);
146 SkISize replayOffset = SkISize::Make(-2, -2);
147
148 auto draw = [&bitmap](SkCanvas* canvas) { canvas->writePixels(bitmap, 0, 0); };
149
150 std::vector<Expectation> expectations = {{0, 0, SkColors::kGreen}};
151
152 run_test(reporter, context, surfaceSize, recordingSize, replayOffset, draw, expectations);
153}
constexpr SkColor4f kGreen
Definition: SkColor.h:441

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [1/5]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( BufferManagerGpuOnlyBufferTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 29 of file BufferManagerTest.cpp.

30 {
31 std::unique_ptr<Recorder> recorder = context->makeRecorder();
32 DrawBufferManager* mgr = recorder->priv().drawBufferManager();
33
34 // Allocate a series of GPU-only buffers. These buffers should not be mapped before and after
35 // they get transferred to the recording.
36 auto ssbo = mgr->getStorage(10);
37 auto vertex = mgr->getVertexStorage(10);
38 auto index = mgr->getIndexStorage(10);
39 auto indirect = mgr->getIndirectStorage(10);
40
41 REPORTER_ASSERT(reporter, !ssbo.fBuffer->isMapped());
42 REPORTER_ASSERT(reporter, !vertex.fBuffer->isMapped());
43 REPORTER_ASSERT(reporter, !index.fBuffer->isMapped());
44 REPORTER_ASSERT(reporter, !indirect.fBuffer->isMapped());
45
46 // Ensure that the buffers' starting alignment matches the required storage buffer alignment.
47 size_t requiredAlignment = context->priv().caps()->requiredStorageBufferAlignment();
48 REPORTER_ASSERT(reporter, is_offset_aligned(ssbo.fOffset, requiredAlignment));
49 REPORTER_ASSERT(reporter, is_offset_aligned(vertex.fOffset, requiredAlignment));
50 REPORTER_ASSERT(reporter, is_offset_aligned(index.fOffset, requiredAlignment));
51 REPORTER_ASSERT(reporter, is_offset_aligned(indirect.fOffset, requiredAlignment));
52
53 // Transfers the ownership of used buffers to a Recording.
54 auto recording = recorder->snap();
55
56 // Ensure that the buffers are still unmapped.
57 REPORTER_ASSERT(reporter, !ssbo.fBuffer->isMapped());
58 REPORTER_ASSERT(reporter, !vertex.fBuffer->isMapped());
59 REPORTER_ASSERT(reporter, !index.fBuffer->isMapped());
60 REPORTER_ASSERT(reporter, !indirect.fBuffer->isMapped());
61
62 // Since these buffers never need their contents to be host-visible, no buffer transfer/copy
63 // tasks should have been created for them.
64 REPORTER_ASSERT(reporter, !recording->priv().hasTasks());
65
66 // Request a mapped ssbo followed by an unmapped one. The two buffers should be distinct.
67 auto [ssboPtr, mappedSsbo] = mgr->getStoragePointer(10);
68 ssbo = mgr->getStorage(10);
69 REPORTER_ASSERT(reporter, !ssbo.fBuffer->isMapped());
70 REPORTER_ASSERT(reporter, ssbo.fBuffer != mappedSsbo.fBuffer);
71}
BindBufferInfo getIndexStorage(size_t requiredBytes)
std::pair< void *, BindBufferInfo > getStoragePointer(size_t requiredBytes)
BindBufferInfo getStorage(size_t requiredBytes, ClearBuffer cleared=ClearBuffer::kNo)
BindBufferInfo getIndirectStorage(size_t requiredBytes, ClearBuffer cleared=ClearBuffer::kNo)
BindBufferInfo getVertexStorage(size_t requiredBytes)

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [2/5]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( ImageOriginTest_drawImage_Graphite  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 172 of file ImageOriginTest.cpp.

173 {
174 test_draw_fn(reporter, context, draw_image);
175}
static void draw_image(SkCanvas *canvas, SkImage *img)

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [3/5]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( ImageOriginTest_imageShader_Graphite  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 177 of file ImageOriginTest.cpp.

178 {
179 test_draw_fn(reporter, context, draw_image_with_shader);
180}

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [4/5]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( ImageShaderTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 85 of file ImageShaderTest.cpp.

86 {
87 // Test that a subset bound covering less than half of a pixel causes that pixel not to be
88 // drawn when using decal tiling and nearest-neighbor filtering. In this case we have a subset
89 // that covers 3/4 the pixel column at y=1, all of the y=2 column, and 1/4 the y=3 column.
91 context,
92 /*canvasSize=*/SkISize::Make(100, 100),
93 /*imageSize=*/SkISize::Make(4, 4),
94 /*srcRect=*/SkRect::MakeLTRB(1.25, 0.0f, 3.25f, 2.0f),
95 /*dstRect=*/SkRect::MakeLTRB(0, 0, 80, 80),
98
99 // Pixel that should sample the image at y=1, since that's where the subset starts.
100 {{{0, 40}, kRectColor},
101 // Pixel that would sample the image at y=3, but the subset bound at y=3.25 prevents
102 // us from sampling the image.
103 {{75, 40}, kBgColor}});
104}
static void test_draw(SkCanvas *canvas, const char label[])
Definition: surface.cpp:72

◆ DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS() [5/5]

skgpu::graphite::DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS ( UploadBufferManagerTest  ,
reporter  ,
context  ,
CtsEnforcement::kNextRelease   
)

Definition at line 19 of file UploadBufferManagerTest.cpp.

20 {
21 std::unique_ptr<Recorder> recorder = context->makeRecorder();
22 UploadBufferManager* bufferManager = recorder->priv().uploadBufferManager();
23
24 // The test source data.
25 char src[8] = {
26 1, 2, 3, 4,
27 5, 6, 7, 8,
28 };
29
30 // Test multiple small writes to a reused buffer.
31 auto [smWriter0, smBufferInfo0] = bufferManager->getTextureUploadWriter(10, 1);
32 smWriter0.write(/*offset=*/0, src, /*srcRowBytes=*/4, /*dstRowBytes=*/3, /*trimRowBytes=*/3,
33 /*rowCount=*/2);
34 smWriter0.write(/*offset=*/6, src, /*srcRowBytes=*/4, /*dstRowBytes=*/2, /*trimRowBytes=*/2,
35 /*rowCount=*/2);
36
37 auto [smWriter1, smBufferInfo1] = bufferManager->getTextureUploadWriter(4, 1);
38 smWriter1.write(/*offset=*/0, src, /*srcRowBytes=*/4, /*dstRowBytes=*/2, /*trimRowBytes=*/2,
39 /*rowCount=*/2);
40
41 REPORTER_ASSERT(reporter, smBufferInfo0.fBuffer == smBufferInfo1.fBuffer);
42 REPORTER_ASSERT(reporter, smBufferInfo0.fOffset == 0);
43 REPORTER_ASSERT(reporter, smBufferInfo1.fOffset >= 10);
44
45 // Test a large write, which should get its own dedicated buffer.
46 auto [lgWriter, lgBufferInfo] = bufferManager->getTextureUploadWriter((64 << 10) + 1, 1);
47 lgWriter.write(/*offset=*/0, src, /*srcRowBytes=*/4, /*dstRowBytes=*/2, /*trimRowBytes=*/2,
48 /*rowCount=*/2);
49
50 REPORTER_ASSERT(reporter, lgBufferInfo.fBuffer != smBufferInfo0.fBuffer);
51 REPORTER_ASSERT(reporter, lgBufferInfo.fOffset == 0);
52 REPORTER_ASSERT(reporter, lgBufferInfo.fBuffer->isMapped());
53 const void* lgBufferMap = const_cast<Buffer*>(lgBufferInfo.fBuffer)->map();
54 const char expectedLgBufferMap[4] = {
55 1, 2,
56 5, 6,
57 };
59 memcmp(lgBufferMap, expectedLgBufferMap, sizeof(expectedLgBufferMap)) == 0);
60
61 // Test another small write after the large write.
62 auto [smWriter2, smBufferInfo2] = bufferManager->getTextureUploadWriter(2, 1);
63 smWriter2.write(/*offset=*/0, src, /*srcRowBytes=*/4, /*dstRowBytes=*/2, /*trimRowBytes=*/2,
64 /*rowCount=*/1);
65
66 REPORTER_ASSERT(reporter, smBufferInfo2.fBuffer == smBufferInfo0.fBuffer);
67 REPORTER_ASSERT(reporter, smBufferInfo2.fOffset >= 4 + smBufferInfo1.fOffset);
68
69 REPORTER_ASSERT(reporter, smBufferInfo0.fBuffer->isMapped());
70 const char* smBufferMap =
71 reinterpret_cast<const char*>(const_cast<Buffer*>(smBufferInfo0.fBuffer)->map());
72 // Each section of written data could be offset and aligned by GPU-required rules, so we can't
73 // easily validate the contents of the buffer in one go, and instead test at each of the three
74 // reported offsets.
75 const char expectedSmBuffer0[10] = { 1, 2, 3, 5, 6, 7, 1, 2, 5, 6 };
76 const char expectedSmBuffer1[4] = { 1, 2, 5, 6 };
77 const char expectedSmBuffer2[2] = { 1, 2};
78 REPORTER_ASSERT(reporter, memcmp(smBufferMap + smBufferInfo0.fOffset,
79 expectedSmBuffer0,
80 sizeof(expectedSmBuffer0)) == 0);
81 REPORTER_ASSERT(reporter, memcmp(smBufferMap + smBufferInfo1.fOffset,
82 expectedSmBuffer1,
83 sizeof(expectedSmBuffer1)) == 0);
84 REPORTER_ASSERT(reporter, memcmp(smBufferMap + smBufferInfo2.fOffset,
85 expectedSmBuffer1,
86 sizeof(expectedSmBuffer2)) == 0);
87
88 // Snap a Recording from the Recorder. This will transfer resources from the UploadBufferManager
89 // to the Recording.
90 auto recording = recorder->snap();
91
92 // Test writes with a required alignment.
93 auto [alWriter0, alBufferInfo0] = bufferManager->getTextureUploadWriter(6, 4);
94 alWriter0.write(/*offset=*/0, src, /*srcRowBytes=*/4, /*dstRowBytes=*/3, /*trimRowBytes=*/3,
95 /*rowCount=*/2);
96
97 auto [alWriter1, alBufferInfo1] = bufferManager->getTextureUploadWriter(2, 4);
98 alWriter1.write(/*offset=*/0, src, /*srcRowBytes=*/4, /*dstRowBytes=*/2, /*trimRowBytes=*/2,
99 /*rowCount=*/1);
100
101 // Should not share a buffer with earlier small writes, since we've transferred previously-
102 // allocated resources to the command buffer.
103 REPORTER_ASSERT(reporter, alBufferInfo0.fBuffer != smBufferInfo0.fBuffer);
104 REPORTER_ASSERT(reporter, alBufferInfo0.fBuffer == alBufferInfo1.fBuffer);
105 REPORTER_ASSERT(reporter, alBufferInfo0.fOffset == 0);
106 REPORTER_ASSERT(reporter, alBufferInfo1.fOffset == 8);
107
108 // From alWriter0.
109 const char expectedAlBufferMap0[6] = {
110 1, 2, 3,
111 5, 6, 7,
112 };
113 // From alWriter1.
114 const char expectedAlBufferMap1[2] = {
115 1, 2,
116 };
117
118 REPORTER_ASSERT(reporter, alBufferInfo0.fBuffer->isMapped());
119 const void* alBufferMap = const_cast<Buffer*>(alBufferInfo0.fBuffer)->map();
121 memcmp(alBufferMap, expectedAlBufferMap0, sizeof(expectedAlBufferMap0)) == 0);
122
123 alBufferMap = SkTAddOffset<const void>(alBufferMap, 8);
125 memcmp(alBufferMap, expectedAlBufferMap1, sizeof(expectedAlBufferMap1)) == 0);
126}
std::tuple< TextureUploadWriter, BindBufferInfo > getTextureUploadWriter(size_t requiredBytes, size_t requiredAlignment)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680

◆ DEF_TEST()

skgpu::graphite::DEF_TEST ( BoundsManager  ,
 
)

Definition at line 14 of file BoundsManagerTest.cpp.

14 {
15 // 64 grid cells, each 16x16
16 const int n = 8;
17 const int w = 16;
18 std::unique_ptr<BoundsManager> bm = GridBoundsManager::Make({n * w, n * w}, n);
19
20 CompressedPaintersOrder order = CompressedPaintersOrder::First();
21 for (int y = 0; y < n; ++y) {
22 for (int x = 0; x < n; ++x) {
23 order = order.next();
24
25 // Should only modify a single cell
26 Rect b = Rect::XYWH((x + 0.1f) * w, (y + 0.1f) * w, 0.8f * w, 0.8f * w);
27 bm->recordDraw(b, order);
28 }
29 }
30
31 // TODO: repeat these queries using bounds that intersect across levels as well
32 order = CompressedPaintersOrder::First();
33 for (int y = 0; y < n; ++y) {
34 for (int x = 0; x < n; ++x) {
35 order = order.next();
36
37 // Should only read a single cell
38 Rect b = Rect::XYWH((x + 0.2f) * w, (y + 0.2f) * w, 0.6f * w, 0.6f * w);
39
40 CompressedPaintersOrder actual = bm->getMostRecentDraw(b);
41 REPORTER_ASSERT(r, actual == order);
42 }
43 }
44
45 // TODO: Then call recordDraw with new values that write to multiple cells
46
47 // TODO: Then test calls where the new value is not larger than the current max
48}
double y
double x
MonotonicValue< CompressedPaintersOrderSequence > CompressedPaintersOrder
Definition: DrawOrder.h:58
SkScalar w

◆ descriptor_data_to_layout()

static VkDescriptorSetLayout skgpu::graphite::descriptor_data_to_layout ( const VulkanSharedContext sharedContext,
const SkSpan< DescriptorData > &  descriptorData 
)
static

Definition at line 447 of file VulkanGraphicsPipeline.cpp.

448 {
449 if (descriptorData.size() == 0) { return VK_NULL_HANDLE; }
450
451 VkDescriptorSetLayout setLayout;
452 DescriptorDataToVkDescSetLayout(sharedContext, descriptorData, &setLayout);
453 if (setLayout == VK_NULL_HANDLE) {
454 SKGPU_LOG_E("Failed to create descriptor set layout; pipeline creation will fail.\n");
455 return VK_NULL_HANDLE;
456 }
457 return setLayout;
458}
constexpr size_t size() const
Definition: SkSpan_impl.h:95
void DescriptorDataToVkDescSetLayout(const VulkanSharedContext *ctxt, const SkSpan< DescriptorData > &requestedDescriptors, VkDescriptorSetLayout *outLayout)

◆ DescriptorDataToVkDescSetLayout()

void skgpu::graphite::DescriptorDataToVkDescSetLayout ( const VulkanSharedContext ctxt,
const SkSpan< DescriptorData > &  requestedDescriptors,
VkDescriptorSetLayout *  outLayout 
)

Definition at line 71 of file VulkanGraphiteUtils.cpp.

73 {
75 for (size_t i = 0; i < requestedDescriptors.size(); i++) {
76 if (requestedDescriptors[i].fCount != 0) {
77 const DescriptorData& currDescriptor = requestedDescriptors[i];
78 VkDescriptorSetLayoutBinding& layoutBinding = bindingLayouts.push_back();
79 memset(&layoutBinding, 0, sizeof(VkDescriptorSetLayoutBinding));
80 layoutBinding.binding = currDescriptor.fBindingIndex;
81 layoutBinding.descriptorType = DsTypeEnumToVkDs(currDescriptor.fType);
82 layoutBinding.descriptorCount = currDescriptor.fCount;
83 layoutBinding.stageFlags =
85 // TODO(b/302126498): Set pImmutableSampler to currDescriptor.fImmutableSampler once
86 // immutable samplers are created and used within graphite.
87 layoutBinding.pImmutableSamplers = nullptr;
88 }
89 }
90
91 VkDescriptorSetLayoutCreateInfo layoutCreateInfo;
92 memset(&layoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo));
94 layoutCreateInfo.pNext = nullptr;
95 layoutCreateInfo.flags = 0;
96 layoutCreateInfo.bindingCount = bindingLayouts.size();
97 layoutCreateInfo.pBindings = &bindingLayouts.front();
98
101 ctxt,
102 result,
103 CreateDescriptorSetLayout(ctxt->device(), &layoutCreateInfo, nullptr, outLayout));
104 if (result != VK_SUCCESS) {
105 SkDebugf("Failed to create VkDescriptorSetLayout\n");
106 outLayout = VK_NULL_HANDLE;
107 }
108}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
VkDescriptorType DsTypeEnumToVkDs(DescriptorType type)
VkShaderStageFlags PipelineStageFlagsToVkShaderStageFlags(SkEnumBitMask< PipelineStageFlags > stageFlags)
VkDescriptorType descriptorType
Definition: vulkan_core.h:3773
const VkSampler * pImmutableSamplers
Definition: vulkan_core.h:3776
VkShaderStageFlags stageFlags
Definition: vulkan_core.h:3775
const VkDescriptorSetLayoutBinding * pBindings
Definition: vulkan_core.h:3784
VkDescriptorSetLayoutCreateFlags flags
Definition: vulkan_core.h:3782
SkEnumBitMask< PipelineStageFlags > fPipelineStageFlags
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
Definition: vulkan_core.h:234

◆ destroy_desc_set_layouts()

static void skgpu::graphite::destroy_desc_set_layouts ( const VulkanSharedContext sharedContext,
skia_private::TArray< VkDescriptorSetLayout > &  setLayouts 
)
static

Definition at line 460 of file VulkanGraphicsPipeline.cpp.

461 {
462 for (int i = 0; i < setLayouts.size(); i++) {
463 if (setLayouts[i] != VK_NULL_HANDLE) {
464 VULKAN_CALL(sharedContext->interface(),
465 DestroyDescriptorSetLayout(sharedContext->device(),
466 setLayouts[i],
467 nullptr));
468 }
469 }
470}
#define VULKAN_CALL(IFACE, X)
const skgpu::VulkanInterface * interface() const

◆ destroy_shader_modules()

static void skgpu::graphite::destroy_shader_modules ( const VulkanSharedContext sharedContext,
VkShaderModule  vsModule,
VkShaderModule  fsModule 
)
static

Definition at line 566 of file VulkanGraphicsPipeline.cpp.

568 {
569 if (vsModule != VK_NULL_HANDLE) {
570 VULKAN_CALL(sharedContext->interface(),
571 DestroyShaderModule(sharedContext->device(), vsModule, nullptr));
572 }
573 if (fsModule != VK_NULL_HANDLE) {
574 VULKAN_CALL(sharedContext->interface(),
575 DestroyShaderModule(sharedContext->device(), fsModule, nullptr));
576 }
577}

◆ DsTypeEnumToVkDs()

VkDescriptorType skgpu::graphite::DsTypeEnumToVkDs ( DescriptorType  type)

Definition at line 110 of file VulkanGraphiteUtils.cpp.

110 {
111 switch (type) {
112 case DescriptorType::kUniformBuffer:
114 case DescriptorType::kTextureSampler:
116 case DescriptorType::kTexture:
118 case DescriptorType::kCombinedTextureSampler:
120 case DescriptorType::kStorageBuffer:
122 case DescriptorType::kInputAttachment:
124 }
126}
@ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
Definition: vulkan_core.h:2127
@ VK_DESCRIPTOR_TYPE_SAMPLER
Definition: vulkan_core.h:2125
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC
Definition: vulkan_core.h:2133
@ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
Definition: vulkan_core.h:2132
@ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
Definition: vulkan_core.h:2135
@ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
Definition: vulkan_core.h:2126

◆ EmitPaintParamsStorageBuffer()

std::string skgpu::graphite::EmitPaintParamsStorageBuffer ( int  bufferID,
SkSpan< const ShaderNode * >  nodes,
int numUniforms,
bool *  wrotePaintColor 
)

Definition at line 309 of file ContextUtils.cpp.

313 {
314
315 std::string result;
316 result += "struct FSUniformData {\n";
317 for (const ShaderNode* n : nodes) {
318 result += get_node_ssbo_fields(n, numUniforms, wrotePaintColor);
319 }
320 result += "};\n\n";
321
322 if (!*numUniforms) {
323 // No uniforms were added
324 return {};
325 }
326
328 "layout (binding=%d) readonly buffer FSUniforms {\n"
329 " FSUniformData fsUniformData[];\n"
330 "};\n",
331 bufferID);
332 return result;
333}

◆ EmitPaintParamsUniforms()

std::string skgpu::graphite::EmitPaintParamsUniforms ( int  bufferID,
const Layout  layout,
SkSpan< const ShaderNode * >  nodes,
int numUniforms,
int uniformsTotalBytes,
bool *  wrotePaintColor 
)

Definition at line 266 of file ContextUtils.cpp.

271 {
272 int offset = 0;
273
274 std::string result = get_uniform_header(bufferID, "FS");
275 for (const ShaderNode* n : nodes) {
276 result += get_node_uniforms(layout, n, &offset, numUniforms, wrotePaintColor);
277 }
278 result.append("};\n\n");
279
280 if (!*numUniforms) {
281 // No uniforms were added
282 return {};
283 }
284
285 if (uniformsTotalBytes) {
286 *uniformsTotalBytes = offset;
287 }
288
289 return result;
290}

◆ EmitRenderStepStorageBuffer()

std::string skgpu::graphite::EmitRenderStepStorageBuffer ( int  bufferID,
SkSpan< const Uniform uniforms 
)

Definition at line 335 of file ContextUtils.cpp.

337 {
338
339 std::string result;
340 result += "struct StepUniformData {\n" +
341 get_ssbo_fields(uniforms, -1, /* wrotePaintColor= */ nullptr) +
342 "};\n\n";
343
345 "layout (binding=%d) readonly buffer StepUniforms {\n"
346 " StepUniformData stepUniformData[];\n"
347 "};\n",
348 bufferID);
349 return result;
350}

◆ EmitRenderStepUniforms()

std::string skgpu::graphite::EmitRenderStepUniforms ( int  bufferID,
const Layout  layout,
SkSpan< const Uniform uniforms,
int renderStepUniformsTotalBytes 
)

Definition at line 292 of file ContextUtils.cpp.

295 {
296 int offset = 0;
297
298 std::string result = get_uniform_header(bufferID, "Step");
299 result += get_uniforms(layout, uniforms, &offset, -1, /* wrotePaintColor= */ nullptr);
300 result.append("};\n\n");
301
302 if (renderStepUniformsTotalBytes) {
303 *renderStepUniformsTotalBytes = offset;
304 }
305
306 return result;
307}

◆ EmitSamplerLayout()

std::string skgpu::graphite::EmitSamplerLayout ( const ResourceBindingRequirements bindingReqs,
int binding 
)

Definition at line 385 of file ContextUtils.cpp.

385 {
386 std::string result;
387
388 // If fDistinctIndexRanges is false, then texture and sampler indices may clash with other
389 // resource indices. Graphite assumes that they will be placed in descriptor set (Vulkan) and
390 // bind group (Dawn) index 1.
391 const char* distinctIndexRange = bindingReqs.fDistinctIndexRanges ? "" : "set=1, ";
392
393 if (bindingReqs.fSeparateTextureAndSamplerBinding) {
394 int samplerIndex = (*binding)++;
395 int textureIndex = (*binding)++;
396 result = SkSL::String::printf("layout(webgpu, %ssampler=%d, texture=%d)",
397 distinctIndexRange,
398 samplerIndex,
399 textureIndex);
400 } else {
401 int samplerIndex = (*binding)++;
402 result = SkSL::String::printf("layout(%sbinding=%d)",
403 distinctIndexRange,
404 samplerIndex);
405 }
406 return result;
407}

◆ EmitStorageBufferAccess()

std::string skgpu::graphite::EmitStorageBufferAccess ( const char *  bufferNamePrefix,
const char *  ssboIndex,
const char *  uniformName 
)

Definition at line 369 of file ContextUtils.cpp.

371 {
372 return SkSL::String::printf("%sUniformData[%s].%s", bufferNamePrefix, ssboIndex, uniformName);
373}

◆ EmitTexturesAndSamplers()

std::string skgpu::graphite::EmitTexturesAndSamplers ( const ResourceBindingRequirements bindingReqs,
SkSpan< const ShaderNode * >  nodes,
int binding 
)

Definition at line 375 of file ContextUtils.cpp.

377 {
378 std::string result;
379 for (const ShaderNode* n : nodes) {
380 result += get_node_texture_samplers(bindingReqs, n, binding);
381 }
382 return result;
383}

◆ EmitUniformsFromStorageBuffer()

std::string skgpu::graphite::EmitUniformsFromStorageBuffer ( const char *  bufferNamePrefix,
const char *  ssboIndex,
SkSpan< const Uniform uniforms 
)

Definition at line 352 of file ContextUtils.cpp.

354 {
355 std::string result;
356
357 for (const Uniform& u : uniforms) {
358 SkSL::String::appendf(&result, "%s %s", SkSLTypeString(u.type()), u.name());
359 if (u.count()) {
360 SkSL::String::appendf(&result, "[%d]", u.count());
361 }
363 &result, " = %sUniformData[%s].%s;\n", bufferNamePrefix, ssboIndex, u.name());
364 }
365
366 return result;
367}
const char * SkSLTypeString(SkSLType t)

◆ EmitVaryings()

std::string skgpu::graphite::EmitVaryings ( const RenderStep step,
const char *  direction,
bool  emitSsboIndicesVarying,
bool  emitLocalCoordsVarying 
)

Definition at line 436 of file ContextUtils.cpp.

439 {
440 std::string result;
441 int location = 0;
442
443 if (emitSsboIndicesVarying) {
445 " layout(location=%d) %s flat ushort2 %s;\n",
446 location++,
447 direction,
448 RenderStep::ssboIndicesVarying());
449 }
450
451 if (emitLocalCoordsVarying) {
452 SkSL::String::appendf(&result, " layout(location=%d) %s ", location++, direction);
454 SkSL::String::appendf(&result, " localCoordsVar;\n");
455 }
456
457 for (auto v : step->varyings()) {
458 SkSL::String::appendf(&result, " layout(location=%d) %s ", location++, direction);
459 result.append(SkSLTypeString(v.fType));
460 SkSL::String::appendf(&result, " %s;\n", v.fName);
461 }
462
463 return result;
464}

◆ expand_bits()

template<typename INT_TYPE >
static void skgpu::graphite::expand_bits ( INT_TYPE *  dst,
const uint8_t *  src,
int  width,
int  height,
int  dstRowBytes,
int  srcRowBytes 
)
static

Definition at line 57 of file TextAtlasManager.cpp.

62 {
63 for (int y = 0; y < height; ++y) {
64 int rowWritesLeft = width;
65 const uint8_t* s = src;
66 INT_TYPE* d = dst;
67 while (rowWritesLeft > 0) {
68 unsigned mask = *s++;
69 for (int x = 7; x >= 0 && rowWritesLeft; --x, --rowWritesLeft) {
70 *d++ = (mask & (1 << x)) ? (INT_TYPE)(~0UL) : 0;
71 }
72 }
73 dst = reinterpret_cast<INT_TYPE*>(reinterpret_cast<intptr_t>(dst) + dstRowBytes);
74 src += srcRowBytes;
75 }
76}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
struct MyStruct s
dst
Definition: cp.py:12
int32_t height
int32_t width

◆ ExtractPaintData()

std::tuple< UniquePaintParamsID, const UniformDataBlock *, const TextureDataBlock * > skgpu::graphite::ExtractPaintData ( Recorder recorder,
PipelineDataGatherer gatherer,
PaintParamsKeyBuilder builder,
const Layout  layout,
const SkM44 local2Dev,
const PaintParams p,
const Geometry geometry,
sk_sp< TextureProxy dstTexture,
SkIPoint  dstOffset,
const SkColorInfo targetColorInfo 
)

Definition at line 32 of file ContextUtils.cpp.

42 {
43 SkDEBUGCODE(builder->checkReset());
44
45 gatherer->resetWithNewLayout(layout);
46
47 KeyContext keyContext(recorder,
48 local2Dev,
49 targetColorInfo,
50 geometry.isShape() || geometry.isEdgeAAQuad()
51 ? KeyContext::OptimizeSampling::kYes
52 : KeyContext::OptimizeSampling::kNo,
53 p.color(),
54 std::move(dstTexture),
55 dstOffset);
56 p.toKey(keyContext, builder, gatherer);
57
59 const UniformDataBlock* uniforms = nullptr;
60 const TextureDataBlock* textures = nullptr;
61 if (paintID.isValid()) {
62 if (gatherer->hasUniforms()) {
63 UniformDataCache* uniformDataCache = recorder->priv().uniformDataCache();
64 uniforms = uniformDataCache->insert(gatherer->finishUniformDataBlock());
65 }
66 if (gatherer->hasTextures()) {
67 TextureDataCache* textureDataCache = recorder->priv().textureDataCache();
68 textures = textureDataCache->insert(gatherer->textureDataBlock());
69 }
70 }
71
72 return { paintID, uniforms, textures };
73}
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
bool isShape() const
Definition: Geometry.h:96
bool isEdgeAAQuad() const
Definition: Geometry.h:99
const T * insert(const T &dataBlock)
UniformDataBlock finishUniformDataBlock()
Definition: PipelineData.h:127
const TextureDataBlock & textureDataBlock()
Definition: PipelineData.h:105
const ShaderCodeDictionary * shaderCodeDictionary() const
Definition: RecorderPriv.h:41
TextureDataCache * textureDataCache()
Definition: RecorderPriv.h:57
UniformDataCache * uniformDataCache()
Definition: RecorderPriv.h:56
UniquePaintParamsID findOrCreate(PaintParamsKeyBuilder *) SK_EXCLUDES(fSpinLock)
PipelineDataCache< TextureDataBlock > TextureDataCache
Definition: Recorder.h:61

◆ ExtractRenderStepData()

std::tuple< const UniformDataBlock *, const TextureDataBlock * > skgpu::graphite::ExtractRenderStepData ( UniformDataCache uniformDataCache,
TextureDataCache textureDataCache,
PipelineDataGatherer gatherer,
const Layout  layout,
const RenderStep step,
const DrawParams params 
)

Definition at line 75 of file ContextUtils.cpp.

81 {
82 gatherer->resetWithNewLayout(layout);
83 step->writeUniformsAndTextures(params, gatherer);
84
85 const UniformDataBlock* uniforms =
86 gatherer->hasUniforms() ? uniformDataCache->insert(gatherer->finishUniformDataBlock())
87 : nullptr;
88 const TextureDataBlock* textures =
89 gatherer->hasTextures() ? textureDataCache->insert(gatherer->textureDataBlock())
90 : nullptr;
91
92 return { uniforms, textures };
93}
const EmbeddedViewParams * params

◆ find_or_create_by_key()

static sk_sp< TextureProxy > skgpu::graphite::find_or_create_by_key ( Recorder recorder,
int  id,
bool *  regenerated 
)
static

Definition at line 412 of file ProxyCacheTest.cpp.

412 {
413 *regenerated = false;
414
416 {
417 static const skgpu::UniqueKey::Domain kTestDomain = UniqueKey::GenerateDomain();
418 UniqueKey::Builder builder(&key, kTestDomain, 1, "TestExplicitKey");
419 builder[0] = id;
420 }
421
422 struct Context {
423 int id;
424 bool* regenerated;
425 } params { id, regenerated };
426
427 return recorder->priv().proxyCache()->findOrCreateCachedProxy(
428 recorder, key, &params,
429 [](const void* context) {
430 const Context* params = static_cast<const Context*>(context);
431 *params->regenerated = true;
432
433 SkBitmap bm;
434 if (params->id == 1) {
435 if (!ToolUtils::GetResourceAsBitmap("images/mandrill_32.png", &bm)) {
436 return SkBitmap();
437 }
438 } else if (!ToolUtils::GetResourceAsBitmap("images/mandrill_64.png", &bm)) {
439 return SkBitmap();
440 }
441 return bm;
442 });
443}
const uintptr_t id

◆ Flush() [1/2]

void skgpu::graphite::Flush ( sk_sp< SkSurface surface)

Definition at line 141 of file Surface_Graphite.cpp.

141 {
142 return Flush(surface.get());
143}
void Flush(SkSurface *surface)

◆ Flush() [2/2]

void skgpu::graphite::Flush ( SkSurface surface)

Definition at line 145 of file Surface_Graphite.cpp.

145 {
146 if (!surface) {
147 return;
148 }
149 auto sb = asSB(surface);
150 if (!sb->isGraphiteBacked()) {
151 return;
152 }
153 auto gs = static_cast<Surface*>(surface);
154 gs->fDevice->flushPendingWorkToRecorder();
155}
static SkSurface_Base * asSB(SkSurface *surface)

◆ gather_runtime_effect_uniforms()

static void skgpu::graphite::gather_runtime_effect_uniforms ( const KeyContext keyContext,
const SkRuntimeEffect effect,
SkSpan< const Uniform graphiteUniforms,
const SkData uniformData,
PipelineDataGatherer gatherer 
)
static

Definition at line 1098 of file KeyHelpers.cpp.

1102 {
1103 if (!uniformData) {
1104 return; // precompiling
1105 }
1106
1107 SkDEBUGCODE(UniformExpectationsValidator uev(gatherer, graphiteUniforms);)
1108
1109 SkSpan<const SkRuntimeEffect::Uniform> rtsUniforms = effect->uniforms();
1110
1111 if (!rtsUniforms.empty() && uniformData) {
1112 // Collect all the other uniforms from the provided SkData.
1113 const uint8_t* uniformBase = uniformData->bytes();
1114 for (size_t index = 0; index < rtsUniforms.size(); ++index) {
1115 const Uniform& uniform = graphiteUniforms[index];
1116 // Get a pointer to the offset in our data for this uniform.
1117 const uint8_t* uniformPtr = uniformBase + rtsUniforms[index].offset;
1118 // Pass the uniform data to the gatherer.
1119 gatherer->write(uniform, uniformPtr);
1120 }
1121 }
1122
1124 SkColorSpace* dstCS = keyContext.dstColorInfo().colorSpace();
1125 if (!dstCS) {
1126 dstCS = sk_srgb_linear_singleton(); // turn colorspace conversion into a noop
1127 }
1128
1129 // TODO(b/332565302): If the runtime shader only uses one of these
1130 // transforms, we could upload only one set of uniforms.
1131 ColorSpaceTransformBlock::ColorSpaceTransformData dstToLinear(dstCS,
1135 ColorSpaceTransformBlock::ColorSpaceTransformData linearToDst(sk_srgb_linear_singleton(),
1137 dstCS,
1139
1140 add_color_space_uniforms(dstToLinear.fSteps, ReadSwizzle::kRGBA, gatherer);
1141 add_color_space_uniforms(linearToDst.fSteps, ReadSwizzle::kRGBA, gatherer);
1142 }
1143}
kUnpremul_SkAlphaType
SkColorSpace * sk_srgb_linear_singleton()
const uint8_t * bytes() const
Definition: SkData.h:43
static bool UsesColorTransform(const SkRuntimeEffect *effect)

◆ GenerateMipmaps()

bool skgpu::graphite::GenerateMipmaps ( Recorder recorder,
sk_sp< TextureProxy texture,
const SkColorInfo colorInfo 
)

Definition at line 727 of file TextureUtils.cpp.

729 {
730 constexpr SkSamplingOptions kSamplingOptions = SkSamplingOptions(SkFilterMode::kLinear);
731
732 SkASSERT(texture->mipmapped() == Mipmapped::kYes);
733
734 // Within a rescaling pass scratchImg is read from and a scratch surface is written to.
735 // At the end of the pass the scratch surface's texture is wrapped and assigned to scratchImg.
736
737 // The scratch surface we create below will use a write swizzle derived from SkColorType and
738 // pixel format. We have to be consistent and swizzle on the read.
739 auto imgSwizzle = recorder->priv().caps()->getReadSwizzle(colorInfo.colorType(),
740 texture->textureInfo());
741 sk_sp<SkImage> scratchImg(new Image(TextureProxyView(texture, imgSwizzle), colorInfo));
742
743 SkISize srcSize = texture->dimensions();
744 const SkColorInfo outColorInfo = colorInfo.makeAlphaType(kPremul_SkAlphaType);
745
746 // Alternate between two scratch surfaces to avoid reading from and writing to a texture in the
747 // same pass. The dimensions of the first usages of the two scratch textures will be 1/2 and 1/4
748 // those of the original texture, respectively.
749 sk_sp<Surface> scratchSurfaces[2];
750 for (int i = 0; i < 2; ++i) {
751 scratchSurfaces[i] = make_renderable_scratch_surface(
752 recorder,
753 SkImageInfo::Make(SkISize::Make(std::max(1, srcSize.width() >> (i + 1)),
754 std::max(1, srcSize.height() >> (i + 1))),
755 outColorInfo),
757 "GenerateMipmapsScratchTexture");
758 if (!scratchSurfaces[i]) {
759 return false;
760 }
761 }
762
763 for (int mipLevel = 1; srcSize.width() > 1 || srcSize.height() > 1; ++mipLevel) {
764 const SkISize dstSize = SkISize::Make(std::max(srcSize.width() >> 1, 1),
765 std::max(srcSize.height() >> 1, 1));
766
767 Surface* scratchSurface = scratchSurfaces[(mipLevel - 1) & 1].get();
768
770 paint.setBlendMode(SkBlendMode::kSrc);
771 scratchSurface->getCanvas()->drawImageRect(scratchImg,
772 SkRect::Make(srcSize),
773 SkRect::Make(dstSize),
774 kSamplingOptions,
775 &paint,
777
778 // Make sure the rescaling draw finishes before copying the results.
779 Flush(scratchSurface);
780
782 static_cast<const Surface*>(scratchSurface)->readSurfaceView().refProxy(),
783 SkIRect::MakeSize(dstSize),
784 texture,
785 {0, 0},
786 mipLevel);
787 if (!copyTask) {
788 return false;
789 }
790 recorder->priv().add(std::move(copyTask));
791
792 scratchImg = scratchSurface->asImage();
793 srcSize = dstSize;
794 }
795
796 return true;
797}
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1542
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
virtual SkCanvas * getCanvas()=0
skgpu::Swizzle getReadSwizzle(SkColorType, const TextureInfo &) const
Definition: Caps.cpp:129
void add(sk_sp< Task >)
Definition: Recorder.cpp:485
const myers::Point & get(const myers::Segment &)
void Flush(SkSurface *surface)
Definition: GpuTools.h:25
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66

◆ GeneratePathMaskKey()

skgpu::UniqueKey skgpu::graphite::GeneratePathMaskKey ( const Shape shape,
const Transform transform,
const SkStrokeRec strokeRec,
skvx::half2  maskSize 
)

Definition at line 69 of file RasterPathUtils.cpp.

72 {
73 skgpu::UniqueKey maskKey;
74 {
76 int styleKeySize = 6;
77 if (!strokeRec.isHairlineStyle() && !strokeRec.isFillStyle()) {
78 // Add space for width and miter if needed
79 styleKeySize += 2;
80 }
81 skgpu::UniqueKey::Builder builder(&maskKey, kDomain, styleKeySize + shape.keySize(),
82 "Raster Path Mask");
83 builder[0] = maskSize.x() | (maskSize.y() << 16);
84
85 // We require the upper left 2x2 of the matrix to match exactly for a cache hit.
86 SkMatrix mat = transform.matrix().asM33();
91#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
92 // Fractional translate does not affect caching on Android. This is done for better cache
93 // hit ratio and speed and is matching HWUI behavior, which didn't consider the matrix
94 // at all when caching paths.
95 SkFixed fracX = 0;
96 SkFixed fracY = 0;
97#else
100 // Allow 8 bits each in x and y of subpixel positioning.
101 SkFixed fracX = SkScalarToFixed(SkScalarFraction(tx)) & 0x0000FF00;
102 SkFixed fracY = SkScalarToFixed(SkScalarFraction(ty)) & 0x0000FF00;
103#endif
104 builder[1] = SkFloat2Bits(sx);
105 builder[2] = SkFloat2Bits(sy);
106 builder[3] = SkFloat2Bits(kx);
107 builder[4] = SkFloat2Bits(ky);
108 // FracX and fracY are &ed with 0x0000ff00, so need to shift one down to fill 16 bits.
109 uint32_t fracBits = fracX | (fracY >> 8);
110 // Distinguish between path styles. For anything but fill, we also need to include
111 // the cap. (SW grows hairlines by 0.5 pixel with round and square caps). For stroke
112 // or fill-and-stroke we need to include the join, width, and miter.
113 static_assert(SkStrokeRec::kStyleCount <= (1 << 2));
114 static_assert(SkPaint::kCapCount <= (1 << 2));
115 static_assert(SkPaint::kJoinCount <= (1 << 2));
116 uint32_t styleBits = strokeRec.getStyle();
117 if (!strokeRec.isFillStyle()) {
118 styleBits |= (strokeRec.getCap() << 2);
119 }
120 if (!strokeRec.isHairlineStyle() && !strokeRec.isFillStyle()) {
121 styleBits |= (strokeRec.getJoin() << 4);
122 builder[5] = SkFloat2Bits(strokeRec.getWidth());
123 builder[6] = SkFloat2Bits(strokeRec.getMiter());
124 }
125 builder[styleKeySize-1] = fracBits | (styleBits << 16);
126 shape.writeKey(&builder[styleKeySize], /*includeInverted=*/false);
127 }
128 return maskKey;
129}
int32_t SkFixed
Definition: SkFixed.h:25
#define SkScalarToFixed(x)
Definition: SkFixed.h:125
static uint32_t SkFloat2Bits(float value)
Definition: SkFloatBits.h:41
static SkScalar SkScalarFraction(SkScalar x)
Definition: SkScalar.h:67
static constexpr int kMScaleX
horizontal scale factor
Definition: SkMatrix.h:353
static constexpr int kMTransY
vertical translation
Definition: SkMatrix.h:358
static constexpr int kMTransX
horizontal translation
Definition: SkMatrix.h:355
static constexpr int kMSkewY
vertical skew factor
Definition: SkMatrix.h:356
SkScalar get(int index) const
Definition: SkMatrix.h:392
static constexpr int kMScaleY
vertical scale factor
Definition: SkMatrix.h:357
static constexpr int kMSkewX
horizontal skew factor
Definition: SkMatrix.h:354
static constexpr int kCapCount
Definition: SkPaint.h:343
static constexpr int kJoinCount
Definition: SkPaint.h:368
static constexpr int kStyleCount
Definition: SkStrokeRec.h:39
Style getStyle() const
Definition: SkStrokeRec.cpp:71
bool isHairlineStyle() const
Definition: SkStrokeRec.h:47
SkScalar getWidth() const
Definition: SkStrokeRec.h:42
SkPaint::Join getJoin() const
Definition: SkStrokeRec.h:45
SkPaint::Cap getCap() const
Definition: SkStrokeRec.h:44
bool isFillStyle() const
Definition: SkStrokeRec.h:51
SkScalar getMiter() const
Definition: SkStrokeRec.h:43
static Domain GenerateDomain()
Definition: ResourceKey.cpp:27
int keySize() const
Definition: Shape.cpp:140
void writeKey(uint32_t *key, bool includeInverted) const
Definition: Shape.cpp:177
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47

◆ get_device_translation()

static skvx::float2 skgpu::graphite::get_device_translation ( const SkM44 localToDevice)
static

Definition at line 21 of file CoverageMaskRenderStep.cpp.

21 {
22 float m00 = localToDevice.rc(0,0), m01 = localToDevice.rc(0,1);
23 float m10 = localToDevice.rc(1,0), m11 = localToDevice.rc(1,1);
24
25 float det = m00*m11 - m01*m10;
26 if (SkScalarNearlyZero(det)) {
27 // We can't extract any pre-translation, since the upper 2x2 is not invertible. Return (0,0)
28 // so that the maskToDeviceRemainder matrix remains the full transform.
29 return {0.f, 0.f};
30 }
31
32 // Calculate inv([[m00,m01][m10,m11]])*[[m30][m31]] to get the pre-remainder device translation.
33 float tx = localToDevice.rc(0,3), ty = localToDevice.rc(1,3);
34 skvx::float4 invT = skvx::float4{m11, -m10, -m01, m00} * skvx::float4{tx,tx,ty,ty};
35 return (invT.xy() + invT.zw()) / det;
36}
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:101
SkScalar rc(int r, int c) const
Definition: SkM44.h:261

◆ get_packed_glyph_image()

static void skgpu::graphite::get_packed_glyph_image ( const SkGlyph glyph,
int  dstRB,
MaskFormat  expectedMaskFormat,
void *  dst 
)
static

Definition at line 78 of file TextAtlasManager.cpp.

79 {
80 const int width = glyph.width();
81 const int height = glyph.height();
82 const void* src = glyph.image();
83 SkASSERT(src != nullptr);
84
86 if (maskFormat == expectedMaskFormat) {
87 int srcRB = glyph.rowBytes();
88 // Notice this comparison is with the glyphs raw mask format, and not its MaskFormat.
89 if (glyph.maskFormat() != SkMask::kBW_Format) {
90 if (srcRB != dstRB) {
91 const int bbp = MaskFormatBytesPerPixel(expectedMaskFormat);
92 for (int y = 0; y < height; y++) {
93 memcpy(dst, src, width * bbp);
94 src = (const char*) src + srcRB;
95 dst = (char*) dst + dstRB;
96 }
97 } else {
98 memcpy(dst, src, dstRB * height);
99 }
100 } else {
101 // Handle 8-bit format by expanding the mask to the expected format.
102 const uint8_t* bits = reinterpret_cast<const uint8_t*>(src);
103 switch (expectedMaskFormat) {
104 case MaskFormat::kA8: {
105 uint8_t* bytes = reinterpret_cast<uint8_t*>(dst);
106 expand_bits(bytes, bits, width, height, dstRB, srcRB);
107 break;
108 }
109 case MaskFormat::kA565: {
110 uint16_t* rgb565 = reinterpret_cast<uint16_t*>(dst);
111 expand_bits(rgb565, bits, width, height, dstRB, srcRB);
112 break;
113 }
114 default:
115 SK_ABORT("Invalid MaskFormat");
116 }
117 }
118 } else if (maskFormat == MaskFormat::kA565 &&
119 expectedMaskFormat == MaskFormat::kARGB) {
120 // Convert if the glyph uses a 565 mask format since it is using LCD text rendering
121 // but the expected format is 8888 (will happen on Intel MacOS with Metal since that
122 // combination does not support 565).
123 static constexpr SkMasks masks{
124 {0b1111'1000'0000'0000, 11, 5}, // Red
125 {0b0000'0111'1110'0000, 5, 6}, // Green
126 {0b0000'0000'0001'1111, 0, 5}, // Blue
127 {0, 0, 0} // Alpha
128 };
129 constexpr int a565Bpp = MaskFormatBytesPerPixel(MaskFormat::kA565);
130 constexpr int argbBpp = MaskFormatBytesPerPixel(MaskFormat::kARGB);
131 constexpr bool kBGRAIsNative = kN32_SkColorType == kBGRA_8888_SkColorType;
132 char* dstRow = (char*)dst;
133 for (int y = 0; y < height; y++) {
134 dst = dstRow;
135 for (int x = 0; x < width; x++) {
136 uint16_t color565 = 0;
137 memcpy(&color565, src, a565Bpp);
138 uint32_t color8888;
139 // On Windows (and possibly others), font data is stored as BGR.
140 // So we need to swizzle the data to reflect that.
141 if (kBGRAIsNative) {
142 color8888 = masks.getBlue(color565) |
143 (masks.getGreen(color565) << 8) |
144 (masks.getRed(color565) << 16) |
145 (0xFF << 24);
146 } else {
147 color8888 = masks.getRed(color565) |
148 (masks.getGreen(color565) << 8) |
149 (masks.getBlue(color565) << 16) |
150 (0xFF << 24);
151 }
152 memcpy(dst, &color8888, argbBpp);
153 src = (const char*)src + a565Bpp;
154 dst = ( char*)dst + argbBpp;
155 }
156 dstRow += dstRB;
157 }
158 } else {
160 }
161}
static void expand_bits(INT_TYPE *dst, const uint8_t *src, int width, int height, int dstRowBytes, int srcRowBytes)
static const uint16_t rgb565[kNumPixels]
size_t rowBytes() const
Definition: SkGlyph.cpp:233
SkMask::Format maskFormat() const
Definition: SkGlyph.h:500
int height() const
Definition: SkGlyph.h:513
int width() const
Definition: SkGlyph.h:512
const void * image() const
Definition: SkGlyph.h:465
static skgpu::MaskFormat FormatFromSkGlyph(SkMask::Format format)
Definition: Glyph.h:19
constexpr int MaskFormatBytesPerPixel(MaskFormat format)
Definition: AtlasTypes.h:110
MaskFormat
Definition: AtlasTypes.h:98
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition: SkMask.h:27

◆ GetDstReadRequirement()

DstReadRequirement skgpu::graphite::GetDstReadRequirement ( const Caps caps,
std::optional< SkBlendMode blendMode,
Coverage  coverage 
)

Definition at line 95 of file ContextUtils.cpp.

97 {
98 // If the blend mode is absent, this is assumed to be for a runtime blender, for which we always
99 // do a dst read.
100 if (!blendMode || *blendMode > SkBlendMode::kLastCoeffMode) {
101 return caps->getDstReadRequirement();
102 }
103
104 const bool isLCD = coverage == Coverage::kLCD;
105 const bool hasCoverage = coverage != Coverage::kNone;
106 BlendFormula blendFormula = isLCD ? skgpu::GetLCDBlendFormula(*blendMode)
107 : skgpu::GetBlendFormula(false, hasCoverage, *blendMode);
108 if ((blendFormula.hasSecondaryOutput() && !caps->shaderCaps()->fDualSourceBlendingSupport) ||
109 (coverage == Coverage::kLCD && blendMode != SkBlendMode::kSrcOver)) {
110 return caps->getDstReadRequirement();
111 }
112
114}
@ kSrcOver
r = s + (1-sa)*d
static bool isLCD(const SkScalerContextRec &rec)
bool hasSecondaryOutput() const
Definition: BlendFormula.h:66
DstReadRequirement getDstReadRequirement() const
Definition: Caps.cpp:152
const SkSL::ShaderCaps * shaderCaps() const
Definition: Caps.h:75
Definition: GpuTools.h:21
BlendFormula GetBlendFormula(bool isOpaque, bool hasCoverage, SkBlendMode xfermode)
BlendFormula GetLCDBlendFormula(SkBlendMode xfermode)
bool fDualSourceBlendingSupport
Definition: SkSLUtil.h:84

◆ GetGraphiteBacked()

std::pair< sk_sp< SkImage >, SkSamplingOptions > skgpu::graphite::GetGraphiteBacked ( Recorder recorder,
const SkImage imageIn,
SkSamplingOptions  sampling 
)

Definition at line 799 of file TextureUtils.cpp.

801 {
804
805 if (imageIn->dimensions().area() <= 1 && mipmapped == Mipmapped::kYes) {
806 mipmapped = Mipmapped::kNo;
808 }
809
811 if (as_IB(imageIn)->isGraphiteBacked()) {
812 result = sk_ref_sp(imageIn);
813
814 // If the preexisting Graphite-backed image doesn't have the required mipmaps we will drop
815 // down the sampling
816 if (mipmapped == Mipmapped::kYes && !result->hasMipmaps()) {
817 mipmapped = Mipmapped::kNo;
819 }
820 } else {
821 auto clientImageProvider = recorder->clientImageProvider();
822 result = clientImageProvider->findOrCreate(
823 recorder, imageIn, {mipmapped == Mipmapped::kYes});
824
825 if (!valid_client_provided_image(
826 result.get(), imageIn, {mipmapped == Mipmapped::kYes})) {
827 // The client did not fulfill the ImageProvider contract so drop the image.
828 result = nullptr;
829 }
830 }
831
832 if (sampling.isAniso() && result) {
834 }
835
836 return { result, sampling };
837}
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
static SkSamplingOptions AnisoFallback(bool imageIsMipped)
ImageProvider * clientImageProvider()
Definition: Recorder.h:88
constexpr int64_t area() const
Definition: SkSize.h:39
const SkMipmapMode mipmap

◆ GetPipelineLabel()

std::string skgpu::graphite::GetPipelineLabel ( const ShaderCodeDictionary dict,
const RenderPassDesc renderPassDesc,
const RenderStep renderStep,
UniquePaintParamsID  paintID 
)

Definition at line 593 of file ContextUtils.cpp.

596 {
597 std::string label = renderPassDesc.toPipelineLabel().c_str(); // includes the write swizzle
598 label += " + ";
599 label += renderStep->name();
600 label += " + ";
601 label += dict->idToString(paintID).c_str(); // will be "(empty)" for depth-only draws
602 return label;
603}
const char * name() const
Definition: Renderer.h:116

◆ graphite_to_mtl_primitive()

static MTLPrimitiveType skgpu::graphite::graphite_to_mtl_primitive ( PrimitiveType  primitiveType)
static

Definition at line 615 of file MtlCommandBuffer.mm.

615 {
616 const static MTLPrimitiveType mtlPrimitiveType[] {
617 MTLPrimitiveTypeTriangle,
618 MTLPrimitiveTypeTriangleStrip,
619 MTLPrimitiveTypePoint,
620 };
621 static_assert((int)PrimitiveType::kTriangles == 0);
622 static_assert((int)PrimitiveType::kTriangleStrip == 1);
623 static_assert((int)PrimitiveType::kPoints == 2);
624
625 SkASSERT(primitiveType <= PrimitiveType::kPoints);
626 return mtlPrimitiveType[static_cast<int>(primitiveType)];
627}

◆ is_clockwise() [1/2]

static bool skgpu::graphite::is_clockwise ( const EdgeAAQuad quad)
static

Definition at line 206 of file AnalyticRRectRenderStep.cpp.

206 {
207 if (quad.isRect()) {
208 return true; // by construction, these are always locally clockwise
209 }
210
211 // This assumes that each corner has a consistent winding, which is the case for convex inputs,
212 // which is an assumption of the per-edge AA API. Check the sign of cross product between the
213 // first two edges.
214 const skvx::float4& xs = quad.xs();
215 const skvx::float4& ys = quad.ys();
216
217 float winding = (xs[0] - xs[3])*(ys[1] - ys[0]) - (ys[0] - ys[3])*(xs[1] - xs[0]);
218 if (winding == 0.f) {
219 // The input possibly forms a triangle with duplicate vertices, so check the opposite corner
220 winding = (xs[2] - xs[1])*(ys[3] - ys[2]) - (ys[2] - ys[1])*(xs[3] - xs[2]);
221 }
222
223 // At this point if winding is < 0, the quad's vertices are CCW. If it's still 0, the vertices
224 // form a line, in which case the vertex shader constructs a correct CW winding. Otherwise,
225 // the quad or triangle vertices produce a positive winding and are CW.
226 return winding >= 0.f;
227}
const skvx::float4 & ys() const
Definition: EdgeAAQuad.h:73
const skvx::float4 & xs() const
Definition: EdgeAAQuad.h:72

◆ is_clockwise() [2/2]

static bool skgpu::graphite::is_clockwise ( const EdgeAAQuad quad)
static

Definition at line 96 of file PerEdgeAAQuadRenderStep.cpp.

96 {
97 if (quad.isRect()) {
98 return true; // by construction, these are always locally clockwise
99 }
100
101 // This assumes that each corner has a consistent winding, which is the case for convex inputs,
102 // which is an assumption of the per-edge AA API. Check the sign of cross product between the
103 // first two edges.
104 const skvx::float4& xs = quad.xs();
105 const skvx::float4& ys = quad.ys();
106
107 float winding = (xs[0] - xs[3])*(ys[1] - ys[0]) - (ys[0] - ys[3])*(xs[1] - xs[0]);
108 if (winding == 0.f) {
109 // The input possibly forms a triangle with duplicate vertices, so check the opposite corner
110 winding = (xs[2] - xs[1])*(ys[3] - ys[2]) - (ys[2] - ys[1])*(xs[3] - xs[2]);
111 }
112
113 // At this point if winding is < 0, the quad's vertices are CCW. If it's still 0, the vertices
114 // form a line, in which case the vertex shader constructs a correct CW winding. Otherwise,
115 // the quad or triangle vertices produce a positive winding and are CW.
116 return winding >= 0.f;
117}

◆ key_to_string()

static int skgpu::graphite::key_to_string ( SkString str,
const ShaderCodeDictionary dict,
SkSpan< const uint32_t >  keyData,
int  currentIndex,
bool  includeData 
)
static

Definition at line 133 of file PaintParamsKey.cpp.

137 {
138 SkASSERT(currentIndex < SkTo<int>(keyData.size()));
139
140 uint32_t id = keyData[currentIndex++];
141 auto entry = dict->getEntry(id);
142 if (!entry) {
143 str->append("UnknownCodeSnippetID:");
144 str->appendS32(id);
145 str->append(" ");
146 return currentIndex;
147 }
148
149 std::string_view name = entry->fName;
150 if (skstd::ends_with(name, "Shader")) {
151 name.remove_suffix(6);
152 }
153 str->append(name);
154
155 if (entry->storesData()) {
156 SkASSERT(currentIndex + 1 < SkTo<int>(keyData.size()));
157 const int dataLength = keyData[currentIndex++];
158 SkASSERT(currentIndex + dataLength < SkTo<int>(keyData.size()));
159
160 str->append(" fData(size: ");
161 str->appendU32(dataLength);
162 str->append(")");
163
164 if (includeData) {
165 str->append(":[");
166 for (int i = 0; i < dataLength; i++) {
167 str->append(" ");
168 str->appendU32(keyData[currentIndex + i]);
169 }
170 str->append(" ]");
171 }
172
173 currentIndex += dataLength;
174 }
175
176 if (entry->fNumChildren > 0) {
177 str->append(" [ ");
178 for (int i = 0; i < entry->fNumChildren; ++i) {
179 currentIndex = key_to_string(str, dict, keyData, currentIndex, includeData);
180 }
181 str->append("]");
182 }
183
184 str->append(" ");
185 return currentIndex;
186}
void append(const char text[])
Definition: SkString.h:203
void appendS32(int32_t value)
Definition: SkString.h:208
void appendU32(uint32_t value)
Definition: SkString.h:210
const ShaderSnippet * getEntry(int codeSnippetID) const SK_EXCLUDES(fSpinLock)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
static int key_to_string(SkString *str, const ShaderCodeDictionary *dict, SkSpan< const uint32_t > keyData, int currentIndex, bool includeData)
constexpr bool ends_with(std::string_view str, std::string_view suffix)
Definition: SkStringView.h:28

◆ LayoutString()

static constexpr const char * skgpu::graphite::LayoutString ( Layout  layout)
staticconstexpr

Definition at line 84 of file ResourceTypes.h.

84 {
85 switch(layout) {
86 case Layout::kStd140: return "std140";
87 case Layout::kStd430: return "std430";
88 case Layout::kMetal: return "metal";
89 case Layout::kInvalid: return "invalid";
90 }
92}

◆ load_x_radii()

static skvx::float4 skgpu::graphite::load_x_radii ( const SkRRect rrect)
static

Definition at line 139 of file AnalyticRRectRenderStep.cpp.

139 {
144}
SkVector radii(Corner corner) const
Definition: SkRRect.h:271
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:255
SkRRect rrect
Definition: SkRecords.h:232
float fX
x-axis value
Definition: SkPoint_impl.h:164

◆ load_y_radii()

static skvx::float4 skgpu::graphite::load_y_radii ( const SkRRect rrect)
static

◆ make_interpolated_to_dst()

static void skgpu::graphite::make_interpolated_to_dst ( const KeyContext keyContext,
PaintParamsKeyBuilder builder,
PipelineDataGatherer gatherer,
const GradientShaderBlocks::GradientData gradData,
const SkGradientShader::Interpolation interp,
SkColorSpace intermediateCS 
)
static

Definition at line 2215 of file KeyHelpers.cpp.

2220 {
2222
2223 bool inputPremul = static_cast<bool>(interp.fInPremul);
2224
2225 switch (interp.fColorSpace) {
2226 case ColorSpace::kLab:
2227 case ColorSpace::kOKLab:
2228 case ColorSpace::kOKLabGamutMap:
2229 case ColorSpace::kLCH:
2230 case ColorSpace::kOKLCH:
2231 case ColorSpace::kOKLCHGamutMap:
2232 case ColorSpace::kHSL:
2233 case ColorSpace::kHWB:
2234 inputPremul = false;
2235 break;
2236 default:
2237 break;
2238 }
2239
2240 const SkColorInfo& dstColorInfo = keyContext.dstColorInfo();
2241
2242 SkColorSpace* dstColorSpace =
2243 dstColorInfo.colorSpace() ? dstColorInfo.colorSpace() : sk_srgb_singleton();
2244
2245 SkAlphaType intermediateAlphaType = inputPremul ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
2246
2247 ColorSpaceTransformBlock::ColorSpaceTransformData data(
2248 intermediateCS, intermediateAlphaType, dstColorSpace, dstColorInfo.alphaType());
2249
2250 // The gradient block and colorSpace conversion block need to be combined
2251 // (via the Compose block) so that the localMatrix block can treat them as
2252 // one child.
2253 Compose(keyContext, builder, gatherer,
2254 /* addInnerToKey= */ [&]() -> void {
2255 GradientShaderBlocks::AddBlock(keyContext, builder, gatherer, gradData);
2256 },
2257 /* addOuterToKey= */ [&]() -> void {
2258 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data);
2259 });
2260}
static float2 interp(const float2 &v0, const float2 &v1, const float2 &t)
Definition: SkGeometry.cpp:169
ColorSpace
Definition: image.h:16

◆ MakeBitmapProxyView()

std::tuple< TextureProxyView, SkColorType > skgpu::graphite::MakeBitmapProxyView ( Recorder recorder,
const SkBitmap bitmap,
sk_sp< SkMipmap mipmapsIn,
Mipmapped  mipmapped,
Budgeted  budgeted,
std::string_view  label 
)

Definition at line 380 of file TextureUtils.cpp.

385 {
386 // Adjust params based on input and Caps
387 const Caps* caps = recorder->priv().caps();
388 SkColorType ct = bitmap.info().colorType();
389
390 if (bitmap.dimensions().area() <= 1) {
391 mipmapped = Mipmapped::kNo;
392 }
393
394 Protected isProtected = recorder->priv().isProtected();
395 auto textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, isProtected,
397 if (!textureInfo.isValid()) {
399 textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, isProtected,
401 }
402 SkASSERT(textureInfo.isValid());
403
404 // Convert bitmap to texture colortype if necessary
405 SkBitmap bmpToUpload;
406 if (ct != bitmap.info().colorType()) {
407 if (!bmpToUpload.tryAllocPixels(bitmap.info().makeColorType(ct)) ||
408 !bitmap.readPixels(bmpToUpload.pixmap())) {
409 return {};
410 }
411 bmpToUpload.setImmutable();
412 } else {
413 bmpToUpload = bitmap;
414 }
415
416 if (!SkImageInfoIsValid(bmpToUpload.info())) {
417 return {};
418 }
419
420 int mipLevelCount = (mipmapped == Mipmapped::kYes) ?
421 SkMipmap::ComputeLevelCount(bitmap.width(), bitmap.height()) + 1 : 1;
422
423
424 // setup MipLevels
425 sk_sp<SkMipmap> mipmaps;
426 std::vector<MipLevel> texels;
427 if (mipLevelCount == 1) {
428 texels.resize(mipLevelCount);
429 texels[0].fPixels = bmpToUpload.getPixels();
430 texels[0].fRowBytes = bmpToUpload.rowBytes();
431 } else {
432 mipmaps = SkToBool(mipmapsIn)
433 ? mipmapsIn
434 : sk_sp<SkMipmap>(SkMipmap::Build(bmpToUpload.pixmap(), nullptr));
435 if (!mipmaps) {
436 return {};
437 }
438
439 SkASSERT(mipLevelCount == mipmaps->countLevels() + 1);
440 texels.resize(mipLevelCount);
441
442 texels[0].fPixels = bmpToUpload.getPixels();
443 texels[0].fRowBytes = bmpToUpload.rowBytes();
444
445 for (int i = 1; i < mipLevelCount; ++i) {
446 SkMipmap::Level generatedMipLevel;
447 mipmaps->getLevel(i - 1, &generatedMipLevel);
448 texels[i].fPixels = generatedMipLevel.fPixmap.addr();
449 texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
450 SkASSERT(texels[i].fPixels);
451 SkASSERT(generatedMipLevel.fPixmap.colorType() == bmpToUpload.colorType());
452 }
453 }
454
455 // Create proxy
457 recorder->priv().resourceProvider(),
458 bmpToUpload.dimensions(),
459 textureInfo,
460 std::move(label),
461 budgeted);
462 if (!proxy) {
463 return {};
464 }
465 SkASSERT(caps->areColorTypeAndTextureInfoCompatible(ct, proxy->textureInfo()));
466 SkASSERT(mipmapped == Mipmapped::kNo || proxy->mipmapped() == Mipmapped::kYes);
467
468 // Src and dst colorInfo are the same
469 const SkColorInfo& colorInfo = bmpToUpload.info().colorInfo();
470 // Add UploadTask to Recorder
471 UploadInstance upload = UploadInstance::Make(
472 recorder, proxy, colorInfo, colorInfo, texels,
473 SkIRect::MakeSize(bmpToUpload.dimensions()), std::make_unique<ImageUploadContext>());
474 if (!upload.isValid()) {
475 SKGPU_LOG_E("MakeBitmapProxyView: Could not create UploadInstance");
476 return {};
477 }
478 recorder->priv().add(UploadTask::Make(std::move(upload)));
479
480 Swizzle swizzle = caps->getReadSwizzle(ct, textureInfo);
481 // If the color type is alpha-only, propagate the alpha value to the other channels.
482 if (SkColorTypeIsAlphaOnly(colorInfo.colorType())) {
483 swizzle = Swizzle::Concat(swizzle, Swizzle("aaaa"));
484 }
485 return {{std::move(proxy), swizzle}, ct};
486}
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
static bool SkImageInfoIsValid(const SkImageInfo &info)
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
void setImmutable()
Definition: SkBitmap.cpp:400
SkISize dimensions() const
Definition: SkBitmap.h:388
const SkPixmap & pixmap() const
Definition: SkBitmap.h:133
size_t rowBytes() const
Definition: SkBitmap.h:238
SkColorType colorType() const
Definition: SkBitmap.h:160
void * getPixels() const
Definition: SkBitmap.h:283
const SkImageInfo & info() const
Definition: SkBitmap.h:139
bool tryAllocPixels(const SkImageInfo &info, size_t rowBytes)
Definition: SkBitmap.cpp:271
static SkMipmap * Build(const SkPixmap &src, SkDiscardableFactoryProc, bool computeContents=true)
Definition: SkMipmap.cpp:45
int countLevels() const
Definition: SkMipmap.cpp:276
bool getLevel(int index, Level *) const
Definition: SkMipmap.cpp:280
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition: SkMipmap.cpp:134
size_t rowBytes() const
Definition: SkPixmap.h:145
SkColorType colorType() const
Definition: SkPixmap.h:173
const void * addr() const
Definition: SkPixmap.h:153
bool areColorTypeAndTextureInfoCompatible(SkColorType, const TextureInfo &) const
Definition: Caps.cpp:85
Protected isProtected() const
Definition: RecorderPriv.h:52
ResourceProvider * resourceProvider()
Definition: RecorderPriv.h:33
static const char * Concat(const char *a, const char *b)
Definition: file_test.cc:86
Definition: upload.py:1
SkPixmap fPixmap
Definition: SkMipmap.h:71

◆ MakeFromBitmap()

sk_sp< SkImage > skgpu::graphite::MakeFromBitmap ( Recorder recorder,
const SkColorInfo colorInfo,
const SkBitmap bitmap,
sk_sp< SkMipmap mipmaps,
Budgeted  budgeted,
SkImage::RequiredProperties  requiredProps,
std::string_view  label 
)

Definition at line 513 of file TextureUtils.cpp.

519 {
520 auto mm = requiredProps.fMipmapped ? Mipmapped::kYes : Mipmapped::kNo;
521 auto [view, ct] = MakeBitmapProxyView(recorder,
522 bitmap,
523 std::move(mipmaps),
524 mm,
525 budgeted,
526 std::move(label));
527 if (!view) {
528 return nullptr;
529 }
530
531 SkASSERT(!requiredProps.fMipmapped || view.proxy()->mipmapped() == Mipmapped::kYes);
532 return sk_make_sp<skgpu::graphite::Image>(std::move(view), colorInfo.makeColorType(ct));
533}
std::tuple< TextureProxyView, SkColorType > MakeBitmapProxyView(Recorder *recorder, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmapsIn, Mipmapped mipmapped, Budgeted budgeted, std::string_view label)

◆ MakePrecompileBlender()

sk_sp< PrecompileBlender > skgpu::graphite::MakePrecompileBlender ( sk_sp< SkRuntimeEffect effect,
SkSpan< const PrecompileChildOptions childOptions 
)

Definition at line 661 of file FactoryFunctions.cpp.

663 {
664 // TODO: check that 'effect' has the kAllowBlender_Flag bit set and:
665 // for each entry in childOptions:
666 // all the SkPrecompileChildPtrs have the same type as the corresponding child in the effect
667 return sk_make_sp<PrecompileRTEffect<PrecompileBlender>>(std::move(effect), childOptions);
668}

◆ MakePrecompileColorFilter()

sk_sp< PrecompileColorFilter > skgpu::graphite::MakePrecompileColorFilter ( sk_sp< SkRuntimeEffect effect,
SkSpan< const PrecompileChildOptions childOptions 
)

Definition at line 652 of file FactoryFunctions.cpp.

654 {
655 // TODO: check that 'effect' has the kAllowColorFilter_Flag bit set and:
656 // for each entry in childOptions:
657 // all the SkPrecompileChildPtrs have the same type as the corresponding child in the effect
658 return sk_make_sp<PrecompileRTEffect<PrecompileColorFilter>>(std::move(effect), childOptions);
659}

◆ MakePrecompileShader()

sk_sp< PrecompileShader > skgpu::graphite::MakePrecompileShader ( sk_sp< SkRuntimeEffect effect,
SkSpan< const PrecompileChildOptions childOptions 
)

Definition at line 643 of file FactoryFunctions.cpp.

645 {
646 // TODO: check that 'effect' has the kAllowShader_Flag bit set and:
647 // for each entry in childOptions:
648 // all the SkPrecompileChildPtrs have the same type as the corresponding child in the effect
649 return sk_make_sp<PrecompileRTEffect<PrecompileShader>>(std::move(effect), childOptions);
650}

◆ MakePromiseImageLazyProxy() [1/2]

sk_sp< TextureProxy > skgpu::graphite::MakePromiseImageLazyProxy ( const Caps ,
SkISize  dimensions,
TextureInfo  ,
Volatile  ,
sk_sp< skgpu::RefCntedCallback releaseHelper,
SkImages::GraphitePromiseTextureFulfillProc  ,
SkImages::GraphitePromiseTextureFulfillContext  ,
SkImages::GraphitePromiseTextureReleaseProc  ,
std::string_view  label 
)

◆ MakePromiseImageLazyProxy() [2/2]

sk_sp< TextureProxy > skgpu::graphite::MakePromiseImageLazyProxy ( const Caps caps,
SkISize  dimensions,
TextureInfo  textureInfo,
Volatile  isVolatile,
sk_sp< RefCntedCallback releaseHelper,
GraphitePromiseTextureFulfillProc  fulfillProc,
GraphitePromiseTextureFulfillContext  fulfillContext,
GraphitePromiseTextureReleaseProc  textureReleaseProc,
std::string_view  label 
)

Definition at line 488 of file TextureUtils.cpp.

497 {
498 SkASSERT(!dimensions.isEmpty());
499 SkASSERT(releaseHelper);
500
501 if (!fulfillProc) {
502 return nullptr;
503 }
504
505 PromiseLazyInstantiateCallback callback{std::move(releaseHelper), fulfillProc,
506 fulfillContext, textureReleaseProc, std::move(label)};
507 // Proxies for promise images are assumed to always be destined for a client's SkImage so
508 // are never considered budgeted.
509 return TextureProxy::MakeLazy(caps, dimensions, textureInfo, Budgeted::kNo, isVolatile,
510 std::move(callback));
511}
bool isEmpty() const
Definition: SkSize.h:31

◆ map_color()

static SkPMColor4f skgpu::graphite::map_color ( const SkColor4f c,
SkColorSpace src,
SkColorSpace dst 
)
static

Definition at line 1302 of file KeyHelpers.cpp.

1302 {
1303 SkPMColor4f color = {c.fR, c.fG, c.fB, c.fA};
1305 return color;
1306}
void apply(float rgba[4]) const

◆ MtlCompileShaderLibrary()

sk_cfp< id< MTLLibrary > > skgpu::graphite::MtlCompileShaderLibrary ( const MtlSharedContext sharedContext,
std::string_view  label,
std::string_view  msl,
ShaderErrorHandler errorHandler 
)

Definition at line 44 of file MtlGraphiteUtils.mm.

47 {
48 TRACE_EVENT0("skia.shaders", "driver_compile_shader");
49 NSString* nsSource = [[NSString alloc] initWithBytesNoCopy:const_cast<char*>(msl.data())
50 length:msl.size()
51 encoding:NSUTF8StringEncoding
52 freeWhenDone:NO];
53 if (!nsSource) {
54 return nil;
55 }
56 MTLCompileOptions* options = [[MTLCompileOptions alloc] init];
57
58 // Framebuffer fetch is supported in MSL 2.3 in MacOS 11+.
59 if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
60 options.languageVersion = MTLLanguageVersion2_3;
61
62 // array<> is supported in MSL 2.0 on MacOS 10.13+ and iOS 11+,
63 // and in MSL 1.2 on iOS 10+ (but not MacOS).
64 } else if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
65 options.languageVersion = MTLLanguageVersion2_0;
66#if defined(SK_BUILD_FOR_IOS)
67 } else if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
68 options.languageVersion = MTLLanguageVersion1_2;
69#endif
70 }
71
72 NSError* error = nil;
73 // TODO: do we need a version with a timeout?
74 sk_cfp<id<MTLLibrary>> compiledLibrary(
75 [sharedContext->device() newLibraryWithSource:(NSString* _Nonnull)nsSource
77 error:&error]);
78 if (!compiledLibrary) {
79 std::string mslStr(msl);
80 errorHandler->compileError(
81 mslStr.c_str(), error.debugDescription.UTF8String, /*shaderWasCached=*/false);
82 return nil;
83 }
84
85 NSString* nsLabel = [[NSString alloc] initWithBytesNoCopy:const_cast<char*>(label.data())
86 length:label.size()
87 encoding:NSUTF8StringEncoding
88 freeWhenDone:NO];
89 compiledLibrary.get().label = nsLabel;
90 return compiledLibrary;
91}
const char * options
virtual void compileError(const char *shader, const char *errors)
id< MTLDevice > device() const
size_t length
static bool init()

◆ MtlFormatBytesPerBlock()

size_t skgpu::graphite::MtlFormatBytesPerBlock ( MtlPixelFormat  format)

Definition at line 93 of file MtlGraphiteUtils.mm.

93 {
94 return skgpu::MtlFormatBytesPerBlock((MTLPixelFormat) format);
95}
size_t MtlFormatBytesPerBlock(MTLPixelFormat mtlFormat)
Definition: MtlUtils.mm:130

◆ MtlFormatToCompressionType()

SkTextureCompressionType skgpu::graphite::MtlFormatToCompressionType ( MtlPixelFormat  format)

Definition at line 97 of file MtlGraphiteUtils.mm.

97 {
98 return skgpu::MtlFormatToCompressionType((MTLPixelFormat) format);
99}
SkTextureCompressionType MtlFormatToCompressionType(MTLPixelFormat mtlFormat)
Definition: MtlUtils.mm:159

◆ MtlTextureSpecToTextureInfo()

MtlTextureInfo skgpu::graphite::MtlTextureSpecToTextureInfo ( const MtlTextureSpec mtlSpec,
uint32_t  sampleCount,
Mipmapped  mipmapped 
)

Definition at line 27 of file MtlGraphiteTypes.mm.

29 {
31 // Shared info
32 info.fSampleCount = sampleCount;
33 info.fMipmapped = mipmapped;
34
35 // Mtl info
36 info.fFormat = mtlSpec.fFormat;
37 info.fUsage = mtlSpec.fUsage;
38 info.fStorageMode = mtlSpec.fStorageMode;
39 info.fFramebufferOnly = mtlSpec.fFramebufferOnly;
40
41 return info;
42}

◆ next_id() [1/3]

static uint32_t skgpu::graphite::next_id ( )
static

Definition at line 70 of file DrawAtlas.cpp.

70 {
71 static std::atomic<uint32_t> nextID{1};
72 uint32_t id;
73 do {
74 id = nextID.fetch_add(1, std::memory_order_relaxed);
75 } while (id == SK_InvalidGenID);
76 return id;
77}
static constexpr uint32_t SK_InvalidGenID
Definition: SkTypes.h:192

◆ next_id() [2/3]

static uint32_t skgpu::graphite::next_id ( )
static

Definition at line 88 of file Recorder.cpp.

88 {
89 static std::atomic<uint32_t> nextID{1};
90 uint32_t id;
91 do {
92 id = nextID.fetch_add(1, std::memory_order_relaxed);
93 } while (id == SK_InvalidGenID);
94 return id;
95}

◆ next_id() [3/3]

static uint32_t skgpu::graphite::next_id ( )
static

Definition at line 12 of file Renderer.cpp.

12 {
13 static std::atomic<uint32_t> nextID{0};
14 // Not worried about overflow since each Context won't have that many RenderSteps, so even if
15 // it wraps back to 0, that RenderStep will not be in the same Context as the original 0.
16 return nextID.fetch_add(1, std::memory_order_relaxed);
17}

◆ notify_in_use() [1/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkColor4Shader  
)
static

Definition at line 1566 of file KeyHelpers.cpp.

1566 {
1567 // No-op
1568}

◆ notify_in_use() [2/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkColorShader  
)
static

Definition at line 1551 of file KeyHelpers.cpp.

1551 {
1552 // No-op
1553}

◆ notify_in_use() [3/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkEmptyShader  
)
static

Definition at line 1616 of file KeyHelpers.cpp.

1616 {
1617 // No-op
1618}

◆ notify_in_use() [4/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkGradientBaseShader  
)
static

Definition at line 2425 of file KeyHelpers.cpp.

2425 {
2426 // Gradients do not have children, so no images to notify
2427}

◆ notify_in_use() [5/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkPerlinNoiseShader  
)
static

Definition at line 2005 of file KeyHelpers.cpp.

2005 {
2006 // No-op, perlin noise has no children.
2007}

◆ notify_in_use() [6/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkPictureShader  
)
static

Definition at line 2083 of file KeyHelpers.cpp.

2083 {
2084 // While the SkPicture the shader points to, may have Graphite-backed shaders that need to be
2085 // notified, that will happen when the picture is rendered into an image in add_to_key
2086}

◆ notify_in_use() [7/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkTransformShader  
)
static

Definition at line 2121 of file KeyHelpers.cpp.

2121 {
2122 // no-op
2123}

◆ notify_in_use() [8/16]

static void skgpu::graphite::notify_in_use ( Recorder ,
DrawContext ,
const SkTriColorShader  
)
static

Definition at line 2132 of file KeyHelpers.cpp.

2132 {
2133 // no-op
2134}

◆ notify_in_use() [9/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkBlendShader shader 
)
static

Definition at line 1514 of file KeyHelpers.cpp.

1516 {
1517 // SkBlendShader uses a fixed blend mode, so there's no blender to recurse through
1518 NotifyImagesInUse(recorder, drawContext, shader->src().get());
1519 NotifyImagesInUse(recorder, drawContext, shader->dst().get());
1520}
void NotifyImagesInUse(Recorder *recorder, DrawContext *drawContext, const SkShader *shader)

◆ notify_in_use() [10/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkColorFilterShader shader 
)
static

Definition at line 1584 of file KeyHelpers.cpp.

1586 {
1587 NotifyImagesInUse(recorder, drawContext, shader->shader().get());
1588 NotifyImagesInUse(recorder, drawContext, shader->filter().get());
1589}

◆ notify_in_use() [11/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkCoordClampShader shader 
)
static

Definition at line 1604 of file KeyHelpers.cpp.

1606 {
1607 NotifyImagesInUse(recorder, drawContext, shader->shader().get());
1608}

◆ notify_in_use() [12/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkCTMShader shader 
)
static

Definition at line 1538 of file KeyHelpers.cpp.

1538 {
1539 NotifyImagesInUse(recorder, drawContext, shader->proxyShader().get());
1540}

◆ notify_in_use() [13/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkImageShader shader 
)
static

Definition at line 1876 of file KeyHelpers.cpp.

1878 {
1879 auto image = as_IB(shader->image());
1880 if (!image->isGraphiteBacked()) {
1881 // If it's not graphite-backed, there's no pending graphite work.
1882 return;
1883 }
1884
1885 static_cast<Image_Base*>(image)->notifyInUse(recorder, drawContext);
1886}

◆ notify_in_use() [14/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkLocalMatrixShader shader 
)
static

Definition at line 1957 of file KeyHelpers.cpp.

1959 {
1960 NotifyImagesInUse(recorder, drawContext, shader->wrappedShader().get());
1961}

◆ notify_in_use() [15/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkRuntimeShader shader 
)
static

Definition at line 2108 of file KeyHelpers.cpp.

2110 {
2111 notify_in_use(recorder, drawContext, shader->children());
2112}
static void notify_in_use(Recorder *, DrawContext *, const SkGradientBaseShader *)

◆ notify_in_use() [16/16]

static void skgpu::graphite::notify_in_use ( Recorder recorder,
DrawContext drawContext,
const SkWorkingColorSpaceShader shader 
)
static

Definition at line 2164 of file KeyHelpers.cpp.

2166 {
2167 NotifyImagesInUse(recorder, drawContext, shader->shader().get());
2168}

◆ NotifyImagesInUse() [1/3]

void skgpu::graphite::NotifyImagesInUse ( Recorder recorder,
DrawContext drawContext,
const SkBlender blender 
)

Definition at line 1290 of file KeyHelpers.cpp.

1290 {
1291 if (!blender) {
1292 return;
1293 }
1294 if (as_BB(blender)->type() == SkBlenderBase::BlenderType::kRuntime) {
1295 const auto* rbb = static_cast<const SkRuntimeBlender*>(blender);
1296 notify_in_use(recorder, drawContext, rbb->children());
1297 } // else blend mode doesn't reference images
1298}

◆ NotifyImagesInUse() [2/3]

void skgpu::graphite::NotifyImagesInUse ( Recorder recorder,
DrawContext drawContext,
const SkColorFilter filter 
)

Definition at line 1475 of file KeyHelpers.cpp.

1475 {
1476 if (!filter) {
1477 return;
1478 }
1479 if (as_CFB(filter)->type() == SkColorFilterBase::Type::kCompose) {
1480 // Recurse to two children
1481 const auto* cf = static_cast<const SkComposeColorFilter*>(filter);
1482 NotifyImagesInUse(recorder, drawContext, cf->inner().get());
1483 NotifyImagesInUse(recorder, drawContext, cf->outer().get());
1484 } else if (as_CFB(filter)->type() == SkColorFilterBase::Type::kWorkingFormat) {
1485 // Recurse to one child
1486 const auto* wfcf = static_cast<const SkWorkingFormatColorFilter*>(filter);
1487 NotifyImagesInUse(recorder, drawContext, wfcf->child().get());
1488 } else if (as_CFB(filter)->type() == SkColorFilterBase::Type::kRuntime) {
1489 // Recurse to all children
1490 const auto* rcf = static_cast<const SkRuntimeColorFilter*>(filter);
1491 notify_in_use(recorder, drawContext, rcf->children());
1492 } // else other color filters do not rely on SkImages
1493}

◆ NotifyImagesInUse() [3/3]

void skgpu::graphite::NotifyImagesInUse ( Recorder recorder,
DrawContext drawContext,
const SkShader shader 
)

Definition at line 2450 of file KeyHelpers.cpp.

2452 {
2453 if (!shader) {
2454 return;
2455 }
2456 switch (as_SB(shader)->type()) {
2457#define M(type) \
2458 case SkShaderBase::ShaderType::k##type: \
2459 notify_in_use(recorder, \
2460 drawContext, \
2461 static_cast<const Sk##type##Shader*>(shader)); \
2462 return;
2464#undef M
2465 }
2467}

◆ opposite_insets_intersect() [1/3]

static bool skgpu::graphite::opposite_insets_intersect ( const Geometry geometry,
float  strokeRadius,
float  aaRadius 
)
static

Definition at line 171 of file AnalyticRRectRenderStep.cpp.

173 {
174 if (geometry.isEdgeAAQuad()) {
175 SkASSERT(strokeRadius == 0.f);
176 const EdgeAAQuad& quad = geometry.edgeAAQuad();
177 if (quad.edgeFlags() == AAFlags::kNone) {
178 // If all edges are non-AA, there won't be any insetting. This allows completely non-AA
179 // quads to use the fill triangles for simpler fragment shader work.
180 return false;
181 } else if (quad.isRect() && quad.edgeFlags() == AAFlags::kAll) {
182 return opposite_insets_intersect(quad.bounds(), 0.f, aaRadius);
183 } else {
184 // Quads with mixed AA edges are tiles where non-AA edges must seam perfectly together.
185 // If we were to inset along just the axis with AA at a corner, two adjacent quads could
186 // arrive at slightly different inset coordinates and then we wouldn't have a perfect
187 // mesh. Forcing insets to snap to the center means all non-AA edges are formed solely
188 // by the original quad coordinates and should seam perfectly assuming perfect input.
189 // The only downside to this is the fill triangles cannot be used since they would
190 // partially extend into the coverage ramp from adjacent AA edges.
191 return true;
192 }
193 } else {
194 const Shape& shape = geometry.shape();
195 if (shape.isLine()) {
196 return strokeRadius <= aaRadius;
197 } else if (shape.isRect()) {
198 return opposite_insets_intersect(shape.rect(), strokeRadius, aaRadius);
199 } else {
200 SkASSERT(shape.isRRect());
201 return opposite_insets_intersect(shape.rrect(), strokeRadius, aaRadius);
202 }
203 }
204}
SkEnumBitMask< Flags > edgeFlags() const
Definition: EdgeAAQuad.h:74
const EdgeAAQuad & edgeAAQuad() const
Definition: Geometry.h:108
const Shape & shape() const
Definition: Geometry.h:106
static bool opposite_insets_intersect(const Geometry &geometry, float strokeRadius, float aaRadius)

◆ opposite_insets_intersect() [2/3]

static bool skgpu::graphite::opposite_insets_intersect ( const Rect rect,
float  strokeRadius,
float  aaRadius 
)
static

Definition at line 167 of file AnalyticRRectRenderStep.cpp.

167 {
168 return any(rect.size() <= 2.f * (strokeRadius + aaRadius));
169}
SIT bool any(const Vec< 1, T > &x)
Definition: SkVx.h:530

◆ opposite_insets_intersect() [3/3]

static bool skgpu::graphite::opposite_insets_intersect ( const SkRRect rrect,
float  strokeRadius,
float  aaRadius 
)
static

Definition at line 152 of file AnalyticRRectRenderStep.cpp.

152 {
153 // One AA inset per side
154 const float maxInset = strokeRadius + 2.f * aaRadius;
155 return // Horizontal insets would intersect opposite corner's curve
160 // Vertical insets would intersect opposite corner's curve
165}
SkScalar width() const
Definition: SkRRect.h:95
SkScalar height() const
Definition: SkRRect.h:102

◆ PipelineStageFlagsToVkShaderStageFlags()

VkShaderStageFlags skgpu::graphite::PipelineStageFlagsToVkShaderStageFlags ( SkEnumBitMask< PipelineStageFlags stageFlags)

Definition at line 163 of file VulkanGraphiteUtils.cpp.

164 {
165 VkShaderStageFlags vkStageFlags = 0;
166 if (stageFlags & PipelineStageFlags::kVertexShader) {
167 vkStageFlags |= VK_SHADER_STAGE_VERTEX_BIT;
168 }
169 if (stageFlags & PipelineStageFlags::kFragmentShader) {
170 vkStageFlags |= VK_SHADER_STAGE_FRAGMENT_BIT;
171 }
172 if (stageFlags & PipelineStageFlags::kCompute) {
173 vkStageFlags |= VK_SHADER_STAGE_COMPUTE_BIT;
174 }
175 return vkStageFlags;
176}
@ VK_SHADER_STAGE_VERTEX_BIT
Definition: vulkan_core.h:2665
@ VK_SHADER_STAGE_COMPUTE_BIT
Definition: vulkan_core.h:2670
@ VK_SHADER_STAGE_FRAGMENT_BIT
Definition: vulkan_core.h:2669
VkFlags VkShaderStageFlags
Definition: vulkan_core.h:2731

◆ Precompile() [1/2]

void skgpu::graphite::Precompile ( Context context,
const PaintOptions paintOptions,
DrawTypeFlags  drawTypes = kMostCommon 
)

Precompilation allows clients to create pipelines ahead of time based on what they expect to draw. This can reduce performance hitches, due to inline compilation, during the actual drawing. Graphite will always be able to perform an inline compilation if some SkPaint combination was omitted from precompilation.

Parameters
contextthe Context to which the actual draws will be submitted
paintOptionscaptures a set of SkPaints that will be drawn
drawTypescommunicates which primitives those paints will be drawn with

Definition at line 102 of file PublicPrecompile.cpp.

102 {
103
105 const Caps* caps = context->priv().caps();
106
107 auto rtEffectDict = std::make_unique<RuntimeEffectDictionary>();
108
110 KeyContext keyContext(
111 caps, dict, rtEffectDict.get(), ci, /* dstTexture= */ nullptr, /* dstOffset= */ {0, 0});
112
113 for (Coverage coverage : { Coverage::kNone, Coverage::kSingleChannel, Coverage::kLCD }) {
115 context, options, keyContext,
116 static_cast<DrawTypeFlags>(drawTypes & ~DrawTypeFlags::kDrawVertices),
117 /* withPrimitiveBlender= */ false,
118 coverage);
119 }
120
121 if (drawTypes & DrawTypeFlags::kDrawVertices) {
122 for (Coverage coverage: { Coverage::kNone, Coverage::kSingleChannel, Coverage::kLCD }) {
123 // drawVertices w/ colors use a primitiveBlender while those w/o don't
124 for (bool withPrimitiveBlender : { true, false }) {
125 PrecompileCombinations(context, options, keyContext,
127 withPrimitiveBlender,
128 coverage);
129 }
130 }
131 }
132}
const Caps * caps() const
Definition: ContextPriv.h:32
const ShaderCodeDictionary * shaderCodeDictionary() const
Definition: ContextPriv.h:34
void PrecompileCombinations(Context *context, const PaintOptions &options, const KeyContext &keyContext, DrawTypeFlags drawTypes, bool withPrimitiveBlender, Coverage coverage)

◆ Precompile() [2/2]

bool skgpu::graphite::Precompile ( Context context,
RuntimeEffectDictionary rteDict,
const GraphicsPipelineDesc pipelineDesc,
const RenderPassDesc renderPassDesc 
)

Definition at line 84 of file PublicPrecompile.cpp.

87 {
88 ResourceProvider* resourceProvider = context->priv().resourceProvider();
89
90 sk_sp<GraphicsPipeline> pipeline = resourceProvider->findOrCreateGraphicsPipeline(
91 rteDict,
92 pipelineDesc,
93 renderPassDesc);
94 if (!pipeline) {
95 SKGPU_LOG_W("Failed to create GraphicsPipeline in precompile!");
96 return false;
97 }
98
99 return true;
100}
ResourceProvider * resourceProvider() const
Definition: ContextPriv.h:49
sk_sp< GraphicsPipeline > findOrCreateGraphicsPipeline(const RuntimeEffectDictionary *, const GraphicsPipelineDesc &, const RenderPassDesc &)

◆ PrecompileCombinations()

void skgpu::graphite::PrecompileCombinations ( Context context,
const PaintOptions options,
const KeyContext keyContext,
DrawTypeFlags  drawTypes,
bool  withPrimitiveBlender,
Coverage  coverage 
)

Definition at line 134 of file PublicPrecompile.cpp.

139 {
140 const Caps* caps = keyContext.caps();
141 // Since the precompilation path's uniforms aren't used and don't change the key,
142 // the exact layout doesn't matter
144
145 SkColorType destCT = keyContext.dstColorInfo().colorType();
146 // TODO: we need iterate over a broader set of TextureInfos here. Perhaps, allow the client
147 // to pass in colorType, mipmapping and protection.
152
153 Swizzle writeSwizzle = caps->getWriteSwizzle(destCT, info);
154 // Note: at least on Metal, the LoadOp, StoreOp and clearColor fields don't influence the
155 // actual RenderPassDescKey.
156 // TODO: if all of the Renderers associated w/ the requested drawTypes require MSAA we
157 // do not need to generate the combinations w/ the non-MSAA RenderPassDescs.
158 const RenderPassDesc renderPassDescs[] = {
160 info,
161 LoadOp::kClear,
162 StoreOp::kStore,
163 DepthStencilFlags::kDepth,
164 /* clearColor= */ { .0f, .0f, .0f, .0f },
165 /* requiresMSAA= */ true,
166 writeSwizzle),
168 info,
169 LoadOp::kClear,
170 StoreOp::kStore,
171 DepthStencilFlags::kDepthStencil,
172 /* clearColor= */ { .0f, .0f, .0f, .0f },
173 /* requiresMSAA= */ true,
174 writeSwizzle),
176 info,
177 LoadOp::kClear,
178 StoreOp::kStore,
179 DepthStencilFlags::kDepth,
180 /* clearColor= */ { .0f, .0f, .0f, .0f },
181 /* requiresMSAA= */ false,
182 writeSwizzle),
184 info,
185 LoadOp::kClear,
186 StoreOp::kStore,
187 DepthStencilFlags::kDepthStencil,
188 /* clearColor= */ { .0f, .0f, .0f, .0f },
189 /* requiresMSAA= */ false,
190 writeSwizzle),
191 };
192
193 options.priv().buildCombinations(
194 keyContext,
195 &gatherer,
196 drawTypes,
197 withPrimitiveBlender,
198 coverage,
199 [context, &keyContext, &renderPassDescs](UniquePaintParamsID uniqueID,
200 DrawTypeFlags drawTypes,
201 bool withPrimitiveBlender,
203 compile(context->priv().rendererProvider(),
204 context->priv().resourceProvider(),
205 keyContext,
206 uniqueID,
207 drawTypes,
208 renderPassDescs,
209 withPrimitiveBlender,
210 coverage);
211 });
212}
skgpu::Swizzle getWriteSwizzle(SkColorType, const TextureInfo &) const
Definition: Caps.cpp:142
const RendererProvider * rendererProvider() const
Definition: ContextPriv.h:46

◆ primitive_type_to_vk_topology()

static VkPrimitiveTopology skgpu::graphite::primitive_type_to_vk_topology ( PrimitiveType  primitiveType)
static

Definition at line 149 of file VulkanGraphicsPipeline.cpp.

149 {
150 switch (primitiveType) {
151 case PrimitiveType::kTriangles:
153 case PrimitiveType::kTriangleStrip:
157 }
159}
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
Definition: vulkan_core.h:2037
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
Definition: vulkan_core.h:2038
@ VK_PRIMITIVE_TOPOLOGY_POINT_LIST
Definition: vulkan_core.h:2034

◆ quad_center()

static skvx::float2 skgpu::graphite::quad_center ( const EdgeAAQuad quad)
static

Definition at line 229 of file AnalyticRRectRenderStep.cpp.

229 {
230 // The center of the bounding box is *not* a good center to use. Take the average of the
231 // four points instead (which is slightly biased if they form a triangle, but still okay).
232 return skvx::float2(dot(quad.xs(), skvx::float4(0.25f)),
233 dot(quad.ys(), skvx::float4(0.25f)));
234}
SINT T dot(const Vec< N, T > &a, const Vec< N, T > &b)
Definition: SkVx.h:964

◆ quantize()

static float skgpu::graphite::quantize ( float  deviceSpaceFloat)
static

Definition at line 180 of file AnalyticBlurMask.cpp.

180 {
181 // Snap the device-space value to the nearest 1/32 to increase cache hits w/o impacting the
182 // visible output since it should be hard to see a change limited to 1/32 of a pixel.
183 return SkScalarRoundToInt(deviceSpaceFloat * 32.f) / 32.f;
184}
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37

◆ RescaleImage()

sk_sp< SkImage > skgpu::graphite::RescaleImage ( Recorder recorder,
const SkImage srcImage,
SkIRect  srcIRect,
const SkImageInfo dstInfo,
SkImage::RescaleGamma  rescaleGamma,
SkImage::RescaleMode  rescaleMode 
)

Definition at line 597 of file TextureUtils.cpp.

602 {
603 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
604 TRACE_EVENT_INSTANT2("skia.gpu", "RescaleImage Src", TRACE_EVENT_SCOPE_THREAD,
605 "width", srcIRect.width(), "height", srcIRect.height());
606 TRACE_EVENT_INSTANT2("skia.gpu", "RescaleImage Dst", TRACE_EVENT_SCOPE_THREAD,
607 "width", dstInfo.width(), "height", dstInfo.height());
608
609 // RescaleImage() should only be called when we already know that srcImage is graphite-backed
610 SkASSERT(srcImage && as_IB(srcImage)->isGraphiteBacked());
611
612 // For now this needs to be texturable because we can't depend on copies to scale.
613 // NOTE: srcView may be empty if srcImage is YUVA.
614 const TextureProxyView srcView = AsView(srcImage);
615 if (srcView && !recorder->priv().caps()->isTexturable(srcView.proxy()->textureInfo())) {
616 // With the current definition of SkImage, this shouldn't happen. If we allow non-texturable
617 // formats for compute, we'll need to copy to a texturable format.
618 SkASSERT(false);
619 return nullptr;
620 }
621
622 // make a Surface *exactly* matching dstInfo to rescale into
623 SkSurfaceProps surfaceProps = {};
624 sk_sp<SkSurface> dst = make_renderable_scratch_surface(recorder,
625 dstInfo,
627 "RescaleDstTexture",
628 &surfaceProps);
629 if (!dst) {
630 return nullptr;
631 }
632
633 SkRect srcRect = SkRect::Make(srcIRect);
634 SkRect dstRect = SkRect::Make(dstInfo.dimensions());
635
636 SkISize finalSize = SkISize::Make(dstRect.width(), dstRect.height());
637 if (finalSize == srcIRect.size()) {
638 rescaleGamma = Image::RescaleGamma::kSrc;
639 rescaleMode = Image::RescaleMode::kNearest;
640 }
641
642 // Within a rescaling pass tempInput is read from and tempOutput is written to.
643 // At the end of the pass tempOutput's texture is wrapped and assigned to tempInput.
644 sk_sp<SkImage> tempInput = sk_ref_sp(srcImage);
645 sk_sp<SkSurface> tempOutput;
646
647 // Assume we should ignore the rescale linear request if the surface has no color space since
648 // it's unclear how we'd linearize from an unknown color space.
649 const SkImageInfo& srcImageInfo = srcImage->imageInfo();
650 if (rescaleGamma == Image::RescaleGamma::kLinear &&
651 srcImageInfo.colorSpace() &&
652 !srcImageInfo.colorSpace()->gammaIsLinear()) {
653 // Draw the src image into a new surface with linear gamma, and make that the new tempInput
654 sk_sp<SkColorSpace> linearGamma = srcImageInfo.colorSpace()->makeLinearGamma();
655 SkImageInfo gammaDstInfo = SkImageInfo::Make(srcIRect.size(),
656 tempInput->imageInfo().colorType(),
658 std::move(linearGamma));
659 tempOutput = make_renderable_scratch_surface(recorder, gammaDstInfo, SkBackingFit::kApprox,
660 "RescaleLinearGammaTexture", &surfaceProps);
661 if (!tempOutput) {
662 return nullptr;
663 }
664 SkCanvas* gammaDst = tempOutput->getCanvas();
665 SkRect gammaDstRect = SkRect::Make(srcIRect.size());
666
668 paint.setBlendMode(SkBlendMode::kSrc);
669 gammaDst->drawImageRect(tempInput, srcRect, gammaDstRect,
672 tempInput = SkSurfaces::AsImage(std::move(tempOutput));
673 srcRect = gammaDstRect;
674 }
675
676 SkImageInfo outImageInfo = tempInput->imageInfo().makeAlphaType(kPremul_SkAlphaType);
677 do {
678 SkISize nextDims = finalSize;
679 if (rescaleMode != Image::RescaleMode::kNearest &&
680 rescaleMode != Image::RescaleMode::kLinear) {
681 if (srcRect.width() > finalSize.width()) {
682 nextDims.fWidth = std::max((srcRect.width() + 1)/2, (float)finalSize.width());
683 } else if (srcRect.width() < finalSize.width()) {
684 nextDims.fWidth = std::min(srcRect.width()*2, (float)finalSize.width());
685 }
686 if (srcRect.height() > finalSize.height()) {
687 nextDims.fHeight = std::max((srcRect.height() + 1)/2, (float)finalSize.height());
688 } else if (srcRect.height() < finalSize.height()) {
689 nextDims.fHeight = std::min(srcRect.height()*2, (float)finalSize.height());
690 }
691 }
692
693 SkRect stepDstRect;
694 if (nextDims == finalSize) {
695 tempOutput = dst;
696 stepDstRect = dstRect;
697 } else {
698 SkImageInfo nextInfo = outImageInfo.makeDimensions(nextDims);
699 tempOutput = make_renderable_scratch_surface(recorder, nextInfo, SkBackingFit::kApprox,
700 "RescaleImageTempTexture", &surfaceProps);
701 if (!tempOutput) {
702 return nullptr;
703 }
704 stepDstRect = SkRect::Make(tempOutput->imageInfo().dimensions());
705 }
706
707 SkSamplingOptions samplingOptions;
708 if (rescaleMode == Image::RescaleMode::kRepeatedCubic) {
710 } else {
711 samplingOptions = (rescaleMode == Image::RescaleMode::kNearest) ?
714 }
716 paint.setBlendMode(SkBlendMode::kSrc);
717 tempOutput->getCanvas()->drawImageRect(tempInput, srcRect, stepDstRect, samplingOptions,
719
720 tempInput = SkSurfaces::AsImage(std::move(tempOutput));
721 srcRect = SkRect::Make(nextDims);
722 } while (srcRect.width() != finalSize.width() || srcRect.height() != finalSize.height());
723
724 return SkSurfaces::AsImage(std::move(dst));
725}
#define TRACE_EVENT_SCOPE_THREAD
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
bool gammaIsLinear() const
sk_sp< SkColorSpace > makeLinearGamma() const
const SkImageInfo & imageInfo() const
Definition: SkImage.h:279
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
virtual SkImageInfo imageInfo() const
Definition: SkSurface.h:188
bool isTexturable(const TextureInfo &) const
Definition: Caps.cpp:66
const TextureInfo & textureInfo() const
Definition: TextureProxy.h:38
static float min(float r, float g, float b)
Definition: hsl.cpp:48
static constexpr skcms_TransferFunction kLinear
Definition: SkColorSpace.h:51
static constexpr SkCubicResampler CatmullRom()
constexpr int32_t height() const
Definition: SkRect.h:165
constexpr int32_t width() const
Definition: SkRect.h:158
int32_t fHeight
Definition: SkSize.h:18
int32_t fWidth
Definition: SkSize.h:17
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.h:466
SkImageInfo makeDimensions(SkISize newSize) const
Definition: SkImageInfo.h:454
SkColorSpace * colorSpace() const
int width() const
Definition: SkImageInfo.h:365
SkColorType colorType() const
Definition: SkImageInfo.h:373
int height() const
Definition: SkImageInfo.h:371
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
#define TRACE_EVENT_INSTANT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)
Definition: trace_event.h:184

◆ run_test()

void skgpu::graphite::run_test ( skiatest::Reporter reporter,
Context context,
SkISize  surfaceSize,
SkISize  recordingSize,
SkISize  replayOffset,
DrawCallback  draw,
const std::vector< Expectation > &  expectations 
)

Definition at line 30 of file RecordingSurfacesTest.cpp.

36 {
37 const SkImageInfo surfaceImageInfo = SkImageInfo::Make(
39
40 std::unique_ptr<Recorder> surfaceRecorder = context->makeRecorder();
41 sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(surfaceRecorder.get(), surfaceImageInfo);
42 Surface* graphiteSurface = static_cast<Surface*>(surface.get());
43 const TextureInfo& textureInfo = graphiteSurface->backingTextureProxy()->textureInfo();
44
45 // Flush the initial clear added by MakeGraphite.
46 std::unique_ptr<skgpu::graphite::Recording> surfaceRecording = surfaceRecorder->snap();
47 context->insertRecording({surfaceRecording.get()});
48
49 // Snap a recording without a bound target.
50 const SkImageInfo recordingImageInfo = surfaceImageInfo.makeDimensions(recordingSize);
51 std::unique_ptr<Recorder> recorder = context->makeRecorder();
52 SkCanvas* canvas = recorder->makeDeferredCanvas(recordingImageInfo, textureInfo);
53 draw(canvas);
54
55 // Can't make another canvas before snapping.
57 recorder->makeDeferredCanvas(recordingImageInfo, textureInfo) == nullptr);
58 std::unique_ptr<Recording> recording = recorder->snap();
59
60 // Play back recording.
61 context->insertRecording(
62 {recording.get(), surface.get(), {replayOffset.fWidth, replayOffset.fHeight}});
63
64 // Read pixels.
66 SkPixmap pixmap;
67 bitmap.allocPixels(surfaceImageInfo);
68 SkAssertResult(bitmap.peekPixels(&pixmap));
69 if (!surface->readPixels(pixmap, 0, 0)) {
70 ERRORF(reporter, "readPixels failed");
71 return;
72 }
73
74 // Veryify expectations are met and recording is uninstantiated.
75 REPORTER_ASSERT(reporter, !recording->priv().isTargetProxyInstantiated());
76 for (const Expectation& e : expectations) {
77 SkColor4f color = pixmap.getColor4f(e.fX, e.fY);
78#ifdef SK_DEBUG
79 if (color != e.fColor) {
80 SkDebugf("Wrong color\n\texpected: %f %f %f %f\n\tactual: %f %f %f %f",
81 e.fColor.fR,
82 e.fColor.fG,
83 e.fColor.fB,
84 e.fColor.fA,
85 color.fR,
86 color.fG,
87 color.fB,
88 color.fA);
89 }
90#endif
91 REPORTER_ASSERT(reporter, color == e.fColor);
92 }
93}
SkColor4f getColor4f(int x, int y) const
Definition: SkPixmap.cpp:388
std::unique_ptr< Recorder > makeRecorder(const RecorderOptions &={})
Definition: Context.cpp:132
bool insertRecording(const InsertRecordingInfo &)
Definition: Context.cpp:156
TextureProxy * backingTextureProxy() const

◆ setup_color_blend_state()

static void skgpu::graphite::setup_color_blend_state ( const skgpu::BlendInfo blendInfo,
VkPipelineColorBlendStateCreateInfo colorBlendInfo,
VkPipelineColorBlendAttachmentState attachmentState 
)
static

Definition at line 379 of file VulkanGraphicsPipeline.cpp.

381 {
382 skgpu::BlendEquation equation = blendInfo.fEquation;
383 skgpu::BlendCoeff srcCoeff = blendInfo.fSrcBlend;
384 skgpu::BlendCoeff dstCoeff = blendInfo.fDstBlend;
385 bool blendOff = skgpu::BlendShouldDisable(equation, srcCoeff, dstCoeff);
386
387 memset(attachmentState, 0, sizeof(VkPipelineColorBlendAttachmentState));
388 attachmentState->blendEnable = !blendOff;
389 if (!blendOff) {
390 attachmentState->srcColorBlendFactor = blend_coeff_to_vk_blend(srcCoeff);
391 attachmentState->dstColorBlendFactor = blend_coeff_to_vk_blend(dstCoeff);
392 attachmentState->colorBlendOp = blend_equation_to_vk_blend_op(equation);
393 attachmentState->srcAlphaBlendFactor = blend_coeff_to_vk_blend(srcCoeff);
394 attachmentState->dstAlphaBlendFactor = blend_coeff_to_vk_blend(dstCoeff);
395 attachmentState->alphaBlendOp = blend_equation_to_vk_blend_op(equation);
396 }
397
398 if (!blendInfo.fWritesColor) {
399 attachmentState->colorWriteMask = 0;
400 } else {
403 }
404
405 memset(colorBlendInfo, 0, sizeof(VkPipelineColorBlendStateCreateInfo));
407 colorBlendInfo->pNext = nullptr;
408 colorBlendInfo->flags = 0;
409 colorBlendInfo->logicOpEnable = VK_FALSE;
410 colorBlendInfo->attachmentCount = 1;
411 colorBlendInfo->pAttachments = attachmentState;
412 // colorBlendInfo->blendConstants is set dynamically
413}
static VkBlendFactor blend_coeff_to_vk_blend(skgpu::BlendCoeff coeff)
static VkBlendOp blend_equation_to_vk_blend_op(skgpu::BlendEquation equation)
static constexpr bool BlendShouldDisable(BlendEquation equation, BlendCoeff srcCoeff, BlendCoeff dstCoeff)
Definition: Blend.h:145
BlendEquation
Definition: Blend.h:26
BlendCoeff
Definition: Blend.h:60
VkColorComponentFlags colorWriteMask
Definition: vulkan_core.h:3644
VkPipelineColorBlendStateCreateFlags flags
Definition: vulkan_core.h:3650
const VkPipelineColorBlendAttachmentState * pAttachments
Definition: vulkan_core.h:3654
skgpu::BlendCoeff fDstBlend
Definition: Blend.h:96
bool fWritesColor
Definition: Blend.h:98
skgpu::BlendCoeff fSrcBlend
Definition: Blend.h:95
#define VK_FALSE
Definition: vulkan_core.h:125
@ VK_COLOR_COMPONENT_R_BIT
Definition: vulkan_core.h:2602
@ VK_COLOR_COMPONENT_A_BIT
Definition: vulkan_core.h:2605
@ VK_COLOR_COMPONENT_B_BIT
Definition: vulkan_core.h:2604
@ VK_COLOR_COMPONENT_G_BIT
Definition: vulkan_core.h:2603
@ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
Definition: vulkan_core.h:228

◆ setup_depth_stencil_state()

static void skgpu::graphite::setup_depth_stencil_state ( const DepthStencilSettings stencilSettings,
VkPipelineDepthStencilStateCreateInfo stencilInfo 
)
static

Definition at line 232 of file VulkanGraphicsPipeline.cpp.

233 {
234 SkASSERT(stencilSettings.fDepthTestEnabled ||
235 stencilSettings.fDepthCompareOp == CompareOp::kAlways);
236
237 memset(stencilInfo, 0, sizeof(VkPipelineDepthStencilStateCreateInfo));
239 stencilInfo->pNext = nullptr;
240 stencilInfo->flags = 0;
241 stencilInfo->depthTestEnable = stencilSettings.fDepthTestEnabled;
242 stencilInfo->depthWriteEnable = stencilSettings.fDepthWriteEnabled;
243 stencilInfo->depthCompareOp = compare_op_to_vk_compare_op(stencilSettings.fDepthCompareOp);
244 stencilInfo->depthBoundsTestEnable = VK_FALSE; // Default value TODO - Confirm
245 stencilInfo->stencilTestEnable = stencilSettings.fStencilTestEnabled;
246 if (stencilSettings.fStencilTestEnabled) {
247 setup_stencil_op_state(&stencilInfo->front,
248 stencilSettings.fFrontStencil,
249 stencilSettings.fStencilReferenceValue);
250 setup_stencil_op_state(&stencilInfo->back,
251 stencilSettings.fBackStencil,
252 stencilSettings.fStencilReferenceValue);
253 }
254 stencilInfo->minDepthBounds = 0.0f;
255 stencilInfo->maxDepthBounds = 1.0f;
256}
static void setup_stencil_op_state(VkStencilOpState *opState, const GrStencilSettings::Face &stencilFace)
static VkCompareOp compare_op_to_vk_compare_op(CompareOp op)
VkPipelineDepthStencilStateCreateFlags flags
Definition: vulkan_core.h:3624
@ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO
Definition: vulkan_core.h:227

◆ setup_dynamic_state()

static void skgpu::graphite::setup_dynamic_state ( VkPipelineDynamicStateCreateInfo dynamicInfo,
VkDynamicState dynamicStates 
)
static

Definition at line 579 of file VulkanGraphicsPipeline.cpp.

580 {
581 memset(dynamicInfo, 0, sizeof(VkPipelineDynamicStateCreateInfo));
583 dynamicInfo->pNext = VK_NULL_HANDLE;
584 dynamicInfo->flags = 0;
585 dynamicStates[0] = VK_DYNAMIC_STATE_VIEWPORT;
586 dynamicStates[1] = VK_DYNAMIC_STATE_SCISSOR;
587 dynamicStates[2] = VK_DYNAMIC_STATE_BLEND_CONSTANTS;
588 dynamicInfo->dynamicStateCount = 3;
589 dynamicInfo->pDynamicStates = dynamicStates;
590}
VkPipelineDynamicStateCreateFlags flags
Definition: vulkan_core.h:3661
const VkDynamicState * pDynamicStates
Definition: vulkan_core.h:3663
@ VK_DYNAMIC_STATE_BLEND_CONSTANTS
Definition: vulkan_core.h:1935
@ VK_DYNAMIC_STATE_VIEWPORT
Definition: vulkan_core.h:1931
@ VK_DYNAMIC_STATE_SCISSOR
Definition: vulkan_core.h:1932
@ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
Definition: vulkan_core.h:229

◆ setup_input_assembly_state()

static void skgpu::graphite::setup_input_assembly_state ( PrimitiveType  primitiveType,
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo 
)
static

Definition at line 161 of file VulkanGraphicsPipeline.cpp.

162 {
163 memset(inputAssemblyInfo, 0, sizeof(VkPipelineInputAssemblyStateCreateInfo));
165 inputAssemblyInfo->pNext = nullptr;
166 inputAssemblyInfo->flags = 0;
167 inputAssemblyInfo->primitiveRestartEnable = false;
168 inputAssemblyInfo->topology = primitive_type_to_vk_topology(primitiveType);
169}
static VkPrimitiveTopology primitive_type_to_vk_topology(PrimitiveType primitiveType)
VkPipelineInputAssemblyStateCreateFlags flags
Definition: vulkan_core.h:3552
@ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
Definition: vulkan_core.h:222

◆ setup_multisample_state()

static void skgpu::graphite::setup_multisample_state ( int  numSamples,
VkPipelineMultisampleStateCreateInfo multisampleInfo 
)
static

Definition at line 273 of file VulkanGraphicsPipeline.cpp.

274 {
275 memset(multisampleInfo, 0, sizeof(VkPipelineMultisampleStateCreateInfo));
277 multisampleInfo->pNext = nullptr;
278 multisampleInfo->flags = 0;
280 &multisampleInfo->rasterizationSamples));
281 multisampleInfo->sampleShadingEnable = VK_FALSE;
282 multisampleInfo->minSampleShading = 0.0f;
283 multisampleInfo->pSampleMask = nullptr;
284 multisampleInfo->alphaToCoverageEnable = VK_FALSE;
285 multisampleInfo->alphaToOneEnable = VK_FALSE;
286}
static constexpr bool SampleCountToVkSampleCount(uint32_t samples, VkSampleCountFlagBits *vkSamples)
VkPipelineMultisampleStateCreateFlags flags
Definition: vulkan_core.h:3602
VkSampleCountFlagBits rasterizationSamples
Definition: vulkan_core.h:3603
@ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
Definition: vulkan_core.h:226

◆ setup_pipeline_layout()

static VkPipelineLayout skgpu::graphite::setup_pipeline_layout ( const VulkanSharedContext sharedContext,
bool  usesIntrinsicConstantUbo,
bool  hasStepUniforms,
int  numPaintUniforms,
int  numTextureSamplers,
int  numInputAttachments 
)
static

Definition at line 472 of file VulkanGraphicsPipeline.cpp.

477 {
478 // Determine descriptor set layouts for this pipeline based upon render pass information.
480
481 // Determine uniform descriptor set layout
483 uniformDescriptors;
484 if (usesIntrinsicConstantUbo) {
485 uniformDescriptors.push_back(VulkanGraphicsPipeline::kIntrinsicUniformBufferDescriptor);
486 }
487 if (hasStepUniforms) {
488 uniformDescriptors.push_back(VulkanGraphicsPipeline::kRenderStepUniformDescriptor);
489 }
490 if (numPaintUniforms > 0) {
491 uniformDescriptors.push_back(VulkanGraphicsPipeline::kPaintUniformDescriptor);
492 }
493
494 if (!uniformDescriptors.empty()) {
495 VkDescriptorSetLayout uniformSetLayout =
496 descriptor_data_to_layout(sharedContext, {uniformDescriptors});
497 if (uniformSetLayout == VK_NULL_HANDLE) { return VK_NULL_HANDLE; }
498 setLayouts.push_back(uniformSetLayout);
499 }
500
501 // Determine input attachment descriptor set layout
502 if (numInputAttachments > 0) {
503 // For now, we only expect to have up to 1 input attachment. We also share that descriptor
504 // set number with uniform descriptors for normal graphics pipeline usages, so verify that
505 // we are not using any uniform descriptors to avoid conflicts.
506 SkASSERT(numInputAttachments == 1 && uniformDescriptors.empty());
507 skia_private::TArray<DescriptorData> inputAttachmentDescriptors(numInputAttachments);
508 inputAttachmentDescriptors.push_back(VulkanGraphicsPipeline::kInputAttachmentDescriptor);
509
510 VkDescriptorSetLayout inputAttachmentDescSetLayout =
511 descriptor_data_to_layout(sharedContext, {inputAttachmentDescriptors});
512
513 if (inputAttachmentDescSetLayout == VK_NULL_HANDLE) {
514 destroy_desc_set_layouts(sharedContext, setLayouts);
515 return VK_NULL_HANDLE;
516 }
517 setLayouts.push_back(inputAttachmentDescSetLayout);
518 }
519
520 // Determine texture/sampler descriptor set layout
521 if (numTextureSamplers > 0) {
522 skia_private::TArray<DescriptorData> textureSamplerDescs(numTextureSamplers);
523 for (int i = 0; i < numTextureSamplers; i++) {
524 textureSamplerDescs.push_back({DescriptorType::kCombinedTextureSampler,
525 /*count=*/1,
526 /*bindingIdx=*/i,
527 PipelineStageFlags::kFragmentShader});
528 }
529 VkDescriptorSetLayout textureSamplerDescSetLayout =
530 descriptor_data_to_layout(sharedContext, {textureSamplerDescs});
531
532 if (textureSamplerDescSetLayout == VK_NULL_HANDLE) {
533 destroy_desc_set_layouts(sharedContext, setLayouts);
534 return VK_NULL_HANDLE;
535 }
536 setLayouts.push_back(textureSamplerDescSetLayout);
537 }
538
539 // Generate a pipeline layout using the now-populated descriptor set layout array
540 VkPipelineLayoutCreateInfo layoutCreateInfo;
541 memset(&layoutCreateInfo, 0, sizeof(VkPipelineLayoutCreateFlags));
543 layoutCreateInfo.pNext = nullptr;
544 layoutCreateInfo.flags = 0;
545 layoutCreateInfo.setLayoutCount = setLayouts.size();
546 layoutCreateInfo.pSetLayouts = setLayouts.begin();
547 // TODO: Add support for push constants.
548 layoutCreateInfo.pushConstantRangeCount = 0;
549 layoutCreateInfo.pPushConstantRanges = nullptr;
550
552 VkPipelineLayout layout;
553 VULKAN_CALL_RESULT(sharedContext,
554 result,
555 CreatePipelineLayout(sharedContext->device(),
556 &layoutCreateInfo,
557 /*const VkAllocationCallbacks*=*/nullptr,
558 &layout));
559
560 // DescriptorSetLayouts can be deleted after the pipeline layout is created.
561 destroy_desc_set_layouts(sharedContext, setLayouts);
562
563 return result == VK_SUCCESS ? layout : VK_NULL_HANDLE;
564}
bool empty() const
Definition: SkTArray.h:199
static VkDescriptorSetLayout descriptor_data_to_layout(const VulkanSharedContext *sharedContext, const SkSpan< DescriptorData > &descriptorData)
static void destroy_desc_set_layouts(const VulkanSharedContext *sharedContext, skia_private::TArray< VkDescriptorSetLayout > &setLayouts)
VkPipelineLayoutCreateFlags flags
Definition: vulkan_core.h:3697
const VkPushConstantRange * pPushConstantRanges
Definition: vulkan_core.h:3701
const VkDescriptorSetLayout * pSetLayouts
Definition: vulkan_core.h:3699
VkFlags VkPipelineLayoutCreateFlags
Definition: vulkan_core.h:2730
@ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
Definition: vulkan_core.h:232

◆ setup_raster_state()

static void skgpu::graphite::setup_raster_state ( bool  isWireframe,
VkPipelineRasterizationStateCreateInfo rasterInfo 
)
static

Definition at line 415 of file VulkanGraphicsPipeline.cpp.

416 {
417 memset(rasterInfo, 0, sizeof(VkPipelineRasterizationStateCreateInfo));
419 rasterInfo->pNext = nullptr;
420 rasterInfo->flags = 0;
421 rasterInfo->depthClampEnable = VK_FALSE;
422 rasterInfo->rasterizerDiscardEnable = VK_FALSE;
423 rasterInfo->polygonMode = isWireframe ? VK_POLYGON_MODE_LINE : VK_POLYGON_MODE_FILL;
424 rasterInfo->cullMode = VK_CULL_MODE_NONE;
426 rasterInfo->depthBiasEnable = VK_FALSE;
427 rasterInfo->depthBiasConstantFactor = 0.0f;
428 rasterInfo->depthBiasClamp = 0.0f;
429 rasterInfo->depthBiasSlopeFactor = 0.0f;
430 rasterInfo->lineWidth = 1.0f;
431}
VkPipelineRasterizationStateCreateFlags flags
Definition: vulkan_core.h:3586
@ VK_CULL_MODE_NONE
Definition: vulkan_core.h:2695
@ VK_FRONT_FACE_COUNTER_CLOCKWISE
Definition: vulkan_core.h:2022
@ VK_POLYGON_MODE_FILL
Definition: vulkan_core.h:2049
@ VK_POLYGON_MODE_LINE
Definition: vulkan_core.h:2050
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
Definition: vulkan_core.h:225

◆ setup_shader_stage_info()

static void skgpu::graphite::setup_shader_stage_info ( VkShaderStageFlagBits  stage,
VkShaderModule  shaderModule,
VkPipelineShaderStageCreateInfo shaderStageInfo 
)
static

Definition at line 433 of file VulkanGraphicsPipeline.cpp.

435 {
436 memset(shaderStageInfo, 0, sizeof(VkPipelineShaderStageCreateInfo));
438 shaderStageInfo->pNext = nullptr;
439 shaderStageInfo->flags = 0;
440 shaderStageInfo->stage = stage;
441 shaderStageInfo->module = shaderModule;
442 shaderStageInfo->pName = "main";
443 shaderStageInfo->pSpecializationInfo = nullptr;
444}
VkPipelineShaderStageCreateFlags flags
Definition: vulkan_core.h:3509
const VkSpecializationInfo * pSpecializationInfo
Definition: vulkan_core.h:3513
VkShaderStageFlagBits stage
Definition: vulkan_core.h:3510
@ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
Definition: vulkan_core.h:220

◆ setup_stencil_op_state()

static void skgpu::graphite::setup_stencil_op_state ( VkStencilOpState opState,
const DepthStencilSettings::Face face,
uint32_t  referenceValue 
)
static

Definition at line 220 of file VulkanGraphicsPipeline.cpp.

222 {
227 opState->compareMask = face.fReadMask; // TODO - check this.
228 opState->writeMask = face.fWriteMask;
229 opState->reference = referenceValue;
230}
static VkStencilOp stencil_op_to_vk_stencil_op(GrStencilOp op)
VkStencilOp failOp
Definition: vulkan_core.h:3612
VkStencilOp passOp
Definition: vulkan_core.h:3613
uint32_t reference
Definition: vulkan_core.h:3618
VkCompareOp compareOp
Definition: vulkan_core.h:3615
uint32_t writeMask
Definition: vulkan_core.h:3617
uint32_t compareMask
Definition: vulkan_core.h:3616
VkStencilOp depthFailOp
Definition: vulkan_core.h:3614

◆ setup_vertex_input_state()

static void skgpu::graphite::setup_vertex_input_state ( const SkSpan< const Attribute > &  vertexAttrs,
const SkSpan< const Attribute > &  instanceAttrs,
VkPipelineVertexInputStateCreateInfo vertexInputInfo,
skia_private::STArray< 2, VkVertexInputBindingDescription, true > *  bindingDescs,
skia_private::STArray< 16, VkVertexInputAttributeDescription > *  attributeDescs 
)
static

Definition at line 92 of file VulkanGraphicsPipeline.cpp.

97 {
98 // Setup attribute & binding descriptions
99 int attribIndex = 0;
100 size_t vertexAttributeOffset = 0;
101 for (auto attrib : vertexAttrs) {
103 vkAttrib.location = attribIndex++;
104 vkAttrib.binding = VulkanGraphicsPipeline::kVertexBufferIndex;
105 vkAttrib.format = attrib_type_to_vkformat(attrib.cpuType());
106 vkAttrib.offset = vertexAttributeOffset;
107 vertexAttributeOffset += attrib.sizeAlign4();
108 attributeDescs->push_back(vkAttrib);
109 }
110
111 size_t instanceAttributeOffset = 0;
112 for (auto attrib : instanceAttrs) {
114 vkAttrib.location = attribIndex++;
115 vkAttrib.binding = VulkanGraphicsPipeline::kInstanceBufferIndex;
116 vkAttrib.format = attrib_type_to_vkformat(attrib.cpuType());
117 vkAttrib.offset = instanceAttributeOffset;
118 instanceAttributeOffset += attrib.sizeAlign4();
119 attributeDescs->push_back(vkAttrib);
120 }
121
122 if (bindingDescs && !vertexAttrs.empty()) {
123 bindingDescs->push_back() = {
124 VulkanGraphicsPipeline::kVertexBufferIndex,
125 (uint32_t) vertexAttributeOffset,
127 };
128 }
129 if (bindingDescs && !instanceAttrs.empty()) {
130 bindingDescs->push_back() = {
131 VulkanGraphicsPipeline::kInstanceBufferIndex,
132 (uint32_t) instanceAttributeOffset,
134 };
135 }
136
137 memset(vertexInputInfo, 0, sizeof(VkPipelineVertexInputStateCreateInfo));
139 vertexInputInfo->pNext = nullptr;
140 vertexInputInfo->flags = 0;
141 vertexInputInfo->vertexBindingDescriptionCount = bindingDescs ? bindingDescs->size() : 0;
142 vertexInputInfo->pVertexBindingDescriptions =
143 bindingDescs && !bindingDescs->empty() ? bindingDescs->begin() : VK_NULL_HANDLE;
144 vertexInputInfo->vertexAttributeDescriptionCount = attributeDescs ? attributeDescs->size() : 0;
145 vertexInputInfo->pVertexAttributeDescriptions =
146 attributeDescs && !attributeDescs->empty() ? attributeDescs->begin() : VK_NULL_HANDLE;
147}
static VkFormat attrib_type_to_vkformat(GrVertexAttribType type)
const VkVertexInputAttributeDescription * pVertexAttributeDescriptions
Definition: vulkan_core.h:3546
const VkVertexInputBindingDescription * pVertexBindingDescriptions
Definition: vulkan_core.h:3544
VkPipelineVertexInputStateCreateFlags flags
Definition: vulkan_core.h:3542
@ VK_VERTEX_INPUT_RATE_VERTEX
Definition: vulkan_core.h:2028
@ VK_VERTEX_INPUT_RATE_INSTANCE
Definition: vulkan_core.h:2029
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
Definition: vulkan_core.h:221

◆ setup_viewport_scissor_state()

static void skgpu::graphite::setup_viewport_scissor_state ( VkPipelineViewportStateCreateInfo viewportInfo)
static

Definition at line 258 of file VulkanGraphicsPipeline.cpp.

258 {
259 memset(viewportInfo, 0, sizeof(VkPipelineViewportStateCreateInfo));
261 viewportInfo->pNext = nullptr;
262 viewportInfo->flags = 0;
263
264 viewportInfo->viewportCount = 1;
265 viewportInfo->pViewports = nullptr; // This is set dynamically with a draw pass command
266
267 viewportInfo->scissorCount = 1;
268 viewportInfo->pScissors = nullptr; // This is set dynamically with a draw pass command
269
270 SkASSERT(viewportInfo->viewportCount == viewportInfo->scissorCount);
271}
VkPipelineViewportStateCreateFlags flags
Definition: vulkan_core.h:3576
@ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
Definition: vulkan_core.h:224

◆ SK_MAKE_BITMASK_OPS() [1/2]

skgpu::graphite::SK_MAKE_BITMASK_OPS ( DawnErrorType  )

◆ SK_MAKE_BITMASK_OPS() [2/2]

skgpu::graphite::SK_MAKE_BITMASK_OPS ( PipelineStageFlags  )

◆ skdata_matches()

static bool skgpu::graphite::skdata_matches ( const SkData a,
const SkData b 
)
static

Definition at line 1088 of file KeyHelpers.cpp.

1088 {
1089 // Returns true if both SkData objects hold the same contents, or if they are both null.
1090 // (SkData::equals supports passing null, and returns false.)
1091 return a ? a->equals(b) : (a == b);
1092}
struct MyStruct a[10]

◆ SkShouldPostMessageToBus()

bool skgpu::graphite::SkShouldPostMessageToBus ( const ClientMappedBufferManager::BufferFinishedMessage &  ,
Context::ContextID  potentialRecipient 
)

◆ stencil_op_to_vk_stencil_op()

static VkStencilOp skgpu::graphite::stencil_op_to_vk_stencil_op ( StencilOp  op)
static

Definition at line 171 of file VulkanGraphicsPipeline.cpp.

171 {
172 static const VkStencilOp gTable[] = {
173 VK_STENCIL_OP_KEEP, // kKeep
174 VK_STENCIL_OP_ZERO, // kZero
175 VK_STENCIL_OP_REPLACE, // kReplace
176 VK_STENCIL_OP_INVERT, // kInvert
181 };
182 static_assert(std::size(gTable) == kStencilOpCount);
183 static_assert(0 == (int)StencilOp::kKeep);
184 static_assert(1 == (int)StencilOp::kZero);
185 static_assert(2 == (int)StencilOp::kReplace);
186 static_assert(3 == (int)StencilOp::kInvert);
187 static_assert(4 == (int)StencilOp::kIncWrap);
188 static_assert(5 == (int)StencilOp::kDecWrap);
189 static_assert(6 == (int)StencilOp::kIncClamp);
190 static_assert(7 == (int)StencilOp::kDecClamp);
192 return gTable[(int)op];
193}
static constexpr int kStencilOpCount
Definition: DrawTypes.h:173
VkStencilOp
Definition: vulkan_core.h:2056
@ VK_STENCIL_OP_INCREMENT_AND_CLAMP
Definition: vulkan_core.h:2060
@ VK_STENCIL_OP_DECREMENT_AND_CLAMP
Definition: vulkan_core.h:2061
@ VK_STENCIL_OP_INCREMENT_AND_WRAP
Definition: vulkan_core.h:2063
@ VK_STENCIL_OP_KEEP
Definition: vulkan_core.h:2057
@ VK_STENCIL_OP_REPLACE
Definition: vulkan_core.h:2059
@ VK_STENCIL_OP_ZERO
Definition: vulkan_core.h:2058
@ VK_STENCIL_OP_DECREMENT_AND_WRAP
Definition: vulkan_core.h:2064
@ VK_STENCIL_OP_INVERT
Definition: vulkan_core.h:2062

◆ submit_to_queue()

static bool skgpu::graphite::submit_to_queue ( const VulkanSharedContext sharedContext,
VkQueue  queue,
VkFence  fence,
uint32_t  waitCount,
const VkSemaphore *  waitSemaphores,
const VkPipelineStageFlags waitStages,
uint32_t  commandBufferCount,
const VkCommandBuffer *  commandBuffers,
uint32_t  signalCount,
const VkSemaphore *  signalSemaphores,
Protected  protectedContext 
)
static

Definition at line 232 of file VulkanCommandBuffer.cpp.

242 {
243 VkProtectedSubmitInfo protectedSubmitInfo;
244 if (protectedContext == Protected::kYes) {
245 memset(&protectedSubmitInfo, 0, sizeof(VkProtectedSubmitInfo));
247 protectedSubmitInfo.pNext = nullptr;
248 protectedSubmitInfo.protectedSubmit = VK_TRUE;
249 }
250
251 VkSubmitInfo submitInfo;
252 memset(&submitInfo, 0, sizeof(VkSubmitInfo));
254 submitInfo.pNext = protectedContext == Protected::kYes ? &protectedSubmitInfo : nullptr;
255 submitInfo.waitSemaphoreCount = waitCount;
256 submitInfo.pWaitSemaphores = waitSemaphores;
257 submitInfo.pWaitDstStageMask = waitStages;
258 submitInfo.commandBufferCount = commandBufferCount;
259 submitInfo.pCommandBuffers = commandBuffers;
260 submitInfo.signalSemaphoreCount = signalCount;
261 submitInfo.pSignalSemaphores = signalSemaphores;
263 VULKAN_CALL_RESULT(sharedContext, result, QueueSubmit(queue, 1, &submitInfo, fence));
264 return result == VK_SUCCESS;
265}
VkQueue queue
Definition: main.cc:55
VkStructureType sType
Definition: vulkan_core.h:5417
uint32_t waitSemaphoreCount
Definition: vulkan_core.h:3285
const VkPipelineStageFlags * pWaitDstStageMask
Definition: vulkan_core.h:3287
uint32_t commandBufferCount
Definition: vulkan_core.h:3288
const VkSemaphore * pWaitSemaphores
Definition: vulkan_core.h:3286
uint32_t signalSemaphoreCount
Definition: vulkan_core.h:3290
const VkCommandBuffer * pCommandBuffers
Definition: vulkan_core.h:3289
const void * pNext
Definition: vulkan_core.h:3284
const VkSemaphore * pSignalSemaphores
Definition: vulkan_core.h:3291
VkStructureType sType
Definition: vulkan_core.h:3283
#define VK_TRUE
Definition: vulkan_core.h:131
@ VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO
Definition: vulkan_core.h:288
@ VK_STRUCTURE_TYPE_SUBMIT_INFO
Definition: vulkan_core.h:206

◆ swizzle_class_to_read_enum()

static skgpu::graphite::ReadSwizzle skgpu::graphite::swizzle_class_to_read_enum ( const skgpu::Swizzle swizzle)
static

Definition at line 1757 of file KeyHelpers.cpp.

1757 {
1758 if (swizzle == skgpu::Swizzle::RGBA()) {
1760 } else if (swizzle == skgpu::Swizzle::RGB1()) {
1762 } else if (swizzle == skgpu::Swizzle("rrr1")) {
1764 } else if (swizzle == skgpu::Swizzle::BGRA()) {
1766 } else if (swizzle == skgpu::Swizzle("000r")) {
1768 } else {
1769 SKGPU_LOG_W("%s is an unsupported read swizzle. Defaulting to RGBA.\n",
1770 swizzle.asString().data());
1772 }
1773}
const char * data() const
Definition: SkString.h:132
static constexpr Swizzle BGRA()
Definition: Swizzle.h:67
static constexpr Swizzle RGBA()
Definition: Swizzle.h:66
static constexpr Swizzle RGB1()
Definition: Swizzle.h:69

◆ tile_mode_to_dawn_address_mode()

static wgpu::AddressMode skgpu::graphite::tile_mode_to_dawn_address_mode ( SkTileMode  tileMode)
inlinestatic

Definition at line 49 of file DawnSampler.cpp.

49 {
50 switch (tileMode) {
52 return wgpu::AddressMode::ClampToEdge;
54 return wgpu::AddressMode::Repeat;
56 return wgpu::AddressMode::MirrorRepeat;
58 // Dawn doesn't support this mode.
59 return wgpu::AddressMode::ClampToEdge;
60 }
62}

◆ tile_mode_to_mtl_sampler_address()

static MTLSamplerAddressMode skgpu::graphite::tile_mode_to_mtl_sampler_address ( SkTileMode  tileMode,
const Caps caps 
)
inlinestatic

Definition at line 21 of file MtlSampler.mm.

22 {
23 switch (tileMode) {
25 return MTLSamplerAddressModeClampToEdge;
27 return MTLSamplerAddressModeRepeat;
29 return MTLSamplerAddressModeMirrorRepeat;
31 // For this tilemode, we should have checked that clamp-to-border support exists.
32 // If it doesn't we should have fallen back to a shader instead.
33 // TODO: for textures with alpha, we could use ClampToZero if there's no
34 // ClampToBorderColor as they'll clamp to (0,0,0,0).
35 // Unfortunately textures without alpha end up clamping to (0,0,0,1).
36 if (@available(macOS 10.12, iOS 14.0, tvOS 14.0, *)) {
38 return MTLSamplerAddressModeClampToBorderColor;
39 } else {
40 SkASSERT(false);
41 return MTLSamplerAddressModeClampToZero;
42 }
43 }
45}

◆ tile_mode_to_vk_sampler_address()

static VkSamplerAddressMode skgpu::graphite::tile_mode_to_vk_sampler_address ( SkTileMode  tileMode)
static

Definition at line 23 of file VulkanSampler.cpp.

23 {
24 switch (tileMode) {
33 }
35}
@ VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT
Definition: vulkan_core.h:2110
@ VK_SAMPLER_ADDRESS_MODE_REPEAT
Definition: vulkan_core.h:2109
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
Definition: vulkan_core.h:2111
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
Definition: vulkan_core.h:2112

◆ to_str()

static std::string skgpu::graphite::to_str ( const SharedContext ctx,
const GraphicsPipelineDesc gpDesc,
const RenderPassDesc rpDesc 
)
static

Definition at line 35 of file ResourceProvider.cpp.

37 {
38 const ShaderCodeDictionary* dict = ctx->shaderCodeDictionary();
39 const RenderStep* step = ctx->rendererProvider()->lookup(gpDesc.renderStepID());
40 return GetPipelineLabel(dict, rpDesc, step, gpDesc.paintParamsID());
41}
UniquePaintParamsID paintParamsID() const
const RenderStep * lookup(uint32_t uniqueID) const
ShaderCodeDictionary * shaderCodeDictionary()
Definition: SharedContext.h:49
const RendererProvider * rendererProvider() const
Definition: SharedContext.h:47
std::string GetPipelineLabel(const ShaderCodeDictionary *dict, const RenderPassDesc &renderPassDesc, const RenderStep *renderStep, UniquePaintParamsID paintID)

◆ top_device_graphite_target_proxy()

static skgpu::graphite::TextureProxy * skgpu::graphite::top_device_graphite_target_proxy ( SkCanvas canvas)
static

Definition at line 93 of file GraphiteResourceCacheTest.cpp.

93 {
94 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGraphiteDevice()) {
95 return gpuDevice->target();
96 }
97 return nullptr;
98}
static SkDevice * TopDevice(const SkCanvas *canvas)
Definition: SkCanvasPriv.h:65

◆ uniform_type_to_sksl_type()

static SkSLType skgpu::graphite::uniform_type_to_sksl_type ( const SkRuntimeEffect::Uniform u)
static

Definition at line 1562 of file ShaderCodeDictionary.cpp.

1562 {
1565 switch (u.type) {
1566 case Type::kFloat: return SkSLType::kHalf;
1567 case Type::kFloat2: return SkSLType::kHalf2;
1568 case Type::kFloat3: return SkSLType::kHalf3;
1569 case Type::kFloat4: return SkSLType::kHalf4;
1570 case Type::kFloat2x2: return SkSLType::kHalf2x2;
1571 case Type::kFloat3x3: return SkSLType::kHalf3x3;
1572 case Type::kFloat4x4: return SkSLType::kHalf4x4;
1573 // NOTE: shorts cannot be uniforms, so we shouldn't ever get here.
1574 // Defensively return the full precision integer type.
1575 case Type::kInt: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt;
1576 case Type::kInt2: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt2;
1577 case Type::kInt3: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt3;
1578 case Type::kInt4: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt4;
1579 }
1580 } else {
1581 switch (u.type) {
1582 case Type::kFloat: return SkSLType::kFloat;
1583 case Type::kFloat2: return SkSLType::kFloat2;
1584 case Type::kFloat3: return SkSLType::kFloat3;
1585 case Type::kFloat4: return SkSLType::kFloat4;
1586 case Type::kFloat2x2: return SkSLType::kFloat2x2;
1587 case Type::kFloat3x3: return SkSLType::kFloat3x3;
1588 case Type::kFloat4x4: return SkSLType::kFloat4x4;
1589 case Type::kInt: return SkSLType::kInt;
1590 case Type::kInt2: return SkSLType::kInt2;
1591 case Type::kInt3: return SkSLType::kInt3;
1592 case Type::kInt4: return SkSLType::kInt4;
1593 }
1594 }
1596}

◆ VELLO_COMPUTE_STEP() [1/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( BackdropDyn  )

◆ VELLO_COMPUTE_STEP() [2/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( BboxClear  )

◆ VELLO_COMPUTE_STEP() [3/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( Binning  )

◆ VELLO_COMPUTE_STEP() [4/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( ClipLeaf  )

◆ VELLO_COMPUTE_STEP() [5/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( ClipReduce  )

◆ VELLO_COMPUTE_STEP() [6/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( Coarse  )

◆ VELLO_COMPUTE_STEP() [7/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( DrawLeaf  )

◆ VELLO_COMPUTE_STEP() [8/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( DrawReduce  )

◆ VELLO_COMPUTE_STEP() [9/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( Flatten  )

◆ VELLO_COMPUTE_STEP() [10/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathCount  )

◆ VELLO_COMPUTE_STEP() [11/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathCountSetup  )

◆ VELLO_COMPUTE_STEP() [12/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathtagReduce  )

◆ VELLO_COMPUTE_STEP() [13/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathtagReduce2  )

◆ VELLO_COMPUTE_STEP() [14/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathtagScan1  )

◆ VELLO_COMPUTE_STEP() [15/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathtagScanLarge  )

◆ VELLO_COMPUTE_STEP() [16/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathtagScanSmall  )

◆ VELLO_COMPUTE_STEP() [17/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathTiling  )

◆ VELLO_COMPUTE_STEP() [18/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( PathTilingSetup  )

◆ VELLO_COMPUTE_STEP() [19/19]

skgpu::graphite::VELLO_COMPUTE_STEP ( TileAlloc  )

◆ VelloNativeShaderSource()

ComputeStep::NativeShaderSource skgpu::graphite::VelloNativeShaderSource ( vello_cpp::ShaderStage  stage,
ComputeStep::NativeShaderFormat  format 
)

Definition at line 35 of file VelloComputeSteps.cpp.

36 {
37 using NativeFormat = ComputeStep::NativeShaderFormat;
38
39 const auto& shader = vello_cpp::shader(stage);
40 ::rust::Str source;
41 std::string entryPoint;
42 switch (format) {
43#ifdef SK_DAWN
44 case NativeFormat::kWGSL:
45 source = shader.wgsl();
46 entryPoint = "main";
47 break;
48#endif
49#ifdef SK_METAL
50 case NativeFormat::kMSL:
51 source = shader.msl();
52 entryPoint = "main_";
53 break;
54#endif
55 default:
56 return {std::string_view(), ""};
57 }
58
59 return {{source.data(), source.length()}, std::move(entryPoint)};
60}
SkBitmap source
Definition: examples.cpp:28

◆ VelloStageLocalSize()

WorkgroupSize skgpu::graphite::VelloStageLocalSize ( vello_cpp::ShaderStage  stage)

Definition at line 17 of file VelloComputeSteps.cpp.

17 {
18 auto wgSize = vello_cpp::shader(stage).workgroup_size();
19 return WorkgroupSize(wgSize.x, wgSize.y, wgSize.z);
20}

◆ VelloStageName()

std::string_view skgpu::graphite::VelloStageName ( vello_cpp::ShaderStage  stage)

Definition at line 12 of file VelloComputeSteps.cpp.

12 {
13 auto name = vello_cpp::shader(stage).name();
14 return {name.data(), name.length()};
15}

◆ VelloWorkgroupBuffers()

skia_private::TArray< ComputeStep::WorkgroupBufferDesc > skgpu::graphite::VelloWorkgroupBuffers ( vello_cpp::ShaderStage  stage)

Definition at line 22 of file VelloComputeSteps.cpp.

23 {
24 auto wgBuffers = vello_cpp::shader(stage).workgroup_buffers();
26 if (!wgBuffers.empty()) {
27 result.reserve(wgBuffers.size());
28 for (const auto& desc : wgBuffers) {
29 result.push_back({desc.size_in_bytes, desc.index});
30 }
31 }
32 return result;
33}

◆ VertexAttribTypeSize()

static constexpr size_t skgpu::graphite::VertexAttribTypeSize ( VertexAttribType  type)
inlinestaticconstexpr

Returns the size of the attrib type in bytes.

Definition at line 77 of file DrawTypes.h.

77 {
78 switch (type) {
80 return sizeof(float);
81 case VertexAttribType::kFloat2:
82 return 2 * sizeof(float);
83 case VertexAttribType::kFloat3:
84 return 3 * sizeof(float);
85 case VertexAttribType::kFloat4:
86 return 4 * sizeof(float);
87 case VertexAttribType::kHalf:
88 return sizeof(uint16_t);
89 case VertexAttribType::kHalf2:
90 return 2 * sizeof(uint16_t);
91 case VertexAttribType::kHalf4:
92 return 4 * sizeof(uint16_t);
93 case VertexAttribType::kInt2:
94 return 2 * sizeof(int32_t);
95 case VertexAttribType::kInt3:
96 return 3 * sizeof(int32_t);
97 case VertexAttribType::kInt4:
98 return 4 * sizeof(int32_t);
100 return 1 * sizeof(char);
101 case VertexAttribType::kByte2:
102 return 2 * sizeof(char);
103 case VertexAttribType::kByte4:
104 return 4 * sizeof(char);
105 case VertexAttribType::kUByte:
106 return 1 * sizeof(char);
107 case VertexAttribType::kUByte2:
108 return 2 * sizeof(char);
109 case VertexAttribType::kUByte4:
110 return 4 * sizeof(char);
111 case VertexAttribType::kUByte_norm:
112 return 1 * sizeof(char);
113 case VertexAttribType::kUByte4_norm:
114 return 4 * sizeof(char);
115 case VertexAttribType::kShort2:
116 return 2 * sizeof(int16_t);
117 case VertexAttribType::kShort4:
118 return 4 * sizeof(int16_t);
119 case VertexAttribType::kUShort2: [[fallthrough]];
120 case VertexAttribType::kUShort2_norm:
121 return 2 * sizeof(uint16_t);
122 case VertexAttribType::kInt:
123 return sizeof(int32_t);
124 case VertexAttribType::kUInt:
125 return sizeof(uint32_t);
126 case VertexAttribType::kUShort_norm:
127 return sizeof(uint16_t);
128 case VertexAttribType::kUShort4_norm:
129 return 4 * sizeof(uint16_t);
130 }
132}

◆ vk_format_to_aspect_flags()

VkImageAspectFlags skgpu::graphite::vk_format_to_aspect_flags ( VkFormat  format)

Definition at line 188 of file VulkanTexture.cpp.

188 {
189 switch (format) {
193 [[fallthrough]];
197 [[fallthrough]];
200 default:
202 }
203}
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan_core.h:2238
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan_core.h:2240
@ VK_IMAGE_ASPECT_DEPTH_BIT
Definition: vulkan_core.h:2239
@ VK_FORMAT_D24_UNORM_S8_UINT
Definition: vulkan_core.h:1588
@ VK_FORMAT_D32_SFLOAT
Definition: vulkan_core.h:1585
@ VK_FORMAT_S8_UINT
Definition: vulkan_core.h:1586
@ VK_FORMAT_D16_UNORM
Definition: vulkan_core.h:1583
@ VK_FORMAT_D32_SFLOAT_S8_UINT
Definition: vulkan_core.h:1589

◆ vkFormatIsSupported()

bool skgpu::graphite::vkFormatIsSupported ( VkFormat  format)

Definition at line 128 of file VulkanGraphiteUtils.cpp.

128 {
129 switch (format) {
157 return true;
158 default:
159 return false;
160 }
161}
@ VK_FORMAT_R8G8B8A8_SRGB
Definition: vulkan_core.h:1502
@ VK_FORMAT_R8G8B8_UNORM
Definition: vulkan_core.h:1482
@ VK_FORMAT_B8G8R8A8_UNORM
Definition: vulkan_core.h:1503
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
Definition: vulkan_core.h:1462
@ VK_FORMAT_R8G8_UNORM
Definition: vulkan_core.h:1475
@ 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_BC1_RGB_UNORM_BLOCK
Definition: vulkan_core.h:1590
@ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
Definition: vulkan_core.h:1646
@ 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

◆ VulkanTextureSpecToTextureInfo()

VulkanTextureInfo skgpu::graphite::VulkanTextureSpecToTextureInfo ( const VulkanTextureSpec vkSpec,
uint32_t  sampleCount,
Mipmapped  mipmapped 
)

◆ write_color_and_offset_bufdata()

static int skgpu::graphite::write_color_and_offset_bufdata ( int  numStops,
const SkPMColor4f colors,
const float *  offsets,
const SkGradientBaseShader shader,
PipelineDataGatherer gatherer 
)
static

Definition at line 313 of file KeyHelpers.cpp.

317 {
318 auto [dstData, bufferOffset] = gatherer->allocateGradientData(numStops, shader);
319 if (dstData) {
320 // Data doesn't already exist so we need to write it.
321 for (int i = 0; i < numStops; i++) {
322 SkColor4f unpremulColor = colors[i].unpremul();
323
324 float offset = offsets ? offsets[i] : SkIntToFloat(i) / (numStops - 1);
325 SkASSERT(offset >= 0.0f && offset <= 1.0f);
326
327 int dataIndex = i * 5;
328 dstData[dataIndex] = offset;
329 dstData[dataIndex + 1] = unpremulColor.fR;
330 dstData[dataIndex + 2] = unpremulColor.fG;
331 dstData[dataIndex + 3] = unpremulColor.fB;
332 dstData[dataIndex + 4] = unpremulColor.fA;
333 }
334 }
335
336 return bufferOffset;
337}
std::pair< float *, int > allocateGradientData(int numStops, const SkGradientBaseShader *shader)
Definition: PipelineData.h:133

◆ write_index_buffer() [1/2]

static void skgpu::graphite::write_index_buffer ( VertexWriter  writer)
static

Definition at line 259 of file AnalyticRRectRenderStep.cpp.

259 {
260 static constexpr uint16_t kTL = 0 * kCornerVertexCount;
261 static constexpr uint16_t kTR = 1 * kCornerVertexCount;
262 static constexpr uint16_t kBR = 2 * kCornerVertexCount;
263 static constexpr uint16_t kBL = 3 * kCornerVertexCount;
264
265 static const uint16_t kIndices[kIndexCount] = {
266 // Exterior AA ramp outset
267 kTL+0,kTL+4,kTL+1,kTL+5,kTL+2,kTL+3,kTL+5,
268 kTR+0,kTR+4,kTR+1,kTR+5,kTR+2,kTR+3,kTR+5,
269 kBR+0,kBR+4,kBR+1,kBR+5,kBR+2,kBR+3,kBR+5,
270 kBL+0,kBL+4,kBL+1,kBL+5,kBL+2,kBL+3,kBL+5,
271 kTL+0,kTL+4, // close and jump to next strip
272 // Outer to inner edges
273 kTL+4,kTL+6,kTL+5,kTL+7,
274 kTR+4,kTR+6,kTR+5,kTR+7,
275 kBR+4,kBR+6,kBR+5,kBR+7,
276 kBL+4,kBL+6,kBL+5,kBL+7,
277 kTL+4,kTL+6, // close and jump to next strip
278 // Fill triangles
279 kTL+6,kTL+8,kTL+7, kTL+7,kTR+8,
280 kTR+6,kTR+8,kTR+7, kTR+7,kBR+8,
281 kBR+6,kBR+8,kBR+7, kBR+7,kBL+8,
282 kBL+6,kBL+8,kBL+7, kBL+7,kTL+8,
283 kTL+6 // close
284 };
285
286 if (writer) {
287 writer << kIndices;
288 } // otherwise static buffer creation failed, so do nothing; Context initialization will fail.
289}
static const uint16_t kTL
static const uint16_t kBL
static const uint16_t kBR
static const uint16_t kTR
static constexpr int kCornerVertexCount

◆ write_index_buffer() [2/2]

static void skgpu::graphite::write_index_buffer ( VertexWriter  writer)
static

Definition at line 131 of file PerEdgeAAQuadRenderStep.cpp.

131 {
132 static constexpr uint16_t kTL = 0 * kCornerVertexCount;
133 static constexpr uint16_t kTR = 1 * kCornerVertexCount;
134 static constexpr uint16_t kBR = 2 * kCornerVertexCount;
135 static constexpr uint16_t kBL = 3 * kCornerVertexCount;
136
137 static const uint16_t kIndices[kIndexCount] = {
138 // Exterior AA ramp outset
139 kTL+1,kTL+2,kTL+3,kTR+0,kTR+3,kTR+1,
140 kTR+1,kTR+2,kTR+3,kBR+0,kBR+3,kBR+1,
141 kBR+1,kBR+2,kBR+3,kBL+0,kBL+3,kBL+1,
142 kBL+1,kBL+2,kBL+3,kTL+0,kTL+3,kTL+1,
143 kTL+3,
144 // Fill triangles
145 kTL+3,kTR+3,kBL+3,kBR+3
146 };
147
148 if (writer) {
149 writer << kIndices;
150 } // otherwise static buffer creation failed, so do nothing; Context initialization will fail.
151}

◆ write_vertex_buffer() [1/2]

static void skgpu::graphite::write_vertex_buffer ( VertexWriter  writer)
static

Definition at line 291 of file AnalyticRRectRenderStep.cpp.

291 {
292 // Allowed values for the normal scale attribute. +1 signals a device-space outset along the
293 // normal away from the outer edge of the stroke. 0 signals no outset, but placed on the outer
294 // edge of the stroke. -1 signals a local inset along the normal from the inner edge.
295 static constexpr float kOutset = 1.0;
296 static constexpr float kInset = -1.0;
297
298 static constexpr float kCenter = 1.f; // "true" as a float
299
300 // Zero, but named this way to help call out non-zero parameters.
301 static constexpr float _______ = 0.f;
302
303 static constexpr float kHR2 = 0.5f * SK_FloatSqrt2; // "half root 2"
304
305 // This template is repeated 4 times in the vertex buffer, for each of the four corners.
306 // The vertex ID is used to lookup per-corner instance properties such as corner radii or
307 // positions, but otherwise this vertex data produces a consistent clockwise mesh from
308 // TL -> TR -> BR -> BL.
309 static constexpr Vertex kCornerTemplate[kCornerVertexCount] = {
310 // Device-space AA outsets from outer curve
311 { {1.0f, 0.0f}, {1.0f, 0.0f}, kOutset, _______ },
312 { {1.0f, 0.0f}, {kHR2, kHR2}, kOutset, _______ },
313 { {0.0f, 1.0f}, {kHR2, kHR2}, kOutset, _______ },
314 { {0.0f, 1.0f}, {0.0f, 1.0f}, kOutset, _______ },
315
316 // Outer anchors (no local or device-space normal outset)
317 { {1.0f, 0.0f}, {kHR2, kHR2}, _______, _______ },
318 { {0.0f, 1.0f}, {kHR2, kHR2}, _______, _______ },
319
320 // Inner curve (with additional AA inset in the common case)
321 { {1.0f, 0.0f}, {1.0f, 0.0f}, kInset, _______ },
322 { {0.0f, 1.0f}, {0.0f, 1.0f}, kInset, _______ },
323
324 // Center filling vertices (equal to inner AA insets unless 'center' triggers a fill).
325 // TODO: On backends that support "cull" distances (and with SkSL support), these vertices
326 // and their corresponding triangles can be completely removed. The inset vertices can
327 // set their cull distance value to cause all filling triangles to be discarded or not
328 // depending on the instance's style.
329 { {1.0f, 0.0f}, {1.0f, 0.0f}, kInset, kCenter },
330 };
331
332 if (writer) {
333 writer << kCornerTemplate // TL
334 << kCornerTemplate // TR
335 << kCornerTemplate // BR
336 << kCornerTemplate; // BL
337 } // otherwise static buffer creation failed, so do nothing; Context initialization will fail.
338}
static constexpr LocalCornerVert kCornerTemplate[19]
static constexpr float kHR2
constexpr float SK_FloatSqrt2
static const int kInset
Definition: flippity.cpp:47

◆ write_vertex_buffer() [2/2]

static void skgpu::graphite::write_vertex_buffer ( VertexWriter  writer)
static

Definition at line 153 of file PerEdgeAAQuadRenderStep.cpp.

153 {
154 static constexpr float kHR2 = 0.5f * SK_FloatSqrt2; // "half root 2"
155
156 // This template is repeated 4 times in the vertex buffer, for each of the four corners.
157 // The vertex ID is used to lookup per-corner instance properties such as positions,
158 // but otherwise this vertex data produces a consistent clockwise mesh from
159 // TL -> TR -> BR -> BL.
160 static constexpr Vertex kCornerTemplate[kCornerVertexCount] = {
161 // Normals for device-space AA outsets from outer curve
162 { {1.0f, 0.0f} },
163 { {kHR2, kHR2} },
164 { {0.0f, 1.0f} },
165
166 // Normal for outer anchor (zero length to signal no local or device-space normal outset)
167 { {0.0f, 0.0f} },
168 };
169
170 if (writer) {
171 writer << kCornerTemplate // TL
172 << kCornerTemplate // TR
173 << kCornerTemplate // BR
174 << kCornerTemplate; // BL
175 } // otherwise static buffer creation failed, so do nothing; Context initialization will fail.
176}

Variable Documentation

◆ kAtlasRecentlyUsedCount

constexpr auto skgpu::graphite::kAtlasRecentlyUsedCount = 128
staticconstexpr

Definition at line 187 of file DrawAtlas.cpp.

◆ kBufferTypeCount

const int skgpu::graphite::kBufferTypeCount = static_cast<int>(BufferType::kLast) + 1
static

Definition at line 72 of file ResourceTypes.h.

◆ kBuiltInCodeSnippetIDCount

constexpr int skgpu::graphite::kBuiltInCodeSnippetIDCount = static_cast<int>(BuiltInCodeSnippetID::kLast)+1
staticconstexpr

Definition at line 108 of file BuiltInCodeSnippetID.h.

◆ kCompareOpCount

constexpr int skgpu::graphite::kCompareOpCount = 1 + (int)CompareOp::kNotEqual
staticconstexpr

Definition at line 159 of file DrawTypes.h.

◆ kComplexAAInsets

constexpr float skgpu::graphite::kComplexAAInsets = -1.f
staticconstexpr

Definition at line 253 of file AnalyticRRectRenderStep.cpp.

◆ kCornerVertexCount [1/2]

constexpr int skgpu::graphite::kCornerVertexCount = 9
staticconstexpr

Definition at line 255 of file AnalyticRRectRenderStep.cpp.

◆ kCornerVertexCount [2/2]

constexpr int skgpu::graphite::kCornerVertexCount = 4
staticconstexpr

Definition at line 127 of file PerEdgeAAQuadRenderStep.cpp.

◆ kDecrementCCW

constexpr DepthStencilSettings::Face skgpu::graphite::kDecrementCCW
constexpr
Initial value:
= {
StencilOp::kKeep,
StencilOp::kKeep,
StencilOp::kDecWrap,
CompareOp::kAlways,
0xffffffff,
0xffffffff
}

Definition at line 56 of file CommonDepthStencilSettings.h.

◆ kDefaultAtlasDim

constexpr uint32_t skgpu::graphite::kDefaultAtlasDim = 4096
staticconstexpr

Definition at line 21 of file RasterPathAtlas.cpp.

◆ kDefaultOutstandingAllocCnt

constexpr int skgpu::graphite::kDefaultOutstandingAllocCnt = 8
staticconstexpr

Definition at line 30 of file QueueManager.cpp.

◆ kDepthStencilVkFormats

constexpr VkFormat skgpu::graphite::kDepthStencilVkFormats[]
staticconstexpr

◆ kDescriptorTypeCount

constexpr int skgpu::graphite::kDescriptorTypeCount = (int)(DescriptorType::kLast) + 1
staticconstexpr

Definition at line 30 of file DescriptorData.h.

◆ kDirectDepthGEqualPass

constexpr DepthStencilSettings skgpu::graphite::kDirectDepthGEqualPass
staticconstexpr
Initial value:
= {
{},
{},
0,
false,
CompareOp::kGEqual,
true,
true
}

Definition at line 30 of file CommonDepthStencilSettings.h.

◆ kDirectDepthGreaterPass

constexpr DepthStencilSettings skgpu::graphite::kDirectDepthGreaterPass
staticconstexpr
Initial value:
= {
{},
{},
0,
false,
CompareOp::kGreater,
true,
true
}

DepthStencilSettings reusable by RenderSteps that can shade directly in a single pass, using GREATER or GEQUAL depth tests depending on if they allow self-intersections.

Definition at line 20 of file CommonDepthStencilSettings.h.

◆ kDumpAtlasData

const constexpr bool skgpu::graphite::kDumpAtlasData = false
staticconstexpr

Definition at line 35 of file DrawAtlas.cpp.

◆ kElementStackIncrement

constexpr int skgpu::graphite::kElementStackIncrement = 8
staticconstexpr

Definition at line 963 of file ClipStack_graphite.cpp.

◆ kEvenOddStencilPass

constexpr DepthStencilSettings skgpu::graphite::kEvenOddStencilPass
constexpr
Initial value:
= {
0,
true,
CompareOp::kGreater,
true,
false
}
constexpr DepthStencilSettings::Face kToggle

Definition at line 89 of file CommonDepthStencilSettings.h.

◆ kFilledStrokeInterior

constexpr float skgpu::graphite::kFilledStrokeInterior = -1.f
staticconstexpr

Definition at line 249 of file AnalyticRRectRenderStep.cpp.

◆ kFineAreaResources

constexpr ComputeStep::ResourceDesc skgpu::graphite::kFineAreaResources[]
staticconstexpr
Initial value:
= {
BUFFER_BINDING(ConfigUniform, Uniform, None),
BUFFER_BINDING(Segments, ReadOnlyStorage, None),
BUFFER_BINDING(PTCL, ReadOnlyStorage, None),
BUFFER_BINDING(InfoBinData, ReadOnlyStorage, None),
TEXTURE_BINDING(OutputImage, WriteOnlyStorage, None),
}
#define BUFFER_BINDING(slot, type, policy)
#define TEXTURE_BINDING(slot, type, policy)

Definition at line 263 of file VelloComputeSteps.cpp.

◆ kFineMsaaResources

constexpr ComputeStep::ResourceDesc skgpu::graphite::kFineMsaaResources[]
staticconstexpr
Initial value:
= {
BUFFER_BINDING(ConfigUniform, Uniform, None),
BUFFER_BINDING(Segments, ReadOnlyStorage, None),
BUFFER_BINDING(PTCL, ReadOnlyStorage, None),
BUFFER_BINDING(InfoBinData, ReadOnlyStorage, None),
TEXTURE_BINDING(OutputImage, WriteOnlyStorage, None),
BUFFER_BINDING(MaskLUT, ReadOnlyStorage, Mapped),
}

Definition at line 271 of file VelloComputeSteps.cpp.

◆ kFixedFunctionBlendModeIDOffset

constexpr int skgpu::graphite::kFixedFunctionBlendModeIDOffset
staticconstexpr
Initial value:
=
static_cast<int>(BuiltInCodeSnippetID::kFirstFixedFunctionBlendMode)

Definition at line 109 of file BuiltInCodeSnippetID.h.

◆ kGraphicsPipelineDomain

const skgpu::UniqueKey::Domain skgpu::graphite::kGraphicsPipelineDomain = UniqueKey::GenerateDomain()
static

Definition at line 895 of file MtlCaps.mm.

◆ kGraphicsPipelineKeyData32Count

const int skgpu::graphite::kGraphicsPipelineKeyData32Count = 5
static

Definition at line 896 of file MtlCaps.mm.

◆ kGridCellSize

constexpr int skgpu::graphite::kGridCellSize = 16
staticconstexpr

Definition at line 321 of file Device.cpp.

◆ kIncrementCW

constexpr DepthStencilSettings::Face skgpu::graphite::kIncrementCW
constexpr
Initial value:
= {
StencilOp::kKeep,
StencilOp::kKeep,
StencilOp::kIncWrap,
CompareOp::kAlways,
0xffffffff,
0xffffffff
}

"stencil" pass DepthStencilSettings reusable for RenderSteps following some form of stencil-then-cover multi-pass algorithm.

Definition at line 46 of file CommonDepthStencilSettings.h.

◆ kIndexCount [1/2]

constexpr int skgpu::graphite::kIndexCount = 69
staticconstexpr

Definition at line 257 of file AnalyticRRectRenderStep.cpp.

◆ kIndexCount [2/2]

constexpr int skgpu::graphite::kIndexCount = 29
staticconstexpr

Definition at line 129 of file PerEdgeAAQuadRenderStep.cpp.

◆ kIndirectDispatchArgumentSize

constexpr size_t skgpu::graphite::kIndirectDispatchArgumentSize = sizeof(IndirectDispatchArgs)
constexpr

Definition at line 24 of file ComputeTypes.h.

◆ kInverseCoverPass

constexpr DepthStencilSettings skgpu::graphite::kInverseCoverPass
constexpr
Initial value:
= {
0,
true,
CompareOp::kGreater,
true,
true
}
constexpr DepthStencilSettings::Face kPassZero

Definition at line 141 of file CommonDepthStencilSettings.h.

◆ kLoadOpCount

constexpr int skgpu::graphite::kLoadOpCount = (int)(LoadOp::kLast) + 1
inlinestaticconstexpr

Definition at line 41 of file ResourceTypes.h.

◆ kMaxBruteForceN

constexpr int skgpu::graphite::kMaxBruteForceN = 64
staticconstexpr

Definition at line 322 of file Device.cpp.

◆ kMaxComputeDataFlowSlots

constexpr int skgpu::graphite::kMaxComputeDataFlowSlots = 28
constexpr

Definition at line 16 of file ComputeTypes.h.

◆ kMaxGridSize

constexpr int skgpu::graphite::kMaxGridSize = 32
staticconstexpr

Definition at line 323 of file Device.cpp.

◆ kMaxNumberOfCachedBufferDescSets

constexpr int skgpu::graphite::kMaxNumberOfCachedBufferDescSets = 1024
constexpr

Definition at line 42 of file VulkanResourceProvider.cpp.

◆ kMtlFormats

constexpr MTLPixelFormat skgpu::graphite::kMtlFormats[]
staticconstexpr

Definition at line 228 of file MtlCaps.mm.

◆ kNoChildren

constexpr int skgpu::graphite::kNoChildren = 0
staticconstexpr

Definition at line 37 of file ShaderCodeDictionary.cpp.

◆ kPassNonZero

constexpr DepthStencilSettings::Face skgpu::graphite::kPassNonZero
constexpr
Initial value:
= {
StencilOp::kKeep,
StencilOp::kZero,
StencilOp::kZero,
CompareOp::kNotEqual,
0xffffffff,
0xffffffff
}

"cover" pass DepthStencilSettings reusable for RenderSteps following some form of stencil-then-cover multi-pass algorithm.

Definition at line 108 of file CommonDepthStencilSettings.h.

◆ kPassZero

constexpr DepthStencilSettings::Face skgpu::graphite::kPassZero
constexpr
Initial value:
= {
StencilOp::kZero,
StencilOp::kKeep,
StencilOp::kKeep,
CompareOp::kEqual,
0xffffffff,
0xffffffff
}

Definition at line 118 of file CommonDepthStencilSettings.h.

◆ kPlotRecentlyUsedCount

constexpr auto skgpu::graphite::kPlotRecentlyUsedCount = 32
staticconstexpr

Definition at line 186 of file DrawAtlas.cpp.

◆ kRegularCoverPass

constexpr DepthStencilSettings skgpu::graphite::kRegularCoverPass
constexpr
Initial value:
= {
0,
true,
CompareOp::kGreater,
true,
true
}
constexpr DepthStencilSettings::Face kPassNonZero

Definition at line 129 of file CommonDepthStencilSettings.h.

◆ kReusedBufferSize

constexpr size_t skgpu::graphite::kReusedBufferSize = 64 << 10
staticconstexpr

Definition at line 20 of file UploadBufferManager.cpp.

◆ kRuntimeEffectColorSpaceTransformUniforms

constexpr Uniform skgpu::graphite::kRuntimeEffectColorSpaceTransformUniforms[]
staticconstexpr
Initial value:
= {
{ "flags_toLinear", SkSLType::kInt },
{ "srcKind_toLinear", SkSLType::kInt },
{ "gamutTransform_toLinear", SkSLType::kHalf3x3 },
{ "dstKind_toLinear", SkSLType::kInt },
{ "csXformCoeffs_toLinear", SkSLType::kHalf4x4 },
{ "flags_fromLinear", SkSLType::kInt },
{ "srcKind_fromLinear", SkSLType::kInt },
{ "gamutTransform_fromLinear", SkSLType::kHalf3x3 },
{ "dstKind_fromLinear", SkSLType::kInt },
{ "csXformCoeffs_fromLinear", SkSLType::kHalf4x4 },
}

Definition at line 46 of file ShaderCodeDictionary.cpp.

◆ kRuntimeShaderName

constexpr char skgpu::graphite::kRuntimeShaderName[] = "RuntimeEffect"
staticconstexpr

Definition at line 38 of file ShaderCodeDictionary.cpp.

◆ kSaveStackIncrement

constexpr int skgpu::graphite::kSaveStackIncrement = 8
staticconstexpr

Definition at line 964 of file ClipStack_graphite.cpp.

◆ kSmallPathPlotHeight

constexpr uint32_t skgpu::graphite::kSmallPathPlotHeight = 256
staticconstexpr

Definition at line 24 of file RasterPathAtlas.cpp.

◆ kSmallPathPlotWidth

constexpr uint32_t skgpu::graphite::kSmallPathPlotWidth = 512
staticconstexpr

Definition at line 23 of file RasterPathAtlas.cpp.

◆ kSolidInterior

constexpr float skgpu::graphite::kSolidInterior = 1.f
staticconstexpr

Definition at line 247 of file AnalyticRRectRenderStep.cpp.

◆ kStencilOpCount

constexpr int skgpu::graphite::kStencilOpCount = 1 + (int)StencilOp::kDecClamp
staticconstexpr

Definition at line 173 of file DrawTypes.h.

◆ kStoreOpCount

constexpr int skgpu::graphite::kStoreOpCount = (int)(StoreOp::kLast) + 1
inlinestaticconstexpr

Definition at line 52 of file ResourceTypes.h.

◆ kStrokeInterior

constexpr float skgpu::graphite::kStrokeInterior = 0.f
staticconstexpr

Definition at line 248 of file AnalyticRRectRenderStep.cpp.

◆ kToggle

constexpr DepthStencilSettings::Face skgpu::graphite::kToggle
constexpr
Initial value:
= {
StencilOp::kKeep,
StencilOp::kKeep,
StencilOp::kInvert,
CompareOp::kAlways,
0xffffffff,
0x00000001
}

Definition at line 66 of file CommonDepthStencilSettings.h.

◆ kVelloSlot_BinHeader

constexpr int skgpu::graphite::kVelloSlot_BinHeader = 17
constexpr

Definition at line 154 of file VelloComputeSteps.h.

◆ kVelloSlot_BumpAlloc

constexpr int skgpu::graphite::kVelloSlot_BumpAlloc = 16
constexpr

Definition at line 153 of file VelloComputeSteps.h.

◆ kVelloSlot_ClipBBoxes

constexpr int skgpu::graphite::kVelloSlot_ClipBBoxes = 14
constexpr

Definition at line 145 of file VelloComputeSteps.h.

◆ kVelloSlot_ClipBicyclic

constexpr int skgpu::graphite::kVelloSlot_ClipBicyclic = 12
constexpr

Definition at line 143 of file VelloComputeSteps.h.

◆ kVelloSlot_ClipElement

constexpr int skgpu::graphite::kVelloSlot_ClipElement = 13
constexpr

Definition at line 144 of file VelloComputeSteps.h.

◆ kVelloSlot_ClipInput

constexpr int skgpu::graphite::kVelloSlot_ClipInput = 11
constexpr

Definition at line 134 of file VelloComputeSteps.h.

◆ kVelloSlot_ConfigUniform

constexpr int skgpu::graphite::kVelloSlot_ConfigUniform = 0
constexpr

Definition at line 90 of file VelloComputeSteps.h.

◆ kVelloSlot_DrawBBoxes

constexpr int skgpu::graphite::kVelloSlot_DrawBBoxes = 15
constexpr

Definition at line 152 of file VelloComputeSteps.h.

◆ kVelloSlot_DrawMonoid

constexpr int skgpu::graphite::kVelloSlot_DrawMonoid = 9
constexpr

Definition at line 132 of file VelloComputeSteps.h.

◆ kVelloSlot_DrawReduceOutput

constexpr int skgpu::graphite::kVelloSlot_DrawReduceOutput = 8
constexpr

Definition at line 131 of file VelloComputeSteps.h.

◆ kVelloSlot_GradientImage

constexpr int skgpu::graphite::kVelloSlot_GradientImage = 24
constexpr

Definition at line 169 of file VelloComputeSteps.h.

◆ kVelloSlot_ImageAtlas

constexpr int skgpu::graphite::kVelloSlot_ImageAtlas = 25
constexpr

Definition at line 170 of file VelloComputeSteps.h.

◆ kVelloSlot_IndirectCount

constexpr int skgpu::graphite::kVelloSlot_IndirectCount = 26
constexpr

Definition at line 175 of file VelloComputeSteps.h.

◆ kVelloSlot_InfoBinData

constexpr int skgpu::graphite::kVelloSlot_InfoBinData = 10
constexpr

Definition at line 133 of file VelloComputeSteps.h.

◆ kVelloSlot_LargePathtagReduceFirstPassOutput

constexpr int skgpu::graphite::kVelloSlot_LargePathtagReduceFirstPassOutput = kVelloSlot_PathtagReduceOutput
constexpr

Definition at line 112 of file VelloComputeSteps.h.

◆ kVelloSlot_LargePathtagReduceSecondPassOutput

constexpr int skgpu::graphite::kVelloSlot_LargePathtagReduceSecondPassOutput = 4
constexpr

Definition at line 113 of file VelloComputeSteps.h.

◆ kVelloSlot_LargePathtagScanFirstPassOutput

constexpr int skgpu::graphite::kVelloSlot_LargePathtagScanFirstPassOutput = 5
constexpr

Definition at line 114 of file VelloComputeSteps.h.

◆ kVelloSlot_Lines

constexpr int skgpu::graphite::kVelloSlot_Lines = 7
constexpr

Definition at line 124 of file VelloComputeSteps.h.

◆ kVelloSlot_MaskLUT

constexpr int skgpu::graphite::kVelloSlot_MaskLUT = 27
constexpr

Definition at line 179 of file VelloComputeSteps.h.

◆ kVelloSlot_OutputImage

constexpr int skgpu::graphite::kVelloSlot_OutputImage = 23
constexpr

Definition at line 168 of file VelloComputeSteps.h.

◆ kVelloSlot_Path

constexpr int skgpu::graphite::kVelloSlot_Path = 18
constexpr

Definition at line 156 of file VelloComputeSteps.h.

◆ kVelloSlot_PathBBoxes

constexpr int skgpu::graphite::kVelloSlot_PathBBoxes = 6
constexpr

Definition at line 123 of file VelloComputeSteps.h.

◆ kVelloSlot_PathtagReduceOutput

constexpr int skgpu::graphite::kVelloSlot_PathtagReduceOutput = 3
constexpr

Definition at line 109 of file VelloComputeSteps.h.

◆ kVelloSlot_PTCL

constexpr int skgpu::graphite::kVelloSlot_PTCL = 22
constexpr

Definition at line 160 of file VelloComputeSteps.h.

◆ kVelloSlot_Scene

constexpr int skgpu::graphite::kVelloSlot_Scene = 1
constexpr

Definition at line 93 of file VelloComputeSteps.h.

◆ kVelloSlot_SegmentCounts

constexpr int skgpu::graphite::kVelloSlot_SegmentCounts = 20
constexpr

Definition at line 158 of file VelloComputeSteps.h.

◆ kVelloSlot_Segments

constexpr int skgpu::graphite::kVelloSlot_Segments = 21
constexpr

Definition at line 159 of file VelloComputeSteps.h.

◆ kVelloSlot_TagMonoid

constexpr int skgpu::graphite::kVelloSlot_TagMonoid = 2
constexpr

Definition at line 106 of file VelloComputeSteps.h.

◆ kVelloSlot_Tile

constexpr int skgpu::graphite::kVelloSlot_Tile = 19
constexpr

Definition at line 157 of file VelloComputeSteps.h.

◆ kVertexAttribTypeCount

const int skgpu::graphite::kVertexAttribTypeCount = (int)(VertexAttribType::kLast) + 1
static

Definition at line 71 of file DrawTypes.h.

◆ kVertexCount [1/2]

constexpr int skgpu::graphite::kVertexCount = 4 * kCornerVertexCount
staticconstexpr

Definition at line 256 of file AnalyticRRectRenderStep.cpp.

◆ kVertexCount [2/2]

constexpr int skgpu::graphite::kVertexCount = 4 * kCornerVertexCount
staticconstexpr

Definition at line 128 of file PerEdgeAAQuadRenderStep.cpp.

◆ kVkFormats

constexpr VkFormat skgpu::graphite::kVkFormats[]
staticconstexpr

◆ kWindingStencilPass

constexpr DepthStencilSettings skgpu::graphite::kWindingStencilPass
constexpr
Initial value:
= {
0,
true,
CompareOp::kGreater,
true,
false
}
constexpr DepthStencilSettings::Face kDecrementCCW
constexpr DepthStencilSettings::Face kIncrementCW

Definition at line 77 of file CommonDepthStencilSettings.h.

◆ vkLoadOp

const VkAttachmentLoadOp skgpu::graphite::vkLoadOp[]
static
Initial value:

Definition at line 27 of file VulkanRenderPass.h.

◆ vkStoreOp

const VkAttachmentStoreOp skgpu::graphite::vkStoreOp[]
static
Initial value:

Definition at line 23 of file VulkanRenderPass.h.