aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-07-13 14:09:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-13 14:09:31 -0700
commit990dbc88796f656418bcc4c196df30ed9bef6345 (patch)
tree8ce14a655fd0e98363e5eb7a895ee79516012927 /include
parente5de130788c8637d2f7df9ddb0241b78e04d5882 (diff)
Add Texture2D and Sampler GrSLTypes
These two new types are in support of Vulkan and the ability to send separate texture and sampler uniforms to the shader. They don't really fit well in the current system, since the current system ties together to idea of intended use and how to emit shader code into the same GrSLType enum. In vulkan, I want the GrGLSLSampler object to be used as a Sampler2D, but when appending its declaration it will emit a Texture2D and sampler object. Our query for GrSLTypeIsSamplerType refers more to the combination of texture and sampler and not just the sampler part. The GrSLTypeIs2DTextureType query is for is a a SamplerType that uses Texture2Ds. My new types don't really fit into either these categories as they are just half of the whole. In some refactoring down the road (possibly connected with SkSL), I suggest we split apart the concept of how we intend to use a GrGLSLSampler (Sampler2D, SamplerBuffer, etc.), from how we actually add it to the code (sampler, texture2D, sampler2D, etc.). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2143143002 Review-Url: https://codereview.chromium.org/2143143002
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrTypesPriv.h98
1 files changed, 55 insertions, 43 deletions
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index 8c7d6bda65..5168ac91a1 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -25,15 +25,17 @@ enum GrSLType {
kMat22f_GrSLType,
kMat33f_GrSLType,
kMat44f_GrSLType,
- kSampler2D_GrSLType,
- kSamplerExternal_GrSLType,
- kSampler2DRect_GrSLType,
- kSamplerBuffer_GrSLType,
+ kTexture2DSampler_GrSLType,
+ kTextureExternalSampler_GrSLType,
+ kTexture2DRectSampler_GrSLType,
+ kTextureBufferSampler_GrSLType,
kBool_GrSLType,
kInt_GrSLType,
kUint_GrSLType,
+ kTexture2D_GrSLType,
+ kSampler_GrSLType,
- kLast_GrSLType = kUint_GrSLType
+ kLast_GrSLType = kSampler_GrSLType
};
static const int kGrSLTypeCount = kLast_GrSLType + 1;
@@ -78,7 +80,7 @@ static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
*/
static inline int GrSLTypeVectorCount(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
- static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1 };
+ static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1 };
return kCounts[type];
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
@@ -89,13 +91,15 @@ static inline int GrSLTypeVectorCount(GrSLType type) {
GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTextureBufferSampler_GrSLType);
GR_STATIC_ASSERT(12 == kBool_GrSLType);
GR_STATIC_ASSERT(13 == kInt_GrSLType);
GR_STATIC_ASSERT(14 == kUint_GrSLType);
+ GR_STATIC_ASSERT(15 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(16 == kSampler_GrSLType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
}
@@ -124,20 +128,22 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) {
GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTextureBufferSampler_GrSLType);
GR_STATIC_ASSERT(12 == kBool_GrSLType);
GR_STATIC_ASSERT(13 == kInt_GrSLType);
GR_STATIC_ASSERT(14 == kUint_GrSLType);
- GR_STATIC_ASSERT(15 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(15 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(16 == kSampler_GrSLType);
+ GR_STATIC_ASSERT(17 == kGrSLTypeCount);
}
/** Is the shading language type integral (including vectors/matrices)? */
static inline bool GrSLTypeIsIntType(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
- return type >= kInt_GrSLType;
+ return type >= kInt_GrSLType && type <= kUint_GrSLType;
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
GR_STATIC_ASSERT(1 == kFloat_GrSLType);
@@ -147,14 +153,16 @@ static inline bool GrSLTypeIsIntType(GrSLType type) {
GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTextureBufferSampler_GrSLType);
GR_STATIC_ASSERT(12 == kBool_GrSLType);
GR_STATIC_ASSERT(13 == kInt_GrSLType);
GR_STATIC_ASSERT(14 == kUint_GrSLType);
- GR_STATIC_ASSERT(15 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(15 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(16 == kSampler_GrSLType);
+ GR_STATIC_ASSERT(17 == kGrSLTypeCount);
}
/** Is the shading language type numeric (including vectors/matrices)? */
@@ -174,13 +182,15 @@ static inline size_t GrSLTypeSize(GrSLType type) {
2 * 2 * sizeof(float), // kMat22f_GrSLType
3 * 3 * sizeof(float), // kMat33f_GrSLType
4 * 4 * sizeof(float), // kMat44f_GrSLType
- 0, // kSampler2D_GrSLType
- 0, // kSamplerExternal_GrSLType
- 0, // kSampler2DRect_GrSLType
- 0, // kSamplerBuffer_GrSLType
+ 0, // kTexture2DSampler_GrSLType
+ 0, // kTextureExternalSampler_GrSLType
+ 0, // kTexture2DRectSampler_GrSLType
+ 0, // kTextureBufferSampler_GrSLType
0, // kBool_GrSLType
0, // kInt_GrSLType
0, // kUint_GrSLType
+ 0, // kTexture2D_GrSLType
+ 0, // kSampler_GrSLType
};
return kSizes[type];
@@ -192,37 +202,39 @@ static inline size_t GrSLTypeSize(GrSLType type) {
GR_STATIC_ASSERT(5 == kMat22f_GrSLType);
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_GrSLType);
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTextureBufferSampler_GrSLType);
GR_STATIC_ASSERT(12 == kBool_GrSLType);
GR_STATIC_ASSERT(13 == kInt_GrSLType);
GR_STATIC_ASSERT(14 == kUint_GrSLType);
- GR_STATIC_ASSERT(15 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(15 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(16 == kSampler_GrSLType);
+ GR_STATIC_ASSERT(17 == kGrSLTypeCount);
}
-static inline bool GrSLTypeIs2DTextureType(GrSLType type) {
+static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
- return type >= kSampler2D_GrSLType && type <= kSampler2DRect_GrSLType;
+ return type >= kTexture2DSampler_GrSLType && type <= kTexture2DRectSampler_GrSLType;
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
}
-static inline bool GrSLTypeIsSamplerType(GrSLType type) {
+static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
- return type >= kSampler2D_GrSLType && type <= kSamplerBuffer_GrSLType;
+ return type >= kTexture2DSampler_GrSLType && type <= kTextureBufferSampler_GrSLType;
- GR_STATIC_ASSERT(8 == kSampler2D_GrSLType);
- GR_STATIC_ASSERT(9 == kSamplerExternal_GrSLType);
- GR_STATIC_ASSERT(10 == kSampler2DRect_GrSLType);
- GR_STATIC_ASSERT(11 == kSamplerBuffer_GrSLType);
+ GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTextureBufferSampler_GrSLType);
}
static inline bool GrSLTypeAcceptsPrecision(GrSLType type) {
- return GrSLTypeIsNumeric(type) || GrSLTypeIsSamplerType(type);
+ return type != kVoid_GrSLType && type != kBool_GrSLType;
}
//////////////////////////////////////////////////////////////////////////////
@@ -243,7 +255,7 @@ enum GrVertexAttribType {
kInt_GrVertexAttribType,
kUint_GrVertexAttribType,
-
+
kLast_GrVertexAttribType = kUint_GrVertexAttribType
};
static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;