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

Namespaces

namespace  ContextFactory
 
namespace  DrawPassCommands
 
namespace  LayoutRules
 
namespace  PrecompileBlenders
 
namespace  PrecompileColorFilters
 
namespace  PrecompileColorFiltersPriv
 
namespace  PrecompileShaders
 
namespace  PrecompileShadersPriv
 

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  IndirectDispatchArgs
 
struct  InsertFinishInfo
 
struct  InsertRecordingInfo
 
class  IntersectionTree
 
class  IntersectionTreeBench
 
class  KeyContext
 
class  KeyContextWithColorInfo
 
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  PrecompileBlendModeBlender
 
class  PrecompileBlendModeColorFilter
 
class  PrecompileBlendShader
 
class  PrecompileBlurMaskFilter
 
class  PrecompileBlurShader
 
class  PrecompileChildPtr
 
class  PrecompileColorFilter
 
class  PrecompileColorFilterShader
 
class  PrecompileColorShader
 
class  PrecompileColorSpaceXformColorFilter
 
class  PrecompileComposeColorFilter
 
class  PrecompileCoordClampShader
 
class  PrecompileCTMShader
 
class  PrecompileEmptyShader
 
class  PrecompileGaussianColorFilter
 
class  PrecompileGradientShader
 
class  PrecompileImageShader
 
class  PrecompileLocalMatrixShader
 
class  PrecompileMaskFilter
 
class  PrecompileMaskFilters
 
class  PrecompileMatrixColorFilter
 
class  PrecompilePerlinNoiseShader
 
class  PrecompileRTEffect
 
class  PrecompileShader
 
class  PrecompileTableColorFilter
 
class  PrecompileWithWorkingFormatColorFilter
 
class  PrecompileWorkingColorSpaceShader
 
class  PrecompileYUVImageShader
 
class  ProxyCache
 
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  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  VulkanSamplerYcbcrConversion
 
class  VulkanSharedContext
 
class  VulkanTexture
 
struct  VulkanTextureInfo
 
struct  VulkanTextureSpec
 
class  VulkanWorkSubmission
 
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 ,
  kRadialGradientShader4 , kRadialGradientShader8 , kRadialGradientShaderTexture , kSweepGradientShader4 ,
  kSweepGradientShader8 , kSweepGradientShaderTexture , kConicalGradientShader4 , kConicalGradientShader8 ,
  kConicalGradientShaderTexture , kLocalMatrixShader , kImageShader , kCubicImageShader ,
  kHWImageShader , kYUVImageShader , kCubicYUVImageShader , 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 }
 
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  PrecompileImageShaderFlags { kNone = 0b00 , kExcludeAlpha = 0b01 , kExcludeCubic = 0b10 }
 
enum class  DstColorType { kSurface , kPrimitive , kChildOutput }
 
enum class  Priority : int { kFatal = 0 , kError = 1 , kWarning = 2 , kDebug = 3 }
 
enum class  PrecompileImageFilters : uint32_t { kNone = 0x0 , kBlur = 0x1 }
 
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
}
 

Functions

SK_API void DawnNativeProcessEventsFunction (const wgpu::Instance &instance)
 
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, 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 (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 ()
 
sk_sp< TextureProxyadd_copy_target_task (Recorder *recorder, sk_sp< TextureProxy > target, const SkImageInfo &targetInfo, const SkIPoint &targetOffset)
 
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 bool can_do_tiling_in_hw (const Caps *caps, const ImageShaderBlock::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 *, 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)
 
MTLPixelFormat MtlDepthStencilFlagsToFormat (SkEnumBitMask< DepthStencilFlags > mask)
 
SkEnumBitMask< DepthStencilFlagsMtlFormatToDepthStencilFlags (MTLPixelFormat format)
 
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 int32_t > keyData, int currentIndex)
 
DstReadRequirement get_dst_read_req (const Caps *caps, Coverage coverage, PrecompileBlender *blender)
 
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)
 
void Precompile (Context *context, const PaintOptions &options, DrawTypeFlags drawTypes)
 
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)
 
sk_sp< TextureProxyMakePromiseImageLazyProxy (const Caps *caps, SkISize dimensions, TextureInfo textureInfo, Volatile isVolatile, sk_sp< RefCntedCallback > releaseHelper, GraphitePromiseTextureFulfillProc fulfillProc, GraphitePromiseTextureFulfillContext fulfillContext, GraphitePromiseTextureReleaseProc textureReleaseProc)
 
sk_sp< SkImageMakeFromBitmap (Recorder *recorder, const SkColorInfo &colorInfo, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmaps, Budgeted budgeted, SkImage::RequiredProperties requiredProps)
 
size_t ComputeSize (SkISize dimensions, const TextureInfo &info)
 
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)
 
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_GRAPHITE_TEST_FOR_ALL_CONTEXTS (ProxyCacheTest3, 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)
 
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 const char * kBufferTypeNames [kBufferTypeCount]
 
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 []
 

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

using skgpu::graphite::DrawCallback = typedef std::function<void(SkCanvas*)>

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 189 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 133 of file ResourceTypes.h.

◆ Status

Definition at line 13 of file TaskList.cpp.

◆ TextureDataCache

Definition at line 60 of file Recorder.h.

◆ UniformDataCache

Definition at line 59 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 100 of file ResourceTypes.h.

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

◆ 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 56 of file ResourceTypes.h.

◆ BuiltInCodeSnippetID

enum class skgpu::graphite::BuiltInCodeSnippetID : int32_t
strong
Enumerator
kError 
kPriorOutput 
kSolidColorShader 
kRGBPaintColor 
kAlphaOnlyPaintColor 
kLinearGradientShader4 
kLinearGradientShader8 
kLinearGradientShaderTexture 
kRadialGradientShader4 
kRadialGradientShader8 
kRadialGradientShaderTexture 
kSweepGradientShader4 
kSweepGradientShader8 
kSweepGradientShaderTexture 
kConicalGradientShader4 
kConicalGradientShader8 
kConicalGradientShaderTexture 
kLocalMatrixShader 
kImageShader 
kCubicImageShader 
kHWImageShader 
kYUVImageShader 
kCubicYUVImageShader 
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
40
51
52 // SkColorFilter code snippets
57
58 // SkBlender code snippets
62
63 // Emits special variable holding the primitiveColor emitted by a RenderStep
65
66 // Dest Read code snippets
69
70 // Clip shader snippet
71 // TODO(b/238763003): Avoid incorporating clip shaders into the actual shader code.
73
74 kCompose,
75
76 // Fixed-function blend modes are used for the final blend with the dst buffer's color when the
77 // SkPaint is using a coefficient-based SkBlendMode. The actual coefficients are extracted into
78 // the SkBlendInfo associated with each pipeline, but a unique code snippet ID is assigned so
79 // that the pipeline keys remain distinct. They are ordered to match SkBlendMode such
80 // that (id - kFirstFixedFunctionBlendMode) == SkBlendMode).
81 //
82 // NOTE: Pipeline code generation depends on the fixed-function code IDs being contiguous and
83 // be defined last in the enum.
99
102};

◆ 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 113 of file ResourceTypes.h.

113 : bool {
114 kNo = false,
115 kYes = true,
116};
@ 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 147 of file DrawTypes.h.

147 : uint8_t {
148 kAlways,
149 kNever,
150 kGreater,
151 kGEqual,
152 kLess,
153 kLEqual,
154 kEqual,
156};
constexpr auto kNever
Definition SkSLTest.cpp:958

◆ 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 22 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 18 of file DescriptorData.h.

18 : uint8_t {
19 kUniformBuffer = 0,
23 kStorageBuffer,
24 kInputAttachment,
25
26 kLast = kInputAttachment,
27};

◆ 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 122 of file ResourceTypes.h.

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

◆ 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};
constexpr char kText[]
Definition glyph_pos.cpp:28

◆ DstColorType

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

Definition at line 40 of file KeyHelpers.h.

40 {
41 // A color read from the framebuffer.
43 // A color provided by geometry.
45 // A color evaluated by a child shader.
47};

◆ DstReadRequirement

Enumerator
kNone 
kTextureCopy 
kTextureSample 
kFramebufferFetch 

Definition at line 63 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 148 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 76 of file ResourceTypes.h.

76 {
77 kInvalid = 0,
78 kStd140,
79 kStd430,
80 kMetal,
81};
@ 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 33 of file ResourceTypes.h.

33 : uint8_t {
34 kLoad,
35 kClear,
37
39};
@ kClear
r = 0

◆ Ownership

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

Definition at line 127 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};

◆ PipelineStageFlags

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

Definition at line 30 of file DescriptorData.h.

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

◆ PrecompileImageFilters

enum class skgpu::graphite::PrecompileImageFilters : uint32_t
strong
Enumerator
kNone 
kBlur 

Definition at line 161 of file Precompile.h.

161 : uint32_t {
162 kNone = 0x0,
163 kBlur = 0x1,
164};

◆ PrecompileImageShaderFlags

Enumerator
kNone 
kExcludeAlpha 
kExcludeCubic 

Definition at line 18 of file FactoryFunctionsPriv.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 {
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 139 of file ResourceTypes.h.

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

◆ SnippetRequirementFlags

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

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

◆ StencilOp

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

Definition at line 159 of file DrawTypes.h.

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

◆ 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 45 of file ResourceTypes.h.

45 : uint8_t {
46 kStore,
48
50};

◆ 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 

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

◆ VelloAaConfig

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

Definition at line 63 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
70};
static constexpr uint16_t kHalf

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

sk_sp< TextureProxy > skgpu::graphite::add_copy_target_task ( Recorder recorder,
sk_sp< TextureProxy target,
const SkImageInfo targetInfo,
const SkIPoint targetOffset 
)

Definition at line 415 of file DrawPass.cpp.

418 {
419 SkASSERT(recorder->priv().caps()->isTexturable(target->textureInfo()));
420 SkIRect dstSrcRect = SkIRect::MakePtSize(targetOffset, targetInfo.dimensions());
421 sk_sp<TextureProxy> copy = TextureProxy::Make(recorder->priv().caps(),
422 recorder->priv().resourceProvider(),
423 targetInfo.dimensions(),
424 target->textureInfo(),
426 if (!copy) {
427 SKGPU_LOG_W("Failed to create destination copy texture for dst read.");
428 return nullptr;
429 }
430
431 sk_sp<CopyTextureToTextureTask> copyTask = CopyTextureToTextureTask::Make(
432 std::move(target), dstSrcRect, copy, /*dstPoint=*/{0, 0});
433 if (!copyTask) {
434 SKGPU_LOG_W("Failed to create destination copy task for dst read.");
435 return nullptr;
436 }
437
438 recorder->priv().add(std::move(copyTask));
439 return copy;
440}
#define SKGPU_LOG_W(fmt,...)
Definition Log.h:40
#define SkASSERT(cond)
Definition SkAssert.h:116
bool isTexturable(const TextureInfo &) const
Definition Caps.cpp:65
const Caps * caps() const
ResourceProvider * resourceProvider()
void add(sk_sp< Task >)
Definition Recorder.cpp:477
uint32_t * target
Definition copy.py:1
static constexpr SkIRect MakePtSize(SkIPoint pt, SkISize size)
Definition SkRect.h:78
SkISize dimensions() const

◆ 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 2074 of file KeyHelpers.cpp.

2077 {
2078 add_gradient_to_key(keyContext,
2079 builder,
2080 gatherer,
2081 shader,
2082 shader->getStartCenter(),
2083 shader->getEndCenter(),
2084 shader->getStartRadius(),
2085 shader->getEndRadius(),
2086 0.0f,
2087 0.0f);
2088}
const SkPoint & getEndCenter() const
SkScalar getEndRadius() const
const SkPoint & getStartCenter() const
SkScalar getStartRadius() const
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)

◆ 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 2015 of file KeyHelpers.cpp.

2024 {
2025 SkColor4fXformer xformedColors(shader, keyContext.dstColorInfo().colorSpace());
2026 const SkPMColor4f* colors = xformedColors.fColors.begin();
2027 const float* positions = xformedColors.fPositions;
2028 const int colorCount = xformedColors.fColors.size();
2029
2030 sk_sp<TextureProxy> proxy;
2031
2032 if (colorCount > GradientShaderBlocks::GradientData::kNumInternalStorageStops) {
2033 if (shader->cachedBitmap().empty()) {
2034 SkBitmap colorsAndOffsetsBitmap =
2035 create_color_and_offset_bitmap(colorCount, colors, positions);
2036 if (colorsAndOffsetsBitmap.empty()) {
2037 SKGPU_LOG_W("Couldn't create GradientShader's color and offset bitmap");
2038 builder->addBlock(BuiltInCodeSnippetID::kError);
2039 return;
2040 }
2041 shader->setCachedBitmap(colorsAndOffsetsBitmap);
2042 }
2043
2044 proxy = RecorderPriv::CreateCachedProxy(keyContext.recorder(), shader->cachedBitmap());
2045 if (!proxy) {
2046 SKGPU_LOG_W("Couldn't create GradientShader's color and offset bitmap proxy");
2047 builder->addBlock(BuiltInCodeSnippetID::kError);
2048 return;
2049 }
2050 }
2051
2052 GradientShaderBlocks::GradientData data(shader->asGradient(),
2053 point0,
2054 point1,
2055 radius0,
2056 radius1,
2057 bias,
2058 scale,
2059 shader->getTileMode(),
2060 colorCount,
2061 colors,
2062 positions,
2063 std::move(proxy),
2064 shader->getInterpolation());
2065
2066 make_interpolated_to_dst(keyContext,
2067 builder,
2068 gatherer,
2069 data,
2070 shader->getInterpolation(),
2071 xformedColors.fIntermediateColorSpace.get());
2072}
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)
bool empty() const
Definition SkBitmap.h:210
SkColorSpace * colorSpace() const
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
Recorder * recorder() const
Definition KeyContext.h:55
const SkColorInfo & dstColorInfo() const
Definition KeyContext.h:65
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
static SkBitmap create_color_and_offset_bitmap(int numStops, const SkPMColor4f *colors, const float *offsets)
const Scalar scale

◆ 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 2090 of file KeyHelpers.cpp.

2093 {
2094 add_gradient_to_key(keyContext,
2095 builder,
2096 gatherer,
2097 shader,
2098 shader->start(),
2099 shader->end(),
2100 0.0f,
2101 0.0f,
2102 0.0f,
2103 0.0f);
2104}
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 2106 of file KeyHelpers.cpp.

2109 {
2110 add_gradient_to_key(keyContext,
2111 builder,
2112 gatherer,
2113 shader,
2114 shader->center(),
2115 { 0.0f, 0.0f },
2116 shader->radius(),
2117 0.0f,
2118 0.0f,
2119 0.0f);
2120}
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 2122 of file KeyHelpers.cpp.

2125 {
2126 add_gradient_to_key(keyContext,
2127 builder,
2128 gatherer,
2129 shader,
2130 shader->center(),
2131 { 0.0f, 0.0f },
2132 0.0f,
2133 0.0f,
2134 shader->tBias(),
2135 shader->tScale());
2136}
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 1166 of file KeyHelpers.cpp.

1169 {
1170 SkASSERT(filter);
1171
1173 keyContext.dstColorInfo().colorSpace());
1174
1175 AddBlendModeColorFilter(keyContext, builder, gatherer, filter->mode(), color);
1176}
SkColor4f color
static SkRGBA4f< kDstAT > map_color(const SkColor4f &c, SkColorSpace *src, SkColorSpace *dst)
SkColorSpace * sk_srgb_singleton()
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 1355 of file KeyHelpers.cpp.

1358 {
1359 SkASSERT(shader);
1360
1361 Blend(keyContext, builder, gatherer,
1362 /* addBlendToKey= */ [&] () -> void {
1363 AddModeBlend(keyContext, builder, gatherer, shader->mode());
1364 },
1365 /* addSrcToKey= */ [&]() -> void {
1366 AddToKey(keyContext, builder, gatherer, shader->src().get());
1367 },
1368 /* addDstToKey= */ [&]() -> void {
1369 AddToKey(keyContext, builder, gatherer, shader->dst().get());
1370 });
1371}
sk_sp< SkShader > dst() const
SkBlendMode mode() const
sk_sp< SkShader > src() const
T * get() const
Definition SkRefCnt.h:303
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 1413 of file KeyHelpers.cpp.

1416 {
1417 SkASSERT(shader);
1418
1419 SkPMColor4f color = map_color(shader->color(), shader->colorSpace().get(),
1420 keyContext.dstColorInfo().colorSpace());
1421
1422 SolidColorShaderBlock::AddBlock(keyContext, builder, gatherer, color);
1423}
SkColor4f color() const
sk_sp< SkColorSpace > colorSpace() const

◆ 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 1428 of file KeyHelpers.cpp.

1431 {
1432 SkASSERT(shader);
1433
1434 Compose(keyContext, builder, gatherer,
1435 /* addInnerToKey= */ [&]() -> void {
1436 AddToKey(keyContext, builder, gatherer, shader->shader().get());
1437 },
1438 /* addOuterToKey= */ [&]() -> void {
1439 AddToKey(keyContext, builder, gatherer, shader->filter().get());
1440 });
1441}
sk_sp< SkColorFilterBase > filter() const
sk_sp< SkShader > shader() const
void AddToKey(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, const SkBlender *blender)

◆ 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 1400 of file KeyHelpers.cpp.

1403 {
1404 SkASSERT(shader);
1405
1406 SolidColorShaderBlock::AddBlock(keyContext, builder, gatherer,
1407 SkColor4f::FromColor(shader->color()).premul());
1408}
SkColor color() const
SkRGBA4f< kPremul_SkAlphaType > premul() const
Definition SkColor.h:385
static SkRGBA4f FromColor(SkColor color)

◆ 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 1178 of file KeyHelpers.cpp.

1181 {
1182 SkASSERT(filter);
1183
1184 constexpr SkAlphaType kAlphaType = kPremul_SkAlphaType;
1185 ColorSpaceTransformBlock::ColorSpaceTransformData csData(filter->src().get(), kAlphaType,
1186 filter->dst().get(), kAlphaType);
1187 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, csData);
1188}
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 1449 of file KeyHelpers.cpp.

1452 {
1453 SkASSERT(shader);
1454
1456
1457 CoordClampShaderBlock::BeginBlock(keyContext, builder, gatherer, data);
1458 AddToKey(keyContext, builder, gatherer, shader->shader().get());
1459 builder->endBlock();
1460}
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 1380 of file KeyHelpers.cpp.

1383 {
1384 // CTM shaders are always given device coordinates, so we don't have to modify the CTM itself
1385 // with keyContext's local transform.
1386 LocalMatrixShaderBlock::LMShaderData lmShaderData(shader->ctm());
1387
1388 KeyContextWithLocalMatrix newContext(keyContext, shader->ctm());
1389
1390 LocalMatrixShaderBlock::BeginBlock(newContext, builder, gatherer, lmShaderData);
1391
1392 AddToKey(newContext, builder, gatherer, shader->proxyShader().get());
1393
1394 builder->endBlock();
1395}
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 1467 of file KeyHelpers.cpp.

