From a533ce18e88fd9445230950200dc61d127bd1572 Mon Sep 17 00:00:00 2001 From: CryoTheRenegade Date: Mon, 26 Oct 2026 15:36:38 -0600 Subject: [PATCH 1/2] refactor(ww3d2): Pass the Vector4 color to Convert_Color without a Vector3 cast DX8Wrapper::Convert_Color(const Vector4&) and Convert_Color_Clamp read the RGB part of a Vector4 through a Vector3 reference. On VC6, the inline assembly that converts the color now lives in Convert_Color_RGB, which takes a pointer to the red, green and blue floats. Both Convert_Color overloads pass &color.X, so the Vector4 overload doesn't copy the color into a Vector3 temporary. Other compilers build a Vector3 from X, Y and Z. Co-Authored-By: Claude Opus 5.5 --- .../Source/WWVegas/WW3D2/dx8wrapper.h | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index 2e929450484..0602e7562f2 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -458,6 +458,10 @@ class DX8Wrapper static unsigned int Convert_Color(const Vector3& color, const float alpha); static void Clamp_Color(Vector4& color); static unsigned int Convert_Color_Clamp(const Vector4& color); +#if defined(_MSC_VER) && _MSC_VER < 1300 + // Converts the red, green and blue floats that rgb points to, plus alpha. Only the inline assembly reads through rgb. + static unsigned int Convert_Color_RGB(const float* rgb, float alpha); +#endif static void Set_Alpha (const float alpha, unsigned int &color); @@ -987,9 +991,9 @@ WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector4& color) // // ---------------------------------------------------------------------------- -WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector3& color,float alpha) -{ #if defined(_MSC_VER) && _MSC_VER < 1300 +WWINLINE unsigned int DX8Wrapper::Convert_Color_RGB(const float* rgb,float alpha) +{ const float scale = 255.0; unsigned int col; @@ -1015,7 +1019,7 @@ WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector3& color,float alpha // Convert the color - mov esi,dword ptr color + mov esi,dword ptr rgb fld dword ptr[scale] fld dword ptr[esi] // r @@ -1056,6 +1060,13 @@ WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector3& color,float alpha mov col,eax } return col; +} +#endif // defined(_MSC_VER) && _MSC_VER < 1300 + +WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector3& color,float alpha) +{ +#if defined(_MSC_VER) && _MSC_VER < 1300 + return Convert_Color_RGB(&color.X,alpha); #else return color.Convert_To_ARGB(alpha); #endif // defined(_MSC_VER) && _MSC_VER < 1300 @@ -1131,14 +1142,18 @@ WWINLINE void DX8Wrapper::Clamp_Color(Vector4& color) WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector4& color) { - return Convert_Color(reinterpret_cast(color),color[3]); +#if defined(_MSC_VER) && _MSC_VER < 1300 + return Convert_Color_RGB(&color.X,color.W); +#else + return Convert_Color(Vector3(color.X,color.Y,color.Z),color.W); +#endif // defined(_MSC_VER) && _MSC_VER < 1300 } WWINLINE unsigned int DX8Wrapper::Convert_Color_Clamp(const Vector4& color) { Vector4 clamped_color=color; DX8Wrapper::Clamp_Color(clamped_color); - return Convert_Color(reinterpret_cast(clamped_color),clamped_color[3]); + return Convert_Color(clamped_color); } #endif From 273f99f89c03467c16174b993c08622d990bfda3 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Wed, 4 Nov 2026 21:07:33 -0700 Subject: [PATCH 2/2] refactor(ww3d2): Copy the Vector4 color into a Vector3 instead of the inline assembly helper Co-Authored-By: Claude Opus 5.5 --- .../Source/WWVegas/WW3D2/dx8wrapper.h | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h index 0602e7562f2..86235e63981 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h @@ -458,10 +458,6 @@ class DX8Wrapper static unsigned int Convert_Color(const Vector3& color, const float alpha); static void Clamp_Color(Vector4& color); static unsigned int Convert_Color_Clamp(const Vector4& color); -#if defined(_MSC_VER) && _MSC_VER < 1300 - // Converts the red, green and blue floats that rgb points to, plus alpha. Only the inline assembly reads through rgb. - static unsigned int Convert_Color_RGB(const float* rgb, float alpha); -#endif static void Set_Alpha (const float alpha, unsigned int &color); @@ -991,9 +987,9 @@ WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector4& color) // // ---------------------------------------------------------------------------- -#if defined(_MSC_VER) && _MSC_VER < 1300 -WWINLINE unsigned int DX8Wrapper::Convert_Color_RGB(const float* rgb,float alpha) +WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector3& color,float alpha) { +#if defined(_MSC_VER) && _MSC_VER < 1300 const float scale = 255.0; unsigned int col; @@ -1019,7 +1015,7 @@ WWINLINE unsigned int DX8Wrapper::Convert_Color_RGB(const float* rgb,float alpha // Convert the color - mov esi,dword ptr rgb + mov esi,dword ptr color fld dword ptr[scale] fld dword ptr[esi] // r @@ -1060,13 +1056,6 @@ WWINLINE unsigned int DX8Wrapper::Convert_Color_RGB(const float* rgb,float alpha mov col,eax } return col; -} -#endif // defined(_MSC_VER) && _MSC_VER < 1300 - -WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector3& color,float alpha) -{ -#if defined(_MSC_VER) && _MSC_VER < 1300 - return Convert_Color_RGB(&color.X,alpha); #else return color.Convert_To_ARGB(alpha); #endif // defined(_MSC_VER) && _MSC_VER < 1300 @@ -1142,11 +1131,7 @@ WWINLINE void DX8Wrapper::Clamp_Color(Vector4& color) WWINLINE unsigned int DX8Wrapper::Convert_Color(const Vector4& color) { -#if defined(_MSC_VER) && _MSC_VER < 1300 - return Convert_Color_RGB(&color.X,color.W); -#else return Convert_Color(Vector3(color.X,color.Y,color.Z),color.W); -#endif // defined(_MSC_VER) && _MSC_VER < 1300 } WWINLINE unsigned int DX8Wrapper::Convert_Color_Clamp(const Vector4& color)