Class GeometryStep
- Direct Known Subclasses:
AnalyticArcStep,AnalyticComplexBoxStep,AnalyticSimpleBoxStep,CoverBoundsStep,PerEdgeAAQuadStep,RasterTextStep,VerticesStep
There are two feedback loops between the FragmentProcessors, the XferProcessor, and the GeometryProcessor. These loops run on the CPU and to determine known properties of the final color and coverage inputs to the XferProcessor in order to perform optimizations that preserve correctness. The DrawOp seeds these loops with initial color and coverage, in its getProcessorAnalysisInputs implementation. These seed values are processed by the subsequent stages of the rendering pipeline and the output is then fed back into the DrawOp in the applyPipelineOptimizations call, where the op can use the information to inform decisions about GeometryProcessor creation.
Note that all derived classes should hide their constructors and provide a Make factory function that takes an arena (except for Tesselation-specific classes). This is because geometry processors can be created in either the record-time or flush-time arenas which define their lifetimes (i.e., a DDLs life time in the first case and a single flush in the second case).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classEveryGeometryStepmust be capable of creating a subclass of ProgramImpl. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final VertexInputLayout.AttributePainter's depth.static final intSet if there'semitFragmentCoverageCode(Formatter, String).static final intSet if this emits per-vertex color, only used for drawing primitives.static final intSet if this can handle solid color from paint params, and draw op does not require any uniform values.static final intstatic final intSet for analytic antialiasing (AAA) or distance-to-edge antialiasing (DEAA).static final intSet if there's fragment shader code and color output, otherwise this is a depth-stencil only step.static final VertexInputLayout.AttributeLocal-to-device transform.static final VertexInputLayout.AttributePre-multiplied solid color in destination color space. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGeometryStep(@NonNull String className, @NonNull String variantName, @Nullable VertexInputLayout.AttributeSet vertexAttributes, @Nullable VertexInputLayout.AttributeSet instanceAttributes, int flags, byte primitiveType, DepthStencilSettings depthStencilSettings) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidappendAttributesToKey(@NonNull KeyBuilder b) abstract voidappendToKey(@NonNull KeyBuilder b) Appends a key on the KeyBuilder that reflects any variety in the code that the geometry processor subclass can emit.final intfinal DepthStencilSettingsvoidemitFragmentColorCode(Formatter fs, String outputColor) Emits the fragment color code into the fragment shader.voidemitFragmentCoverageCode(Formatter fs, String outputCoverage) Emits the fragment coverage code into the fragment shader.voidvoidemitSamplers(UniformHandler uniformHandler) final booleanfinal booleanvoidemitUniforms(UniformHandler uniformHandler, boolean mayRequireLocalCoords) voidemitVaryings(VaryingHandler varyingHandler, boolean usesFastSolidColor) voidvoidemitVertexGeomCode(Formatter vs, @NonNull String worldPosVar, @Nullable String localPosVar, boolean usesFastSolidColor) Emits the geometry code into the vertex shader.final booleanfinal booleanReturns true ifnumInstanceAttributes()will return non-zero.final booleanReturns true ifnumVertexAttributes()will return non-zero.final @NonNull Iterator<VertexInputLayout.Attribute> Returns an iterable of used per-instance attributes.final intfinal intReturns the number of bytes from one instance to the next instance, including paddings.protected static @NonNull VertexInputLayout.AttributemakeColorAttribute(String name, boolean wideColor) GPs that need to use either float or ubyte colors can just call this to get a correctly configured Attribute structabstract @NonNull GeometryStep.ProgramImplmakeProgramImpl(ShaderCaps caps) Returns a new instance of the appropriate implementation class for the given GeometryProcessor.final @NonNull Stringname()Human-meaningful string to identify this processor; may be embedded in generated shader code and must be a legal AkSL identifier prefix.final intReturns the number of used per-instance attributes (input variables).final intReturns the number of used per-instance attribute locations.intCurrently, GP is limited to one texture sampler at most.final intReturns the number of used per-vertex attributes (input variables).final intReturns the number of used per-vertex attribute locations (slots).final booleanfinal byteReturns a primitive topology for render passes.inttextureSamplerState(int i) Used to capture the properties of the TextureProxies required/expected by a GeometryProcessor along with an associated SamplerState.shorttextureSamplerSwizzle(int i) final intuniqueID()final @NonNull Iterator<VertexInputLayout.Attribute> Returns an iterable of used per-vertex attributes.final intfinal intReturns the number of bytes from one vertex to the next vertex, including paddings.voidwriteMesh(MeshDrawWriter writer, Draw draw, float @Nullable [] solidColor, boolean mayRequireLocalCoords) voidwriteUniformsAndTextures(RecordingContext context, Draw draw, UniformDataGatherer uniformDataGatherer, TextureDataGatherer textureDataGatherer, boolean mayRequireLocalCoords)
-
Field Details
-
DEPTH
Painter's depth. -
SOLID_COLOR
Pre-multiplied solid color in destination color space. -
MODEL_VIEW
Local-to-device transform. -
FLAG_PERFORM_SHADING
public static final int FLAG_PERFORM_SHADINGSet if there's fragment shader code and color output, otherwise this is a depth-stencil only step.- See Also:
-
FLAG_HAS_TEXTURES
public static final int FLAG_HAS_TEXTURES- See Also:
-
FLAG_EMIT_COVERAGE
public static final int FLAG_EMIT_COVERAGESet if there'semitFragmentCoverageCode(Formatter, String).- See Also:
-
FLAG_OUTSET_BOUNDS_FOR_AA
public static final int FLAG_OUTSET_BOUNDS_FOR_AASet for analytic antialiasing (AAA) or distance-to-edge antialiasing (DEAA).- See Also:
-
FLAG_EMIT_PRIMITIVE_COLOR
public static final int FLAG_EMIT_PRIMITIVE_COLORSet if this emits per-vertex color, only used for drawing primitives.Not compatible with
FLAG_HANDLE_SOLID_COLOR,FLAG_EMIT_COVERAGE,FLAG_OUTSET_BOUNDS_FOR_AA.- See Also:
-
FLAG_HANDLE_SOLID_COLOR
public static final int FLAG_HANDLE_SOLID_COLORSet if this can handle solid color from paint params, and draw op does not require any uniform values.See
emitFragmentColorCode(Formatter, String)andwriteMesh(MeshDrawWriter, Draw, float[], boolean).Not compatible with
FLAG_EMIT_PRIMITIVE_COLOR.- See Also:
-
-
Constructor Details
-
GeometryStep
protected GeometryStep(@NonNull String className, @NonNull String variantName, @Nullable VertexInputLayout.AttributeSet vertexAttributes, @Nullable VertexInputLayout.AttributeSet instanceAttributes, int flags, byte primitiveType, DepthStencilSettings depthStencilSettings)
-
-
Method Details
-
makeColorAttribute
protected static @NonNull VertexInputLayout.Attribute makeColorAttribute(String name, boolean wideColor) GPs that need to use either float or ubyte colors can just call this to get a correctly configured Attribute struct -
name
Human-meaningful string to identify this processor; may be embedded in generated shader code and must be a legal AkSL identifier prefix. -
uniqueID
public final int uniqueID()- Returns:
- unique ID that identifies this processor class.
-
primitiveType
public final byte primitiveType()Returns a primitive topology for render passes. If the return values of different instances are different, they must be reflected in the key, seeappendToKey(KeyBuilder).- See Also:
-
numTextureSamplers
public int numTextureSamplers()Currently, GP is limited to one texture sampler at most. -
textureSamplerState
public int textureSamplerState(int i) Used to capture the properties of the TextureProxies required/expected by a GeometryProcessor along with an associated SamplerState. The actual proxies used are stored in either the fixed or dynamic state arrays. TextureSamplers don't perform any coord manipulation to account for texture origin.- See Also:
-
textureSamplerSwizzle
public short textureSamplerSwizzle(int i) - See Also:
-
getInputLayout
-
hasVertexAttributes
public final boolean hasVertexAttributes()Returns true ifnumVertexAttributes()will return non-zero.- Returns:
- true if there are per-vertex attributes
-
vertexBinding
public final int vertexBinding() -
numVertexAttributes
public final int numVertexAttributes()Returns the number of used per-vertex attributes (input variables). Note: attribute of a matrix type counts as just one.- See Also:
-
numVertexLocations
public final int numVertexLocations()Returns the number of used per-vertex attribute locations (slots). An attribute (variable) may take up multiple consecutive locations.- See Also:
-
vertexAttributes
Returns an iterable of used per-vertex attributes. It's safe to call even if there's no attribute. The iterator handles hides two pieces of complexity:- It skips unused attributes (see mask in
).
invalid reference
#setVertexAttributes(int) - It always returns an attribute with a known offset.
- It skips unused attributes (see mask in
-
vertexStride
public final int vertexStride()Returns the number of bytes from one vertex to the next vertex, including paddings. A common practice is to populate the vertex's memory using an implicit array of structs. In this case, it is best to assert that: stride == sizeof(struct). -
hasInstanceAttributes
public final boolean hasInstanceAttributes()Returns true ifnumInstanceAttributes()will return non-zero.- Returns:
- true if there are per-instance attributes
-
instanceBinding
public final int instanceBinding() -
numInstanceAttributes
public final int numInstanceAttributes()Returns the number of used per-instance attributes (input variables). Note: attribute of a matrix type counts as just one.- See Also:
-
numInstanceLocations
public final int numInstanceLocations()Returns the number of used per-instance attribute locations. (slots). An attribute (variable) may take up multiple consecutive locations.- See Also:
-
instanceAttributes
Returns an iterable of used per-instance attributes. It's safe to call even if there's no attribute. The iterator handles hides two pieces of complexity:- It skips unused attributes (see mask in
).
invalid reference
#setInstanceAttributes(int) - It always returns an attribute with a known offset.
- It skips unused attributes (see mask in
-
instanceStride
public final int instanceStride()Returns the number of bytes from one instance to the next instance, including paddings. A common practice is to populate the instance's memory using an implicit array of structs. In this case, it is best to assert that: stride == sizeof(struct). -
performsShading
public final boolean performsShading() -
emitsCoverage
public final boolean emitsCoverage() -
handlesSolidColor
public final boolean handlesSolidColor() -
emitsPrimitiveColor
public final boolean emitsPrimitiveColor() -
depthStencilSettings
-
depthStencilFlags
public final int depthStencilFlags() -
appendToKey
Appends a key on the KeyBuilder that reflects any variety in the code that the geometry processor subclass can emit.- See Also:
-
appendAttributesToKey
-
makeProgramImpl
Returns a new instance of the appropriate implementation class for the given GeometryProcessor. This method is called only when the specified key does not exist in the program cache.- See Also:
-
emitVaryings
-
emitUniforms
-
emitSamplers
-
emitVertexDefinitions
-
emitVertexGeomCode
public void emitVertexGeomCode(Formatter vs, @NonNull String worldPosVar, @Nullable String localPosVar, boolean usesFastSolidColor) Emits the geometry code into the vertex shader. Implementation must define "vec4 worldPosVar" with the given name and setup it. If localPosVar is not null, then it must write geometry's local pos to it. -
emitFragmentDefinitions
-
emitFragmentColorCode
Emits the fragment color code into the fragment shader. This is either paint's solid color or per-vertex primitive color. SeeFLAG_HANDLE_SOLID_COLORandFLAG_EMIT_PRIMITIVE_COLOR. -
emitFragmentCoverageCode
Emits the fragment coverage code into the fragment shader.If
emitsCoverage()is false, this method is called for hard-edge coverage, discard the fragment if coverage is 0. Otherwise outputCoverage is non-null, and coverage will involve in blending operations. -
writeMesh
public void writeMesh(MeshDrawWriter writer, Draw draw, float @Nullable [] solidColor, boolean mayRequireLocalCoords) -
writeUniformsAndTextures
public void writeUniformsAndTextures(RecordingContext context, Draw draw, UniformDataGatherer uniformDataGatherer, TextureDataGatherer textureDataGatherer, boolean mayRequireLocalCoords)
-