skia2/include/private/GrInstancedPipelineInfo.h
csmartdalton a7f29640f6 Begin instanced rendering for simple shapes
Adds a module that performs instanced rendering and starts using it
for a select subset of draws on Mac GL platforms. The instance
processor can currently handle rects, ovals, round rects, and double
round rects. It can generalize shapes as round rects in order to
improve batching. The instance processor also employs new drawing
algorithms, irrespective of instanced rendering, that improve GPU-side
performance (e.g. sample mask, different triangle layouts, etc.).

This change only scratches the surface of instanced rendering. The
majority of draws still only have one instance. Future work may
include:

 * Passing coord transforms through the texel buffer.
 * Sending FP uniforms through instanced vertex attribs.
 * Using instanced rendering for more draws (stencil writes,
   drawAtlas, etc.).
 * Adding more shapes to the instance processor’s repertoire.
 * Batching draws that have mismatched scissors (analyzing draw
   bounds, inserting clip planes, etc.).
 * Bindless textures.
 * Uber shaders.

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

Committed: https://skia.googlesource.com/skia/+/42eafa4bc00354b132ad114d22ed6b95d8849891
Review-Url: https://codereview.chromium.org/2066993003
2016-07-07 08:49:11 -07:00

50 lines
1.7 KiB
C

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGrInstancedPipelineInfo_DEFINED
#define GrGrInstancedPipelineInfo_DEFINED
#include "GrRenderTarget.h"
/**
* Provides info about the pipeline that GrInstancedRendering needs in order to select appropriate
* drawing algorithms.
*/
struct GrInstancedPipelineInfo {
GrInstancedPipelineInfo(const GrRenderTarget* rt)
: fIsMultisampled(rt->isStencilBufferMultisampled()),
fIsMixedSampled(rt->hasMixedSamples()),
fIsRenderingToFloat(GrPixelConfigIsFloatingPoint(rt->desc().fConfig)),
fColorDisabled(false),
fDrawingShapeToStencil(false),
fCanDiscard(false) {
}
bool canUseCoverageAA() const {
return !fIsMultisampled || (fIsMixedSampled && !fDrawingShapeToStencil);
}
bool fIsMultisampled : 1;
bool fIsMixedSampled : 1;
bool fIsRenderingToFloat : 1;
bool fColorDisabled : 1;
/**
* Indicates that the instanced renderer should take extra precautions to ensure the shape gets
* drawn correctly to the stencil buffer (e.g. no coverage AA). NOTE: this does not mean a
* stencil test is or is not active.
*/
bool fDrawingShapeToStencil : 1;
/**
* Indicates that the instanced renderer can use processors with discard instructions. This
* should not be set if the shader will use derivatives, automatic mipmap LOD, or other features
* that depend on neighboring pixels. Some draws will fail to create if this is not set.
*/
bool fCanDiscard : 1;
};
#endif