Module: wine Branch: master Commit: 99033b14534ffe8ff6c88c8d38a70d398c933b4d URL: http://source.winehq.org/git/wine.git/?a=commit;h=99033b14534ffe8ff6c88c8d38...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Wed Nov 4 00:02:46 2015 +0100
wined3d: Get rid of getDepthStencilBits().
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/context.c | 31 ++++++++++++------------------- dlls/wined3d/directx.c | 24 ++++++++++-------------- dlls/wined3d/utils.c | 31 ------------------------------- dlls/wined3d/wined3d_private.h | 2 -- 4 files changed, 22 insertions(+), 66 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 543eaf3..e97206e 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1244,7 +1244,6 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC BOOL auxBuffers, BOOL findCompatible) { int iPixelFormat=0; - BYTE depthBits=0, stencilBits=0; unsigned int current_value; unsigned int cfg_count = device->adapter->cfg_count; unsigned int i; @@ -1253,8 +1252,6 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC device, hdc, debug_d3dformat(color_format->id), debug_d3dformat(ds_format->id), auxBuffers, findCompatible);
- getDepthStencilBits(ds_format, &depthBits, &stencilBits); - current_value = 0; for (i = 0; i < cfg_count; ++i) { @@ -1276,9 +1273,9 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC continue; if (cfg->alphaSize < color_format->alpha_size) continue; - if (cfg->depthSize < depthBits) + if (cfg->depthSize < ds_format->depth_size) continue; - if (stencilBits && cfg->stencilSize != stencilBits) + if (ds_format->stencil_size && cfg->stencilSize != ds_format->stencil_size) continue; /* Check multisampling support. */ if (cfg->numSamples) @@ -1287,9 +1284,9 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC value = 1; /* We try to locate a format which matches our requirements exactly. In case of * depth it is no problem to emulate 16-bit using e.g. 24-bit, so accept that. */ - if (cfg->depthSize == depthBits) + if (cfg->depthSize == ds_format->depth_size) value += 1; - if (cfg->stencilSize == stencilBits) + if (cfg->stencilSize == ds_format->stencil_size) value += 2; if (cfg->alphaSize == color_format->alpha_size) value += 4; @@ -1325,8 +1322,8 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC pfd.cAlphaBits = color_format->alpha_size; pfd.cColorBits = color_format->red_size + color_format->green_size + color_format->blue_size + color_format->alpha_size; - pfd.cDepthBits = depthBits; - pfd.cStencilBits = stencilBits; + pfd.cDepthBits = ds_format->depth_size; + pfd.cStencilBits = ds_format->stencil_size; pfd.iLayerType = PFD_MAIN_PLANE;
iPixelFormat = ChoosePixelFormat(hdc, &pfd); @@ -2245,21 +2242,17 @@ static void context_set_render_offscreen(struct wined3d_context *context, BOOL o static BOOL match_depth_stencil_format(const struct wined3d_format *existing, const struct wined3d_format *required) { - BYTE existing_depth, existing_stencil, required_depth, required_stencil; - if (existing == required) return TRUE; if ((existing->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT) != (required->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT)) return FALSE; - - getDepthStencilBits(existing, &existing_depth, &existing_stencil); - getDepthStencilBits(required, &required_depth, &required_stencil); - - if(existing_depth < required_depth) return FALSE; - /* If stencil bits are used the exact amount is required - otherwise wrapping - * won't work correctly */ - if(required_stencil && required_stencil != existing_stencil) return FALSE; + if (existing->depth_size < required->depth_size) + return FALSE; + /* If stencil bits are used the exact amount is required - otherwise + * wrapping won't work correctly. */ + if (required->stencil_size && required->stencil_size != existing->stencil_size) + return FALSE; return TRUE; }
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index e30e785..e2203ea 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4291,15 +4291,8 @@ static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_in static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info, const struct wined3d_pixel_format *cfg, const struct wined3d_format *format) { - BYTE depthSize, stencilSize; BOOL lockable = FALSE;
- if (!getDepthStencilBits(format, &depthSize, &stencilSize)) - { - ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id)); - return FALSE; - } - /* Float formats need FBOs. If FBOs are used this function isn't called */ if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT) return FALSE; @@ -4307,15 +4300,18 @@ static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_in if ((format->id == WINED3DFMT_D16_LOCKABLE) || (format->id == WINED3DFMT_D32_FLOAT)) lockable = TRUE;
- /* On some modern cards like the Geforce8/9 GLX doesn't offer some dephthstencil formats which D3D9 reports. - * We can safely report 'compatible' formats (e.g. D24 can be used for D16) as long as we aren't dealing with - * a lockable format. This also helps D3D <= 7 as they expect D16 which isn't offered without this on Geforce8 cards. */ - if(!(cfg->depthSize == depthSize || (!lockable && cfg->depthSize > depthSize))) + /* On some modern cards like the Geforce8/9, GLX doesn't offer some + * dephth/stencil formats which D3D9 reports. We can safely report + * "compatible" formats (e.g. D24 can be used for D16) as long as we + * aren't dealing with a lockable format. This also helps D3D <= 7 as they + * expect D16 which isn't offered without this on Geforce8 cards. */ + if (!(cfg->depthSize == format->depth_size || (!lockable && cfg->depthSize > format->depth_size))) return FALSE;
- /* Some cards like Intel i915 ones only offer D24S8 but lots of games also need a format without stencil, so - * allow more stencil bits than requested. */ - if(cfg->stencilSize < stencilSize) + /* Some cards like Intel i915 ones only offer D24S8 but lots of games also + * need a format without stencil, so allow more stencil bits than + * requested. */ + if (cfg->stencilSize < format->stencil_size) return FALSE;
return TRUE; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 40ba09c..4ddfead 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4016,37 +4016,6 @@ unsigned int count_bits(unsigned int mask) return count; }
-/* Helper function for retrieving depth/stencil info for ChoosePixelFormat and wglChoosePixelFormatARB */ -BOOL getDepthStencilBits(const struct wined3d_format *format, BYTE *depthSize, BYTE *stencilSize) -{ - TRACE("format %s.\n", debug_d3dformat(format->id)); - - switch (format->id) - { - case WINED3DFMT_D16_LOCKABLE: - case WINED3DFMT_D16_UNORM: - case WINED3DFMT_S1_UINT_D15_UNORM: - case WINED3DFMT_X8D24_UNORM: - case WINED3DFMT_S4X4_UINT_D24_UNORM: - case WINED3DFMT_D24_UNORM_S8_UINT: - case WINED3DFMT_S8_UINT_D24_FLOAT: - case WINED3DFMT_D32_UNORM: - case WINED3DFMT_D32_FLOAT: - case WINED3DFMT_INTZ: - break; - default: - FIXME("Unsupported depth/stencil format %s.\n", debug_d3dformat(format->id)); - return FALSE; - } - - *depthSize = format->depth_size; - *stencilSize = format->stencil_size; - - TRACE("Returning depthSize: %d and stencilSize: %d for format %s.\n", - *depthSize, *stencilSize, debug_d3dformat(format->id)); - return TRUE; -} - /* Note: It's the caller's responsibility to ensure values can be expressed * in the requested format. UNORM formats for example can only express values * in the range 0.0f -> 1.0f. */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0fb261a..ac0b09a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2903,8 +2903,6 @@ void state_pointsprite_w(struct wined3d_context *context, void state_pointsprite(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
-BOOL getDepthStencilBits(const struct wined3d_format *format, - BYTE *depthSize, BYTE *stencilSize) DECLSPEC_HIDDEN; GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
/* Math utils */