/** *SkOpts(shortforSkOptimizations)isamechanismwherewecanshipwithmultipleimplementations *ofasetoffunctionsanddynamicallychoosethebestoneatruntime(e.g.thecallto *SkGraphics::Init(),whichcallsSkOpts::Init())dependingonthedetectedCPUfeatures.Thisis *alsoreferredtoashaving"specializations"ofagivenfunction. * *Forexample,SkiamightbecompiledtosupportCPUsthatonlyhavethesse2instructionset *(https://en.wikipedia.org/wiki/X86_instruction_listings#SSE2_instructions) *butmayberunonamoremodernCPUthatsupportsAVX2instructions. *(https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) *SkOptsallowSkiatohavetwoversionsofarow-blittingfunction,onethatusesnormalC++ *code(e.g.loops,scalarintegermath)andonethatmakesuseoftheAVX2vectortypesand *intrinsicfunctions.ThisfunctionisdeclaredhereintheSkOptsnamespace,andthenthe *implementation(seeSkOpts.cpp)isdeferredtoafunctionofthesamenameinthesse2:: *namespace(theminimumSkiaiscompiledwith)usingDEFINE_DEFAULT. * *Allimplementationsofthisblitfunctionaredoneinaheaderfilefilein//src/opts *(e.g.//src/opts/SkBlitRow_opts.h). ifdefs guard each of the implementations, such that only *oneimplementationispossibleforagivenSK_CPU_X64_LEVEL.Thisheaderwillbecompiled **multiple*timeswithadifferentSK_CPU_X64_LEVELeachcompilation. * *EachCPUinstructionsetthatwewantspecializationsforhasa.cppfilein//src/opts which *definesanInit()functionthatreplacesthefunctionpointersintheSkOptsnamespacewiththe *onesfromthespecializednamespace(e.g.ml3::).These.cppfilesdon'timplementthe *specializations,theyjustrefertothespecializationcreatedintheheaderfiles(e.g. *SkBlitRow_opts.h). * *Atcompiletime: *-SkOpts.cppiscompiledwiththeminimumCPUlevel(e.g.SSE2).Becausethis *fileincludesalltheheadersin//src/opts/, those headers add "the default implementation" *ofalltheirfunctionstotheSK_OPTS_NSnamespace(e.g.sse2::blit_row_color32). *-Eachofthespecialized.cppfilesin//src/opts/ are compiled with their respective *compilerflags.Becausethespecialized.cppfileincludestheheadersthatimplementthe *functionsusingintrinsicsorotherCPU-specificcode,thosespecializedfunctionsendup *inthespecializednamespace,e.g.(ml3::blit_row_color32). * *Atlinktime,thedefaultimplementationsandallspecializationsofallSkOptsfunctionsare *includedintheresultinglibrary/binaryfile. * *Atruntime,SkOpts::Init()willruntheappropriateInitfunctionsthatthecurrentCPUlevel *supportsspecializationsfor(e.g.Init_ml3,Init_ssse3).NotemultipleInitfunctionscan *becalledasCPUinstructionsetsaretypicallysupersetsofolderinstructionsets
*/
struct SkRasterPipelineStage;
namespace SkOpts { // Call to replace pointers to portable functions with pointers to CPU-specific functions. // Thread-safe and idempotent. // Called by SkGraphics::Init(). void Init();
// We can't necessarily express the type of SkRasterPipeline stage functions here, // so we just use this void(*)(void) as a stand-in.
using StageFn = void(*)(void); extern StageFn ops_highp[kNumRasterPipelineHighpOps], just_return_highp; extern StageFn ops_lowp [kNumRasterPipelineLowpOps ], just_return_lowp;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.