1470 {
1471 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
1472}

◆ 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 1205 of file KeyHelpers.cpp.

1208 {
1209 builder->addBlock(BuiltInCodeSnippetID::kGaussianColorFilter);
1210}

◆ 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 2138 of file KeyHelpers.cpp.

2141 {
2142 SkASSERT(shader);
2143 switch (shader->asGradient()) {
2144#define M(type) \
2145 case SkShaderBase::GradientType::k##type: \
2146 add_gradient_to_key(keyContext, \
2147 builder, \
2148 gatherer, \
2149 static_cast<const Sk##type##Gradient*>(shader)); \
2150 return;
2152#undef M
2154 SkDEBUGFAIL("Gradient shader says its type is none");
2155 return;
2156 }
2158}
#define M(type)
#define SkUNREACHABLE
Definition SkAssert.h:135
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
#define SK_ALL_GRADIENTS(M)

◆ 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 1617 of file KeyHelpers.cpp.

1620 {
1621 SkASSERT(shader);
1622
1623 auto [ imageToDraw, newSampling ] = GetGraphiteBacked(keyContext.recorder(),
1624 shader->image().get(),
1625 shader->sampling());
1626 if (!imageToDraw) {
1627 SKGPU_LOG_W("Couldn't convert ImageShader's image to a Graphite-backed image");
1628 builder->addBlock(BuiltInCodeSnippetID::kError);
1629 return;
1630 }
1631 if (as_IB(imageToDraw)->isYUVA()) {
1632 return add_yuv_image_to_key(keyContext,
1633 builder,
1634 gatherer,
1635 shader,
1636 std::move(imageToDraw),
1637 newSampling);
1638 }
1639
1640 auto view = AsView(imageToDraw.get());
1641 SkASSERT(newSampling.mipmap == SkMipmapMode::kNone || view.mipmapped() == Mipmapped::kYes);
1642
1643 ImageShaderBlock::ImageData imgData(shader->sampling(),
1644 shader->tileModeX(),
1645 shader->tileModeY(),
1646 view.proxy()->dimensions(),
1647 shader->subset(),
1648 ReadSwizzle::kRGBA);
1649 imgData.fSampling = newSampling;
1650 imgData.fTextureProxy = view.refProxy();
1651 skgpu::Swizzle readSwizzle = view.swizzle();
1652 // If the color type is alpha-only, propagate the alpha value to the other channels.
1653 if (imageToDraw->isAlphaOnly()) {
1654 readSwizzle = skgpu::Swizzle::Concat(readSwizzle, skgpu::Swizzle("000a"));
1655 }
1656 imgData.fReadSwizzle = swizzle_class_to_read_enum(readSwizzle);
1657
1658 if (!shader->isRaw()) {
1659 imgData.fSteps = SkColorSpaceXformSteps(imageToDraw->colorSpace(),
1660 imageToDraw->alphaType(),
1661 keyContext.dstColorInfo().colorSpace(),
1662 keyContext.dstColorInfo().alphaType());
1663
1664 if (imageToDraw->isAlphaOnly() && keyContext.scope() != KeyContext::Scope::kRuntimeEffect) {
1665 Blend(keyContext, builder, gatherer,
1666 /* addBlendToKey= */ [&] () -> void {
1667 AddKnownModeBlend(keyContext, builder, gatherer, SkBlendMode::kDstIn);
1668 },
1669 /* addSrcToKey= */ [&] () -> void {
1670 ImageShaderBlock::AddBlock(keyContext, builder, gatherer, imgData);
1671 },
1672 /* addDstToKey= */ [&]() -> void {
1673 RGBPaintColorBlock::AddBlock(keyContext, builder, gatherer);
1674 });
1675 return;
1676 }
1677 }
1678
1679 ImageShaderBlock::AddBlock(keyContext, builder, gatherer, imgData);
1680}
@ kDstIn
r = d * sa
static SkImage_Base * as_IB(SkImage *image)
SkAlphaType alphaType() const
SkSamplingOptions sampling() const
SkTileMode tileModeX() const
sk_sp< SkImage > image() const
bool isRaw() const
SkTileMode tileModeY() const
SkRect subset() const
static constexpr Swizzle Concat(const Swizzle &a, const Swizzle &b)
Definition Swizzle.h:156
void AddKnownModeBlend(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)
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 1695 of file KeyHelpers.cpp.

1698 {
1699 SkASSERT(shader);
1700 auto wrappedShader = shader->wrappedShader().get();
1701
1702 // Fold the texture's origin flip into the local matrix so that the image shader doesn't need
1703 // additional state
1704 SkMatrix matrix;
1705 if (as_SB(wrappedShader)->type() == SkShaderBase::ShaderType::kImage) {
1706 auto imgShader = static_cast<const SkImageShader*>(wrappedShader);
1707 // If the image is not graphite backed then we can assume the origin will be TopLeft as we
1708 // require that in the ImageProvider utility. Also Graphite YUV images are assumed to be
1709 // TopLeft origin.
1710 // TODO (b/336788317): Fold YUVAImage's origin into this matrix as well.
1711 auto imgBase = as_IB(imgShader->image());
1712 if (imgBase->isGraphiteBacked() && !imgBase->isYUVA()) {
1713 auto imgGraphite = static_cast<Image*>(imgBase);
1714 SkASSERT(imgGraphite);
1715 const auto& view = imgGraphite->textureProxyView();
1716 if (view.origin() == Origin::kBottomLeft) {
1717 matrix.setScaleY(-1);
1718 matrix.setTranslateY(view.height());
1719 }
1720 }
1721 }
1722
1723 matrix.postConcat(shader->localMatrix());
1724 LocalMatrixShaderBlock::LMShaderData lmShaderData(matrix);
1725
1726 KeyContextWithLocalMatrix newContext(keyContext, matrix);
1727
1728 LocalMatrixShaderBlock::BeginBlock(newContext, builder, gatherer, lmShaderData);
1729
1730 AddToKey(newContext, builder, gatherer, wrappedShader);
1731
1732 builder->endBlock();
1733}
SkShaderBase * as_SB(SkShader *shader)
const SkMatrix & localMatrix() const
sk_sp< SkShader > wrappedShader() const
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 1212 of file KeyHelpers.cpp.

1215 {
1216 SkASSERT(filter);
1217
1218 bool inHSLA = filter->domain() == SkMatrixColorFilter::Domain::kHSLA;
1219 MatrixColorFilterBlock::MatrixColorFilterData matrixCFData(filter->matrix(), inHSLA);
1220
1221 MatrixColorFilterBlock::AddBlock(keyContext, builder, gatherer, matrixCFData);
1222}
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 1747 of file KeyHelpers.cpp.

1750 {
1751 SkASSERT(shader);
1752 SkASSERT(shader->numOctaves());
1753
1754 std::unique_ptr<SkPerlinNoiseShader::PaintingData> paintingData = shader->getPaintingData();
1755 paintingData->generateBitmaps();
1756
1757 sk_sp<TextureProxy> perm = RecorderPriv::CreateCachedProxy(
1758 keyContext.recorder(), paintingData->getPermutationsBitmap());
1759
1760 sk_sp<TextureProxy> noise =
1761 RecorderPriv::CreateCachedProxy(keyContext.recorder(), paintingData->getNoiseBitmap());
1762
1763 if (!perm || !noise) {
1764 SKGPU_LOG_W("Couldn't create tables for PerlinNoiseShader");
1765 builder->addBlock(BuiltInCodeSnippetID::kError);
1766 return;
1767 }
1768
1769 PerlinNoiseShaderBlock::PerlinNoiseData perlinData(
1770 static_cast<PerlinNoiseShaderBlock::Type>(shader->noiseType()),
1771 paintingData->fBaseFrequency,
1772 shader->numOctaves(),
1773 {paintingData->fStitchDataInit.fWidth, paintingData->fStitchDataInit.fHeight});
1774
1775 perlinData.fPermutationsProxy = std::move(perm);
1776 perlinData.fNoiseProxy = std::move(noise);
1777
1778 PerlinNoiseShaderBlock::AddBlock(keyContext, builder, gatherer, perlinData);
1779}
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 1784 of file KeyHelpers.cpp.

1787 {
1788 SkASSERT(shader);
1789
1790 Recorder* recorder = keyContext.recorder();
1791 const Caps* caps = recorder->priv().caps();
1792
1793 // TODO: We'll need additional plumbing to get the correct props from our callers. In
1794 // particular we'll need to expand the keyContext to have the surfaceProps.
1795 SkSurfaceProps props{};
1796
1797 SkMatrix totalM = keyContext.local2Dev().asM33();
1798 if (keyContext.localMatrix()) {
1799 totalM.preConcat(*keyContext.localMatrix());
1800 }
1802 totalM,
1803 keyContext.dstColorInfo().colorType(),
1804 keyContext.dstColorInfo().colorSpace(),
1805 caps->maxTextureSize(),
1806 props);
1807 if (!info.success) {
1808 SKGPU_LOG_W("Couldn't access PictureShaders' Image info");
1809 builder->addBlock(BuiltInCodeSnippetID::kError);
1810 return;
1811 }
1812
1813 // TODO: right now we're explicitly not caching here. We could expand the ImageProvider
1814 // API to include already Graphite-backed images, add a Recorder-local cache or add
1815 // rendered-picture images to the global cache.
1816 sk_sp<SkImage> img = info.makeImage(
1817 SkSurfaces::RenderTarget(recorder, info.imageInfo, skgpu::Mipmapped::kNo, &info.props),
1818 shader->picture().get());
1819 if (!img) {
1820 SKGPU_LOG_W("Couldn't create SkImage for PictureShader");
1821 builder->addBlock(BuiltInCodeSnippetID::kError);
1822 return;
1823 }
1824
1825 const auto shaderLM = SkMatrix::Scale(1.f/info.tileScale.width(), 1.f/info.tileScale.height());
1826 sk_sp<SkShader> imgShader = img->makeShader(shader->tileModeX(), shader->tileModeY(),
1827 SkSamplingOptions(shader->filter()), &shaderLM);
1828 if (!imgShader) {
1829 SKGPU_LOG_W("Couldn't create SkImageShader for PictureShader");
1830 builder->addBlock(BuiltInCodeSnippetID::kError);
1831 return;
1832 }
1833
1834 AddToKey(keyContext, builder, gatherer, imgShader.get());
1835}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
SkColorType colorType() const
SkMatrix asM33() const
Definition SkM44.h:409
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition SkMatrix.h:75
SkMatrix & preConcat(const SkMatrix &other)
Definition SkMatrix.cpp:674
SkRect tile() const
SkTileMode tileModeY() const
SkTileMode tileModeX() const
SkFilterMode filter() const
sk_sp< SkPicture > picture() const
int maxTextureSize() const
Definition Caps.h:134
const SkM44 & local2Dev() const
Definition KeyContext.h:59
const SkMatrix * localMatrix() const
Definition KeyContext.h:60
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 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 1224 of file KeyHelpers.cpp.

1227 {
1228 SkASSERT(filter);
1229
1230 sk_sp<SkRuntimeEffect> effect = filter->effect();
1232 effect->uniforms(), filter->uniforms(), keyContext.dstColorInfo().colorSpace());
1233 SkASSERT(uniforms);
1234
1235 RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer, {effect, std::move(uniforms)});
1236
1237 add_children_to_key(keyContext, builder, gatherer,
1238 filter->children(), effect->children());
1239
1240 builder->endBlock();
1241}
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 &)

◆ 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 1841 of file KeyHelpers.cpp.

1844 {
1845 SkASSERT(shader);
1846 sk_sp<SkRuntimeEffect> effect = shader->effect();
1848 effect->uniforms(),
1849 shader->uniformData(keyContext.dstColorInfo().colorSpace()),
1850 keyContext.dstColorInfo().colorSpace());
1851 SkASSERT(uniforms);
1852
1853 RuntimeEffectBlock::BeginBlock(keyContext, builder, gatherer,
1854 {effect, std::move(uniforms)});
1855
1856 add_children_to_key(keyContext, builder, gatherer,
1857 shader->children(), effect->children());
1858
1859 builder->endBlock();
1860}
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 1243 of file KeyHelpers.cpp.

1246 {
1247 SkASSERT(filter);
1248
1249 sk_sp<TextureProxy> proxy = RecorderPriv::CreateCachedProxy(keyContext.recorder(),
1250 filter->bitmap());
1251 if (!proxy) {
1252 SKGPU_LOG_W("Couldn't create TableColorFilter's table");
1253
1254 // Return the input color as-is.
1255 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
1256 return;
1257 }
1258
1259 TableColorFilterBlock::TableColorFilterData data(std::move(proxy));
1260
1261 TableColorFilterBlock::AddBlock(keyContext, builder, gatherer, data);
1262}
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 1867 of file KeyHelpers.cpp.

1870 {
1871 SKGPU_LOG_W("Raster-only SkShader (SkTransformShader) encountered");
1872 builder->addBlock(BuiltInCodeSnippetID::kError);
1873}

◆ 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 1878 of file KeyHelpers.cpp.

1881 {
1882 SKGPU_LOG_W("Raster-only SkShader (SkTriColorShader) encountered");
1883 builder->addBlock(BuiltInCodeSnippetID::kError);
1884}

◆ 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 1889 of file KeyHelpers.cpp.

1892 {
1893 SkASSERT(shader);
1894
1895 const SkColorInfo& dstInfo = keyContext.dstColorInfo();
1896 const SkAlphaType dstAT = dstInfo.alphaType();
1897 sk_sp<SkColorSpace> dstCS = dstInfo.refColorSpace();
1898 if (!dstCS) {
1899 dstCS = SkColorSpace::MakeSRGB();
1900 }
1901
1902 sk_sp<SkColorSpace> workingCS = shader->workingSpace();
1903 SkColorInfo workingInfo(dstInfo.colorType(), dstAT, workingCS);
1904 KeyContextWithColorInfo workingContext(keyContext, workingInfo);
1905
1906 // Compose the inner shader (in the working space) with a (working->dst) transform:
1907 Compose(keyContext, builder, gatherer,
1908 /* addInnerToKey= */ [&]() -> void {
1909 AddToKey(workingContext, builder, gatherer, shader->shader().get());
1910 },
1911 /* addOuterToKey= */ [&]() -> void {
1912 ColorSpaceTransformBlock::ColorSpaceTransformData data(
1913 workingCS.get(), dstAT, dstCS.get(), dstAT);
1914 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data);
1915 });
1916}
sk_sp< SkColorSpace > refColorSpace() const
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 1264 of file KeyHelpers.cpp.

1267 {
1268 SkASSERT(filter);
1269
1270 const SkColorInfo& dstInfo = keyContext.dstColorInfo();
1271 const SkAlphaType dstAT = dstInfo.alphaType();
1272 sk_sp<SkColorSpace> dstCS = dstInfo.refColorSpace();
1273 if (!dstCS) {
1274 dstCS = SkColorSpace::MakeSRGB();
1275 }
1276
1277 SkAlphaType workingAT;
1278 sk_sp<SkColorSpace> workingCS = filter->workingFormat(dstCS, &workingAT);
1279 SkColorInfo workingInfo(dstInfo.colorType(), workingAT, workingCS);
1280 KeyContextWithColorInfo workingContext(keyContext, workingInfo);
1281
1282 // Use two nested compose blocks to chain (dst->working), child, and (working->dst) together
1283 // while appearing as one block to the parent node.
1284 Compose(keyContext, builder, gatherer,
1285 /* addInnerToKey= */ [&]() -> void {
1286 // Inner compose
1287 Compose(keyContext, builder, gatherer,
1288 /* addInnerToKey= */ [&]() -> void {
1289 // Innermost (inner of inner compose)
1290 ColorSpaceTransformBlock::ColorSpaceTransformData data1(
1291 dstCS.get(), dstAT, workingCS.get(), workingAT);
1292 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer,
1293 data1);
1294 },
1295 /* addOuterToKey= */ [&]() -> void {
1296 // Middle (outer of inner compose)
1297 AddToKey(workingContext, builder, gatherer, filter->child().get());
1298 });
1299 },
1300 /* addOuterToKey= */ [&]() -> void {
1301 // Outermost (outer of outer compose)
1302 ColorSpaceTransformBlock::ColorSpaceTransformData data2(
1303 workingCS.get(), workingAT, dstCS.get(), dstAT);
1304 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data2);
1305 });
1306}
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 1190 of file KeyHelpers.cpp.

1193 {
1194 SkASSERT(filter);
1195
1196 Compose(keyContext, keyBuilder, gatherer,
1197 /* addInnerToKey= */ [&]() -> void {
1198 AddToKey(keyContext, keyBuilder, gatherer, filter->inner().get());
1199 },
1200 /* addOuterToKey= */ [&]() -> void {
1201 AddToKey(keyContext, keyBuilder, gatherer, filter->outer().get());
1202 });
1203}
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 1477 of file KeyHelpers.cpp.

