Revert "Revert "Change how vertex/instance attributes are handled in geometry processors.""
This reverts commit 5045e501d2aec23e5f1e4b46346033ac3202c6b0.
TBR=csmartdalton@google.com
Change-Id: Ifbf5f1d8f8ef340fdc69653e931b6d68d4bf0854
Reviewed-on: https://skia-review.googlesource.com/135862
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index 6ea1f2c..ca4eddc 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -10,7 +10,6 @@
#define GrGLProgram_DEFINED
#include "GrGLProgramDataManager.h"
-#include "GrPrimitiveProcessor.h"
#include "glsl/GrGLSLProgramDataManager.h"
#include "glsl/GrGLSLUniformHandler.h"
@@ -35,15 +34,18 @@
*/
struct Attribute {
GrVertexAttribType fType;
- int fOffset;
+ size_t fOffset;
GrGLint fLocation;
- GrPrimitiveProcessor::Attribute::InputRate fInputRate;
};
using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
using UniformInfoArray = GrGLProgramDataManager::UniformInfoArray;
using VaryingInfoArray = GrGLProgramDataManager::VaryingInfoArray;
+ /**
+ * The attribute array consists of vertexAttributeCnt + instanceAttributeCnt elements with
+ * the vertex attributes preceding the instance attributes.
+ */
GrGLProgram(GrGLGpu*,
const GrGLSLBuiltinUniformHandles&,
GrGLuint programID,
@@ -56,7 +58,8 @@
std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fragmentProcessors,
int fragmentProcessorCnt,
std::unique_ptr<Attribute[]>,
- int attributeCnt,
+ int vertexAttributeCnt,
+ int instanceAttributeCnt,
int vertexStride,
int instanceStride);
@@ -124,8 +127,17 @@
int vertexStride() const { return fVertexStride; }
int instanceStride() const { return fInstanceStride; }
- int numAttributes() const { return fAttributeCnt; }
- const Attribute& attribute(int i) const { return fAttributes[i]; }
+ int numVertexAttributes() const { return fVertexAttributeCnt; }
+ const Attribute& vertexAttribute(int i) const {
+ SkASSERT(i >= 0 && i < fVertexAttributeCnt);
+ return fAttributes[i];
+ }
+
+ int numInstanceAttributes() const { return fInstanceAttributeCnt; }
+ const Attribute& instanceAttribute(int i) const {
+ SkASSERT(i >= 0 && i < fInstanceAttributeCnt);
+ return fAttributes[i + fVertexAttributeCnt];
+ }
private:
// A helper to loop over effects, set the transforms (via subclass) and bind textures
@@ -153,7 +165,8 @@
int fFragmentProcessorCnt;
std::unique_ptr<Attribute[]> fAttributes;
- int fAttributeCnt;
+ int fVertexAttributeCnt;
+ int fInstanceAttributeCnt;
int fVertexStride;
int fInstanceStride;