Flutter Engine
The Flutter Engine
Classes | Functions | Variables
ProgramsTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/gl/GrGLTypes.h"
#include "include/private/base/SkDebug.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkRandom.h"
#include "src/gpu/KeyBuilder.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/Swizzle.h"
#include "src/gpu/ganesh/GrAutoLocaleSetter.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrDrawOpTest.h"
#include "src/gpu/ganesh/GrDrawingManager.h"
#include "src/gpu/ganesh/GrFragmentProcessor.h"
#include "src/gpu/ganesh/GrPaint.h"
#include "src/gpu/ganesh/GrProcessorUnitTest.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "src/gpu/ganesh/effects/GrBlendFragmentProcessor.h"
#include "src/gpu/ganesh/effects/GrPorterDuffXferProcessor.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include <algorithm>
#include <array>
#include <cstdint>
#include <memory>
#include <tuple>
#include <utility>

Go to the source code of this file.

Classes

class  BlockInputFragmentProcessor
 

Functions

static std::unique_ptr< skgpu::ganesh::SurfaceDrawContextrandom_surface_draw_context (GrRecordingContext *rContext, SkRandom *random, const GrCaps *caps)
 
static int get_programs_max_stages (const sk_gpu_test::ContextInfo &ctxInfo)
 
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)
 
 DEF_GANESH_TEST (Programs, reporter, options, CtsEnforcement::kNever)
 

Variables

static const uint32_t kMaxKeySize = 1024
 
static const int kRenderTargetHeight = 1
 
static const int kRenderTargetWidth = 1
 

Function Documentation

◆ DEF_GANESH_TEST()

DEF_GANESH_TEST ( Programs  ,
reporter  ,
options  ,
CtsEnforcement::kNever   
)

Definition at line 449 of file ProgramsTest.cpp.

449 {
450 // Set a locale that would cause shader compilation to fail because of , as decimal separator.
451 // skbug 3330
452#ifdef SK_BUILD_FOR_WIN
453 GrAutoLocaleSetter als("sv-SE");
454#else
455 GrAutoLocaleSetter als("sv_SE.UTF-8");
456#endif
457
458 // We suppress prints to avoid spew
460 opts.fSuppressPrints = true;
461 sk_gpu_test::GrContextFactory debugFactory(opts);
463}
const char * options
reporter
Definition: FontMgrTest.cpp:39
static void test_programs(skiatest::Reporter *reporter, const sk_gpu_test::ContextInfo &ctxInfo)
bool IsRenderingContext(skgpu::ContextType type)
Definition: ContextType.cpp:88
void RunWithGaneshTestContexts(GrContextTestFn *testFn, ContextTypeFilterFn *filter, Reporter *reporter, const GrContextOptions &options)

◆ get_programs_max_levels()

static int get_programs_max_levels ( const sk_gpu_test::ContextInfo ctxInfo)
static

Definition at line 409 of file ProgramsTest.cpp.

409 {
410 // A full tree with 5 levels (31 nodes) may cause a program that exceeds shader limits
411 // (e.g. uniform or varying limits); maxTreeLevels should be a number from 1 to 4 inclusive.
412 int maxTreeLevels = 4;
413 if (skiatest::IsGLContextType(ctxInfo.type())) {
414 // On iOS we can exceed the maximum number of varyings. http://skbug.com/6627.
415#ifdef SK_BUILD_FOR_IOS
416 maxTreeLevels = 2;
417#endif
418#if defined(SK_BUILD_FOR_ANDROID) && defined(SK_GL)
419 GrGLGpu* gpu = static_cast<GrGLGpu*>(ctxInfo.directContext()->priv().getGpu());
420 // Tecno Spark 3 Pro with Power VR Rogue GE8300 will fail shader compiles with
421 // no message if the shader is particularly long.
422 if (gpu->ctxInfo().vendor() == GrGLVendor::kImagination) {
423 maxTreeLevels = 3;
424 }
425#endif
426 if (ctxInfo.type() == skgpu::ContextType::kANGLE_D3D9_ES2 ||
428 // On Angle D3D we will hit a limit of out variables if we use too many stages.
429 maxTreeLevels = 2;
430 }
431 }
432 return maxTreeLevels;
433}
GrDirectContextPriv priv()
GrGLVendor vendor() const
Definition: GrGLContext.h:40
const GrGLContextInfo & ctxInfo() const
Definition: GrGLGpu.h:104
GrDirectContext * directContext() const
skgpu::ContextType type() const
@ kANGLE_D3D11_ES2
ANGLE on Direct3D9 OpenGL ES 2 context.
@ kANGLE_D3D9_ES2
OpenGL ES context.
bool IsGLContextType(skgpu::ContextType type)

