aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ops
diff options
context:
space:
mode:
authorGravatar Joe Gregorio <jcgregorio@google.com>2018-07-10 20:35:19 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-10 20:35:26 +0000
commit383c9bbf0fca577d9efd86ce6ccb28c1c39c6e34 (patch)
tree306fb53aa4402d73345775db12facf39b7bedbcd /src/gpu/ops
parent1b112cc5604d294427c0d51f194ab7fb3067d9e2 (diff)
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>
Diffstat (limited to 'src/gpu/ops')
-rw-r--r--src/gpu/ops/GrDrawVerticesOp.cpp133
-rw-r--r--src/gpu/ops/GrDrawVerticesOp.h22
2 files changed, 22 insertions, 133 deletions
diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp
index bb5b7a5ef2..7cfb3a2efa 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 @@ std::unique_ptr<GrDrawOp> GrDrawVerticesOp::Make(GrContext* context,
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 @@ GrDrawVerticesOp::GrDrawVerticesOp(const Helper::MakeArgs& helperArgs, GrColor c
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 @@ GrDrawVerticesOp::GrDrawVerticesOp(const Helper::MakeArgs& helperArgs, GrColor c
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 @@ GrDrawVerticesOp::GrDrawVerticesOp(const Helper::MakeArgs& helperArgs, GrColor c
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 @@ GrDrawOp::RequiresDstTexture GrDrawVerticesOp::finalize(const GrCaps& caps,
}
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 @@ sk_sp<GrGeometryProcessor> GrDrawVerticesOp::makeGP(bool* hasColorAttribute,
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::onPrepareDraws(Target* target) {
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 @@ void GrDrawVerticesOp::drawVolatile(Target* target) {
// Fill the buffers.
this->fillBuffers(hasColorAttribute,
hasLocalCoordsAttribute,
- hasBoneAttribute,
vertexStride,
verts,
indices);
@@ -265,10 +202,8 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) {
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 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) {
// 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 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) {
// Fill the buffers.
this->fillBuffers(hasColorAttribute,
hasLocalCoordsAttribute,
- hasBoneAttribute,
vertexStride,
verts,
indices);
@@ -353,7 +286,6 @@ void GrDrawVerticesOp::drawNonVolatile(Target* target) {
void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
bool hasLocalCoordsAttribute,
- bool hasBoneAttribute,
size_t vertexStride,
void* verts,
uint16_t* indices) const {
@@ -364,7 +296,7 @@ void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
// 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 @@ void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
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 @@ void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
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 @@ void GrDrawVerticesOp::fillBuffers(bool hasColorAttribute,
*(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 @@ bool GrDrawVerticesOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) {
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 @@ GR_DRAW_OP_TEST_DEFINE(GrDrawVerticesOp) {
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);
}
diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h
index d15e620ff5..3a6eca0a0d 100644
--- a/src/gpu/ops/GrDrawVerticesOp.h
+++ b/src/gpu/ops/GrDrawVerticesOp.h
@@ -38,16 +38,13 @@ public:
static std::unique_ptr<GrDrawOp> Make(GrContext* context,
GrPaint&&,
sk_sp<SkVertices>,
- const SkMatrix bones[],
- int boneCount,
const SkMatrix& viewMatrix,
GrAAType,
sk_sp<GrColorSpaceXform>,
GrPrimitiveType* overridePrimType = nullptr);
- GrDrawVerticesOp(const Helper::MakeArgs&, GrColor, sk_sp<SkVertices>, const SkMatrix bones[],
- int boneCount, GrPrimitiveType, GrAAType, sk_sp<GrColorSpaceXform>,
- const SkMatrix& viewMatrix);
+ GrDrawVerticesOp(const Helper::MakeArgs&, GrColor, sk_sp<SkVertices>, GrPrimitiveType, GrAAType,
+ sk_sp<GrColorSpaceXform>, const SkMatrix& viewMatrix);
const char* name() const override { return "DrawVerticesOp"; }
@@ -75,7 +72,6 @@ private:
void fillBuffers(bool hasColorAttribute,
bool hasLocalCoordsAttribute,
- bool hasBoneAttribute,
size_t vertexStride,
void* verts,
uint16_t* indices) const;
@@ -88,8 +84,7 @@ private:
int firstIndex);
sk_sp<GrGeometryProcessor> makeGP(bool* hasColorAttribute,
- bool* hasLocalCoordAttribute,
- bool* hasBoneAttribute) const;
+ bool* hasLocalCoordAttribute) const;
GrPrimitiveType primitiveType() const { return fPrimitiveType; }
bool combinablePrimitive() const {
@@ -103,11 +98,9 @@ private:
struct Mesh {
GrColor fColor; // Used if this->hasPerVertexColors() is false.
sk_sp<SkVertices> fVertices;
- std::vector<float> fBones; // Transformation matrices stored in GPU format.
SkMatrix fViewMatrix;
bool fIgnoreTexCoords;
bool fIgnoreColors;
- bool fIgnoreBones;
bool hasExplicitLocalCoords() const {
return fVertices->hasTexCoords() && !fIgnoreTexCoords;
@@ -116,10 +109,6 @@ private:
bool hasPerVertexColors() const {
return fVertices->hasColors() && !fIgnoreColors;
}
-
- bool hasBones() const {
- return fVertices->hasBones() && fBones.size() && !fIgnoreBones;
- }
};
bool isIndexed() const {
@@ -139,15 +128,10 @@ private:
return SkToBool(kHasMultipleViewMatrices_Flag & fFlags);
}
- bool hasBones() const {
- return SkToBool(kHasBones_Flag & fFlags);
- }
-
enum Flags {
kRequiresPerVertexColors_Flag = 0x1,
kAnyMeshHasExplicitLocalCoords_Flag = 0x2,
kHasMultipleViewMatrices_Flag = 0x4,
- kHasBones_Flag = 0x8,
};
Helper fHelper;