1482 {
1483 SkASSERT(!imageToDraw->isAlphaOnly());
1484
1485 const Image_YUVA* yuvaImage = static_cast<const Image_YUVA*>(imageToDraw.get());
1486 const SkYUVAInfo& yuvaInfo = yuvaImage->yuvaInfo();
1487 // We would want to add a translation to the local matrix to handle other sitings.
1490 YUVImageShaderBlock::ImageData imgData(sampling,
1491 origShader->tileModeX(),
1492 origShader->tileModeY(),
1493 imageToDraw->dimensions(),
1494 origShader->subset());
1495 for (int locIndex = 0; locIndex < SkYUVAInfo::kYUVAChannelCount; ++locIndex) {
1496 const TextureProxyView& view = yuvaImage->proxyView(locIndex);
1497 if (view) {
1498 imgData.fTextureProxies[locIndex] = view.refProxy();
1499 // The view's swizzle has the data channel for the YUVA location in all slots, so read
1500 // the 0th slot to determine fChannelSelect
1501 switch(view.swizzle()[0]) {
1502 case 'r': imgData.fChannelSelect[locIndex] = {1.f, 0.f, 0.f, 0.f}; break;
1503 case 'g': imgData.fChannelSelect[locIndex] = {0.f, 1.f, 0.f, 0.f}; break;
1504 case 'b': imgData.fChannelSelect[locIndex] = {0.f, 0.f, 1.f, 0.f}; break;
1505 case 'a': imgData.fChannelSelect[locIndex] = {0.f, 0.f, 0.f, 1.f}; break;
1506 default:
1507 imgData.fChannelSelect[locIndex] = {0.f, 0.f, 0.f, 0.f};
1508 SkDEBUGFAILF("Unexpected swizzle for YUVA data: %c", view.swizzle()[0]);
1509 break;
1510 }
1511 } else {
1512 // Only the A proxy view should be null, in which case we bind the Y proxy view to
1513 // pass validation and send all 1s for the channel selection to signal opaque alpha.
1514 SkASSERT(locIndex == 3);
1515 imgData.fTextureProxies[locIndex] = yuvaImage->proxyView(SkYUVAInfo::kY).refProxy();
1516 imgData.fChannelSelect[locIndex] = {1.f, 1.f, 1.f, 1.f};
1517 }
1518 }
1519
1520 auto [ssx, ssy] = yuvaImage->uvSubsampleFactors();
1521 if (ssx > 1 || ssy > 1) {
1522 // We need to adjust the image size we use for sampling to reflect the actual image size of
1523 // the UV planes. However, since our coordinates are in Y's texel space we need to scale
1524 // accordingly.
1525 const TextureProxyView& view = yuvaImage->proxyView(SkYUVAInfo::kU);
1526 imgData.fImgSizeUV = {view.dimensions().width()*ssx, view.dimensions().height()*ssy};
1527 // This promotion of nearest to linear filtering for UV planes exists to mimic
1528 // libjpeg[-turbo]'s do_fancy_upsampling option. We will filter the subsampled plane,
1529 // however we want to filter at a fixed point for each logical image pixel to simulate
1530 // nearest neighbor. In the shader we detect that the UV filtermode doesn't match the Y
1531 // filtermode, and snap to Y pixel centers.
1532 if (imgData.fSampling.filter == SkFilterMode::kNearest) {
1533 imgData.fSamplingUV = SkSamplingOptions(SkFilterMode::kLinear,
1534 imgData.fSampling.mipmap);
1535 // Consider a logical image pixel at the edge of the subset. When computing the logical
1536 // pixel color value we should use a blend of two values from the subsampled plane.
1537 // Depending on where the subset edge falls in actual subsampled plane, one of those
1538 // values may come from outside the subset. Hence, we use this custom inset which
1539 // applies the wrap mode to the subset but allows linear filtering to read pixels from
1540 // that are just outside the subset. We only want to apply this offset in non-decal
1541 // modes, or when the image view size is not a multiple of the UV subsampling factor.
1542 if (imgData.fTileModes[0] != SkTileMode::kDecal ||
1543 view.dimensions().width()*ssx > yuvaInfo.width()) {
1544 imgData.fLinearFilterUVInset.fX = 1.f/(2*ssx);
1545 }
1546 if (imgData.fTileModes[1] != SkTileMode::kDecal ||
1547 view.dimensions().height()*ssy > yuvaInfo.height()) {
1548 imgData.fLinearFilterUVInset.fY = 1.f/(2*ssy);
1549 }
1550 }
1551 // Need to scale this just like we scale the image size
1552 imgData.fLinearFilterUVInset = {imgData.fLinearFilterUVInset.fX*ssx,
1553 imgData.fLinearFilterUVInset.fY*ssy};
1554 }
1555
1556 float yuvM[20];
1557 SkColorMatrix_YUV2RGB(yuvaInfo.yuvColorSpace(), yuvM);
1558 // We drop the fourth column entirely since the transformation
1559 // should not depend on alpha. The fifth column is sent as a separate
1560 // vector. The fourth row is also dropped entirely because alpha should
1561 // never be modified.
1562 SkASSERT(yuvM[3] == 0 && yuvM[8] == 0 && yuvM[13] == 0 && yuvM[18] == 1);
1563 SkASSERT(yuvM[15] == 0 && yuvM[16] == 0 && yuvM[17] == 0 && yuvM[19] == 0);
1564 imgData.fYUVtoRGBMatrix.setAll(
1565 yuvM[ 0], yuvM[ 1], yuvM[ 2],
1566 yuvM[ 5], yuvM[ 6], yuvM[ 7],
1567 yuvM[10], yuvM[11], yuvM[12]
1568 );
1569 imgData.fYUVtoRGBTranslate = {yuvM[4], yuvM[9], yuvM[14]};
1570
1571 // The YUV formats can encode their own origin including reflection and rotation,
1572 // so we need to wrap our block in an additional local matrix transform.
1573 SkMatrix originMatrix = yuvaInfo.originMatrix();
1574 LocalMatrixShaderBlock::LMShaderData lmShaderData(originMatrix);
1575
1576 KeyContextWithLocalMatrix newContext(keyContext, originMatrix);
1577
1579 SkASSERT(steps.flags.mask() == 0); // By default, the colorspace should have no effect
1580 if (!origShader->isRaw()) {
1581 steps = SkColorSpaceXformSteps(imageToDraw->colorSpace(),
1582 imageToDraw->alphaType(),
1583 keyContext.dstColorInfo().colorSpace(),
1584 keyContext.dstColorInfo().alphaType());
1585 }
1586 ColorSpaceTransformBlock::ColorSpaceTransformData data(steps);
1587
1588 Compose(keyContext, builder, gatherer,
1589 /* addInnerToKey= */ [&]() -> void {
1590 LocalMatrixShaderBlock::BeginBlock(newContext, builder, gatherer, lmShaderData);
1591 YUVImageShaderBlock::AddBlock(newContext, builder, gatherer, imgData);
1592 builder->endBlock();
1593 },
1594 /* addOuterToKey= */ [&]() -> void {
1595 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data);
1596 });
1597}
#define SkDEBUGFAILF(fmt,...)
Definition SkAssert.h:119
void SkColorMatrix_YUV2RGB(SkYUVColorSpace cs, float m[20])
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
int width() const
Definition SkYUVAInfo.h:172
Siting sitingY() const
Definition SkYUVAInfo.h:177
SkMatrix originMatrix() const
Definition SkYUVAInfo.h:181
SkYUVColorSpace yuvColorSpace() const
Definition SkYUVAInfo.h:175
int height() const
Definition SkYUVAInfo.h:173
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
constexpr uint32_t mask() const
constexpr int32_t width() const
Definition SkSize.h:36

◆ 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 917 of file KeyHelpers.cpp.

921 {
922 Blend(keyContext, builder, gatherer,
923 /* addBlendToKey= */ [&] () -> void {
924 // Note, we're playing a bit of a game here. By explicitly adding a
925 // BlendModeBlenderBlock we're always forcing the SkSL to call 'sk_blend'
926 // rather than allowing it to sometimes call 'blend_porter_duff'. This reduces
927 // the number of shader combinations and allows the pre-compilation system to more
928 // easily match the rendering path.
929 BlendModeBlenderBlock::AddBlock(keyContext, builder, gatherer, bm);
930 },
931 /* addSrcToKey= */ [&]() -> void {
932 SolidColorShaderBlock::AddBlock(keyContext, builder, gatherer, srcColor);
933 },
934 /* addDstToKey= */ [&]() -> void {
935 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
936 });
937}

◆ 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 if (keyContext.recorder() && !proxy) {
176 SKGPU_LOG_W("Couldn't create dither shader's LUT");
177 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
178 return;
179 }
180
181 DitherShaderBlock::DitherData data(skgpu::DitherRangeForConfig(ct), std::move(proxy));
182
183 DitherShaderBlock::AddBlock(keyContext, builder, gatherer, data);
184}
float DitherRangeForConfig(SkColorType dstColorType)
SkBitmap MakeDitherLUT()

◆ 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) {
153 case DstReadRequirement::kNone:
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:70
sk_sp< TextureProxy > dstTexture() const
Definition KeyContext.h:68

◆ AddKnownModeBlend()

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

Definition at line 126 of file PaintParams.cpp.

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

◆ 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 1128 of file KeyHelpers.cpp.

1131 {
1132 if (!blender) {
1133 return;
1134 }
1135 switch (as_BB(blender)->type()) {
1136#define M(type) \
1137 case SkBlenderBase::BlenderType::k##type: \
1138 add_to_key(keyContext, \
1139 builder, \
1140 gatherer, \
1141 static_cast<const Sk##type##Blender*>(blender)); \
1142 return;
1144#undef M
1145 }
1147}
#define SK_ALL_BLENDERS(M)
SkBlenderBase * as_BB(SkBlender *blend)

◆ 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 1308 of file KeyHelpers.cpp.

1311 {
1312 if (!filter) {
1313 return;
1314 }
1315 switch (as_CFB(filter)->type()) {
1317 // Return the input color as-is.
1318 builder->addBlock(BuiltInCodeSnippetID::kPriorOutput);
1319 return;
1320#define M(type) \
1321 case SkColorFilterBase::Type::k##type: \
1322 add_to_key(keyContext, \
1323 builder, \
1324 gatherer, \
1325 static_cast<const Sk##type##ColorFilter*>(filter)); \
1326 return;
1328#undef M
1329 }
1331}
#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 2163 of file KeyHelpers.cpp.

2166 {
2167 if (!shader) {
2168 return;
2169 }
2170 switch (as_SB(shader)->type()) {
2171#define M(type) \
2172 case SkShaderBase::ShaderType::k##type: \
2173 add_to_key(keyContext, \
2174 builder, \
2175 gatherer, \
2176 static_cast<const Sk##type##Shader*>(shader)); \
2177 return;
2179#undef M
2180 }
2182}
#define SK_ALL_SHADERS(M)

◆ 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) {
79 case SkSLType::kFloat2x2: return {SkSLType::kFloat2, 2*std::max(1, count)};
80 case SkSLType::kFloat3x3: return {SkSLType::kFloat3, 3*std::max(1, count)};
81 case SkSLType::kFloat4x4: return {SkSLType::kFloat4, 4*std::max(1, count)};
82
83 case SkSLType::kHalf2x2: return {SkSLType::kHalf2, 2*std::max(1, count)};
84 case SkSLType::kHalf3x3: return {SkSLType::kHalf3, 3*std::max(1, count)};
85 case SkSLType::kHalf4x4: return {SkSLType::kHalf4, 4*std::max(1, count)};
86
87 // Otherwise leave type and count alone.
88 default: return {type, count};
89 }
90}
int count

◆ append_color_output()

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

Definition at line 223 of file ShaderCodeDictionary.cpp.

226 {
227 switch (outputType) {
228 case BlendFormula::kNone_OutputType:
229 SkSL::String::appendf(mainBody, "%s = half4(0.0);", outColor);
230 break;
231 case BlendFormula::kCoverage_OutputType:
232 SkSL::String::appendf(mainBody, "%s = outputCoverage;", outColor);
233 break;
234 case BlendFormula::kModulate_OutputType:
235 SkSL::String::appendf(mainBody, "%s = %s * outputCoverage;", outColor, inColor);
236 break;
237 case BlendFormula::kSAModulate_OutputType:
238 SkSL::String::appendf(mainBody, "%s = %s.a * outputCoverage;", outColor, inColor);
239 break;
240 case BlendFormula::kISAModulate_OutputType:
242 mainBody, "%s = (1.0 - %s.a) * outputCoverage;", outColor, inColor);
243 break;
244 case BlendFormula::kISCModulate_OutputType:
246 mainBody, "%s = (half4(1.0) - %s) * outputCoverage;", outColor, inColor);
247 break;
248 default:
250 break;
251 }
252}
std::string void appendf(std::string *str, const char *fmt,...) SK_PRINTF_LIKE(2

◆ AsView() [1/2]

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

Definition at line 777 of file TextureUtils.cpp.

777 {
778 if (!image) {
779 return {};
780 }
781 if (!as_IB(image)->isGraphiteBacked()) {
782 return {};
783 }
784 // A YUVA image (even if backed by graphite textures) is not a single texture
785 if (as_IB(image)->isYUVA()) {
786 return {};
787 }
788
789 auto gi = reinterpret_cast<const Image*>(image);
790 return gi->textureProxyView();
791}
sk_sp< SkImage > image
Definition examples.cpp:29
CanvasImage Image
Definition dart_ui.cc:55

◆ AsView() [2/2]

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

Definition at line 75 of file TextureUtils.h.

75{ return AsView(image.get()); }

◆ 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) {
36 case VertexAttribType::kFloat:
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:
56 case VertexAttribType::kByte:
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
@ VK_FORMAT_R16G16_SFLOAT
@ VK_FORMAT_R32G32_SFLOAT
@ VK_FORMAT_R16_SFLOAT
@ VK_FORMAT_R32_SINT
@ VK_FORMAT_R16G16_UINT
@ VK_FORMAT_R8_UNORM
@ VK_FORMAT_R32G32B32A32_SFLOAT
@ VK_FORMAT_R32_SFLOAT
@ VK_FORMAT_R16G16B16A16_SINT
@ VK_FORMAT_R8G8B8A8_UNORM
@ VK_FORMAT_R16G16_SINT
@ VK_FORMAT_R8G8_SINT
@ VK_FORMAT_R32G32B32_SINT
@ VK_FORMAT_R16_UNORM
@ VK_FORMAT_R8_SINT
@ VK_FORMAT_R8_UINT
@ VK_FORMAT_R16G16B16A16_SFLOAT
@ VK_FORMAT_R16G16_UNORM
@ VK_FORMAT_R8G8B8A8_SINT
@ VK_FORMAT_R32G32B32A32_SINT
@ VK_FORMAT_R32G32B32_SFLOAT
@ VK_FORMAT_R8G8B8A8_UINT
@ VK_FORMAT_R8G8_UINT
@ VK_FORMAT_R32G32_SINT
@ VK_FORMAT_R32_UINT

◆ 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
@ VK_BLEND_FACTOR_SRC1_ALPHA
@ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR
@ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
@ VK_BLEND_FACTOR_SRC_COLOR
@ VK_BLEND_FACTOR_CONSTANT_COLOR
@ VK_BLEND_FACTOR_SRC_ALPHA
@ VK_BLEND_FACTOR_DST_ALPHA
@ VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA
@ VK_BLEND_FACTOR_ZERO
@ VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
@ VK_BLEND_FACTOR_DST_COLOR
@ VK_BLEND_FACTOR_SRC1_COLOR
@ VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR

◆ 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}
Type::kYUV Type::kRGBA() int(0.7 *637)
static const int kBlendEquationCnt
Definition Blend.h:55
VkBlendOp
@ VK_BLEND_OP_MULTIPLY_EXT
@ VK_BLEND_OP_ADD
@ VK_BLEND_OP_HARDLIGHT_EXT
@ VK_BLEND_OP_OVERLAY_EXT
@ VK_BLEND_OP_COLORDODGE_EXT
@ VK_BLEND_OP_SUBTRACT
@ VK_BLEND_OP_HSL_COLOR_EXT
@ VK_BLEND_OP_DARKEN_EXT
@ VK_BLEND_OP_SOFTLIGHT_EXT
@ VK_BLEND_OP_LIGHTEN_EXT
@ VK_BLEND_OP_HSL_HUE_EXT
@ VK_BLEND_OP_HSL_SATURATION_EXT
@ VK_BLEND_OP_SCREEN_EXT
@ VK_BLEND_OP_HSL_LUMINOSITY_EXT
@ VK_BLEND_OP_EXCLUSION_EXT
@ VK_BLEND_OP_COLORBURN_EXT
@ VK_BLEND_OP_DIFFERENCE_EXT
@ VK_BLEND_OP_REVERSE_SUBTRACT

◆ BuildComputeSkSL()

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

Definition at line 595 of file ContextUtils.cpp.

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

◆ 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 543 of file ContextUtils.cpp.

549 {
551 if (!paintID.isValid()) {
552 // Depth-only draw so no fragment shader to compile
553 return {};
554 }
555
556 const char* shadingSsboIndex =
557 useStorageBuffers && step->performsShading() ? "shadingSsboIndex" : nullptr;
558 ShaderInfo shaderInfo(paintID, dict, rteDict, shadingSsboIndex);
559
560 result.fSkSL = shaderInfo.toSkSL(caps,
561 step,
562 useStorageBuffers,
563 &result.fNumTexturesAndSamplers,
564 &result.fNumPaintUniforms,
565 &result.fRenderStepUniformsTotalBytes,
566 &result.fPaintUniformsTotalBytes,
567 writeSwizzle);
568
569 // Extract blend info after integrating the RenderStep into the final fragment shader in case
570 // that changes the HW blending choice to handle analytic coverage.
571 result.fBlendInfo = shaderInfo.blendInfo();
572 result.fRequiresLocalCoords = shaderInfo.needsLocalCoords();
573
574 result.fLabel = writeSwizzle.asString().c_str();
575 result.fLabel += " + ";
576 result.fLabel = step->name();
577 result.fLabel += " + ";
578 result.fLabel += dict->idToString(paintID).c_str();
579
580 return result;
581}
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 457 of file ContextUtils.cpp.

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

static bool skgpu::graphite::can_do_tiling_in_hw ( const Caps caps,
const ImageShaderBlock::ImageData imgData 
)
static

Definition at line 570 of file KeyHelpers.cpp.

570 {
571 if (!caps->clampToBorderSupport() && (imgData.fTileModes[0] == SkTileMode::kDecal ||
572 imgData.fTileModes[1] == SkTileMode::kDecal)) {
573 return false;
574 }
575 return imgData.fSubset.contains(SkRect::Make(imgData.fImgSize));
576}
bool clampToBorderSupport() const
Definition Caps.h:217
static SkRect Make(const SkISize &size)
Definition SkRect.h:669
bool contains(SkScalar x, SkScalar y) const
Definition extension.cpp:19

◆ check_max_blit_width()

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

Definition at line 776 of file MtlCommandBuffer.mm.

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

◆ check_shader_module()

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

Definition at line 91 of file DawnGraphiteUtils.cpp.

93 {
94 // Prior to emsdk 3.1.51 wgpu::ShaderModule::GetCompilationInfo is unimplemented.
95#if defined(__EMSCRIPTEN__) && \
96 ((__EMSCRIPTEN_major__ < 3 || \
97 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ < 1) || \
98 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ < 51)))
99 return true;
100#endif
101 struct Handler {
102 static void Fn(WGPUCompilationInfoRequestStatus status,
103 const WGPUCompilationInfo* info,
104 void* userdata) {
105 Handler* self = reinterpret_cast<Handler*>(userdata);
106 SkASSERT(status == WGPUCompilationInfoRequestStatus_Success);
107
108 // Walk the message list and check for hard errors.
109 self->fSuccess = true;
110 for (size_t index = 0; index < info->messageCount; ++index) {
111 const WGPUCompilationMessage& entry = info->messages[index];
112 if (entry.type == WGPUCompilationMessageType_Error) {
113 self->fSuccess = false;
114 break;
115 }
116 }
117
118 // If we found a hard error, report the compilation messages to the error handler.
119 if (!self->fSuccess) {
120 std::string errors;
121 for (size_t index = 0; index < info->messageCount; ++index) {
122 const WGPUCompilationMessage& entry = info->messages[index];
123 errors += "line " +
124 std::to_string(entry.lineNum) + ':' +
125 std::to_string(entry.linePos) + ' ' +
126 entry.message + '\n';
127 }
128 self->fErrorHandler->compileError(
129 self->fShaderText, errors.c_str(), /*shaderWasCached=*/false);
130 }
131 }
132
133 const char* fShaderText;
134 ShaderErrorHandler* fErrorHandler;
135 bool fSuccess = false;
136 };
137
138 Handler handler;
139 handler.fShaderText = shaderText;
140 handler.fErrorHandler = errorHandler;
141 module->GetCompilationInfo(&Handler::Fn, &handler);
142
143 return handler.fSuccess;
144}

