aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-11-10 11:19:51 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-10 17:13:34 +0000
commit434c534bd0ec08cb355fecfb6d2110197b523e74 (patch)
tree119167b88683157346ab8250bbc553903e046f7f /include
parente13a69baac9dc326510009fa7c0c5966aee9240c (diff)
Add integer texture support.
This allows us to create integer textures and sample them from a GrProcessor's code. Filtering is limited to NEAREST. Adds tests for reading/writing pixels, copying, and drawing. These operations are not allowed to convert to fixed/float configs. Vulkan support is TBD. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4348 Change-Id: If38d89a03285d4bd98d1f14f9638b0320977e43d Reviewed-on: https://skia-review.googlesource.com/4348 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrColor.h16
-rw-r--r--include/gpu/GrTypes.h11
-rw-r--r--include/gpu/GrTypesPriv.h90
3 files changed, 68 insertions, 49 deletions
diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h
index cde9b74cb9..7277f0b21c 100644
--- a/include/gpu/GrColor.h
+++ b/include/gpu/GrColor.h
@@ -295,6 +295,7 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) {
kRGBA_GrColorComponentFlags, // kBGRA_8888_GrPixelConfig
kRGBA_GrColorComponentFlags, // kSRGBA_8888_GrPixelConfig
kRGBA_GrColorComponentFlags, // kSBGRA_8888_GrPixelConfig
+ kRGBA_GrColorComponentFlags, // kRGBA_8888_sint_GrPixelConfig
kRGB_GrColorComponentFlags, // kETC1_GrPixelConfig
kA_GrColorComponentFlag, // kLATC_GrPixelConfig
kA_GrColorComponentFlag, // kR11_EAC_GrPixelConfig
@@ -314,13 +315,14 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) {
GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(8 == kSBGRA_8888_GrPixelConfig);
- GR_STATIC_ASSERT(9 == kETC1_GrPixelConfig);
- GR_STATIC_ASSERT(10 == kLATC_GrPixelConfig);
- GR_STATIC_ASSERT(11 == kR11_EAC_GrPixelConfig);
- GR_STATIC_ASSERT(12 == kASTC_12x12_GrPixelConfig);
- GR_STATIC_ASSERT(13 == kRGBA_float_GrPixelConfig);
- GR_STATIC_ASSERT(14 == kAlpha_half_GrPixelConfig);
- GR_STATIC_ASSERT(15 == kRGBA_half_GrPixelConfig);
+ GR_STATIC_ASSERT(9 == kRGBA_8888_sint_GrPixelConfig);
+ GR_STATIC_ASSERT(10 == kETC1_GrPixelConfig);
+ GR_STATIC_ASSERT(11 == kLATC_GrPixelConfig);
+ GR_STATIC_ASSERT(12 == kR11_EAC_GrPixelConfig);
+ GR_STATIC_ASSERT(13 == kASTC_12x12_GrPixelConfig);
+ GR_STATIC_ASSERT(14 == kRGBA_float_GrPixelConfig);
+ GR_STATIC_ASSERT(15 == kAlpha_half_GrPixelConfig);
+ GR_STATIC_ASSERT(16 == kRGBA_half_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt);
}
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 3ec3023373..846537a546 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -230,6 +230,10 @@ enum GrPixelConfig {
*/
kSBGRA_8888_GrPixelConfig,
/**
+ * 8 bit signed integers per-channel. Byte order is b,g,r,a.
+ */
+ kRGBA_8888_sint_GrPixelConfig,
+ /**
* ETC1 Compressed Data
*/
kETC1_GrPixelConfig,
@@ -318,7 +322,7 @@ static inline GrPixelConfig GrMakePixelConfigUncompressed(GrPixelConfig config)
}
// Returns true if the pixel config is 32 bits per pixel
-static inline bool GrPixelConfigIs8888(GrPixelConfig config) {
+static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) {
switch (config) {
case kRGBA_8888_GrPixelConfig:
case kBGRA_8888_GrPixelConfig:
@@ -372,6 +376,7 @@ static inline size_t GrBytesPerPixel(GrPixelConfig config) {
case kBGRA_8888_GrPixelConfig:
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
+ case kRGBA_8888_sint_GrPixelConfig:
return 4;
case kRGBA_half_GrPixelConfig:
return 8;
@@ -416,6 +421,10 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) {
}
}
+static inline bool GrPixelConfigIsSint(GrPixelConfig config) {
+ return config == kRGBA_8888_sint_GrPixelConfig;
+}
+
/**
* Optional bitfield flags that can be set on GrSurfaceDesc (below).
*/
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index 636e72a019..44d5599fed 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -25,6 +25,7 @@ enum GrSLType {
kMat33f_GrSLType,
kMat44f_GrSLType,
kTexture2DSampler_GrSLType,
+ kTexture2DISampler_GrSLType,
kTextureExternalSampler_GrSLType,
kTexture2DRectSampler_GrSLType,
kTextureBufferSampler_GrSLType,
@@ -87,7 +88,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, -1, -1 };
+ static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1 };
return kCounts[type];
GR_STATIC_ASSERT(0 == kVoid_GrSLType);
@@ -99,14 +100,15 @@ static inline int GrSLTypeVectorCount(GrSLType type) {
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_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(9 == kTexture2DISampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(12 == kTextureBufferSampler_GrSLType);
+ GR_STATIC_ASSERT(13 == kBool_GrSLType);
+ GR_STATIC_ASSERT(14 == kInt_GrSLType);
+ GR_STATIC_ASSERT(15 == kUint_GrSLType);
+ GR_STATIC_ASSERT(16 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(17 == kSampler_GrSLType);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
}
@@ -136,15 +138,16 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) {
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_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(17 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(9 == kTexture2DISampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(12 == kTextureBufferSampler_GrSLType);
+ GR_STATIC_ASSERT(13 == kBool_GrSLType);
+ GR_STATIC_ASSERT(14 == kInt_GrSLType);
+ GR_STATIC_ASSERT(15 == kUint_GrSLType);
+ GR_STATIC_ASSERT(16 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(17 == kSampler_GrSLType);
+ GR_STATIC_ASSERT(18 == kGrSLTypeCount);
}
/** Is the shading language type integral (including vectors/matrices)? */
@@ -161,15 +164,16 @@ static inline bool GrSLTypeIsIntType(GrSLType type) {
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_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(17 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(9 == kTexture2DISampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(12 == kTextureBufferSampler_GrSLType);
+ GR_STATIC_ASSERT(13 == kBool_GrSLType);
+ GR_STATIC_ASSERT(14 == kInt_GrSLType);
+ GR_STATIC_ASSERT(15 == kUint_GrSLType);
+ GR_STATIC_ASSERT(16 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(17 == kSampler_GrSLType);
+ GR_STATIC_ASSERT(18 == kGrSLTypeCount);
}
/** Is the shading language type numeric (including vectors/matrices)? */
@@ -190,6 +194,7 @@ static inline size_t GrSLTypeSize(GrSLType type) {
3 * 3 * sizeof(float), // kMat33f_GrSLType
4 * 4 * sizeof(float), // kMat44f_GrSLType
0, // kTexture2DSampler_GrSLType
+ 0, // kTexture2DISampler_GrSLType
0, // kTextureExternalSampler_GrSLType
0, // kTexture2DRectSampler_GrSLType
0, // kTextureBufferSampler_GrSLType
@@ -210,15 +215,16 @@ static inline size_t GrSLTypeSize(GrSLType type) {
GR_STATIC_ASSERT(6 == kMat33f_GrSLType);
GR_STATIC_ASSERT(7 == kMat44f_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(17 == kGrSLTypeCount);
+ GR_STATIC_ASSERT(9 == kTexture2DISampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(12 == kTextureBufferSampler_GrSLType);
+ GR_STATIC_ASSERT(13 == kBool_GrSLType);
+ GR_STATIC_ASSERT(14 == kInt_GrSLType);
+ GR_STATIC_ASSERT(15 == kUint_GrSLType);
+ GR_STATIC_ASSERT(16 == kTexture2D_GrSLType);
+ GR_STATIC_ASSERT(17 == kSampler_GrSLType);
+ GR_STATIC_ASSERT(18 == kGrSLTypeCount);
}
static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) {
@@ -226,8 +232,9 @@ static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) {
return type >= kTexture2DSampler_GrSLType && type <= kTexture2DRectSampler_GrSLType;
GR_STATIC_ASSERT(8 == kTexture2DSampler_GrSLType);
- GR_STATIC_ASSERT(9 == kTextureExternalSampler_GrSLType);
- GR_STATIC_ASSERT(10 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(9 == kTexture2DISampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTexture2DRectSampler_GrSLType);
}
static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
@@ -235,9 +242,10 @@ static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
return type >= kTexture2DSampler_GrSLType && type <= kTextureBufferSampler_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(9 == kTexture2DISampler_GrSLType);
+ GR_STATIC_ASSERT(10 == kTextureExternalSampler_GrSLType);
+ GR_STATIC_ASSERT(11 == kTexture2DRectSampler_GrSLType);
+ GR_STATIC_ASSERT(12 == kTextureBufferSampler_GrSLType);
}
static inline bool GrSLTypeAcceptsPrecision(GrSLType type) {