Remove hacks for UShort2 texture coords
Plumb GPU type down for binding of vertex attributes in GL. Use that
to select between float and int versions of VertexAttribPointer.
For client code that was relying on the strange behavior of UShort2,
use shader caps to pick the appropriate GrSLType.
Bug: skia:
Change-Id: If52ea49e0a5667246687e90e088d0823dbedb921
Reviewed-on: https://skia-review.googlesource.com/155401
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index 2f65ed5..4646adc 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -76,70 +76,11 @@
return {false, 0, 0};
};
-static bool GrVertexAttribTypeIsIntType(const GrShaderCaps* shaderCaps,
- GrVertexAttribType type) {
- switch (type) {
- case kFloat_GrVertexAttribType:
- return false;
- 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 kHalf3_GrVertexAttribType:
- return false;
- case kHalf4_GrVertexAttribType:
- return false;
- case kInt2_GrVertexAttribType:
- return true;
- case kInt3_GrVertexAttribType:
- return true;
- case kInt4_GrVertexAttribType:
- return true;
- case kByte_GrVertexAttribType:
- return true;
- case kByte2_GrVertexAttribType:
- return true;
- case kByte3_GrVertexAttribType:
- return true;
- case kByte4_GrVertexAttribType:
- return true;
- case kUByte_GrVertexAttribType:
- return true;
- case kUByte2_GrVertexAttribType:
- return true;
- case kUByte3_GrVertexAttribType:
- return true;
- case kUByte4_GrVertexAttribType:
- return true;
- case kUByte_norm_GrVertexAttribType:
- return false;
- case kUByte4_norm_GrVertexAttribType:
- return false;
- case kShort2_GrVertexAttribType:
- return true;
- case kUShort2_GrVertexAttribType:
- return shaderCaps->integerSupport(); // FIXME: caller should handle this.
- case kUShort2_norm_GrVertexAttribType:
- return false;
- case kInt_GrVertexAttribType:
- return true;
- case kUint_GrVertexAttribType:
- return true;
- }
- SK_ABORT("Unexpected attribute type");
- return false;
-}
-
void GrGLAttribArrayState::set(GrGLGpu* gpu,
int index,
const GrBuffer* vertexBuffer,
- GrVertexAttribType type,
+ GrVertexAttribType cpuType,
+ GrSLType gpuType,
GrGLsizei stride,
size_t offsetInBytes,
int divisor) {
@@ -147,13 +88,14 @@
SkASSERT(0 == divisor || gpu->caps()->instanceAttribSupport());
AttribArrayState* array = &fAttribArrayStates[index];
if (array->fVertexBufferUniqueID != vertexBuffer->uniqueID() ||
- array->fType != type ||
+ array->fCPUType != cpuType ||
+ array->fGPUType != gpuType ||
array->fStride != stride ||
array->fOffset != offsetInBytes) {
gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
- const AttribLayout& layout = attrib_layout(type);
+ const AttribLayout& layout = attrib_layout(cpuType);
const GrGLvoid* offsetAsPtr = reinterpret_cast<const GrGLvoid*>(offsetInBytes);
- if (!GrVertexAttribTypeIsIntType(gpu->caps()->shaderCaps(), type)) {
+ if (GrSLTypeIsFloatType(gpuType)) {
GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
layout.fCount,
layout.fType,
@@ -170,7 +112,8 @@
offsetAsPtr));
}
array->fVertexBufferUniqueID = vertexBuffer->uniqueID();
- array->fType = type;
+ array->fCPUType = cpuType;
+ array->fGPUType = gpuType;
array->fStride = stride;
array->fOffset = offsetInBytes;
}