Skip to content

Commit

Permalink
Merge pull request #1030 from devnexen/toconstexpr
Browse files Browse the repository at this point in the history
Use `if constexpr` to enforce the static (compile-time) branching by
`SWFeatureLevel` in inner rendering loops of the software renderer
  • Loading branch information
yvt authored Jul 18, 2022
2 parents f754592 + dfefa5d commit f47c997
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Sources/Draw/SWMapRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ namespace spades {
LinePixel px;
px.depth = dist;
#if ENABLE_SSE
if (flevel == SWFeatureLevel::SSE2) {
if constexpr (flevel == SWFeatureLevel::SSE2) {
__m128i m;
uint32_t col = map.GetColorWrapped(x, y, z);
m = _mm_setr_epi32(col, 0, 0, 0);
Expand Down Expand Up @@ -887,7 +887,7 @@ namespace spades {
// though this isn't a problem as long as the color comes
// in the LSB's
#if ENABLE_SSE
if (flevel == SWFeatureLevel::SSE2) {
if constexpr (flevel == SWFeatureLevel::SSE2) {
__m128i m;

if (under == 1) {
Expand Down Expand Up @@ -985,7 +985,7 @@ namespace spades {
// though this isn't a problem as long as the color comes
// in the LSB's
#if ENABLE_SSE
if (flevel == SWFeatureLevel::SSE2) {
if constexpr (flevel == SWFeatureLevel::SSE2) {
__m128i m;

if (under == 1) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Draw/SWModelRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace spades {
SPAssert(normal < 28);
int bright = brights[normal];
#if ENABLE_SSE2
if (lvl == SWFeatureLevel::SSE2) {
if constexpr (lvl == SWFeatureLevel::SSE2) {
auto m = _mm_setr_epi32(color, 0, 0, 0);
auto f = _mm_set1_epi16(bright << 8);

Expand Down

0 comments on commit f47c997

Please sign in to comment.