69 static std::unique_ptr<GrFragmentProcessor>
Make() {
70 return std::unique_ptr<GrFragmentProcessor>(
new BigKeyProcessor);
73 const char*
name()
const override {
return "Big_Ole_Key"; }
75 std::unique_ptr<ProgramImpl> onMakeProgramImpl()
const override {
78 void emitCode(EmitArgs&
args)
override {
79 args.fFragBuilder->codeAppendf(
"return half4(1);\n");
83 return std::make_unique<Impl>();
86 std::unique_ptr<GrFragmentProcessor> clone()
const override {
return Make(); }
89 BigKeyProcessor() :
INHERITED(kBigKeyProcessor_ClassID, kNone_OptimizationFlags) {}
105#if defined(GR_TEST_UTILS)
106std::unique_ptr<GrFragmentProcessor> BigKeyProcessor::TestCreate(GrProcessorTestData*) {
107 return BigKeyProcessor::Make();
115 static std::unique_ptr<GrFragmentProcessor>
Make(std::unique_ptr<GrFragmentProcessor> fp) {
119 const char*
name()
const override {
return "Block_Input"; }
122 return std::make_unique<GLFP>();
125 std::unique_ptr<GrFragmentProcessor>
clone()
const override {
132 void emitCode(EmitArgs&
args)
override {
134 args.fFragBuilder->codeAppendf(
"return %s;", temp.
c_str());
171 sampleCnt = std::max(1, sampleCnt);
181 skgpu::Mipmapped::kNo,
186#if defined(GR_TEST_UTILS)
187static void set_random_xpf(
GrPaint*
paint, GrProcessorTestData*
d) {
188 paint->setXPFactory(GrXPFactoryTestFactory::Get(
d));
191static std::unique_ptr<GrFragmentProcessor> create_random_proc_tree(GrProcessorTestData*
d,
192 int minLevels,
int maxLevels) {
199 const float terminateProbability = 0.3f;
200 if (1 == minLevels) {
201 bool terminate = (1 == maxLevels) || (
d->fRandom->nextF() < terminateProbability);
203 std::unique_ptr<GrFragmentProcessor>
fp;
205 fp = GrFragmentProcessorTestFactory::Make(
d);
209 if (0 ==
fp->numNonNullChildProcessors()) {
222 auto minLevelsChild = create_random_proc_tree(
d, minLevels, maxLevels - 1);
223 std::unique_ptr<GrFragmentProcessor> otherChild(create_random_proc_tree(
d, 1, maxLevels - 1));
224 if (!minLevelsChild || !otherChild) {
229 std::unique_ptr<GrFragmentProcessor>
fp;
230 if (
d->fRandom->nextF() < 0.5f) {
240static void set_random_color_coverage_stages(
GrPaint*
paint,
241 GrProcessorTestData*
d,
245 const float procTreeProbability = 0.5f;
246 if (
d->fRandom->nextF() < procTreeProbability) {
247 std::unique_ptr<GrFragmentProcessor>
fp(create_random_proc_tree(
d, 2, maxTreeLevels));
249 paint->setColorFragmentProcessor(std::move(fp));
252 if (maxStages >= 1) {
253 if (std::unique_ptr<GrFragmentProcessor> fp = GrFragmentProcessorTestFactory::Make(
d)) {
254 paint->setColorFragmentProcessor(std::move(fp));
257 if (maxStages >= 2) {
258 if (std::unique_ptr<GrFragmentProcessor> fp = GrFragmentProcessorTestFactory::Make(
d)) {
259 paint->setCoverageFragmentProcessor(std::move(fp));
267#if !defined(GR_TEST_UTILS)
274 GrProcessorTestData::ViewInfo views[2];
279 static constexpr SkISize kDims = {34, 18};
297 static constexpr SkISize kDims = {16, 22};
315 if (!std::get<0>(views[0]) || !std::get<0>(views[1])) {
316 SkDebugf(
"Could not allocate textures for test");
321 static const int NUM_TESTS = 1024;
322 for (
int t = 0; t < NUM_TESTS; t++) {
325 if (!surfaceDrawContext) {
326 SkDebugf(
"Could not allocate surfaceDrawContext");
331 GrProcessorTestData ptd(&random, direct, 1, std::size(views), views);
332 set_random_color_coverage_stages(&
paint, &ptd, maxStages, maxLevels);
333 set_random_xpf(&
paint, &ptd);
349 SkDebugf(
"Could not allocate a surfaceDrawContext");
353 int fpFactoryCnt = GrFragmentProcessorTestFactory::Count();
354 for (
int i = 0; i < fpFactoryCnt; ++i) {
356 for (
int j = 0; j < 10; ++j) {
357 GrProcessorTestData ptd(&random, direct, 1, std::size(views),
362 auto fp = GrFragmentProcessorTestFactory::MakeIdx(i, &ptd);
364 paint.setColorFragmentProcessor(std::move(blockFP));
386#ifdef SK_BUILD_FOR_ANDROID
392#ifdef SK_BUILD_FOR_IOS
399 if (ctxInfo.
type() == skgpu::ContextType::kANGLE_D3D9_ES2) {
401 }
else if (ctxInfo.
type() == skgpu::ContextType::kANGLE_D3D11_ES2) {
412 int maxTreeLevels = 4;
415#ifdef SK_BUILD_FOR_IOS
418#if defined(SK_BUILD_FOR_ANDROID) && defined(SK_GL)
426 if (ctxInfo.
type() == skgpu::ContextType::kANGLE_D3D9_ES2 ||
427 ctxInfo.
type() == skgpu::ContextType::kANGLE_D3D11_ES2) {
432 return maxTreeLevels;
437 if (maxStages == 0) {
441 if (maxLevels == 0) {
452#ifdef SK_BUILD_FOR_WIN
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(...)
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST
void GrDrawRandomOp(SkRandom *random, skgpu::ganesh::SurfaceDrawContext *sdc, GrPaint &&paint)
@ kBottomLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
static const int kRenderTargetWidth
static const uint32_t kMaxKeySize
static int get_programs_max_stages(const sk_gpu_test::ContextInfo &ctxInfo)
static const int kRenderTargetHeight
static int get_programs_max_levels(const sk_gpu_test::ContextInfo &ctxInfo)
static void test_programs(skiatest::Reporter *reporter, const sk_gpu_test::ContextInfo &ctxInfo)
static std::unique_ptr< skgpu::ganesh::SurfaceDrawContext > random_surface_draw_context(GrRecordingContext *rContext, SkRandom *random, const GrCaps *caps)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kLastMode
last valid value
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static std::unique_ptr< SkEncoder > Make(SkWStream *dst, const SkPixmap *src, const SkYUVAPixmaps *srcYUVA, const SkColorSpace *srcYUVAColorSpace, const SkJpegEncoder::Options &options)
#define INHERITED(method,...)
#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
#define REPORTER_ASSERT(r, cond,...)
const GrCaps * caps() const
bool mipmapSupport() const
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const =0
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
bool submit(GrSyncCpu sync=GrSyncCpu::kNo)
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
GrDirectContextPriv priv()
static bool ProgramUnitTest(GrDirectContext *, int maxStages, int maxLevels)
SkString invokeChild(int childIndex, EmitArgs &parentArgs, std::string_view skslCoords={})
GrFragmentProcessor * childProcessor(int index)
void registerChild(std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough())
@ kNone_OptimizationFlags
GrGLVendor vendor() const
GrGLStandard glStandard() const
const GrGLContextInfo & ctxInfo() const
static const GrXPFactory * Get(SkBlendMode blendMode)
@ kBlockInputFragmentProcessor_ClassID
sk_sp< GrTextureProxy > createProxy(const GrBackendFormat &, SkISize dimensions, GrRenderable, int renderTargetSampleCnt, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, GrProtected, std::string_view label, GrInternalSurfaceFlags=GrInternalSurfaceFlags::kNone, UseAllocator useAllocator=UseAllocator::kYes)
GrProxyProvider * proxyProvider()
const char * c_str() const
GrDirectContext * directContext() const
skgpu::ContextType type() const
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
uint32_t uint32_t * format
std::unique_ptr< GrFragmentProcessor > Make(std::unique_ptr< GrFragmentProcessor > src, std::unique_ptr< GrFragmentProcessor > dst, SkBlendMode mode, bool shareBlendLogic=true)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
bool IsRenderingContext(skgpu::ContextType type)
void RunWithGaneshTestContexts(GrContextTestFn *testFn, ContextTypeFilterFn *filter, Reporter *reporter, const GrContextOptions &options)
bool IsGLContextType(skgpu::ContextType type)