[PATCH 2/5] d3dx9: Reimplement make_pow2 in d3dx9_private.h.
Sven Baars
sbaars at codeweavers.com
Thu Feb 13 10:13:45 CST 2020
Signed-off-by: Sven Baars <sbaars at codeweavers.com>
---
dlls/d3dx9_36/d3dx9_private.h | 14 ++++++++++++++
dlls/d3dx9_36/texture.c | 15 ---------------
2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h
index 61ec320ba5..b1c8db3dff 100644
--- a/dlls/d3dx9_36/d3dx9_private.h
+++ b/dlls/d3dx9_36/d3dx9_private.h
@@ -225,6 +225,20 @@ static inline BOOL is_param_type_sampler(D3DXPARAMETER_TYPE type)
|| type == D3DXPT_SAMPLER3D || type == D3DXPT_SAMPLERCUBE;
}
+/* Returns the smallest power of 2 which is greater than or equal to num */
+static inline UINT make_pow2(UINT num)
+{
+ num--;
+ num |= num >> 1;
+ num |= num >> 2;
+ num |= num >> 4;
+ num |= num >> 8;
+ num |= num >> 16;
+ num++;
+
+ return num;
+}
+
struct d3dx_parameter;
enum pres_reg_tables
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index d96ade9aed..6af4458904 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -30,21 +30,6 @@ static BOOL is_pow2(UINT num)
return !(num & (num - 1));
}
-/* Returns the smallest power of 2 which is greater than or equal to num */
-static UINT make_pow2(UINT num)
-{
- UINT result = 1;
-
- /* In the unlikely event somebody passes a large value, make sure we don't enter an infinite loop */
- if (num >= 0x80000000)
- return 0x80000000;
-
- while (result < num)
- result <<= 1;
-
- return result;
-}
-
static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex,
int face, UINT level, struct IDirect3DSurface9 **surf)
{
--
2.24.0
More information about the wine-devel
mailing list