Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/surface.c | 8 ++++---- dlls/wined3d/utils.c | 10 +++++----- dlls/wined3d/wined3d_private.h | 5 +++++ 3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index c5d7a7d9d55..8a4ca4f5781 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -36,11 +36,11 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); static const DWORD surface_simple_locations = WINED3D_LOCATION_SYSMEM | WINED3D_LOCATION_BUFFER;
/* Works correctly only for <= 4 bpp formats. */ -static void get_color_masks(const struct wined3d_format *format, DWORD *masks) +static void get_color_masks(const struct wined3d_format *format, uint32_t *masks) { - masks[0] = ((1u << format->red_size) - 1) << format->red_offset; - masks[1] = ((1u << format->green_size) - 1) << format->green_offset; - masks[2] = ((1u << format->blue_size) - 1) << format->blue_offset; + masks[0] = wined3d_mask_from_size(format->red_size) << format->red_offset; + masks[1] = wined3d_mask_from_size(format->green_size) << format->green_offset; + masks[2] = wined3d_mask_from_size(format->blue_size) << format->blue_offset; }
/* See also float_16_to_32() in wined3d_private.h */ diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index b39fb46cadc..8eacc52ee2c 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -5902,7 +5902,7 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, con
static float color_to_float(DWORD color, DWORD size, DWORD offset) { - DWORD mask = size < 32 ? (1u << size) - 1 : ~0u; + uint32_t mask = wined3d_mask_from_size(size);
if (!size) return 1.0f; @@ -5938,10 +5938,10 @@ void wined3d_format_get_float_color_key(const struct wined3d_format *format, case WINED3DFMT_R8G8B8X8_UNORM: case WINED3DFMT_R16G16_UNORM: case WINED3DFMT_B10G10R10A2_UNORM: - slop.r = 0.5f / ((1u << format->red_size) - 1); - slop.g = 0.5f / ((1u << format->green_size) - 1); - slop.b = 0.5f / ((1u << format->blue_size) - 1); - slop.a = 0.5f / ((1u << format->alpha_size) - 1); + slop.r = 0.5f / wined3d_mask_from_size(format->red_size); + slop.g = 0.5f / wined3d_mask_from_size(format->green_size); + slop.b = 0.5f / wined3d_mask_from_size(format->blue_size); + slop.a = 0.5f / wined3d_mask_from_size(format->alpha_size);
float_colors[0].r = color_to_float(key->color_space_low_value, format->red_size, format->red_offset) - slop.r; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b0f8ea1bf93..6d41f02e842 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -5959,6 +5959,11 @@ static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geomet && geometry_shader->u.gs.so_desc->rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM; }
+static inline uint32_t wined3d_mask_from_size(unsigned int size) +{ + return size < 32 ? (1u << size) - 1 : ~0u; +} + static inline DWORD wined3d_extract_bits(const DWORD *bitstream, unsigned int offset, unsigned int count) {