diff options
author | Brian Salomon <bsalomon@google.com> | 2017-11-15 14:28:33 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-15 20:06:12 +0000 |
commit | 559f556d9d70ef9d1202e436a56d48364b279ac6 (patch) | |
tree | 0371c13e6ed17e351066f1be46f4053e72c63365 /tests | |
parent | 33d17cbb003975fff895954435183756f9893c17 (diff) |
Remove support for image load/store
This isn't used and has become a maintenance burden.
Change-Id: I5f3af8f91e5c4f073fe4ea30e0a7f1f61efeea47
Reviewed-on: https://skia-review.googlesource.com/70640
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ImageStorageTest.cpp | 178 | ||||
-rw-r--r-- | tests/ProcessorTest.cpp | 60 |
2 files changed, 7 insertions, 231 deletions
diff --git a/tests/ImageStorageTest.cpp b/tests/ImageStorageTest.cpp deleted file mode 100644 index a8704c6264..0000000000 --- a/tests/ImageStorageTest.cpp +++ /dev/null @@ -1,178 +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 "GrFragmentProcessor.h" -#include "GrRenderTargetContext.h" -#include "GrTexture.h" -#include "glsl/GrGLSLFragmentProcessor.h" -#include "glsl/GrGLSLFragmentShaderBuilder.h" - -DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) { - class TestFP : public GrFragmentProcessor { - public: - static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, - GrSLMemoryModel mm, - GrSLRestrict restrict) { - return std::unique_ptr<GrFragmentProcessor>(new TestFP(std::move(proxy), mm, restrict)); - } - - const char* name() const override { return "Image Load Test FP"; } - - std::unique_ptr<GrFragmentProcessor> clone() const override { - return std::unique_ptr<GrFragmentProcessor>(new TestFP(*this)); - } - - private: - TestFP(sk_sp<GrTextureProxy> proxy, GrSLMemoryModel mm, GrSLRestrict restrict) - : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags) - , fImageStorageAccess(std::move(proxy), kRead_GrIOType, mm, restrict) { - this->addImageStorageAccess(&fImageStorageAccess); - } - - explicit TestFP(const TestFP& that) - : INHERITED(kTestFP_ClassID, that.optimizationFlags()) - , fImageStorageAccess(that.fImageStorageAccess) { - this->addImageStorageAccess(&fImageStorageAccess); - } - - void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} - - bool onIsEqual(const GrFragmentProcessor& that) const override { return true; } - - GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { - class GLSLProcessor : public GrGLSLFragmentProcessor { - public: - GLSLProcessor() = default; - void emitCode(EmitArgs& args) override { - const TestFP& tfp = args.fFp.cast<TestFP>(); - GrGLSLFPFragmentBuilder* fb = args.fFragBuilder; - SkString imageLoadStr; - fb->codeAppend("float2 coord = sk_FragCoord.xy;"); - fb->appendImageStorageLoad(&imageLoadStr, args.fImageStorages[0], - "int2(coord)"); - if (GrPixelConfigIsSint(tfp.fImageStorageAccess.peekTexture()->config())) { - // Map the signed bytes so that when then get read back as unorm values they - // will have their original bit pattern. - fb->codeAppendf("int4 ivals = %s;", imageLoadStr.c_str()); - // NV gives a linker error for this: - // fb->codeAppend("ivals += - // "mix(int4(0), int4(256), lessThan(ivals, int4(0)));"); - fb->codeAppend("if (ivals.r < 0) { ivals.r += 256; }"); - fb->codeAppend("if (ivals.g < 0) { ivals.g += 256; }"); - fb->codeAppend("if (ivals.b < 0) { ivals.b += 256; }"); - fb->codeAppend("if (ivals.a < 0) { ivals.a += 256; }"); - fb->codeAppendf("%s = half4(ivals)/255;", args.fOutputColor); - } else { - fb->codeAppendf("%s = %s;", args.fOutputColor, imageLoadStr.c_str()); - } - } - }; - return new GLSLProcessor; - } - - ImageStorageAccess fImageStorageAccess; - typedef GrFragmentProcessor INHERITED; - }; - - static constexpr int kS = 256; - GrContext* context = ctxInfo.grContext(); - if (context->caps()->shaderCaps()->maxFragmentImageStorages() < 1) { - return; - } - - std::unique_ptr<uint32_t[]> data(new uint32_t[kS * kS]); - for (int j = 0; j < kS; ++j) { - for (int i = 0; i < kS; ++i) { - data[i + kS * j] = GrColorPackRGBA(i, j, 0, 0); - } - } - - std::unique_ptr<uint32_t[]> idata(new uint32_t[kS * kS]); - for (int j = 0; j < kS; ++j) { - for (int i = 0; i < kS; ++i) { - int8_t r = i - 128; - int8_t g = j - 128; - int8_t b = -128; - int8_t a = -128; - idata[i + kS * j] = ((uint8_t)a << 24) | ((uint8_t)b << 16) | - ((uint8_t)g << 8) | (uint8_t)r; - } - } - - // Currently image accesses always have "top left" semantics. - GrSurfaceDesc desc; - desc.fOrigin = kTopLeft_GrSurfaceOrigin; - desc.fWidth = kS; - desc.fHeight = kS; - struct { - GrPixelConfig fConfig; - std::unique_ptr<uint32_t[]> fData; - } tests[] = { - { - kRGBA_8888_GrPixelConfig, - std::move(data) - }, - { - kRGBA_8888_sint_GrPixelConfig, - std::move(idata) - }, - }; - for (const auto& test : tests) { - // This test should work with any memory model and with or without restrict - for (auto mm : {GrSLMemoryModel::kNone, - GrSLMemoryModel::kCoherent, - GrSLMemoryModel::kVolatile}) { - for (auto restrict : {GrSLRestrict::kNo, GrSLRestrict::kYes}) { - if (!context->caps()->canConfigBeImageStorage(test.fConfig)) { - continue; - } - desc.fConfig = test.fConfig; - sk_sp<GrTextureProxy> imageStorageTexture = - GrSurfaceProxy::MakeDeferred(context->resourceProvider(), desc, - SkBudgeted::kYes, test.fData.get(), 0); - - sk_sp<GrRenderTargetContext> rtContext = - context->makeDeferredRenderTargetContext(SkBackingFit::kExact, kS, kS, - kRGBA_8888_GrPixelConfig, nullptr); - // We make a clone to test that copying GrFragmentProcessor::ImageStorageAccess - // works. - std::unique_ptr<GrFragmentProcessor> fps[2]; - fps[0] = TestFP::Make(imageStorageTexture, mm, restrict); - fps[1] = fps[0]->clone(); - for (auto& fp : fps) { - GrPaint paint; - paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.addColorFragmentProcessor(std::move(fp)); - rtContext->drawPaint(GrNoClip(), std::move(paint), SkMatrix::I()); - std::unique_ptr<uint32_t[]> readData(new uint32_t[kS * kS]); - SkImageInfo info = SkImageInfo::Make(kS, kS, kRGBA_8888_SkColorType, - kPremul_SkAlphaType); - rtContext->readPixels(info, readData.get(), 0, 0, 0); - int failed = false; - for (int j = 0; j < kS && !failed; ++j) { - for (int i = 0; i < kS && !failed; ++i) { - uint32_t d = test.fData[j * kS + i]; - uint32_t rd = readData[j * kS + i]; - if (d != rd) { - failed = true; - ERRORF(reporter, "Expected 0x%08x, got 0x%08x at %d, %d.", - d, rd, i, j); - } - } - } - } - } - } - } -} - -#endif diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 9acf185b9b..177eead450 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -67,18 +67,12 @@ private: */ class TestFP : public GrFragmentProcessor { public: - struct Image { - Image(sk_sp<GrTextureProxy> proxy, GrIOType ioType) : fProxy(proxy), fIOType(ioType) {} - sk_sp<GrTextureProxy> fProxy; - GrIOType fIOType; - }; static std::unique_ptr<GrFragmentProcessor> Make(std::unique_ptr<GrFragmentProcessor> child) { return std::unique_ptr<GrFragmentProcessor>(new TestFP(std::move(child))); } static std::unique_ptr<GrFragmentProcessor> Make(const SkTArray<sk_sp<GrTextureProxy>>& proxies, - const SkTArray<sk_sp<GrBuffer>>& buffers, - const SkTArray<Image>& images) { - return std::unique_ptr<GrFragmentProcessor>(new TestFP(proxies, buffers, images)); + const SkTArray<sk_sp<GrBuffer>>& buffers) { + return std::unique_ptr<GrFragmentProcessor>(new TestFP(proxies, buffers)); } const char* name() const override { return "test"; } @@ -94,33 +88,23 @@ public: } private: - TestFP(const SkTArray<sk_sp<GrTextureProxy>>& proxies, - const SkTArray<sk_sp<GrBuffer>>& buffers, - const SkTArray<Image>& images) - : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4), fBuffers(4), - fImages(4) { + TestFP(const SkTArray<sk_sp<GrTextureProxy>>& proxies, const SkTArray<sk_sp<GrBuffer>>& buffers) + : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4), fBuffers(4) { for (const auto& proxy : proxies) { this->addTextureSampler(&fSamplers.emplace_back(proxy)); } for (const auto& buffer : buffers) { this->addBufferAccess(&fBuffers.emplace_back(kRGBA_8888_GrPixelConfig, buffer.get())); } - for (const Image& image : images) { - fImages.emplace_back(image.fProxy, image.fIOType, - GrSLMemoryModel::kNone, GrSLRestrict::kNo); - this->addImageStorageAccess(&fImages.back()); - } } TestFP(std::unique_ptr<GrFragmentProcessor> child) - : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4), fBuffers(4), - fImages(4) { + : INHERITED(kTestFP_ClassID, kNone_OptimizationFlags), fSamplers(4), fBuffers(4) { this->registerChildProcessor(std::move(child)); } explicit TestFP(const TestFP& that) - : INHERITED(kTestFP_ClassID, that.optimizationFlags()), fSamplers(4), fBuffers(4), - fImages(4) { + : INHERITED(kTestFP_ClassID, that.optimizationFlags()), fSamplers(4), fBuffers(4) { for (int i = 0; i < that.fSamplers.count(); ++i) { fSamplers.emplace_back(that.fSamplers[i]); this->addTextureSampler(&fSamplers.back()); @@ -129,10 +113,6 @@ private: fBuffers.emplace_back(that.fBuffers[i]); this->addBufferAccess(&fBuffers.back()); } - for (int i = 0; i < that.fImages.count(); ++i) { - fImages.emplace_back(that.fImages[i]); - this->addImageStorageAccess(&fImages.back()); - } for (int i = 0; i < that.numChildProcessors(); ++i) { this->registerChildProcessor(that.childProcessor(i).clone()); } @@ -156,7 +136,6 @@ private: GrTAllocator<TextureSampler> fSamplers; GrTAllocator<BufferAccess> fBuffers; - GrTAllocator<ImageStorageAccess> fImages; typedef GrFragmentProcessor INHERITED; }; } @@ -190,7 +169,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { kRGBA_8888_GrPixelConfig, nullptr)); { bool texelBufferSupport = context->caps()->shaderCaps()->texelBufferSupport(); - bool imageLoadStoreSupport = context->caps()->shaderCaps()->imageLoadStoreSupport(); sk_sp<GrTextureProxy> proxy1( GrSurfaceProxy::MakeDeferred(context->resourceProvider(), desc, SkBackingFit::kExact, @@ -215,18 +193,11 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { { SkTArray<sk_sp<GrTextureProxy>> proxies; SkTArray<sk_sp<GrBuffer>> buffers; - SkTArray<TestFP::Image> images; proxies.push_back(proxy1); if (texelBufferSupport) { buffers.push_back(buffer); } - if (imageLoadStoreSupport) { - images.emplace_back(proxy2, GrIOType::kRead_GrIOType); - images.emplace_back(proxy3, GrIOType::kWrite_GrIOType); - images.emplace_back(proxy4, GrIOType::kRW_GrIOType); - } - auto fp = TestFP::Make(std::move(proxies), std::move(buffers), - std::move(images)); + auto fp = TestFP::Make(std::move(proxies), std::move(buffers)); for (int i = 0; i < parentCnt; ++i) { fp = TestFP::Make(std::move(fp)); } @@ -257,23 +228,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { REPORTER_ASSERT(reporter, ioRefMul * 0 == writeCnt); } - if (imageLoadStoreSupport) { - testingOnly_getIORefCnts(proxy2.get(), &refCnt, &readCnt, &writeCnt); - REPORTER_ASSERT(reporter, 1 == refCnt); - REPORTER_ASSERT(reporter, ioRefMul * 1 == readCnt); - REPORTER_ASSERT(reporter, ioRefMul * 0 == writeCnt); - - testingOnly_getIORefCnts(proxy3.get(), &refCnt, &readCnt, &writeCnt); - REPORTER_ASSERT(reporter, 1 == refCnt); - REPORTER_ASSERT(reporter, ioRefMul * 0 == readCnt); - REPORTER_ASSERT(reporter, ioRefMul * 1 == writeCnt); - - testingOnly_getIORefCnts(proxy4.get(), &refCnt, &readCnt, &writeCnt); - REPORTER_ASSERT(reporter, 1 == refCnt); - REPORTER_ASSERT(reporter, ioRefMul * 1 == readCnt); - REPORTER_ASSERT(reporter, ioRefMul * 1 == writeCnt); - } - context->flush(); testingOnly_getIORefCnts(proxy1.get(), &refCnt, &readCnt, &writeCnt); |