From 43c57e3239caea8d3d4235bb88ba394cba21bb17 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 5 Oct 2023 13:40:09 +0200
Subject: [PATCH] triangle: don't read destination pixel when you're going to
discard it anyways
---
src/render/software/SDL_triangle.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c
index fc429db6e207..a4c04b2ddc2a 100644
--- a/src/render/software/SDL_triangle.c
+++ b/src/render/software/SDL_triangle.c
@@ -789,15 +789,20 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
continue;
}
}
- if (FORMAT_HAS_ALPHA(dstfmt_val)) {
- DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA);
- } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
- DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
- dstA = 0xFF;
+ if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) {
+ if (FORMAT_HAS_ALPHA(dstfmt_val)) {
+ DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA);
+ } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
+ DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
+ dstA = 0xFF;
+ } else {
+ /* SDL_PIXELFORMAT_ARGB2101010 */
+ dstpixel = *((Uint32 *) (dst));
+ RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
+ }
} else {
- /* SDL_PIXELFORMAT_ARGB2101010 */
- dstpixel = *((Uint32 *)(dst));
- RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
+ /* don't care */
+ dstR = dstG = dstB = dstA = 0;
}
if (!is_uniform) {