Skip to content

Commit

Permalink
dun_render: Specialized FullyDark+Solid triangles
Browse files Browse the repository at this point in the history
Eliminates regression in the rendering speed of such triangles.
  • Loading branch information
glebm committed Aug 19, 2024
1 parent b410b85 commit 4f18b24
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Source/engine/render/dun_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,19 @@ DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderTriangleLower(uint8_t *DVL_RESTRI
dst -= 16 * dstLineOffset;
}

template <>
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderTriangleLower<LightType::FullyDark, /*Transparent=*/false>(uint8_t *DVL_RESTRICT &dst, ptrdiff_t dstLineOffset, const uint8_t *DVL_RESTRICT &src, [[maybe_unused]] const uint8_t *DVL_RESTRICT tbl)
{
unsigned width = XStep;
for (unsigned i = 0; i < LowerHeight; ++i) {
BlitFillDirect(dst, width, 0);
dst -= dstLineOffset;
width += XStep;
}
src += 272;
dst -= 16 * dstLineOffset;
}

template <LightType Light, bool Transparent>
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderTriangleUpper(uint8_t *DVL_RESTRICT dst, ptrdiff_t dstLineOffset, const uint8_t *DVL_RESTRICT src, const uint8_t *DVL_RESTRICT tbl)
{
Expand All @@ -515,6 +528,17 @@ DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderTriangleUpper(uint8_t *DVL_RESTRI
RenderLineTransparentOrOpaque<Light, Transparent>(dst - 14 * dstLineOffset, src + 238, 2, tbl);
}

template <>
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderTriangleUpper<LightType::FullyDark, /*Transparent=*/false>(uint8_t *DVL_RESTRICT dst, ptrdiff_t dstLineOffset, [[maybe_unused]] const uint8_t *DVL_RESTRICT src, [[maybe_unused]] const uint8_t *DVL_RESTRICT tbl)
{
unsigned width = XStep;
for (unsigned i = 0; i < LowerHeight; ++i) {
BlitFillDirect(dst, width, 0);
dst -= dstLineOffset;
width += XStep;
}
}

template <LightType Light, bool Transparent>
DVL_ALWAYS_INLINE DVL_ATTRIBUTE_HOT void RenderLeftTriangleLower(uint8_t *DVL_RESTRICT &dst, uint16_t dstPitch, const uint8_t *DVL_RESTRICT &src, const uint8_t *DVL_RESTRICT tbl)
{
Expand Down

0 comments on commit 4f18b24

Please sign in to comment.