aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLVertexArray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl/GrGLVertexArray.cpp')
-rw-r--r--src/gpu/gl/GrGLVertexArray.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index 807b9d091b..74e609e9b8 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -53,27 +53,23 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
const GrBuffer* vertexBuffer,
GrVertexAttribType type,
GrGLsizei stride,
- GrGLvoid* offset) {
+ size_t offsetInBytes) {
SkASSERT(index >= 0 && index < fAttribArrayStates.count());
AttribArrayState* array = &fAttribArrayStates[index];
- if (!array->fEnableIsValid || !array->fEnabled) {
- GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(index));
- array->fEnableIsValid = true;
- array->fEnabled = true;
- }
if (array->fVertexBufferUniqueID != vertexBuffer->uniqueID() ||
array->fType != type ||
array->fStride != stride ||
- array->fOffset != offset) {
+ array->fOffset != offsetInBytes) {
gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
const AttribLayout& layout = attrib_layout(type);
+ const GrGLvoid* offsetAsPtr = reinterpret_cast<const GrGLvoid*>(offsetInBytes);
if (!GrVertexAttribTypeIsIntType(type)) {
GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
layout.fCount,
layout.fType,
layout.fNormalized,
stride,
- offset));
+ offsetAsPtr));
} else {
SkASSERT(gpu->caps()->shaderCaps()->integerSupport());
SkASSERT(!layout.fNormalized);
@@ -81,30 +77,30 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
layout.fCount,
layout.fType,
stride,
- offset));
+ offsetAsPtr));
}
array->fVertexBufferUniqueID = vertexBuffer->uniqueID();
array->fType = type;
array->fStride = stride;
- array->fOffset = offset;
+ array->fOffset = offsetInBytes;
}
}
-void GrGLAttribArrayState::disableUnusedArrays(const GrGLGpu* gpu, uint64_t usedMask) {
- int count = fAttribArrayStates.count();
- for (int i = 0; i < count; ++i) {
- if (!(usedMask & 0x1)) {
- if (!fAttribArrayStates[i].fEnableIsValid || fAttribArrayStates[i].fEnabled) {
- GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i));
- fAttribArrayStates[i].fEnableIsValid = true;
- fAttribArrayStates[i].fEnabled = false;
- }
- } else {
- SkASSERT(fAttribArrayStates[i].fEnableIsValid && fAttribArrayStates[i].fEnabled);
- }
- // if the count is greater than 64 then this will become 0 and we will disable arrays 64+.
- usedMask >>= 1;
+void GrGLAttribArrayState::enableVertexArrays(const GrGLGpu* gpu, int enabledCount) {
+ SkASSERT(enabledCount <= fAttribArrayStates.count());
+
+ int firstIdxToEnable = fEnabledCountIsValid ? fNumEnabledArrays : 0;
+ for (int i = firstIdxToEnable; i < enabledCount; ++i) {
+ GR_GL_CALL(gpu->glInterface(), EnableVertexAttribArray(i));
}
+
+ int endIdxToDisable = fEnabledCountIsValid ? fNumEnabledArrays : fAttribArrayStates.count();
+ for (int i = enabledCount; i < endIdxToDisable; ++i) {
+ GR_GL_CALL(gpu->glInterface(), DisableVertexAttribArray(i));
+ }
+
+ fNumEnabledArrays = enabledCount;
+ fEnabledCountIsValid = true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////