diff options
24 files changed, 187 insertions, 175 deletions
diff --git a/include/gpu/GrShaderCaps.h b/include/gpu/GrShaderCaps.h index d40e935773..667433c295 100644 --- a/include/gpu/GrShaderCaps.h +++ b/include/gpu/GrShaderCaps.h @@ -81,7 +81,7 @@ public: int imageLoadStoreSupport() const { return fImageLoadStoreSupport; } /** - * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a + * Get the precision info for a variable of type kFloat_GrSLType, kFloat2_GrSLType, etc in a * given shader type. If the shader type is not supported or the precision level is not * supported in that shader type then the returned struct will report false when supported() is * called. diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h index 0b4703f7a7..04a0111744 100644 --- a/include/private/GrTypesPriv.h +++ b/include/private/GrTypesPriv.h @@ -449,19 +449,24 @@ static inline bool GrSLTypeTemporarilyAcceptsPrecision(GrSLType type) { */ enum GrVertexAttribType { kFloat_GrVertexAttribType = 0, - kVec2f_GrVertexAttribType, - kVec3f_GrVertexAttribType, - kVec4f_GrVertexAttribType, + kFloat2_GrVertexAttribType, + kFloat3_GrVertexAttribType, + kFloat4_GrVertexAttribType, + kHalf_GrVertexAttribType, + kHalf2_GrVertexAttribType, + kHalf3_GrVertexAttribType, + kHalf4_GrVertexAttribType, - kVec2i_GrVertexAttribType, // vector of 2 32-bit ints - kVec3i_GrVertexAttribType, // vector of 3 32-bit ints - kVec4i_GrVertexAttribType, // vector of 4 32-bit ints + kInt2_GrVertexAttribType, // vector of 2 32-bit ints + kInt3_GrVertexAttribType, // vector of 3 32-bit ints + kInt4_GrVertexAttribType, // vector of 4 32-bit ints - kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage - kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors + kUByte_norm_GrVertexAttribType, // unsigned byte, e.g. coverage, 0 -> 0.0f, 255 -> 1.0f. + kUByte4_norm_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors, 0 -> 0.0f, + // 255 -> 1.0f. - kVec2us_norm_GrVertexAttribType, // vector of 2 shorts. 0 -> 0.0f, 65535 -> 1.0f. - kVec2us_uint_GrVertexAttribType, // vector of 2 shorts. 0 -> 0, 65535 -> 65535. + kUShort2_GrVertexAttribType, // vector of 2 shorts. 0 -> 0, 65535 -> 65535. + kUShort2_norm_GrVertexAttribType, // vector of 2 shorts. 0 -> 0.0f, 65535 -> 1.0f. kInt_GrVertexAttribType, kUint_GrVertexAttribType, @@ -477,24 +482,32 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { switch (type) { case kFloat_GrVertexAttribType: return sizeof(float); - case kVec2f_GrVertexAttribType: + case kFloat2_GrVertexAttribType: return 2 * sizeof(float); - case kVec3f_GrVertexAttribType: + case kFloat3_GrVertexAttribType: return 3 * sizeof(float); - case kVec4f_GrVertexAttribType: + case kFloat4_GrVertexAttribType: return 4 * sizeof(float); - case kVec2i_GrVertexAttribType: + case kHalf_GrVertexAttribType: + return sizeof(float); + case kHalf2_GrVertexAttribType: + return 2 * sizeof(float); + case kHalf3_GrVertexAttribType: + return 3 * sizeof(float); + case kHalf4_GrVertexAttribType: + return 4 * sizeof(float); + case kInt2_GrVertexAttribType: return 2 * sizeof(int32_t); - case kVec3i_GrVertexAttribType: + case kInt3_GrVertexAttribType: return 3 * sizeof(int32_t); - case kVec4i_GrVertexAttribType: + case kInt4_GrVertexAttribType: return 4 * sizeof(int32_t); - case kUByte_GrVertexAttribType: + case kUByte_norm_GrVertexAttribType: return 1 * sizeof(char); - case kVec4ub_GrVertexAttribType: + case kUByte4_norm_GrVertexAttribType: return 4 * sizeof(char); - case kVec2us_norm_GrVertexAttribType: // fall through - case kVec2us_uint_GrVertexAttribType: + case kUShort2_norm_GrVertexAttribType: // fall through + case kUShort2_GrVertexAttribType: return 2 * sizeof(int16_t); case kInt_GrVertexAttribType: return sizeof(int32_t); @@ -510,25 +523,33 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { */ static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { switch (type) { - case kVec2us_norm_GrVertexAttribType: // fall through + case kUShort2_norm_GrVertexAttribType: // fall through return kFloat2_GrSLType; - case kVec2us_uint_GrVertexAttribType: + case kUShort2_GrVertexAttribType: return kUint2_GrSLType; - case kUByte_GrVertexAttribType: // fall through + case kUByte_norm_GrVertexAttribType: // fall through case kFloat_GrVertexAttribType: return kFloat_GrSLType; - case kVec2f_GrVertexAttribType: + case kFloat2_GrVertexAttribType: return kFloat2_GrSLType; - case kVec3f_GrVertexAttribType: + case kFloat3_GrVertexAttribType: return kFloat3_GrSLType; - case kVec4ub_GrVertexAttribType: - case kVec4f_GrVertexAttribType: + case kFloat4_GrVertexAttribType: return kFloat4_GrSLType; - case kVec2i_GrVertexAttribType: + case kHalf_GrVertexAttribType: + return kHalf_GrSLType; + case kHalf2_GrVertexAttribType: + return kHalf2_GrSLType; + case kHalf3_GrVertexAttribType: + return kHalf3_GrSLType; + case kHalf4_GrVertexAttribType: + case kUByte4_norm_GrVertexAttribType: + return kHalf4_GrSLType; + case kInt2_GrVertexAttribType: return kInt2_GrSLType; - case kVec3i_GrVertexAttribType: + case kInt3_GrVertexAttribType: return kInt3_GrSLType; - case kVec4i_GrVertexAttribType: + case kInt4_GrVertexAttribType: return kInt4_GrSLType; case kInt_GrVertexAttribType: return kInt_GrSLType; diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index 58ae2a90ec..32d16ffa75 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -256,18 +256,16 @@ private: , fLocalCoordsWillBeRead(localCoordsWillBeRead) , fColorSpaceXform(std::move(colorSpaceXform)) { this->initClassID<DefaultGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); if (fFlags & kColorAttribute_GPFlag) { - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); } if (fFlags & kLocalCoordAttribute_GPFlag) { - fInLocalCoords = &this->addVertexAttrib("inLocalCoord", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); + fInLocalCoords = &this->addVertexAttrib("inLocalCoord", kFloat2_GrVertexAttribType); this->setHasExplicitLocalCoords(); } if (fFlags & kCoverageAttribute_GPFlag) { - fInCoverage = &this->addVertexAttrib("inCoverage", kFloat_GrVertexAttribType); + fInCoverage = &this->addVertexAttrib("inCoverage", kHalf_GrVertexAttribType); } } diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h index 3b90689aca..eb59d98b15 100644 --- a/src/gpu/GrPrimitiveProcessor.h +++ b/src/gpu/GrPrimitiveProcessor.h @@ -49,7 +49,6 @@ public: const char* fName; GrVertexAttribType fType; int fOffsetInRecord; - GrSLPrecision fPrecision; InputRate fInputRate; }; @@ -118,19 +117,13 @@ protected: /** * Subclasses call these from their constructor to register vertex and instance attributes. */ - const Attribute& addVertexAttrib(const char* name, GrVertexAttribType type, - GrSLPrecision precision = kDefault_GrSLPrecision) { - precision = (kDefault_GrSLPrecision == precision) ? kMedium_GrSLPrecision : precision; - fAttribs.push_back() = {name, type, fVertexStride, precision, - Attribute::InputRate::kPerVertex}; + const Attribute& addVertexAttrib(const char* name, GrVertexAttribType type) { + fAttribs.push_back() = {name, type, fVertexStride, Attribute::InputRate::kPerVertex}; fVertexStride += static_cast<int>(SkAlign4(GrVertexAttribTypeSize(type))); return fAttribs.back(); } - const Attribute& addInstanceAttrib(const char* name, GrVertexAttribType type, - GrSLPrecision precision = kDefault_GrSLPrecision) { - precision = (kDefault_GrSLPrecision == precision) ? kMedium_GrSLPrecision : precision; - fAttribs.push_back() = {name, type, fInstanceStride, precision, - Attribute::InputRate::kPerInstance}; + const Attribute& addInstanceAttrib(const char* name, GrVertexAttribType type) { + fAttribs.push_back() = {name, type, fInstanceStride, Attribute::InputRate::kPerInstance}; fInstanceStride += static_cast<int>(SkAlign4(GrVertexAttribTypeSize(type))); return fAttribs.back(); } diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp index 4a0dd2666a..7354c03592 100644 --- a/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp +++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.cpp @@ -43,8 +43,7 @@ const char* GrCCPRCoverageProcessor::GetProcessorName(Mode mode) { GrCCPRCoverageProcessor::GrCCPRCoverageProcessor(Mode mode, GrBuffer* pointsBuffer) : fMode(mode) - , fInstanceAttrib(this->addInstanceAttrib("instance", InstanceArrayFormat(mode), - kHigh_GrSLPrecision)) { + , fInstanceAttrib(this->addInstanceAttrib("instance", InstanceArrayFormat(mode))) { fPointsBufferAccess.reset(kRG_float_GrPixelConfig, pointsBuffer, kVertex_GrShaderFlag); this->addBufferAccess(&fPointsBufferAccess); diff --git a/src/gpu/ccpr/GrCCPRCoverageProcessor.h b/src/gpu/ccpr/GrCCPRCoverageProcessor.h index 879f724f4f..f02b7422c8 100644 --- a/src/gpu/ccpr/GrCCPRCoverageProcessor.h +++ b/src/gpu/ccpr/GrCCPRCoverageProcessor.h @@ -73,7 +73,7 @@ public: kLoopCorners }; static constexpr GrVertexAttribType InstanceArrayFormat(Mode mode) { - return mode < Mode::kQuadraticHulls ? kVec4i_GrVertexAttribType : kVec2i_GrVertexAttribType; + return mode < Mode::kQuadraticHulls ? kInt4_GrVertexAttribType : kInt2_GrVertexAttribType; } static const char* GetProcessorName(Mode); @@ -81,7 +81,7 @@ public: const char* instanceAttrib() const { return fInstanceAttrib.fName; } int atlasOffsetIdx() const { - return kVec4i_GrVertexAttribType == InstanceArrayFormat(fMode) ? 3 : 1; + return kInt4_GrVertexAttribType == InstanceArrayFormat(fMode) ? 3 : 1; } const char* name() const override { return GetProcessorName(fMode); } SkString dumpInfo() const override { diff --git a/src/gpu/ccpr/GrCCPRPathProcessor.cpp b/src/gpu/ccpr/GrCCPRPathProcessor.cpp index 78baa368da..bac52ce447 100644 --- a/src/gpu/ccpr/GrCCPRPathProcessor.cpp +++ b/src/gpu/ccpr/GrCCPRPathProcessor.cpp @@ -51,14 +51,14 @@ GR_DECLARE_STATIC_UNIQUE_KEY(gIndexBufferKey); GrCCPRPathProcessor::GrCCPRPathProcessor(GrResourceProvider* rp, sk_sp<GrTextureProxy> atlas, SkPath::FillType fillType, const GrShaderCaps& shaderCaps) : fFillType(fillType) { - this->addInstanceAttrib("devbounds", kVec4f_GrVertexAttribType, kHigh_GrSLPrecision); - this->addInstanceAttrib("devbounds45", kVec4f_GrVertexAttribType, kHigh_GrSLPrecision); - this->addInstanceAttrib("view_matrix", kVec4f_GrVertexAttribType, kHigh_GrSLPrecision); - this->addInstanceAttrib("view_translate", kVec2f_GrVertexAttribType, kHigh_GrSLPrecision); + this->addInstanceAttrib("devbounds", kFloat4_GrVertexAttribType); + this->addInstanceAttrib("devbounds45", kFloat4_GrVertexAttribType); + this->addInstanceAttrib("view_matrix", kFloat4_GrVertexAttribType); + this->addInstanceAttrib("view_translate", kFloat2_GrVertexAttribType); // FIXME: this could be a vector of two shorts if it were supported by Ganesh. - // Note: this should be doable now with kVec2us_uint_GrVertexAttribType - this->addInstanceAttrib("atlas_offset", kVec2i_GrVertexAttribType, kHigh_GrSLPrecision); - this->addInstanceAttrib("color", kVec4ub_GrVertexAttribType, kLow_GrSLPrecision); + // Note: this should be doable now with kUShort2_GrVertexAttribType + this->addInstanceAttrib("atlas_offset", kInt2_GrVertexAttribType); + this->addInstanceAttrib("color", kUByte4_norm_GrVertexAttribType); SkASSERT(offsetof(Instance, fDevBounds) == this->getInstanceAttrib(InstanceAttribs::kDevBounds).fOffsetInRecord); @@ -76,7 +76,7 @@ GrCCPRPathProcessor::GrCCPRPathProcessor(GrResourceProvider* rp, sk_sp<GrTexture GR_STATIC_ASSERT(6 == kNumInstanceAttribs); - this->addVertexAttrib("edge_norms", kVec4f_GrVertexAttribType, kHigh_GrSLPrecision); + this->addVertexAttrib("edge_norms", kFloat4_GrVertexAttribType); fAtlasAccess.reset(std::move(atlas), GrSamplerState::Filter::kNearest, GrSamplerState::WrapMode::kClamp, kFragment_GrShaderFlag); diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index 9f5c8ca0e7..354bc67bda 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -241,9 +241,8 @@ GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t , fCoverageScale(coverage) , fEdgeType(edgeType) { this->initClassID<GrConicEffect>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInConicCoeffs = &this->addVertexAttrib("inConicCoeffs", kVec4f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInConicCoeffs = &this->addVertexAttrib("inConicCoeffs", kHalf4_GrVertexAttribType); } ////////////////////////////////////////////////////////////////////////////// @@ -444,9 +443,8 @@ GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co , fCoverageScale(coverage) , fEdgeType(edgeType) { this->initClassID<GrQuadEffect>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInHairQuadEdge = &this->addVertexAttrib("inHairQuadEdge", kVec4f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInHairQuadEdge = &this->addVertexAttrib("inHairQuadEdge", kHalf4_GrVertexAttribType); } ////////////////////////////////////////////////////////////////////////////// @@ -670,8 +668,7 @@ GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, const Sk , fDevKLMMatrix(devKLMMatrix) , fEdgeType(edgeType) { this->initClassID<GrCubicEffect>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); } ////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 0997b9ed7d..4370219f67 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -130,17 +130,15 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, , fInColor(nullptr) , fMaskFormat(format) { this->initClassID<GrBitmapTextGeoProc>(); - fInPosition = - &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, kHigh_GrSLPrecision); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); bool hasVertexColor = kA8_GrMaskFormat == fMaskFormat || kA565_GrMaskFormat == fMaskFormat; if (hasVertexColor) { - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); } - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_uint_GrVertexAttribType, - kHigh_GrSLPrecision); + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < kMaxTextures; ++i) { if (proxies[i]) { fTextureSamplers[i].reset(std::move(proxies[i]), params); diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 44e52735bd..dcbb5d5df9 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -247,11 +247,9 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc( , fUsesLocalCoords(usesLocalCoords) { SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); this->initClassID<GrDistanceFieldA8TextGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_uint_GrVertexAttribType, - kHigh_GrSLPrecision); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < kMaxTextures; ++i) { if (proxies[i]) { fTextureSamplers[i].reset(std::move(proxies[i]), params); @@ -507,11 +505,9 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc( , fUsesLocalCoords(usesLocalCoords) { SkASSERT(!(flags & ~kNonLCD_DistanceFieldEffectMask)); this->initClassID<GrDistanceFieldPathGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_uint_GrVertexAttribType, - kHigh_GrSLPrecision); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < kMaxTextures; ++i) { if (proxies[i]) { fTextureSamplers[i].reset(std::move(proxies[i]), params); @@ -828,11 +824,9 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc( , fUsesLocalCoords(usesLocalCoords) { SkASSERT(!(flags & ~kLCD_DistanceFieldEffectMask) && (flags & kUseLCD_DistanceFieldEffectFlag)); this->initClassID<GrDistanceFieldLCDTextGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kVec2us_uint_GrVertexAttribType, - kHigh_GrSLPrecision); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInTextureCoords = &this->addVertexAttrib("inTextureCoords", kUShort2_GrVertexAttribType); for (int i = 0; i < kMaxTextures; ++i) { if (proxies[i]) { fTextureSamplers[i].reset(std::move(proxies[i]), params); diff --git a/src/gpu/effects/GrShadowGeoProc.cpp b/src/gpu/effects/GrShadowGeoProc.cpp index ca4c5dba75..3217f46303 100644 --- a/src/gpu/effects/GrShadowGeoProc.cpp +++ b/src/gpu/effects/GrShadowGeoProc.cpp @@ -65,10 +65,9 @@ private: GrRRectShadowGeoProc::GrRRectShadowGeoProc() { this->initClassID<GrRRectShadowGeoProc>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInShadowParams = &this->addVertexAttrib("inShadowParams", kVec4f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInShadowParams = &this->addVertexAttrib("inShadowParams", kHalf4_GrVertexAttribType); } GrGLSLPrimitiveProcessor* GrRRectShadowGeoProc::createGLSLInstance(const GrShaderCaps&) const { diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 92eb86d707..ff19bb6fc3 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -3811,7 +3811,7 @@ void GrGLGpu::clearStencilClipAsDraw(const GrFixedClip& clip, bool insideStencil GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this); attribs->enableVertexArrays(this, 1); - attribs->set(this, 0, fStencilClipClearArrayBuffer.get(), kVec2f_GrVertexAttribType, + attribs->set(this, 0, fStencilClipClearArrayBuffer.get(), kHalf2_GrVertexAttribType, 2 * sizeof(GrGLfloat), 0); GrXferProcessor::BlendInfo blendInfo; @@ -3864,7 +3864,7 @@ bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin, GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this); attribs->enableVertexArrays(this, 1); - attribs->set(this, 0, fCopyProgramArrayBuffer.get(), kVec2f_GrVertexAttribType, + attribs->set(this, 0, fCopyProgramArrayBuffer.get(), kHalf2_GrVertexAttribType, 2 * sizeof(GrGLfloat), 0); // dst rect edges in NDC (-1 to 1) @@ -4095,7 +4095,7 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin GrGLAttribArrayState* attribs = fHWVertexArrayState.bindInternalVertexArray(this); attribs->enableVertexArrays(this, 1); - attribs->set(this, 0, fMipmapProgramArrayBuffer.get(), kVec2f_GrVertexAttribType, + attribs->set(this, 0, fMipmapProgramArrayBuffer.get(), kHalf2_GrVertexAttribType, 2 * sizeof(GrGLfloat), 0); // Set "simple" state once: diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp index 991de96325..a903e7d2f1 100644 --- a/src/gpu/gl/GrGLVertexArray.cpp +++ b/src/gpu/gl/GrGLVertexArray.cpp @@ -21,25 +21,33 @@ static AttribLayout attrib_layout(GrVertexAttribType type) { switch (type) { case kFloat_GrVertexAttribType: return {false, 1, GR_GL_FLOAT}; - case kVec2f_GrVertexAttribType: + case kFloat2_GrVertexAttribType: return {false, 2, GR_GL_FLOAT}; - case kVec3f_GrVertexAttribType: + case kFloat3_GrVertexAttribType: return {false, 3, GR_GL_FLOAT}; - case kVec4f_GrVertexAttribType: + case kFloat4_GrVertexAttribType: return {false, 4, GR_GL_FLOAT}; - case kVec2i_GrVertexAttribType: + case kHalf_GrVertexAttribType: + return {false, 1, GR_GL_FLOAT}; + case kHalf2_GrVertexAttribType: + return {false, 2, GR_GL_FLOAT}; + case kHalf3_GrVertexAttribType: + return {false, 3, GR_GL_FLOAT}; + case kHalf4_GrVertexAttribType: + return {false, 4, GR_GL_FLOAT}; + case kInt2_GrVertexAttribType: return {false, 2, GR_GL_INT}; - case kVec3i_GrVertexAttribType: + case kInt3_GrVertexAttribType: return {false, 3, GR_GL_INT}; - case kVec4i_GrVertexAttribType: + case kInt4_GrVertexAttribType: return {false, 4, GR_GL_INT}; - case kUByte_GrVertexAttribType: + case kUByte_norm_GrVertexAttribType: return {true, 1, GR_GL_UNSIGNED_BYTE}; - case kVec4ub_GrVertexAttribType: + case kUByte4_norm_GrVertexAttribType: return {true, 4, GR_GL_UNSIGNED_BYTE}; - case kVec2us_norm_GrVertexAttribType: + case kUShort2_norm_GrVertexAttribType: return {true, 2, GR_GL_UNSIGNED_SHORT}; - case kVec2us_uint_GrVertexAttribType: + case kUShort2_GrVertexAttribType: return {false, 2, GR_GL_UNSIGNED_SHORT}; case kInt_GrVertexAttribType: return {false, 1, GR_GL_INT}; @@ -55,25 +63,33 @@ static bool GrVertexAttribTypeIsIntType(const GrShaderCaps* shaderCaps, switch (type) { case kFloat_GrVertexAttribType: return false; - case kVec2f_GrVertexAttribType: + case kFloat2_GrVertexAttribType: + return false; + case kFloat3_GrVertexAttribType: + return false; + case kFloat4_GrVertexAttribType: + return false; + case kHalf_GrVertexAttribType: + return false; + case kHalf2_GrVertexAttribType: return false; - case kVec3f_GrVertexAttribType: + case kHalf3_GrVertexAttribType: return false; - case kVec4f_GrVertexAttribType: + case kHalf4_GrVertexAttribType: return false; - case kVec2i_GrVertexAttribType: + case kInt2_GrVertexAttribType: return true; - case kVec3i_GrVertexAttribType: + case kInt3_GrVertexAttribType: return true; - case kVec4i_GrVertexAttribType: + case kInt4_GrVertexAttribType: return true; - case kUByte_GrVertexAttribType: + case kUByte_norm_GrVertexAttribType: return false; - case kVec4ub_GrVertexAttribType: + case kUByte4_norm_GrVertexAttribType: return false; - case kVec2us_norm_GrVertexAttribType: + case kUShort2_norm_GrVertexAttribType: return false; - case kVec2us_uint_GrVertexAttribType: + case kUShort2_GrVertexAttribType: return shaderCaps->integerSupport(); case kInt_GrVertexAttribType: return true; diff --git a/src/gpu/glsl/GrGLSLVarying.cpp b/src/gpu/glsl/GrGLSLVarying.cpp index ef3fe8af23..1f8ddbd8dd 100644 --- a/src/gpu/glsl/GrGLSLVarying.cpp +++ b/src/gpu/glsl/GrGLSLVarying.cpp @@ -69,8 +69,7 @@ void GrGLSLVaryingHandler::emitAttributes(const GrGeometryProcessor& gp) { this->addAttribute(GrShaderVar(attr.fName, GrVertexAttribTypeToSLType(attr.fType), GrShaderVar::kIn_TypeModifier, - GrShaderVar::kNonArray, - attr.fPrecision)); + GrShaderVar::kNonArray)); } } diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp index 3dcc3caf21..5890028b6a 100644 --- a/src/gpu/instanced/InstanceProcessor.cpp +++ b/src/gpu/instanced/InstanceProcessor.cpp @@ -43,13 +43,13 @@ GrCaps::InstancedSupport InstanceProcessor::CheckSupport(const GrShaderCaps& sha InstanceProcessor::InstanceProcessor(OpInfo opInfo, GrBuffer* paramsBuffer) : fOpInfo(opInfo) { this->initClassID<InstanceProcessor>(); - this->addVertexAttrib("shapeCoords", kVec2f_GrVertexAttribType, kHigh_GrSLPrecision); + this->addVertexAttrib("shapeCoords", kFloat2_GrVertexAttribType); this->addVertexAttrib("vertexAttrs", kInt_GrVertexAttribType); this->addVertexAttrib("instanceInfo", kUint_GrVertexAttribType); - this->addVertexAttrib("shapeMatrixX", kVec3f_GrVertexAttribType, kHigh_GrSLPrecision); - this->addVertexAttrib("shapeMatrixY", kVec3f_GrVertexAttribType, kHigh_GrSLPrecision); - this->addVertexAttrib("color", kVec4f_GrVertexAttribType, kLow_GrSLPrecision); - this->addVertexAttrib("localRect", kVec4f_GrVertexAttribType, kHigh_GrSLPrecision); + this->addVertexAttrib("shapeMatrixX", kFloat3_GrVertexAttribType); + this->addVertexAttrib("shapeMatrixY", kFloat3_GrVertexAttribType); + this->addVertexAttrib("color", kHalf4_GrVertexAttribType); + this->addVertexAttrib("localRect", kFloat4_GrVertexAttribType); GR_STATIC_ASSERT(0 == (int)Attrib::kShapeCoords); GR_STATIC_ASSERT(1 == (int)Attrib::kVertexAttrs); diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 03dabe3b83..292f59420a 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -636,9 +636,9 @@ private: QuadEdgeEffect(const SkMatrix& localMatrix, bool usesLocalCoords) : fLocalMatrix(localMatrix), fUsesLocalCoords(usesLocalCoords) { this->initClassID<QuadEdgeEffect>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInQuadEdge = &this->addVertexAttrib("inQuadEdge", kVec4f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInQuadEdge = &this->addVertexAttrib("inQuadEdge", kHalf4_GrVertexAttribType); } const Attribute* fInPosition; diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 0d8ef94413..8090f43d00 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -983,9 +983,9 @@ DashingCircleEffect::DashingCircleEffect(GrColor color, , fUsesLocalCoords(usesLocalCoords) , fAAMode(aaMode) { this->initClassID<DashingCircleEffect>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType); - fInDashParams = &this->addVertexAttrib("inDashParams", kVec3f_GrVertexAttribType); - fInCircleParams = &this->addVertexAttrib("inCircleParams", kVec2f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInDashParams = &this->addVertexAttrib("inDashParams", kHalf3_GrVertexAttribType); + fInCircleParams = &this->addVertexAttrib("inCircleParams", kHalf2_GrVertexAttribType); } GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingCircleEffect); @@ -1205,9 +1205,9 @@ DashingLineEffect::DashingLineEffect(GrColor color, , fUsesLocalCoords(usesLocalCoords) , fAAMode(aaMode) { this->initClassID<DashingLineEffect>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType); - fInDashParams = &this->addVertexAttrib("inDashParams", kVec3f_GrVertexAttribType); - fInRectParams = &this->addVertexAttrib("inRect", kVec4f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInDashParams = &this->addVertexAttrib("inDashParams", kHalf3_GrVertexAttribType); + fInRectParams = &this->addVertexAttrib("inRect", kHalf4_GrVertexAttribType); } GR_DEFINE_GEOMETRY_PROCESSOR_TEST(DashingLineEffect); diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp index c29fe12a7a..5c46563316 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.cpp +++ b/src/gpu/ops/GrMSAAPathRenderer.cpp @@ -199,10 +199,9 @@ private: MSAAQuadProcessor(const SkMatrix& viewMatrix) : fViewMatrix(viewMatrix) { this->initClassID<MSAAQuadProcessor>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInUV = &this->addVertexAttrib("inUV", kVec2f_GrVertexAttribType, kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInUV = &this->addVertexAttrib("inUV", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); this->setSampleShading(1.0f); } diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index 89e3afb3dd..b29ecf7ee9 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -70,23 +70,21 @@ public: const SkMatrix& localMatrix) : fLocalMatrix(localMatrix) { this->initClassID<CircleGeometryProcessor>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInCircleEdge = &this->addVertexAttrib("inCircleEdge", kVec4f_GrVertexAttribType, - kHigh_GrSLPrecision); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInCircleEdge = &this->addVertexAttrib("inCircleEdge", kFloat4_GrVertexAttribType); if (clipPlane) { - fInClipPlane = &this->addVertexAttrib("inClipPlane", kVec3f_GrVertexAttribType); + fInClipPlane = &this->addVertexAttrib("inClipPlane", kHalf3_GrVertexAttribType); } else { fInClipPlane = nullptr; } if (isectPlane) { - fInIsectPlane = &this->addVertexAttrib("inIsectPlane", kVec3f_GrVertexAttribType); + fInIsectPlane = &this->addVertexAttrib("inIsectPlane", kHalf3_GrVertexAttribType); } else { fInIsectPlane = nullptr; } if (unionPlane) { - fInUnionPlane = &this->addVertexAttrib("inUnionPlane", kVec3f_GrVertexAttribType); + fInUnionPlane = &this->addVertexAttrib("inUnionPlane", kHalf3_GrVertexAttribType); } else { fInUnionPlane = nullptr; } @@ -242,10 +240,10 @@ class EllipseGeometryProcessor : public GrGeometryProcessor { public: EllipseGeometryProcessor(bool stroke, const SkMatrix& localMatrix) : fLocalMatrix(localMatrix) { this->initClassID<EllipseGeometryProcessor>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInEllipseOffset = &this->addVertexAttrib("inEllipseOffset", kVec2f_GrVertexAttribType); - fInEllipseRadii = &this->addVertexAttrib("inEllipseRadii", kVec4f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInEllipseOffset = &this->addVertexAttrib("inEllipseOffset", kHalf2_GrVertexAttribType); + fInEllipseRadii = &this->addVertexAttrib("inEllipseRadii", kHalf4_GrVertexAttribType); fStroke = stroke; } @@ -383,11 +381,10 @@ public: DIEllipseGeometryProcessor(const SkMatrix& viewMatrix, DIEllipseStyle style) : fViewMatrix(viewMatrix) { this->initClassID<DIEllipseGeometryProcessor>(); - fInPosition = &this->addVertexAttrib("inPosition", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fInColor = &this->addVertexAttrib("inColor", kVec4ub_GrVertexAttribType); - fInEllipseOffsets0 = &this->addVertexAttrib("inEllipseOffsets0", kVec2f_GrVertexAttribType); - fInEllipseOffsets1 = &this->addVertexAttrib("inEllipseOffsets1", kVec2f_GrVertexAttribType); + fInPosition = &this->addVertexAttrib("inPosition", kFloat2_GrVertexAttribType); + fInColor = &this->addVertexAttrib("inColor", kUByte4_norm_GrVertexAttribType); + fInEllipseOffsets0 = &this->addVertexAttrib("inEllipseOffsets0", kHalf2_GrVertexAttribType); + fInEllipseOffsets1 = &this->addVertexAttrib("inEllipseOffsets1", kHalf2_GrVertexAttribType); fStyle = style; } diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp index 724d26b981..7ef7757939 100644 --- a/src/gpu/ops/GrTextureOp.cpp +++ b/src/gpu/ops/GrTextureOp.cpp @@ -177,8 +177,7 @@ private: : fColorSpaceXform(std::move(csxf)) { SkASSERT(proxyCnt > 0 && samplerCnt >= proxyCnt); this->initClassID<TextureGeometryProcessor>(); - fPositions = - this->addVertexAttrib("position", kVec2f_GrVertexAttribType, kHigh_GrSLPrecision); + fPositions = this->addVertexAttrib("position", kFloat2_GrVertexAttribType); fSamplers[0].reset(std::move(proxies[0]), filters[0]); this->addTextureSampler(&fSamplers[0]); for (int i = 1; i < proxyCnt; ++i) { @@ -199,9 +198,8 @@ private: fTextureIdx = this->addVertexAttrib("textureIdx", kInt_GrVertexAttribType); } - fTextureCoords = this->addVertexAttrib("textureCoords", kVec2f_GrVertexAttribType, - kHigh_GrSLPrecision); - fColors = this->addVertexAttrib("color", kVec4ub_GrVertexAttribType); + fTextureCoords = this->addVertexAttrib("textureCoords", kFloat2_GrVertexAttribType); + fColors = this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType); } Attribute fPositions; diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp index 11dd982fda..ba64532c4e 100644 --- a/src/gpu/vk/GrVkPipeline.cpp +++ b/src/gpu/vk/GrVkPipeline.cpp @@ -17,26 +17,30 @@ static inline VkFormat attrib_type_to_vkformat(GrVertexAttribType type) { switch (type) { case kFloat_GrVertexAttribType: + case kHalf_GrVertexAttribType: return VK_FORMAT_R32_SFLOAT; - case kVec2f_GrVertexAttribType: + case kFloat2_GrVertexAttribType: + case kHalf2_GrVertexAttribType: return VK_FORMAT_R32G32_SFLOAT; - case kVec3f_GrVertexAttribType: + case kFloat3_GrVertexAttribType: + case kHalf3_GrVertexAttribType: return VK_FORMAT_R32G32B32_SFLOAT; - case kVec4f_GrVertexAttribType: + case kFloat4_GrVertexAttribType: + case kHalf4_GrVertexAttribType: return VK_FORMAT_R32G32B32A32_SFLOAT; - case kVec2i_GrVertexAttribType: + case kInt2_GrVertexAttribType: return VK_FORMAT_R32G32_SINT; - case kVec3i_GrVertexAttribType: + case kInt3_GrVertexAttribType: return VK_FORMAT_R32G32B32_SINT; - case kVec4i_GrVertexAttribType: + case kInt4_GrVertexAttribType: return VK_FORMAT_R32G32B32A32_SINT; - case kUByte_GrVertexAttribType: + case kUByte_norm_GrVertexAttribType: return VK_FORMAT_R8_UNORM; - case kVec4ub_GrVertexAttribType: + case kUByte4_norm_GrVertexAttribType: return VK_FORMAT_R8G8B8A8_UNORM; - case kVec2us_norm_GrVertexAttribType: + case kUShort2_norm_GrVertexAttribType: return VK_FORMAT_R16G16_UNORM; - case kVec2us_uint_GrVertexAttribType: + case kUShort2_GrVertexAttribType: return VK_FORMAT_R16G16_UINT; case kInt_GrVertexAttribType: return VK_FORMAT_R32_SINT; diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index 223138b4ce..1ae3926699 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -285,14 +285,14 @@ public: , fVertex(nullptr) , fColor(nullptr) { if (instanced) { - fInstanceLocation = &this->addInstanceAttrib("location", kVec2f_GrVertexAttribType); + fInstanceLocation = &this->addInstanceAttrib("location", kHalf2_GrVertexAttribType); if (hasVertexBuffer) { - fVertex = &this->addVertexAttrib("vertex", kVec2f_GrVertexAttribType); + fVertex = &this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType); } - fColor = &this->addInstanceAttrib("color", kVec4ub_GrVertexAttribType); + fColor = &this->addInstanceAttrib("color", kUByte4_norm_GrVertexAttribType); } else { - fVertex = &this->addVertexAttrib("vertex", kVec2f_GrVertexAttribType); - fColor = &this->addVertexAttrib("color", kVec4ub_GrVertexAttribType); + fVertex = &this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType); + fColor = &this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType); } this->initClassID<GrMeshTestProcessor>(); } diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index 475f8f37e5..4b8621db04 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -59,8 +59,8 @@ struct Vertex { class GrPipelineDynamicStateTestProcessor : public GrGeometryProcessor { public: GrPipelineDynamicStateTestProcessor() - : fVertex(this->addVertexAttrib("vertex", kVec2f_GrVertexAttribType)) - , fColor(this->addVertexAttrib("color", kVec4ub_GrVertexAttribType)) { + : fVertex(this->addVertexAttrib("vertex", kHalf2_GrVertexAttribType)) + , fColor(this->addVertexAttrib("color", kUByte4_norm_GrVertexAttribType)) { this->initClassID<GrPipelineDynamicStateTestProcessor>(); } diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 6402020458..8898e35266 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -60,7 +60,7 @@ private: fAttribNames.push_back().printf("attr%d", i); } for (auto i = 0; i < numAttribs; ++i) { - this->addVertexAttrib(fAttribNames[i].c_str(), kVec2f_GrVertexAttribType); + this->addVertexAttrib(fAttribNames[i].c_str(), kFloat2_GrVertexAttribType); } } const char* name() const override { return "Dummy GP"; } |