srp
software rendering pipeline
Loading...
Searching...
No Matches
interpolation.c File Reference
#include <string.h>
#include "srp/context.h"
#include "pipeline/interpolation.h"
#include "utils/message_callback_p.h"
#include "utils/voidptr.h"
Include dependency graph for interpolation.c:
#define INTERPOLATE_FLOATING(Type)
 
#define INTERPOLATE_INTEGER(Type)
 
void interpolateDepthAndWTriangle (SRPVertexShaderOut *vertices, const float *weights, const float *invW, const SRPShaderProgram *sp, float *depth, float *reciprocalInterpolatedInvW)
 
void interpolateDepthAndWLine (SRPVertexShaderOut *vertices, const float *weights, const float *invW, const SRPShaderProgram *sp, float *depth, float *reciprocalInterpolatedInvW)
 
void interpolateAttributes (SRPVertexShaderOut *vertices, size_t nVertices, const float *weights, const float *invW, float reciprocalInterpolatedInvW, const SRPShaderProgram *sp, SRPInterpolated *pOutput)
 

Detailed Description

Interpolation implementation

Macro Definition Documentation

◆ INTERPOLATE_FLOATING

#define INTERPOLATE_FLOATING (   Type)
Value:
do { \
elemSize = sizeof(Type); \
Type* interpolated = (Type*) interpolatedVoid; \
for (size_t elemI = 0; elemI < attr->nItems; elemI++) \
{ \
Type value = 0.; \
if (perspective) \
{ \
for (size_t i = 0; i < nVertices; i++) \
value += ((Type*) AV[i])[elemI] * invW[i] * weights[i]; \
value *= reciprocalInterpolatedInvW; \
} \
else if (affine) \
for (size_t i = 0; i < nVertices; i++) \
value += ((Type*) AV[i])[elemI] * weights[i]; \
else /* flat */ \
value = ((Type*) AV[provokingVertex])[elemI]; \
interpolated[elemI] = value; \
} \
} while(0)

Interpolate a floating point type attribute

See also
interpolateAttribute

◆ INTERPOLATE_INTEGER

#define INTERPOLATE_INTEGER (   Type)
Value:
do { \
elemSize = sizeof(Type); \
Type* interpolated = (Type*) interpolatedVoid; \
memcpy(interpolated, AV[provokingVertex], elemSize * attr->nItems); \
} while(0)

Flat-interpolate an integer type attribute

See also
interpolateAttribute

Function Documentation

◆ interpolateAttributes()

void interpolateAttributes ( SRPVertexShaderOut vertices,
size_t  nVertices,
const float *  weights,
const float *  invW,
float  reciprocalInterpolatedInvW,
const SRPShaderProgram sp,
SRPInterpolated pOutput 
)

Interpolate the attributes inside the primitive

Parameters
[in]verticesArray of vertices
[in]nVerticesAmount of passed vertices
[in]weightsArray of barycentric coordinates
[in]invWArray of inverseW values for each corresponding vertex
[in]reciprocalInterpolatedInvWThe reciprocal of interpolated inverse W_clip
[in]spThe SRPShaderProgram being used
[out]pOutputInterpolated vertex attributes

◆ interpolateDepthAndWLine()

void interpolateDepthAndWLine ( SRPVertexShaderOut vertices,
const float *  weights,
const float *  invW,
const SRPShaderProgram sp,
float *  depth,
float *  reciprocalInterpolatedInvW 
)

Interpolate the depth and inverse W values inside the line

Parameters
[in]verticesArray of vertices
[in]weightsArray of barycentric coordinates
[in]invWArray of inverseW values for each corresponding vertex
[in]spThe SRPShaderProgram being used
[out]depthWhere interpolated depth will be stored
[out]reciprocalInterpolatedInvWWhere the reciprocal of interpolated inverse W_clip will be stored