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 15:49:11 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2016-10-28 17:25:24 +00:00
|
|
|
#include "GrRenderTargetProxy.h"
|
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 15:49:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides info about the pipeline that GrInstancedRendering needs in order to select appropriate
|
|
|
|
* drawing algorithms.
|
|
|
|
*/
|
|
|
|
struct GrInstancedPipelineInfo {
|
2016-10-28 17:25:24 +00:00
|
|
|
GrInstancedPipelineInfo(const GrRenderTargetProxy* rtp)
|
|
|
|
: fIsMultisampled(rtp->isStencilBufferMultisampled())
|
|
|
|
, fIsMixedSampled(rtp->isMixedSampled())
|
|
|
|
, fIsRenderingToFloat(GrPixelConfigIsFloatingPoint(rtp->desc().fConfig))
|
|
|
|
, fColorDisabled(false)
|
|
|
|
, fDrawingShapeToStencil(false)
|
|
|
|
, fCanDiscard(false) {
|
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 15:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|