bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 8 | #ifndef GrMesh_DEFINED |
| 9 | #define GrMesh_DEFINED |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 10 | |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 11 | #include "GrBuffer.h" |
Brian Salomon | ae5f953 | 2018-07-31 11:03:40 -0400 | [diff] [blame] | 12 | #include "GrPendingIOResource.h" |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 13 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 14 | class GrPrimitiveProcessor; |
| 15 | |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 16 | /** |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 17 | * Used to communicate index and vertex buffers, counts, and offsets for a draw from GrOp to |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 18 | * GrGpu. It also holds the primitive type for the draw. TODO: Consider moving ownership of this |
| 19 | * and draw-issuing responsibility to GrPrimitiveProcessor. The rest of the vertex info lives there |
| 20 | * already (stride, attribute mappings). |
| 21 | */ |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 22 | class GrMesh { |
| 23 | public: |
Brian Salomon | 7eae3e0 | 2018-08-07 14:02:38 +0000 | [diff] [blame] | 24 | GrMesh(GrPrimitiveType primitiveType = GrPrimitiveType::kTriangles) |
| 25 | : fPrimitiveType(primitiveType), fBaseVertex(0) { |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 26 | SkDEBUGCODE(fNonIndexNonInstanceData.fVertexCount = -1;) |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 27 | } |
| 28 | |
Brian Salomon | 7eae3e0 | 2018-08-07 14:02:38 +0000 | [diff] [blame] | 29 | void setPrimitiveType(GrPrimitiveType type) { fPrimitiveType = type; } |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 30 | GrPrimitiveType primitiveType() const { return fPrimitiveType; } |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 31 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 32 | bool isIndexed() const { return SkToBool(fIndexBuffer.get()); } |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 33 | bool isInstanced() const { return SkToBool(fInstanceBuffer.get()); } |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 34 | bool hasVertexData() const { return SkToBool(fVertexBuffer.get()); } |
| 35 | |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 36 | void setNonIndexedNonInstanced(int vertexCount); |
| 37 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 38 | void setIndexed(const GrBuffer* indexBuffer, int indexCount, int baseIndex, |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 39 | uint16_t minIndexValue, uint16_t maxIndexValue, GrPrimitiveRestart); |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 40 | void setIndexedPatterned(const GrBuffer* indexBuffer, int indexCount, int vertexCount, |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 41 | int patternRepeatCount, int maxPatternRepetitionsInIndexBuffer); |
| 42 | |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 43 | void setInstanced(const GrBuffer* instanceBuffer, int instanceCount, int baseInstance, |
| 44 | int vertexCount); |
| 45 | void setIndexedInstanced(const GrBuffer* indexBuffer, int indexCount, |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 46 | const GrBuffer* instanceBuffer, int instanceCount, int baseInstance, |
| 47 | GrPrimitiveRestart); |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 48 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 49 | void setVertexData(const GrBuffer* vertexBuffer, int baseVertex = 0); |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 50 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 51 | class SendToGpuImpl { |
| 52 | public: |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 53 | virtual void sendMeshToGpu(GrPrimitiveType, const GrBuffer* vertexBuffer, int vertexCount, |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 54 | int baseVertex) = 0; |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 55 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 56 | virtual void sendIndexedMeshToGpu(GrPrimitiveType, const GrBuffer* indexBuffer, |
| 57 | int indexCount, int baseIndex, uint16_t minIndexValue, |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 58 | uint16_t maxIndexValue, const GrBuffer* vertexBuffer, |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 59 | int baseVertex, GrPrimitiveRestart) = 0; |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 60 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 61 | virtual void sendInstancedMeshToGpu(GrPrimitiveType, const GrBuffer* vertexBuffer, |
| 62 | int vertexCount, int baseVertex, |
| 63 | const GrBuffer* instanceBuffer, int instanceCount, |
| 64 | int baseInstance) = 0; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 65 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 66 | virtual void sendIndexedInstancedMeshToGpu(GrPrimitiveType, const GrBuffer* indexBuffer, |
| 67 | int indexCount, int baseIndex, |
| 68 | const GrBuffer* vertexBuffer, int baseVertex, |
| 69 | const GrBuffer* instanceBuffer, |
| 70 | int instanceCount, int baseInstance, |
| 71 | GrPrimitiveRestart) = 0; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 72 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 73 | virtual ~SendToGpuImpl() {} |
| 74 | }; |
| 75 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 76 | void sendToGpu(SendToGpuImpl*) const; |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 77 | |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 78 | private: |
Chris Dalton | ff92650 | 2017-05-03 14:36:54 -0400 | [diff] [blame] | 79 | using PendingBuffer = GrPendingIOResource<const GrBuffer, kRead_GrIOType>; |
| 80 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 81 | GrPrimitiveType fPrimitiveType; |
| 82 | PendingBuffer fIndexBuffer; |
| 83 | PendingBuffer fInstanceBuffer; |
| 84 | PendingBuffer fVertexBuffer; |
| 85 | int fBaseVertex; |
| 86 | GrPrimitiveRestart fPrimitiveRestart; |
Chris Dalton | ff92650 | 2017-05-03 14:36:54 -0400 | [diff] [blame] | 87 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 88 | union { |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 89 | struct { // When fIndexBuffer == nullptr and fInstanceBuffer == nullptr. |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 90 | int fVertexCount; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 91 | } fNonIndexNonInstanceData; |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 92 | |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 93 | struct { // When fIndexBuffer != nullptr and fInstanceBuffer == nullptr. |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 94 | struct { |
| 95 | int fIndexCount; |
| 96 | int fPatternRepeatCount; |
| 97 | } fIndexData; |
| 98 | |
| 99 | union { |
| 100 | struct { // When fPatternRepeatCount == 0. |
| 101 | int fBaseIndex; |
| 102 | uint16_t fMinIndexValue; |
| 103 | uint16_t fMaxIndexValue; |
| 104 | } fNonPatternIndexData; |
| 105 | |
| 106 | struct { // When fPatternRepeatCount != 0. |
| 107 | int fVertexCount; |
| 108 | int fMaxPatternRepetitionsInIndexBuffer; |
| 109 | } fPatternData; |
| 110 | }; |
| 111 | }; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 112 | |
| 113 | struct { // When fInstanceBuffer != nullptr. |
| 114 | struct { |
| 115 | int fInstanceCount; |
| 116 | int fBaseInstance; |
| 117 | } fInstanceData; |
| 118 | |
| 119 | union { // When fIndexBuffer == nullptr. |
| 120 | struct { |
| 121 | int fVertexCount; |
| 122 | } fInstanceNonIndexData; |
| 123 | |
| 124 | struct { // When fIndexBuffer != nullptr. |
| 125 | int fIndexCount; |
| 126 | } fInstanceIndexData; |
| 127 | }; |
| 128 | }; |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 129 | }; |
Chris Dalton | ff92650 | 2017-05-03 14:36:54 -0400 | [diff] [blame] | 130 | }; |
| 131 | |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 132 | inline void GrMesh::setNonIndexedNonInstanced(int vertexCount) { |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 133 | fIndexBuffer.reset(nullptr); |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 134 | fInstanceBuffer.reset(nullptr); |
| 135 | fNonIndexNonInstanceData.fVertexCount = vertexCount; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 136 | fPrimitiveRestart = GrPrimitiveRestart::kNo; |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 137 | } |
| 138 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 139 | inline void GrMesh::setIndexed(const GrBuffer* indexBuffer, int indexCount, int baseIndex, |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 140 | uint16_t minIndexValue, uint16_t maxIndexValue, |
| 141 | GrPrimitiveRestart primitiveRestart) { |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 142 | SkASSERT(indexBuffer); |
| 143 | SkASSERT(indexCount >= 1); |
| 144 | SkASSERT(baseIndex >= 0); |
Chris Dalton | a88da48 | 2017-06-06 12:25:28 -0600 | [diff] [blame] | 145 | SkASSERT(maxIndexValue >= minIndexValue); |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 146 | fIndexBuffer.reset(indexBuffer); |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 147 | fInstanceBuffer.reset(nullptr); |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 148 | fIndexData.fIndexCount = indexCount; |
| 149 | fIndexData.fPatternRepeatCount = 0; |
| 150 | fNonPatternIndexData.fBaseIndex = baseIndex; |
| 151 | fNonPatternIndexData.fMinIndexValue = minIndexValue; |
| 152 | fNonPatternIndexData.fMaxIndexValue = maxIndexValue; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 153 | fPrimitiveRestart = primitiveRestart; |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | inline void GrMesh::setIndexedPatterned(const GrBuffer* indexBuffer, int indexCount, |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 157 | int vertexCount, int patternRepeatCount, |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 158 | int maxPatternRepetitionsInIndexBuffer) { |
| 159 | SkASSERT(indexBuffer); |
| 160 | SkASSERT(indexCount >= 1); |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 161 | SkASSERT(vertexCount >= 1); |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 162 | SkASSERT(patternRepeatCount >= 1); |
| 163 | SkASSERT(maxPatternRepetitionsInIndexBuffer >= 1); |
| 164 | fIndexBuffer.reset(indexBuffer); |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 165 | fInstanceBuffer.reset(nullptr); |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 166 | fIndexData.fIndexCount = indexCount; |
| 167 | fIndexData.fPatternRepeatCount = patternRepeatCount; |
| 168 | fPatternData.fVertexCount = vertexCount; |
| 169 | fPatternData.fMaxPatternRepetitionsInIndexBuffer = maxPatternRepetitionsInIndexBuffer; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 170 | fPrimitiveRestart = GrPrimitiveRestart::kNo; |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 171 | } |
| 172 | |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 173 | inline void GrMesh::setInstanced(const GrBuffer* instanceBuffer, int instanceCount, |
| 174 | int baseInstance, int vertexCount) { |
| 175 | SkASSERT(instanceBuffer); |
| 176 | SkASSERT(instanceCount >= 1); |
| 177 | SkASSERT(baseInstance >= 0); |
| 178 | fIndexBuffer.reset(nullptr); |
| 179 | fInstanceBuffer.reset(instanceBuffer); |
| 180 | fInstanceData.fInstanceCount = instanceCount; |
| 181 | fInstanceData.fBaseInstance = baseInstance; |
| 182 | fInstanceNonIndexData.fVertexCount = vertexCount; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 183 | fPrimitiveRestart = GrPrimitiveRestart::kNo; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | inline void GrMesh::setIndexedInstanced(const GrBuffer* indexBuffer, int indexCount, |
| 187 | const GrBuffer* instanceBuffer, int instanceCount, |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 188 | int baseInstance, GrPrimitiveRestart primitiveRestart) { |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 189 | SkASSERT(indexBuffer); |
| 190 | SkASSERT(indexCount >= 1); |
| 191 | SkASSERT(instanceBuffer); |
| 192 | SkASSERT(instanceCount >= 1); |
| 193 | SkASSERT(baseInstance >= 0); |
| 194 | fIndexBuffer.reset(indexBuffer); |
| 195 | fInstanceBuffer.reset(instanceBuffer); |
| 196 | fInstanceData.fInstanceCount = instanceCount; |
| 197 | fInstanceData.fBaseInstance = baseInstance; |
| 198 | fInstanceIndexData.fIndexCount = indexCount; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 199 | fPrimitiveRestart = primitiveRestart; |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 200 | } |
| 201 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 202 | inline void GrMesh::setVertexData(const GrBuffer* vertexBuffer, int baseVertex) { |
| 203 | SkASSERT(baseVertex >= 0); |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 204 | fVertexBuffer.reset(vertexBuffer); |
Chris Dalton | bca46e2 | 2017-05-15 11:03:26 -0600 | [diff] [blame] | 205 | fBaseVertex = baseVertex; |
| 206 | } |
| 207 | |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 208 | inline void GrMesh::sendToGpu(SendToGpuImpl* impl) const { |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 209 | if (this->isInstanced()) { |
| 210 | if (!this->isIndexed()) { |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 211 | impl->sendInstancedMeshToGpu(fPrimitiveType, fVertexBuffer.get(), |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 212 | fInstanceNonIndexData.fVertexCount, fBaseVertex, |
| 213 | fInstanceBuffer.get(), fInstanceData.fInstanceCount, |
| 214 | fInstanceData.fBaseInstance); |
| 215 | } else { |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 216 | impl->sendIndexedInstancedMeshToGpu( |
| 217 | fPrimitiveType, fIndexBuffer.get(), fInstanceIndexData.fIndexCount, 0, |
| 218 | fVertexBuffer.get(), fBaseVertex, fInstanceBuffer.get(), |
| 219 | fInstanceData.fInstanceCount, fInstanceData.fBaseInstance, fPrimitiveRestart); |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 220 | } |
| 221 | return; |
| 222 | } |
| 223 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 224 | if (!this->isIndexed()) { |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 225 | SkASSERT(fNonIndexNonInstanceData.fVertexCount > 0); |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 226 | impl->sendMeshToGpu(fPrimitiveType, fVertexBuffer.get(), |
Chris Dalton | 1d61635 | 2017-05-31 12:51:23 -0600 | [diff] [blame] | 227 | fNonIndexNonInstanceData.fVertexCount, fBaseVertex); |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 228 | return; |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 231 | if (0 == fIndexData.fPatternRepeatCount) { |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 232 | impl->sendIndexedMeshToGpu(fPrimitiveType, fIndexBuffer.get(), fIndexData.fIndexCount, |
| 233 | fNonPatternIndexData.fBaseIndex, |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 234 | fNonPatternIndexData.fMinIndexValue, |
| 235 | fNonPatternIndexData.fMaxIndexValue, fVertexBuffer.get(), |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 236 | fBaseVertex, fPrimitiveRestart); |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 237 | return; |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 240 | SkASSERT(fIndexData.fPatternRepeatCount > 0); |
| 241 | int baseRepetition = 0; |
| 242 | do { |
| 243 | int repeatCount = SkTMin(fPatternData.fMaxPatternRepetitionsInIndexBuffer, |
| 244 | fIndexData.fPatternRepeatCount - baseRepetition); |
| 245 | // A patterned index buffer must contain indices in the range [0..vertexCount]. |
| 246 | int minIndexValue = 0; |
| 247 | int maxIndexValue = fPatternData.fVertexCount * repeatCount - 1; |
Brian Salomon | 802cb31 | 2018-06-08 18:05:20 -0400 | [diff] [blame] | 248 | SkASSERT(fPrimitiveRestart == GrPrimitiveRestart::kNo); |
| 249 | impl->sendIndexedMeshToGpu( |
| 250 | fPrimitiveType, fIndexBuffer.get(), fIndexData.fIndexCount * repeatCount, 0, |
| 251 | minIndexValue, maxIndexValue, fVertexBuffer.get(), |
| 252 | fBaseVertex + fPatternData.fVertexCount * baseRepetition, GrPrimitiveRestart::kNo); |
Chris Dalton | 114a3c0 | 2017-05-26 15:17:19 -0600 | [diff] [blame] | 253 | baseRepetition += repeatCount; |
| 254 | } while (baseRepetition < fIndexData.fPatternRepeatCount); |
Chris Dalton | ff92650 | 2017-05-03 14:36:54 -0400 | [diff] [blame] | 255 | } |
| 256 | |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 257 | #endif |