Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::ShaderKey Struct Reference

#include <shader_key.h>

Classes

struct  Equal
 
struct  Hash
 

Public Member Functions

 ShaderKey (std::string_view p_name, ShaderStage p_stage)
 

Static Public Member Functions

static std::string MakeUserScopedName (std::string_view scope, std::string_view library_id, std::string_view entrypoint)
 
static std::string MakeFallbackLibraryId ()
 

Public Attributes

std::string name
 
ShaderStage stage = ShaderStage::kUnknown
 

Static Public Attributes

static constexpr std::string_view kScopeRuntimeEffect = "re"
 
static constexpr std::string_view kScopeFlutterGPU = "fg"
 Scope tag for Flutter GPU user shader bundles.
 

Detailed Description

Definition at line 18 of file shader_key.h.

Constructor & Destructor Documentation

◆ ShaderKey()

impeller::ShaderKey::ShaderKey ( std::string_view  p_name,
ShaderStage  p_stage 
)
inline

Definition at line 22 of file shader_key.h.

23 : name({p_name.data(), p_name.size()}), stage(p_stage) {}
ShaderStage stage
Definition shader_key.h:20
std::string name
Definition shader_key.h:19

Member Function Documentation

◆ MakeFallbackLibraryId()

std::string impeller::ShaderKey::MakeFallbackLibraryId ( )
static

Returns a process-unique library id for user shader sources that were not constructed via an asset-bearing entry point (e.g. tests, future in-memory APIs). Stable for the lifetime of the source but distinct across sources, so the user-scoped registry name cannot collide.

Definition at line 14 of file shader_key.cc.

14 {
15 static std::atomic<uint64_t> counter{0};
16 return absl::StrCat("auto:", counter.fetch_add(1, std::memory_order_relaxed));
17}

Referenced by flutter::gpu::ShaderLibrary::MakeFromFlatbuffer().

◆ MakeUserScopedName()

std::string impeller::ShaderKey::MakeUserScopedName ( std::string_view  scope,
std::string_view  library_id,
std::string_view  entrypoint 
)
static

Build a registry name for a user-supplied shader so it cannot collide with engine-internal names that share the same source-derived entrypoint.

scope is a short tag identifying the source kind (see kScope* constants below). library_id is an opaque identifier that is stable across reloads of the same logical user shader (typically the asset path that loaded the shader). entrypoint is the original shader entrypoint name as produced by impellerc.

Engine-internal entrypoints generated by impellerc are valid identifiers and therefore cannot contain ':', so the colon-separated format makes user-scoped names unspoofable from the engine namespace.

Definition at line 19 of file shader_key.cc.

21 {
22 return absl::StrCat(scope, ":", library_id, ":", entrypoint);
23}

Referenced by impeller::RuntimeEffectContents::SetRuntimeStage(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

Member Data Documentation

◆ kScopeFlutterGPU

constexpr std::string_view impeller::ShaderKey::kScopeFlutterGPU = "fg"
staticconstexpr

Scope tag for Flutter GPU user shader bundles.

Definition at line 59 of file shader_key.h.

Referenced by impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ kScopeRuntimeEffect

constexpr std::string_view impeller::ShaderKey::kScopeRuntimeEffect = "re"
staticconstexpr

Scope tag for RuntimeStage-backed shaders (FragmentProgram / RuntimeEffect).

Definition at line 56 of file shader_key.h.

Referenced by impeller::RuntimeEffectContents::SetRuntimeStage(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ name

std::string impeller::ShaderKey::name

Definition at line 19 of file shader_key.h.

Referenced by impeller::ShaderKey::Equal::operator()().

◆ stage

ShaderStage impeller::ShaderKey::stage = ShaderStage::kUnknown

Definition at line 20 of file shader_key.h.

Referenced by impeller::ShaderKey::Equal::operator()().


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