aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-07-30 10:24:13 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-30 14:54:25 +0000
commit60dd8c746428fb6218fff5f437b1b7c5256bba13 (patch)
treebc9c5c5b16de0ecf6d60452d69dbfd870126f97a
parent12e42565886ac6b28cbcae40d63ee093bde3e630 (diff)
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>
-rw-r--r--include/gpu/GrTexture.h6
-rw-r--r--include/private/GrTypesPriv.h24
-rw-r--r--src/gpu/GrProgramDesc.cpp19
-rw-r--r--src/gpu/GrTexture.cpp7
-rw-r--r--src/gpu/GrTexturePriv.h2
-rw-r--r--src/gpu/gl/GrGLGpu.cpp5
-rw-r--r--src/gpu/gl/GrGLTexture.cpp77
-rw-r--r--src/gpu/gl/GrGLTexture.h9
-rw-r--r--src/gpu/gl/GrGLUniformHandler.cpp5
-rw-r--r--src/gpu/gl/GrGLUniformHandler.h2
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp12
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.h2
-rw-r--r--src/gpu/glsl/GrGLSLUniformHandler.h2
-rw-r--r--src/gpu/mock/GrMockTexture.h2
-rw-r--r--src/gpu/mtl/GrMtlTexture.mm9
-rw-r--r--src/gpu/ops/GrTextureOp.cpp2
-rw-r--r--src/gpu/vk/GrVkTexture.cpp27
-rw-r--r--src/gpu/vk/GrVkUniformHandler.cpp5
-rw-r--r--src/gpu/vk/GrVkUniformHandler.h2
19 files changed, 125 insertions, 94 deletions
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 215cda1e94..2776567ae8 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -65,8 +65,8 @@ public:
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 @@ private:
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 ecd95574f2..db25236e3d 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -330,6 +330,17 @@ enum GrSLType {
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 @@ static inline int GrSLTypeVecLength(GrSLType type) {
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 f1524db555..b0396f9c37 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -22,28 +22,26 @@ enum {
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 @@ static void add_sampler_and_image_keys(GrProcessorKeyBuilder* b, const GrResourc
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 0051a225ef..8b08e7182d 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -35,11 +35,10 @@ size_t GrTexture::onGpuMemorySize() const {
}
/////////////////////////////////////////////////////////////////////////////
-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 1cdd2dc9f5..316afbc4c4 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -40,7 +40,7 @@ public:
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 e04a40d8ab..ea1bfcd726 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -3008,7 +3008,8 @@ bool GrGLGpu::createCopyProgram(GrTexture* srcTex) {
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 @@ sk_sp<GrSemaphore> GrGLGpu::prepareTextureForCrossContextUsage(GrTexture* textur
}
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 2d674f4756..f0fafabcba 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 @@ static inline GrSamplerState::Filter highest_filter_mode(const GrGLTexture::IDDe
// 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 @@ void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
}
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 @@ sk_sp<GrGLTexture> GrGLTexture::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& d
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 10b8e26e78..298f1faf11 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -58,9 +58,9 @@ public:
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 @@ private:
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 81b1ee69ac..0d57a1422c 100644
--- a/src/gpu/gl/GrGLUniformHandler.cpp
+++ b/src/gpu/gl/GrGLUniformHandler.cpp
@@ -63,7 +63,7 @@ GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
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 @@ GrGLSLUniformHandler::SamplerHandle GrGLUniformHandler::addSampler(uint32_t visi
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 d3aa2f8358..1bf8553e73 100644
--- a/src/gpu/gl/GrGLUniformHandler.h
+++ b/src/gpu/gl/GrGLUniformHandler.h
@@ -39,7 +39,7 @@ private:
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 6f05eba0f6..05b78eef0c 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -226,10 +226,10 @@ void GrGLSLProgramBuilder::emitAndInstallXferProc(const SkString& colorIn,
// 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 @@ void GrGLSLProgramBuilder::emitSamplers(
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 @@ void GrGLSLProgramBuilder::updateSamplerCounts(GrShaderFlags visibility) {
}
}
-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 b1ccec8deb..bdc39c00dd 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.h
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.h
@@ -137,7 +137,7 @@ private:
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 8e077e4eec..ae87fafed9 100644
--- a/src/gpu/glsl/GrGLSLUniformHandler.h
+++ b/src/gpu/glsl/GrGLSLUniformHandler.h
@@ -95,7 +95,7 @@ private:
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 24ef009229..1722329b89 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -46,7 +46,7 @@ protected:
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 0511df29a8..1b5ffcbb33 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -22,8 +22,7 @@ GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
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 @@ GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
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 @@ GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu,
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 ff0198533f..99ecdf8101 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -953,7 +953,7 @@ __attribute__((no_sanitize("float-cast-overflow")))
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 1f1d1bbc1a..93171c0aa9 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -30,11 +30,10 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
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 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
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 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
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 3af61d0111..0f25be80f1 100644
--- a/src/gpu/vk/GrVkUniformHandler.cpp
+++ b/src/gpu/vk/GrVkUniformHandler.cpp
@@ -256,7 +256,7 @@ GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
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 @@ GrGLSLUniformHandler::SamplerHandle GrVkUniformHandler::addSampler(uint32_t visi
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 7653abea67..bd8f8f354e 100644
--- a/src/gpu/vk/GrVkUniformHandler.h
+++ b/src/gpu/vk/GrVkUniformHandler.h
@@ -60,7 +60,7 @@ private:
SamplerHandle addSampler(uint32_t visibility,
GrSwizzle swizzle,
- GrSLType type,
+ GrTextureType type,
GrSLPrecision precision,
const char* name) override;