Add test configs for instanced rendering

Adds the following configs and enables them on select bots:

  glinst, glinst4, glinstdit4, glinst16, glinstdit16,
  esinst, esinst4, esinstdit4

Makes general changes to GrContextOptions, GrCaps, etc. to facilitate
this.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2182783004

Review-Url: https://codereview.chromium.org/2182783004
This commit is contained in:
csmartdalton 2016-07-29 08:14:20 -07:00 committed by Commit bot
parent 0d9990f052
commit e0d362929d
32 changed files with 880 additions and 125 deletions

View File

@ -407,6 +407,10 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
ctxOptions = static_cast<GrContextFactory::ContextOptions>(
ctxOptions | GrContextFactory::kEnableNVPR_ContextOptions);
}
if (gpuConfig->getUseInstanced()) {
ctxOptions = static_cast<GrContextFactory::ContextOptions>(
ctxOptions | GrContextFactory::kUseInstanced_ContextOptions);
}
if (SkColorAndColorSpaceAreGammaCorrect(gpuConfig->getColorType(),
gpuConfig->getColorSpace())) {
ctxOptions = static_cast<GrContextFactory::ContextOptions>(

View File

@ -832,6 +832,10 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kEnableNVPR_ContextOptions);
}
if (gpuConfig->getUseInstanced()) {
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kUseInstanced_ContextOptions);
}
if (SkColorAndColorSpaceAreGammaCorrect(gpuConfig->getColorType(),
gpuConfig->getColorSpace())) {
contextOptions = static_cast<GrContextFactory::ContextOptions>(

View File

@ -173,6 +173,21 @@ public:
bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; }
/**
* Indicates the level of support for gr_instanced::* functionality. A higher level includes
* all functionality from the levels below it.
*/
enum class InstancedSupport {
kNone,
kBasic,
kMultisampled,
kMixedSampled
};
InstancedSupport instancedSupport() const { return fInstancedSupport; }
bool avoidInstancedDrawsToFPTargets() const { return fAvoidInstancedDrawsToFPTargets; }
/**
* Indicates the capabilities of the fixed function blend unit.
*/
@ -307,12 +322,15 @@ protected:
bool fUseDrawInsteadOfClear : 1;
bool fUseDrawInsteadOfPartialRenderTargetWrite : 1;
bool fUseDrawInsteadOfAllRenderTargetWrites : 1;
bool fAvoidInstancedDrawsToFPTargets : 1;
// ANGLE workaround
bool fPreferVRAMUseOverFlushes : 1;
bool fSampleShadingSupport : 1;
InstancedSupport fInstancedSupport;
BlendEquationSupport fBlendEquationSupport;
uint32_t fAdvBlendEqBlacklist;
GR_STATIC_ASSERT(kLast_GrBlendEquation < 32);

View File

@ -24,7 +24,8 @@ struct GrContextOptions {
, fMaxBatchLookback(-1)
, fMaxBatchLookahead(-1)
, fUseShaderSwizzling(false)
, fDoManualMipmapping(false) {}
, fDoManualMipmapping(false)
, fEnableInstancedRendering(false) {}
// Suppress prints for the GrContext.
bool fSuppressPrints;
@ -73,6 +74,10 @@ struct GrContextOptions {
the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap
level and LOD control (ie desktop or ES3). */
bool fDoManualMipmapping;
/** Enable instanced rendering as long as all required functionality is supported by the HW.
Instanced rendering is still experimental at this point and disabled by default. */
bool fEnableInstancedRendering;
};
#endif

View File

@ -106,6 +106,8 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fUseDrawInsteadOfClear = false;
fInstancedSupport = InstancedSupport::kNone;
fBlendEquationSupport = kBasic_BlendEquationSupport;
fAdvBlendEqBlacklist = 0;
@ -123,6 +125,7 @@ GrCaps::GrCaps(const GrContextOptions& options) {
fBufferMapThreshold = options.fBufferMapThreshold;
fUseDrawInsteadOfPartialRenderTargetWrite = options.fUseDrawInsteadOfPartialRenderTargetWrite;
fUseDrawInsteadOfAllRenderTargetWrites = false;
fAvoidInstancedDrawsToFPTargets = false;
fPreferVRAMUseOverFlushes = true;
}
@ -197,6 +200,21 @@ SkString GrCaps::dump() const {
r.appendf("Max Stencil Sample Count : %d\n", fMaxStencilSampleCount);
r.appendf("Max Raster Samples : %d\n", fMaxRasterSamples);
static const char* kInstancedSupportNames[] = {
"None",
"Basic",
"Multisampled",
"Mixed Sampled",
};
GR_STATIC_ASSERT(0 == (int)InstancedSupport::kNone);
GR_STATIC_ASSERT(1 == (int)InstancedSupport::kBasic);
GR_STATIC_ASSERT(2 == (int)InstancedSupport::kMultisampled);
GR_STATIC_ASSERT(3 == (int)InstancedSupport::kMixedSampled);
GR_STATIC_ASSERT(4 == SK_ARRAY_COUNT(kInstancedSupportNames));
r.appendf("Instanced Support : %s\n",
kInstancedSupportNames[(int)fInstancedSupport]);
static const char* kBlendEquationSupportNames[] = {
"Basic",
"Advanced",

View File

@ -368,7 +368,8 @@ bool GrDrawContext::drawFilledRect(const GrClip& clip,
SkAutoTUnref<GrDrawBatch> batch;
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
batch.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
paint.isAntiAlias(), fInstancedPipelineInfo,
&useHWAA));
@ -618,7 +619,8 @@ void GrDrawContext::fillRectToRect(const GrClip& clip,
AutoCheckFlush acf(fDrawingManager);
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
croppedLocalRect, paint.isAntiAlias(),
fInstancedPipelineInfo, &useHWAA));
@ -676,7 +678,8 @@ void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
AutoCheckFlush acf(fDrawingManager);
bool useHWAA;
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
localMatrix, paint.isAntiAlias(),
fInstancedPipelineInfo, &useHWAA));
@ -803,7 +806,8 @@ void GrDrawContext::drawRRect(const GrClip& clip,
const SkStrokeRec stroke = style.strokeRec();
bool useHWAA;
if (this->getDrawTarget()->instancedRendering() && stroke.isFillStyle()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() &&
stroke.isFillStyle()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordRRect(rrect, viewMatrix, paint.getColor(),
paint.isAntiAlias(), fInstancedPipelineInfo,
@ -843,8 +847,9 @@ bool GrDrawContext::drawFilledDRRect(const GrClip& clip,
SkASSERT(!origInner.isEmpty());
SkASSERT(!origOuter.isEmpty());
if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
bool useHWAA;
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordDRRect(origOuter, origInner, viewMatrix,
paintIn.getColor(), paintIn.isAntiAlias(),
fInstancedPipelineInfo, &useHWAA));
@ -954,7 +959,8 @@ void GrDrawContext::drawOval(const GrClip& clip,
const SkStrokeRec& stroke = style.strokeRec();
bool useHWAA;
if (this->getDrawTarget()->instancedRendering() && stroke.isFillStyle()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() &&
stroke.isFillStyle()) {
InstancedRendering* ir = this->getDrawTarget()->instancedRendering();
SkAutoTUnref<GrDrawBatch> batch(ir->recordOval(oval, viewMatrix, paint.getColor(),
paint.isAntiAlias(), fInstancedPipelineInfo,

View File

@ -48,8 +48,7 @@ GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r
, fResourceProvider(resourceProvider)
, fAuditTrail(auditTrail)
, fFlags(0)
, fRenderTarget(rt)
, fInstancedRendering(fGpu->createInstancedRenderingIfSupported()) {
, fRenderTarget(rt) {
// TODO: Stop extracting the context (currently needed by GrClipMaskManager)
fContext = fGpu->getContext();
@ -60,6 +59,10 @@ GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r
fMaxBatchLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLookahead :
options.fMaxBatchLookahead;
if (GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport()) {
fInstancedRendering.reset(fGpu->createInstancedRendering());
}
rt->setLastDrawTarget(this);
#ifdef SK_DEBUG

View File

@ -139,10 +139,10 @@ public:
const SkIRect& srcRect,
const SkIPoint& dstPoint);
/**
* Gets the shape rendering object if it is supported on this platform.
*/
gr_instanced::InstancedRendering* instancedRendering() const { return fInstancedRendering; }
gr_instanced::InstancedRendering* instancedRendering() const {
SkASSERT(fInstancedRendering);
return fInstancedRendering;
}
private:
friend class GrDrawingManager; // for resetFlag & TopoSortTraits

View File

@ -45,7 +45,8 @@ GrDrawingManager::~GrDrawingManager() {
void GrDrawingManager::abandon() {
fAbandoned = true;
for (int i = 0; i < fDrawTargets.count(); ++i) {
if (InstancedRendering* ir = fDrawTargets[i]->instancedRendering()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = fDrawTargets[i]->instancedRendering();
ir->resetGpuResources(InstancedRendering::ResetType::kAbandon);
}
}
@ -58,7 +59,8 @@ void GrDrawingManager::freeGpuResources() {
fPathRendererChain = nullptr;
SkSafeSetNull(fSoftwarePathRenderer);
for (int i = 0; i < fDrawTargets.count(); ++i) {
if (InstancedRendering* ir = fDrawTargets[i]->instancedRendering()) {
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
InstancedRendering* ir = fDrawTargets[i]->instancedRendering();
ir->resetGpuResources(InstancedRendering::ResetType::kDestroy);
}
}

View File

@ -251,6 +251,11 @@ GrBuffer* GrGpu::createBuffer(size_t size, GrBufferType intendedType,
return buffer;
}
gr_instanced::InstancedRendering* GrGpu::createInstancedRendering() {
SkASSERT(GrCaps::InstancedSupport::kNone != this->caps()->instancedSupport());
return this->onCreateInstancedRendering();
}
bool GrGpu::copySurface(GrSurface* dst,
GrSurface* src,
const SkIRect& srcRect,

View File

@ -152,9 +152,7 @@ public:
/**
* Creates an instanced rendering object if it is supported on this platform.
*/
virtual gr_instanced::InstancedRendering* createInstancedRenderingIfSupported() {
return nullptr;
}
gr_instanced::InstancedRendering* createInstancedRendering();
/**
* Resolves MSAA.
@ -537,6 +535,8 @@ private:
virtual GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data) = 0;
virtual gr_instanced::InstancedRendering* onCreateInstancedRendering() = 0;
virtual bool onMakeCopyForTextureParams(GrTexture* texture, const GrTextureParams&,
GrTextureProducer::CopyParams*) const { return false; }

View File

@ -12,6 +12,7 @@
#include "GrGLContext.h"
#include "GrGLRenderTarget.h"
#include "glsl/GrGLSLCaps.h"
#include "instanced/GLInstancedRendering.h"
#include "SkTSearch.h"
#include "SkTSort.h"
@ -40,7 +41,6 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fDrawIndirectSupport = false;
fMultiDrawIndirectSupport = false;
fBaseInstanceSupport = false;
fCanDrawIndirectToFloat = false;
fIsCoreProfile = false;
fBindFragDataLocationSupport = false;
fRectangleTextureSupport = false;
@ -526,14 +526,6 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
fBaseInstanceSupport = ctxInfo.hasExtension("GL_EXT_base_instance");
}
// OS X doesn't seem to write correctly to floating point textures when using glDraw*Indirect,
// regardless of the underlying GPU.
#ifndef SK_BUILD_FOR_MAC
if (fDrawIndirectSupport) {
fCanDrawIndirectToFloat = true;
}
#endif
this->initShaderPrecisionTable(ctxInfo, gli, glslCaps);
if (contextOptions.fUseShaderSwizzling) {
@ -1116,7 +1108,6 @@ SkString GrGLCaps::dump() const {
r.appendf("Draw indirect support: %s\n", (fDrawIndirectSupport ? "YES" : "NO"));
r.appendf("Multi draw indirect support: %s\n", (fMultiDrawIndirectSupport ? "YES" : "NO"));
r.appendf("Base instance support: %s\n", (fBaseInstanceSupport ? "YES" : "NO"));
r.appendf("Can draw indirect to float: %s\n", (fCanDrawIndirectToFloat ? "YES" : "NO"));
r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ? "YES" : "NO"));
r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" : "NO"));
r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSupport ? "YES" : "NO"));
@ -1935,4 +1926,13 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
#endif
}
void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {
if (options.fEnableInstancedRendering) {
fInstancedSupport = gr_instanced::GLInstancedRendering::CheckSupport(*this);
#ifndef SK_BUILD_FOR_MAC
// OS X doesn't seem to write correctly to floating point textures when using
// glDraw*Indirect, regardless of the underlying GPU.
fAvoidInstancedDrawsToFPTargets = true;
#endif
}
}

View File

@ -307,9 +307,6 @@ public:
/// Are the baseInstance fields supported in indirect draw commands?
bool baseInstanceSupport() const { return fBaseInstanceSupport; }
/// Does the platform have known issuses rendering to floating point when using glDraw*Indirect?
bool canDrawIndirectToFloat() const { return fCanDrawIndirectToFloat; }
/// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
@ -401,7 +398,6 @@ private:
bool fDrawIndirectSupport : 1;
bool fMultiDrawIndirectSupport : 1;
bool fBaseInstanceSupport : 1;
bool fCanDrawIndirectToFloat : 1;
bool fUseNonVBOVertexAndIndexDynamicData : 1;
bool fIsCoreProfile : 1;
bool fBindFragDataLocationSupport : 1;

View File

@ -479,10 +479,6 @@ void GrGLGpu::disconnect(DisconnectType type) {
///////////////////////////////////////////////////////////////////////////////
InstancedRendering* GrGLGpu::createInstancedRenderingIfSupported() {
return GLInstancedRendering::CreateIfSupported(this);
}
void GrGLGpu::onResetContext(uint32_t resetBits) {
// we don't use the zb at all
if (resetBits & kMisc_GrGLBackendState) {
@ -1965,6 +1961,10 @@ GrBuffer* GrGLGpu::onCreateBuffer(size_t size, GrBufferType intendedType,
return GrGLBuffer::Create(this, size, intendedType, accessPattern, data);
}
InstancedRendering* GrGLGpu::onCreateInstancedRendering() {
return new GLInstancedRendering(this);
}
void GrGLGpu::flushScissor(const GrScissorState& scissorState,
const GrGLIRect& rtViewport,
GrSurfaceOrigin rtOrigin) {

View File

@ -55,8 +55,6 @@ public:
return static_cast<GrGLPathRendering*>(pathRendering());
}
gr_instanced::InstancedRendering* createInstancedRenderingIfSupported() override;
// Used by GrGLProgram to configure OpenGL state.
void bindTexture(int unitIdx, const GrTextureParams& params, bool allowSRGBInputs,
GrGLTexture* texture);
@ -165,6 +163,9 @@ private:
GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&,
GrWrapOwnership) override;
GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&) override;
gr_instanced::InstancedRendering* onCreateInstancedRendering() override;
// Given a GrPixelConfig return the index into the stencil format array on GrGLCaps to a
// compatible stencil format, or negative if there is no compatible stencil format.
int getCompatibleStencilIndex(GrPixelConfig config);

View File

@ -31,27 +31,21 @@ private:
typedef Batch INHERITED;
};
GLInstancedRendering* GLInstancedRendering::CreateIfSupported(GrGLGpu* gpu) {
#ifndef SK_BUILD_FOR_MAC
// Only whitelisting on Mac for now. Once we've been able to work through the various issues on
// other platforms we can enable more generally.
return nullptr;
#endif
const GrGLCaps& glCaps = gpu->glCaps();
AntialiasMode lastSupportedAAMode;
if (!glCaps.vertexArrayObjectSupport() ||
!glCaps.drawIndirectSupport() ||
!InstanceProcessor::IsSupported(*glCaps.glslCaps(), glCaps, &lastSupportedAAMode)) {
return nullptr;
GrCaps::InstancedSupport GLInstancedRendering::CheckSupport(const GrGLCaps& glCaps) {
// This method is only intended to be used for initializing fInstancedSupport in the caps.
SkASSERT(GrCaps::InstancedSupport::kNone == glCaps.instancedSupport());
if (!glCaps.vertexArrayObjectSupport() || !glCaps.drawIndirectSupport()) {
return GrCaps::InstancedSupport::kNone;
}
return new GLInstancedRendering(gpu, lastSupportedAAMode);
return InstanceProcessor::CheckSupport(*glCaps.glslCaps(), glCaps);
}
GLInstancedRendering::GLInstancedRendering(GrGLGpu* gpu, AntialiasMode lastSupportedAAMode)
: INHERITED(gpu, lastSupportedAAMode, gpu->glCaps().canDrawIndirectToFloat()),
GLInstancedRendering::GLInstancedRendering(GrGLGpu* gpu)
: INHERITED(gpu),
fVertexArrayID(0),
fGLDrawCmdsInfo(0),
fInstanceAttribsBufferUniqueId(SK_InvalidUniqueID) {
SkASSERT(GrCaps::InstancedSupport::kNone != this->gpu()->caps()->instancedSupport());
}
GLInstancedRendering::~GLInstancedRendering() {

View File

@ -8,9 +8,11 @@
#ifndef gr_instanced_GLInstancedRendering_DEFINED
#define gr_instanced_GLInstancedRendering_DEFINED
#include "GrCaps.h"
#include "gl/GrGLBuffer.h"
#include "instanced/InstancedRendering.h"
class GrGLCaps;
class GrGLGpu;
#define GR_GL_LOG_INSTANCED_BATCHES 0
@ -19,11 +21,15 @@ namespace gr_instanced {
class GLInstancedRendering final : public InstancedRendering {
public:
static GLInstancedRendering* CreateIfSupported(GrGLGpu*);
GLInstancedRendering(GrGLGpu*);
~GLInstancedRendering() override;
private:
GLInstancedRendering(GrGLGpu*, AntialiasMode lastSupportedAAMode);
/**
* Called by GrGLCaps to determine the level of support this class can offer for instanced
* rendering on the current platform.
*/
static GrCaps::InstancedSupport CheckSupport(const GrGLCaps&);
GrGLGpu* glGpu() const;
@ -52,6 +58,8 @@ private:
class GLBatch;
friend class ::GrGLCaps; // For CheckSupport.
typedef InstancedRendering INHERITED;
};

View File

@ -18,29 +18,26 @@
namespace gr_instanced {
bool InstanceProcessor::IsSupported(const GrGLSLCaps& glslCaps, const GrCaps& caps,
AntialiasMode* lastSupportedAAMode) {
GrCaps::InstancedSupport InstanceProcessor::CheckSupport(const GrGLSLCaps& glslCaps,
const GrCaps& caps) {
if (!glslCaps.canUseAnyFunctionInShader() ||
!glslCaps.flatInterpolationSupport() ||
!glslCaps.integerSupport() ||
0 == glslCaps.maxVertexSamplers() ||
!caps.shaderCaps()->texelBufferSupport() ||
caps.maxVertexAttributes() < kNumAttribs) {
return false;
return GrCaps::InstancedSupport::kNone;
}
if (caps.sampleLocationsSupport() &&
glslCaps.sampleVariablesSupport() &&
glslCaps.shaderDerivativeSupport()) {
if (0 != caps.maxRasterSamples() &&
glslCaps.sampleMaskOverrideCoverageSupport()) {
*lastSupportedAAMode = AntialiasMode::kMixedSamples;
} else {
*lastSupportedAAMode = AntialiasMode::kMSAA;
if (!caps.sampleLocationsSupport() ||
!glslCaps.sampleVariablesSupport() ||
!glslCaps.shaderDerivativeSupport()) {
return GrCaps::InstancedSupport::kBasic;
}
} else {
*lastSupportedAAMode = AntialiasMode::kCoverage;
if (0 == caps.maxRasterSamples() ||
!glslCaps.sampleMaskOverrideCoverageSupport()) {
return GrCaps::InstancedSupport::kMultisampled;
}
return true;
return GrCaps::InstancedSupport::kMixedSampled;
}
InstanceProcessor::InstanceProcessor(BatchInfo batchInfo, GrBuffer* paramsBuffer)
@ -767,8 +764,8 @@ void GLSLInstanceProcessor::BackendCoverage::onInit(GrGLSLVaryingHandler* varyin
varyingHandler->addVarying("ellipseCoords", &fEllipseCoords, kMedium_GrSLPrecision);
varyingHandler->addFlatVarying("ellipseName", &fEllipseName, kHigh_GrSLPrecision);
} else {
varyingHandler->addVarying("circleCoords", &fEllipseCoords, kMedium_GrSLPrecision);
varyingHandler->addFlatVarying("bloatedRadius", &fBloatedRadius, kMedium_GrSLPrecision);
varyingHandler->addVarying("circleCoords", &fEllipseCoords, kHigh_GrSLPrecision);
varyingHandler->addFlatVarying("bloatedRadius", &fBloatedRadius, kHigh_GrSLPrecision);
}
}
}
@ -1016,7 +1013,7 @@ void GLSLInstanceProcessor::BackendCoverage::emitCircle(GrGLSLPPFragmentBuilder*
const char* outCoverage) {
// TODO: circleCoords = max(circleCoords, 0) if we decide to do this optimization on rrects.
SkASSERT(!(kRRect_ShapesMask & fBatchInfo.fShapeTypes));
f->appendPrecisionModifier(kLow_GrSLPrecision);
f->appendPrecisionModifier(kMedium_GrSLPrecision);
f->codeAppendf("float distanceToEdge = %s - length(%s);",
fBloatedRadius.fsIn(), fEllipseCoords.fsIn());
f->codeAppendf("%s = clamp(distanceToEdge, 0.0, 1.0);", outCoverage);
@ -1407,9 +1404,8 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*,
}
} else {
const char* arcTest = fArcTest.fsIn();
SkASSERT(arcTest);
if (fBatchInfo.fHasPerspective) {
// The non-perspective version accounts for fwith() in the vertex shader.
if (arcTest && fBatchInfo.fHasPerspective) {
// The non-perspective version accounts for fwidth() in the vertex shader.
// We make sure to take the derivative here, before a neighbor pixel may early accept.
f->enableFeature(GrGLSLPPFragmentBuilder::kStandardDerivatives_GLSLFeature);
f->appendPrecisionModifier(kHigh_GrSLPrecision);

View File

@ -8,6 +8,7 @@
#ifndef gr_instanced_InstanceProcessor_DEFINED
#define gr_instanced_InstanceProcessor_DEFINED
#include "GrCaps.h"
#include "GrBufferAccess.h"
#include "GrGeometryProcessor.h"
#include "instanced/InstancedRenderingTypes.h"
@ -22,8 +23,6 @@ namespace gr_instanced {
*/
class InstanceProcessor : public GrGeometryProcessor {
public:
static bool IsSupported(const GrGLSLCaps&, const GrCaps&, AntialiasMode* lastSupportedAAMode);
InstanceProcessor(BatchInfo, GrBuffer* paramsBuffer);
const char* name() const override { return "Instance Processor"; }
@ -52,9 +51,17 @@ public:
static const char* GetNameOfIndexRange(IndexRange);
private:
/**
* Called by the platform-specific instanced rendering implementation to determine the level of
* support this class can offer on the given GLSL platform.
*/
static GrCaps::InstancedSupport CheckSupport(const GrGLSLCaps&, const GrCaps&);
const BatchInfo fBatchInfo;
GrBufferAccess fParamsAccess;
friend class GLInstancedRendering; // For CheckSupport.
typedef GrGeometryProcessor INHERITED;
};

View File

@ -15,11 +15,8 @@
namespace gr_instanced {
InstancedRendering::InstancedRendering(GrGpu* gpu, AntialiasMode lastSupportedAAMode,
bool canRenderToFloat)
InstancedRendering::InstancedRendering(GrGpu* gpu)
: fGpu(SkRef(gpu)),
fLastSupportedAAMode(lastSupportedAAMode),
fCanRenderToFloat(canRenderToFloat),
fState(State::kRecordingDraws),
fDrawPool(1024 * sizeof(Batch::Draw), 1024 * sizeof(Batch::Draw)) {
}
@ -107,7 +104,7 @@ InstancedRendering::Batch* InstancedRendering::recordShape(ShapeType type, const
bool* useHWAA) {
SkASSERT(State::kRecordingDraws == fState);
if (info.fIsRenderingToFloat && !fCanRenderToFloat) {
if (info.fIsRenderingToFloat && fGpu->caps()->avoidInstancedDrawsToFPTargets()) {
return nullptr;
}
@ -201,9 +198,9 @@ inline bool InstancedRendering::selectAntialiasMode(const SkMatrix& viewMatrix,
bool* useHWAA, AntialiasMode* antialiasMode) {
SkASSERT(!info.fColorDisabled || info.fDrawingShapeToStencil);
SkASSERT(!info.fIsMixedSampled || info.fIsMultisampled);
SkASSERT(GrCaps::InstancedSupport::kNone != fGpu->caps()->instancedSupport());
if (!info.fIsMultisampled || fGpu->caps()->multisampleDisableSupport()) {
SkASSERT(fLastSupportedAAMode >= AntialiasMode::kCoverage);
if (!antialias) {
if (info.fDrawingShapeToStencil && !info.fCanDiscard) {
// We can't draw to the stencil buffer without discard (or sample mask if MSAA).
@ -221,13 +218,14 @@ inline bool InstancedRendering::selectAntialiasMode(const SkMatrix& viewMatrix,
}
}
if (info.fIsMultisampled && fLastSupportedAAMode >= AntialiasMode::kMSAA) {
if (info.fIsMultisampled &&
fGpu->caps()->instancedSupport() >= GrCaps::InstancedSupport::kMultisampled) {
if (!info.fIsMixedSampled || info.fColorDisabled) {
*antialiasMode = AntialiasMode::kMSAA;
*useHWAA = true;
return true;
}
if (fLastSupportedAAMode >= AntialiasMode::kMixedSamples) {
if (fGpu->caps()->instancedSupport() >= GrCaps::InstancedSupport::kMixedSampled) {
*antialiasMode = AntialiasMode::kMixedSamples;
*useHWAA = true;
return true;

View File

@ -143,7 +143,7 @@ protected:
typedef SkTInternalLList<Batch> BatchList;
InstancedRendering(GrGpu* gpu, AntialiasMode lastSupportedAAMode, bool canRenderToFloat);
InstancedRendering(GrGpu* gpu);
const BatchList& trackedBatches() const { return fTrackedBatches; }
const GrBuffer* vertexBuffer() const { SkASSERT(fVertexBuffer); return fVertexBuffer; }
@ -171,8 +171,6 @@ private:
virtual Batch* createBatch() = 0;
const SkAutoTUnref<GrGpu> fGpu;
const AntialiasMode fLastSupportedAAMode;
const bool fCanRenderToFloat;
State fState;
GrMemoryPool fDrawPool;
SkSTArray<1024, ParamsTexel, true> fParams;

View File

@ -182,6 +182,8 @@ private:
GrBuffer* onCreateBuffer(size_t size, GrBufferType type, GrAccessPattern,
const void* data) override;
gr_instanced::InstancedRendering* onCreateInstancedRendering() override { return nullptr; }
bool onReadPixels(GrSurface* surface,
int left, int top, int width, int height,
GrPixelConfig,

View File

@ -44,6 +44,7 @@ DEF_TEST(ParseConfigs_Gpu, reporter) {
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType()
== GrContextFactory::kNativeGL_ContextType);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseInstanced() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getColorType() == kN32_SkColorType);
@ -75,9 +76,10 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
SkCommandLineFlags::StringArray config1 = make_string_array({
"565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16", "msaa4",
"nonrendering", "null", "nullgpu", "nvpr16", "nvpr4", "nvprdit16", "nvprdit4", "pdf",
"skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui",
"gpuf16", "gpusrgb", "gl", "glnvpr4", "glnvprdit4", "glsrgb", "glmsaa4", "vk"
"nonrendering", "null", "nullgpu", "nvpr16", "nvpr4", "nvprdit16", "nvprdit4", "pdf", "skp",
"svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui", "gpuf16", "gpusrgb",
"gl", "glnvpr4", "glnvprdit4", "glsrgb", "glmsaa4", "vk", "glinst", "glinst4", "glinstdit4",
"glinst16", "glinstdit16", "esinst", "esinst4", "esinstdit4"
});
SkCommandLineConfigArray configs;
@ -124,6 +126,39 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace() == srgbColorSpace.get());
REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getColorType() == kN32_SkColorType);
REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getColorSpace() == srgbColorSpace.get());
REPORTER_ASSERT(reporter, configs[33]->asConfigGpu()->getContextType() ==
GrContextFactory::kGL_ContextType);
REPORTER_ASSERT(reporter, configs[33]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[34]->asConfigGpu()->getContextType() ==
GrContextFactory::kGL_ContextType);
REPORTER_ASSERT(reporter, configs[34]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[34]->asConfigGpu()->getSamples() == 4);
REPORTER_ASSERT(reporter, configs[35]->asConfigGpu()->getContextType() ==
GrContextFactory::kGL_ContextType);
REPORTER_ASSERT(reporter, configs[35]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[35]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[35]->asConfigGpu()->getSamples() == 4);
REPORTER_ASSERT(reporter, configs[36]->asConfigGpu()->getContextType() ==
GrContextFactory::kGL_ContextType);
REPORTER_ASSERT(reporter, configs[36]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[36]->asConfigGpu()->getSamples() == 16);
REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()->getContextType() ==
GrContextFactory::kGL_ContextType);
REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[37]->asConfigGpu()->getSamples() == 16);
REPORTER_ASSERT(reporter, configs[38]->asConfigGpu()->getContextType() ==
GrContextFactory::kGLES_ContextType);
REPORTER_ASSERT(reporter, configs[38]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[39]->asConfigGpu()->getContextType() ==
GrContextFactory::kGLES_ContextType);
REPORTER_ASSERT(reporter, configs[39]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[39]->asConfigGpu()->getSamples() == 4);
REPORTER_ASSERT(reporter, configs[40]->asConfigGpu()->getContextType() ==
GrContextFactory::kGLES_ContextType);
REPORTER_ASSERT(reporter, configs[40]->asConfigGpu()->getUseInstanced());
REPORTER_ASSERT(reporter, configs[40]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[40]->asConfigGpu()->getSamples() == 4);
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN

View File

@ -1116,10 +1116,11 @@
"gl",
"glsrgb",
"glmsaa4",
"glnvprdit4",
"glinstdit4",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
"glinst",
"--src",
"tests",
"gm",
@ -1688,6 +1689,251 @@
"--match",
"~CopySurface"
],
"Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug": [
"--config",
"565",
"8888",
"gpu",
"gpusrgb",
"msaa4",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
"esinst",
"--src",
"tests",
"gm",
"image",
"--blacklist",
"f16",
"_",
"_",
"dstreadshuffle",
"f16",
"image",
"_",
"_",
"srgb",
"image",
"_",
"_",
"gpusrgb",
"image",
"_",
"_",
"_",
"test",
"_",
"GrShape",
"serialize-8888",
"gm",
"_",
"bleed_image",
"serialize-8888",
"gm",
"_",
"c_gms",
"serialize-8888",
"gm",
"_",
"colortype",
"serialize-8888",
"gm",
"_",
"colortype_xfermodes",
"serialize-8888",
"gm",
"_",
"drawfilter",
"serialize-8888",
"gm",
"_",
"fontmgr_bounds_0.75_0",
"serialize-8888",
"gm",
"_",
"fontmgr_bounds_1_-0.25",
"serialize-8888",
"gm",
"_",
"fontmgr_bounds",
"serialize-8888",
"gm",
"_",
"fontmgr_match",
"serialize-8888",
"gm",
"_",
"fontmgr_iter",
"serialize-8888",
"gm",
"_",
"bleed_alpha_image",
"serialize-8888",
"gm",
"_",
"bleed_alpha_image_shader",
"serialize-8888",
"gm",
"_",
"verylargebitmap",
"serialize-8888",
"gm",
"_",
"verylarge_picture_image",
"sp-8888",
"gm",
"_",
"drawfilter",
"pic-8888",
"gm",
"_",
"drawfilter",
"2ndpic-8888",
"gm",
"_",
"drawfilter",
"sp-8888",
"gm",
"_",
"image-cacherator-from-picture",
"pic-8888",
"gm",
"_",
"image-cacherator-from-picture",
"2ndpic-8888",
"gm",
"_",
"image-cacherator-from-picture",
"serialize-8888",
"gm",
"_",
"image-cacherator-from-picture",
"sp-8888",
"gm",
"_",
"image-cacherator-from-raster",
"pic-8888",
"gm",
"_",
"image-cacherator-from-raster",
"2ndpic-8888",
"gm",
"_",
"image-cacherator-from-raster",
"serialize-8888",
"gm",
"_",
"image-cacherator-from-raster",
"sp-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"pic-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"2ndpic-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"serialize-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"_",
"image",
"_",
"interlaced1.png",
"_",
"image",
"_",
"interlaced2.png",
"_",
"image",
"_",
"interlaced3.png",
"_",
"image",
"_",
".arw",
"_",
"image",
"_",
".cr2",
"_",
"image",
"_",
".dng",
"_",
"image",
"_",
".nef",
"_",
"image",
"_",
".nrw",
"_",
"image",
"_",
".orf",
"_",
"image",
"_",
".raf",
"_",
"image",
"_",
".rw2",
"_",
"image",
"_",
".pef",
"_",
"image",
"_",
".srw",
"_",
"image",
"_",
".ARW",
"_",
"image",
"_",
".CR2",
"_",
"image",
"_",
".DNG",
"_",
"image",
"_",
".NEF",
"_",
"image",
"_",
".NRW",
"_",
"image",
"_",
".ORF",
"_",
"image",
"_",
".RAF",
"_",
"image",
"_",
".RW2",
"_",
"image",
"_",
".PEF",
"_",
"image",
"_",
".SRW"
],
"Test-Android-GCC-Nexus7-GPU-Tegra3-Arm7-Release": [
"--config",
"565",
@ -2849,6 +3095,265 @@
"_",
"blurcircles"
],
"Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug": [
"--config",
"565",
"8888",
"gpu",
"gpusrgb",
"pdf",
"msaa16",
"serialize-8888",
"tiles_rt-8888",
"pic-8888",
"glinst",
"glinst16",
"--src",
"tests",
"gm",
"image",
"--blacklist",
"f16",
"_",
"_",
"dstreadshuffle",
"f16",
"image",
"_",
"_",
"srgb",
"image",
"_",
"_",
"gpusrgb",
"image",
"_",
"_",
"_",
"image",
"gen_platf",
"rgba32abf.bmp",
"_",
"image",
"gen_platf",
"rgb24prof.bmp",
"_",
"image",
"gen_platf",
"rgb24lprof.bmp",
"_",
"image",
"gen_platf",
"8bpp-pixeldata-cropped.bmp",
"_",
"image",
"gen_platf",
"4bpp-pixeldata-cropped.bmp",
"_",
"image",
"gen_platf",
"32bpp-pixeldata-cropped.bmp",
"_",
"image",
"gen_platf",
"24bpp-pixeldata-cropped.bmp",
"_",
"image",
"gen_platf",
"frame_larger_than_image.gif",
"serialize-8888",
"gm",
"_",
"bleed_image",
"serialize-8888",
"gm",
"_",
"c_gms",
"serialize-8888",
"gm",
"_",
"colortype",
"serialize-8888",
"gm",
"_",
"colortype_xfermodes",
"serialize-8888",
"gm",
"_",
"drawfilter",
"serialize-8888",
"gm",
"_",
"fontmgr_bounds_0.75_0",
"serialize-8888",
"gm",
"_",
"fontmgr_bounds_1_-0.25",
"serialize-8888",
"gm",
"_",
"fontmgr_bounds",
"serialize-8888",
"gm",
"_",
"fontmgr_match",
"serialize-8888",
"gm",
"_",
"fontmgr_iter",
"sp-8888",
"gm",
"_",
"drawfilter",
"pic-8888",
"gm",
"_",
"drawfilter",
"2ndpic-8888",
"gm",
"_",
"drawfilter",
"sp-8888",
"gm",
"_",
"image-cacherator-from-picture",
"pic-8888",
"gm",
"_",
"image-cacherator-from-picture",
"2ndpic-8888",
"gm",
"_",
"image-cacherator-from-picture",
"serialize-8888",
"gm",
"_",
"image-cacherator-from-picture",
"sp-8888",
"gm",
"_",
"image-cacherator-from-raster",
"pic-8888",
"gm",
"_",
"image-cacherator-from-raster",
"2ndpic-8888",
"gm",
"_",
"image-cacherator-from-raster",
"serialize-8888",
"gm",
"_",
"image-cacherator-from-raster",
"sp-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"pic-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"2ndpic-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"serialize-8888",
"gm",
"_",
"image-cacherator-from-ctable",
"_",
"image",
"_",
"interlaced1.png",
"_",
"image",
"_",
"interlaced2.png",
"_",
"image",
"_",
"interlaced3.png",
"_",
"image",
"_",
".arw",
"_",
"image",
"_",
".cr2",
"_",
"image",
"_",
".dng",
"_",
"image",
"_",
".nef",
"_",
"image",
"_",
".nrw",
"_",
"image",
"_",
".orf",
"_",
"image",
"_",
".raf",
"_",
"image",
"_",
".rw2",
"_",
"image",
"_",
".pef",
"_",
"image",
"_",
".srw",
"_",
"image",
"_",
".ARW",
"_",
"image",
"_",
".CR2",
"_",
"image",
"_",
".DNG",
"_",
"image",
"_",
".NEF",
"_",
"image",
"_",
".NRW",
"_",
"image",
"_",
".ORF",
"_",
"image",
"_",
".RAF",
"_",
"image",
"_",
".RW2",
"_",
"image",
"_",
".PEF",
"_",
"image",
"_",
".SRW"
],
"Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer": [
"--config",
"commandbuffer",

View File

@ -90,6 +90,16 @@ def get_args(bot):
if 'GalaxyS3' in bot:
configs.append('gpudft')
# Test instanced rendering on a limited number of platforms
if 'Nexus6' in bot:
configs.append('esinst') # esinst4 isn't working yet on Adreno.
elif 'TegraX1' in bot:
# Multisampled instanced configs use nvpr.
configs = [x.replace('glnvpr', 'glinst') for x in configs]
configs.append('glinst')
elif 'MacMini6.2' in bot:
configs.extend(['glinst', 'glinst16'])
# CommandBuffer bot *only* runs the command_buffer config.
if 'CommandBuffer' in bot:
configs = ['commandbuffer']
@ -303,6 +313,7 @@ def self_test():
'Test-Android-GCC-AndroidOne-GPU-Mali400MP2-Arm7-Release',
'Test-Android-GCC-GalaxyS3-GPU-Mali400-Arm7-Debug',
'Test-Android-GCC-GalaxyS4-GPU-SGX544-Arm7-Release',
'Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug',
'Test-Android-GCC-Nexus7-GPU-Tegra3-Arm7-Release',
'Test-Android-GCC-Nexus9-GPU-TegraK1-Arm64-Debug',
'Test-Android-GCC-Nexus10-GPU-MaliT604-Arm7-Debug',
@ -310,6 +321,7 @@ def self_test():
'Test-Android-GCC-NVIDIA_Shield-GPU-TegraX1-Arm64-Release',
'Test-Mac-Clang-MacMini4.1-GPU-GeForce320M-x86_64-Release',
'Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug-CommandBuffer',
'Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug',
'Test-Mac10.8-Clang-MacMini4.1-CPU-SSE4-x86_64-Release',
'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-MSAN',
'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN',

View File

@ -29,6 +29,7 @@ static const char configHelp[] =
"Options: 565 8888 debug gpu gl gpudebug gpudft gpunull "
"msaa16 msaa4 glmsaa4 gpuf16 gpusrgb glsrgb nonrendering null nullgpu "
"nvpr16 nvpr4 nvprdit16 nvprdit4 glnvpr4 glnvprdit4 pdf skp svg xps"
"glinst glinst4 glinstdit4 glinst16 glinstdit16 esinst esinst4 esinsdit4"
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
" angle"
@ -54,7 +55,7 @@ static const char configExtendedHelp[] =
"Possible backends and options:\n"
#if SK_SUPPORT_GPU
"\n"
"gpu(api=string,color=string,dit=bool,nvpr=bool,samples=int)\tGPU backend\n"
"gpu(api=string,color=string,dit=bool,nvpr=bool,inst=bool,samples=int)\tGPU backend\n"
"\tapi\ttype: string\tdefault: native.\n"
"\t Select graphics API to use with gpu backend.\n"
"\t Options:\n"
@ -149,6 +150,14 @@ static const struct {
{ "nvprdit4", "gpu", "nvpr=true,samples=4,dit=true" },
{ "glnvprdit4", "gpu", "api=gl,nvpr=true,samples=4,dit=true" },
{ "nvprdit16", "gpu", "nvpr=true,samples=16,dit=true" },
{ "glinst", "gpu", "api=gl,inst=true" },
{ "glinst4", "gpu", "api=gl,inst=true,samples=4" },
{ "glinstdit4", "gpu", "api=gl,inst=true,samples=4,dit=true" },
{ "glinst16", "gpu", "api=gl,inst=true,samples=16" },
{ "glinstdit16", "gpu", "api=gl,inst=true,samples=16,dit=true" },
{ "esinst", "gpu", "api=gles,inst=true" },
{ "esinst4", "gpu", "api=gles,inst=true,samples=4" },
{ "esinstdit4", "gpu", "api=gles,inst=true,samples=4,dit=true" },
{ "gpuf16", "gpu", "color=f16" },
{ "gpusrgb", "gpu", "color=srgb" },
{ "glsrgb", "gpu", "api=gl,color=srgb" },
@ -190,12 +199,13 @@ SkCommandLineConfig::~SkCommandLineConfig() {
#if SK_SUPPORT_GPU
SkCommandLineConfigGpu::SkCommandLineConfigGpu(
const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useDIText, int samples,
SkColorType colorType, sk_sp<SkColorSpace> colorSpace)
const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR,
bool useInstanced, bool useDIText, int samples, SkColorType colorType,
sk_sp<SkColorSpace> colorSpace)
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
, fContextType(contextType)
, fUseNVPR(useNVPR)
, fUseInstanced(useInstanced)
, fUseDIText(useDIText)
, fSamples(samples)
, fColorType(colorType)
@ -303,6 +313,8 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
SkCommandLineConfigGpu::ContextType contextType = GrContextFactory::kNativeGL_ContextType;
bool seenUseNVPR = false;
bool useNVPR = false;
bool seenUseInstanced = false;
bool useInstanced = false;
bool seenUseDIText =false;
bool useDIText = false;
bool seenSamples = false;
@ -328,6 +340,9 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
} else if (key.equals("nvpr") && !seenUseNVPR) {
valueOk = parse_option_bool(value, &useNVPR);
seenUseNVPR = true;
} else if (key.equals("inst") && !seenUseInstanced) {
valueOk = parse_option_bool(value, &useInstanced);
seenUseInstanced = true;
} else if (key.equals("dit") && !seenUseDIText) {
valueOk = parse_option_bool(value, &useDIText);
seenUseDIText = true;
@ -342,8 +357,8 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
return nullptr;
}
}
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, samples,
colorType, colorSpace);
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstanced, useDIText,
samples, colorType, colorSpace);
}
#endif

View File

@ -52,11 +52,12 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
public:
typedef sk_gpu_test::GrContextFactory::ContextType ContextType;
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useDIText, int samples,
SkColorType colorType, sk_sp<SkColorSpace> colorSpace);
ContextType contextType, bool useNVPR, bool useInstanced, bool useDIText,
int samples, SkColorType colorType, sk_sp<SkColorSpace> colorSpace);
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
ContextType getContextType() const { return fContextType; }
bool getUseNVPR() const { return fUseNVPR; }
bool getUseInstanced() const { return fUseInstanced; }
bool getUseDIText() const { return fUseDIText; }
int getSamples() const { return fSamples; }
SkColorType getColorType() const { return fColorType; }
@ -65,6 +66,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
private:
ContextType fContextType;
bool fUseNVPR;
bool fUseInstanced;
bool fUseDIText;
int fSamples;
SkColorType fColorType;

View File

@ -31,6 +31,8 @@ GrContextFactory::GrContextFactory() { }
GrContextFactory::GrContextFactory(const GrContextOptions& opts)
: fGlobalOptions(opts) {
// In this factory, instanced rendering is specified with kUseInstanced_ContextOptions.
SkASSERT(!fGlobalOptions.fEnableInstancedRendering);
}
GrContextFactory::~GrContextFactory() {
@ -150,8 +152,9 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
}
testCtx.reset(glCtx);
glInterface.reset(SkRef(glCtx->gl()));
// Block NVPR from non-NVPR types.
if (!(kEnableNVPR_ContextOptions & options)) {
// Block NVPR from non-NVPR types. We don't block NVPR from contexts that will use
// instanced rendering because that would prevent us from testing mixed samples.
if (!((kEnableNVPR_ContextOptions | kUseInstanced_ContextOptions) & options)) {
glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get()));
if (!glInterface) {
return ContextInfo();
@ -188,7 +191,11 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
}
testCtx->makeCurrent();
SkASSERT(testCtx && testCtx->backend() == backend);
grCtx.reset(GrContext::Create(backend, backendContext, fGlobalOptions));
GrContextOptions grOptions = fGlobalOptions;
if (kUseInstanced_ContextOptions & options) {
grOptions.fEnableInstancedRendering = true;
}
grCtx.reset(GrContext::Create(backend, backendContext, grOptions));
if (!grCtx.get()) {
return ContextInfo();
}
@ -197,6 +204,11 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op
return ContextInfo();
}
}
if (kUseInstanced_ContextOptions & options) {
if (GrCaps::InstancedSupport::kNone == grCtx->caps()->instancedSupport()) {
return ContextInfo();
}
}
if (kRequireSRGBSupport_ContextOptions & options) {
if (!grCtx->caps()->srgbSupport()) {
return ContextInfo();

View File

@ -92,7 +92,8 @@ public:
enum ContextOptions {
kNone_ContextOptions = 0x0,
kEnableNVPR_ContextOptions = 0x1,
kRequireSRGBSupport_ContextOptions = 0x2,
kUseInstanced_ContextOptions = 0x2,
kRequireSRGBSupport_ContextOptions = 0x4,
};
static ContextType NativeContextTypeForBackend(GrBackend backend) {

View File

@ -342,6 +342,8 @@ private:
return nullptr;
}
gr_instanced::InstancedRendering* onCreateInstancedRendering() override { return nullptr; }
bool onReadPixels(GrSurface* surface,
int left, int top, int width, int height,
GrPixelConfig,

View File

@ -68,6 +68,8 @@
"glmsaa4",
"glnvpr4",
"glnvprdit4",
"glinst",
"glinst4",
"--match",
"~blurroundrect",
"~patch_grid",
@ -197,6 +199,7 @@
"msaa4",
"nvpr4",
"nvprdit4",
"esinst",
"--match",
"~blurroundrect",
"~patch_grid",
@ -353,6 +356,99 @@
"~inc0.webp",
"~inc1.webp"
],
"Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug": [
"--pre_log",
"--images",
"--gpuStatsDump",
"true",
"--useThermalManager",
"1,1,10,1000",
"--scales",
"1.0",
"1.1",
"--config",
"565",
"8888",
"gpu",
"nonrendering",
"angle",
"hwui",
"f16",
"srgb",
"msaa4",
"nvpr4",
"nvprdit4",
"esinst",
"--match",
"~blurroundrect",
"~patch_grid",
"~desk_carsvg",
"~inc0.gif",
"~inc1.gif",
"~incInterlaced.gif",
"~inc0.jpg",
"~incGray.jpg",
"~inc0.wbmp",
"~inc1.wbmp",
"~inc0.webp",
"~inc1.webp",
"~inc0.ico",
"~inc1.ico",
"~inc0.png",
"~inc1.png",
"~inc2.png",
"~inc12.png",
"~inc13.png",
"~inc14.png",
"~inc0.webp",
"~inc1.webp"
],
"Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug": [
"--pre_log",
"--images",
"--gpuStatsDump",
"true",
"--scales",
"1.0",
"1.1",
"--config",
"565",
"8888",
"gpu",
"nonrendering",
"angle",
"hwui",
"f16",
"srgb",
"msaa16",
"nvpr16",
"nvprdit16",
"glinst",
"glinst16",
"--match",
"~interlaced1.png",
"~interlaced2.png",
"~interlaced3.png",
"~inc0.gif",
"~inc1.gif",
"~incInterlaced.gif",
"~inc0.jpg",
"~incGray.jpg",
"~inc0.wbmp",
"~inc1.wbmp",
"~inc0.webp",
"~inc1.webp",
"~inc0.ico",
"~inc1.ico",
"~inc0.png",
"~inc1.png",
"~inc2.png",
"~inc12.png",
"~inc13.png",
"~inc14.png",
"~inc0.webp",
"~inc1.webp"
],
"Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind": [
"--pre_log",
"--images",

View File

@ -58,6 +58,14 @@ def get_args(bot):
else:
config.extend(['msaa16', 'nvpr16', 'nvprdit16'])
# Bench instanced rendering on a limited number of platforms
if 'Nexus6' in bot:
config.append('esinst') # esinst4 isn't working yet on Adreno.
elif 'TegraX1' in bot:
config.extend(['glinst', 'glinst4'])
elif 'MacMini6.2' in bot:
config.extend(['glinst', 'glinst16'])
if 'Vulkan' in bot:
config = ['vk']
@ -147,9 +155,11 @@ def self_test():
args = {}
cases = [
'Perf-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Release',
'Test-Android-GCC-Nexus6-GPU-Adreno420-Arm7-Debug',
'Perf-Android-Nexus7-Tegra3-Arm7-Release',
'Perf-Android-GCC-NexusPlayer-GPU-PowerVR-x86-Release',
'Perf-Android-GCC-GalaxyS3-GPU-Mali400-Arm7-Release',
'Test-Mac-Clang-MacMini6.2-GPU-HD4000-x86_64-Debug',
'Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind',
'Test-Win7-MSVC-ShuttleA-GPU-HD2000-x86-Debug-ANGLE',
'Test-iOS-Clang-iPad4-GPU-SGX554-Arm7-Debug',