aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-11-07 09:53:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-07 15:38:03 +0000
commit739c5bf111baf977fe418a24fa00ce260989ee9a (patch)
treeb8a2bbe94bc66fef1912497a72f24bf993a69bf4 /src/gpu
parent4394cc4b00a4b3af9037d3c6a86cfb1f016050a7 (diff)
Revert "Revert "Limit GL_TEXTURE_RECTANGLE filtering to bilinear.""
This reverts commit ce4d04ae8eace6ba53ff8b8c8d8f4a2e6af4e59f. BUG=skia:5932 Original CL description: > >Limit GL_TEXTURE_RECTANGLE filtering to bilinear. > >Adds a clamp for GrTexture filtering that can be set by a subclass at construction. The clamping is performed by GrTextureParams. GrGLTexture limits filtering to bilinear for rectangle and external textures. > >Also moves samplerType() to GrTexturePriv from GrTexture. > >BUG=skia:5932 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4455 Change-Id: I4a9f4abac44979cb900f5b04fe741524eade66b1 Reviewed-on: https://skia-review.googlesource.com/4455 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrProgramDesc.cpp4
-rw-r--r--src/gpu/GrTexture.cpp3
-rw-r--r--src/gpu/GrTextureAccess.cpp3
-rw-r--r--src/gpu/GrTexturePriv.h5
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.h4
-rw-r--r--src/gpu/gl/GrGLTexture.cpp20
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp3
-rw-r--r--src/gpu/vk/GrVkTexture.cpp9
8 files changed, 38 insertions, 13 deletions
diff --git a/src/gpu/GrProgramDesc.cpp b/src/gpu/GrProgramDesc.cpp
index 3b0e54bcd2..fa728ed682 100644
--- a/src/gpu/GrProgramDesc.cpp
+++ b/src/gpu/GrProgramDesc.cpp
@@ -9,6 +9,7 @@
#include "GrProcessor.h"
#include "GrPipeline.h"
#include "GrRenderTargetPriv.h"
+#include "GrTexturePriv.h"
#include "SkChecksum.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -45,7 +46,8 @@ static void add_sampler_keys(GrProcessorKeyBuilder* b, const GrProcessor& proc,
for (; i < numTextures; ++i) {
const GrTextureAccess& access = proc.textureAccess(i);
const GrTexture* tex = access.getTexture();
- k16[i] = sampler_key(tex->samplerType(), tex->config(), access.getVisibility(), caps);
+ k16[i] = sampler_key(tex->texturePriv().samplerType(), tex->config(),
+ access.getVisibility(), caps);
}
for (; i < numSamplers; ++i) {
const GrBufferAccess& access = proc.bufferAccess(i - numTextures);
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index de1135a1eb..6fc1580e89 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -70,9 +70,10 @@ GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) {
//////////////////////////////////////////////////////////////////////////////
GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType,
- bool wasMipMapDataProvided)
+ GrTextureParams::FilterMode highestFilterMode, bool wasMipMapDataProvided)
: INHERITED(gpu, desc)
, fSamplerType(samplerType)
+ , fHighestFilterMode(highestFilterMode)
// Gamma treatment is explicitly set after creation via GrTexturePriv
, fGammaTreatment(SkSourceGammaTreatment::kIgnore) {
if (wasMipMapDataProvided) {
diff --git a/src/gpu/GrTextureAccess.cpp b/src/gpu/GrTextureAccess.cpp
index 675bc20777..bddbd5a2d7 100644
--- a/src/gpu/GrTextureAccess.cpp
+++ b/src/gpu/GrTextureAccess.cpp
@@ -8,6 +8,7 @@
#include "GrTextureAccess.h"
#include "GrColor.h"
#include "GrTexture.h"
+#include "GrTexturePriv.h"
GrTextureAccess::GrTextureAccess() {}
@@ -28,6 +29,7 @@ void GrTextureAccess::reset(GrTexture* texture,
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
fParams = params;
+ fParams.setFilterMode(SkTMin(params.filterMode(), texture->texturePriv().highestFilterMode()));
fVisibility = visibility;
}
@@ -37,6 +39,7 @@ void GrTextureAccess::reset(GrTexture* texture,
GrShaderFlags visibility) {
SkASSERT(texture);
fTexture.set(SkRef(texture), kRead_GrIOType);
+ filterMode = SkTMin(filterMode, texture->texturePriv().highestFilterMode());
fParams.reset(tileXAndY, filterMode);
fVisibility = visibility;
}
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index c4e6538d16..c4c185560e 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -49,6 +49,11 @@ public:
return fTexture->fMaxMipMapLevel;
}
+ GrSLType samplerType() const { return fTexture->fSamplerType; }
+
+ /** The filter used is clamped to this value in GrTextureAccess. */
+ GrTextureParams::FilterMode highestFilterMode() const { return fTexture->fHighestFilterMode; }
+
void setGammaTreatment(SkSourceGammaTreatment gammaTreatment) const {
fTexture->fGammaTreatment = gammaTreatment;
}
diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h
index 8242362a9c..fced736183 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/GrSimpleTextureEffect.h
@@ -31,8 +31,8 @@ public:
/* clamp mode */
static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
sk_sp<GrColorSpaceXform> colorSpaceXform,
- const SkMatrix& matrix,
- GrTextureParams::FilterMode filterMode) {
+ const SkMatrix& matrix,
+ GrTextureParams::FilterMode filterMode) {
return sk_sp<GrFragmentProcessor>(
new GrSimpleTextureEffect(tex, std::move(colorSpaceXform), matrix, filterMode));
}
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index ec0ad3b7f3..c45d08f93c 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -12,7 +12,7 @@
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
-inline static GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrGLGpu* gpu) {
+static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrGLGpu* gpu) {
if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
SkASSERT(gpu->glCaps().glslCaps()->externalTextureSupport());
return kTextureExternalSampler_GrSLType;
@@ -25,11 +25,19 @@ inline static GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrG
}
}
+static inline GrTextureParams::FilterMode highest_filter_mode(const GrGLTexture::IDDesc& idDesc) {
+ if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE ||
+ idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
+ return GrTextureParams::kBilerp_FilterMode;
+ }
+ return GrTextureParams::kMipMap_FilterMode;
+}
+
// 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)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
+ , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc), false) {
this->init(desc, idDesc);
this->registerWithCache(budgeted);
}
@@ -38,14 +46,15 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc&
const IDDesc& idDesc,
bool wasMipMapDataProvided)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided) {
+ , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc),
+ wasMipMapDataProvided) {
this->init(desc, idDesc);
this->registerWithCache(budgeted);
}
GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const IDDesc& idDesc)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
+ , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc), false) {
this->init(desc, idDesc);
this->registerWithCacheWrapped();
}
@@ -53,7 +62,8 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
bool wasMipMapDataProvided)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided) {
+ , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc),
+ wasMipMapDataProvided) {
this->init(desc, idDesc);
}
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index abfeafda0c..5b1fbe1c79 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -8,6 +8,7 @@
#include "glsl/GrGLSLProgramBuilder.h"
#include "GrPipeline.h"
+#include "GrTexturePriv.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLGeometryProcessor.h"
#include "glsl/GrGLSLVarying.h"
@@ -244,7 +245,7 @@ void GrGLSLProgramBuilder::emitSamplers(const GrProcessor& processor,
int numTextures = processor.numTextures();
for (int t = 0; t < numTextures; ++t) {
const GrTextureAccess& access = processor.textureAccess(t);
- GrSLType samplerType = access.getTexture()->samplerType();
+ GrSLType samplerType = access.getTexture()->texturePriv().samplerType();
if (kTextureExternalSampler_GrSLType == samplerType) {
const char* externalFeatureString = this->glslCaps()->externalTextureExtensionString();
// We shouldn't ever create a GrGLTexture that requires external sampler type
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index 8c461f8308..3b6108cd52 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -24,7 +24,8 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
const GrVkImageView* view)
: GrSurface(gpu, desc)
, GrVkImage(info, GrVkImage::kNot_Wrapped)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped)
+ , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrTextureParams::kMipMap_FilterMode,
+ desc.fIsMipMapped)
, fTextureView(view)
, fLinearTextureView(nullptr) {
this->registerWithCache(budgeted);
@@ -38,7 +39,8 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped)
: GrSurface(gpu, desc)
, GrVkImage(info, wrapped)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped)
+ , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrTextureParams::kMipMap_FilterMode,
+ desc.fIsMipMapped)
, fTextureView(view)
, fLinearTextureView(nullptr) {
this->registerWithCacheWrapped();
@@ -52,7 +54,8 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
GrVkImage::Wrapped wrapped)
: GrSurface(gpu, desc)
, GrVkImage(info, wrapped)
- , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped)
+ , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrTextureParams::kMipMap_FilterMode,
+ desc.fIsMipMapped)
, fTextureView(view)
, fLinearTextureView(nullptr) {
}