◆ color_type_fallback()

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

Definition at line 91 of file Caps.cpp.

91 {
92 switch (ct) {
93 // kRGBA_8888 is our default fallback for many color types that may not have renderable
94 // backend formats.
108 default:
110 }
111}
@ 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);
215 SkASSERT(op < (CompareOp)kCompareOpCount);
216
217 return gTable[(int)op];
218}
VkCompareOp
@ VK_COMPARE_OP_LESS_OR_EQUAL
@ VK_COMPARE_OP_LESS
@ VK_COMPARE_OP_NOT_EQUAL
@ VK_COMPARE_OP_NEVER
@ VK_COMPARE_OP_ALWAYS
@ VK_COMPARE_OP_EQUAL
@ VK_COMPARE_OP_GREATER_OR_EQUAL
@ VK_COMPARE_OP_GREATER

◆ 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:159
size_t requiredTransferBufferAlignment() const
Definition Caps.h:156
int size() const
Definition SkTArray.h:416
SkISize CompressedDimensionsInBlocks(SkTextureCompressionType type, SkISize baseDimensions)
constexpr int32_t height() const
Definition SkSize.h:37

◆ ComputeShaderCoverageMaskTargetFormat()

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

Definition at line 793 of file TextureUtils.cpp.

793 {
794 // GPU compute coverage mask renderers need to bind the mask texture as a storage binding, which
795 // support a limited set of color formats. In general, we use RGBA8 if Alpha8 can't be
796 // supported.
799 }
801}
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 516 of file TextureUtils.cpp.

517 {
518
519 SkTextureCompressionType compression = info.compressionType();
520
521 size_t colorSize = 0;
522
523 if (compression != SkTextureCompressionType::kNone) {
524 colorSize = SkCompressedFormatDataSize(compression,
525 dimensions,
526 info.mipmapped() == Mipmapped::kYes);
527 } else {
528 // TODO: Should we make sure the backends return zero here if the TextureInfo is for a
529 // memoryless texture?
530 size_t bytesPerPixel = info.bytesPerPixel();
531
532 colorSize = (size_t)dimensions.width() * dimensions.height() * bytesPerPixel;
533 }
534
535 size_t finalSize = colorSize * info.numSamples();
536
537 if (info.mipmapped() == Mipmapped::kYes) {
538 finalSize += colorSize/3;
539 }
540 return finalSize;
541}
size_t SkCompressedFormatDataSize(SkTextureCompressionType compressionType, SkISize dimensions, bool mipmapped)

◆ ContextTypeBackend()

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

Definition at line 128 of file ContextType.cpp.

128 {
129 switch (type) {
130 case skgpu::ContextType::kGL:
131 case skgpu::ContextType::kGLES:
132 case skgpu::ContextType::kANGLE_D3D9_ES2:
133 case skgpu::ContextType::kANGLE_D3D11_ES2:
134 case skgpu::ContextType::kANGLE_D3D11_ES3:
135 case skgpu::ContextType::kANGLE_GL_ES2:
136 case skgpu::ContextType::kANGLE_GL_ES3:
137 case skgpu::ContextType::kANGLE_Metal_ES2:
138 case skgpu::ContextType::kANGLE_Metal_ES3:
139 case skgpu::ContextType::kDirect3D:
140 return BackendApi::kUnsupported;
141
142 case ContextType::kVulkan:
143 return BackendApi::kVulkan;
144
145 case ContextType::kMetal:
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}

◆ 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 1923 of file KeyHelpers.cpp.

1925 {
1926 SkBitmap colorsAndOffsetsBitmap;
1927
1928 colorsAndOffsetsBitmap.allocPixels(
1930
1931 for (int i = 0; i < numStops; i++) {
1932 // TODO: there should be a way to directly set a premul pixel in a bitmap with
1933 // a premul color.
1934 SkColor4f unpremulColor = colors[i].unpremul();
1935 colorsAndOffsetsBitmap.erase(unpremulColor, SkIRect::MakeXYWH(i, 0, 1, 1));
1936
1937 float offset = offsets ? offsets[i] : SkIntToFloat(i) / (numStops - 1);
1938 SkASSERT(offset >= 0.0f && offset <= 1.0f);
1939
1940 int exponent;
1941 float mantissa = frexp(offset, &exponent);
1942
1943 SkHalf halfE = SkFloatToHalf(exponent);
1944 if ((int)SkHalfToFloat(halfE) != exponent) {
1945 SKGPU_LOG_W("Encoding gradient to f16 failed");
1946 return {};
1947 }
1948
1949#if defined(SK_DEBUG)
1950 SkHalf halfM = SkFloatToHalf(mantissa);
1951
1952 float restored = ldexp(SkHalfToFloat(halfM), (int)SkHalfToFloat(halfE));
1953 float error = abs(restored - offset);
1954 SkASSERT(error < 0.001f);
1955#endif
1956
1957 // TODO: we're only using 2 of the f16s here. The encoding could be altered to better
1958 // preserve precision. This encoding yields < 0.001f error for 2^20 evenly spaced stops.
1959 colorsAndOffsetsBitmap.erase(SkColor4f{mantissa, (float)exponent, 0, 1},
1960 SkIRect::MakeXYWH(i, 1, 1, 1));
1961 }
1962
1963 return colorsAndOffsetsBitmap;
1964}
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
Point offset
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
Definition SkRect.h:104
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ create_image_data()

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

Definition at line 85 of file GraphiteResourceCacheTest.cpp.

85 {
86 const size_t rowBytes = info.minRowBytes();
87 sk_sp<SkData> data(SkData::MakeUninitialized(rowBytes * info.height()));
88 {
89 SkBitmap bm;
90 bm.installPixels(info, data->writable_data(), rowBytes);
91 SkCanvas canvas(bm);
92 canvas.clear(SK_ColorRED);
93 }
94 return data;
95}
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
const uint32_t * pCode
#define TRACE_EVENT0(category_group, name)
VkResult
@ VK_SUCCESS
#define VK_NULL_HANDLE
Definition vulkan_core.h:46
@ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO

◆ DawnCompileWGSLShaderModule()

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

Definition at line 146 of file DawnGraphiteUtils.cpp.

150 {
151 wgpu::ShaderModuleWGSLDescriptor wgslDesc;
152 wgslDesc.code = wgsl.c_str();
153
154 wgpu::ShaderModuleDescriptor desc;
155 desc.nextInChain = &wgslDesc;
156 desc.label = label;
157
158 *module = sharedContext->device().CreateShaderModule(&desc);
159
160 return check_shader_module(module, wgsl.c_str(), errorHandler);
161}
static bool check_shader_module(wgpu::ShaderModule *module, const char *shaderText, ShaderErrorHandler *errorHandler)

◆ DawnDepthStencilFlagsToFormat()

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

Definition at line 76 of file DawnGraphiteUtils.cpp.

76 {
77 // TODO: Decide if we want to change this to always return a combined depth and stencil format
78 // to allow more sharing of depth stencil allocations.
79 if (mask == DepthStencilFlags::kDepth) {
80 // wgpu::TextureFormatDepth16Unorm is also a universally supported option here
81 return wgpu::TextureFormat::Depth32Float;
82 } else if (mask == DepthStencilFlags::kStencil) {
83 return wgpu::TextureFormat::Stencil8;
84 } else if (mask == DepthStencilFlags::kDepthStencil) {
85 return wgpu::TextureFormat::Depth24PlusStencil8;
86 }
87 SkASSERT(false);
88 return wgpu::TextureFormat::Undefined;
89}

◆ 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::Depth32Float: return 4;
37 case wgpu::TextureFormat::Depth32FloatStencil8: return 5;
38 case wgpu::TextureFormat::Depth24PlusStencil8: return 5; // could be backed by d32s8
39
40#if !defined(__EMSCRIPTEN__)
41 case wgpu::TextureFormat::R16Unorm: return 2;
42 case wgpu::TextureFormat::RG16Unorm: return 4;
43#endif
44 default:
46 }
47}
uint32_t uint32_t * format

◆ DawnFormatChannels()

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

Definition at line 57 of file DawnUtils.cpp.

57 {
58 switch (format) {
59 case wgpu::TextureFormat::RGBA8Unorm: return kRGBA_SkColorChannelFlags;
60 case wgpu::TextureFormat::BGRA8Unorm: return kRGBA_SkColorChannelFlags;
61 case wgpu::TextureFormat::R8Unorm: return kRed_SkColorChannelFlag;
62 case wgpu::TextureFormat::RGBA16Float: return kRGBA_SkColorChannelFlags;
63 case wgpu::TextureFormat::R16Float: return kRed_SkColorChannelFlag;
64 case wgpu::TextureFormat::RG8Unorm: return kRG_SkColorChannelFlags;
65 case wgpu::TextureFormat::RGB10A2Unorm: return kRGBA_SkColorChannelFlags;
66 case wgpu::TextureFormat::RG16Float: return kRG_SkColorChannelFlags;
67
68#if !defined(__EMSCRIPTEN__)
69 case wgpu::TextureFormat::R16Unorm: return kRed_SkColorChannelFlag;
70 case wgpu::TextureFormat::RG16Unorm: return kRG_SkColorChannelFlags;
71#endif
72
73 default: return 0;
74 }
76}
@ 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 54 of file DawnGraphiteUtils.cpp.

54 {
55 switch (format) {
56 case wgpu::TextureFormat::Depth32Float:
57 case wgpu::TextureFormat::Depth24PlusStencil8:
58 case wgpu::TextureFormat::Depth32FloatStencil8:
59 return true;
60 default:
61 return false;
62 }
63}

◆ 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::Depth32Float:
46 case wgpu::TextureFormat::Depth24PlusStencil8:
47 case wgpu::TextureFormat::Depth32FloatStencil8:
48 return true;
49 default:
50 return false;
51 }
52}

◆ DawnFormatIsStencil()

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

Definition at line 65 of file DawnGraphiteUtils.cpp.

65 {
66 switch (format) {
67 case wgpu::TextureFormat::Stencil8: // fallthrough
68 case wgpu::TextureFormat::Depth24PlusStencil8:
69 case wgpu::TextureFormat::Depth32FloatStencil8:
70 return true;
71 default:
72 return false;
73 }
74}

◆ DawnFormatToCompressionType()

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

Definition at line 49 of file DawnUtils.cpp.

49 {
50 switch (format) {
51 case wgpu::TextureFormat::ETC2RGB8Unorm: return SkTextureCompressionType::kETC2_RGB8_UNORM;
52 case wgpu::TextureFormat::BC1RGBAUnorm: return SkTextureCompressionType::kBC1_RGBA8_UNORM;
53 default: return SkTextureCompressionType::kNone;
54 }
55}

◆ 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}
VkInstance instance
Definition main.cc:48

◆ 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
Mipmapped
Definition GpuTypes.h:53

◆ 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
46 return info;
47}
wgpu::TextureFormat fViewFormat

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [1/7]

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

Definition at line 104 of file GraphiteResourceCacheTest.cpp.

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

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [2/7]

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

Definition at line 202 of file ProxyCacheTest.cpp.

207 {
208 std::unique_ptr<Recorder> recorder = context->makeRecorder();
209 ProxyCache* proxyCache = recorder->priv().proxyCache();
210
211 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
212 REPORTER_ASSERT(r, setup.valid());
213 if (!setup.valid()) {
214 return;
215 }
216
217 proxyCache->forceFreeUniquelyHeld();
218 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
219
220 setup.fProxy1.reset();
221 proxyCache->forceFreeUniquelyHeld();
222 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
223
224 setup.fProxy2.reset();
225 proxyCache->forceFreeUniquelyHeld();
226 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
227}
Definition setup.py:1

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [3/7]

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

Definition at line 230 of file ProxyCacheTest.cpp.

235 {
236 std::unique_ptr<Recorder> recorder = context->makeRecorder();
237 ProxyCache* proxyCache = recorder->priv().proxyCache();
238
239 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
240 REPORTER_ASSERT(r, setup.valid());
241 if (!setup.valid()) {
242 return;
243 }
244
245 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
246 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
247
248 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeBetweenProxyCreation);
249 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
250 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
251 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
252
253 sk_sp<TextureProxy> test = proxyCache->find(setup.fBitmap1, Mipmapped::kNo);
254 REPORTER_ASSERT(r, !test); // proxy1 should've been purged
255
256 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeAfterAllProxyCreation);
257 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
258 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
259 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
260}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [4/7]

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

Definition at line 264 of file ProxyCacheTest.cpp.

269 {
270 std::unique_ptr<Recorder> recorder = context->makeRecorder();
271 ProxyCache* proxyCache = recorder->priv().proxyCache();
272
273 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
274 REPORTER_ASSERT(r, setup.valid());
275 if (!setup.valid()) {
276 return;
277 }
278
279 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
280 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
281
282 // update proxy1's timestamp
283 sk_sp<TextureProxy> test = proxyCache->findOrCreateCachedProxy(recorder.get(), setup.fBitmap1,
284 Mipmapped::kNo);
285 REPORTER_ASSERT(r, test == setup.fProxy1);
286
287 std::this_thread::sleep_for(std::chrono::milliseconds(2));
288 auto timeAfterProxy1Update = skgpu::StdSteadyClock::now();
289
290 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeBetweenProxyCreation);
291 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
292 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
293 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
294
295 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeAfterAllProxyCreation);
296 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
297 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
298 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
299
300 test = proxyCache->find(setup.fBitmap2, Mipmapped::kNo);
301 REPORTER_ASSERT(r, !test); // proxy2 should've been purged
302
303 proxyCache->forcePurgeProxiesNotUsedSince(timeAfterProxy1Update);
304 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
305 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
306 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
307}
sk_sp< TextureProxy > findOrCreateCachedProxy(Recorder *, const SkBitmap &, Mipmapped)

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [5/7]

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

Definition at line 310 of file ProxyCacheTest.cpp.

315 {
316 std::unique_ptr<Recorder> recorder = context->makeRecorder();
317 ProxyCache* proxyCache = recorder->priv().proxyCache();
318
319 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
320 REPORTER_ASSERT(r, setup.valid());
321 if (!setup.valid()) {
322 return;
323 }
324
325 REPORTER_ASSERT(r, !setup.fProxy1->texture()->testingShouldDeleteASAP());
326 REPORTER_ASSERT(r, !setup.fProxy2->texture()->testingShouldDeleteASAP());
327
328 proxyCache->forcePurgeProxiesNotUsedSince(setup.fTimeAfterAllProxyCreation);
329 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
330 REPORTER_ASSERT(r, setup.fProxy1->texture()->testingShouldDeleteASAP());
331 REPORTER_ASSERT(r, setup.fProxy2->texture()->testingShouldDeleteASAP());
332}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [6/7]

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

Definition at line 335 of file ProxyCacheTest.cpp.

340 {
341 std::unique_ptr<Recorder> recorder = context->makeRecorder();
342 ResourceCache* resourceCache = recorder->priv().resourceCache();
343 ProxyCache* proxyCache = recorder->priv().proxyCache();
344
345 resourceCache->setMaxBudget(0);
346
347 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
348 REPORTER_ASSERT(r, setup.valid());
349 if (!setup.valid()) {
350 return;
351 }
352
353 resourceCache->forcePurgeAsNeeded();
354
355 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
356
357 setup.fProxy1.reset();
358 proxyCache->forceProcessInvalidKeyMsgs();
359
360 // unreffing fProxy1 and forcing message processing shouldn't purge proxy1 from the cache
361 sk_sp<TextureProxy> test = proxyCache->find(setup.fBitmap1, Mipmapped::kNo);
363 test.reset();
364
365 resourceCache->forcePurgeAsNeeded();
366
367 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
368 test = proxyCache->find(setup.fBitmap1, Mipmapped::kNo);
369 REPORTER_ASSERT(r, !test); // proxy1 should've been purged
370
371 setup.fProxy2.reset();
372 proxyCache->forceProcessInvalidKeyMsgs();
373
374 // unreffing fProxy2 and forcing message processing shouldn't purge proxy2 from the cache
375 test = proxyCache->find(setup.fBitmap2, Mipmapped::kNo);
377 test.reset();
378
379 resourceCache->forcePurgeAsNeeded();
380
381 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
382}

◆ DEF_CONDITIONAL_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [7/7]

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

Definition at line 386 of file ProxyCacheTest.cpp.

391 {
392 std::unique_ptr<Recorder> recorder = context->makeRecorder();
393 ResourceCache* resourceCache = recorder->priv().resourceCache();
394 ProxyCache* proxyCache = recorder->priv().proxyCache();
395
396 ProxyCacheSetup setup = setup_test(context, testContext, recorder.get(), r);
397 REPORTER_ASSERT(r, setup.valid());
398 if (!setup.valid()) {
399 return;
400 }
401
402 REPORTER_ASSERT(r, setup.fProxy1->isInstantiated());
403 REPORTER_ASSERT(r, setup.fProxy2->isInstantiated());
404
405 if (!setup.fProxy1->texture() || !setup.fProxy2->texture()) {
406 return;
407 }
408
409 // Clear out resources used to setup bitmap proxies so we can track things easier.
410 resourceCache->setMaxBudget(0);
411 resourceCache->setMaxBudget(256 * (1 << 20));
412
413 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
414 int baselineResourceCount = resourceCache->getResourceCount();
415 // When buffer maps are async it can take extra time for buffers to be returned to the cache.
416 if (context->priv().caps()->bufferMapsAreAsync()) {
417 // We expect at least 2 textures (and possibly buffers).
418 REPORTER_ASSERT(r, baselineResourceCount >= 2);
419 } else {
420 REPORTER_ASSERT(r, baselineResourceCount == 2);
421 }
422 // Force a command buffer ref on the second proxy in the cache so it can't be purged immediately
423 setup.fProxy2->texture()->refCommandBuffer();
424
425 Resource* proxy2ResourcePtr = setup.fProxy2->texture();
426
427 setup.fProxy1.reset();
428 setup.fProxy2.reset();
429 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
430
431 auto timeAfterProxyCreation = skgpu::StdSteadyClock::now();
432
433 // This should trigger both proxies to be purged from the ProxyCache. The first proxy should
434 // immediately be purged from the ResourceCache as well since it has not other refs. The second
435 // proxy will not be purged from the ResourceCache since it still has a command buffer ref.
436 // However, that resource should have its deleteASAP flag set.
437 resourceCache->purgeResourcesNotUsedSince(timeAfterProxyCreation);
438
439 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
440 REPORTER_ASSERT(r, resourceCache->getResourceCount() == baselineResourceCount - 1);
441 REPORTER_ASSERT(r, resourceCache->topOfPurgeableQueue() == nullptr);
442 REPORTER_ASSERT(r, proxy2ResourcePtr->testingShouldDeleteASAP());
443
444 // Removing the command buffer ref and returning proxy2Resource to the cache should cause it to
445 // immediately get deleted without going in the purgeable queue.
446 proxy2ResourcePtr->unrefCommandBuffer();
447 resourceCache->forceProcessReturnedResources();
448
449 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
450 REPORTER_ASSERT(r, resourceCache->getResourceCount() == baselineResourceCount - 2);
451 REPORTER_ASSERT(r, resourceCache->topOfPurgeableQueue() == nullptr);
452}
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

