222 {
223 if (!ctxInfo.directContext()->priv().caps()->transferFromBufferToBufferSupport()) {
224 return;
225 }
226
228
230
232
233 GrGpu* gpu = ctxInfo.directContext()->priv().getGpu();
234
235 auto create_cpu_to_gpu_buffer = [&](int baseVertex) {
236
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);
241
242
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);
246
251 };
252
254 int srcBaseVertex,
255 int vbBaseVertex,
256 bool useTask,
257 bool minSizedTransfers) {
258
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);
263
265 dstVertexCount*
sizeof(
SkPoint),
268
269
270
271 static constexpr size_t kTotalSize = 6*
sizeof(
SkPoint);
272
273 size_t srcOffset = srcBaseVertex*
sizeof(
SkPoint);
274 size_t vbOffset = vbBaseVertex*
sizeof(
SkPoint);
275
277 SkASSERT(kTotalSize % alignment == 0);
279
280 if (minSizedTransfers) {
281 for (
size_t n = kTotalSize/alignment,
i = 0;
i < n; ++
i) {
282 if (useTask) {
284 srcOffset +
i*alignment,
285 vb,
286 vbOffset +
i*alignment,
287 alignment);
288 } else {
290 srcOffset +
i*alignment,
291 vb,
292 vbOffset +
i*alignment,
293 alignment);
294 }
295 }
296 } else if (useTask) {
298 } else {
300 }
301 return vb;
302 };
303
306 nullptr,
308 {1, 1},
310 std::string_view{});
311 if (!sdc) {
313 return;
314 }
315
317
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);
324 return;
325 }
326 for (int vbBaseVertex : {0, 2}) {
327 auto vb = create_vertex_buffer(
src,
328 srcBaseVertex,
329 vbBaseVertex,
330 useTask,
331 minSizedTransfers);
332 if (!vb) {
334 return;
335 }
336
338
339 static constexpr SkRect kBounds{0, 0, 1, 1};
340
342
344 vb,
345 vbBaseVertex,
346 6,
347 kBounds));
348
351 if (!sdc->readPixels(dc, pm, {0, 0})) {
353 return;
354 }
355
357
359 "vb base vertex: %d, "
360 "use task: %d, "
361 "minSizedTransfers: %d",
362 srcBaseVertex,
363 vbBaseVertex,
364 useTask,
365 minSizedTransfers);
366 }
367 }
368 }
369 }
370}
@ kDynamic_GrAccessPattern
static const int points[]
static const uint64_t kGreen
static const uint64_t kRed
#define REPORTER_ASSERT(r, cond,...)
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)
const GrCaps * caps() const
bool transferFromBufferToBuffer(sk_sp< GrGpuBuffer > src, size_t srcOffset, sk_sp< GrGpuBuffer > dst, size_t dstOffset, size_t size)
static GrPixmap Allocate(const GrImageInfo &info)
GrDrawingManager * drawingManager()
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
GrResourceProviderPriv priv()
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 &)