Fixed bug 4929 - Software renderer produces bugs when optimizations are turned on with Visual C++ 2019 Konrad I took the liberty of rewriting this function a bit as it seemed to be unnecessary extended with ifs regarding flags (we can check everything in one pass which seem to be the thing which confuses Visual C++ 2019 as well). Also, I have made CPU features an int instead of uint because if we check it against flags which are all ints it might as well just be int (no signed/unsigned bitwise comparison).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c
index 361e7de..8a14e5b 100644
--- a/src/video/SDL_blit.c
+++ b/src/video/SDL_blit.c
@@ -128,11 +128,11 @@ static SDL_BlitFunc
SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
SDL_BlitFuncEntry * entries)
{
- int i, flagcheck;
- static Uint32 features = 0xffffffff;
+ int i, flagcheck = (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_COLORKEY | SDL_COPY_NEAREST));
+ static int features = 0x7fffffff;
/* Get the available CPU features */
- if (features == 0xffffffff) {
+ if (features == 0x7fffffff) {
const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES");
features = SDL_CPU_ANY;
@@ -172,36 +172,13 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
continue;
}
- /* Check modulation flags */
- flagcheck =
- (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA));
- if ((flagcheck & entries[i].flags) != flagcheck) {
- continue;
- }
-
- /* Check blend flags */
- flagcheck =
- (flags &
- (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL));
- if ((flagcheck & entries[i].flags) != flagcheck) {
- continue;
- }
-
- /* Check colorkey flag */
- flagcheck = (flags & SDL_COPY_COLORKEY);
- if ((flagcheck & entries[i].flags) != flagcheck) {
- continue;
- }
-
- /* Check scaling flags */
- flagcheck = (flags & SDL_COPY_NEAREST);
+ /* Check flags */
if ((flagcheck & entries[i].flags) != flagcheck) {
continue;
}
/* Check CPU features */
- flagcheck = entries[i].cpu;
- if ((flagcheck & features) != flagcheck) {
+ if ((entries[i].cpu & features) != entries[i].cpu) {
continue;
}