◆ 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
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350
TRect< Scalar > Rect
Definition rect.h:746
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 intersect(const SkRect &r)
Definition SkRect.cpp:114
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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [1/17]

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
35 SkColor colors[kVertexCount];
36 for (size_t i = 0; i < kVertexCount; ++i) {
37 colors[i] = 0x7F00FF00;
38 }
39
42 positions,
43 nullptr,
44 colors,
45 kIndexCount,
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[]
#define SkAssertResult(cond)
Definition SkAssert.h:123
uint32_t SkColor
Definition SkColor.h:37
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
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[])
@ kTriangleFan_VertexMode
Definition SkVertices.h:33
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
void set(float x, float y)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [2/17]

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);
47 sk_sp<TextureProxy> target = TextureProxy::Make(
48 caps,
49 recorder->priv().resourceProvider(),
50 targetSize,
52 targetColorType, Mipmapped::kNo,
53 recorder->priv().isProtected(), Renderable::kYes),
54 Budgeted::kYes);
55 std::unique_ptr<DrawPass> drawPass = DrawPass::Make(recorder.get(),
56 std::move(drawList),
57 target,
58 targetInfo,
59 {LoadOp::kClear, StoreOp::kStore},
60 {0.0f, 0.0f, 0.0f, 0.0f});
61
62 // Make sure creating the draw pass failed.
63 REPORTER_ASSERT(reporter, !drawPass);
64}
static float next(float f)
SkColorType
Definition SkColorType.h:19
Shape
virtual TextureInfo getDefaultSampledTextureInfo(SkColorType, Mipmapped mipmapped, Protected, Renderable) const =0
const Paint & paint
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition SkRect.h:56

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [3/17]

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

Definition at line 221 of file TextureProxyTest.cpp.

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [4/17]

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

Definition at line 314 of file GraphiteResourceCacheTest.cpp.

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [5/17]

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

Definition at line 619 of file GraphiteResourceCacheTest.cpp.

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [6/17]

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

Definition at line 528 of file GraphiteResourceCacheTest.cpp.

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [7/17]

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

Definition at line 697 of file GraphiteResourceCacheTest.cpp.

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [8/17]

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [9/17]

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

Definition at line 200 of file TextureProxyTest.cpp.

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [10/17]

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

Definition at line 441 of file GraphiteResourceCacheTest.cpp.

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

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [11/17]

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);
45
46 SkPath path;
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)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
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/17]

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 Mipmapped::kNo);
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/17]

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 Mipmapped::kNo);
77 sk_sp<TextureProxy> proxy2 = proxyCache2->findOrCreateCachedProxy(recorder2.get(), bitmap,
78 Mipmapped::kNo);
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/17]

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

Definition at line 95 of file ProxyCacheTest.cpp.

95 {
96 std::unique_ptr<Recorder> recorder = context->makeRecorder();
97 ProxyCache* proxyCache = recorder->priv().proxyCache();
98
100 bool success = ToolUtils::GetResourceAsBitmap("images/mandrill_128.png", &bitmap);
101 REPORTER_ASSERT(r, success);
102 if (!success) {
103 return;
104 }
105
106 REPORTER_ASSERT(r, proxyCache->numCached() == 0);
107
108 sk_sp<TextureProxy> nonMipmapped = proxyCache->findOrCreateCachedProxy(recorder.get(), bitmap,
109 Mipmapped::kNo);
110 REPORTER_ASSERT(r, nonMipmapped->mipmapped() == Mipmapped::kNo);
111 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
112
113 sk_sp<TextureProxy> test = proxyCache->findOrCreateCachedProxy(recorder.get(), bitmap,
114 Mipmapped::kNo);
115 REPORTER_ASSERT(r, nonMipmapped == test);
116 REPORTER_ASSERT(r, proxyCache->numCached() == 1);
117
118 sk_sp<TextureProxy> mipmapped = proxyCache->findOrCreateCachedProxy(recorder.get(), bitmap,
119 Mipmapped::kYes);
120 REPORTER_ASSERT(r, mipmapped->mipmapped() == Mipmapped::kYes);
121 REPORTER_ASSERT(r, mipmapped != nonMipmapped);
122
123 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
124
125 test = proxyCache->findOrCreateCachedProxy(recorder.get(), bitmap, Mipmapped::kNo);
126 REPORTER_ASSERT(r, mipmapped == test);
127
128 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
129
130 test = proxyCache->findOrCreateCachedProxy(recorder.get(), bitmap, Mipmapped::kYes);
131 REPORTER_ASSERT(r, mipmapped == test);
132
133 REPORTER_ASSERT(r, proxyCache->numCached() == 2);
134}

◆ DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS() [15/17]

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() [16/17]

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() [17/17]

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:62

◆ 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

◆ 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].count != 0) {
77 const DescriptorData& currDescriptor = requestedDescriptors[i];
78 VkDescriptorSetLayoutBinding& layoutBinding = bindingLayouts.push_back();
79 memset(&layoutBinding, 0, sizeof(VkDescriptorSetLayoutBinding));
80 layoutBinding.binding = currDescriptor.bindingIndex;
81 layoutBinding.descriptorType = DsTypeEnumToVkDs(currDescriptor.type);
82 layoutBinding.descriptorCount = currDescriptor.count;
83 layoutBinding.stageFlags =
85 // TODO(b/302126498): Optionally set immutableSamplers here. Needed for YCbCr
86 layoutBinding.pImmutableSamplers = nullptr;
87 }
88 }
89
90 VkDescriptorSetLayoutCreateInfo layoutCreateInfo;
91 memset(&layoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo));
93 layoutCreateInfo.pNext = nullptr;
94 layoutCreateInfo.flags = 0;
95 layoutCreateInfo.bindingCount = bindingLayouts.size();
96 layoutCreateInfo.pBindings = &bindingLayouts.front();
97
100 ctxt,
101 result,
102 CreateDescriptorSetLayout(ctxt->device(), &layoutCreateInfo, nullptr, outLayout));
103 if (result != VK_SUCCESS) {
104 SkDebugf("Failed to create VkDescriptorSetLayout\n");
105 outLayout = VK_NULL_HANDLE;
106 }
107}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
VkDescriptorType DsTypeEnumToVkDs(DescriptorType type)
VkShaderStageFlags PipelineStageFlagsToVkShaderStageFlags(SkEnumBitMask< PipelineStageFlags > stageFlags)
VkDescriptorType descriptorType
const VkSampler * pImmutableSamplers
VkShaderStageFlags stageFlags
const VkDescriptorSetLayoutBinding * pBindings
VkDescriptorSetLayoutCreateFlags flags
SkEnumBitMask< PipelineStageFlags > pipelineStageFlags
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO

◆ 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 109 of file VulkanGraphiteUtils.cpp.

109 {
110 switch (type) {
111 case DescriptorType::kUniformBuffer:
113 case DescriptorType::kTextureSampler:
115 case DescriptorType::kTexture:
117 case DescriptorType::kCombinedTextureSampler:
119 case DescriptorType::kStorageBuffer:
121 case DescriptorType::kInputAttachment:
123 }
125}
@ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
@ VK_DESCRIPTOR_TYPE_SAMPLER
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
@ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
@ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT
@ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER

◆ EmitPaintParamsStorageBuffer()

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

Definition at line 300 of file ContextUtils.cpp.

304 {
305
306 std::string result;
307 result += "struct FSUniformData {\n";
308 for (const ShaderNode* n : nodes) {
309 result += get_node_ssbo_fields(n, numUniforms, wrotePaintColor);
310 }
311 result += "};\n\n";
312
313 if (!*numUniforms) {
314 // No uniforms were added
315 return {};
316 }
317
319 "layout (binding=%d) readonly buffer FSUniforms {\n"
320 " FSUniformData fsUniformData[];\n"
321 "};\n",
322 bufferID);
323 return result;
324}

◆ EmitPaintParamsUniforms()

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

Definition at line 257 of file ContextUtils.cpp.

262 {
263 int offset = 0;
264
265 std::string result = get_uniform_header(bufferID, "FS");
266 for (const ShaderNode* n : nodes) {
267 result += get_node_uniforms(layout, n, &offset, numUniforms, wrotePaintColor);
268 }
269 result.append("};\n\n");
270
271 if (!*numUniforms) {
272 // No uniforms were added
273 return {};
274 }
275
276 if (uniformsTotalBytes) {
277 *uniformsTotalBytes = offset;
278 }
279
280 return result;
281}

◆ EmitRenderStepStorageBuffer()

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

Definition at line 326 of file ContextUtils.cpp.

328 {
329
330 std::string result;
331 result += "struct StepUniformData {\n" +
332 get_ssbo_fields(uniforms, -1, /* wrotePaintColor= */ nullptr) +
333 "};\n\n";
334
336 "layout (binding=%d) readonly buffer StepUniforms {\n"
337 " StepUniformData stepUniformData[];\n"
338 "};\n",
339 bufferID);
340 return result;
341}

◆ EmitRenderStepUniforms()

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

Definition at line 283 of file ContextUtils.cpp.

286 {
287 int offset = 0;
288
289 std::string result = get_uniform_header(bufferID, "Step");
290 result += get_uniforms(layout, uniforms, &offset, -1, /* wrotePaintColor= */ nullptr);
291 result.append("};\n\n");
292
293 if (renderStepUniformsTotalBytes) {
294 *renderStepUniformsTotalBytes = offset;
295 }
296
297 return result;
298}

◆ EmitSamplerLayout()

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

Definition at line 376 of file ContextUtils.cpp.

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

◆ EmitStorageBufferAccess()

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

Definition at line 360 of file ContextUtils.cpp.

362 {
363 return SkSL::String::printf("%sUniformData[%s].%s", bufferNamePrefix, ssboIndex, uniformName);
364}

◆ EmitTexturesAndSamplers()

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

Definition at line 366 of file ContextUtils.cpp.

368 {
369 std::string result;
370 for (const ShaderNode* n : nodes) {
371 result += get_node_texture_samplers(bindingReqs, n, binding);
372 }
373 return result;
374}

◆ EmitUniformsFromStorageBuffer()

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

Definition at line 343 of file ContextUtils.cpp.

345 {
346 std::string result;
347
348 for (const Uniform& u : uniforms) {
349 SkSL::String::appendf(&result, "%s %s", SkSLTypeString(u.type()), u.name());
350 if (u.count()) {
351 SkSL::String::appendf(&result, "[%d]", u.count());
352 }
354 &result, " = %sUniformData[%s].%s;\n", bufferNamePrefix, ssboIndex, u.name());
355 }
356
357 return result;
358}
const char * SkSLTypeString(SkSLType t)

◆ EmitVaryings()

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

Definition at line 427 of file ContextUtils.cpp.

430 {
431 std::string result;
432 int location = 0;
433
434 if (emitSsboIndicesVarying) {
436 " layout(location=%d) %s flat ushort2 %s;\n",
437 location++,
438 direction,
439 RenderStep::ssboIndicesVarying());
440 }
441
442 if (emitLocalCoordsVarying) {
443 SkSL::String::appendf(&result, " layout(location=%d) %s ", location++, direction);
445 SkSL::String::appendf(&result, " localCoordsVar;\n");
446 }
447
448 for (auto v : step->varyings()) {
449 SkSL::String::appendf(&result, " layout(location=%d) %s ", location++, direction);
450 result.append(SkSLTypeString(v.fType));
451 SkSL::String::appendf(&result, " %s;\n", v.fName);
452 }
453
454 return result;
455}

◆ 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
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,
sk_sp< TextureProxy dstTexture,
SkIPoint  dstOffset,
const SkColorInfo targetColorInfo 
)

Definition at line 32 of file ContextUtils.cpp.

40 {
41 SkDEBUGCODE(builder->checkReset());
42
43 gatherer->resetWithNewLayout(layout);
44
45 KeyContext keyContext(
46 recorder, local2Dev, targetColorInfo, p.color(), std::move(dstTexture), dstOffset);
47 p.toKey(keyContext, builder, gatherer);
48
49 UniquePaintParamsID paintID = recorder->priv().shaderCodeDictionary()->findOrCreate(builder);
50 const UniformDataBlock* uniforms = nullptr;
51 const TextureDataBlock* textures = nullptr;
52 if (paintID.isValid()) {
53 if (gatherer->hasUniforms()) {
54 UniformDataCache* uniformDataCache = recorder->priv().uniformDataCache();
55 uniforms = uniformDataCache->insert(gatherer->finishUniformDataBlock());
56 }
57 if (gatherer->hasTextures()) {
58 TextureDataCache* textureDataCache = recorder->priv().textureDataCache();
59 textures = textureDataCache->insert(gatherer->textureDataBlock());
60 }
61 }
62
63 return { paintID, uniforms, textures };
64}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
const T * insert(const T &dataBlock)
const TextureDataBlock & textureDataBlock()
const ShaderCodeDictionary * shaderCodeDictionary() const
TextureDataCache * textureDataCache()
UniformDataCache * uniformDataCache()
UniquePaintParamsID findOrCreate(PaintParamsKeyBuilder *) SK_EXCLUDES(fSpinLock)
std::vector< std::shared_ptr< FakeTexture > > textures

◆ 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 66 of file ContextUtils.cpp.

72 {
73 gatherer->resetWithNewLayout(layout);
74 step->writeUniformsAndTextures(params, gatherer);
75
76 const UniformDataBlock* uniforms =
77 gatherer->hasUniforms() ? uniformDataCache->insert(gatherer->finishUniformDataBlock())
78 : nullptr;
80 gatherer->hasTextures() ? textureDataCache->insert(gatherer->textureDataBlock())
81 : nullptr;
82
83 return { uniforms, textures };
84}
const EmbeddedViewParams * params

◆ Flush() [1/2]

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

Definition at line 147 of file Surface_Graphite.cpp.

147 {
148 return Flush(surface.get());
149}
void Flush(sk_sp< SkSurface > surface)

◆ Flush() [2/2]

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

Definition at line 151 of file Surface_Graphite.cpp.

151 {
152 if (!surface) {
153 return;
154 }
155 auto sb = asSB(surface);
156 if (!sb->isGraphiteBacked()) {
157 return;
158 }
159 auto gs = static_cast<Surface*>(surface);
160 gs->fDevice->flushPendingWorkToRecorder();
161}
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 957 of file KeyHelpers.cpp.

961 {
962 if (!uniformData) {
963 return; // precompiling
964 }
965
966 SkDEBUGCODE(UniformExpectationsValidator uev(gatherer, graphiteUniforms);)
967
968 SkSpan<const SkRuntimeEffect::Uniform> rtsUniforms = effect->uniforms();
969
970 if (!rtsUniforms.empty() && uniformData) {
971 // Collect all the other uniforms from the provided SkData.
972 const uint8_t* uniformBase = uniformData->bytes();
973 for (size_t index = 0; index < rtsUniforms.size(); ++index) {
974 const Uniform& uniform = graphiteUniforms[index];
975 // Get a pointer to the offset in our data for this uniform.
976 const uint8_t* uniformPtr = uniformBase + rtsUniforms[index].offset;
977 // Pass the uniform data to the gatherer.
978 gatherer->write(uniform, uniformPtr);
979 }
980 }
981
983 SkColorSpace* dstCS = keyContext.dstColorInfo().colorSpace();
984 if (!dstCS) {
985 dstCS = sk_srgb_linear_singleton(); // turn colorspace conversion into a noop
986 }
987
988 // TODO(b/332565302): If the runtime shader only uses one of these
989 // transforms, we could upload only one set of uniforms.
990 ColorSpaceTransformBlock::ColorSpaceTransformData dstToLinear(dstCS,
994 ColorSpaceTransformBlock::ColorSpaceTransformData linearToDst(sk_srgb_linear_singleton(),
996 dstCS,
998
999 add_color_space_uniforms(dstToLinear.fSteps, ReadSwizzle::kRGBA, gatherer);
1000 add_color_space_uniforms(linearToDst.fSteps, ReadSwizzle::kRGBA, gatherer);
1001 }
1002}
kUnpremul_SkAlphaType
SkColorSpace * sk_srgb_linear_singleton()
const uint8_t * bytes() const
Definition SkData.h:43
static bool UsesColorTransform(const SkRuntimeEffect *effect)
SkSpan< const Uniform > uniforms() const

◆ GenerateMipmaps()

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

Definition at line 667 of file TextureUtils.cpp.

669 {
670 constexpr SkSamplingOptions kSamplingOptions = SkSamplingOptions(SkFilterMode::kLinear);
671
672 SkASSERT(texture->mipmapped() == Mipmapped::kYes);
673
674 // Within a rescaling pass scratchImg is read from and a scratch surface is written to.
675 // At the end of the pass the scratch surface's texture is wrapped and assigned to scratchImg.
676
677 // The scratch surface we create below will use a write swizzle derived from SkColorType and
678 // pixel format. We have to be consistent and swizzle on the read.
679 auto imgSwizzle = recorder->priv().caps()->getReadSwizzle(colorInfo.colorType(),
680 texture->textureInfo());
681 sk_sp<SkImage> scratchImg(new Image(TextureProxyView(texture, imgSwizzle), colorInfo));
682
683 SkISize srcSize = texture->dimensions();
684 const SkColorInfo outColorInfo = colorInfo.makeAlphaType(kPremul_SkAlphaType);
685
686 // Alternate between two scratch surfaces to avoid reading from and writing to a texture in the
687 // same pass. The dimensions of the first usages of the two scratch textures will be 1/2 and 1/4
688 // those of the original texture, respectively.
689 sk_sp<Surface> scratchSurfaces[2];
690 for (int i = 0; i < 2; ++i) {
691 scratchSurfaces[i] = make_renderable_scratch_surface(
692 recorder,
693 SkImageInfo::Make(SkISize::Make(std::max(1, srcSize.width() >> (i + 1)),
694 std::max(1, srcSize.height() >> (i + 1))),
695 outColorInfo));
696 if (!scratchSurfaces[i]) {
697 return false;
698 }
699 }
700
701 for (int mipLevel = 1; srcSize.width() > 1 || srcSize.height() > 1; ++mipLevel) {
702 const SkISize dstSize = SkISize::Make(std::max(srcSize.width() >> 1, 1),
703 std::max(srcSize.height() >> 1, 1));
704
705 Surface* scratchSurface = scratchSurfaces[(mipLevel - 1) & 1].get();
706
708 paint.setBlendMode(SkBlendMode::kSrc);
709 scratchSurface->getCanvas()->drawImageRect(scratchImg,
710 SkRect::Make(srcSize),
711 SkRect::Make(dstSize),
712 kSamplingOptions,
713 &paint,
715
716 // Make sure the rescaling draw finishes before copying the results.
717 Flush(scratchSurface);
718
719 sk_sp<CopyTextureToTextureTask> copyTask = CopyTextureToTextureTask::Make(
720 static_cast<const Surface*>(scratchSurface)->readSurfaceView().refProxy(),
721 SkIRect::MakeSize(dstSize),
722 texture,
723 {0, 0},
724 mipLevel);
725 if (!copyTask) {
726 return false;
727 }
728 recorder->priv().add(std::move(copyTask));
729
730 scratchImg = scratchSurface->asImage();
731 srcSize = dstSize;
732 }
733
734 return true;
735}
@ 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)
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const
virtual SkCanvas * getCanvas()=0
skgpu::Swizzle getReadSwizzle(SkColorType, const TextureInfo &) const
Definition Caps.cpp:128
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
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()
int keySize() const
Definition Shape.cpp:140
void writeKey(uint32_t *key, bool includeInverted) const
Definition Shape.cpp:177
float SkScalar
Definition extension.cpp:12
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_dst_read_req()

DstReadRequirement skgpu::graphite::get_dst_read_req ( const Caps caps,
Coverage  coverage,
PrecompileBlender blender 
)

Definition at line 151 of file Precompile.cpp.

153 {
154 if (blender) {
155 return GetDstReadRequirement(caps, blender->asBlendMode(), coverage);
156 }
157 return GetDstReadRequirement(caps, SkBlendMode::kSrcOver, coverage);
158}
@ kSrcOver
r = s + (1-sa)*d
virtual std::optional< SkBlendMode > asBlendMode() const
Definition Precompile.h:156
DstReadRequirement GetDstReadRequirement(const Caps *caps, std::optional< SkBlendMode > blendMode, Coverage coverage)

◆ 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 char* dstRow = (char*)dst;
132 for (int y = 0; y < height; y++) {
133 dst = dstRow;
134 for (int x = 0; x < width; x++) {
135 uint16_t color565 = 0;
136 memcpy(&color565, src, a565Bpp);
137 // TODO: create Graphite version of GrColorPackRGBA?
138 uint32_t colorRGBA = masks.getRed(color565) |
139 (masks.getGreen(color565) << 8) |
140 (masks.getBlue(color565) << 16) |
141 (0xFF << 24);
142 memcpy(dst, &colorRGBA, argbBpp);
143 src = (const char*)src + a565Bpp;
144 dst = ( char*)dst + argbBpp;
145 }
146 dstRow += dstRB;
147 }
148 } else {
150 }
151}
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
dst
Definition cp.py:12
constexpr int MaskFormatBytesPerPixel(MaskFormat format)
Definition AtlasTypes.h:110
@ 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 86 of file ContextUtils.cpp.

