renderCore.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. // zlib open source license
  2. //
  3. // Copyright (c) 2017 to 2019 David Forsgren Piuva
  4. //
  5. // This software is provided 'as-is', without any express or implied
  6. // warranty. In no event will the authors be held liable for any damages
  7. // arising from the use of this software.
  8. //
  9. // Permission is granted to anyone to use this software for any purpose,
  10. // including commercial applications, and to alter it and redistribute it
  11. // freely, subject to the following restrictions:
  12. //
  13. // 1. The origin of this software must not be misrepresented; you must not
  14. // claim that you wrote the original software. If you use this software
  15. // in a product, an acknowledgment in the product documentation would be
  16. // appreciated but is not required.
  17. //
  18. // 2. Altered source versions must be plainly marked as such, and must not be
  19. // misrepresented as being the original software.
  20. //
  21. // 3. This notice may not be removed or altered from any source
  22. // distribution.
  23. #include <cassert>
  24. #include "renderCore.h"
  25. #include "../../base/virtualStack.h"
  26. #include "shader/RgbaMultiply.h"
  27. #include "constants.h"
  28. using namespace dsr;
  29. class SubVertex {
  30. public:
  31. FVector3D cs; // Camera space position based on the weights
  32. float subB, subC; // Weights for second and third vertices in the parent triangle
  33. int state = 0; // Used by algorithms
  34. float value = 0.0f; // Used by algorithms
  35. SubVertex() : subB(0.0f), subC(0.0f) {}
  36. SubVertex(const FVector3D &cs, float subB, float subC) : cs(cs), subB(subB), subC(subC) {}
  37. SubVertex(const SubVertex &vertexA, const SubVertex &vertexB, float ratio) {
  38. float invRatio = 1.0f - ratio;
  39. this->cs = vertexA.cs * invRatio + vertexB.cs * ratio;
  40. this->subB = vertexA.subB * invRatio + vertexB.subB * ratio;
  41. this->subC = vertexA.subC * invRatio + vertexB.subC * ratio;
  42. }
  43. };
  44. // Returns 0 when value = a
  45. // Returns 0.5 when value = (a + b) / 2
  46. // Returns 1 when value = b
  47. static float inverseLerp(float a, float b, float value) {
  48. float c = b - a;
  49. if (c == 0.0f) {
  50. return 0.5f;
  51. } else {
  52. return (value - a) / c;
  53. }
  54. }
  55. static const int maxPoints = 9; // If a triangle starts with 3 points and each of 6 planes in the view frustum can add one point each then the maximum is 9 points
  56. class ClippedTriangle {
  57. private:
  58. int vertexCount = 0;
  59. public:
  60. int getVertexCount() {
  61. return this->vertexCount;
  62. }
  63. SubVertex vertices[maxPoints] = {};
  64. ClippedTriangle(const ITriangle2D &triangle) {
  65. this->vertices[0] = SubVertex(triangle.position[0].cs, 0.0f, 0.0f);
  66. this->vertices[1] = SubVertex(triangle.position[1].cs, 1.0f, 0.0f);
  67. this->vertices[2] = SubVertex(triangle.position[2].cs, 0.0f, 1.0f);
  68. this->vertexCount = 3;
  69. }
  70. void deleteVertex(int removeIndex) {
  71. assert(removeIndex >= 0);
  72. assert(removeIndex < this->vertexCount);
  73. if (this->vertexCount > 0 && this->vertexCount <= maxPoints) {
  74. for (int v = removeIndex; v < this->vertexCount - 1; v++) {
  75. assert(v >= 0 && v + 1 < maxPoints);
  76. this->vertices[v] = this->vertices[v + 1];
  77. }
  78. this->vertexCount--;
  79. }
  80. }
  81. void insertVertex(int newIndex, const SubVertex &newVertex) {
  82. // Check against buffer overflow in case of bugs from rounding errors
  83. assert(newIndex >= 0);
  84. assert(newIndex <= this->vertexCount);
  85. if (this->vertexCount < maxPoints) {
  86. for (int v = this->vertexCount - 1; v >= newIndex; v--) {
  87. assert(v >= 0 && v + 1 < maxPoints);
  88. this->vertices[v + 1] = this->vertices[v];
  89. }
  90. this->vertices[newIndex] = newVertex;
  91. this->vertexCount++;
  92. }
  93. }
  94. void deleteAll() {
  95. this->vertexCount = 0;
  96. }
  97. // Cut away parts of the triangle that are on the positive side of the plane
  98. void clip(const FPlane3D &plane) {
  99. static const int state_use = 0;
  100. static const int state_delete = 1;
  101. static const int state_modified = 2;
  102. if (this->vertexCount >= 3 && this->vertexCount < maxPoints) {
  103. int outsideCount = 0;
  104. int lastOutside = 0;
  105. for (int v = 0; v < this->vertexCount; v++) {
  106. assert(v >= 0 && v < maxPoints);
  107. float distance = plane.signedDistance(this->vertices[v].cs);
  108. this->vertices[v].value = distance;
  109. if (distance > 0.0f) {
  110. outsideCount++;
  111. lastOutside = v;
  112. this->vertices[v].state = state_delete;
  113. } else {
  114. this->vertices[v].state = state_use;
  115. }
  116. }
  117. if (outsideCount > 0) {
  118. if (outsideCount >= this->vertexCount) {
  119. this->deleteAll();
  120. } else if (outsideCount == 1) {
  121. // Split a single vertex into two corners by interpolating with the previous and next corners
  122. int currentVertex = lastOutside;
  123. int previousVertex = (lastOutside - 1 + this->vertexCount) % this->vertexCount;
  124. int nextVertex = (lastOutside + 1) % this->vertexCount;
  125. float previousToCurrentRatio = inverseLerp(this->vertices[previousVertex].value, this->vertices[currentVertex].value, 0.0f);
  126. float currentToNextRatio = inverseLerp(this->vertices[currentVertex].value, this->vertices[nextVertex].value, 0.0f);
  127. SubVertex cutStart(this->vertices[previousVertex], this->vertices[currentVertex], previousToCurrentRatio);
  128. SubVertex cutEnd(this->vertices[currentVertex], this->vertices[nextVertex], currentToNextRatio);
  129. this->vertices[lastOutside] = cutStart;
  130. insertVertex(nextVertex, cutEnd);
  131. } else {
  132. // Start and end of the cut
  133. for (int currentVertex = 0; currentVertex < this->vertexCount; currentVertex++) {
  134. int previousVertex = (currentVertex - 1 + this->vertexCount) % this->vertexCount;
  135. int nextVertex = (currentVertex + 1) % this->vertexCount;
  136. if (this->vertices[currentVertex].state == state_delete) {
  137. if (this->vertices[previousVertex].state == state_use) {
  138. // Begin the cut
  139. float previousToCurrentRatio = inverseLerp(this->vertices[previousVertex].value, this->vertices[currentVertex].value, 0.0f);
  140. this->vertices[currentVertex] = SubVertex(this->vertices[previousVertex], this->vertices[currentVertex], previousToCurrentRatio);
  141. this->vertices[currentVertex].state = state_modified;
  142. } else if (this->vertices[nextVertex].state == state_use) {
  143. // End the cut
  144. float currentToNextRatio = inverseLerp(this->vertices[currentVertex].value, this->vertices[nextVertex].value, 0.0f);
  145. this->vertices[currentVertex] = SubVertex(this->vertices[currentVertex], this->vertices[nextVertex], currentToNextRatio);
  146. this->vertices[currentVertex].state = state_modified;
  147. }
  148. }
  149. }
  150. // Delete every vertex that is marked for removal
  151. // Looping backwards will avoid using altered indices while deleting
  152. if (outsideCount > 2) {
  153. for (int v = this->vertexCount - 1; v >= 0; v--) {
  154. assert(v >= 0 && v < maxPoints);
  155. if (this->vertices[v].state == state_delete) {
  156. this->deleteVertex(v);
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. };
  165. Visibility dsr::getTriangleVisibility(const ITriangle2D &triangle, const Camera &camera, bool clipFrustum) {
  166. static const int cornerCount = 3;
  167. int planeCount = camera.getFrustumPlaneCount(clipFrustum);
  168. VirtualStackAllocation<bool> outside(cornerCount * planeCount, "Corner outside buffer in getTriangleVIsibility");
  169. // Check which corners are outside of the different planes
  170. int offset = 0;
  171. for (int c = 0; c < cornerCount; c++) {
  172. FVector3D triangleCorner = triangle.position[c].cs;
  173. for (int s = 0; s < planeCount; s++) {
  174. outside[offset + s] = !(camera.getFrustumPlane(s, clipFrustum).inside(triangleCorner));
  175. }
  176. offset += planeCount;
  177. }
  178. // Do not render if all corners are outside of the same side
  179. for (int s = 0; s < planeCount; s++) {
  180. if (outside[s] && outside[s + planeCount] && outside[s + 2 * planeCount]) {
  181. return Visibility::Hidden; // All corners outside of the same plane
  182. }
  183. }
  184. // Partial visibility if any corner is outside of a side
  185. for (int i = 0; i < planeCount * cornerCount; i++) {
  186. if (outside[i]) {
  187. return Visibility::Partial; // Any corner outside of a plane
  188. }
  189. }
  190. return Visibility::Full;
  191. }
  192. static const int alignX = 2;
  193. static const int alignY = 2;
  194. void dsr::executeTriangleDrawing(const TriangleDrawCommand &command, const IRect &clipBound) {
  195. IRect finalClipBound = IRect::cut(command.clipBound, clipBound);
  196. int32_t rowCount = command.triangle.getBufferSize(finalClipBound, alignX, alignY);
  197. if (rowCount > 0) {
  198. int startRow;
  199. // TODO: Use SafePointer in shape functions.
  200. VirtualStackAllocation<RowInterval> rows(rowCount, "Row intervals in executeTriangleDrawing");
  201. command.triangle.getShape(startRow, rows.getUnsafe(), finalClipBound, alignX, alignY);
  202. Projection projection = command.triangle.getProjection(command.subB, command.subC, command.perspective);
  203. command.processTriangle(command.triangleInput, command.targetImage, command.depthBuffer, command.triangle, projection, RowShape(startRow, rowCount, rows.getUnsafe()), command.filter);
  204. #ifdef SHOW_POST_CLIPPING_WIREFRAME
  205. drawWireframe(command.targetImage, command.triangle);
  206. #endif
  207. }
  208. }
  209. // Draw a linearly interpolated sub-triangle for clipping
  210. static void drawSubTriangle(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, const IRect &clipBound, const SubVertex &vertexA, const SubVertex &vertexB, const SubVertex &vertexC) {
  211. //Get the weight of the first corner from the other weights
  212. FVector3D subB(vertexA.subB, vertexB.subB, vertexC.subB);
  213. FVector3D subC(vertexA.subC, vertexB.subC, vertexC.subC);
  214. //FVector3D subA = FVector3D(1.0f, 1.0f, 1.0f) - (subB + subC);
  215. ProjectedPoint posA = camera.cameraToScreen(vertexA.cs);
  216. ProjectedPoint posB = camera.cameraToScreen(vertexB.cs);
  217. ProjectedPoint posC = camera.cameraToScreen(vertexC.cs);
  218. // Create the sub-triangle
  219. ITriangle2D triangle(posA, posB, posC);
  220. // Rounding sub-triangles to integer locations may reverse the direction of zero area triangles
  221. if (triangle.isFrontfacing()) {
  222. TriangleDrawCommand command(triangleDrawData, triangle, subB, subC, clipBound);
  223. if (commandQueue) {
  224. commandQueue->add(command);
  225. } else {
  226. executeTriangleDrawing(command, clipBound);
  227. }
  228. }
  229. }
  230. // Clip triangles against the clip bounds outside of the image
  231. // Precondition: The triangle needs to be clipped
  232. // TODO: Take drawSubTriangle as a lambda to drawClippedTriangle using vertex weights as arguments and vertex data as captured variables
  233. static void drawClippedTriangle(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, const ITriangle2D &triangle, const IRect &clipBound) {
  234. ClippedTriangle clipped(triangle);
  235. int planeCount = camera.getFrustumPlaneCount(true);
  236. for (int s = 0; s < planeCount; s++) {
  237. clipped.clip(camera.getFrustumPlane(s, true));
  238. }
  239. // Draw a convex triangle fan from the clipped triangle
  240. for (int triangleIndex = 0; triangleIndex < clipped.getVertexCount() - 2; triangleIndex++) {
  241. int indexA = 0;
  242. int indexB = 1 + triangleIndex;
  243. int indexC = 2 + triangleIndex;
  244. drawSubTriangle(commandQueue, triangleDrawData, camera, clipBound, clipped.vertices[indexA], clipped.vertices[indexB], clipped.vertices[indexC]);
  245. }
  246. }
  247. // Clipping is applied automatically if needed
  248. static void renderTriangleWithShader(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, const ITriangle2D &triangle, const IRect &clipBound) {
  249. // Allow small triangles to be a bit outside of the view frustum without being clipped by increasing the width and height slopes in a second test
  250. // This reduces redundant clipping to improve both speed and quality
  251. Visibility paddedVisibility = getTriangleVisibility(triangle, camera, true);
  252. // Draw the triangle
  253. if (paddedVisibility == Visibility::Full) {
  254. // Only check if the triangle is front facing once we know that the projection is in positive depth
  255. if (triangle.isFrontfacing()) {
  256. // Draw the full triangle
  257. TriangleDrawCommand command(triangleDrawData, triangle, FVector3D(0.0f, 1.0f, 0.0f), FVector3D(0.0f, 0.0f, 1.0f), clipBound);
  258. if (commandQueue) {
  259. commandQueue->add(command);
  260. } else {
  261. executeTriangleDrawing(command, clipBound);
  262. }
  263. }
  264. } else {
  265. // Draw a clipped triangle
  266. drawClippedTriangle(commandQueue, triangleDrawData, camera, triangle, clipBound);
  267. }
  268. }
  269. // TODO: Move shader selection to Shader_RgbaMultiply and let models default to its shader factory function pointer as shader selection
  270. void dsr::renderTriangleFromData(
  271. CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer,
  272. const Camera &camera, const ProjectedPoint &posA, const ProjectedPoint &posB, const ProjectedPoint &posC,
  273. Filter filter, const TextureRgbaU8 &diffuse, const TextureRgbaU8 &light,
  274. const TriangleTexCoords &texCoords, const TriangleColors &colors) {
  275. // Get dimensions from both buffers
  276. int colorWidth = image_getWidth(targetImage);
  277. int colorHeight = image_getHeight(targetImage);
  278. int depthWidth = image_getWidth(depthBuffer);
  279. int depthHeight = image_getHeight(depthBuffer);
  280. // Combine dimensions
  281. int targetWidth, targetHeight;
  282. if (image_exists(targetImage)) {
  283. targetWidth = colorWidth;
  284. targetHeight = colorHeight;
  285. if (image_exists(depthBuffer)) {
  286. assert(targetWidth == depthWidth);
  287. assert(targetHeight == depthHeight);
  288. }
  289. } else {
  290. if (image_exists(depthBuffer)) {
  291. targetWidth = depthWidth;
  292. targetHeight = depthHeight;
  293. } else {
  294. return; // No target buffer to draw on
  295. }
  296. }
  297. // Select a bound
  298. IRect clipBound = IRect::FromSize(targetWidth, targetHeight);
  299. // Create a triangle
  300. ITriangle2D triangle(posA, posB, posC);
  301. // Only draw visible triangles
  302. Visibility visibility = getTriangleVisibility(triangle, camera, false);
  303. if (visibility != Visibility::Hidden) {
  304. // Select an instance of the default shader
  305. if (!(filter == Filter::Alpha && almostZero(colors.alpha))) {
  306. renderTriangleWithShader (
  307. commandQueue,
  308. TriangleDrawData (
  309. targetImage,
  310. depthBuffer,
  311. camera.perspective,
  312. filter,
  313. TriangleInput (
  314. diffuse,
  315. light,
  316. texCoords,
  317. colors
  318. ),
  319. &processTriangle_RgbaMultiply
  320. ),
  321. camera,
  322. triangle,
  323. clipBound
  324. );
  325. }
  326. }
  327. }
  328. template<bool AFFINE>
  329. static void executeTriangleDrawingDepth(const ImageF32 &depthBuffer, const ITriangle2D& triangle, const IRect &clipBound) {
  330. int32_t rowCount = triangle.getBufferSize(clipBound, 1, 1);
  331. if (rowCount > 0) {
  332. int startRow;
  333. VirtualStackAllocation<RowInterval> rows(rowCount, "Row intervals in executeTriangleDrawingDepth");
  334. triangle.getShape(startRow, rows.getUnsafe(), clipBound, 1, 1);
  335. Projection projection = triangle.getProjection(FVector3D(), FVector3D(), !AFFINE); // TODO: Create a weight using only depth to save time
  336. RowShape shape = RowShape(startRow, rowCount, rows.getUnsafe());
  337. // Draw the triangle
  338. const int depthBufferStride = image_getStride(depthBuffer);
  339. SafePointer<float> depthDataRow = image_getSafePointer<float>(depthBuffer, shape.startRow);
  340. for (int32_t y = shape.startRow; y < shape.startRow + shape.rowCount; y++) {
  341. RowInterval row = shape.rows[y - shape.startRow];
  342. SafePointer<float> depthData = depthDataRow + row.left;
  343. // Initialize depth iteration
  344. float depthValue;
  345. if (AFFINE) {
  346. depthValue = projection.getWeight_affine(IVector2D(row.left, y)).x;
  347. } else {
  348. depthValue = projection.getDepthDividedWeight_perspective(IVector2D(row.left, y)).x;
  349. }
  350. float depthDx = projection.pWeightDx.x;
  351. // Loop over a row of depth pixels
  352. for (int32_t x = row.left; x < row.right; x++) {
  353. float oldValue = *depthData;
  354. if (AFFINE) {
  355. // Write lower depthValue for orthogonal cameras
  356. if (depthValue < oldValue) {
  357. *depthData = depthValue;
  358. }
  359. } else {
  360. // Write higher depthValue for perspective cameras
  361. if (depthValue > oldValue) {
  362. *depthData = depthValue;
  363. }
  364. }
  365. depthValue += depthDx;
  366. depthData += 1;
  367. }
  368. // Iterate to the next row
  369. depthDataRow.increaseBytes(depthBufferStride);
  370. }
  371. }
  372. }
  373. static void drawTriangleDepth(const ImageF32 &depthBuffer, const Camera &camera, const IRect &clipBound, const ITriangle2D& triangle) {
  374. // Rounding sub-triangles to integer locations may reverse the direction of zero area triangles
  375. if (triangle.isFrontfacing()) {
  376. if (camera.perspective) {
  377. executeTriangleDrawingDepth<false>(depthBuffer, triangle, clipBound);
  378. } else {
  379. executeTriangleDrawingDepth<true>(depthBuffer, triangle, clipBound);
  380. }
  381. }
  382. }
  383. static void drawSubTriangleDepth(const ImageF32 &depthBuffer, const Camera &camera, const IRect &clipBound, const SubVertex &vertexA, const SubVertex &vertexB, const SubVertex &vertexC) {
  384. ProjectedPoint posA = camera.cameraToScreen(vertexA.cs);
  385. ProjectedPoint posB = camera.cameraToScreen(vertexB.cs);
  386. ProjectedPoint posC = camera.cameraToScreen(vertexC.cs);
  387. drawTriangleDepth(depthBuffer, camera, clipBound, ITriangle2D(posA, posB, posC));
  388. }
  389. void dsr::renderTriangleFromDataDepth(const ImageF32 &depthBuffer, const Camera &camera, const ProjectedPoint &posA, const ProjectedPoint &posB, const ProjectedPoint &posC) {
  390. // Skip rendering if there's no target buffer
  391. if (!image_exists(depthBuffer)) { return; }
  392. // Select a bound
  393. IRect clipBound = IRect::FromSize(image_getWidth(depthBuffer), image_getHeight(depthBuffer));
  394. // Create a triangle
  395. ITriangle2D triangle(posA, posB, posC);
  396. // Only draw visible triangles
  397. Visibility visibility = getTriangleVisibility(triangle, camera, false);
  398. if (visibility != Visibility::Hidden) {
  399. // Allow small triangles to be a bit outside of the view frustum without being clipped by increasing the width and height slopes in a second test
  400. // This reduces redundant clipping to improve both speed and quality
  401. Visibility paddedVisibility = getTriangleVisibility(triangle, camera, true);
  402. // Draw the triangle
  403. if (paddedVisibility == Visibility::Full) {
  404. // Only check if the triangle is front facing once we know that the projection is in positive depth
  405. if (triangle.isFrontfacing()) {
  406. // Draw the full triangle
  407. drawTriangleDepth(depthBuffer, camera, clipBound, triangle);
  408. }
  409. } else {
  410. // Draw a clipped triangle
  411. ClippedTriangle clipped(triangle); // TODO: Simpler vertex clipping using only positions
  412. int planeCount = camera.getFrustumPlaneCount(true);
  413. for (int s = 0; s < planeCount; s++) {
  414. clipped.clip(camera.getFrustumPlane(s, true));
  415. }
  416. // Draw a convex triangle fan from the clipped triangle
  417. for (int triangleIndex = 0; triangleIndex < clipped.getVertexCount() - 2; triangleIndex++) {
  418. int indexA = 0;
  419. int indexB = 1 + triangleIndex;
  420. int indexC = 2 + triangleIndex;
  421. drawSubTriangleDepth(depthBuffer, camera, clipBound, clipped.vertices[indexA], clipped.vertices[indexB], clipped.vertices[indexC]);
  422. }
  423. }
  424. }
  425. }
  426. void CommandQueue::add(const TriangleDrawCommand &command) {
  427. this->buffer.push(command);
  428. }
  429. void CommandQueue::execute(const IRect &clipBound, int jobCount) const {
  430. if (jobCount <= 1) {
  431. // TODO: Make a setting for sorting triangles using indices within each job
  432. for (int i = 0; i < this->buffer.length(); i++) {
  433. if (!this->buffer[i].occluded) {
  434. executeTriangleDrawing(this->buffer[i], clipBound);
  435. }
  436. }
  437. } else {
  438. // Split the target region for multiple threads, with one slice per job.
  439. VirtualStackAllocation<IRect> regions(jobCount, "Multi-threaded target pixel regions in CommandQueue::execute");
  440. int y1 = clipBound.top();
  441. for (int j = 0; j < jobCount; j++) {
  442. int y2 = clipBound.top() + ((clipBound.bottom() * (j + 1)) / jobCount);
  443. // Align to multiples of two lines if it's not at the bottom
  444. if (j < jobCount - 1) {
  445. y2 = (y2 / 2) * 2;
  446. }
  447. int height = y2 - y1;
  448. regions[j] = IRect(clipBound.left(), y1, clipBound.width(), height);
  449. y1 = y2;
  450. }
  451. std::function<void(void *context, int jobIndex)> job = [&regions](void *context, int jobIndex) {
  452. CommandQueue *commandQueue = (CommandQueue*)context;
  453. for (int i = 0; i < commandQueue->buffer.length(); i++) {
  454. if (!commandQueue->buffer[i].occluded) {
  455. executeTriangleDrawing(commandQueue->buffer[i], regions[jobIndex]);
  456. }
  457. }
  458. };
  459. threadedWorkByIndex(job, (void*)this, jobCount);
  460. }
  461. }
  462. void CommandQueue::clear() {
  463. this->buffer.clear();
  464. }