Revert "added skeletal animation support to GPU backend"
This reverts commit d275ef501c8e6ea6444912e22c29e2d13a3dfb53.
Reason for revert: Failing to compile on debian9.
Original change's description:
> added skeletal animation support to GPU backend
>
> Pulled from reverted CL: https://skia-review.googlesource.com/c/skia/+/138596
>
> Bug: skia:
> Change-Id: Ie07f1c76bae65c219ebe93d071bb19f1a30100c2
> Reviewed-on: https://skia-review.googlesource.com/139282
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Commit-Queue: Ruiqi Mao <ruiqimao@google.com>
TBR=robertphillips@google.com,brianosman@google.com,ruiqimao@google.com
Change-Id: Ibc0da6ce16f078ff74a2c1bcab30750baff460f7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/140381
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index bb5b7a5..7cfb3a2 100644
--- a/src/gpu/ops/GrDrawVerticesOp.cpp
+++ b/src/gpu/ops/GrDrawVerticesOp.cpp
@@ -12,13 +12,9 @@
#include "SkGr.h"
#include "SkRectPriv.h"
-static constexpr int kNumFloatsPerSkMatrix = 9;
-
std::unique_ptr<GrDrawOp> GrDrawVerticesOp::Make(GrContext* context,
GrPaint&& paint,
sk_sp<SkVertices> vertices,
- const SkMatrix bones[],
- int boneCount,
const SkMatrix& viewMatrix,
GrAAType aaType,
sk_sp<GrColorSpaceXform> colorSpaceXform,
@@ -27,14 +23,13 @@
GrPrimitiveType primType = overridePrimType ? *overridePrimType
: SkVertexModeToGrPrimitiveType(vertices->mode());
return Helper::FactoryHelper<GrDrawVerticesOp>(context, std::move(paint), std::move(vertices),
- bones, boneCount, primType, aaType,
- std::move(colorSpaceXform), viewMatrix);
+ primType, aaType, std::move(colorSpaceXform),
+ viewMatrix);
}
GrDrawVerticesOp::GrDrawVerticesOp(const Helper::MakeArgs& helperArgs, GrColor color,
- sk_sp<SkVertices> vertices, const SkMatrix bones[],
- int boneCount, GrPrimitiveType primitiveType, GrAAType aaType,
- sk_sp<GrColorSpaceXform> colorSpaceXform,
+ sk_sp<SkVertices> vertices, GrPrimitiveType primitiveType,
+ GrAAType aaType, sk_sp<GrColorSpaceXform> colorSpaceXform,
const SkMatrix& viewMatrix)
: INHERITED(ClassID())
, fHelper(helperArgs, aaType)
@@ -51,25 +46,8 @@
mesh.fColor = color;
mesh.fViewMatrix = viewMatrix;
mesh.fVertices = std::move(vertices);
- if (bones) {
- // Copy the bone data over in the format that the GPU would upload.
- mesh.fBones.reserve(boneCount * kNumFloatsPerSkMatrix);
- for (int i = 0; i < boneCount; i ++) {
- const SkMatrix& matrix = bones[i];
- mesh.fBones.push_back(matrix.get(SkMatrix::kMScaleX));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMSkewY));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMPersp0));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMSkewX));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMScaleY));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMPersp1));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMTransX));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMTransY));
- mesh.fBones.push_back(matrix.get(SkMatrix::kMPersp2));
- }
- }
mesh.fIgnoreTexCoords = false;
mesh.fIgnoreColors = false;
- mesh.fIgnoreBones = false;
fFlags = 0;
if (mesh.hasPerVertexColors()) {
@@ -78,15 +56,6 @@
if (mesh.hasExplicitLocalCoords()) {
fFlags |= kAnyMeshHasExplicitLocalCoords_Flag;
}
- if (mesh.hasBones()) {
- fFlags |= kHasBones_Flag;
- }
-
- // Special case for meshes with a world transform but no bone weights.
- // These will be considered normal vertices draws without bones.
- if (!mesh.fVertices->hasBones() && boneCount == 1) {
- mesh.fViewMatrix.preConcat(bones[0]);
- }
IsZeroArea zeroArea;
if (GrIsPrimTypeLines(primitiveType) || GrPrimitiveType::kPoints == primitiveType) {
@@ -95,26 +64,10 @@
zeroArea = IsZeroArea::kNo;
}
- if (this->hasBones()) {
- // We don't know the bounds if there are deformations involved, so attempt to calculate
- // the maximum possible.
- SkRect bounds;
- const SkRect originalBounds = bones[0].mapRect(mesh.fVertices->bounds());
- for (int i = 1; i < boneCount; i++) {
- const SkMatrix& matrix = bones[i];
- bounds.join(matrix.mapRect(originalBounds));
- }
-
- this->setTransformedBounds(bounds,
- mesh.fViewMatrix,
- HasAABloat::kNo,
- zeroArea);
- } else {
- this->setTransformedBounds(mesh.fVertices->bounds(),
- mesh.fViewMatrix,
- HasAABloat::kNo,
- zeroArea);
- }
+ this->setTransformedBounds(mesh.fVertices->bounds(),
+ mesh.fViewMatrix,
+ HasAABloat::kNo,
+ zeroArea);
}
SkString GrDrawVerticesOp::dumpInfo() const {
@@ -154,8 +107,7 @@
}
sk_sp<GrGeometryProcessor> GrDrawVerticesOp::makeGP(bool* hasColorAttribute,
- bool* hasLocalCoordAttribute,
- bool* hasBoneAttribute) const {
+ bool* hasLocalCoordAttribute) const {
using namespace GrDefaultGeoProcFactory;
LocalCoords::Type localCoordsType;
if (fHelper.usesLocalCoords()) {
@@ -188,21 +140,10 @@
const SkMatrix& vm = this->hasMultipleViewMatrices() ? SkMatrix::I() : fMeshes[0].fViewMatrix;
- Bones bones(fMeshes[0].fBones.data(), fMeshes[0].fBones.size() / kNumFloatsPerSkMatrix);
- *hasBoneAttribute = this->hasBones();
-
- if (this->hasBones()) {
- return GrDefaultGeoProcFactory::MakeWithBones(color,
- Coverage::kSolid_Type,
- localCoordsType,
- bones,
- vm);
- } else {
- return GrDefaultGeoProcFactory::Make(color,
- Coverage::kSolid_Type,
- localCoordsType,
- vm);
- }
+ return GrDefaultGeoProcFactory::Make(color,
+ Coverage::kSolid_Type,
+ localCoordsType,
+ vm);
}
void GrDrawVerticesOp::onPrepareDraws(Target* target) {
@@ -216,16 +157,13 @@
void GrDrawVerticesOp::drawVolatile(Target* target) {
bool hasColorAttribute;
bool hasLocalCoordsAttribute;
- bool hasBoneAttribute;
sk_sp<GrGeometryProcessor> gp = this->makeGP(&hasColorAttribute,
- &hasLocalCoordsAttribute,
- &hasBoneAttribute);
+ &hasLocalCoordsAttribute);
// Calculate the stride.
size_t vertexStride = sizeof(SkPoint) +
(hasColorAttribute ? sizeof(uint32_t) : 0) +
- (hasLocalCoordsAttribute ? sizeof(SkPoint) : 0) +
- (hasBoneAttribute ? 4 * (sizeof(uint32_t) + sizeof(float)) : 0);
+ (hasLocalCoordsAttribute ? sizeof(SkPoint) : 0);
SkASSERT(vertexStride == gp->debugOnly_vertexStride());
// Allocate buffers.
@@ -251,7 +189,6 @@
// Fill the buffers.
this->fillBuffers(hasColorAttribute,
hasLocalCoordsAttribute,
- hasBoneAttribute,
vertexStride,
verts,
indices);
@@ -265,10 +202,8 @@
bool hasColorAttribute;
bool hasLocalCoordsAttribute;
- bool hasBoneAttribute;
sk_sp<GrGeometryProcessor> gp = this->makeGP(&hasColorAttribute,
- &hasLocalCoordsAttribute,
- &hasBoneAttribute);
+ &hasLocalCoordsAttribute);
SkASSERT(fMeshes.count() == 1); // Non-volatile meshes should never combine.
@@ -300,8 +235,7 @@
// Calculate the stride.
size_t vertexStride = sizeof(SkPoint) +
(hasColorAttribute ? sizeof(uint32_t) : 0) +
- (hasLocalCoordsAttribute ? sizeof(SkPoint) : 0) +
- (hasBoneAttribute ? 4 * (sizeof(uint32_t) + sizeof(float)) : 0);
+ (hasLocalCoordsAttribute ? sizeof(SkPoint) : 0);
SkASSERT(vertexStride == gp->debugOnly_vertexStride());
// Allocate vertex buffer.
@@ -332,7 +266,6 @@
// Fill the buffers.
this->fillBuffers(hasColorAttribute,
hasLocalCoordsAttribute,
- hasBoneAttribute,
vertexStride,
verts,
indices);
@@ -353,7 +286,6 @@
void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
bool hasLocalCoordsAttribute,
- bool hasBoneAttribute,
size_t vertexStride,
void* verts,
uint16_t* indices) const {
@@ -364,7 +296,7 @@
// We have a fast case below for uploading the vertex data when the matrix is translate
// only and there are colors but not local coords. Fast case does not apply when there are bone
// transformations.
- bool fastAttrs = hasColorAttribute && !hasLocalCoordsAttribute && !hasBoneAttribute;
+ bool fastAttrs = hasColorAttribute && !hasLocalCoordsAttribute;
for (int i = 0; i < instanceCount; i++) {
// Get each mesh.
const Mesh& mesh = fMeshes[i];
@@ -382,8 +314,6 @@
const SkPoint* positions = mesh.fVertices->positions();
const SkColor* colors = mesh.fVertices->colors();
const SkPoint* localCoords = mesh.fVertices->texCoords();
- const SkVertices::BoneIndices* boneIndices = mesh.fVertices->boneIndices();
- const SkVertices::BoneWeights* boneWeights = mesh.fVertices->boneWeights();
bool fastMesh = (!this->hasMultipleViewMatrices() ||
mesh.fViewMatrix.getType() <= SkMatrix::kTranslate_Mask) &&
mesh.hasPerVertexColors();
@@ -413,14 +343,6 @@
offset += sizeof(uint32_t);
}
size_t localCoordOffset = offset;
- if (hasLocalCoordsAttribute) {
- offset += sizeof(SkPoint);
- }
- size_t boneIndexOffset = offset;
- if (hasBoneAttribute) {
- offset += 4 * sizeof(uint32_t);
- }
- size_t boneWeightOffset = offset;
for (int j = 0; j < vertexCount; ++j) {
if (this->hasMultipleViewMatrices()) {
@@ -442,16 +364,6 @@
*(SkPoint*)((intptr_t)verts + localCoordOffset) = positions[j];
}
}
- if (hasBoneAttribute) {
- const SkVertices::BoneIndices& indices = boneIndices[j];
- const SkVertices::BoneWeights& weights = boneWeights[j];
- for (int k = 0; k < 4; k++) {
- size_t indexOffset = boneIndexOffset + sizeof(uint32_t) * k;
- size_t weightOffset = boneWeightOffset + sizeof(float) * k;
- *(uint32_t*)((intptr_t)verts + indexOffset) = indices.indices[k];
- *(float*)((intptr_t)verts + weightOffset) = weights.weights[k];
- }
- }
verts = (void*)((intptr_t)verts + vertexStride);
}
}
@@ -485,13 +397,6 @@
return false;
}
- // Meshes with bones cannot be combined because different meshes use different bones, so to
- // combine them, the matrices would have to be combined, and the bone indices on each vertex
- // would change, thus making the vertices uncacheable.
- if (this->hasBones() || that->hasBones()) {
- return false;
- }
-
// Non-volatile meshes cannot batch, because if a non-volatile mesh batches with another mesh,
// then on the next frame, if that non-volatile mesh is drawn, it will draw the other mesh
// that was saved in its vertex buffer, which is not necessarily there anymore.
@@ -653,7 +558,7 @@
if (GrFSAAType::kUnifiedMSAA == fsaaType && random->nextBool()) {
aaType = GrAAType::kMSAA;
}
- return GrDrawVerticesOp::Make(context, std::move(paint), std::move(vertices), nullptr, 0,
+ return GrDrawVerticesOp::Make(context, std::move(paint), std::move(vertices),
viewMatrix, aaType, std::move(colorSpaceXform), &type);
}