88 {
89 // If the blend mode is absent, this is assumed to be for a runtime blender, for which we always
90 // do a dst read.
91 if (!blendMode || *blendMode > SkBlendMode::kLastCoeffMode) {
92 return caps->getDstReadRequirement();
93 }
94
95 const bool isLCD = coverage == Coverage::kLCD;
96 const bool hasCoverage = coverage != Coverage::kNone;
97 BlendFormula blendFormula = isLCD ? skgpu::GetLCDBlendFormula(*blendMode)
98 : skgpu::GetBlendFormula(false, hasCoverage, *blendMode);
99 if ((blendFormula.hasSecondaryOutput() && !caps->shaderCaps()->fDualSourceBlendingSupport) ||
100 (coverage == Coverage::kLCD && blendMode != SkBlendMode::kSrcOver)) {
101 return caps->getDstReadRequirement();
102 }
103
104 return DstReadRequirement::kNone;
105}
static bool isLCD(const SkScalerContextRec &rec)
bool hasSecondaryOutput() const
DstReadRequirement getDstReadRequirement() const
Definition Caps.cpp:151
const SkSL::ShaderCaps * shaderCaps() const
Definition Caps.h:74
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 737 of file TextureUtils.cpp.

739 {
740 Mipmapped mipmapped = (sampling.mipmap != SkMipmapMode::kNone)
741 ? Mipmapped::kYes : Mipmapped::kNo;
742
743 if (imageIn->dimensions().area() <= 1 && mipmapped == Mipmapped::kYes) {
744 mipmapped = Mipmapped::kNo;
746 }
747
749 if (as_IB(imageIn)->isGraphiteBacked()) {
750 result = sk_ref_sp(imageIn);
751
752 // If the preexisting Graphite-backed image doesn't have the required mipmaps we will drop
753 // down the sampling
754 if (mipmapped == Mipmapped::kYes && !result->hasMipmaps()) {
755 mipmapped = Mipmapped::kNo;
757 }
758 } else {
759 auto clientImageProvider = recorder->clientImageProvider();
760 result = clientImageProvider->findOrCreate(
761 recorder, imageIn, {mipmapped == Mipmapped::kYes});
762
763 if (!valid_client_provided_image(
764 result.get(), imageIn, {mipmapped == Mipmapped::kYes})) {
765 // The client did not fulfill the ImageProvider contract so drop the image.
766 result = nullptr;
767 }
768 }
769
770 if (sampling.isAniso() && result) {
772 }
773
774 return { result, sampling };
775}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
static SkSamplingOptions AnisoFallback(bool imageIsMipped)
virtual sk_sp< SkImage > findOrCreate(Recorder *recorder, const SkImage *image, SkImage::RequiredProperties)=0
ImageProvider * clientImageProvider()
Definition Recorder.h:87
SkSamplingOptions sampling
Definition SkRecords.h:337
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 583 of file ContextUtils.cpp.

586 {
587 std::string label = renderPassDesc.toString().c_str(); // includes the write swizzle
588 label += " + ";
589 label += renderStep->name();
590 label += " + ";
591 label += dict->idToString(paintID).c_str(); // will be "(empty)" for depth-only draws
592 return label;
593}
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 612 of file MtlCommandBuffer.mm.

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

◆ 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 int32_t >  keyData,
int  currentIndex 
)
static

Definition at line 111 of file PaintParamsKey.cpp.

114 {
115 SkASSERT(currentIndex < SkTo<int>(keyData.size()));
116
117 int32_t id = keyData[currentIndex++];
118 auto entry = dict->getEntry(id);
119 if (!entry) {
120 str->append("UnknownCodeSnippetID:");
121 str->appendS32(id);
122 str->append(" ");
123 return currentIndex;
124 }
125
126 std::string_view name = entry->fName;
127 if (skstd::ends_with(name, "Shader")) {
128 name.remove_suffix(6);
129 }
130 str->append(name);
131
132 if (entry->fNumChildren > 0) {
133 str->append(" [ ");
134 for (int i = 0; i < entry->fNumChildren; ++i) {
135 currentIndex = key_to_string(str, dict, keyData, currentIndex);
136 }
137 str->append("]");
138 }
139
140 str->append(" ");
141 return currentIndex;
142}
void append(const char text[])
Definition SkString.h:203
void appendS32(int32_t value)
Definition SkString.h:208
const ShaderSnippet * getEntry(int codeSnippetID) const SK_EXCLUDES(fSpinLock)
const char * name
Definition fuchsia.cc:50
constexpr bool ends_with(std::string_view str, std::string_view suffix)

◆ LayoutString()

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

Definition at line 83 of file ResourceTypes.h.

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

◆ 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
float fX
x-axis value

◆ load_y_radii()

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

Definition at line 145 of file AnalyticRRectRenderStep.cpp.

◆ 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 1968 of file KeyHelpers.cpp.

1973 {
1975
1976 bool inputPremul = static_cast<bool>(interp.fInPremul);
1977
1978 switch (interp.fColorSpace) {
1979 case ColorSpace::kLab:
1980 case ColorSpace::kOKLab:
1981 case ColorSpace::kOKLabGamutMap:
1982 case ColorSpace::kLCH:
1983 case ColorSpace::kOKLCH:
1984 case ColorSpace::kOKLCHGamutMap:
1985 case ColorSpace::kHSL:
1986 case ColorSpace::kHWB:
1987 inputPremul = false;
1988 break;
1989 default:
1990 break;
1991 }
1992
1993 const SkColorInfo& dstColorInfo = keyContext.dstColorInfo();
1994
1995 SkColorSpace* dstColorSpace =
1996 dstColorInfo.colorSpace() ? dstColorInfo.colorSpace() : sk_srgb_singleton();
1997
1998 SkAlphaType intermediateAlphaType = inputPremul ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
1999
2000 ColorSpaceTransformBlock::ColorSpaceTransformData data(
2001 intermediateCS, intermediateAlphaType, dstColorSpace, dstColorInfo.alphaType());
2002
2003 // The gradient block and colorSpace conversion block need to be combined
2004 // (via the Compose block) so that the localMatrix block can treat them as
2005 // one child.
2006 Compose(keyContext, builder, gatherer,
2007 /* addInnerToKey= */ [&]() -> void {
2008 GradientShaderBlocks::AddBlock(keyContext, builder, gatherer, gradData);
2009 },
2010 /* addOuterToKey= */ [&]() -> void {
2011 ColorSpaceTransformBlock::AddBlock(keyContext, builder, gatherer, data);
2012 });
2013}
static float2 interp(const float2 &v0, const float2 &v1, const float2 &t)

◆ MakeBitmapProxyView()

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

Definition at line 373 of file TextureUtils.cpp.

377 {
378 // Adjust params based on input and Caps
379 const Caps* caps = recorder->priv().caps();
380 SkColorType ct = bitmap.info().colorType();
381
382 if (bitmap.dimensions().area() <= 1) {
383 mipmapped = Mipmapped::kNo;
384 }
385
386 Protected isProtected = recorder->priv().isProtected();
387 auto textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, isProtected,
388 Renderable::kNo);
389 if (!textureInfo.isValid()) {
391 textureInfo = caps->getDefaultSampledTextureInfo(ct, mipmapped, isProtected,
392 Renderable::kNo);
393 }
394 SkASSERT(textureInfo.isValid());
395
396 // Convert bitmap to texture colortype if necessary
397 SkBitmap bmpToUpload;
398 if (ct != bitmap.info().colorType()) {
399 if (!bmpToUpload.tryAllocPixels(bitmap.info().makeColorType(ct)) ||
400 !bitmap.readPixels(bmpToUpload.pixmap())) {
401 return {};
402 }
403 bmpToUpload.setImmutable();
404 } else {
405 bmpToUpload = bitmap;
406 }
407
408 if (!SkImageInfoIsValid(bmpToUpload.info())) {
409 return {};
410 }
411
412 int mipLevelCount = (mipmapped == Mipmapped::kYes) ?
413 SkMipmap::ComputeLevelCount(bitmap.width(), bitmap.height()) + 1 : 1;
414
415
416 // setup MipLevels
417 sk_sp<SkMipmap> mipmaps;
418 std::vector<MipLevel> texels;
419 if (mipLevelCount == 1) {
420 texels.resize(mipLevelCount);
421 texels[0].fPixels = bmpToUpload.getPixels();
422 texels[0].fRowBytes = bmpToUpload.rowBytes();
423 } else {
424 mipmaps = SkToBool(mipmapsIn)
425 ? mipmapsIn
426 : sk_sp<SkMipmap>(SkMipmap::Build(bmpToUpload.pixmap(), nullptr));
427 if (!mipmaps) {
428 return {};
429 }
430
431 SkASSERT(mipLevelCount == mipmaps->countLevels() + 1);
432 texels.resize(mipLevelCount);
433
434 texels[0].fPixels = bmpToUpload.getPixels();
435 texels[0].fRowBytes = bmpToUpload.rowBytes();
436
437 for (int i = 1; i < mipLevelCount; ++i) {
438 SkMipmap::Level generatedMipLevel;
439 mipmaps->getLevel(i - 1, &generatedMipLevel);
440 texels[i].fPixels = generatedMipLevel.fPixmap.addr();
441 texels[i].fRowBytes = generatedMipLevel.fPixmap.rowBytes();
442 SkASSERT(texels[i].fPixels);
443 SkASSERT(generatedMipLevel.fPixmap.colorType() == bmpToUpload.colorType());
444 }
445 }
446
447 // Create proxy
448 sk_sp<TextureProxy> proxy = TextureProxy::Make(caps, recorder->priv().resourceProvider(),
449 bmpToUpload.dimensions(), textureInfo, budgeted);
450 if (!proxy) {
451 return {};
452 }
453 SkASSERT(caps->areColorTypeAndTextureInfoCompatible(ct, proxy->textureInfo()));
454 SkASSERT(mipmapped == Mipmapped::kNo || proxy->mipmapped() == Mipmapped::kYes);
455
456 // Src and dst colorInfo are the same
457 const SkColorInfo& colorInfo = bmpToUpload.info().colorInfo();
458 // Add UploadTask to Recorder
459 UploadInstance upload = UploadInstance::Make(
460 recorder, proxy, colorInfo, colorInfo, texels,
461 SkIRect::MakeSize(bmpToUpload.dimensions()), std::make_unique<ImageUploadContext>());
462 if (!upload.isValid()) {
463 SKGPU_LOG_E("MakeBitmapProxyView: Could not create UploadInstance");
464 return {};
465 }
466 recorder->priv().add(UploadTask::Make(std::move(upload)));
467
468 Swizzle swizzle = caps->getReadSwizzle(ct, textureInfo);
469 // If the color type is alpha-only, propagate the alpha value to the other channels.
470 if (SkColorTypeIsAlphaOnly(colorInfo.colorType())) {
471 swizzle = Swizzle::Concat(swizzle, Swizzle("aaaa"));
472 }
473 return {{std::move(proxy), swizzle}, ct};
474}
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
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:84
Protected isProtected() const
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 
)

Definition at line 500 of file TextureUtils.cpp.

505 {
506 auto mm = requiredProps.fMipmapped ? Mipmapped::kYes : Mipmapped::kNo;
507 auto [view, ct] = MakeBitmapProxyView(recorder, bitmap, std::move(mipmaps), mm, budgeted);
508 if (!view) {
509 return nullptr;
510 }
511
512 SkASSERT(!requiredProps.fMipmapped || view.proxy()->mipmapped() == Mipmapped::kYes);
513 return sk_make_sp<skgpu::graphite::Image>(std::move(view), colorInfo.makeColorType(ct));
514}
SkColorInfo makeColorType(SkColorType newColorType) const
std::tuple< TextureProxyView, SkColorType > MakeBitmapProxyView(Recorder *recorder, const SkBitmap &bitmap, sk_sp< SkMipmap > mipmapsIn, Mipmapped mipmapped, Budgeted budgeted)

◆ MakePrecompileBlender()

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

Definition at line 1488 of file FactoryFunctions.cpp.

1490 {
1491 // TODO: check that 'effect' has the kAllowBlender_Flag bit set and:
1492 // for each entry in childOptions:
1493 // all the SkPrecompileChildPtrs have the same type as the corresponding child in the effect
1494 return sk_make_sp<PrecompileRTEffect<PrecompileBlender>>(std::move(effect), childOptions);
1495}

◆ MakePrecompileColorFilter()

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

Definition at line 1479 of file FactoryFunctions.cpp.

1481 {
1482 // TODO: check that 'effect' has the kAllowColorFilter_Flag bit set and:
1483 // for each entry in childOptions:
1484 // all the SkPrecompileChildPtrs have the same type as the corresponding child in the effect
1485 return sk_make_sp<PrecompileRTEffect<PrecompileColorFilter>>(std::move(effect), childOptions);
1486}

◆ MakePrecompileShader()

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

Definition at line 1470 of file FactoryFunctions.cpp.

1472 {
1473 // TODO: check that 'effect' has the kAllowShader_Flag bit set and:
1474 // for each entry in childOptions:
1475 // all the SkPrecompileChildPtrs have the same type as the corresponding child in the effect
1476 return sk_make_sp<PrecompileRTEffect<PrecompileShader>>(std::move(effect), childOptions);
1477}

◆ MakePromiseImageLazyProxy() [1/2]

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

Definition at line 476 of file TextureUtils.cpp.

484 {
485 SkASSERT(!dimensions.isEmpty());
486 SkASSERT(releaseHelper);
487
488 if (!fulfillProc) {
489 return nullptr;
490 }
491
492 PromiseLazyInstantiateCallback callback{std::move(releaseHelper), fulfillProc,
493 fulfillContext, textureReleaseProc};
494 // Proxies for promise images are assumed to always be destined for a client's SkImage so
495 // are never considered budgeted.
496 return TextureProxy::MakeLazy(caps, dimensions, textureInfo,
497 Budgeted::kNo, isVolatile, std::move(callback));
498}
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 1161 of file KeyHelpers.cpp.

1161 {
1162 SkPMColor4f color = {c.fR, c.fG, c.fB, c.fA};
1164 return color;
1165}
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 71 of file MtlGraphiteUtils.mm.

74 {
75 TRACE_EVENT0("skia.shaders", "driver_compile_shader");
76 NSString* nsSource = [[NSString alloc] initWithBytesNoCopy:const_cast<char*>(msl.data())
77 length:msl.size()
78 encoding:NSUTF8StringEncoding
79 freeWhenDone:NO];
80 if (!nsSource) {
81 return nil;
82 }
83 MTLCompileOptions* options = [[MTLCompileOptions alloc] init];
84
85 // Framebuffer fetch is supported in MSL 2.3 in MacOS 11+.
86 if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) {
87 options.languageVersion = MTLLanguageVersion2_3;
88
89 // array<> is supported in MSL 2.0 on MacOS 10.13+ and iOS 11+,
90 // and in MSL 1.2 on iOS 10+ (but not MacOS).
91 } else if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
92 options.languageVersion = MTLLanguageVersion2_0;
93#if defined(SK_BUILD_FOR_IOS)
94 } else if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, *)) {
95 options.languageVersion = MTLLanguageVersion1_2;
96#endif
97 }
98
99 NSError* error = nil;
100 // TODO: do we need a version with a timeout?
101 sk_cfp<id<MTLLibrary>> compiledLibrary(
102 [sharedContext->device() newLibraryWithSource:(NSString* _Nonnull)nsSource
104 error:&error]);
105 if (!compiledLibrary) {
106 std::string mslStr(msl);
107 errorHandler->compileError(
108 mslStr.c_str(), error.debugDescription.UTF8String, /*shaderWasCached=*/false);
109 return nil;
110 }
111
112 NSString* nsLabel = [[NSString alloc] initWithBytesNoCopy:const_cast<char*>(label.data())
113 length:label.size()
114 encoding:NSUTF8StringEncoding
115 freeWhenDone:NO];
116 compiledLibrary.get().label = nsLabel;
117 return compiledLibrary;
118}
const char * options
virtual void compileError(const char *shader, const char *errors)
size_t length
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

