Introduce enum class for texture type.
This represents the GL texture "target" but at the API-neutral level. It
will be needed here because proxy's that wrap imported texture's need to
know about sampling restrictions.
Change-Id: Ie811a6f6d04ba1b04faa6908422dca64e8e447c8
Reviewed-on: https://skia-review.googlesource.com/144304
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 215cda1..2776567 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -65,8 +65,8 @@
inline const GrTexturePriv texturePriv() const;
protected:
- GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType,
- GrSamplerState::Filter highestFilterMode, GrMipMapsStatus);
+ GrTexture(GrGpu*, const GrSurfaceDesc&, GrTextureType, GrSamplerState::Filter highestFilterMode,
+ GrMipMapsStatus);
virtual bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) = 0;
@@ -76,7 +76,7 @@
void markMipMapsDirty();
void markMipMapsClean();
- GrSLType fSamplerType;
+ GrTextureType fTextureType;
GrSamplerState::Filter fHighestFilterMode;
GrMipMapsStatus fMipMapsStatus;
int fMaxMipMapLevel;
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index ecd9557..db25236 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -330,6 +330,17 @@
kTexture2DRectSampler_GrSLType,
};
+/**
+ * The type of texture. Backends other than GL currently only use the 2D value but the type must
+ * still be known at the API-neutral layer as it used to determine whether MIP maps, renderability,
+ * and sampling parameters are legal for proxies that will be instantiated with wrapped textures.
+ */
+enum class GrTextureType {
+ k2D,
+ kRectangle,
+ kExternal
+};
+
enum GrShaderType {
kVertex_GrShaderType,
kGeometry_GrShaderType,
@@ -479,6 +490,19 @@
return -1;
}
+static inline GrSLType GrSLCombinedSamplerTypeForTextureType(GrTextureType type) {
+ switch (type) {
+ case GrTextureType::k2D:
+ return kTexture2DSampler_GrSLType;
+ case GrTextureType::kRectangle:
+ return kTexture2DRectSampler_GrSLType;
+ case GrTextureType::kExternal:
+ return kTextureExternalSampler_GrSLType;
+ }
+ SK_ABORT("Unexpected texture type");
+ return kTexture2DSampler_GrSLType;
+}
+
static inline bool GrSLTypeIsCombinedSamplerType(GrSLType type) {
switch (type) {
case kTexture2DSampler_GrSLType:
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index f1524db..b0396f9 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -22,28 +22,26 @@
kSamplerOrImageTypeKeyBits = 4
};
-static inline uint16_t image_storage_or_sampler_uniform_type_key(GrSLType type ) {
+static inline uint16_t texture_type_key(GrTextureType type) {
int value = UINT16_MAX;
switch (type) {
- case kTexture2DSampler_GrSLType:
+ case GrTextureType::k2D:
value = 0;
break;
- case kTextureExternalSampler_GrSLType:
+ case GrTextureType::kExternal:
value = 1;
break;
- case kTexture2DRectSampler_GrSLType:
+ case GrTextureType::kRectangle:
value = 2;
break;
- default:
- break;
}
SkASSERT((value & ((1 << kSamplerOrImageTypeKeyBits) - 1)) == value);
- return value;
+ return SkToU16(value);
}
-static uint16_t sampler_key(GrSLType samplerType, GrPixelConfig config, GrShaderFlags visibility,
+static uint16_t sampler_key(GrTextureType textureType, GrPixelConfig config,
const GrShaderCaps& caps) {
- int samplerTypeKey = image_storage_or_sampler_uniform_type_key(samplerType);
+ int samplerTypeKey = texture_type_key(textureType);
GR_STATIC_ASSERT(1 == sizeof(caps.configTextureSwizzle(config).asKey()));
return SkToU16(samplerTypeKey |
@@ -65,8 +63,7 @@
const GrResourceIOProcessor::TextureSampler& sampler = proc.textureSampler(i);
const GrTexture* tex = sampler.peekTexture();
- k16[j] = sampler_key(tex->texturePriv().samplerType(), tex->config(), sampler.visibility(),
- caps);
+ k16[j] = sampler_key(tex->texturePriv().textureType(), tex->config(), caps);
}
// zero the last 16 bits if the number of uniforms for samplers is odd.
if (numTextureSamplers & 0x1) {
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 0051a22..8b08e71 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -35,11 +35,10 @@
}
/////////////////////////////////////////////////////////////////////////////
-GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType,
- GrSamplerState::Filter highestFilterMode,
- GrMipMapsStatus mipMapsStatus)
+GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrTextureType textureType,
+ GrSamplerState::Filter highestFilterMode, GrMipMapsStatus mipMapsStatus)
: INHERITED(gpu, desc)
- , fSamplerType(samplerType)
+ , fTextureType(textureType)
, fHighestFilterMode(highestFilterMode)
, fMipMapsStatus(mipMapsStatus) {
if (GrMipMapsStatus::kNotAllocated == fMipMapsStatus) {
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index 1cdd2dc..316afbc 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -40,7 +40,7 @@
return fTexture->fMaxMipMapLevel;
}
- GrSLType samplerType() const { return fTexture->fSamplerType; }
+ GrTextureType textureType() const { return fTexture->fTextureType; }
/** The filter used is clamped to this value in GrProcessor::TextureSampler. */
GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; }
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index e04a40d..ea1bfcd 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3008,7 +3008,8 @@
int progIdx = TextureToCopyProgramIdx(srcTex);
const GrShaderCaps* shaderCaps = this->caps()->shaderCaps();
- GrSLType samplerType = srcTex->texturePriv().samplerType();
+ GrSLType samplerType =
+ GrSLCombinedSamplerTypeForTextureType(srcTex->texturePriv().textureType());
if (!fCopyProgramArrayBuffer) {
static const GrGLfloat vdata[] = {
@@ -4126,7 +4127,7 @@
}
int GrGLGpu::TextureToCopyProgramIdx(GrTexture* texture) {
- switch (texture->texturePriv().samplerType()) {
+ switch (GrSLCombinedSamplerTypeForTextureType(texture->texturePriv().textureType())) {
case kTexture2DSampler_GrSLType:
return 0;
case kTexture2DRectSampler_GrSLType:
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 2d674f4..f0fafab 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -15,18 +15,30 @@
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
-static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, GrPixelConfig config,
- const GrGLGpu* gpu) {
- if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
- SkASSERT(gpu->caps()->shaderCaps()->externalTextureSupport());
- return kTextureExternalSampler_GrSLType;
- } else if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE) {
- SkASSERT(gpu->glCaps().rectangleTextureSupport());
- return kTexture2DRectSampler_GrSLType;
- } else {
- SkASSERT(idDesc.fInfo.fTarget == GR_GL_TEXTURE_2D);
- return kTexture2DSampler_GrSLType;
+static inline GrTextureType texture_type_from_target(GrGLenum target) {
+ switch (target) {
+ case GR_GL_TEXTURE_2D:
+ return GrTextureType::k2D;
+ case GR_GL_TEXTURE_RECTANGLE:
+ return GrTextureType::kRectangle;
+ case GR_GL_TEXTURE_EXTERNAL:
+ return GrTextureType::kExternal;
}
+ SK_ABORT("Unexpected texture target");
+ return GrTextureType::k2D;
+}
+
+static inline GrGLenum target_from_texture_type(GrTextureType type) {
+ switch (type) {
+ case GrTextureType::k2D:
+ return GR_GL_TEXTURE_2D;
+ case GrTextureType::kRectangle:
+ return GR_GL_TEXTURE_RECTANGLE;
+ case GrTextureType::kExternal:
+ return GR_GL_TEXTURE_EXTERNAL;
+ }
+ SK_ABORT("Unexpected texture type");
+ return GR_GL_TEXTURE_2D;
}
// This method parallels GrTextureProxy::highestFilterMode
@@ -42,27 +54,27 @@
// Because this class is virtually derived from GrSurface we must explicitly call its constructor.
GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
const IDDesc& idDesc, GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, desc)
- , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu),
- highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
+ : GrSurface(gpu, desc)
+ , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget),
+ highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
this->init(desc, idDesc);
this->registerWithCache(budgeted);
}
GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc,
GrMipMapsStatus mipMapsStatus, const IDDesc& idDesc)
- : GrSurface(gpu, desc)
- , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu),
- highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
+ : GrSurface(gpu, desc)
+ , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget),
+ highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
this->init(desc, idDesc);
this->registerWithCacheWrapped();
}
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, desc)
- , INHERITED(gpu, desc, sampler_type(idDesc, desc.fConfig, gpu),
- highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
+ : GrSurface(gpu, desc)
+ , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget),
+ highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
this->init(desc, idDesc);
}
@@ -75,30 +87,38 @@
}
fTexParams.invalidate();
fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
- fInfo = idDesc.fInfo;
+ fID = idDesc.fInfo.fID;
+ fFormat = idDesc.fInfo.fFormat;
fTextureIDOwnership = idDesc.fOwnership;
}
+GrGLenum GrGLTexture::target() const {
+ return target_from_texture_type(this->texturePriv().textureType());
+}
+
void GrGLTexture::onRelease() {
- if (fInfo.fID) {
+ if (fID) {
if (GrBackendObjectOwnership::kBorrowed != fTextureIDOwnership) {
- GL_CALL(DeleteTextures(1, &fInfo.fID));
+ GL_CALL(DeleteTextures(1, &fID));
}
- fInfo.fID = 0;
+ fID = 0;
}
this->invokeReleaseProc();
INHERITED::onRelease();
}
void GrGLTexture::onAbandon() {
- fInfo.fTarget = 0;
- fInfo.fID = 0;
+ fID = 0;
this->invokeReleaseProc();
INHERITED::onAbandon();
}
GrBackendTexture GrGLTexture::getBackendTexture() const {
- return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), fInfo);
+ GrGLTextureInfo info;
+ info.fTarget = target_from_texture_type(this->texturePriv().textureType());
+ info.fID = fID;
+ info.fFormat = fFormat;
+ return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), info);
}
sk_sp<GrGLTexture> GrGLTexture::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
@@ -108,8 +128,7 @@
bool GrGLTexture::onStealBackendTexture(GrBackendTexture* backendTexture,
SkImage::BackendTextureReleaseProc* releaseProc) {
- *backendTexture = GrBackendTexture(this->width(), this->height(),
- this->texturePriv().mipMapped(), fInfo);
+ *backendTexture = this->getBackendTexture();
// Set the release proc to a no-op function. GL doesn't require any special cleanup.
*releaseProc = [](GrBackendTexture){};
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 10b8e26..298f1fa 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -58,9 +58,9 @@
fTexParamsTimestamp = timestamp;
}
- GrGLuint textureID() const { return fInfo.fID; }
+ GrGLuint textureID() const { return fID; }
- GrGLenum target() const { return fInfo.fTarget; }
+ GrGLenum target() const;
bool hasBaseLevelBeenBoundToFBO() const { return fBaseLevelHasBeenBoundToFBO; }
void baseLevelWasBoundToFBO() { fBaseLevelHasBeenBoundToFBO = true; }
@@ -96,9 +96,8 @@
TexParams fTexParams;
GrGpu::ResetTimestamp fTexParamsTimestamp;
- // Holds the texture target and ID. A pointer to this may be shared to external clients for
- // direct interaction with the GL object.
- GrGLTextureInfo fInfo;
+ GrGLuint fID;
+ GrGLenum fFormat;
GrBackendObjectOwnership fTextureIDOwnership;
bool fBaseLevelHasBeenBoundToFBO = false;
diff --git a/src/gpu/gl/GrGLUniformHandler.cpp b/src/gpu/gl/GrGLUniformHandler.cpp
index 81b1ee6..0d57a14 100644
--- a/src/gpu/gl/GrGLUniformHandler.cpp
+++ b/src/gpu/gl/GrGLUniformHandler.cpp
@@ -63,7 +63,7 @@
GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(uint32_t visibility,
GrSwizzle swizzle,
- GrSLType type,
+ GrTextureType type,
GrSLPrecision precision,
const char* name) {
SkASSERT(name && strlen(name));
@@ -74,8 +74,7 @@
fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
UniformInfo& sampler = fSamplers.push_back();
- SkASSERT(GrSLTypeIsCombinedSamplerType(type));
- sampler.fVariable.setType(type);
+ sampler.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type));
sampler.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
sampler.fVariable.setPrecision(precision);
sampler.fVariable.setName(mangleName);
diff --git a/src/gpu/gl/GrGLUniformHandler.h b/src/gpu/gl/GrGLUniformHandler.h
index d3aa2f8..1bf8553 100644
--- a/src/gpu/gl/GrGLUniformHandler.h
+++ b/src/gpu/gl/GrGLUniformHandler.h
@@ -39,7 +39,7 @@
int arrayCount,
const char** outName) override;
- SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
+ SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrTextureType, GrSLPrecision,
const char* name) override;
const GrShaderVar& samplerVariable(SamplerHandle handle) const override {
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 6f05eba..05b78ee 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -226,10 +226,10 @@
// GrProcessor::TextureSampler sampler(dstTexture);
SkString name("DstTextureSampler");
dstTextureSamplerHandle =
- this->emitSampler(dstTexture->texturePriv().samplerType(), dstTexture->config(),
+ this->emitSampler(dstTexture->texturePriv().textureType(), dstTexture->config(),
"DstTextureSampler", kFragment_GrShaderFlag);
dstTextureOrigin = fPipeline.dstTextureProxy()->origin();
- SkASSERT(kTextureExternalSampler_GrSLType != dstTexture->texturePriv().samplerType());
+ SkASSERT(dstTexture->texturePriv().textureType() != GrTextureType::kExternal);
}
GrGLSLXferProcessor::EmitArgs args(&fFS,
@@ -258,9 +258,9 @@
for (int t = 0; t < numTextureSamplers; ++t) {
const GrResourceIOProcessor::TextureSampler& sampler = processor.textureSampler(t);
name.printf("TextureSampler_%d", outTexSamplerHandles->count());
- GrSLType samplerType = sampler.peekTexture()->texturePriv().samplerType();
+ GrTextureType textureType = sampler.peekTexture()->texturePriv().textureType();
outTexSamplerHandles->emplace_back(this->emitSampler(
- samplerType, sampler.peekTexture()->config(), name.c_str(), sampler.visibility()));
+ textureType, sampler.peekTexture()->config(), name.c_str(), sampler.visibility()));
}
}
@@ -277,14 +277,14 @@
}
}
-GrGLSLProgramBuilder::SamplerHandle GrGLSLProgramBuilder::emitSampler(GrSLType samplerType,
+GrGLSLProgramBuilder::SamplerHandle GrGLSLProgramBuilder::emitSampler(GrTextureType textureType,
GrPixelConfig config,
const char* name,
GrShaderFlags visibility) {
this->updateSamplerCounts(visibility);
GrSLPrecision precision = GrSLSamplerPrecision(config);
GrSwizzle swizzle = this->shaderCaps()->configTextureSwizzle(config);
- return this->uniformHandler()->addSampler(visibility, swizzle, samplerType, precision, name);
+ return this->uniformHandler()->addSampler(visibility, swizzle, textureType, precision, name);
}
void GrGLSLProgramBuilder::emitFSOutputSwizzle(bool hasSecondaryOutput) {
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.h b/src/gpu/glsl/GrGLSLProgramBuilder.h
index b1ccec8..bdc39c00 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.h
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.h
@@ -137,7 +137,7 @@
void emitAndInstallXferProc(const SkString& colorIn, const SkString& coverageIn);
void emitSamplers(const GrResourceIOProcessor& processor,
SkTArray<SamplerHandle>* outTexSamplerHandles);
- SamplerHandle emitSampler(GrSLType samplerType, GrPixelConfig, const char* name,
+ SamplerHandle emitSampler(GrTextureType, GrPixelConfig, const char* name,
GrShaderFlags visibility);
void emitFSOutputSwizzle(bool hasSecondaryOutput);
void updateSamplerCounts(GrShaderFlags visibility);
diff --git a/src/gpu/glsl/GrGLSLUniformHandler.h b/src/gpu/glsl/GrGLSLUniformHandler.h
index 8e077e4..ae87faf 100644
--- a/src/gpu/glsl/GrGLSLUniformHandler.h
+++ b/src/gpu/glsl/GrGLSLUniformHandler.h
@@ -95,7 +95,7 @@
virtual const GrShaderVar& samplerVariable(SamplerHandle) const = 0;
virtual GrSwizzle samplerSwizzle(SamplerHandle) const = 0;
- virtual SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrSLType, GrSLPrecision,
+ virtual SamplerHandle addSampler(uint32_t visibility, GrSwizzle, GrTextureType, GrSLPrecision,
const char* name) = 0;
virtual UniformHandle internalAddUniformArray(uint32_t visibility,
diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h
index 24ef009..1722329 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -46,7 +46,7 @@
GrMockTexture(GrMockGpu* gpu, const GrSurfaceDesc& desc, GrMipMapsStatus mipMapsStatus,
const GrMockTextureInfo& info)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrSamplerState::Filter::kMipMap,
+ , INHERITED(gpu, desc, GrTextureType::k2D, GrSamplerState::Filter::kMipMap,
mipMapsStatus)
, fInfo(info) {}
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index 0511df2..1b5ffcb 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -22,8 +22,7 @@
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
- mipMapsStatus)
+ , INHERITED(gpu, desc, GrTextureType::k2D, highest_filter_mode(desc.fConfig), mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
this->registerWithCache(budgeted);
@@ -35,8 +34,7 @@
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
- mipMapsStatus)
+ , INHERITED(gpu, desc, GrTextureType::k2D, highest_filter_mode(desc.fConfig), mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
this->registerWithCacheWrapped();
@@ -47,8 +45,7 @@
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
- mipMapsStatus)
+ , INHERITED(gpu, desc, GrTextureType::k2D, highest_filter_mode(desc.fConfig), mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
}
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index ff01985..99ecdf8 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -953,7 +953,7 @@
return -1;
}
if (GrTexture* tex = thatProxies[j]->priv().peekTexture()) {
- if (tex->texturePriv().samplerType() != kTexture2DSampler_GrSLType) {
+ if (tex->texturePriv().textureType() != GrTextureType::k2D) {
return -1;
}
}
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 1f1d1bb..93171c0 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -30,11 +30,10 @@
sk_sp<GrVkImageLayout> layout,
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus)
- : GrSurface(gpu, desc)
- , GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kOwned)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
- mipMapsStatus)
- , fTextureView(view) {
+ : GrSurface(gpu, desc)
+ , GrVkImage(info, std::move(layout), GrBackendObjectOwnership::kOwned)
+ , INHERITED(gpu, desc, GrTextureType::k2D, highest_filter_mode(desc.fConfig), mipMapsStatus)
+ , fTextureView(view) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
this->registerWithCache(budgeted);
}
@@ -47,11 +46,10 @@
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership)
- : GrSurface(gpu, desc)
- , GrVkImage(info, std::move(layout), ownership)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
- mipMapsStatus)
- , fTextureView(view) {
+ : GrSurface(gpu, desc)
+ , GrVkImage(info, std::move(layout), ownership)
+ , INHERITED(gpu, desc, GrTextureType::k2D, highest_filter_mode(desc.fConfig), mipMapsStatus)
+ , fTextureView(view) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
this->registerWithCacheWrapped();
}
@@ -64,11 +62,10 @@
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership)
- : GrSurface(gpu, desc)
- , GrVkImage(info, layout, ownership)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, highest_filter_mode(desc.fConfig),
- mipMapsStatus)
- , fTextureView(view) {
+ : GrSurface(gpu, desc)
+ , GrVkImage(info, layout, ownership)
+ , INHERITED(gpu, desc, GrTextureType::k2D, highest_filter_mode(desc.fConfig), mipMapsStatus)
+ , fTextureView(view) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
}
diff --git a/src/gpu/vk/GrVkUniformHandler.cpp b/src/gpu/vk/GrVkUniformHandler.cpp
index 3af61d0..0f25be8 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -256,7 +256,7 @@
GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(uint32_t visibility,
GrSwizzle swizzle,
- GrSLType type,
+ GrTextureType type,
GrSLPrecision precision,
const char* name) {
SkASSERT(name && strlen(name));
@@ -269,8 +269,7 @@
fProgramBuilder->nameVariable(&mangleName, prefix, name, true);
UniformInfo& info = fSamplers.push_back();
- SkASSERT(GrSLTypeIsCombinedSamplerType(type));
- info.fVariable.setType(type);
+ info.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type));
info.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
info.fVariable.setPrecision(precision);
info.fVariable.setName(mangleName);
diff --git a/src/gpu/vk/GrVkUniformHandler.h b/src/gpu/vk/GrVkUniformHandler.h
index 7653abe..bd8f8f3 100644
--- a/src/gpu/vk/GrVkUniformHandler.h
+++ b/src/gpu/vk/GrVkUniformHandler.h
@@ -60,7 +60,7 @@
SamplerHandle addSampler(uint32_t visibility,
GrSwizzle swizzle,
- GrSLType type,
+ GrTextureType type,
GrSLPrecision precision,
const char* name) override;