From 59dc41175d99d0a31c046aec0c26c4d82a3a3574 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Wed, 23 Nov 2016 01:02:43 +0000 Subject: Revert "Initial OpenGL Image support." This reverts commit be34882042048db096baca32ddf4a8b472529804. Reason for revert: Test failures and shader compilation issues on Android. Original change's description: > Initial OpenGL Image support. > > This change along with recently landed changes is enough to make the new unit test work and not much else. imageLoad is support but not stores or any other image functions (atomics). Barriers in the shading language or the GL API are not yet hooked up. > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4182 > > Change-Id: I5958b7c89e40ae5ee05f7bbaca3b3738162fe5ce > Reviewed-on: https://skia-review.googlesource.com/4182 > Reviewed-by: Greg Daniel > Reviewed-by: Chris Dalton > Commit-Queue: Brian Salomon > TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I29a2502c296ae39ed9a999957800414ae46e6f0f Reviewed-on: https://skia-review.googlesource.com/5129 Commit-Queue: Brian Salomon Reviewed-by: Brian Salomon --- tests/ImageStorageTest.cpp | 149 --------------------------------------------- 1 file changed, 149 deletions(-) delete mode 100644 tests/ImageStorageTest.cpp (limited to 'tests/ImageStorageTest.cpp') diff --git a/tests/ImageStorageTest.cpp b/tests/ImageStorageTest.cpp deleted file mode 100644 index 99949d07ce..0000000000 --- a/tests/ImageStorageTest.cpp +++ /dev/null @@ -1,149 +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 "GrFragmentProcessor.h" -#include "GrInvariantOutput.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 sk_sp Make(sk_sp texture) { - return sk_sp(new TestFP(std::move(texture))); - } - - const char* name() const override { return "Image Load Test FP"; } - - private: - TestFP(sk_sp texture) : fImageStorageAccess(std::move(texture), kRead_GrIOType) { - this->initClassID(); - this->setWillReadFragmentPosition(); - this->addImageStorageAccess(&fImageStorageAccess); - } - - void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const override {} - - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); - } - - 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(); - GrGLSLFPFragmentBuilder* fb = args.fFragBuilder; - SkString imageLoadStr; - fb->codeAppendf("vec2 coord = %s.xy;", args.fFragBuilder->fragmentPosition()); - fb->appendImageStorageLoad(&imageLoadStr, args.fImageStorages[0], - "ivec2(coord)"); - if (GrPixelConfigIsSint(tfp.fImageStorageAccess.texture()->config())) { - // Map the signed bytes so that when then get read back as unorm values they - // will have their original bit pattern. - fb->codeAppendf("ivec4 ivals = %s;", imageLoadStr.c_str()); - // NV gives a linker error for this: - // fb->codeAppend("ivals += - // "mix(ivec4(0), ivec4(256), lessThan(ivals, ivec4(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 = (vec4(ivals) + vec4(0.5))/255;", args.fOutputColor); - } else { - fb->codeAppendf("%s = %s;", args.fOutputColor, imageLoadStr.c_str()); - } - } - }; - return new GLSLProcessor; - } - - ImageStorageAccess fImageStorageAccess; - }; - - static constexpr int kS = 256; - GrContext* context = ctxInfo.grContext(); - if (!context->caps()->shaderCaps()->imageLoadStoreSupport()) { - return; - } - - std::unique_ptr 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 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 fData; - } tests[] = { - { - kRGBA_8888_GrPixelConfig, - std::move(data) - }, - { - kRGBA_8888_sint_GrPixelConfig, - std::move(idata) - }, - }; - for (const auto& test : tests) { - desc.fConfig = test.fConfig; - sk_sp imageStorageTexture(context->textureProvider()->createTexture(desc, - SkBudgeted::kYes, test.fData.get(), 0)); - - sk_sp rtContext = - context->makeRenderTargetContext(SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, - nullptr); - GrPaint paint; - paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - paint.addColorFragmentProcessor(TestFP::Make(imageStorageTexture)); - rtContext->drawPaint(GrNoClip(), paint, SkMatrix::I()); - std::unique_ptr 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 -- cgit v1.2.3