Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 41e377d

Browse files
bsalomonSkia Commit-Bot
authored andcommitted
Revert "Support large kernels on GPU in matrix convolution effect"
This reverts commit 1ed4391. Reason for revert: Looks like some bad images showed up at gold.skia.org and that the ProcessorCloneTest is crashing on Windows bots: https://logs.chromium.org/logs/skia/4bfabe0bad476911/+/steps/dm/0/stdout Original change's description: > Support large kernels on GPU in matrix convolution effect > > Currently matrix convolution falls back to CPU execution for large kernels, due to the argument limit for fragment shaders. > > Now for large kernels, we store them in a texture and sample them in a shader to sidestep the limit. > > Change-Id: Icc069a701ea8e9cd0adf75f4bfd149fd22e31afd > Bug: skia:8449 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263495 > Reviewed-by: Michael Ludwig <[email protected]> > Commit-Queue: Adlai Holler <[email protected]> [email protected],[email protected],[email protected] Change-Id: Iaf4858131046a343481bcf0fd9cc3919d9fc2bda No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:8449 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287736 Reviewed-by: Brian Salomon <[email protected]> Commit-Queue: Brian Salomon <[email protected]>
1 parent 6d2febd commit 41e377d

File tree

6 files changed

+71
-264
lines changed

6 files changed

+71
-264
lines changed

gm/matrixconvolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class MatrixConvolutionGM : public GM {
7979
return SkImageFilters::MatrixConvolution({3,3}, kernel.data(), /* gain */ 0.3f, /* bias */ SkIntToScalar(100), kernelOffset, tileMode, convolveAlpha, nullptr, cropRect);
8080
}
8181
case kLarge_KernelFixture: {
82-
// Intentionally go over the uniform kernel size limit of 25.
82+
// Intentionally go over the MAX_KERNEL_SIZE limit and trigger CPU fallback.
8383
// All 1s except center value, which is -47 (sum of 1).
8484
std::vector<SkScalar> kernel(49, SkIntToScalar(1));
8585
kernel[24] = SkIntToScalar(-47);

src/core/SkGpuBlurUtils.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingCo
128128
SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY);
129129
GrPaint paint;
130130
auto wm = SkTileModeToWrapMode(mode);
131-
auto conv = GrMatrixConvolutionEffect::MakeGaussian(context, std::move(srcView), srcBounds,
132-
size, 1.0, 0.0, kernelOffset, wm, true,
133-
sigmaX, sigmaY,
131+
auto conv = GrMatrixConvolutionEffect::MakeGaussian(std::move(srcView), srcBounds, size, 1.0,
132+
0.0, kernelOffset, wm, true, sigmaX, sigmaY,
134133
*renderTargetContext->caps());
135134
paint.addColorFragmentProcessor(std::move(conv));
136135
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -448,8 +447,7 @@ std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
448447
if (scaleFactorX == 1 && scaleFactorY == 1) {
449448
// For really small blurs (certainly no wider than 5x5 on desktop GPUs) it is faster to just
450449
// launch a single non separable kernel vs two launches.
451-
const int kernelSize = (2 * radiusX + 1) * (2 * radiusY + 1);
452-
if (sigmaX > 0 && sigmaY > 0 && kernelSize <= GrMatrixConvolutionEffect::kMaxUniformSize) {
450+
if (sigmaX > 0 && sigmaY > 0 && (2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) {
453451
// Apply the proxy offset to src bounds and offset directly
454452
return convolve_gaussian_2d(context, std::move(srcView), srcColorType, srcBounds,
455453
dstBounds, radiusX, radiusY, sigmaX, sigmaY, mode,

src/effects/imagefilters/SkMatrixConvolutionImageFilter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(const Co
391391
}
392392

393393
#if SK_SUPPORT_GPU
394-
if (ctx.gpuBacked()) {
394+
// Note: if the kernel is too big, the GPU path falls back to SW
395+
if (ctx.gpuBacked() &&
396+
fKernelSize.width() * fKernelSize.height() <= MAX_KERNEL_SIZE) {
395397
auto context = ctx.getContext();
396398

397399
// Ensure the input is in the destination color space. Typically applyCropRect will have
@@ -412,8 +414,7 @@ sk_sp<SkSpecialImage> SkMatrixConvolutionImageFilterImpl::onFilterImage(const Co
412414
// Map srcBounds from input's logical image domain to that of the proxy
413415
srcBounds.offset(input->subset().x(), input->subset().y());
414416

415-
auto fp = GrMatrixConvolutionEffect::Make(context,
416-
std::move(inputView),
417+
auto fp = GrMatrixConvolutionEffect::Make(std::move(inputView),
417418
srcBounds,
418419
fKernelSize,
419420
fKernel,

src/gpu/GrFragmentProcessor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ class GrFragmentProcessor::TextureSampler {
490490

491491
TextureSampler(GrSurfaceProxyView, GrSamplerState = {});
492492

493-
TextureSampler(TextureSampler&&) = default;
494-
TextureSampler& operator=(TextureSampler&&) = default;
495493
TextureSampler& operator=(const TextureSampler&) = delete;
496494

497495
bool operator==(const TextureSampler& that) const {

0 commit comments

Comments
 (0)