aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar csmartdalton <csmartdalton@google.com>2017-02-08 14:56:27 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-08 21:37:22 +0000
commitb37cb236c3a698b45a7d0deca0df32bb70bbaaa6 (patch)
treecc59d0b58445468be23612004fd953a6333ab433 /src/gpu
parent119fb2b9505aea87900d2cf5cf3573814bcae08c (diff)
Add integer vectors to GrSLType
BUG=skia: Change-Id: I4a4a50e214f2240d83f6f0b02cf43e695c067933 Reviewed-on: https://skia-review.googlesource.com/8122 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/gl/GrGLVertexArray.cpp59
-rw-r--r--src/gpu/vk/GrVkPipeline.cpp49
-rw-r--r--src/gpu/vk/GrVkUniformHandler.cpp16
-rw-r--r--src/gpu/vk/GrVkVaryingHandler.cpp6
4 files changed, 84 insertions, 46 deletions
diff --git a/src/gpu/gl/GrGLVertexArray.cpp b/src/gpu/gl/GrGLVertexArray.cpp
index e03101a564..807b9d091b 100644
--- a/src/gpu/gl/GrGLVertexArray.cpp
+++ b/src/gpu/gl/GrGLVertexArray.cpp
@@ -10,32 +10,43 @@
#include "GrGLGpu.h"
struct AttribLayout {
- GrGLint fCount;
- GrGLenum fType;
- GrGLboolean fNormalized; // Only used by floating point types.
+ bool fNormalized; // Only used by floating point types.
+ uint8_t fCount;
+ uint16_t fType;
};
-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_UNSIGNED_SHORT, true}, // kVec2s_GrVertexAttribType
- {1, GR_GL_INT, false}, // kInt_GrVertexAttribType
- {1, GR_GL_UNSIGNED_INT, false}, // kUint_GrVertexAttribType
-};
+GR_STATIC_ASSERT(4 == sizeof(AttribLayout));
-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 == kVec2us_GrVertexAttribType);
-GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
-GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
+static AttribLayout attrib_layout(GrVertexAttribType type) {
+ switch (type) {
+ case kFloat_GrVertexAttribType:
+ return {false, 1, GR_GL_FLOAT};
+ case kVec2f_GrVertexAttribType:
+ return {false, 2, GR_GL_FLOAT};
+ case kVec3f_GrVertexAttribType:
+ return {false, 3, GR_GL_FLOAT};
+ case kVec4f_GrVertexAttribType:
+ return {false, 4, GR_GL_FLOAT};
+ case kVec2i_GrVertexAttribType:
+ return {false, 2, GR_GL_INT};
+ case kVec3i_GrVertexAttribType:
+ return {false, 3, GR_GL_INT};
+ case kVec4i_GrVertexAttribType:
+ return {false, 4, GR_GL_INT};
+ case kUByte_GrVertexAttribType:
+ return {true, 1, GR_GL_UNSIGNED_BYTE};
+ case kVec4ub_GrVertexAttribType:
+ return {true, 4, GR_GL_UNSIGNED_BYTE};
+ case kVec2us_GrVertexAttribType:
+ return {true, 2, GR_GL_UNSIGNED_SHORT};
+ case kInt_GrVertexAttribType:
+ return {false, 1, GR_GL_INT};
+ case kUint_GrVertexAttribType:
+ return {false, 1, GR_GL_UNSIGNED_INT};
+ }
+ SkFAIL("Unknown vertex attrib type");
+ return {false, 0, 0};
+};
void GrGLAttribArrayState::set(GrGLGpu* gpu,
int index,
@@ -55,7 +66,7 @@ void GrGLAttribArrayState::set(GrGLGpu* gpu,
array->fStride != stride ||
array->fOffset != offset) {
gpu->bindBuffer(kVertex_GrBufferType, vertexBuffer);
- const AttribLayout& layout = gLayouts[type];
+ const AttribLayout& layout = attrib_layout(type);
if (!GrVertexAttribTypeIsIntType(type)) {
GR_GL_CALL(gpu->glInterface(), VertexAttribPointer(index,
layout.fCount,
diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp
index 40a6cf07a9..7c0aeb4b15 100644
--- a/src/gpu/vk/GrVkPipeline.cpp
+++ b/src/gpu/vk/GrVkPipeline.cpp
@@ -14,26 +14,35 @@
#include "GrVkRenderTarget.h"
#include "GrVkUtil.h"
-static inline const VkFormat& attrib_type_to_vkformat(GrVertexAttribType type) {
- SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
- static const VkFormat kFormats[kGrVertexAttribTypeCount] = {
- VK_FORMAT_R32_SFLOAT, // kFloat_GrVertexAttribType
- VK_FORMAT_R32G32_SFLOAT, // kVec2f_GrVertexAttribType
- VK_FORMAT_R32G32B32_SFLOAT, // kVec3f_GrVertexAttribType
- VK_FORMAT_R32G32B32A32_SFLOAT, // kVec4f_GrVertexAttribType
- VK_FORMAT_R8_UNORM, // kUByte_GrVertexAttribType
- VK_FORMAT_R8G8B8A8_UNORM, // kVec4ub_GrVertexAttribType
- VK_FORMAT_R16G16_UNORM, // kVec2us_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 == kVec2us_GrVertexAttribType);
- GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFormats) == kGrVertexAttribTypeCount);
- return kFormats[type];
+static inline VkFormat attrib_type_to_vkformat(GrVertexAttribType type) {
+ switch (type) {
+ case kFloat_GrVertexAttribType:
+ return VK_FORMAT_R32_SFLOAT;
+ case kVec2f_GrVertexAttribType:
+ return VK_FORMAT_R32G32_SFLOAT;
+ case kVec3f_GrVertexAttribType:
+ return VK_FORMAT_R32G32B32_SFLOAT;
+ case kVec4f_GrVertexAttribType:
+ return VK_FORMAT_R32G32B32A32_SFLOAT;
+ case kVec2i_GrVertexAttribType:
+ return VK_FORMAT_R32G32_SINT;
+ case kVec3i_GrVertexAttribType:
+ return VK_FORMAT_R32G32B32_SINT;
+ case kVec4i_GrVertexAttribType:
+ return VK_FORMAT_R32G32B32A32_SINT;
+ case kUByte_GrVertexAttribType:
+ return VK_FORMAT_R8_UNORM;
+ case kVec4ub_GrVertexAttribType:
+ return VK_FORMAT_R8G8B8A8_UNORM;
+ case kVec2us_GrVertexAttribType:
+ return VK_FORMAT_R16G16_UNORM;
+ case kInt_GrVertexAttribType:
+ return VK_FORMAT_R32_SINT;
+ case kUint_GrVertexAttribType:
+ return VK_FORMAT_R32_UINT;
+ }
+ SkFAIL("Unknown vertex attrib type");
+ return VK_FORMAT_UNDEFINED;
}
static void setup_vertex_input_state(const GrPrimitiveProcessor& primProc,
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index f0f0fff7a6..f69c9d16f9 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -28,6 +28,12 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
return 0xF;
case kVec4f_GrSLType:
return 0xF;
+ case kVec2i_GrSLType:
+ return 0x7;
+ case kVec3i_GrSLType:
+ return 0xF;
+ case kVec4i_GrSLType:
+ return 0xF;
case kMat22f_GrSLType:
return 0x7;
case kMat33f_GrSLType:
@@ -59,9 +65,9 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
static inline uint32_t grsltype_to_vk_size(GrSLType type) {
switch(type) {
case kInt_GrSLType:
- return 4;
+ return sizeof(int32_t);
case kUint_GrSLType:
- return 4;
+ return sizeof(int32_t);
case kFloat_GrSLType:
return sizeof(float);
case kVec2f_GrSLType:
@@ -70,6 +76,12 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) {
return 3 * sizeof(float);
case kVec4f_GrSLType:
return 4 * sizeof(float);
+ case kVec2i_GrSLType:
+ return 2 * sizeof(int32_t);
+ case kVec3i_GrSLType:
+ return 3 * sizeof(int32_t);
+ case kVec4i_GrSLType:
+ return 4 * sizeof(int32_t);
case kMat22f_GrSLType:
//TODO: this will be 4 * szof(float) on std430.
return 8 * sizeof(float);
diff --git a/src/gpu/vk/GrVkVaryingHandler.cpp b/src/gpu/vk/GrVkVaryingHandler.cpp
index d7d08c9622..d936e2bd1a 100644
--- a/src/gpu/vk/GrVkVaryingHandler.cpp
+++ b/src/gpu/vk/GrVkVaryingHandler.cpp
@@ -21,6 +21,12 @@ static inline int grsltype_to_location_size(GrSLType type) {
return 1;
case kVec4f_GrSLType:
return 1;
+ case kVec2i_GrSLType:
+ return 1;
+ case kVec3i_GrSLType:
+ return 1;
+ case kVec4i_GrSLType:
+ return 1;
case kMat22f_GrSLType:
return 2;
case kMat33f_GrSLType: