Add vector GrSLTypes for shorts
Bug: skia: Change-Id: I686950df9f5470b4885823471957c3859cc692ea Reviewed-on: https://skia-review.googlesource.com/63441 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
parent
482ee7dd7d
commit
51ebd6615f
@ -110,7 +110,13 @@ enum GrSLType {
|
||||
kVoid_GrSLType,
|
||||
kBool_GrSLType,
|
||||
kShort_GrSLType,
|
||||
kShort2_GrSLType,
|
||||
kShort3_GrSLType,
|
||||
kShort4_GrSLType,
|
||||
kUShort_GrSLType,
|
||||
kUShort2_GrSLType,
|
||||
kUShort3_GrSLType,
|
||||
kUShort4_GrSLType,
|
||||
kFloat_GrSLType,
|
||||
kFloat2_GrSLType,
|
||||
kFloat3_GrSLType,
|
||||
@ -208,7 +214,13 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) {
|
||||
case kBufferSampler_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kShort_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
case kInt_GrSLType:
|
||||
case kInt2_GrSLType:
|
||||
case kInt3_GrSLType:
|
||||
@ -257,7 +269,13 @@ static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) {
|
||||
case kBufferSampler_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kShort_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
case kTexture2D_GrSLType:
|
||||
case kSampler_GrSLType:
|
||||
case kImageStorage2D_GrSLType:
|
||||
@ -300,7 +318,13 @@ static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
|
||||
case kUint2_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kShort_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
case kTexture2D_GrSLType:
|
||||
case kSampler_GrSLType:
|
||||
case kImageStorage2D_GrSLType:
|
||||
@ -340,7 +364,13 @@ static inline bool GrSLTypeIsImageStorage(GrSLType type) {
|
||||
case kUint2_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kShort_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
case kTexture2D_GrSLType:
|
||||
case kSampler_GrSLType:
|
||||
case kTexture2DSampler_GrSLType:
|
||||
@ -370,7 +400,13 @@ static inline bool GrSLTypeAcceptsPrecision(GrSLType type) {
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kShort_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
case kFloat_GrSLType:
|
||||
case kFloat2_GrSLType:
|
||||
case kFloat3_GrSLType:
|
||||
@ -436,6 +472,12 @@ static inline bool GrSLTypeTemporarilyAcceptsPrecision(GrSLType type) {
|
||||
|
||||
case kVoid_GrSLType:
|
||||
case kBool_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
return false;
|
||||
}
|
||||
SK_ABORT("Unexpected type");
|
||||
@ -526,7 +568,7 @@ static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) {
|
||||
case kUShort2_norm_GrVertexAttribType: // fall through
|
||||
return kFloat2_GrSLType;
|
||||
case kUShort2_GrVertexAttribType:
|
||||
return kUint2_GrSLType;
|
||||
return kUShort2_GrSLType;
|
||||
case kUByte_norm_GrVertexAttribType: // fall through
|
||||
case kFloat_GrVertexAttribType:
|
||||
return kFloat_GrSLType;
|
||||
|
@ -47,12 +47,7 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
|
||||
case kFloat4_GrSLType:
|
||||
return "float4";
|
||||
case kUint2_GrSLType:
|
||||
if (shaderCaps->integerSupport()) {
|
||||
return "uint2";
|
||||
} else {
|
||||
// uint2 (aka uvec2) isn't supported in GLSL ES 1.00/GLSL 1.20
|
||||
return "float2";
|
||||
}
|
||||
return "uint2";
|
||||
case kInt2_GrSLType:
|
||||
return "int2";
|
||||
case kInt3_GrSLType:
|
||||
@ -89,8 +84,27 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) {
|
||||
return "uint";
|
||||
case kShort_GrSLType:
|
||||
return "short";
|
||||
case kShort2_GrSLType:
|
||||
return "short2";
|
||||
case kShort3_GrSLType:
|
||||
return "short3";
|
||||
case kShort4_GrSLType:
|
||||
return "short4";
|
||||
case kUShort_GrSLType:
|
||||
return "ushort";
|
||||
case kUShort2_GrSLType:
|
||||
if (shaderCaps->integerSupport()) {
|
||||
return "ushort2";
|
||||
} else {
|
||||
// uint2 (aka uvec2) isn't supported in GLSL ES 1.00/GLSL 1.20
|
||||
// FIXME: this should be handled by the client code rather than relying on
|
||||
// unconventional ushort2 behavior.
|
||||
return "float2";
|
||||
}
|
||||
case kUShort3_GrSLType:
|
||||
return "ushort3";
|
||||
case kUShort4_GrSLType:
|
||||
return "ushort4";
|
||||
case kTexture2D_GrSLType:
|
||||
return "texture2D";
|
||||
case kSampler_GrSLType:
|
||||
|
@ -14,12 +14,22 @@
|
||||
// This alignment mask will give correct alignments for using the std430 block layout. If you want
|
||||
// the std140 alignment, you can use this, but then make sure if you have an array type it is
|
||||
// aligned to 16 bytes (i.e. has mask of 0xF).
|
||||
// These are designated in the Vulkan spec, section 14.5.4 "Offset and Stride Assignment".
|
||||
// https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#interfaces-resources-layout
|
||||
uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
switch(type) {
|
||||
case kShort_GrSLType: // fall through
|
||||
case kInt_GrSLType:
|
||||
case kUShort_GrSLType:
|
||||
return 0x1;
|
||||
case kShort2_GrSLType: // fall through
|
||||
case kUShort2_GrSLType:
|
||||
return 0x3;
|
||||
case kUShort_GrSLType: // fall through
|
||||
case kShort3_GrSLType: // fall through
|
||||
case kShort4_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
return 0x7;
|
||||
case kInt_GrSLType:
|
||||
case kUint_GrSLType:
|
||||
return 0x3;
|
||||
case kHalf_GrSLType: // fall through
|
||||
@ -35,7 +45,7 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
case kFloat4_GrSLType:
|
||||
return 0xF;
|
||||
case kUint2_GrSLType:
|
||||
return 0x3;
|
||||
return 0x7;
|
||||
case kInt2_GrSLType:
|
||||
return 0x7;
|
||||
case kInt3_GrSLType:
|
||||
@ -70,15 +80,27 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Returns the size in bytes taken up in vulkanbuffers for floating point GrSLTypes.
|
||||
For non floating point type returns 0. Currently this reflects the std140 alignment
|
||||
so a float2x2 takes up 8 floats. */
|
||||
/** Returns the size in bytes taken up in vulkanbuffers for GrSLTypes. */
|
||||
static inline uint32_t grsltype_to_vk_size(GrSLType type) {
|
||||
switch(type) {
|
||||
case kShort_GrSLType: // fall through
|
||||
case kShort_GrSLType:
|
||||
return sizeof(int16_t);
|
||||
case kShort2_GrSLType:
|
||||
return 2 * sizeof(int16_t);
|
||||
case kShort3_GrSLType:
|
||||
return 3 * sizeof(int16_t);
|
||||
case kShort4_GrSLType:
|
||||
return 4 * sizeof(int16_t);
|
||||
case kUShort_GrSLType:
|
||||
return sizeof(uint16_t);
|
||||
case kUShort2_GrSLType:
|
||||
return 2 * sizeof(uint16_t);
|
||||
case kUShort3_GrSLType:
|
||||
return 3 * sizeof(uint16_t);
|
||||
case kUShort4_GrSLType:
|
||||
return 4 * sizeof(uint16_t);
|
||||
case kInt_GrSLType:
|
||||
return sizeof(int32_t);
|
||||
case kUShort_GrSLType: // fall through
|
||||
case kUint_GrSLType:
|
||||
return sizeof(int32_t);
|
||||
case kHalf_GrSLType: // fall through
|
||||
@ -94,7 +116,7 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) {
|
||||
case kFloat4_GrSLType:
|
||||
return 4 * sizeof(float);
|
||||
case kUint2_GrSLType:
|
||||
return 2 * sizeof(uint16_t);
|
||||
return 2 * sizeof(uint32_t);
|
||||
case kInt2_GrSLType:
|
||||
return 2 * sizeof(int32_t);
|
||||
case kInt3_GrSLType:
|
||||
|
@ -28,10 +28,16 @@ static inline int grsltype_to_location_size(GrSLType type) {
|
||||
case kUint2_GrSLType:
|
||||
return 1;
|
||||
case kInt2_GrSLType:
|
||||
case kShort2_GrSLType:
|
||||
case kUShort2_GrSLType:
|
||||
return 1;
|
||||
case kInt3_GrSLType:
|
||||
case kShort3_GrSLType:
|
||||
case kUShort3_GrSLType:
|
||||
return 1;
|
||||
case kInt4_GrSLType:
|
||||
case kShort4_GrSLType:
|
||||
case kUShort4_GrSLType:
|
||||
return 1;
|
||||
case kFloat2x2_GrSLType:
|
||||
case kHalf2x2_GrSLType:
|
||||
|
Loading…
Reference in New Issue
Block a user