diff options
author | Brian Salomon <bsalomon@google.com> | 2018-02-05 15:55:54 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-02-06 12:56:46 +0000 |
commit | 5711133a1b216bfa5d1d24aaffd32dc02c64b333 (patch) | |
tree | 7f50e87e3bca2df9b7f8406a1ffdbb2257275dd2 | |
parent | b915b978e3c34e7ded50e1433cbc9e342bb71404 (diff) |
Remove integer texture support
Change-Id: I0db1c4d705711b8d980bbe0d986013daec6c8ef3
Reviewed-on: https://skia-review.googlesource.com/103762
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
-rw-r--r-- | gn/tests.gni | 1 | ||||
-rw-r--r-- | include/gpu/GrTypes.h | 4 | ||||
-rw-r--r-- | include/private/GrTypesPriv.h | 20 | ||||
-rw-r--r-- | src/gpu/GrCaps.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 5 | ||||
-rw-r--r-- | src/gpu/GrGpu.cpp | 19 | ||||
-rw-r--r-- | src/gpu/GrProgramDesc.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrTextureProxy.cpp | 5 | ||||
-rw-r--r-- | src/gpu/effects/GrDitherEffect.fp | 1 | ||||
-rw-r--r-- | src/gpu/effects/GrDitherEffect.h | 1 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 31 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 23 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLTexture.cpp | 9 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.cpp | 2 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSL.cpp | 2 | ||||
-rw-r--r-- | src/gpu/mock/GrMockTexture.h | 2 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlCaps.mm | 4 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlTexture.mm | 4 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlUtil.mm | 5 | ||||
-rw-r--r-- | src/gpu/ops/GrCopySurfaceOp.cpp | 3 | ||||
-rw-r--r-- | src/gpu/vk/GrVkTexture.cpp | 4 | ||||
-rw-r--r-- | src/gpu/vk/GrVkUniformHandler.cpp | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkUtil.cpp | 7 | ||||
-rw-r--r-- | src/gpu/vk/GrVkVaryingHandler.cpp | 2 | ||||
-rw-r--r-- | tests/GrSurfaceTest.cpp | 4 | ||||
-rw-r--r-- | tests/IntTextureTest.cpp | 288 |
27 files changed, 15 insertions, 453 deletions
diff --git a/gn/tests.gni b/gn/tests.gni index e4519d9678..3630884c8b 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -123,7 +123,6 @@ tests_sources = [ "$_tests/InfRectTest.cpp", "$_tests/InsetConvexPolyTest.cpp", "$_tests/InterpolatorTest.cpp", - "$_tests/IntTextureTest.cpp", "$_tests/InvalidIndexedPngTest.cpp", "$_tests/IsClosedSingleContourTest.cpp", "$_tests/LayerDrawLooperTest.cpp", diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index ab21fba732..c88d9ee63b 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -313,10 +313,6 @@ enum GrPixelConfig { * Premultiplied and sRGB. Byte order is b,g,r,a. */ kSBGRA_8888_GrPixelConfig, - /** - * 8 bit signed integers per-channel. Byte order is b,g,r,a. - */ - kRGBA_8888_sint_GrPixelConfig, /** * Byte order is r, g, b, a. This color format is 32 bits per channel diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h index 89861e3d5b..985d1828a6 100644 --- a/include/private/GrTypesPriv.h +++ b/include/private/GrTypesPriv.h @@ -134,7 +134,6 @@ enum GrSLType { kUint_GrSLType, kUint2_GrSLType, kTexture2DSampler_GrSLType, - kITexture2DSampler_GrSLType, kTextureExternalSampler_GrSLType, kTexture2DRectSampler_GrSLType, kBufferSampler_GrSLType, @@ -202,7 +201,6 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) { case kVoid_GrSLType: case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: case kBufferSampler_GrSLType: @@ -271,7 +269,6 @@ static inline int GrSLTypeVecLength(GrSLType type) { case kHalf4x4_GrSLType: case kVoid_GrSLType: case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: case kBufferSampler_GrSLType: @@ -286,7 +283,6 @@ static inline int GrSLTypeVecLength(GrSLType type) { static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) { switch (type) { case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: return true; @@ -333,7 +329,6 @@ static inline bool GrSLTypeIs2DCombinedSamplerType(GrSLType type) { static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) { switch (type) { case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: case kBufferSampler_GrSLType: @@ -380,7 +375,6 @@ static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) { static inline bool GrSLTypeAcceptsPrecision(GrSLType type) { switch (type) { case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: case kBufferSampler_GrSLType: @@ -451,7 +445,6 @@ static inline bool GrSLTypeTemporarilyAcceptsPrecision(GrSLType type) { case kUint_GrSLType: case kUint2_GrSLType: case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: case kBufferSampler_GrSLType: @@ -787,7 +780,6 @@ static inline bool GrPixelConfigIs8888Unorm(GrPixelConfig config) { case kGray_8_as_Red_GrPixelConfig: case kRGB_565_GrPixelConfig: case kRGBA_4444_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: case kAlpha_half_GrPixelConfig: @@ -817,7 +809,6 @@ static inline bool GrPixelConfigIsSRGB(GrPixelConfig config) { case kRGBA_4444_GrPixelConfig: case kRGBA_8888_GrPixelConfig: case kBGRA_8888_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: case kAlpha_half_GrPixelConfig: @@ -850,7 +841,6 @@ static inline GrPixelConfig GrPixelConfigSwapRAndB(GrPixelConfig config) { case kGray_8_as_Red_GrPixelConfig: case kRGB_565_GrPixelConfig: case kRGBA_4444_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: case kAlpha_half_GrPixelConfig: @@ -880,7 +870,6 @@ 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; @@ -913,7 +902,6 @@ static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) { case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_half_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kUnknown_GrPixelConfig: @@ -941,7 +929,6 @@ static inline bool GrPixelConfigIsAlphaOnly(GrPixelConfig config) { case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: case kRGBA_half_GrPixelConfig: @@ -972,17 +959,12 @@ static inline bool GrPixelConfigIsFloatingPoint(GrPixelConfig config) { case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: return false; } SK_ABORT("Invalid pixel config"); return false; } -static inline bool GrPixelConfigIsSint(GrPixelConfig config) { - return config == kRGBA_8888_sint_GrPixelConfig; -} - static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) { switch (config) { case kAlpha_8_GrPixelConfig: @@ -1001,7 +983,6 @@ static inline bool GrPixelConfigIsUnorm(GrPixelConfig config) { case kUnknown_GrPixelConfig: case kAlpha_half_GrPixelConfig: case kAlpha_half_as_Red_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: case kRGBA_half_GrPixelConfig: @@ -1029,7 +1010,6 @@ static inline GrSLPrecision GrSLSamplerPrecision(GrPixelConfig config) { case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: return kLow_GrSLPrecision; case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index dd589b436f..2b0a2a4013 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -27,7 +27,6 @@ static const char* pixel_config_name(GrPixelConfig config) { case kBGRA_8888_GrPixelConfig: return "BGRA8888"; case kSRGBA_8888_GrPixelConfig: return "SRGBA8888"; case kSBGRA_8888_GrPixelConfig: return "SBGRA8888"; - case kRGBA_8888_sint_GrPixelConfig: return "RGBA8888_sint"; case kRGBA_float_GrPixelConfig: return "RGBAFloat"; case kRG_float_GrPixelConfig: return "RGFloat"; case kAlpha_half_GrPixelConfig: return "AlphaHalf"; @@ -225,10 +224,8 @@ bool GrCaps::validateSurfaceDesc(const GrSurfaceDesc& desc, GrMipMapped mipped) return false; } - if (GrMipMapped::kYes == mipped) { - if (GrPixelConfigIsSint(desc.fConfig) || !this->mipMapSupport()) { - return false; - } + if (GrMipMapped::kYes == mipped && !this->mipMapSupport()) { + return false; } if (desc.fWidth < 1 || desc.fHeight < 1) { diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 05908f4889..536ad07d2b 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -491,11 +491,6 @@ static bool valid_premul_config(GrPixelConfig config) { static bool valid_pixel_conversion(GrPixelConfig srcConfig, GrPixelConfig dstConfig, bool premulConversion) { - // We don't allow conversion between integer configs and float/fixed configs. - if (GrPixelConfigIsSint(srcConfig) != GrPixelConfigIsSint(dstConfig)) { - return false; - } - // We only allow premul <-> unpremul conversions for some formats if (premulConversion && (!valid_premul_config(srcConfig) || !valid_premul_config(dstConfig))) { return false; diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 955d57ddb0..d9b3b87397 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -190,10 +190,6 @@ bool GrGpu::copySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, GR_CREATE_TRACE_MARKER_CONTEXT("GrGpu", "copySurface", fContext); SkASSERT(dst && src); this->handleDirtyContext(); - // We don't allow conversion between integer configs and float/fixed configs. - if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) { - return false; - } return this->onCopySurface(dst, dstOrigin, src, srcOrigin, srcRect, dstPoint); } @@ -262,11 +258,6 @@ bool GrGpu::readPixels(GrSurface* surface, GrSurfaceOrigin origin, size_t rowBytes) { SkASSERT(surface); - // We don't allow conversion between integer configs and float/fixed configs. - if (GrPixelConfigIsSint(surface->config()) != GrPixelConfigIsSint(config)) { - return false; - } - size_t bpp = GrBytesPerPixel(config); if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp, &left, &top, &width, &height, @@ -305,11 +296,6 @@ bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, } } - // We don't allow conversion between integer configs and float/fixed configs. - if (GrPixelConfigIsSint(surface->config()) != GrPixelConfigIsSint(config)) { - return false; - } - this->handleDirtyContext(); if (this->onWritePixels(surface, origin, left, top, width, height, config, texels, mipLevelCount)) { @@ -336,11 +322,6 @@ bool GrGpu::transferPixels(GrTexture* texture, size_t offset, size_t rowBytes) { SkASSERT(transferBuffer); - // We don't allow conversion between integer configs and float/fixed configs. - if (GrPixelConfigIsSint(texture->config()) != GrPixelConfigIsSint(config)) { - return false; - } - // We require that the write region is contained in the texture SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height); SkIRect bounds = SkIRect::MakeWH(texture->width(), texture->height()); diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp index 9c0add66e6..976b12ab09 100644 --- a/src/gpu/GrProgramDesc.cpp +++ b/src/gpu/GrProgramDesc.cpp @@ -25,17 +25,14 @@ static inline uint16_t image_storage_or_sampler_uniform_type_key(GrSLType type ) case kTexture2DSampler_GrSLType: value = 0; break; - case kITexture2DSampler_GrSLType: - value = 1; - break; case kTextureExternalSampler_GrSLType: - value = 2; + value = 1; break; case kTexture2DRectSampler_GrSLType: - value = 3; + value = 2; break; case kBufferSampler_GrSLType: - value = 4; + value = 3; break; default: diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp index 98c9ca0c6a..13e124021f 100644 --- a/src/gpu/GrTextureProxy.cpp +++ b/src/gpu/GrTextureProxy.cpp @@ -114,11 +114,6 @@ GrSamplerState::Filter GrTextureProxy::highestFilterMode() const { return fTarget->asTexture()->texturePriv().highestFilterMode(); } - if (GrPixelConfigIsSint(this->config())) { - // We only ever want to nearest-neighbor sample signed int textures. - return GrSamplerState::Filter::kNearest; - } - // In OpenGL, GR_GL_TEXTURE_RECTANGLE and GR_GL_TEXTURE_EXTERNAL (which have a highest filter // mode of bilerp) can only be created via wrapping. diff --git a/src/gpu/effects/GrDitherEffect.fp b/src/gpu/effects/GrDitherEffect.fp index 0f9b443802..8ae323e089 100644 --- a/src/gpu/effects/GrDitherEffect.fp +++ b/src/gpu/effects/GrDitherEffect.fp @@ -30,7 +30,6 @@ layout(key) in int rangeType; case kUnknown_GrPixelConfig: case kAlpha_half_GrPixelConfig: case kAlpha_half_as_Red_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: case kRGBA_half_GrPixelConfig: diff --git a/src/gpu/effects/GrDitherEffect.h b/src/gpu/effects/GrDitherEffect.h index 166ab716fb..c614982538 100644 --- a/src/gpu/effects/GrDitherEffect.h +++ b/src/gpu/effects/GrDitherEffect.h @@ -39,7 +39,6 @@ public: case kUnknown_GrPixelConfig: case kAlpha_half_GrPixelConfig: case kAlpha_half_as_Red_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: case kRGBA_half_GrPixelConfig: diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 99f56564d8..7fccb4652f 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -876,10 +876,6 @@ bool GrGLCaps::readPixelsSupported(GrPixelConfig surfaceConfig, return false; } - if (GrPixelConfigIsSint(surfaceConfig) != GrPixelConfigIsSint(readConfig)) { - return false; - } - GrGLenum readFormat; GrGLenum readType; if (!this->getReadPixelsFormat(surfaceConfig, readConfig, &readFormat, &readType)) { @@ -1585,33 +1581,6 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions, } fConfigTable[kSBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); - bool hasIntegerTextures; - if (standard == kGL_GrGLStandard) { - hasIntegerTextures = version >= GR_GL_VER(3, 0) || - ctxInfo.hasExtension("GL_EXT_texture_integer"); - } else { - hasIntegerTextures = (version >= GR_GL_VER(3, 0)); - } - // We may have limited GLSL to an earlier version that doesn't have integer sampler types. - if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) { - hasIntegerTextures = false; - } - fConfigTable[kRGBA_8888_sint_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA_INTEGER; - fConfigTable[kRGBA_8888_sint_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA8I; - fConfigTable[kRGBA_8888_sint_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = GR_GL_RGBA_INTEGER; - fConfigTable[kRGBA_8888_sint_GrPixelConfig].fFormats.fExternalType = GR_GL_BYTE; - fConfigTable[kRGBA_8888_sint_GrPixelConfig].fFormatType = kInteger_FormatType; - // We currently only support using integer textures as srcs, not for rendering (even though GL - // allows it). - if (hasIntegerTextures) { - fConfigTable[kRGBA_8888_sint_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag | - ConfigInfo::kFBOColorAttachment_Flag; - if (texStorageSupported) { - fConfigTable[kRGBA_8888_sint_GrPixelConfig].fFlags |= - ConfigInfo::kCanUseTexStorage_Flag; - } - } - fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGB; if (this->ES2CompatibilitySupport()) { fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGB565; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 1aebb1271d..30a8d7a4fa 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -801,7 +801,6 @@ static inline GrGLint config_alignment(GrPixelConfig config) { case kBGRA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig: - case kRGBA_8888_sint_GrPixelConfig: case kRGBA_float_GrPixelConfig: case kRG_float_GrPixelConfig: return 4; @@ -917,8 +916,8 @@ static bool allocate_and_populate_texture(GrPixelConfig config, // This means if we may later want to add mipmaps, we cannot use TexStorage. // Right now, we cannot know if we will later add mipmaps or not. // The only time we can use TexStorage is when we already have the - // mipmaps or are using a format incompatible with MIP maps. - useTexStorage &= mipLevelCount > 1 || GrPixelConfigIsSint(config); + // mipmaps. + useTexStorage &= mipLevelCount > 1; if (useTexStorage) { // We never resize or change formats of textures. @@ -1428,12 +1427,8 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, GrMipLevel zeroLevel; std::unique_ptr<uint8_t[]> zeros; - // TODO: remove the GrPixelConfigIsSint test. This is here because we have yet to add support - // for glClearBuffer* which must be used instead of glClearColor/glClear for integer FBO - // attachments. if (performClear && !this->glCaps().clearTextureSupport() && - (!this->glCaps().canConfigBeFBOColorAttachment(desc.fConfig) || - GrPixelConfigIsSint(desc.fConfig))) { + !this->glCaps().canConfigBeFBOColorAttachment(desc.fConfig)) { size_t rowSize = GrBytesPerPixel(desc.fConfig) * desc.fWidth; size_t size = rowSize * desc.fHeight; zeros.reset(new uint8_t[size]); @@ -1479,11 +1474,9 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, #endif if (tex && performClear) { if (this->glCaps().clearTextureSupport()) { - GrGLenum format = GrPixelConfigIsSint(tex->config()) ? GR_GL_RGBA_INTEGER : GR_GL_RGBA; static constexpr uint32_t kZero = 0; - GL_CALL(ClearTexImage(tex->textureID(), 0, format, GR_GL_UNSIGNED_BYTE, &kZero)); + GL_CALL(ClearTexImage(tex->textureID(), 0, GR_GL_RGBA, GR_GL_UNSIGNED_BYTE, &kZero)); } else { - SkASSERT(!GrPixelConfigIsSint(desc.fConfig)); GrGLIRect viewport; this->bindSurfaceFBOForPixelOps(tex.get(), GR_GL_FRAMEBUFFER, &viewport, kDst_TempFBOTarget); @@ -3319,7 +3312,6 @@ static inline bool can_blit_framebuffer_for_copy_surface( } // Blits are not allowed between int color buffers and float/fixed color buffers. GrGpu should // have filtered such cases out. - SkASSERT(GrPixelConfigIsSint(dst->config()) == GrPixelConfigIsSint(src->config())); const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTexture()); const GrGLTexture* srcTex = static_cast<const GrGLTexture*>(src->asTexture()); const GrRenderTarget* dstRT = dst->asRenderTarget(); @@ -4205,7 +4197,6 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst, GrSurfaceOrigin dstOr // If this returns false, then the calling code falls back to using glGenerateMipmap. bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin, bool gammaCorrect) { - SkASSERT(!GrPixelConfigIsSint(texture->config())); // Our iterative downsample requires the ability to limit which level we're sampling: if (!this->glCaps().doManualMipmapping()) { return false; @@ -4637,12 +4628,10 @@ int GrGLGpu::TextureToCopyProgramIdx(GrTexture* texture) { switch (texture->texturePriv().samplerType()) { case kTexture2DSampler_GrSLType: return 0; - case kITexture2DSampler_GrSLType: - return 1; case kTexture2DRectSampler_GrSLType: - return 2; + return 1; case kTextureExternalSampler_GrSLType: - return 3; + return 2; default: SK_ABORT("Unexpected samper type"); return 0; diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 9ac86ba123..7f3809eb28 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -604,13 +604,13 @@ private: int fHWNumRasterSamples; ///@} - /** IDs for copy surface program. (4 sampler types) */ + /** IDs for copy surface program. (3 sampler types) */ struct { GrGLuint fProgram = 0; GrGLint fTextureUniform = 0; GrGLint fTexCoordXformUniform = 0; GrGLint fPosXformUniform = 0; - } fCopyPrograms[4]; + } fCopyPrograms[3]; sk_sp<GrGLBuffer> fCopyProgramArrayBuffer; /** IDs for texture mipmap program. (4 filter configurations) */ diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp index 9c7fe2295c..0f36dd0f32 100644 --- a/src/gpu/gl/GrGLTexture.cpp +++ b/src/gpu/gl/GrGLTexture.cpp @@ -19,14 +19,10 @@ static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, GrPixelCo const GrGLGpu* gpu) { if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) { SkASSERT(gpu->caps()->shaderCaps()->externalTextureSupport()); - SkASSERT(!GrPixelConfigIsSint(config)); return kTextureExternalSampler_GrSLType; } else if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE) { SkASSERT(gpu->glCaps().rectangleTextureSupport()); - SkASSERT(!GrPixelConfigIsSint(config)); return kTexture2DRectSampler_GrSLType; - } else if (GrPixelConfigIsSint(config)) { - return kITexture2DSampler_GrSLType; } else { SkASSERT(idDesc.fInfo.fTarget == GR_GL_TEXTURE_2D); return kTexture2DSampler_GrSLType; @@ -36,11 +32,6 @@ static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, GrPixelCo // This method parallels GrTextureProxy::highestFilterMode static inline GrSamplerState::Filter highest_filter_mode(const GrGLTexture::IDDesc& idDesc, GrPixelConfig config) { - if (GrPixelConfigIsSint(config)) { - // Integer textures in GL can use GL_NEAREST_MIPMAP_NEAREST. This is a mode we don't support - // and don't currently have a use for. - return GrSamplerState::Filter::kNearest; - } if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE || idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) { return GrSamplerState::Filter::kBilerp; diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index 179c4acdb8..791d9ecfcb 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -498,8 +498,6 @@ GrPixelConfig GrGLSizedFormatToPixelConfig(GrGLenum sizedFormat) { return kBGRA_8888_GrPixelConfig; case GR_GL_SRGB8_ALPHA8: return kSRGBA_8888_GrPixelConfig; - case GR_GL_RGBA8I: - return kRGBA_8888_sint_GrPixelConfig; case GR_GL_RGB565: return kRGB_565_GrPixelConfig; case GR_GL_RGB5: diff --git a/src/gpu/glsl/GrGLSL.cpp b/src/gpu/glsl/GrGLSL.cpp index 07e36db5f7..4791a0ee22 100644 --- a/src/gpu/glsl/GrGLSL.cpp +++ b/src/gpu/glsl/GrGLSL.cpp @@ -68,8 +68,6 @@ const char* GrGLSLTypeString(const GrShaderCaps* shaderCaps, GrSLType t) { return "half4x4"; case kTexture2DSampler_GrSLType: return "sampler2D"; - case kITexture2DSampler_GrSLType: - return "isampler2D"; case kTextureExternalSampler_GrSLType: return "samplerExternalOES"; case kTexture2DRectSampler_GrSLType: diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h index b5cc4a27c0..8a5a1758a6 100644 --- a/src/gpu/mock/GrMockTexture.h +++ b/src/gpu/mock/GrMockTexture.h @@ -40,7 +40,7 @@ protected: GrMockTexture(GrMockGpu* gpu, const GrSurfaceDesc& desc, GrMipMapsStatus mipMapsStatus, const GrMockTextureInfo& info) : GrSurface(gpu, desc) - , INHERITED(gpu, desc, kITexture2DSampler_GrSLType, GrSamplerState::Filter::kMipMap, + , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrSamplerState::Filter::kMipMap, mipMapsStatus) , fInfo(info) {} diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm index 0bb7530fe2..865aa37fe6 100644 --- a/src/gpu/mtl/GrMtlCaps.mm +++ b/src/gpu/mtl/GrMtlCaps.mm @@ -289,10 +289,6 @@ void GrMtlCaps::initConfigTable() { info = &fConfigTable[kSBGRA_8888_GrPixelConfig]; info->fFlags = ConfigInfo::kAllFlags; - // RGBA_8888_sint uses RGBA8Sint - info = &fConfigTable[kRGBA_8888_sint_GrPixelConfig]; - info->fFlags = ConfigInfo::kMSAA_Flag; - // RGBA_float uses RGBA32Float info = &fConfigTable[kRGBA_float_GrPixelConfig]; if (this->isMac()) { diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm index 26e5918faf..92afe31a9a 100644 --- a/src/gpu/mtl/GrMtlTexture.mm +++ b/src/gpu/mtl/GrMtlTexture.mm @@ -48,10 +48,6 @@ sk_sp<GrMtlTexture> GrMtlTexture::CreateNewTexture(GrMtlGpu* gpu, SkBudgeted bud // This method parallels GrTextureProxy::highestFilterMode static inline GrSamplerState::Filter highest_filter_mode(GrPixelConfig config) { - if (GrPixelConfigIsSint(config)) { - // We only ever want to nearest-neighbor sample signed int textures. - return GrSamplerState::Filter::kNearest; - } return GrSamplerState::Filter::kMipMap; } diff --git a/src/gpu/mtl/GrMtlUtil.mm b/src/gpu/mtl/GrMtlUtil.mm index d05b9988e9..a188afe4ad 100644 --- a/src/gpu/mtl/GrMtlUtil.mm +++ b/src/gpu/mtl/GrMtlUtil.mm @@ -30,9 +30,6 @@ bool GrPixelConfigToMTLFormat(GrPixelConfig config, MTLPixelFormat* format) { case kSBGRA_8888_GrPixelConfig: *format = MTLPixelFormatBGRA8Unorm_sRGB; return true; - case kRGBA_8888_sint_GrPixelConfig: - *format = MTLPixelFormatRGBA8Sint; - return true; case kRGB_565_GrPixelConfig: #ifdef SK_BUILD_FOR_IOS *format = MTLPixelFormatR5G6B5Unorm; @@ -87,8 +84,6 @@ GrPixelConfig GrMTLFormatToPixelConfig(MTLPixelFormat format) { return kSRGBA_8888_GrPixelConfig; case MTLPixelFormatBGRA8Unorm_sRGB: return kSBGRA_8888_GrPixelConfig; - case MTLPixelFormatRGBA8Sint: - return kRGBA_8888_sint_GrPixelConfig; #ifdef SK_BUILD_FOR_IOS case MTLPixelFormatB5G6R5Unorm: return kRGB_565_GrPixelConfig; diff --git a/src/gpu/ops/GrCopySurfaceOp.cpp b/src/gpu/ops/GrCopySurfaceOp.cpp index 7b1c1723b2..66d9f893f3 100644 --- a/src/gpu/ops/GrCopySurfaceOp.cpp +++ b/src/gpu/ops/GrCopySurfaceOp.cpp @@ -64,9 +64,6 @@ std::unique_ptr<GrOp> GrCopySurfaceOp::Make(GrSurfaceProxy* dstProxy, GrSurfaceP const SkIPoint& dstPoint) { SkASSERT(dstProxy); SkASSERT(srcProxy); - if (GrPixelConfigIsSint(dstProxy->config()) != GrPixelConfigIsSint(srcProxy->config())) { - return nullptr; - } SkIRect clippedSrcRect; SkIPoint clippedDstPoint; // If the rect is outside the srcProxy or dstProxy then we've already succeeded. diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp index e696dd1454..109b10638d 100644 --- a/src/gpu/vk/GrVkTexture.cpp +++ b/src/gpu/vk/GrVkTexture.cpp @@ -19,10 +19,6 @@ // This method parallels GrTextureProxy::highestFilterMode static inline GrSamplerState::Filter highest_filter_mode(GrPixelConfig config) { - if (GrPixelConfigIsSint(config)) { - // We only ever want to nearest-neighbor sample signed int textures. - return GrSamplerState::Filter::kNearest; - } return GrSamplerState::Filter::kMipMap; } diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp index e76cbda959..72b350983b 100644 --- a/src/gpu/vk/GrVkUniformHandler.cpp +++ b/src/gpu/vk/GrVkUniformHandler.cpp @@ -66,7 +66,6 @@ uint32_t grsltype_to_alignment_mask(GrSLType type) { case kVoid_GrSLType: case kBool_GrSLType: case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: case kBufferSampler_GrSLType: @@ -136,7 +135,6 @@ static inline uint32_t grsltype_to_vk_size(GrSLType type) { case kVoid_GrSLType: case kBool_GrSLType: case kTexture2DSampler_GrSLType: - case kITexture2DSampler_GrSLType: case kTextureExternalSampler_GrSLType: case kTexture2DRectSampler_GrSLType: case kBufferSampler_GrSLType: diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp index 12db4c111e..330a1de7a2 100644 --- a/src/gpu/vk/GrVkUtil.cpp +++ b/src/gpu/vk/GrVkUtil.cpp @@ -31,9 +31,6 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) { case kSBGRA_8888_GrPixelConfig: *format = VK_FORMAT_B8G8R8A8_SRGB; return true; - case kRGBA_8888_sint_GrPixelConfig: - *format = VK_FORMAT_R8G8B8A8_SINT; - return true; case kRGB_565_GrPixelConfig: *format = VK_FORMAT_R5G6B5_UNORM_PACK16; return true; @@ -82,8 +79,6 @@ GrPixelConfig GrVkFormatToPixelConfig(VkFormat format) { return kSRGBA_8888_GrPixelConfig; case VK_FORMAT_B8G8R8A8_SRGB: return kSBGRA_8888_GrPixelConfig; - case VK_FORMAT_R8G8B8A8_SINT: - return kRGBA_8888_sint_GrPixelConfig; case VK_FORMAT_R5G6B5_UNORM_PACK16: return kRGB_565_GrPixelConfig; break; @@ -116,8 +111,6 @@ bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) { return kSRGBA_8888_GrPixelConfig == config; case VK_FORMAT_B8G8R8A8_SRGB: return kSBGRA_8888_GrPixelConfig == config; - case VK_FORMAT_R8G8B8A8_SINT: - return kRGBA_8888_sint_GrPixelConfig == config; case VK_FORMAT_R5G6B5_UNORM_PACK16: return kRGB_565_GrPixelConfig == config; case VK_FORMAT_B4G4R4A4_UNORM_PACK16: diff --git a/src/gpu/vk/GrVkVaryingHandler.cpp b/src/gpu/vk/GrVkVaryingHandler.cpp index 307ea53c69..c8c56c2aa2 100644 --- a/src/gpu/vk/GrVkVaryingHandler.cpp +++ b/src/gpu/vk/GrVkVaryingHandler.cpp @@ -50,8 +50,6 @@ static inline int grsltype_to_location_size(GrSLType type) { return 4; case kTexture2DSampler_GrSLType: return 0; - case kITexture2DSampler_GrSLType: - return 0; case kTextureExternalSampler_GrSLType: return 0; case kTexture2DRectSampler_GrSLType: diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 32ac0c71e6..9c4359af2c 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -92,7 +92,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { kBGRA_8888_GrPixelConfig, kSRGBA_8888_GrPixelConfig, kSBGRA_8888_GrPixelConfig, - kRGBA_8888_sint_GrPixelConfig, kRGBA_float_GrPixelConfig, kRG_float_GrPixelConfig, kAlpha_half_GrPixelConfig, @@ -138,8 +137,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { texels.get(), levelCount); REPORTER_ASSERT(reporter, SkToBool(proxy.get()) == (caps->isConfigTexturable(desc.fConfig) && - caps->mipMapSupport() && - !GrPixelConfigIsSint(desc.fConfig))); + caps->mipMapSupport())); desc.fFlags = kRenderTarget_GrSurfaceFlag; tex = resourceProvider->createTexture(desc, SkBudgeted::kNo); diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp deleted file mode 100644 index 1d133d67a0..0000000000 --- a/tests/IntTextureTest.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "Test.h" - -#if SK_SUPPORT_GPU -#include "GrClip.h" -#include "GrContext.h" -#include "GrContextPriv.h" -#include "GrProxyProvider.h" -#include "GrRenderTargetContext.h" -#include "GrResourceProvider.h" -#include "GrTexture.h" -#include "effects/GrSimpleTextureEffect.h" - -template <typename I> -static SK_WHEN(std::is_integral<I>::value && 4 == sizeof(I), void) -check_pixels(skiatest::Reporter* reporter, int w, int h, const I exepctedData[], - const I actualData[], const char* testName) { - for (int j = 0; j < h; ++j) { - for (int i = 0; i < w; ++i) { - I expected = exepctedData[j * w + i]; - I actual = actualData[j * w + i]; - if (expected != actual) { - ERRORF(reporter, "[%s] Expected 0x08%x, got 0x%08x at %d, %d.", testName, expected, - actual, i, j); - return; - } - } - } -} - -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { - GrContext* context = ctxInfo.grContext(); - if (!context->caps()->isConfigTexturable(kRGBA_8888_sint_GrPixelConfig)) { - return; - } - - GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); - auto resourceProvider = context->contextPriv().resourceProvider(); - - static const int kS = UINT8_MAX + 1; - static const size_t kRowBytes = kS * sizeof(int32_t); - - GrSurfaceDesc desc; - desc.fOrigin = kTopLeft_GrSurfaceOrigin; - desc.fConfig = kRGBA_8888_sint_GrPixelConfig; - desc.fWidth = kS; - desc.fHeight = kS; - - std::unique_ptr<int32_t[]> testData(new int32_t[kS * kS]); - for (int j = 0; j < kS; ++j) { - for (int i = 0; i < kS; ++i) { - uint32_t r = i - INT8_MIN; - uint32_t g = j - INT8_MIN; - uint32_t b = INT8_MAX - r; - uint32_t a = INT8_MAX - g; - testData.get()[j * kS + i] = (a << 24) | (b << 16) | (g << 8) | r; - } - } - - // Test that attempting to create a integer texture with multiple MIP levels fails. - { - GrMipLevel levels[2]; - levels[0].fPixels = testData.get(); - levels[0].fRowBytes = kRowBytes; - levels[1].fPixels = testData.get(); - levels[1].fRowBytes = (kS / 2) * sizeof(int32_t); - - sk_sp<GrTextureProxy> temp = proxyProvider->createMipMapProxy( - desc, SkBudgeted::kYes, levels, 2); - REPORTER_ASSERT(reporter, !temp); - } - - sk_sp<GrSurfaceContext> sContext; - // Test that we can create a non-mipmapped integer texture. - { - sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes, - testData.get(), kRowBytes); - REPORTER_ASSERT(reporter, proxy); - if (!proxy) { - return; - } - - sContext = context->contextPriv().makeWrappedSurfaceContext(std::move(proxy)); - if (!sContext) { - return; - } - } - - std::unique_ptr<int32_t[]> readData(new int32_t[kS * kS]); - // Test that reading to a non-integer config fails. - { - bool success = context->contextPriv().readSurfacePixels(sContext.get(), - 0, 0, kS, kS, - kRGBA_8888_GrPixelConfig, - nullptr, readData.get()); - REPORTER_ASSERT(reporter, !success); - } - { - std::unique_ptr<uint16_t[]> halfData(new uint16_t[4 * kS * kS]); - bool success = context->contextPriv().readSurfacePixels(sContext.get(), - 0, 0, kS, kS, - kRGBA_half_GrPixelConfig, - nullptr, halfData.get()); - REPORTER_ASSERT(reporter, !success); - } - { - // Can read back as ints. (ES only requires being able to read back into 32bit ints which - // we don't support. Right now this test is counting on GR_RGBA_INTEGER/GL_BYTE being the - // implementation-dependent second format). - sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - bool success = context->contextPriv().readSurfacePixels(sContext.get(), - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get()); - REPORTER_ASSERT(reporter, success); - if (success) { - check_pixels(reporter, kS, kS, testData.get(), readData.get(), "readPixels"); - } - } - { - // readPixels should fail if we attempt to use the unpremul flag with an integer texture. - bool success = context->contextPriv().readSurfacePixels( - sContext.get(), - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get(), 0, - GrContextPriv::kUnpremul_PixelOpsFlag); - REPORTER_ASSERT(reporter, !success); - } - - // Test that copying from one integer texture to another succeeds. - { - sk_sp<GrSurfaceContext> dstContext(GrSurfaceProxy::TestCopy(context, desc, - sContext->asSurfaceProxy())); - REPORTER_ASSERT(reporter, dstContext); - if (!dstContext || !dstContext->asTextureProxy()) { - return; - } - - sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - bool success = context->contextPriv().readSurfacePixels(dstContext.get(), 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get()); - REPORTER_ASSERT(reporter, success); - if (success) { - check_pixels(reporter, kS, kS, testData.get(), readData.get(), "copyIntegerToInteger"); - } - } - - - // Test that copying to a non-integer (8888) texture fails. - { - GrSurfaceDesc nonIntDesc = desc; - nonIntDesc.fConfig = kRGBA_8888_GrPixelConfig; - - sk_sp<GrSurfaceContext> dstContext(GrSurfaceProxy::TestCopy(context, nonIntDesc, - sContext->asSurfaceProxy())); - REPORTER_ASSERT(reporter, !dstContext); - } - - // Test that copying to a non-integer (RGBA_half) texture fails. - if (context->caps()->isConfigTexturable(kRGBA_half_GrPixelConfig)) { - GrSurfaceDesc nonIntDesc = desc; - nonIntDesc.fConfig = kRGBA_half_GrPixelConfig; - - sk_sp<GrSurfaceContext> dstContext(GrSurfaceProxy::TestCopy(context, nonIntDesc, - sContext->asSurfaceProxy())); - REPORTER_ASSERT(reporter, !dstContext); - } - - // We overwrite the top left quarter of the texture with the bottom right quarter of the - // original data. - const void* bottomRightQuarter = testData.get() + kS / 2 * kS + kS / 2; - - { - // Can't write pixels from a non-int config. - bool success = context->contextPriv().writeSurfacePixels(sContext.get(), - 0, 0, kS/2, kS/2, - kRGBA_8888_GrPixelConfig, nullptr, - bottomRightQuarter, kRowBytes); - REPORTER_ASSERT(reporter, !success); - } - { - // Can't use unpremul flag. - bool success = context->contextPriv().writeSurfacePixels( - sContext.get(), - 0, 0, kS/2, kS/2, - kRGBA_8888_sint_GrPixelConfig, - nullptr, - bottomRightQuarter, kRowBytes, - GrContextPriv::kUnpremul_PixelOpsFlag); - REPORTER_ASSERT(reporter, !success); - } - { - bool success = context->contextPriv().writeSurfacePixels(sContext.get(), - 0, 0, kS/2, kS/2, - kRGBA_8888_sint_GrPixelConfig, - nullptr, - bottomRightQuarter, kRowBytes); - REPORTER_ASSERT(reporter, success); - if (!success) { - return; - } - - sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - success = context->contextPriv().readSurfacePixels(sContext.get(), - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, - nullptr, readData.get(), 0); - REPORTER_ASSERT(reporter, success); - if (!success) { - return; - } - std::unique_ptr<int32_t[]> overwrittenTestData(new int32_t[kS * kS]); - memcpy(overwrittenTestData.get(), testData.get(), sizeof(int32_t) * kS * kS); - char* dst = (char*)overwrittenTestData.get(); - char* src = (char*)(testData.get() + kS/2 * kS + kS/2); - for (int i = 0; i < kS/2; ++i) { - memcpy(dst, src, sizeof(int32_t) * kS/2); - dst += kRowBytes; - src += kRowBytes; - } - check_pixels(reporter, kS, kS, overwrittenTestData.get(), readData.get(), "overwrite"); - } - - // Test drawing from the integer texture to a fixed point texture. To avoid any premul issues - // we init the int texture with 0s and 1s and make alpha always be 1. We expect that 1s turn - // into 0xffs and zeros stay zero. - std::unique_ptr<uint32_t[]> expectedData(new uint32_t[kS * kS]); - std::unique_ptr<uint32_t[]> actualData(new uint32_t[kS * kS]); - for (int i = 0; i < kS*kS; ++i) { - int32_t a = 0x1; - int32_t b = ((i & 0x1) ? 1 : 0); - int32_t g = ((i & 0x1) ? 0 : 1); - int32_t r = ((i & 0x2) ? 1 : 0); - testData.get()[i] = (a << 24) | (b << 16) | (g << 8) | r; - expectedData.get()[i] = ((0xFF * a) << 24) | ((0xFF * b) << 16) | - ((0xFF * g) << 8) | (0xFF * r); - } - context->contextPriv().writeSurfacePixels(sContext.get(), - 0, 0, kS, kS, - kRGBA_8888_sint_GrPixelConfig, nullptr, - testData.get(), 0); - - sk_sp<GrRenderTargetContext> rtContext = context->makeDeferredRenderTargetContext( - SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, nullptr); - - struct { - GrSamplerState::Filter fMode; - const char* fName; - } kNamedFilters[] = {{GrSamplerState::Filter::kNearest, "filter-none"}, - {GrSamplerState::Filter::kBilerp, "filter-bilerp"}, - {GrSamplerState::Filter::kMipMap, "filter-mipmap"}}; - - for (auto filter : kNamedFilters) { - auto fp = GrSimpleTextureEffect::Make(sContext->asTextureProxyRef(), SkMatrix::I(), - filter.fMode); - REPORTER_ASSERT(reporter, fp); - if (!fp) { - return; - } - rtContext->clear(nullptr, 0xDDAABBCC, GrRenderTargetContext::CanClearFullscreen::kYes); - GrPaint paint; - paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.addColorFragmentProcessor(std::move(fp)); - rtContext->drawPaint(GrNoClip(), std::move(paint), SkMatrix::I()); - SkImageInfo readInfo = SkImageInfo::Make(kS, kS, kRGBA_8888_SkColorType, - kPremul_SkAlphaType); - rtContext->readPixels(readInfo, actualData.get(), 0, 0, 0); - check_pixels(reporter, kS, kS, expectedData.get(), actualData.get(), filter.fName); - } - - { - // No rendering to integer textures. - GrSurfaceDesc intRTDesc = desc; - intRTDesc.fFlags = kRenderTarget_GrSurfaceFlag; - sk_sp<GrTexture> temp(resourceProvider->createTexture(intRTDesc, SkBudgeted::kYes)); - REPORTER_ASSERT(reporter, !temp); - } -} - -#endif |