◆ get_programs_max_stages()

static int get_programs_max_stages ( const sk_gpu_test::ContextInfo ctxInfo)
static

Definition at line 376 of file ProgramsTest.cpp.

376 {
377 int maxStages = 6;
378#ifdef SK_GL
379 auto context = ctxInfo.directContext();
380 if (skiatest::IsGLContextType(ctxInfo.type())) {
381 GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
382 if (kGLES_GrGLStandard == gpu->glStandard()) {
383 // We've had issues with driver crashes and HW limits being exceeded with many effects on
384 // Android devices. We have passes on ARM devices with the default number of stages.
385 // TODO When we run ES 3.00 GLSL in more places, test again
386#ifdef SK_BUILD_FOR_ANDROID
387 if (gpu->ctxInfo().vendor() != GrGLVendor::kARM) {
388 maxStages = 1;
389 }
390#endif
391 // On iOS we can exceed the maximum number of varyings. http://skbug.com/6627.
392#ifdef SK_BUILD_FOR_IOS
393 maxStages = 3;
394#endif
395 }
396 // On Angle D3D we will hit a limit of out variables if we use too many stages. This is
397 // particularly true on D3D9 with a low limit on varyings and the fact that every varying is
398 // packed as though it has 4 components.
399 if (ctxInfo.type() == skgpu::ContextType::kANGLE_D3D9_ES2) {
400 maxStages = 2;
401 } else if (ctxInfo.type() == skgpu::ContextType::kANGLE_D3D11_ES2) {
402 maxStages = 3;
403 }
404 }
405#endif
406 return maxStages;
407}
@ kGLES_GrGLStandard
Definition: GrGLTypes.h:22
GrGLStandard glStandard() const
Definition: GrGLGpu.h:105

◆ random_surface_draw_context()

static std::unique_ptr< skgpu::ganesh::SurfaceDrawContext > random_surface_draw_context ( GrRecordingContext rContext,
SkRandom random,
const GrCaps caps 
)
static

Definition at line 161 of file ProgramsTest.cpp.

162 {
165
168
169 int sampleCnt = random->nextBool() ? caps->getRenderTargetSampleCount(2, format) : 1;
170 // Above could be 0 if msaa isn't supported.
171 sampleCnt = std::max(1, sampleCnt);
172
175 nullptr,
179 /*label=*/{},
180 sampleCnt,
183 origin);
184}
GrColorType
Definition: GrTypesPriv.h:540
GrSurfaceOrigin
Definition: GrTypes.h:147
@ kBottomLeft_GrSurfaceOrigin
Definition: GrTypes.h:149
@ kTopLeft_GrSurfaceOrigin
Definition: GrTypes.h:148
static const int kRenderTargetWidth
static const int kRenderTargetHeight
GrBackendFormat getDefaultBackendFormat(GrColorType, GrRenderable) const
Definition: GrCaps.cpp:400
virtual int getRenderTargetSampleCount(int requestedCount, const GrBackendFormat &) const =0
bool nextBool()
Definition: SkRandom.h:117
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
uint32_t uint32_t * format
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ test_programs()

static void test_programs ( skiatest::Reporter reporter,
const sk_gpu_test::ContextInfo ctxInfo 
)
static

Definition at line 435 of file ProgramsTest.cpp.

435 {
436 int maxStages = get_programs_max_stages(ctxInfo);
437 if (maxStages == 0) {
438 return;
439 }
440 int maxLevels = get_programs_max_levels(ctxInfo);
441 if (maxLevels == 0) {
442 return;
443 }
444
446 maxLevels));
447}
static int get_programs_max_stages(const sk_gpu_test::ContextInfo &ctxInfo)
static int get_programs_max_levels(const sk_gpu_test::ContextInfo &ctxInfo)
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
static bool ProgramUnitTest(GrDirectContext *, int maxStages, int maxLevels)

Variable Documentation

◆ kMaxKeySize

const uint32_t kMaxKeySize = 1024
static

Definition at line 64 of file ProgramsTest.cpp.

◆ kRenderTargetHeight

const int kRenderTargetHeight = 1
static

Definition at line 158 of file ProgramsTest.cpp.

◆ kRenderTargetWidth

const int kRenderTargetWidth = 1
static

Definition at line 159 of file ProgramsTest.cpp.