aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-01-30 13:13:42 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-30 13:13:56 +0000
commit7f861927fcd4f9fdef958b5ed9d50b1362ee3232 (patch)
treef7c60f611d039539676ae4eb2466d81798e81cd7 /tests
parent2f5b8d81c231ef4acb4b5671c0956a249f0ef4cf (diff)
Revert "Drop support for unused MSAA extensions"
This reverts commit 7df27465c4ecc8a4a0cdd95e9785c342903c2de9. Reason for revert: experimental revert to see if this is the cause of the tree redness Original change's description: > Drop support for unused MSAA extensions > > Bug: skia: > Change-Id: I113b80e3f991f195155148625ceb29242ea82776 > Reviewed-on: https://skia-review.googlesource.com/101403 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Commit-Queue: Chris Dalton <csmartdalton@google.com> TBR=bsalomon@google.com,csmartdalton@google.com,ethannicholas@google.com Change-Id: I4fa4123e2d176bef88cd76a09a14053d9ac5809f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/101680 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/GpuSampleLocationsTest.cpp199
-rw-r--r--tests/GrMeshTest.cpp2
-rw-r--r--tests/GrPipelineDynamicStateTest.cpp2
-rw-r--r--tests/PrimitiveProcessorTest.cpp2
4 files changed, 202 insertions, 3 deletions
diff --git a/tests/GpuSampleLocationsTest.cpp b/tests/GpuSampleLocationsTest.cpp
new file mode 100644
index 0000000000..de15e03389
--- /dev/null
+++ b/tests/GpuSampleLocationsTest.cpp
@@ -0,0 +1,199 @@
+/*
+ * 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 "SkTypes.h"
+#include "SkPoint.h"
+#include "Test.h"
+#include <vector>
+
+#if SK_SUPPORT_GPU
+
+#include "GrAppliedClip.h"
+#include "GrRenderTargetContext.h"
+#include "GrRenderTargetPriv.h"
+#include "GrTypesPriv.h"
+#include "gl/GrGLGpu.h"
+#include "gl/debug/DebugGLTestContext.h"
+
+typedef std::vector<SkPoint> SamplePattern;
+
+static const SamplePattern kTestPatterns[] = {
+ SamplePattern{ // Intel on mac, msaa8, offscreen.
+ {0.562500, 0.312500},
+ {0.437500, 0.687500},
+ {0.812500, 0.562500},
+ {0.312500, 0.187500},
+ {0.187500, 0.812500},
+ {0.062500, 0.437500},
+ {0.687500, 0.937500},
+ {0.937500, 0.062500}
+ },
+
+ SamplePattern{ // Intel on mac, msaa8, on-screen.
+ {0.562500, 0.687500},
+ {0.437500, 0.312500},
+ {0.812500, 0.437500},
+ {0.312500, 0.812500},
+ {0.187500, 0.187500},
+ {0.062500, 0.562500},
+ {0.687500, 0.062500},
+ {0.937500, 0.937500}
+ },
+
+ SamplePattern{ // NVIDIA, msaa16.
+ {0.062500, 0.000000},
+ {0.250000, 0.125000},
+ {0.187500, 0.375000},
+ {0.437500, 0.312500},
+ {0.500000, 0.062500},
+ {0.687500, 0.187500},
+ {0.750000, 0.437500},
+ {0.937500, 0.250000},
+ {0.000000, 0.500000},
+ {0.312500, 0.625000},
+ {0.125000, 0.750000},
+ {0.375000, 0.875000},
+ {0.562500, 0.562500},
+ {0.812500, 0.687500},
+ {0.625000, 0.812500},
+ {0.875000, 0.937500}
+ },
+
+ SamplePattern{ // NVIDIA, mixed samples, 16:1.
+ {0.250000, 0.125000},
+ {0.625000, 0.812500},
+ {0.500000, 0.062500},
+ {0.812500, 0.687500},
+ {0.187500, 0.375000},
+ {0.875000, 0.937500},
+ {0.125000, 0.750000},
+ {0.750000, 0.437500},
+ {0.937500, 0.250000},
+ {0.312500, 0.625000},
+ {0.437500, 0.312500},
+ {0.000000, 0.500000},
+ {0.375000, 0.875000},
+ {0.687500, 0.187500},
+ {0.062500, 0.000000},
+ {0.562500, 0.562500}
+ }
+};
+constexpr int numTestPatterns = SK_ARRAY_COUNT(kTestPatterns);
+
+class TestSampleLocationsInterface : public SkNoncopyable {
+public:
+ virtual void overrideSamplePattern(const SamplePattern&) = 0;
+ virtual ~TestSampleLocationsInterface() {}
+};
+
+void assert_equal(skiatest::Reporter* reporter, const SamplePattern& pattern,
+ const GrGpu::MultisampleSpecs& specs, bool flipY) {
+ GrAlwaysAssert(specs.fSampleLocations);
+ if ((int)pattern.size() != specs.fEffectiveSampleCnt) {
+ REPORT_FAILURE(reporter, "", SkString("Sample pattern has wrong number of samples."));
+ return;
+ }
+ for (int i = 0; i < specs.fEffectiveSampleCnt; ++i) {
+ SkPoint expectedLocation = specs.fSampleLocations[i];
+ if (flipY) {
+ expectedLocation.fY = 1 - expectedLocation.fY;
+ }
+ if (pattern[i] != expectedLocation) {
+ REPORT_FAILURE(reporter, "", SkString("Sample pattern has wrong sample location."));
+ return;
+ }
+ }
+}
+
+void test_sampleLocations(skiatest::Reporter* reporter, TestSampleLocationsInterface* testInterface,
+ GrContext* ctx) {
+ SkRandom rand;
+ sk_sp<GrRenderTargetContext> bottomUps[numTestPatterns];
+ sk_sp<GrRenderTargetContext> topDowns[numTestPatterns];
+ for (int i = 0; i < numTestPatterns; ++i) {
+ int numSamples = (int)kTestPatterns[i].size();
+ GrAlwaysAssert(numSamples > 1 && SkIsPow2(numSamples));
+ bottomUps[i] = ctx->makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig, nullptr,
+ rand.nextRangeU(1 + numSamples / 2, numSamples), GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin);
+ topDowns[i] = ctx->makeDeferredRenderTargetContext(
+ SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig, nullptr,
+ rand.nextRangeU(1 + numSamples / 2, numSamples), GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin);
+ }
+
+ // Ensure all sample locations get queried and/or cached properly.
+ for (int repeat = 0; repeat < 2; ++repeat) {
+ for (int i = 0; i < numTestPatterns; ++i) {
+ testInterface->overrideSamplePattern(kTestPatterns[i]);
+ for (GrRenderTargetContext* rtc : {bottomUps[i].get(), topDowns[i].get()}) {
+ GrPipeline dummyPipeline(rtc->asRenderTargetProxy(),
+ GrPipeline::ScissorState::kDisabled,
+ SkBlendMode::kSrcOver);
+ GrRenderTarget* rt = rtc->accessRenderTarget();
+ assert_equal(reporter, kTestPatterns[i],
+ rt->renderTargetPriv().getMultisampleSpecs(dummyPipeline),
+ kBottomLeft_GrSurfaceOrigin == rtc->asSurfaceProxy()->origin());
+ }
+ }
+ }
+
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class GLTestSampleLocationsInterface : public TestSampleLocationsInterface, public GrGLInterface {
+public:
+ GLTestSampleLocationsInterface() : fTestContext(sk_gpu_test::CreateDebugGLTestContext()) {
+ fStandard = fTestContext->gl()->fStandard;
+ fExtensions = fTestContext->gl()->fExtensions;
+ fFunctions = fTestContext->gl()->fFunctions;
+
+ fFunctions.fGetIntegerv = [&](GrGLenum pname, GrGLint* params) {
+ GrAlwaysAssert(GR_GL_EFFECTIVE_RASTER_SAMPLES != pname);
+ if (GR_GL_SAMPLES == pname) {
+ GrAlwaysAssert(!fSamplePattern.empty());
+ *params = (int)fSamplePattern.size();
+ } else {
+ fTestContext->gl()->fFunctions.fGetIntegerv(pname, params);
+ }
+ };
+
+ fFunctions.fGetMultisamplefv = [&](GrGLenum pname, GrGLuint index, GrGLfloat* val) {
+ GrAlwaysAssert(GR_GL_SAMPLE_POSITION == pname);
+ val[0] = fSamplePattern[index].fX;
+ val[1] = fSamplePattern[index].fY;
+ };
+ }
+
+ operator GrBackendContext() {
+ return reinterpret_cast<GrBackendContext>(static_cast<GrGLInterface*>(this));
+ }
+
+ void overrideSamplePattern(const SamplePattern& newPattern) override {
+ fSamplePattern = newPattern;
+ }
+
+private:
+ std::unique_ptr<sk_gpu_test::GLTestContext> fTestContext;
+ SamplePattern fSamplePattern;
+};
+
+DEF_GPUTEST(GLSampleLocations, reporter, /* options */) {
+ auto testInterface = sk_make_sp<GLTestSampleLocationsInterface>();
+ sk_sp<GrContext> ctx(GrContext::MakeGL(testInterface));
+
+ // This test relies on at least 2 samples.
+ int supportedSample = ctx->caps()->getSampleCount(2, kRGBA_8888_GrPixelConfig);
+ if (supportedSample < 2) {
+ return;
+ }
+ test_sampleLocations(reporter, testInterface.get(), ctx.get());
+}
+
+#endif
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index 86437d5dfb..ccc9a73e8f 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -341,7 +341,7 @@ class GLSLMeshTestProcessor : public GrGLSLGeometryProcessor {
}
gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertex");
- GrGLSLFragmentBuilder* f = args.fFragBuilder;
+ GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
f->codeAppendf("%s = half4(1);", args.fOutputCoverage);
}
};
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 00da84e1a9..cd1ce1e053 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -93,7 +93,7 @@ class GLSLPipelineDynamicStateTestProcessor : public GrGLSLGeometryProcessor {
v->codeAppendf("float2 vertex = %s;", mp.fVertex.fName);
gpArgs->fPositionVar.set(kFloat2_GrSLType, "vertex");
- GrGLSLFragmentBuilder* f = args.fFragBuilder;
+ GrGLSLPPFragmentBuilder* f = args.fFragBuilder;
f->codeAppendf("%s = half4(1);", args.fOutputCoverage);
}
};
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index ffe8175ba7..406d5e2104 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -73,7 +73,7 @@ private:
const GP& gp = args.fGP.cast<GP>();
args.fVaryingHandler->emitAttributes(gp);
this->writeOutputPosition(args.fVertBuilder, gpArgs, gp.getAttrib(0).fName);
- GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
+ GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
fragBuilder->codeAppendf("%s = half4(1);", args.fOutputColor);
fragBuilder->codeAppendf("%s = half4(1);", args.fOutputCoverage);
}