Skip to content

Commit

Permalink
Micro-optimization: reducing function calls in hot code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hamsham committed Jan 2, 2019
1 parent 3930a12 commit 1856066
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions soft_render/src/SR_VertexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,18 @@ void SR_VertexProcessor::push_fragments(
// Copy all per-vertex coordinates and varyings to the fragment bins which
// will need the data for interpolation
SR_FragmentBin bin;
ls::utils::fast_memcpy(bin.mScreenCoords, screenCoords, sizeof(bin.mScreenCoords));
//ls::utils::fast_memcpy(bin.mScreenCoords, screenCoords, sizeof(bin.mScreenCoords));
bin.mScreenCoords[0] = screenCoords[0];
bin.mScreenCoords[1] = screenCoords[1];
bin.mScreenCoords[2] = screenCoords[2];

bin.mPerspDivide = math::rcp(math::vec4{worldCoords[0][3], worldCoords[1][3], worldCoords[2][3], 1.f});
ls::utils::fast_memcpy(bin.mVaryings, varyings, sizeof(bin.mVaryings));

//ls::utils::fast_memcpy(bin.mVaryings, varyings, sizeof(bin.mVaryings));
for (unsigned i = 0; i < LS_ARRAY_SIZE(bin.mVaryings); ++i)
{
bin.mVaryings[i] = varyings[i];
}

const math::vec4& p0 = screenCoords[0];
const math::vec4& p1 = screenCoords[1];
Expand Down

0 comments on commit 1856066

Please sign in to comment.