◆ MtlDepthStencilFlagsToFormat()

MTLPixelFormat skgpu::graphite::MtlDepthStencilFlagsToFormat ( SkEnumBitMask< DepthStencilFlags mask)

Definition at line 44 of file MtlGraphiteUtils.mm.

44 {
45 // TODO: Decide if we want to change this to always return a combined depth and stencil format
46 // to allow more sharing of depth stencil allocations.
47 if (mask == DepthStencilFlags::kDepth) {
48 // MTLPixelFormatDepth16Unorm is also a universally supported option here
49 return MTLPixelFormatDepth32Float;
50 } else if (mask == DepthStencilFlags::kStencil) {
51 return MTLPixelFormatStencil8;
52 } else if (mask == DepthStencilFlags::kDepthStencil) {
53 // MTLPixelFormatDepth24Unorm_Stencil8 is supported on Mac family GPUs.
54 return MTLPixelFormatDepth32Float_Stencil8;
55 }
56 SkASSERT(false);
57 return MTLPixelFormatInvalid;
58}

◆ MtlFormatBytesPerBlock()

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

Definition at line 120 of file MtlGraphiteUtils.mm.

120 {
121 return skgpu::MtlFormatBytesPerBlock((MTLPixelFormat) format);
122}
size_t MtlFormatBytesPerBlock(MTLPixelFormat mtlFormat)
Definition MtlUtils.mm:119

◆ MtlFormatToCompressionType()

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

Definition at line 124 of file MtlGraphiteUtils.mm.

124 {
125 return skgpu::MtlFormatToCompressionType((MTLPixelFormat) format);
126}
SkTextureCompressionType MtlFormatToCompressionType(MTLPixelFormat mtlFormat)
Definition MtlUtils.mm:148

◆ MtlFormatToDepthStencilFlags()

SkEnumBitMask< DepthStencilFlags > skgpu::graphite::MtlFormatToDepthStencilFlags ( MTLPixelFormat  format)

Definition at line 60 of file MtlGraphiteUtils.mm.

60 {
61 switch (format) {
62 case MTLPixelFormatDepth32Float: return DepthStencilFlags::kDepth;
63 case MTLPixelFormatStencil8: return DepthStencilFlags::kStencil;
64 case MTLPixelFormatDepth32Float_Stencil8: return DepthStencilFlags::kDepthStencil;
65 default: return DepthStencilFlags::kNone;
66 }
67
69}

◆ 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 69 of file DrawAtlas.cpp.

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

◆ next_id() [2/3]

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

Definition at line 87 of file Recorder.cpp.

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

◆ 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 1424 of file KeyHelpers.cpp.

1424 {
1425 // No-op
1426}

◆ notify_in_use() [2/16]

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

Definition at line 1409 of file KeyHelpers.cpp.

1409 {
1410 // No-op
1411}

◆ notify_in_use() [3/16]

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

Definition at line 1473 of file KeyHelpers.cpp.

1473 {
1474 // No-op
1475}

◆ notify_in_use() [4/16]

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

Definition at line 2159 of file KeyHelpers.cpp.

2159 {
2160 // Gradients do not have children, so no images to notify
2161}

◆ notify_in_use() [5/16]

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

Definition at line 1780 of file KeyHelpers.cpp.

1780 {
1781 // No-op, perlin noise has no children.
1782}

◆ notify_in_use() [6/16]

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

Definition at line 1836 of file KeyHelpers.cpp.

1836 {
1837 // While the SkPicture the shader points to, may have Graphite-backed shaders that need to be
1838 // notified, that will happen when the picture is rendered into an image in add_to_key
1839}

◆ notify_in_use() [7/16]

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

Definition at line 1874 of file KeyHelpers.cpp.

1874 {
1875 // no-op
1876}

◆ notify_in_use() [8/16]

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

Definition at line 1885 of file KeyHelpers.cpp.

1885 {
1886 // no-op
1887}

◆ notify_in_use() [9/16]

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

Definition at line 1681 of file KeyHelpers.cpp.

1683 {
1684 auto image = as_IB(shader->image());
1685 if (!image->isGraphiteBacked()) {
1686 // If it's not graphite-backed, there's no pending graphite work.
1687 return;
1688 }
1689
1690 // TODO(b/323887207): Once scratch devices are linked to special images and their use needs to
1691 // be linked to specific draw contexts, that will be passed in here.
1692 static_cast<Image_Base*>(image)->notifyInUse(recorder);
1693}

◆ notify_in_use() [10/16]

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

Definition at line 1372 of file KeyHelpers.cpp.

1374 {
1375 // SkBlendShader uses a fixed blend mode, so there's no blender to recurse through
1376 NotifyImagesInUse(recorder, drawContext, shader->src().get());
1377 NotifyImagesInUse(recorder, drawContext, shader->dst().get());
1378}
void NotifyImagesInUse(Recorder *recorder, DrawContext *drawContext, const SkBlender *blender)

◆ notify_in_use() [11/16]

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

Definition at line 1442 of file KeyHelpers.cpp.

1444 {
1445 NotifyImagesInUse(recorder, drawContext, shader->shader().get());
1446 NotifyImagesInUse(recorder, drawContext, shader->filter().get());
1447}

◆ notify_in_use() [12/16]

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

Definition at line 1461 of file KeyHelpers.cpp.

1463 {
1464 NotifyImagesInUse(recorder, drawContext, shader->shader().get());
1465}

◆ notify_in_use() [13/16]

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

Definition at line 1396 of file KeyHelpers.cpp.

1396 {
1397 NotifyImagesInUse(recorder, drawContext, shader->proxyShader().get());
1398}

◆ notify_in_use() [14/16]

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

Definition at line 1735 of file KeyHelpers.cpp.

1737 {
1738 NotifyImagesInUse(recorder, drawContext, shader->wrappedShader().get());
1739}

◆ notify_in_use() [15/16]

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

Definition at line 1861 of file KeyHelpers.cpp.

1863 {
1864 notify_in_use(recorder, drawContext, shader->children());
1865}
static void notify_in_use(Recorder *recorder, DrawContext *drawContext, const SkBlendShader *shader)

◆ notify_in_use() [16/16]

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

Definition at line 1917 of file KeyHelpers.cpp.

1919 {
1920 NotifyImagesInUse(recorder, drawContext, shader->shader().get());
1921}

◆ NotifyImagesInUse() [1/3]

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

Definition at line 1149 of file KeyHelpers.cpp.

1149 {
1150 if (!blender) {
1151 return;
1152 }
1153 if (as_BB(blender)->type() == SkBlenderBase::BlenderType::kRuntime) {
1154 const auto* rbb = static_cast<const SkRuntimeBlender*>(blender);
1155 notify_in_use(recorder, drawContext, rbb->children());
1156 } // else blend mode doesn't reference images
1157}

◆ NotifyImagesInUse() [2/3]

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

Definition at line 1333 of file KeyHelpers.cpp.

1333 {
1334 if (!filter) {
1335 return;
1336 }
1337 if (as_CFB(filter)->type() == SkColorFilterBase::Type::kCompose) {
1338 // Recurse to two children
1339 const auto* cf = static_cast<const SkComposeColorFilter*>(filter);
1340 NotifyImagesInUse(recorder, drawContext, cf->inner().get());
1341 NotifyImagesInUse(recorder, drawContext, cf->outer().get());
1342 } else if (as_CFB(filter)->type() == SkColorFilterBase::Type::kWorkingFormat) {
1343 // Recurse to one child
1344 const auto* wfcf = static_cast<const SkWorkingFormatColorFilter*>(filter);
1345 NotifyImagesInUse(recorder, drawContext, wfcf->child().get());
1346 } else if (as_CFB(filter)->type() == SkColorFilterBase::Type::kRuntime) {
1347 // Recurse to all children
1348 const auto* rcf = static_cast<const SkRuntimeColorFilter*>(filter);
1349 notify_in_use(recorder, drawContext, rcf->children());
1350 } // else other color filters do not rely on SkImages
1351}

◆ NotifyImagesInUse() [3/3]

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

Definition at line 2184 of file KeyHelpers.cpp.

2186 {
2187 if (!shader) {
2188 return;
2189 }
2190 switch (as_SB(shader)->type()) {
2191#define M(type) \
2192 case SkShaderBase::ShaderType::k##type: \
2193 notify_in_use(recorder, \
2194 drawContext, \
2195 static_cast<const Sk##type##Shader*>(shader)); \
2196 return;
2198#undef M
2199 }
2201}

◆ 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
bool isEdgeAAQuad() const
Definition Geometry.h:99
static bool opposite_insets_intersect(const SkRRect &rrect, 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}

◆ 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
156 maxInset >= rrect.width() - rrect.radii(SkRRect::kLowerLeft_Corner).fX ||
157 maxInset >= rrect.width() - rrect.radii(SkRRect::kLowerRight_Corner).fX ||
158 maxInset >= rrect.width() - rrect.radii(SkRRect::kUpperLeft_Corner).fX ||
159 maxInset >= rrect.width() - rrect.radii(SkRRect::kUpperRight_Corner).fX ||
160 // Vertical insets would intersect opposite corner's curve
161 maxInset >= rrect.height() - rrect.radii(SkRRect::kLowerLeft_Corner).fY ||
162 maxInset >= rrect.height() - rrect.radii(SkRRect::kLowerRight_Corner).fY ||
163 maxInset >= rrect.height() - rrect.radii(SkRRect::kUpperLeft_Corner).fY ||
164 maxInset >= rrect.height() - rrect.radii(SkRRect::kUpperRight_Corner).fY;
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 160 of file VulkanGraphiteUtils.cpp.

161 {
162 VkShaderStageFlags vkStageFlags = 0;
163 if (stageFlags & PipelineStageFlags::kVertexShader) {
164 vkStageFlags |= VK_SHADER_STAGE_VERTEX_BIT;
165 }
166 if (stageFlags & PipelineStageFlags::kFragmentShader) {
167 vkStageFlags |= VK_SHADER_STAGE_FRAGMENT_BIT;
168 }
169 if (stageFlags & PipelineStageFlags::kCompute) {
170 vkStageFlags |= VK_SHADER_STAGE_COMPUTE_BIT;
171 }
172 return vkStageFlags;
173}
@ VK_SHADER_STAGE_VERTEX_BIT
@ VK_SHADER_STAGE_COMPUTE_BIT
@ VK_SHADER_STAGE_FRAGMENT_BIT
VkFlags VkShaderStageFlags

◆ Precompile() [1/2]

void skgpu::graphite::Precompile ( Context ,
const PaintOptions ,
DrawTypeFlags  = 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 99 of file PublicPrecompile.cpp.

99 {
100
102 const Caps* caps = context->priv().caps();
103
104 auto rtEffectDict = std::make_unique<RuntimeEffectDictionary>();
105
107 KeyContext keyContext(
108 caps, dict, rtEffectDict.get(), ci, /* dstTexture= */ nullptr, /* dstOffset= */ {0, 0});
109
110 for (Coverage coverage : { Coverage::kNone, Coverage::kSingleChannel, Coverage::kLCD }) {
112 context, options, keyContext,
113 static_cast<DrawTypeFlags>(drawTypes & ~DrawTypeFlags::kDrawVertices),
114 /* withPrimitiveBlender= */ false,
115 coverage);
116 }
117
118 if (drawTypes & DrawTypeFlags::kDrawVertices) {
119 for (Coverage coverage: { Coverage::kNone, Coverage::kSingleChannel, Coverage::kLCD }) {
120 // drawVertices w/ colors use a primitiveBlender while those w/o don't
121 for (bool withPrimitiveBlender : { true, false }) {
122 PrecompileCombinations(context, options, keyContext,
123 DrawTypeFlags::kDrawVertices,
124 withPrimitiveBlender,
125 coverage);
126 }
127 }
128 }
129}
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 81 of file PublicPrecompile.cpp.

84 {
85 ResourceProvider* resourceProvider = context->priv().resourceProvider();
86
87 sk_sp<GraphicsPipeline> pipeline = resourceProvider->findOrCreateGraphicsPipeline(
88 rteDict,
89 pipelineDesc,
90 renderPassDesc);
91 if (!pipeline) {
92 SKGPU_LOG_W("Failed to create GraphicsPipeline in precompile!");
93 return false;
94 }
95
96 return true;
97}
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 131 of file PublicPrecompile.cpp.

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

◆ 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:
155 case PrimitiveType::kPoints:
157 }
159}
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
@ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
@ VK_PRIMITIVE_TOPOLOGY_POINT_LIST

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

◆ 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 543 of file TextureUtils.cpp.

548 {
549 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
550 TRACE_EVENT_INSTANT2("skia.gpu", "RescaleImage Src", TRACE_EVENT_SCOPE_THREAD,
551 "width", srcIRect.width(), "height", srcIRect.height());
552 TRACE_EVENT_INSTANT2("skia.gpu", "RescaleImage Dst", TRACE_EVENT_SCOPE_THREAD,
553 "width", dstInfo.width(), "height", dstInfo.height());
554
555 // make a Surface matching dstInfo to rescale into
556 SkSurfaceProps surfaceProps = {};
557 sk_sp<SkSurface> dst = make_renderable_scratch_surface(recorder, dstInfo, &surfaceProps);
558 if (!dst) {
559 return nullptr;
560 }
561
562 SkRect srcRect = SkRect::Make(srcIRect);
563 SkRect dstRect = SkRect::Make(dstInfo.dimensions());
564
565 // Get backing texture information for source Image.
566 // For now this needs to be texturable because we can't depend on copies to scale.
567 auto srcGraphiteImage = reinterpret_cast<const graphite::Image*>(srcImage);
568
569 const TextureProxyView& imageView = srcGraphiteImage->textureProxyView();
570 if (!imageView.proxy()) {
571 // With the current definition of SkImage, this shouldn't happen.
572 // If we allow non-texturable formats for compute, we'll need to
573 // copy to a texturable format.
574 SkASSERT(false);
575 return nullptr;
576 }
577
578 SkISize finalSize = SkISize::Make(dstRect.width(), dstRect.height());
579 if (finalSize == srcIRect.size()) {
580 rescaleGamma = Image::RescaleGamma::kSrc;
581 rescaleMode = Image::RescaleMode::kNearest;
582 }
583
584 // Within a rescaling pass tempInput is read from and tempOutput is written to.
585 // At the end of the pass tempOutput's texture is wrapped and assigned to tempInput.
586 const SkImageInfo& srcImageInfo = srcImage->imageInfo();
587 sk_sp<SkImage> tempInput(new Image(imageView, srcImageInfo.colorInfo()));
588 sk_sp<SkSurface> tempOutput;
589
590 // Assume we should ignore the rescale linear request if the surface has no color space since
591 // it's unclear how we'd linearize from an unknown color space.
592 if (rescaleGamma == Image::RescaleGamma::kLinear &&
593 srcImageInfo.colorSpace() &&
594 !srcImageInfo.colorSpace()->gammaIsLinear()) {
595 // Draw the src image into a new surface with linear gamma, and make that the new tempInput
596 sk_sp<SkColorSpace> linearGamma = srcImageInfo.colorSpace()->makeLinearGamma();
597 SkImageInfo gammaDstInfo = SkImageInfo::Make(srcIRect.size(),
598 tempInput->imageInfo().colorType(),
600 std::move(linearGamma));
601 tempOutput = make_renderable_scratch_surface(recorder, gammaDstInfo, &surfaceProps);
602 if (!tempOutput) {
603 return nullptr;
604 }
605 SkCanvas* gammaDst = tempOutput->getCanvas();
606 SkRect gammaDstRect = SkRect::Make(srcIRect.size());
607
609 paint.setBlendMode(SkBlendMode::kSrc);
610 gammaDst->drawImageRect(tempInput, srcRect, gammaDstRect,
613 tempInput = SkSurfaces::AsImage(std::move(tempOutput));
614 srcRect = gammaDstRect;
615 }
616
617 SkImageInfo outImageInfo = tempInput->imageInfo().makeAlphaType(kPremul_SkAlphaType);
618 do {
619 SkISize nextDims = finalSize;
620 if (rescaleMode != Image::RescaleMode::kNearest &&
621 rescaleMode != Image::RescaleMode::kLinear) {
622 if (srcRect.width() > finalSize.width()) {
623 nextDims.fWidth = std::max((srcRect.width() + 1)/2, (float)finalSize.width());
624 } else if (srcRect.width() < finalSize.width()) {
625 nextDims.fWidth = std::min(srcRect.width()*2, (float)finalSize.width());
626 }
627 if (srcRect.height() > finalSize.height()) {
628 nextDims.fHeight = std::max((srcRect.height() + 1)/2, (float)finalSize.height());
629 } else if (srcRect.height() < finalSize.height()) {
630 nextDims.fHeight = std::min(srcRect.height()*2, (float)finalSize.height());
631 }
632 }
633
634 SkRect stepDstRect;
635 if (nextDims == finalSize) {
636 tempOutput = dst;
637 stepDstRect = dstRect;
638 } else {
639 SkImageInfo nextInfo = outImageInfo.makeDimensions(nextDims);
640 tempOutput = make_renderable_scratch_surface(recorder, nextInfo, &surfaceProps);
641 if (!tempOutput) {
642 return nullptr;
643 }
644 stepDstRect = SkRect::Make(tempOutput->imageInfo().dimensions());
645 }
646
647 SkSamplingOptions samplingOptions;
648 if (rescaleMode == Image::RescaleMode::kRepeatedCubic) {
650 } else {
651 samplingOptions = (rescaleMode == Image::RescaleMode::kNearest) ?
654 }
656 paint.setBlendMode(SkBlendMode::kSrc);
657 tempOutput->getCanvas()->drawImageRect(tempInput, srcRect, stepDstRect, samplingOptions,
659
660 tempInput = SkSurfaces::AsImage(std::move(tempOutput));
661 srcRect = SkRect::Make(nextDims);
662 } while (srcRect.width() != finalSize.width() || srcRect.height() != finalSize.height());
663
664 return SkSurfaces::AsImage(std::move(dst));
665}
#define TRACE_EVENT_SCOPE_THREAD
#define TRACE_FUNC
bool gammaIsLinear() const
sk_sp< SkColorSpace > makeLinearGamma() const
const SkImageInfo & imageInfo() const
Definition SkImage.h:279
SK_API sk_sp< SkImage > AsImage(sk_sp< const SkSurface >)
static constexpr SkCubicResampler CatmullRom()
constexpr SkISize size() const
Definition SkRect.h:172
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
SkImageInfo makeDimensions(SkISize newSize) const
SkColorSpace * colorSpace() const
int width() const
int height() const
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)

◆ 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:130
bool insertRecording(const InsertRecordingInfo &)
Definition Context.cpp:142
TextureProxy * backingTextureProxy() const
const TextureInfo & textureInfo() 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
VkPipelineColorBlendStateCreateFlags flags
const VkPipelineColorBlendAttachmentState * pAttachments
skgpu::BlendCoeff fDstBlend
Definition Blend.h:96
bool fWritesColor
Definition Blend.h:98
skgpu::BlendCoeff fSrcBlend
Definition Blend.h:95
#define VK_FALSE
@ VK_COLOR_COMPONENT_R_BIT
@ VK_COLOR_COMPONENT_A_BIT
@ VK_COLOR_COMPONENT_B_BIT
@ VK_COLOR_COMPONENT_G_BIT
@ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO

◆ 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
@ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO

◆ 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
const VkDynamicState * pDynamicStates
@ VK_DYNAMIC_STATE_BLEND_CONSTANTS
@ VK_DYNAMIC_STATE_VIEWPORT
@ VK_DYNAMIC_STATE_SCISSOR
@ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO

◆ 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
@ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO

◆ 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
VkSampleCountFlagBits rasterizationSamples
@ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO

◆ 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 /*descCount=*/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:194
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
const VkPushConstantRange * pPushConstantRanges
const VkDescriptorSetLayout * pSetLayouts
VkFlags VkPipelineLayoutCreateFlags
@ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO

◆ 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
@ VK_CULL_MODE_NONE
@ VK_FRONT_FACE_COUNTER_CLOCKWISE
@ VK_POLYGON_MODE_FILL
@ VK_POLYGON_MODE_LINE
@ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO

◆ 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
const VkSpecializationInfo * pSpecializationInfo
VkShaderModule const char * pName
VkShaderStageFlagBits stage
@ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO

◆ 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
VkStencilOp passOp
VkCompareOp compareOp
VkStencilOp depthFailOp

◆ 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)
constexpr bool empty() const
Definition SkSpan_impl.h:96
const VkVertexInputAttributeDescription * pVertexAttributeDescriptions
const VkVertexInputBindingDescription * pVertexBindingDescriptions
VkPipelineVertexInputStateCreateFlags flags
@ VK_VERTEX_INPUT_RATE_VERTEX
@ VK_VERTEX_INPUT_RATE_INSTANCE
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO

