Specify CPU (buffer) and GPU (shader) types explicitly in Attribute
The CPU type is still specified using GrVertexAttribType.
The GPU type is specified directly using GrSLType.
kHalfX_GrVertexAttribType now really means half-float buffer
data, rather than float. (Caveat: The GL enum is only correct
with ES3/GL3 - ES2+extension needs a different value. Sigh.)
Bug: skia:
Change-Id: Ife101db68a5d4ea1ddc2f6c60fbec0c66d725c16
Reviewed-on: https://skia-review.googlesource.com/154628
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp
index 9d61fb3..0ac6af7 100644
--- a/src/gpu/GrDefaultGeoProcFactory.cpp
+++ b/src/gpu/GrDefaultGeoProcFactory.cpp
@@ -321,29 +321,34 @@
, fColorSpaceXform(std::move(colorSpaceXform))
, fBones(bones)
, fBoneCount(boneCount) {
- fInPosition = {"inPosition", kFloat2_GrVertexAttribType};
+ fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
int cnt = 1;
if (fFlags & kColorAttribute_GPFlag) {
- fInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
+ fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
++cnt;
}
if (fFlags & kLocalCoordAttribute_GPFlag) {
- fInLocalCoords = {"inLocalCoord", kFloat2_GrVertexAttribType};
+ fInLocalCoords = {"inLocalCoord", kFloat2_GrVertexAttribType,
+ kFloat2_GrSLType};
++cnt;
}
if (fFlags & kCoverageAttribute_GPFlag) {
- fInCoverage = {"inCoverage", kHalf_GrVertexAttribType};
+ fInCoverage = {"inCoverage", kFloat_GrVertexAttribType, kHalf_GrSLType};
++cnt;
}
if (fFlags & kBonesAttribute_GPFlag) {
SkASSERT(bones && (boneCount > 0));
// GLSL 1.10 and 1.20 don't support integer attributes.
- GrVertexAttribType indicesAttribType =
- shaderCaps->unsignedSupport() ? kByte4_GrVertexAttribType :
- kUByte4_norm_GrVertexAttribType;
- fInBoneIndices = {"inBoneIndices", indicesAttribType};
+ GrVertexAttribType indicesCPUType = kByte4_GrVertexAttribType;
+ GrSLType indicesGPUType = kByte4_GrSLType;
+ if (!shaderCaps->unsignedSupport()) {
+ indicesCPUType = kUByte4_norm_GrVertexAttribType;
+ indicesGPUType = kHalf4_GrSLType;
+ }
+ fInBoneIndices = {"inBoneIndices", indicesCPUType, indicesGPUType};
++cnt;
- fInBoneWeights = {"inBoneWeights", kUByte4_norm_GrVertexAttribType};
+ fInBoneWeights = {"inBoneWeights", kUByte4_norm_GrVertexAttribType,
+ kHalf4_GrSLType};
++cnt;
}
this->setVertexAttributeCnt(cnt);
diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h
index bd92f82..8a903f3 100644
--- a/src/gpu/GrPrimitiveProcessor.h
+++ b/src/gpu/GrPrimitiveProcessor.h
@@ -53,7 +53,10 @@
class Attribute {
public:
constexpr Attribute() = default;
- constexpr Attribute(const char* name, GrVertexAttribType type) : fName(name), fType(type) {}
+ constexpr Attribute(const char* name,
+ GrVertexAttribType cpuType,
+ GrSLType gpuType)
+ : fName(name), fCPUType(cpuType), fGPUType(gpuType) {}
constexpr Attribute(const Attribute&) = default;
Attribute& operator=(const Attribute&) = default;
@@ -61,18 +64,20 @@
constexpr bool isInitialized() const { return SkToBool(fName); }
constexpr const char* name() const { return fName; }
- constexpr GrVertexAttribType type() const { return fType; }
+ constexpr GrVertexAttribType cpuType() const { return fCPUType; }
+ constexpr GrSLType gpuType() const { return fGPUType; }
inline constexpr size_t size() const;
constexpr size_t sizeAlign4() const { return SkAlign4(this->size()); }
GrShaderVar asShaderVar() const {
- return {fName, GrVertexAttribTypeToSLType(fType), GrShaderVar::kIn_TypeModifier};
+ return {fName, fGPUType, GrShaderVar::kIn_TypeModifier};
}
private:
const char* fName = nullptr;
- GrVertexAttribType fType = kFloat_GrVertexAttribType;
+ GrVertexAttribType fCPUType = kFloat_GrVertexAttribType;
+ GrSLType fGPUType = kFloat_GrSLType;
};
GrPrimitiveProcessor(ClassID);
@@ -253,13 +258,13 @@
case kFloat4_GrVertexAttribType:
return 4 * sizeof(float);
case kHalf_GrVertexAttribType:
- return sizeof(float);
+ return sizeof(uint16_t);
case kHalf2_GrVertexAttribType:
- return 2 * sizeof(float);
+ return 2 * sizeof(uint16_t);
case kHalf3_GrVertexAttribType:
- return 3 * sizeof(float);
+ return 3 * sizeof(uint16_t);
case kHalf4_GrVertexAttribType:
- return 4 * sizeof(float);
+ return 4 * sizeof(uint16_t);
case kInt2_GrVertexAttribType:
return 2 * sizeof(int32_t);
case kInt3_GrVertexAttribType:
@@ -305,7 +310,7 @@
}
constexpr size_t GrPrimitiveProcessor::Attribute::size() const {
- return GrVertexAttribTypeSize(fType);
+ return GrVertexAttribTypeSize(fCPUType);
}
#endif
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp b/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
index 8134fbe..8c2f507 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor_GSImpl.cpp
@@ -61,7 +61,7 @@
Shader::CalcWind(proc, g, "pts", wind.c_str());
if (PrimitiveType::kWeightedTriangles == proc.fPrimitiveType) {
SkASSERT(3 == numInputPoints);
- SkASSERT(kFloat4_GrVertexAttribType == proc.fVertexAttribute.type());
+ SkASSERT(kFloat4_GrVertexAttribType == proc.fVertexAttribute.cpuType());
g->codeAppendf("%s *= sk_in[0].sk_Position.w;", wind.c_str());
}
@@ -381,13 +381,15 @@
void GrCCCoverageProcessor::initGS() {
SkASSERT(Impl::kGeometryShader == fImpl);
if (4 == this->numInputPoints() || this->hasInputWeight()) {
- fVertexAttribute = {"x_or_y_values", kFloat4_GrVertexAttribType};
+ fVertexAttribute =
+ {"x_or_y_values", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
GR_STATIC_ASSERT(sizeof(QuadPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
GR_STATIC_ASSERT(offsetof(QuadPointInstance, fY) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
} else {
- fVertexAttribute = {"x_or_y_values", kFloat3_GrVertexAttribType};
+ fVertexAttribute =
+ {"x_or_y_values", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
GR_STATIC_ASSERT(sizeof(TriPointInstance) ==
2 * GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
GR_STATIC_ASSERT(offsetof(TriPointInstance, fY) ==
diff --git a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
index 5c5120c..a6a05a7 100644
--- a/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
+++ b/src/gpu/ccpr/GrCCCoverageProcessor_VSImpl.cpp
@@ -267,7 +267,7 @@
if (PrimitiveType::kWeightedTriangles == proc.fPrimitiveType) {
SkASSERT(3 == numInputPoints);
SkASSERT(kFloat4_GrVertexAttribType ==
- proc.fInstanceAttributes[kInstanceAttribIdx_X].type());
+ proc.fInstanceAttributes[kInstanceAttribIdx_X].cpuType());
v->codeAppendf("wind *= %s.w;", proc.fInstanceAttributes[kInstanceAttribIdx_X].name());
}
@@ -496,6 +496,7 @@
}
GrVertexAttribType xyAttribType;
+ GrSLType xySLType;
if (4 == this->numInputPoints() || this->hasInputWeight()) {
GR_STATIC_ASSERT(offsetof(QuadPointInstance, fX) == 0);
GR_STATIC_ASSERT(sizeof(QuadPointInstance::fX) ==
@@ -503,6 +504,7 @@
GR_STATIC_ASSERT(sizeof(QuadPointInstance::fY) ==
GrVertexAttribTypeSize(kFloat4_GrVertexAttribType));
xyAttribType = kFloat4_GrVertexAttribType;
+ xySLType = kFloat4_GrSLType;
} else {
GR_STATIC_ASSERT(offsetof(TriPointInstance, fX) == 0);
GR_STATIC_ASSERT(sizeof(TriPointInstance::fX) ==
@@ -510,11 +512,12 @@
GR_STATIC_ASSERT(sizeof(TriPointInstance::fY) ==
GrVertexAttribTypeSize(kFloat3_GrVertexAttribType));
xyAttribType = kFloat3_GrVertexAttribType;
+ xySLType = kFloat3_GrSLType;
}
- fInstanceAttributes[kInstanceAttribIdx_X] = {"X", xyAttribType};
- fInstanceAttributes[kInstanceAttribIdx_Y] = {"Y", xyAttribType};
+ fInstanceAttributes[kInstanceAttribIdx_X] = {"X", xyAttribType, xySLType};
+ fInstanceAttributes[kInstanceAttribIdx_Y] = {"Y", xyAttribType, xySLType};
this->setInstanceAttributeCnt(2);
- fVertexAttribute = {"vertexdata", kInt_GrVertexAttribType};
+ fVertexAttribute = {"vertexdata", kInt_GrVertexAttribType, kInt_GrSLType};
this->setVertexAttributeCnt(1);
if (caps.usePrimitiveRestart()) {
diff --git a/src/gpu/ccpr/GrCCPathProcessor.h b/src/gpu/ccpr/GrCCPathProcessor.h
index 394746b..4eb319a 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPathProcessor.h
@@ -101,12 +101,13 @@
SkMatrix fLocalMatrix;
static constexpr Attribute kInstanceAttribs[kNumInstanceAttribs] = {
- {"devbounds", kFloat4_GrVertexAttribType},
- {"devbounds45", kFloat4_GrVertexAttribType},
- {"dev_to_atlas_offset", kInt2_GrVertexAttribType},
- {"color", kUByte4_norm_GrVertexAttribType}
+ {"devbounds", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
+ {"devbounds45", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
+ {"dev_to_atlas_offset", kInt2_GrVertexAttribType, kInt2_GrSLType},
+ {"color", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType}
};
- static constexpr Attribute kEdgeNormsAttrib = {"edge_norms", kFloat4_GrVertexAttribType};
+ static constexpr Attribute kEdgeNormsAttrib = {"edge_norms", kFloat4_GrVertexAttribType,
+ kFloat4_GrSLType};
typedef GrGeometryProcessor INHERITED;
};
diff --git a/src/gpu/ccpr/GrCCStroker.cpp b/src/gpu/ccpr/GrCCStroker.cpp
index 919e0f7..98f8cef 100644
--- a/src/gpu/ccpr/GrCCStroker.cpp
+++ b/src/gpu/ccpr/GrCCStroker.cpp
@@ -87,8 +87,8 @@
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
static constexpr Attribute kInstanceAttribs[2] = {
- {"endpts", kFloat4_GrVertexAttribType},
- {"stroke_radius", kFloat_GrVertexAttribType}
+ {"endpts", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
+ {"stroke_radius", kFloat_GrVertexAttribType, kFloat_GrSLType}
};
const Attribute& onInstanceAttribute(int i) const override { return kInstanceAttribs[i]; }
@@ -186,9 +186,9 @@
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
static constexpr Attribute kInstanceAttribs[3] = {
- {"X", kFloat4_GrVertexAttribType},
- {"Y", kFloat4_GrVertexAttribType},
- {"stroke_info", kFloat2_GrVertexAttribType}
+ {"X", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
+ {"Y", kFloat4_GrVertexAttribType, kFloat4_GrSLType},
+ {"stroke_info", kFloat2_GrVertexAttribType, kFloat2_GrSLType}
};
const Attribute& onInstanceAttribute(int i) const override { return kInstanceAttribs[i]; }
diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h
index eebe42a..b8742e8 100644
--- a/src/gpu/effects/GrBezierEffect.h
+++ b/src/gpu/effects/GrBezierEffect.h
@@ -120,8 +120,10 @@
bool fUsesLocalCoords;
uint8_t fCoverageScale;
GrClipEdgeType fEdgeType;
- static constexpr Attribute kAttributes[] = {{"inPosition", kFloat2_GrVertexAttribType},
- {"inConicCoeffs", kHalf4_GrVertexAttribType}};
+ static constexpr Attribute kAttributes[] = {
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType},
+ {"inConicCoeffs", kFloat4_GrVertexAttribType, kHalf4_GrSLType}
+ };
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
@@ -205,8 +207,10 @@
uint8_t fCoverageScale;
GrClipEdgeType fEdgeType;
- static constexpr Attribute kAttributes[] = {{"inPosition", kFloat2_GrVertexAttribType},
- {"inHairQuadEdge", kHalf4_GrVertexAttribType}};
+ static constexpr Attribute kAttributes[] = {
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType},
+ {"inHairQuadEdge", kFloat4_GrVertexAttribType, kHalf4_GrSLType}
+ };
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
@@ -292,7 +296,8 @@
SkMatrix fDevKLMMatrix;
GrClipEdgeType fEdgeType;
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index ee38f43..02a9c46 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -132,17 +132,18 @@
SkASSERT(numActiveProxies <= kMaxTextures);
if (usesW) {
- fInPosition = {"inPosition", kFloat3_GrVertexAttribType};
+ fInPosition = {"inPosition", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
} else {
- fInPosition = {"inPosition", kFloat2_GrVertexAttribType};
+ fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
}
- fInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType};
+ fInTextureCoords =
+ {"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
int cnt = 2;
bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat ||
kA565_GrMaskFormat == fMaskFormat;
if (hasVertexColor) {
- fInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
+ fInColor = {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
++cnt;
}
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index 099cc7e..04f73c8 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -226,9 +226,9 @@
SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask));
if (flags & kPerspective_DistanceFieldEffectFlag) {
- fInPosition = {"inPosition", kFloat3_GrVertexAttribType};
+ fInPosition = {"inPosition", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
} else {
- fInPosition = {"inPosition", kFloat2_GrVertexAttribType};
+ fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
}
this->setVertexAttributeCnt(3);
@@ -837,9 +837,9 @@
SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag));
if (fFlags & kPerspective_DistanceFieldEffectFlag) {
- fInPosition = {"inPosition", kFloat3_GrVertexAttribType};
+ fInPosition = {"inPosition", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
} else {
- fInPosition = {"inPosition", kFloat2_GrVertexAttribType};
+ fInPosition = {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
}
this->setVertexAttributeCnt(3);
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h
index fcd98aa..c311908 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -118,8 +118,10 @@
float fDistanceAdjust;
#endif
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInTextureCoords =
+ {"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
@@ -175,9 +177,12 @@
TextureSampler fTextureSamplers[kMaxTextures];
SkISize fAtlasSize; // size for all textures used with fTextureSamplers[].
uint32_t fFlags;
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInTextureCoords =
+ {"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
@@ -253,8 +258,10 @@
Attribute fInPosition;
uint32_t fFlags;
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInTextureCoords = {"inTextureCoords", kUShort2_GrVertexAttribType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInTextureCoords =
+ {"inTextureCoords", kUShort2_GrVertexAttribType, kUShort2_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
diff --git a/src/gpu/effects/GrShadowGeoProc.h b/src/gpu/effects/GrShadowGeoProc.h
index a8880a2..8380015 100644
--- a/src/gpu/effects/GrShadowGeoProc.h
+++ b/src/gpu/effects/GrShadowGeoProc.h
@@ -43,9 +43,12 @@
GrColor fColor;
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInShadowParams = {"inShadowParams", kHalf3_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInShadowParams =
+ {"inShadowParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 87784bd..fda222a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3433,7 +3433,7 @@
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
attribs->enableVertexArrays(this, 1);
- attribs->set(this, 0, fStencilClipClearArrayBuffer.get(), kHalf2_GrVertexAttribType,
+ attribs->set(this, 0, fStencilClipClearArrayBuffer.get(), kFloat2_GrVertexAttribType,
2 * sizeof(GrGLfloat), 0);
GrXferProcessor::BlendInfo blendInfo;
@@ -3545,7 +3545,7 @@
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
attribs->enableVertexArrays(this, 1);
- attribs->set(this, 0, fClearProgramArrayBuffer.get(), kHalf2_GrVertexAttribType,
+ attribs->set(this, 0, fClearProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
2 * sizeof(GrGLfloat), 0);
GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(dst);
@@ -3605,7 +3605,7 @@
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
attribs->enableVertexArrays(this, 1);
- attribs->set(this, 0, fCopyProgramArrayBuffer.get(), kHalf2_GrVertexAttribType,
+ attribs->set(this, 0, fCopyProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
2 * sizeof(GrGLfloat), 0);
// dst rect edges in NDC (-1 to 1)
@@ -3804,7 +3804,7 @@
GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this);
attribs->enableVertexArrays(this, 1);
- attribs->set(this, 0, fMipmapProgramArrayBuffer.get(), kHalf2_GrVertexAttribType,
+ attribs->set(this, 0, fMipmapProgramArrayBuffer.get(), kFloat2_GrVertexAttribType,
2 * sizeof(GrGLfloat), 0);
// Set "simple" state once:
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index deca17d..2f65ed5 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -28,13 +28,13 @@
case kFloat4_GrVertexAttribType:
return {false, 4, GR_GL_FLOAT};
case kHalf_GrVertexAttribType:
- return {false, 1, GR_GL_FLOAT};
+ return {false, 1, GR_GL_HALF_FLOAT};
case kHalf2_GrVertexAttribType:
- return {false, 2, GR_GL_FLOAT};
+ return {false, 2, GR_GL_HALF_FLOAT};
case kHalf3_GrVertexAttribType:
- return {false, 3, GR_GL_FLOAT};
+ return {false, 3, GR_GL_HALF_FLOAT};
case kHalf4_GrVertexAttribType:
- return {false, 4, GR_GL_FLOAT};
+ return {false, 4, GR_GL_HALF_FLOAT};
case kInt2_GrVertexAttribType:
return {false, 2, GR_GL_INT};
case kInt3_GrVertexAttribType:
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index f6890fd..be72881 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -136,7 +136,7 @@
fAttributes.reset(
new GrGLProgram::Attribute[fVertexAttributeCnt + fInstanceAttributeCnt]);
auto addAttr = [&](int i, const auto& a, size_t* stride) {
- fAttributes[i].fType = a.type();
+ fAttributes[i].fType = a.cpuType();
fAttributes[i].fOffset = *stride;
*stride += a.sizeAlign4();
fAttributes[i].fLocation = i;
diff --git a/src/gpu/glsl/GrGLSLVarying.cpp b/src/gpu/glsl/GrGLSLVarying.cpp
index 0563406..42a5abd 100644
--- a/src/gpu/glsl/GrGLSLVarying.cpp
+++ b/src/gpu/glsl/GrGLSLVarying.cpp
@@ -14,8 +14,7 @@
Interpolation interpolation) {
SkASSERT(input.isInitialized());
SkASSERT(!fProgramBuilder->primitiveProcessor().willUseGeoShader());
- GrSLType type = GrVertexAttribTypeToSLType(input.type());
- GrGLSLVarying v(type);
+ GrGLSLVarying v(input.gpuType());
this->addVarying(input.name(), &v, interpolation);
fProgramBuilder->fVS.codeAppendf("%s = %s;", v.vsOut(), input.name());
fProgramBuilder->fFS.codeAppendf("%s = %s;", output, v.fsIn());
diff --git a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
index 269779f..5f2c1ca 100644
--- a/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
+++ b/src/gpu/mtl/GrMtlPipelineStateBuilder.mm
@@ -86,17 +86,21 @@
// metal to avoid an issue with narrow type coercions (float->half) http://skbug.com/8221
switch (type) {
case kFloat_GrVertexAttribType:
- case kHalf_GrVertexAttribType:
return MTLVertexFormatFloat;
case kFloat2_GrVertexAttribType:
- case kHalf2_GrVertexAttribType:
return MTLVertexFormatFloat2;
case kFloat3_GrVertexAttribType:
- case kHalf3_GrVertexAttribType:
return MTLVertexFormatFloat3;
case kFloat4_GrVertexAttribType:
- case kHalf4_GrVertexAttribType:
return MTLVertexFormatFloat4;
+ case kHalf_GrVertexAttribType:
+ return MTLVertexFormatHalf;
+ case kHalf2_GrVertexAttribType:
+ return MTLVertexFormatHalf2;
+ case kHalf3_GrVertexAttribType:
+ return MTLVertexFormatHalf3;
+ case kHalf4_GrVertexAttribType:
+ return MTLVertexFormatHalf4;
case kInt2_GrVertexAttribType:
return MTLVertexFormatInt2;
case kInt3_GrVertexAttribType:
@@ -158,7 +162,7 @@
for (int vertexIndex = 0; vertexIndex < vertexAttributeCount; vertexIndex++) {
const GrGeometryProcessor::Attribute& attribute = primProc.vertexAttribute(vertexIndex);
MTLVertexAttributeDescriptor* mtlAttribute = vertexDescriptor.attributes[attributeIndex];
- mtlAttribute.format = attribute_type_to_mtlformat(attribute.type());
+ mtlAttribute.format = attribute_type_to_mtlformat(attribute.cpuType());
mtlAttribute.offset = vertexAttributeOffset;
mtlAttribute.bufferIndex = vertexBinding;
@@ -181,7 +185,7 @@
for (int instanceIndex = 0; instanceIndex < instanceAttributeCount; instanceIndex++) {
const GrGeometryProcessor::Attribute& attribute = primProc.instanceAttribute(instanceIndex);
MTLVertexAttributeDescriptor* mtlAttribute = vertexDescriptor.attributes[attributeIndex];
- mtlAttribute.format = attribute_type_to_mtlformat(attribute.type());
+ mtlAttribute.format = attribute_type_to_mtlformat(attribute.cpuType());
mtlAttribute.offset = instanceAttributeOffset;
mtlAttribute.bufferIndex = instanceBinding;
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 0f81897..1cbf5cf 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -653,9 +653,12 @@
const Attribute& onVertexAttribute(int i) const override {
return IthAttribute(i, kInPosition, kInColor, kInQuadEdge);
}
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInQuadEdge = {"inQuadEdge", kHalf4_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInQuadEdge =
+ {"inQuadEdge", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
SkMatrix fLocalMatrix;
bool fUsesLocalCoords;
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index 075df70..cb3e772 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -863,9 +863,12 @@
bool fUsesLocalCoords;
AAMode fAAMode;
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInDashParams = {"inDashParams", kHalf3_GrVertexAttribType};
- static constexpr Attribute kInCircleParams = {"inCircleParams", kHalf2_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInDashParams =
+ {"inDashParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
+ static constexpr Attribute kInCircleParams =
+ {"inCircleParams", kFloat2_GrVertexAttribType, kHalf2_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
@@ -1073,9 +1076,12 @@
bool fUsesLocalCoords;
AAMode fAAMode;
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInDashParams = {"inDashParams", kHalf3_GrVertexAttribType};
- static constexpr Attribute kInRectParams = {"inRect", kHalf4_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInDashParams =
+ {"inDashParams", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
+ static constexpr Attribute kInRectParams =
+ {"inRect", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 4832ee7..7c3d4bf 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -106,10 +106,14 @@
const TextureSampler& onTextureSampler(int) const override { return fSampler; }
- static constexpr Attribute kPositions = {"position", kFloat2_GrVertexAttribType};
- static constexpr Attribute kTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType};
- static constexpr Attribute kTextureDomain = {"textureDomain", kFloat4_GrVertexAttribType};
- static constexpr Attribute kColors = {"color", kUByte4_norm_GrVertexAttribType};
+ static constexpr Attribute kPositions =
+ {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kTextureCoords =
+ {"textureCoords", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kTextureDomain =
+ {"textureDomain", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
+ static constexpr Attribute kColors =
+ {"color", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
sk_sp<GrColorSpaceXform> fColorSpaceXform;
TextureSampler fSampler;
diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp
index c0158ba..c739374 100644
--- a/src/gpu/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ops/GrOvalOpFactory.cpp
@@ -77,21 +77,22 @@
, fStroke(stroke) {
int cnt = 3;
if (clipPlane) {
- fInClipPlane = {"inClipPlane", kHalf3_GrVertexAttribType};
+ fInClipPlane = {"inClipPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
++cnt;
}
if (isectPlane) {
- fInIsectPlane = {"inIsectPlane", kHalf3_GrVertexAttribType};
+ fInIsectPlane = {"inIsectPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
++cnt;
}
if (unionPlane) {
- fInUnionPlane = {"inUnionPlane", kHalf3_GrVertexAttribType};
+ fInUnionPlane = {"inUnionPlane", kFloat3_GrVertexAttribType, kHalf3_GrSLType};
++cnt;
}
if (roundCaps) {
SkASSERT(stroke);
SkASSERT(clipPlane);
- fInRoundCapCenters = {"inRoundCapCenters", kFloat4_GrVertexAttribType};
+ fInRoundCapCenters =
+ {"inRoundCapCenters", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
++cnt;
}
this->setVertexAttributeCnt(cnt);
@@ -237,9 +238,12 @@
SkMatrix fLocalMatrix;
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInCircleEdge =
+ {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
// Optional attributes.
Attribute fInClipPlane;
@@ -489,10 +493,14 @@
}
SkMatrix fLocalMatrix;
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInCircleEdge = {"inCircleEdge", kFloat4_GrVertexAttribType};
- static constexpr Attribute kInDashParams = {"inDashParams", kFloat4_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInCircleEdge =
+ {"inCircleEdge", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
+ static constexpr Attribute kInDashParams =
+ {"inDashParams", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
GR_DECLARE_GEOMETRY_PROCESSOR_TEST
@@ -635,10 +643,14 @@
return IthAttribute(i, kInPosition, kInColor, kInEllipseOffset, kInEllipseRadii);
}
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
- static constexpr Attribute kInEllipseOffset = {"inEllipseOffset", kHalf2_GrVertexAttribType};
- static constexpr Attribute kInEllipseRadii = {"inEllipseRadii", kHalf4_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ static constexpr Attribute kInEllipseOffset =
+ {"inEllipseOffset", kFloat2_GrVertexAttribType, kHalf2_GrSLType};
+ static constexpr Attribute kInEllipseRadii =
+ {"inEllipseRadii", kFloat4_GrVertexAttribType, kHalf4_GrSLType};
SkMatrix fLocalMatrix;
bool fStroke;
@@ -807,12 +819,16 @@
return IthAttribute(i, kInPosition, kInColor, kInEllipseOffsets0, kInEllipseOffsets1);
}
- static constexpr Attribute kInPosition = {"inPosition", kFloat2_GrVertexAttribType};
- static constexpr Attribute kInColor = {"inColor", kUByte4_norm_GrVertexAttribType};
+ static constexpr Attribute kInPosition =
+ {"inPosition", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
+ static constexpr Attribute kInColor =
+ {"inColor", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
static constexpr Attribute kInEllipseOffsets0 = {"inEllipseOffsets0",
- kHalf2_GrVertexAttribType};
+ kFloat2_GrVertexAttribType,
+ kHalf2_GrSLType};
static constexpr Attribute kInEllipseOffsets1 = {"inEllipseOffsets1",
- kHalf2_GrVertexAttribType};
+ kFloat2_GrVertexAttribType,
+ kHalf2_GrSLType};
SkMatrix fViewMatrix;
DIEllipseStyle fStyle;
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 2ba3639..ba37048 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -95,7 +95,7 @@
b->add32(GrColorSpaceXform::XformKey(fTextureColorSpaceXform.get()));
b->add32(GrColorSpaceXform::XformKey(fPaintColorSpaceXform.get()));
uint32_t x = this->usesCoverageEdgeAA() ? 0 : 1;
- x |= kFloat3_GrVertexAttribType == fPositions.type() ? 0 : 2;
+ x |= kFloat3_GrVertexAttribType == fPositions.cpuType() ? 0 : 2;
x |= fDomain.isInitialized() ? 4 : 0;
b->add32(x);
}
@@ -121,7 +121,7 @@
fPaintColorSpaceXformHelper.emitCode(
args.fUniformHandler, textureGP.fPaintColorSpaceXform.get(),
kVertex_GrShaderFlag);
- if (kFloat2_GrVertexAttribType == textureGP.fPositions.type()) {
+ if (kFloat2_GrVertexAttribType == textureGP.fPositions.cpuType()) {
args.fVaryingHandler->setNoPerspective();
}
args.fVaryingHandler->emitAttributes(textureGP);
@@ -165,7 +165,7 @@
bool mulByFragCoordW = false;
GrGLSLVarying aaDistVarying(kFloat4_GrSLType,
GrGLSLVarying::Scope::kVertToFrag);
- if (kFloat3_GrVertexAttribType == textureGP.fPositions.type()) {
+ if (kFloat3_GrVertexAttribType == textureGP.fPositions.cpuType()) {
args.fVaryingHandler->addVarying("aaDists", &aaDistVarying);
// The distance from edge equation e to homogenous point p=sk_Position
// is e.x*p.x/p.wx + e.y*p.y/p.w + e.z. However, we want screen space
@@ -224,23 +224,23 @@
this->setTextureSamplerCnt(1);
if (perspective) {
- fPositions = {"position", kFloat3_GrVertexAttribType};
+ fPositions = {"position", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
} else {
- fPositions = {"position", kFloat2_GrVertexAttribType};
+ fPositions = {"position", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
}
- fColors = {"color", kUByte4_norm_GrVertexAttribType};
- fTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType};
+ fColors = {"color", kUByte4_norm_GrVertexAttribType, kHalf4_GrSLType};
+ fTextureCoords = {"textureCoords", kFloat2_GrVertexAttribType, kFloat2_GrSLType};
int vertexAttributeCnt = 3;
if (domain == Domain::kYes) {
- fDomain = {"domain", kFloat4_GrVertexAttribType};
+ fDomain = {"domain", kFloat4_GrVertexAttribType, kFloat4_GrSLType};
++vertexAttributeCnt;
}
if (coverageAA) {
- fAAEdges[0] = {"aaEdge0", kFloat3_GrVertexAttribType};
- fAAEdges[1] = {"aaEdge1", kFloat3_GrVertexAttribType};
- fAAEdges[2] = {"aaEdge2", kFloat3_GrVertexAttribType};
- fAAEdges[3] = {"aaEdge3", kFloat3_GrVertexAttribType};
+ fAAEdges[0] = {"aaEdge0", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
+ fAAEdges[1] = {"aaEdge1", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
+ fAAEdges[2] = {"aaEdge2", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
+ fAAEdges[3] = {"aaEdge3", kFloat3_GrVertexAttribType, kFloat3_GrSLType};
vertexAttributeCnt += 4;
}
this->setVertexAttributeCnt(vertexAttributeCnt);
diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp
index c85dcd7..c07f082 100644
--- a/src/gpu/vk/GrVkPipeline.cpp
+++ b/src/gpu/vk/GrVkPipeline.cpp
@@ -17,17 +17,21 @@
static inline VkFormat attrib_type_to_vkformat(GrVertexAttribType type) {
switch (type) {
case kFloat_GrVertexAttribType:
- case kHalf_GrVertexAttribType:
return VK_FORMAT_R32_SFLOAT;
case kFloat2_GrVertexAttribType:
- case kHalf2_GrVertexAttribType:
return VK_FORMAT_R32G32_SFLOAT;
case kFloat3_GrVertexAttribType:
- case kHalf3_GrVertexAttribType:
return VK_FORMAT_R32G32B32_SFLOAT;
case kFloat4_GrVertexAttribType:
- case kHalf4_GrVertexAttribType:
return VK_FORMAT_R32G32B32A32_SFLOAT;
+ case kHalf_GrVertexAttribType:
+ return VK_FORMAT_R16_SFLOAT;
+ case kHalf2_GrVertexAttribType:
+ return VK_FORMAT_R16G16_SFLOAT;
+ case kHalf3_GrVertexAttribType:
+ return VK_FORMAT_R16G16B16_SFLOAT;
+ case kHalf4_GrVertexAttribType:
+ return VK_FORMAT_R16G16B16A16_SFLOAT;
case kInt2_GrVertexAttribType:
return VK_FORMAT_R32G32_SINT;
case kInt3_GrVertexAttribType:
@@ -93,7 +97,7 @@
VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
vkAttrib.location = attribIndex; // for now assume location = attribIndex
vkAttrib.binding = vertexBinding;
- vkAttrib.format = attrib_type_to_vkformat(attrib.type());
+ vkAttrib.format = attrib_type_to_vkformat(attrib.cpuType());
vkAttrib.offset = vertexAttributeOffset;
SkASSERT(vkAttrib.offset == primProc.debugOnly_vertexAttributeOffset(attribIndex));
vertexAttributeOffset += attrib.sizeAlign4();
@@ -107,7 +111,7 @@
VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
vkAttrib.location = attribIndex; // for now assume location = attribIndex
vkAttrib.binding = instanceBinding;
- vkAttrib.format = attrib_type_to_vkformat(attrib.type());
+ vkAttrib.format = attrib_type_to_vkformat(attrib.cpuType());
vkAttrib.offset = instanceAttributeOffset;
SkASSERT(vkAttrib.offset == primProc.debugOnly_instanceAttributeOffset(iaIndex));
instanceAttributeOffset += attrib.sizeAlign4();