Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Unified Diff: src/gpu/gl/GrGLVertexArray.cpp

Issue 1669853002: Improve GLSL integer support (Closed) Base URL: https://skia.googlesource.com/skia.git@uploat_dratindirect
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/gl/SkNullGLContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLVertexArray.cpp
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index 8cfa8d655050fa5b69e453970c035e6af7d534fe..2048e2c58f30fc99f7049e87cfb5e2df39b6797c 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -8,14 +8,38 @@
#include "GrGLVertexArray.h"
#include "GrGLGpu.h"
+struct AttribLayout {
+ GrGLint fCount;
+ GrGLenum fType;
+ GrGLboolean fNormalized; // Only used by floating point types.
+};
+static const AttribLayout gLayouts[kGrVertexAttribTypeCount] = {
+ {1, GR_GL_FLOAT, false}, // kFloat_GrVertexAttribType
+ {2, GR_GL_FLOAT, false}, // kVec2f_GrVertexAttribType
+ {3, GR_GL_FLOAT, false}, // kVec3f_GrVertexAttribType
+ {4, GR_GL_FLOAT, false}, // kVec4f_GrVertexAttribType
+ {1, GR_GL_UNSIGNED_BYTE, true}, // kUByte_GrVertexAttribType
+ {4, GR_GL_UNSIGNED_BYTE, true}, // kVec4ub_GrVertexAttribType
+ {2, GR_GL_SHORT, false}, // kVec2s_GrVertexAttribType
+ {1, GR_GL_INT, false}, // kInt_GrVertexAttribType
+ {1, GR_GL_UNSIGNED_INT, false}, // kUint_GrVertexAttribType
+};
+
+GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
+GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
+GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
+GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
+GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
+GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
+GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
+GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
+GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
void GrGLAttribArrayState::set(GrGLGpu* gpu,
int index,
GrGLuint vertexBufferID,
- GrGLint size,
- GrGLenum type,
- GrGLboolean normalized,
+ GrVertexAttribType type,
GrGLsizei stride,
GrGLvoid* offset) {
SkASSERT(index >= 0 && index < fAttribArrayStates.count());
@@ -27,22 +51,31 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
}
if (!array->fAttribPointerIsValid ||
array->fVertexBufferID != vertexBufferID ||
- array->fSize != size ||
- array->fNormalized != normalized ||
+ array->fType != type ||
array->fStride != stride ||
array->fOffset != offset) {
gpu->bindVertexBuffer(vertexBufferID);
- GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
- size,
- type,
- normalized,
- stride,
- offset));
+ const AttribLayout& layout = gLayouts[type];
+ if (!GrVertexAttribTypeIsIntType(type)) {
+ GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
+ layout.fCount,
+ layout.fType,
+ layout.fNormalized,
+ stride,
+ offset));
+ } else {
+ SkASSERT(gpu->caps()->shaderCaps()->integerSupport());
+ SkASSERT(!layout.fNormalized);
+ GR_GL_CALL(gpu->glInterface(), VertexAttribIPointer(index,
+ layout.fCount,
+ layout.fType,
+ stride,
+ offset));
+ }
array->fAttribPointerIsValid = true;
array->fVertexBufferID = vertexBufferID;
- array->fSize = size;
- array->fNormalized = normalized;
+ array->fType = type;
array->fStride = stride;
array->fOffset = offset;
}
« no previous file with comments | « src/gpu/gl/GrGLVertexArray.h ('k') | src/gpu/gl/SkNullGLContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698