53#include <initializer_list>
64namespace skgpu {
class KeyBuilder; }
78 return GrOp::Make<TestVertexOp>(context,
85 const char*
name()
const override {
return "TestVertexOp"; }
121 , fBaseVertex(baseVertex)
122 , fVertexCount(vertexCount) {
126 GrProgramInfo* programInfo()
override {
return fProgramInfo; }
128 void onCreateProgramInfo(
const GrCaps* caps,
131 bool usesMSAASurface,
141 std::move(appliedClip),
144 std::move(fProcessorSet),
146 renderPassXferBarriers,
157 const char*
name()
const override {
return "TestVertexOp::GP"; }
159 std::unique_ptr<ProgramImpl> makeProgramImpl(
const GrShaderCaps&)
const override {
167 void onEmitCode(EmitArgs&
args, GrGPArgs* gpArgs)
override {
168 const auto& gp =
args.fGeomProc.cast<
GP>();
169 args.fVaryingHandler->emitAttributes(gp);
170 args.fFragBuilder->codeAppendf(
"half4 %s = half4(0, 1, 0, 1);",
172 args.fFragBuilder->codeAppendf(
"const half4 %s = half4(1);",
173 args.fOutputCoverage);
174 WriteOutputPosition(
args.fVertBuilder, gpArgs, kPos.name());
177 UniformHandle fLocalMatrixUni;
180 return std::make_unique<Impl>();
190 fMesh =
target->allocMesh();
191 fMesh->
set(fBuffer, fVertexCount, fBaseVertex);
223 if (!ctxInfo.directContext()->priv().caps()->transferFromBufferToBufferSupport()) {
233 GrGpu* gpu = ctxInfo.directContext()->priv().getGpu();
235 auto create_cpu_to_gpu_buffer = [&](
int baseVertex) {
237 int totalVertices = baseVertex + 6;
238 auto points = std::make_unique<SkPoint[]>(totalVertices);
239 SkPoint offscreenPt{-10000, -10000};
240 std::fill_n(
points.get(), totalVertices, offscreenPt);
243 static constexpr SkPoint kUnitQuad[] {{0, 0}, {0, 1}, {1, 0},
244 {1, 0}, {0, 1}, {1, 1}};
245 std::copy_n(kUnitQuad, 6,
points.get() + baseVertex);
257 bool minSizedTransfers) {
259 int dstVertexCount = vbBaseVertex + 6;
260 auto points = std::make_unique<SkPoint[]>(dstVertexCount);
261 SkPoint offscreenPt{-10000, -10000};
262 std::fill_n(
points.get(), dstVertexCount, offscreenPt);
265 dstVertexCount*
sizeof(
SkPoint),
271 static constexpr size_t kTotalSize = 6*
sizeof(
SkPoint);
273 size_t srcOffset = srcBaseVertex*
sizeof(
SkPoint);
274 size_t vbOffset = vbBaseVertex*
sizeof(
SkPoint);
277 SkASSERT(kTotalSize % alignment == 0);
280 if (minSizedTransfers) {
281 for (
size_t n = kTotalSize/alignment,
i = 0;
i < n; ++
i) {
284 srcOffset +
i*alignment,
286 vbOffset +
i*alignment,
290 srcOffset +
i*alignment,
292 vbOffset +
i*alignment,
296 }
else if (useTask) {
318 for (
bool useTask : {
false,
true}) {
319 for (
bool minSizedTransfers : {
false,
true}) {
320 for (
int srcBaseVertex : {0, 5}) {
321 auto src = create_cpu_to_gpu_buffer(srcBaseVertex);
326 for (
int vbBaseVertex : {0, 2}) {
327 auto vb = create_vertex_buffer(
src,
339 static constexpr SkRect kBounds{0, 0, 1, 1};
351 if (!sdc->readPixels(dc, pm, {0, 0})) {
359 "vb base vertex: %d, "
361 "minSizedTransfers: %d",
378 GrGpu* gpu = ctxInfo.directContext()->priv().getGpu();
380 static constexpr SkPoint kUnitQuad[] {{0, 0}, {0, 1}, {1, 0},
381 {1, 0}, {0, 1}, {1, 1}};
397 for (
bool piecewise : {
false,
true}) {
399 for (
size_t offset : {
size_t{0}, 4*
sizeof(
SkPoint),
size_t{1},
size_t{27}}) {
419 const void*
src = kUnitQuad;
420 size_t updateSize =
sizeof(kUnitQuad);
425 std::unique_ptr<char[]> tempSrc;
428 size_t pad =
sizeof(
SkPoint) - r;
431 updateSize =
SkAlignTo(updateSize, alignment);
434 tempSrc.reset(
new char[updateSize]);
435 std::memcpy(tempSrc.get() + pad, kUnitQuad,
sizeof(kUnitQuad));
440 size_t pieceSize = alignment;
446 auto piece = std::make_unique<unsigned char[]>(pieceSize + 2);
447 piece[0] = piece[pieceSize + 1] = 0xFF;
449 for (
size_t o = 0; o < updateSize; o += pieceSize) {
450 memcpy(&piece[1], SkTAddOffset<const void>(
src, o), pieceSize);
451 if (!vb->updateData(&piece[1],
offset + o, pieceSize,
true)) {
456 }
else if (!vb->updateData(
src,
offset, updateSize,
false)) {
463 static constexpr SkRect kBounds{0, 0, 1, 1};
475 if (!sdc->readPixels(dc, pm, {0, 0})) {
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(GrGpuBufferTransferTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_U)
#define DEFINE_OP_CLASS_ID
std::function< void(GrSurfaceProxy *, skgpu::Mipmapped)> GrVisitProxyFunc
@ kDynamic_GrAccessPattern
@ kStatic_GrAccessPattern
@ kFloat2_GrVertexAttribType
static const int points[]
static const uint64_t kGreen
static const uint64_t kRed
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define REPORTER_ASSERT(r, cond,...)
size_t bufferUpdateDataPreserveAlignment() const
size_t transferFromBufferToBufferAlignment() const
GrDirectContextPriv priv()
void newBufferTransferTask(sk_sp< GrGpuBuffer > src, size_t srcOffset, sk_sp< GrGpuBuffer > dst, size_t dstOffset, size_t size)
void setVertexAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
const GrCaps * caps() const
bool transferFromBufferToBuffer(sk_sp< GrGpuBuffer > src, size_t srcOffset, sk_sp< GrGpuBuffer > dst, size_t dstOffset, size_t size)
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType intendedType, GrAccessPattern accessPattern)
void createProgramInfo(const GrCaps *caps, SkArenaAlloc *arena, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrAppliedClip &&appliedClip, const GrDstProxyView &dstProxyView, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
void drawMesh(const GrSimpleMesh &mesh)
void bindPipelineAndScissorClip(const GrProgramInfo &programInfo, const SkRect &drawBounds)
void bindTextures(const GrGeometryProcessor &geomProc, const GrSurfaceProxy &singleGeomProcTexture, const GrPipeline &pipeline)
std::unique_ptr< GrOp > Owner
const SkRect & bounds() const
void setBounds(const SkRect &newBounds, HasAABloat aabloat, IsHairline zeroArea)
static GrPixmap Allocate(const GrImageInfo &info)
Analysis finalize(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage, const GrAppliedClip *, const GrUserStencilSettings *, const GrCaps &, GrClampType, SkPMColor4f *inputColorOverride)
const GrPipeline & pipeline() const
const GrGeometryProcessor & geomProc() const
void visitFPProxies(const GrVisitProxyFunc &func) const
GrDrawingManager * drawingManager()
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
GrResourceProviderPriv priv()
static GrProgramInfo * CreateProgramInfo(const GrCaps *, SkArenaAlloc *, const GrPipeline *, const GrSurfaceProxyView &writeView, bool usesMSAASurface, GrGeometryProcessor *, GrPrimitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp, const GrUserStencilSettings *=&GrUserStencilSettings::kUnused)
const char * name() const override
GrProcessorSet::Analysis finalize(const GrCaps &caps, const GrAppliedClip *clip, GrClampType clampType) override
FixedFunctionFlags fixedFunctionFlags() const override
void visitProxies(const GrVisitProxyFunc &func) const override
static GrOp::Owner Make(GrRecordingContext *context, sk_sp< GrGpuBuffer > buffer, int baseVertex, int vertexCount, const SkRect &bounds)
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
void set(sk_sp< const GrBuffer > vertexBuffer, int vertexCount, int baseVertex)
static const GrUserStencilSettings & kUnused