Functions related to primitive assembly.
More...
|
| file | primitive_assembly.c |
| |
| file | primitive_assembly.h |
| |
| file | topology.c |
| |
| file | topology.h |
| |
| static void | warnOnExcessVertexCount (const SRPIndexBuffer *ib, const SRPVertexBuffer *vb, SRPPrimitive prim, size_t startIndex, size_t vertexCount) |
| |
| static void | resolvePolygonModeOutput (size_t *nOutPrimitivesPerClippedTriangle, size_t *sizeOutPrimitive) |
| |
| bool | assembleLines (const SRPIndexBuffer *ib, const SRPVertexBuffer *vb, const SRPFramebuffer *fb, const SRPShaderProgram *sp, SRPPrimitive prim, size_t startIndex, size_t vertexCount, size_t *outLineCount, SRPLine **outLines) |
| |
| bool | assemblePoints (const SRPIndexBuffer *ib, const SRPVertexBuffer *vb, const SRPFramebuffer *fb, const SRPShaderProgram *sp, size_t startIndex, size_t count, size_t *outPointCount, SRPPoint **outPoints) |
| |
| bool | assembleTrianglesGeneric (const SRPIndexBuffer *ib, const SRPVertexBuffer *vb, const SRPFramebuffer *fb, const SRPShaderProgram *sp, SRPPrimitive prim, size_t startIndex, size_t vertexCount, size_t *outCount, void **outPrimitives) |
| |
| size_t | computeTriangleCount (size_t vertexCount, SRPPrimitive prim) |
| |
| void | resolveTriangleTopology (size_t base, size_t rawTriIdx, SRPPrimitive prim, size_t *out) |
| |
| size_t | computeLineCount (size_t vertexCount, SRPPrimitive prim) |
| |
| void | resolveLineTopology (size_t base, size_t rawLineIdx, SRPPrimitive prim, size_t vertexCount, size_t *out) |
| |
Functions related to primitive assembly.
◆ assembleLines()
Call the vertex shader and assemble lines from vertex or index buffer. If ib == NULL, assembles from vertex buffer, else from index buffer. Uses memory from SRPArena, so the returned points are valid until the next call to arenaReset().
- Parameters
-
| [in] | ib | Pointer to index buffer, or NULL if assembling from vertex buffer |
| [in] | vb | Pointer to vertex buffer |
| [in] | fb | Pointer to the framebuffer to draw to (needed for NDC to screen-space conversion) |
| [in] | sp | Pointer to the shader program to use |
| [in] | primitive | Primitive type (one of SRP_PRIM_LINES, SRP_PRIM_LINE_STRIP or SRP_PRIM_LINE_LOOP) |
| [in] | startIndex | First stream index to assemble |
| [in] | count | Number of stream indices to assemble |
| [out] | outLineCount | Amount of assembled lines |
| [out] | outLines | Pointer to the array of count assembled lines |
- Returns
true if successful, false otherwise. If false if returned, *outLineCount and *outLines are undefined
◆ assemblePoints()
Call the vertex shader and assemble points from vertex or index buffer. If ib == NULL, assembles from vertex buffer, else from index buffer. Uses memory from SRPArena, so the returned points are valid until the next call to arenaReset().
- Parameters
-
| [in] | ib | Pointer to index buffer, or NULL if assembling from vertex buffer |
| [in] | vb | Pointer to vertex buffer |
| [in] | fb | Pointer to the framebuffer to draw to (needed for NDC to screen-space conversion) |
| [in] | sp | Pointer to the shader program to use |
| [in] | startIndex | First stream index to assemble |
| [in] | count | Number of stream indices to assemble |
| [out] | outPointCount | Amount of assembled points |
| [out] | outPoints | Pointer to the array of count assembled points |
- Returns
true if successful, false otherwise. If false if returned, *outPointCount and *outPoints are undefined
◆ assembleTrianglesGeneric()
Call the vertex shader and assemble triangles from vertex or index buffer, possibly converting them to lines or points according to the set polygon mode. If ib == NULL, assembles from vertex buffer, else from index buffer. Uses memory from SRPArena, so the returned triangles are valid until the next call to arenaReset().
- Parameters
-
| [in] | ib | Pointer to index buffer, or NULL if assembling from vertex buffer |
| [in] | vb | Pointer to vertex buffer |
| [in] | fb | Pointer to the framebuffer to draw to (needed for NDC to screen-space conversion) |
| [in] | sp | Pointer to the shader program to use |
| [in] | prim | Primitive type (one of SRP_PRIM_TRIANGLES, SRP_PRIM_TRIANGLE_STRIP or SRP_PRIM_TRIANGLE_FAN) |
| [in] | startIndex | First stream index to assemble |
| [in] | vertexCount | Number of stream indices to assemble |
| [out] | outCount | Amount of assembled primitives |
| [out] | outPrimitives | Pointer to the array of assembled primitives |
- Returns
true if successful, false otherwise. If false is returned, *outCount and *outPrimitives are 0 and NULL
◆ computeLineCount()
| size_t computeLineCount |
( |
size_t |
vertexCount, |
|
|
SRPPrimitive |
prim |
|
) |
| |
Deduce the number of lines to assemble based on the number of vertices and primitive type
- Parameters
-
| [in] | vertexCount | Number of vertices |
| [in] | prim | Primitive type |
- Returns
- Number of lines that should be assembled
◆ computeTriangleCount()
| size_t computeTriangleCount |
( |
size_t |
vertexCount, |
|
|
SRPPrimitive |
prim |
|
) |
| |
Deduce the number of triangles to assemble based on the number of vertices and primitive type
- Parameters
-
| [in] | vertexCount | Number of vertices |
| [in] | prim | Primitive type |
- Returns
- Number of triangles that should be assembled
◆ resolveLineTopology()
| void resolveLineTopology |
( |
size_t |
base, |
|
|
size_t |
rawLineIdx, |
|
|
SRPPrimitive |
prim, |
|
|
size_t |
vertexCount, |
|
|
size_t * |
out |
|
) |
| |
Determine the stream indices for a line based on its type
- Parameters
-
| [in] | base | Base stream index |
| [in] | rawLineIdx | Index of the primitive to assemble, starting from 0, including culled/skipped lines |
| [in] | prim | Primitive type |
| [in] | vertexCount | The total amount of stream vertices for this draw call |
| [out] | out | Array of size 2 to store the resulting stream indices |
◆ resolvePolygonModeOutput()
| static void resolvePolygonModeOutput |
( |
size_t * |
nOutPrimitivesPerClippedTriangle, |
|
|
size_t * |
sizeOutPrimitive |
|
) |
| |
|
static |
Calculate constants for triangle assembly
- Parameters
-
| [out] | nOutPrimitivesPerClippedTriangle | How many primitives end up from a clipped triangle |
| [out] | sizeOutPrimitive | The size of an output primitive (in bytes) |
◆ resolveTriangleTopology()
| void resolveTriangleTopology |
( |
size_t |
base, |
|
|
size_t |
rawTriIdx, |
|
|
SRPPrimitive |
prim, |
|
|
size_t * |
out |
|
) |
| |
Determine the stream indices for a triangle based on its type
- Parameters
-
| [in] | base | Base stream index |
| [in] | rawTriIdx | Index of the primitive to assemble, starting from 0, including culled triangles |
| [in] | prim | Primitive type |
| [out] | out | Array of size 3 to store the resulting stream indices |
◆ warnOnExcessVertexCount()
Check if there are excess vertices when drawing some kind of primitive, send a warning if so
- See also
- assembleTriangles() for parameter documentation