157 {
158#endif
159 auto dContext = ctxInfo.directContext();
160
163 nullptr,
167 {});
168 if (!sdc) {
170 return;
171 }
172
176
177
178
182
184
188 int rgb[3] = {-(c & 1) & 0xff, -((c >> 1) & 1) & 0xff, -((c >> 2) & 1) & 0xff};
189
194 };
195
196 std::array<Box, 4>& boxVertices = vertexData.
push_back();
197 for (int i = 0; i < 4; ++i) {
198 boxVertices[i] = {
202 };
203 }
204
205 paint.setARGB(255, rgb[0], rgb[1], rgb[2]);
207 }
208 }
209
210
211
212#define VALIDATE(buff) \
213 do { \
214 if (!buff) { \
215 ERRORF(reporter, #buff " is null."); \
216 return; \
217 } \
218 } while (0)
219
224 for (int j = 0; j < 6; ++j) {
226 }
227 }
228
229
232 },
238 }
239 });
240
247 },
249 int baseRepetition = 0;
250 int i = 0;
251
252
255 int repetitionCount = std::min(3 - baseRepetition,
kBoxCount - i);
256
259 pass->drawIndexed(repetitionCount * 6, baseRepetition * 6, baseRepetition * 4,
260 (baseRepetition + repetitionCount) * 4 - 1,
261 (i - baseRepetition) * 4);
262
263 baseRepetition = (baseRepetition + 1) % 3;
264 i += repetitionCount;
265 }
266 });
267
274 },
276
277
283
284 }
285 });
286
287 for (bool indexed : {false, true}) {
288 if (!dContext->priv().caps()->drawInstancedSupport()) {
289 break;
290 }
291
292 run_test(dContext, indexed ?
"drawIndexedInstanced" :
"drawInstanced",
298 for (int i = 0; i < 6; ++i) {
300 }
302 baseIndexData.
size());
309 std::vector<float>{-1,-1, -1,-1, 0,0, 0,1, 1,0, 1,1});
311 },
313
314
317 int baseVertex = 0;
319 case 0:
320 if (dContext->priv().caps()->shaderCaps()->fVertexIDSupport) {
321 break;
322 }
323 [[fallthrough]];
324 case 1:
326 break;
327 case 2:
329 baseVertex = 2;
330 break;
331 }
332
337 if (indexed) {
341 int baseIndex = (
y % 2);
342 pass->bindBuffers(std::move(indexBuffer), helper->
fInstBuffer,
343 std::move(vertexBuffer));
345 baseVertex);
346 } else {
348 std::move(vertexBuffer));
350 }
351 }
352 });
353 }
354
355 for (bool indexed : {false, true}) {
356 if (!dContext->priv().caps()->drawInstancedSupport()) {
357 break;
358 }
359
360 run_test(dContext, (indexed) ?
"drawIndexedIndirect" :
"drawIndirect",
366 for (int i = 0; i < 6; ++i) {
368 }
369 }
371 baseIndexData.
size());
376 -1,-1, 0,0, 0,1, 1,0, 1,1, -1,-1, 0,0, 1,0, 0,1, 1,1});
378
381 if (indexed) {
382
384 size_t ignoredOffset;
385
386
391 } else {
392
394 size_t ignoredOffset;
395
396
398 &ignoredOffset);
402 }
403
404
406 int baseVertex = (
y % 2) ? 1 : 6;
407 if (indexed) {
408 int baseIndex = 1 +
y * 6;
411 } else {
413 }
414 }
415 },
418 if (indexed) {
422 for (int i = 0; i < 3; ++i) {
429 }
430 } else {
433 for (int i = 0; i < 2; ++i) {
440 }
441 }
442 });
443 }
444}
static GrColor GrColorPackRGBA(unsigned r, unsigned g, unsigned b, unsigned a)
constexpr uint16_t kIndexPattern[6]
static constexpr int kBoxCount
static constexpr int kBoxCountX
static constexpr int kIndexPatternRepeatCount
static constexpr int kImageWidth
static constexpr int kBoxCountY
static constexpr int kBoxSize
static constexpr int kImageHeight
static constexpr bool SkToBool(const T &x)
sk_sp< const GrBuffer > fInstBuffer
sk_sp< const GrBuffer > fIndexBuffer2
sk_sp< const GrBuffer > fVertBuffer
sk_sp< const GrBuffer > getIndexBuffer()
size_t fDrawIndirectBufferOffset
sk_sp< const GrBuffer > fDrawIndirectBuffer
GrMeshDrawTarget * target()
sk_sp< const GrBuffer > fVertBuffer2
sk_sp< const GrBuffer > fIndexBuffer
sk_sp< const GrBuffer > makeVertexBuffer(const TArray< T > &data)
sk_sp< const GrBuffer > makeIndexBuffer(const uint16_t[], int count)
GrOpsRenderPass * bindPipeline(GrPrimitiveType, bool isInstanced, bool hasVertexBuffer)
virtual GrDrawIndexedIndirectWriter makeDrawIndexedIndirectSpace(int drawCount, sk_sp< const GrBuffer > *, size_t *offsetInBytes)=0
virtual GrDrawIndirectWriter makeDrawIndirectSpace(int drawCount, sk_sp< const GrBuffer > *buffer, size_t *offsetInBytes)=0
void bindBuffers(sk_sp< const GrBuffer > indexBuffer, sk_sp< const GrBuffer > instanceBuffer, sk_sp< const GrBuffer > vertexBuffer, GrPrimitiveRestart=GrPrimitiveRestart::kNo)
void drawIndexedIndirect(const GrBuffer *drawIndirectBuffer, size_t bufferOffset, int drawCount)
void drawIndirect(const GrBuffer *drawIndirectBuffer, size_t bufferOffset, int drawCount)
void allocN32Pixels(int width, int height, bool isOpaque=false)
static std::unique_ptr< SurfaceDrawContext > Make(GrRecordingContext *, GrColorType, sk_sp< GrSurfaceProxy >, sk_sp< SkColorSpace >, GrSurfaceOrigin, const SkSurfaceProps &)
void run_test(skiatest::Reporter *reporter, Context *context, SkISize surfaceSize, SkISize recordingSize, SkISize replayOffset, DrawCallback draw, const std::vector< Expectation > &expectations)
void writeIndexed(uint32_t indexCount, uint32_t baseIndex, uint32_t instanceCount, uint32_t baseInstance, int32_t baseVertex)
void write(uint32_t instanceCount, uint32_t baseInstance, uint32_t vertexCount, int32_t baseVertex)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)