Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions | Variables
GrPipelineDynamicStateTest.cpp File Reference
#include "include/core/SkAlphaType.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkTArray.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkArenaAlloc.h"
#include "src/core/SkSLTypeShared.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/ganesh/GrBuffer.h"
#include "src/gpu/ganesh/GrColor.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGeometryProcessor.h"
#include "src/gpu/ganesh/GrImageInfo.h"
#include "src/gpu/ganesh/GrOpFlushState.h"
#include "src/gpu/ganesh/GrPipeline.h"
#include "src/gpu/ganesh/GrPixmap.h"
#include "src/gpu/ganesh/GrProcessorSet.h"
#include "src/gpu/ganesh/GrProgramInfo.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrShaderVar.h"
#include "src/gpu/ganesh/GrSimpleMesh.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrUserStencilSettings.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ganesh/glsl/GrGLSLVarying.h"
#include "src/gpu/ganesh/glsl/GrGLSLVertexGeoBuilder.h"
#include "src/gpu/ganesh/ops/GrDrawOp.h"
#include "src/gpu/ganesh/ops/GrOp.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include <array>
#include <cstdint>
#include <initializer_list>
#include <memory>
#include <utility>

Go to the source code of this file.

Classes

struct  Vertex
 

Namespaces

namespace  skgpu
 

Functions

 DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS (GrPipelineDynamicStateTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
 

Variables

static constexpr int kScreenSize = 6
 
static constexpr int kNumMeshes = 4
 
static constexpr int kScreenSplitX = kScreenSize/2
 
static constexpr int kScreenSplitY = kScreenSize/2
 
static const SkIRect kDynamicScissors [kNumMeshes]
 
static const GrColor kMeshColors [kNumMeshes]
 

Function Documentation

◆ DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS()

DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS ( GrPipelineDynamicStateTest  ,
reporter  ,
ctxInfo  ,
CtsEnforcement::kApiLevel_T   
)

Definition at line 226 of file GrPipelineDynamicStateTest.cpp.

229 {
230 auto dContext = ctxInfo.directContext();
231 GrResourceProvider* rp = dContext->priv().resourceProvider();
232
233 auto sdc = skgpu::ganesh::SurfaceDrawContext::Make(dContext,
235 nullptr,
239 /*label=*/{});
240 if (!sdc) {
241 ERRORF(reporter, "could not create render target context.");
242 return;
243 }
244
245 constexpr float d = (float) kScreenSize;
246 Vertex vdata[kNumMeshes * 4] = {
247 {0, 0, kMeshColors[0]},
248 {0, d, kMeshColors[0]},
249 {d, 0, kMeshColors[0]},
250 {d, d, kMeshColors[0]},
251
252 {0, 0, kMeshColors[1]},
253 {0, d, kMeshColors[1]},
254 {d, 0, kMeshColors[1]},
255 {d, d, kMeshColors[1]},
256
257 {0, 0, kMeshColors[2]},
258 {0, d, kMeshColors[2]},
259 {d, 0, kMeshColors[2]},
260 {d, d, kMeshColors[2]},
261
262 {0, 0, kMeshColors[3]},
263 {0, d, kMeshColors[3]},
264 {d, 0, kMeshColors[3]},
265 {d, d, kMeshColors[3]}
266 };
267
268 sk_sp<const GrBuffer> vbuff(rp->createBuffer(vdata,
269 sizeof(vdata),
272 if (!vbuff) {
273 ERRORF(reporter, "vbuff is null.");
274 return;
275 }
276
277 uint32_t resultPx[kScreenSize * kScreenSize];
278
280 sdc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
281 sdc->addDrawOp(GrPipelineDynamicStateTestOp::Make(dContext, scissorTest, vbuff));
284 GrPixmap resultPM(ii, resultPx, kScreenSize*sizeof(uint32_t));
285 sdc->readPixels(dContext, resultPM, {0, 0});
286 for (int y = 0; y < kScreenSize; ++y) {
287 for (int x = 0; x < kScreenSize; ++x) {
288 int expectedColorIdx;
289 if (GrScissorTest::kEnabled == scissorTest) {
290 expectedColorIdx = (x < kScreenSplitX ? 0 : 2) + (y < kScreenSplitY ? 0 : 1);
291 } else {
292 expectedColorIdx = kNumMeshes - 1;
293 }
294 uint32_t expected = kMeshColors[expectedColorIdx];
295 uint32_t actual = resultPx[y * kScreenSize + x];
296 if (expected != actual) {
297 ERRORF(reporter, "[scissor=%s] pixel (%i,%i): got 0x%x expected 0x%x",
298 GrScissorTest::kEnabled == scissorTest ? "enabled" : "disabled", x, y,
299 actual, expected);
300 return;
301 }
302 }
303 }
304 }
305}
reporter
Definition: FontMgrTest.cpp:39
static constexpr int kScreenSplitY
static constexpr int kScreenSplitX
static constexpr int kNumMeshes
static const GrColor kMeshColors[kNumMeshes]
static constexpr int kScreenSize
GrScissorTest
Definition: GrTypesPriv.h:115
@ kDynamic_GrAccessPattern
Definition: GrTypesPriv.h:426
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
#define ERRORF(r,...)
Definition: Test.h:293
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
GrResourceProviderPriv priv()
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
Definition: main.cc:19
double y
double x
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRGBA4f FromBytes_RGBA(uint32_t color)

Variable Documentation

◆ kDynamicScissors

const SkIRect kDynamicScissors[kNumMeshes]
static
Initial value:

Definition at line 76 of file GrPipelineDynamicStateTest.cpp.

◆ kMeshColors

const GrColor kMeshColors[kNumMeshes]
static
Initial value:
{
GrColorPackRGBA(255, 0, 0, 255),
GrColorPackRGBA(0, 255, 0, 255),
GrColorPackRGBA(0, 0, 255, 255),
GrColorPackRGBA(0, 0, 0, 255)
}
static GrColor GrColorPackRGBA(unsigned r, unsigned g, unsigned b, unsigned a)
Definition: GrColor.h:46

Definition at line 83 of file GrPipelineDynamicStateTest.cpp.

◆ kNumMeshes

constexpr int kNumMeshes = 4
staticconstexpr

Definition at line 72 of file GrPipelineDynamicStateTest.cpp.

◆ kScreenSize

constexpr int kScreenSize = 6
staticconstexpr

This is a GPU-backend specific test for dynamic pipeline state. It draws boxes using dynamic scissor rectangles then reads back the result to verify a successful test.

Definition at line 71 of file GrPipelineDynamicStateTest.cpp.

◆ kScreenSplitX

constexpr int kScreenSplitX = kScreenSize/2
staticconstexpr

Definition at line 73 of file GrPipelineDynamicStateTest.cpp.

◆ kScreenSplitY

constexpr int kScreenSplitY = kScreenSize/2
staticconstexpr

Definition at line 74 of file GrPipelineDynamicStateTest.cpp.