◆ 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
@ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO

◆ 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 947 of file KeyHelpers.cpp.

947 {
948 // Returns true if both SkData objects hold the same contents, or if they are both null.
949 // (SkData::equals supports passing null, and returns false.)
950 return a ? a->equals(b) : (a == b);
951}
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);
191 SkASSERT(op < (StencilOp)kStencilOpCount);
192 return gTable[(int)op];
193}
VkStencilOp
@ VK_STENCIL_OP_INCREMENT_AND_CLAMP
@ VK_STENCIL_OP_DECREMENT_AND_CLAMP
@ VK_STENCIL_OP_INCREMENT_AND_WRAP
@ VK_STENCIL_OP_KEEP
@ VK_STENCIL_OP_REPLACE
@ VK_STENCIL_OP_ZERO
@ VK_STENCIL_OP_DECREMENT_AND_WRAP
@ VK_STENCIL_OP_INVERT

◆ 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 244 of file VulkanCommandBuffer.cpp.

254 {
255 VkProtectedSubmitInfo protectedSubmitInfo;
256 if (protectedContext == Protected::kYes) {
257 memset(&protectedSubmitInfo, 0, sizeof(VkProtectedSubmitInfo));
259 protectedSubmitInfo.pNext = nullptr;
260 protectedSubmitInfo.protectedSubmit = VK_TRUE;
261 }
262
263 VkSubmitInfo submitInfo;
264 memset(&submitInfo, 0, sizeof(VkSubmitInfo));
266 submitInfo.pNext = protectedContext == Protected::kYes ? &protectedSubmitInfo : nullptr;
267 submitInfo.waitSemaphoreCount = waitCount;
268 submitInfo.pWaitSemaphores = waitSemaphores;
269 submitInfo.pWaitDstStageMask = waitStages;
270 submitInfo.commandBufferCount = commandBufferCount;
271 submitInfo.pCommandBuffers = commandBuffers;
272 submitInfo.signalSemaphoreCount = signalCount;
273 submitInfo.pSignalSemaphores = signalSemaphores;
275 VULKAN_CALL_RESULT(sharedContext, result, QueueSubmit(queue, 1, &submitInfo, fence));
276 return result == VK_SUCCESS;
277}
VkStructureType sType
uint32_t waitSemaphoreCount
const VkPipelineStageFlags * pWaitDstStageMask
uint32_t commandBufferCount
const VkSemaphore * pWaitSemaphores
uint32_t signalSemaphoreCount
const VkCommandBuffer * pCommandBuffers
const void * pNext
const VkSemaphore * pSignalSemaphores
VkStructureType sType
#define VK_TRUE
@ VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO
@ VK_STRUCTURE_TYPE_SUBMIT_INFO

◆ swizzle_class_to_read_enum()

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

Definition at line 1599 of file KeyHelpers.cpp.

1599 {
1600 if (swizzle == skgpu::Swizzle::RGBA()) {
1602 } else if (swizzle == skgpu::Swizzle::RGB1()) {
1604 } else if (swizzle == skgpu::Swizzle("rrr1")) {
1606 } else if (swizzle == skgpu::Swizzle::BGRA()) {
1608 } else if (swizzle == skgpu::Swizzle("000r")) {
1610 } else {
1611 SKGPU_LOG_W("%s is an unsupported read swizzle. Defaulting to RGBA.\n",
1612 swizzle.asString().data());
1614 }
1615}
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 21 of file VulkanSampler.cpp.

21 {
22 switch (tileMode) {
31 }
33}
@ VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT
@ VK_SAMPLER_ADDRESS_MODE_REPEAT
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER

◆ 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()
const RendererProvider * rendererProvider() const
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 97 of file GraphiteResourceCacheTest.cpp.

97 {
98 if (auto gpuDevice = SkCanvasPriv::TopDevice(canvas)->asGraphiteDevice()) {
99 return gpuDevice->target();
100 }
101 return nullptr;
102}
static SkDevice * TopDevice(const SkCanvas *canvas)

◆ uniform_type_to_sksl_type()

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

Definition at line 1486 of file ShaderCodeDictionary.cpp.

1486 {
1489 switch (u.type) {
1490 case Type::kFloat: return SkSLType::kHalf;
1491 case Type::kFloat2: return SkSLType::kHalf2;
1492 case Type::kFloat3: return SkSLType::kHalf3;
1493 case Type::kFloat4: return SkSLType::kHalf4;
1494 case Type::kFloat2x2: return SkSLType::kHalf2x2;
1495 case Type::kFloat3x3: return SkSLType::kHalf3x3;
1496 case Type::kFloat4x4: return SkSLType::kHalf4x4;
1497 // NOTE: shorts cannot be uniforms, so we shouldn't ever get here.
1498 // Defensively return the full precision integer type.
1499 case Type::kInt: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt;
1500 case Type::kInt2: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt2;
1501 case Type::kInt3: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt3;
1502 case Type::kInt4: SkDEBUGFAIL("unsupported uniform type"); return SkSLType::kInt4;
1503 }
1504 } else {
1505 switch (u.type) {
1506 case Type::kFloat: return SkSLType::kFloat;
1507 case Type::kFloat2: return SkSLType::kFloat2;
1508 case Type::kFloat3: return SkSLType::kFloat3;
1509 case Type::kFloat4: return SkSLType::kFloat4;
1510 case Type::kFloat2x2: return SkSLType::kFloat2x2;
1511 case Type::kFloat3x3: return SkSLType::kFloat3x3;
1512 case Type::kFloat4x4: return SkSLType::kFloat4x4;
1513 case Type::kInt: return SkSLType::kInt;
1514 case Type::kInt2: return SkSLType::kInt2;
1515 case Type::kInt3: return SkSLType::kInt3;
1516 case Type::kInt4: return SkSLType::kInt4;
1517 }
1518 }
1520}

◆ 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}
void reserve(int n)
Definition SkTArray.h:165

◆ 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) {
79 case VertexAttribType::kFloat:
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);
99 case VertexAttribType::kByte:
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 193 of file VulkanTexture.cpp.

193 {
194 switch (format) {
198 [[fallthrough]];
201 default:
203 }
204}
@ VK_IMAGE_ASPECT_COLOR_BIT
@ VK_IMAGE_ASPECT_STENCIL_BIT
@ VK_IMAGE_ASPECT_DEPTH_BIT
@ VK_FORMAT_D24_UNORM_S8_UINT
@ VK_FORMAT_S8_UINT
@ VK_FORMAT_D32_SFLOAT_S8_UINT

◆ vkFormatIsSupported()

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

Definition at line 127 of file VulkanGraphiteUtils.cpp.

127 {
128 switch (format) {
154 return true;
155 default:
156 return false;
157 }
158}
@ VK_FORMAT_R8G8B8A8_SRGB
@ VK_FORMAT_R8G8B8_UNORM
@ VK_FORMAT_B8G8R8A8_UNORM
@ VK_FORMAT_B4G4R4A4_UNORM_PACK16
@ VK_FORMAT_R8G8_UNORM
@ VK_FORMAT_R5G6B5_UNORM_PACK16
@ VK_FORMAT_R4G4B4A4_UNORM_PACK16
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
@ VK_FORMAT_BC1_RGB_UNORM_BLOCK
@ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
@ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
@ VK_FORMAT_A2R10G10B10_UNORM_PACK32
@ VK_FORMAT_BC1_RGBA_UNORM_BLOCK
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM

◆ VulkanTextureSpecToTextureInfo()

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

◆ 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 kIndexCount
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 183 of file DrawAtlas.cpp.

◆ kBufferTypeCount

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

Definition at line 71 of file ResourceTypes.h.

◆ kBufferTypeNames

const char* skgpu::graphite::kBufferTypeNames[kBufferTypeCount]
static
Initial value:
= {
"Vertex",
"Index",
"Xfer CPU to GPU",
"Xfer GPU to CPU",
"Uniform",
"Storage",
"Indirect",
"VertexStorage",
"IndexStorage",
}

Definition at line 18 of file DawnBuffer.cpp.

18 {
19 "Vertex",
20 "Index",
21 "Xfer CPU to GPU",
22 "Xfer GPU to CPU",
23 "Uniform",
24 "Storage",
25 "Indirect",
26 "VertexStorage",
27 "IndexStorage",
28};

◆ kBuiltInCodeSnippetIDCount

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

Definition at line 103 of file BuiltInCodeSnippetID.h.

◆ kCompareOpCount

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

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

56 {
57 /*stencilFail=*/ StencilOp::kKeep,
58 /*depthFail=*/ StencilOp::kKeep,
59 /*dsPass=*/ StencilOp::kDecWrap,
60 /*compare=*/ CompareOp::kAlways,
61 /*readMask=*/ 0xffffffff,
62 /*writeMask=*/ 0xffffffff
63};

◆ 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 28 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.

30 {
31 /*front=*/ {},
32 /*back=*/ {},
33 /*stencilRef=*/ 0,
34 /*stencilTest=*/ false,
35 /*depthCompare=*/CompareOp::kGEqual,
36 /*depthTest=*/ true,
37 /*depthWrite=*/ true
38};

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

20 {
21 /*front=*/ {},
22 /*back=*/ {},
23 /*stencilRef=*/ 0,
24 /*stencilTest=*/ false,
25 /*depthCompare=*/CompareOp::kGreater,
26 /*depthTest=*/ true,
27 /*depthWrite=*/ true
28};

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

89 {
90 /*front=*/ kToggle,
91 /*back=*/ kToggle,
92 /*stencilRef=*/ 0,
93 /*stencilTest=*/ true,
94 /*depthCompare=*/CompareOp::kGreater,
95 /*depthTest=*/ true,
96 /*depthWrite=*/ false // The depth write will be handled by the covering pass
97};

◆ 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 262 of file VelloComputeSteps.cpp.

262 {
263 BUFFER_BINDING(ConfigUniform, Uniform, None),
264 BUFFER_BINDING(Segments, ReadOnlyStorage, None),
265 BUFFER_BINDING(PTCL, ReadOnlyStorage, None),
266 BUFFER_BINDING(InfoBinData, ReadOnlyStorage, None),
267 TEXTURE_BINDING(OutputImage, WriteOnlyStorage, None),
268};

◆ 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 270 of file VelloComputeSteps.cpp.

270 {
271 BUFFER_BINDING(ConfigUniform, Uniform, None),
272 BUFFER_BINDING(Segments, ReadOnlyStorage, None),
273 BUFFER_BINDING(PTCL, ReadOnlyStorage, None),
274 BUFFER_BINDING(InfoBinData, ReadOnlyStorage, None),
275 TEXTURE_BINDING(OutputImage, WriteOnlyStorage, None),
276 BUFFER_BINDING(MaskLUT, ReadOnlyStorage, Mapped),
277};

◆ kFixedFunctionBlendModeIDOffset

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

Definition at line 104 of file BuiltInCodeSnippetID.h.

◆ kGraphicsPipelineDomain

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

Definition at line 959 of file MtlCaps.mm.

◆ kGraphicsPipelineKeyData32Count

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

Definition at line 960 of file MtlCaps.mm.

◆ kGridCellSize

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

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

46 {
47 /*stencilFail=*/ StencilOp::kKeep,
48 /*depthFail=*/ StencilOp::kKeep,
49 /*dsPass=*/ StencilOp::kIncWrap,
50 /*compare=*/ CompareOp::kAlways,
51 /*readMask=*/ 0xffffffff,
52 /*writeMask=*/ 0xffffffff
53};

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

141 {
142 /*front=*/ kPassZero,
143 /*back=*/ kPassZero,
144 /*stencilRef=*/ 0,
145 /*stencilTest=*/ true,
146 /*depthCompare=*/CompareOp::kGreater,
147 /*depthTest=*/ true,
148 /*depthWrite=*/ true
149};

◆ kLoadOpCount

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

Definition at line 40 of file ResourceTypes.h.

◆ kMaxBruteForceN

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

Definition at line 314 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 315 of file Device.cpp.

◆ kMtlFormats

constexpr MTLPixelFormat skgpu::graphite::kMtlFormats[]
staticconstexpr
Initial value:
= {
MTLPixelFormatRGBA8Unorm,
MTLPixelFormatR8Unorm,
MTLPixelFormatA8Unorm,
MTLPixelFormatBGRA8Unorm,
MTLPixelFormatRGBA16Float,
MTLPixelFormatR16Float,
MTLPixelFormatRG8Unorm,
MTLPixelFormatRGB10A2Unorm,
MTLPixelFormatRGBA8Unorm_sRGB,
MTLPixelFormatR16Unorm,
MTLPixelFormatRG16Unorm,
MTLPixelFormatRGBA16Unorm,
MTLPixelFormatRG16Float,
MTLPixelFormatStencil8,
MTLPixelFormatDepth32Float,
MTLPixelFormatDepth32Float_Stencil8,
MTLPixelFormatInvalid,
}
#define kMTLPixelFormatB5G6R5Unorm
Definition MtlCaps.mm:333
#define kMTLPixelFormatETC2_RGB8
Definition MtlCaps.mm:335
#define kMTLPixelFormatABGR4Unorm
Definition MtlCaps.mm:334

Definition at line 339 of file MtlCaps.mm.

339 {
340 MTLPixelFormatRGBA8Unorm,
341 MTLPixelFormatR8Unorm,
342 MTLPixelFormatA8Unorm,
343 MTLPixelFormatBGRA8Unorm,
345 MTLPixelFormatRGBA16Float,
346 MTLPixelFormatR16Float,
347 MTLPixelFormatRG8Unorm,
348 MTLPixelFormatRGB10A2Unorm,
349 // MTLPixelFormatBGR10A2Unorm
351 MTLPixelFormatRGBA8Unorm_sRGB,
352 MTLPixelFormatR16Unorm,
353 MTLPixelFormatRG16Unorm,
355#ifdef SK_BUILD_FOR_MAC
356 MTLPixelFormatBC1_RGBA,
357#endif
358 MTLPixelFormatRGBA16Unorm,
359 MTLPixelFormatRG16Float,
360
361 MTLPixelFormatStencil8,
362 MTLPixelFormatDepth32Float,
363 MTLPixelFormatDepth32Float_Stencil8,
364
365 MTLPixelFormatInvalid,
366};

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

108 {
109 /*stencilFail=*/ StencilOp::kKeep,
110 /*depthFail=*/ StencilOp::kZero,
111 /*dsPass=*/ StencilOp::kZero,
112 /*compare=*/ CompareOp::kNotEqual,
113 /*readMask=*/ 0xffffffff,
114 /*writeMask=*/ 0xffffffff
115};

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

118 {
119 /*stencilFail=*/ StencilOp::kZero,
120 /*depthFail=*/ StencilOp::kKeep,
121 /*dsPass=*/ StencilOp::kKeep,
122 /*compare=*/ CompareOp::kEqual,
123 /*readMask=*/ 0xffffffff,
124 /*writeMask=*/ 0xffffffff
125};

◆ kPlotRecentlyUsedCount

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

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

129 {
130 /*front=*/ kPassNonZero,
131 /*back=*/ kPassNonZero,
132 /*stencilRef=*/ 0,
133 /*stencilTest=*/ true,
134 /*depthCompare=*/CompareOp::kGreater,
135 /*depthTest=*/ true,
136 /*depthWrite=*/ true
137};

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

46 {
47 // to LinearSRGB
48 { "flags_toLinear", SkSLType::kInt },
49 { "srcKind_toLinear", SkSLType::kInt },
50 { "gamutTransform_toLinear", SkSLType::kHalf3x3 },
51 { "dstKind_toLinear", SkSLType::kInt },
52 { "csXformCoeffs_toLinear", SkSLType::kHalf4x4 },
53 // from LinearSRGB
54 { "flags_fromLinear", SkSLType::kInt },
55 { "srcKind_fromLinear", SkSLType::kInt },
56 { "gamutTransform_fromLinear", SkSLType::kHalf3x3 },
57 { "dstKind_fromLinear", SkSLType::kInt },
58 { "csXformCoeffs_fromLinear", SkSLType::kHalf4x4 },
59};

◆ 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 171 of file DrawTypes.h.

◆ kStoreOpCount

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

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

66 {
67 /*stencilFail=*/ StencilOp::kKeep,
68 /*depthFail=*/ StencilOp::kKeep,
69 /*dsPass=*/ StencilOp::kInvert,
70 /*compare=*/ CompareOp::kAlways,
71 /*readMask=*/ 0xffffffff,
72 /*writeMask=*/ 0x00000001
73};

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

77 {
78 /*front=*/ kIncrementCW,
79 /*back=*/ kDecrementCCW,
80 /*stencilRef=*/ 0,
81 /*stencilTest=*/ true,
82 /*depthCompare=*/CompareOp::kGreater,
83 /*depthTest=*/ true,
84 /*depthWrite=*/ false // The depth write will be handled by the covering pass
85};

◆ vkLoadOp

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

◆ vkStoreOp

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

Definition at line 23 of file VulkanRenderPass.h.