aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2018-06-19 01:40:57 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 01:41:10 +0000
commit5045e501d2aec23e5f1e4b46346033ac3202c6b0 (patch)
treeb0179c300d6bc1822b0d945be812fff267bb414a /src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
parent63b3bfb711d7e3d4f9ad75681d77a69a3c454ab0 (diff)
Revert "Change how vertex/instance attributes are handled in geometry processors."
This reverts commit 19c1233c447f625c2522e7ecd0a0adecc629bb2f. Reason for revert: want to make sure Google3 can roll Original change's description: > Change how vertex/instance attributes are handled in geometry processors. > > * No longer register vertex/instance attributes on base class, just counts > > * Separate instance and vertex attributes and remove InputRate and offset > > * Make attributes constexpr where possible > > Change-Id: I1f1d5e772fa177a96d2aeb805aab7b69f35bfae6 > Reviewed-on: https://skia-review.googlesource.com/132405 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Chris Dalton <csmartdalton@google.com> TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com Change-Id: I4800632515e14fbf54af52826928ac915657b59f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/135661 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp')
-rw-r--r--src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp68
1 files changed, 36 insertions, 32 deletions
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
index 5c5120cf45..3c9fe89fbc 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
@@ -28,8 +28,9 @@ private:
const int fNumSides;
};
-static constexpr int kInstanceAttribIdx_X = 0; // Transposed X values of all input points.
-static constexpr int kInstanceAttribIdx_Y = 1; // Transposed Y values of all input points.
+static constexpr int kAttribIdx_X = 0; // Transposed X values of all input points.
+static constexpr int kAttribIdx_Y = 1; // Transposed Y values of all input points.
+static constexpr int kAttribIdx_VertexData = 2;
// Vertex data tells the shader how to offset vertices for conservative raster, as well as how to
// calculate coverage values for corners and edges.
@@ -259,16 +260,15 @@ void GrCCCoverageProcessor::VSImpl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs)
int inputWidth = (4 == numInputPoints || proc.hasInputWeight()) ? 4 : 3;
const char* swizzle = (4 == inputWidth) ? "xyzw" : "xyz";
v->codeAppendf("float%ix2 pts = transpose(float2x%i(%s.%s, %s.%s));", inputWidth, inputWidth,
- proc.fInstanceAttributes[kInstanceAttribIdx_X].name(), swizzle,
- proc.fInstanceAttributes[kInstanceAttribIdx_Y].name(), swizzle);
+ proc.getAttrib(kAttribIdx_X).name(), swizzle,
+ proc.getAttrib(kAttribIdx_Y).name(), swizzle);
v->codeAppend ("half wind;");
Shader::CalcWind(proc, v, "pts", "wind");
if (PrimitiveType::kWeightedTriangles == proc.fPrimitiveType) {
SkASSERT(3 == numInputPoints);
- SkASSERT(kFloat4_GrVertexAttribType ==
- proc.fInstanceAttributes[kInstanceAttribIdx_X].type());
- v->codeAppendf("wind *= %s.w;", proc.fInstanceAttributes[kInstanceAttribIdx_X].name());
+ SkASSERT(kFloat4_GrVertexAttribType == proc.getAttrib(kAttribIdx_X).type());
+ v->codeAppendf("wind *= %s.w;", proc.getAttrib(kAttribIdx_X).name());
}
float bloat = kAABloatRadius;
@@ -284,12 +284,12 @@ void GrCCCoverageProcessor::VSImpl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs)
// Reverse all indices if the wind is counter-clockwise: [0, 1, 2] -> [2, 1, 0].
v->codeAppendf("int clockwise_indices = wind > 0 ? %s : 0x%x - %s;",
- proc.fVertexAttribute.name(),
+ proc.getAttrib(kAttribIdx_VertexData).name(),
((fNumSides - 1) << kVertexData_LeftNeighborIdShift) |
((fNumSides - 1) << kVertexData_RightNeighborIdShift) |
(((1 << kVertexData_RightNeighborIdShift) - 1) ^ 3) |
(fNumSides - 1),
- proc.fVertexAttribute.name());
+ proc.getAttrib(kAttribIdx_VertexData).name());
// Here we generate conservative raster geometry for the input polygon. It is the convex
// hull of N pixel-size boxes, one centered on each the input points. Each corner has three
@@ -322,7 +322,7 @@ void GrCCCoverageProcessor::VSImpl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs)
v->codeAppend ("rightdir = (float2(0) != rightdir) ? normalize(rightdir) : float2(1, 0);");
v->codeAppendf("if (0 != (%s & %i)) {", // Are we a corner?
- proc.fVertexAttribute.name(), kVertexData_IsCornerBit);
+ proc.getAttrib(kAttribIdx_VertexData).name(), kVertexData_IsCornerBit);
// In corner boxes, all 4 coverage values will not map linearly.
// Therefore it is important to align the box so its diagonal shared
@@ -341,7 +341,7 @@ void GrCCCoverageProcessor::VSImpl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs)
// continue rotating 90 degrees clockwise until we reach the desired raster vertex for this
// invocation. Corners with less than 3 corresponding raster vertices will result in
// redundant vertices and degenerate triangles.
- v->codeAppendf("int bloatidx = (%s >> %i) & 3;", proc.fVertexAttribute.name(),
+ v->codeAppendf("int bloatidx = (%s >> %i) & 3;", proc.getAttrib(kAttribIdx_VertexData).name(),
kVertexData_BloatIdxShift);
v->codeAppend ("switch (bloatidx) {");
v->codeAppend ( "case 3:");
@@ -376,12 +376,12 @@ void GrCCCoverageProcessor::VSImpl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs)
v->codeAppend ("}");
v->codeAppendf("if (0 != (%s & %i)) {", // Are we an edge?
- proc.fVertexAttribute.name(), kVertexData_IsEdgeBit);
+ proc.getAttrib(kAttribIdx_VertexData).name(), kVertexData_IsEdgeBit);
v->codeAppend ( "coverage = left_coverage;");
v->codeAppend ("}");
v->codeAppendf("if (0 != (%s & %i)) {", // Invert coverage?
- proc.fVertexAttribute.name(),
+ proc.getAttrib(kAttribIdx_VertexData).name(),
kVertexData_InvertNegativeCoverageBit);
v->codeAppend ( "coverage = -1 - coverage;");
v->codeAppend ("}");
@@ -391,7 +391,7 @@ void GrCCCoverageProcessor::VSImpl::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs)
v->codeAppend ("half2 corner_coverage = half2(0);");
v->codeAppendf("if (0 != (%s & %i)) {", // Are we a corner?
- proc.fVertexAttribute.name(), kVertexData_IsCornerBit);
+ proc.getAttrib(kAttribIdx_VertexData).name(), kVertexData_IsCornerBit);
// We use coverage=-1 to erase what the hull geometry wrote.
//
// In the context of curves, this effectively means "wind = -wind" and
@@ -495,27 +495,31 @@ void GrCCCoverageProcessor::initVS(GrResourceProvider* rp) {
}
}
- GrVertexAttribType xyAttribType;
if (4 == this->numInputPoints() || this->hasInputWeight()) {
- GR_STATIC_ASSERT(offsetof(QuadPointInstance, fX) == 0);
- GR_STATIC_ASSERT(sizeof(QuadPointInstance::fX) ==
- GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
- GR_STATIC_ASSERT(sizeof(QuadPointInstance::fY) ==
- GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
- xyAttribType = kFloat4_GrVertexAttribType;
+ SkASSERT(kAttribIdx_X == this->numAttribs());
+ this->addInstanceAttrib("X", kFloat4_GrVertexAttribType);
+
+ SkASSERT(kAttribIdx_Y == this->numAttribs());
+ this->addInstanceAttrib("Y", kFloat4_GrVertexAttribType);
+
+ SkASSERT(offsetof(QuadPointInstance, fX) == this->getAttrib(kAttribIdx_X).offsetInRecord());
+ SkASSERT(offsetof(QuadPointInstance, fY) == this->getAttrib(kAttribIdx_Y).offsetInRecord());
+ SkASSERT(sizeof(QuadPointInstance) == this->getInstanceStride());
} else {
- GR_STATIC_ASSERT(offsetof(TriPointInstance, fX) == 0);
- GR_STATIC_ASSERT(sizeof(TriPointInstance::fX) ==
- GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
- GR_STATIC_ASSERT(sizeof(TriPointInstance::fY) ==
- GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
- xyAttribType = kFloat3_GrVertexAttribType;
+ SkASSERT(kAttribIdx_X == this->numAttribs());
+ this->addInstanceAttrib("X", kFloat3_GrVertexAttribType);
+
+ SkASSERT(kAttribIdx_Y == this->numAttribs());
+ this->addInstanceAttrib("Y", kFloat3_GrVertexAttribType);
+
+ SkASSERT(offsetof(TriPointInstance, fX) == this->getAttrib(kAttribIdx_X).offsetInRecord());
+ SkASSERT(offsetof(TriPointInstance, fY) == this->getAttrib(kAttribIdx_Y).offsetInRecord());
+ SkASSERT(sizeof(TriPointInstance) == this->getInstanceStride());
}
- fInstanceAttributes[kInstanceAttribIdx_X] = {"X", xyAttribType};
- fInstanceAttributes[kInstanceAttribIdx_Y] = {"Y", xyAttribType};
- this->setInstanceAttributeCnt(2);
- fVertexAttribute = {"vertexdata", kInt_GrVertexAttribType};
- this->setVertexAttributeCnt(1);
+
+ SkASSERT(kAttribIdx_VertexData == this->numAttribs());
+ this->addVertexAttrib("vertexdata", kInt_GrVertexAttribType);
+ SkASSERT(sizeof(int32_t) == this->getVertexStride());
if (caps.usePrimitiveRestart()) {
fVSTriangleType = GrPrimitiveType::kTriangleStrip;