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/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