Commit e0ab314b authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of getColorBits().

parent 4896fd6e
......@@ -1244,7 +1244,6 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC
BOOL auxBuffers, BOOL findCompatible)
{
int iPixelFormat=0;
BYTE redBits, greenBits, blueBits, alphaBits, colorBits;
BYTE depthBits=0, stencilBits=0;
unsigned int current_value;
unsigned int cfg_count = device->adapter->cfg_count;
......@@ -1254,13 +1253,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);
if (!getColorBits(color_format, &redBits, &greenBits, &blueBits, &alphaBits, &colorBits))
{
ERR("Unable to get color bits for format %s (%#x)!\n",
debug_d3dformat(color_format->id), color_format->id);
return 0;
}
getDepthStencilBits(ds_format, &depthBits, &stencilBits);
current_value = 0;
......@@ -1276,13 +1268,13 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC
/* In window mode we need a window drawable format and double buffering. */
if (!(cfg->windowDrawable && cfg->doubleBuffer))
continue;
if (cfg->redSize < redBits)
if (cfg->redSize < color_format->red_size)
continue;
if (cfg->greenSize < greenBits)
if (cfg->greenSize < color_format->green_size)
continue;
if (cfg->blueSize < blueBits)
if (cfg->blueSize < color_format->blue_size)
continue;
if (cfg->alphaSize < alphaBits)
if (cfg->alphaSize < color_format->alpha_size)
continue;
if (cfg->depthSize < depthBits)
continue;
......@@ -1299,14 +1291,14 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC
value += 1;
if (cfg->stencilSize == stencilBits)
value += 2;
if (cfg->alphaSize == alphaBits)
if (cfg->alphaSize == color_format->alpha_size)
value += 4;
/* We like to have aux buffers in backbuffer mode */
if (auxBuffers && cfg->auxBuffers)
value += 8;
if (cfg->redSize == redBits
&& cfg->greenSize == greenBits
&& cfg->blueSize == blueBits)
if (cfg->redSize == color_format->red_size
&& cfg->greenSize == color_format->green_size
&& cfg->blueSize == color_format->blue_size)
value += 16;
if (value > current_value)
......@@ -1330,8 +1322,9 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC
pfd.nVersion = 1;
pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW;/*PFD_GENERIC_ACCELERATED*/
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cAlphaBits = alphaBits;
pfd.cColorBits = colorBits;
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.iLayerType = PFD_MAIN_PLANE;
......
......@@ -4271,36 +4271,21 @@ HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, U
static BOOL wined3d_check_pixel_format_color(const struct wined3d_gl_info *gl_info,
const struct wined3d_pixel_format *cfg, const struct wined3d_format *format)
{
BYTE redSize, greenSize, blueSize, alphaSize, colorBits;
/* 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;
if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
if (!getColorBits(format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
{
ERR("Unable to check compatibility for format %s.\n", debug_d3dformat(format->id));
return FALSE;
}
if(cfg->redSize < redSize)
return FALSE;
if(cfg->greenSize < greenSize)
return FALSE;
if(cfg->blueSize < blueSize)
/* Probably a RGBA_float or color index mode. */
if (cfg->iPixelType != WGL_TYPE_RGBA_ARB)
return FALSE;
if(cfg->alphaSize < alphaSize)
if (cfg->redSize < format->red_size
|| cfg->greenSize < format->green_size
|| cfg->blueSize < format->blue_size
|| cfg->alphaSize < format->alpha_size)
return FALSE;
return TRUE;
}
/* Probably a RGBA_float or color index mode */
return FALSE;
}
static BOOL wined3d_check_pixel_format_depth(const struct wined3d_gl_info *gl_info,
......@@ -4479,17 +4464,15 @@ static BOOL CheckRenderTargetCapability(const struct wined3d_adapter *adapter,
return FALSE;
if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
{
BYTE AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
BYTE CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
const struct wined3d_pixel_format *cfgs = adapter->cfgs;
unsigned int i;
getColorBits(adapter_format, &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
getColorBits(check_format, &CheckRed, &CheckGreen, &CheckBlue, &CheckAlpha, &CheckTotalSize);
/* In backbuffer mode the front and backbuffer share the same WGL pixelformat.
* The format must match in RGB, alpha is allowed to be different. (Only the backbuffer can have alpha) */
if (!((AdapterRed == CheckRed) && (AdapterGreen == CheckGreen) && (AdapterBlue == CheckBlue)))
/* In backbuffer mode the front and backbuffer share the same WGL
* pixelformat. The format must match in RGB, alpha is allowed to be
* different. (Only the backbuffer can have alpha.) */
if (adapter_format->red_size != check_format->red_size
|| adapter_format->green_size != check_format->green_size
|| adapter_format->blue_size != check_format->blue_size)
{
TRACE("[FAILED]\n");
return FALSE;
......
......@@ -4016,46 +4016,6 @@ unsigned int count_bits(unsigned int mask)
return count;
}
/* Helper function for retrieving color info for ChoosePixelFormat and wglChoosePixelFormatARB.
* The later function requires individual color components. */
BOOL getColorBits(const struct wined3d_format *format,
BYTE *redSize, BYTE *greenSize, BYTE *blueSize, BYTE *alphaSize, BYTE *totalSize)
{
TRACE("format %s.\n", debug_d3dformat(format->id));
switch (format->id)
{
case WINED3DFMT_B10G10R10A2_UNORM:
case WINED3DFMT_R10G10B10A2_UNORM:
case WINED3DFMT_B8G8R8X8_UNORM:
case WINED3DFMT_B8G8R8_UNORM:
case WINED3DFMT_B8G8R8A8_UNORM:
case WINED3DFMT_R8G8B8A8_UNORM:
case WINED3DFMT_B5G5R5X1_UNORM:
case WINED3DFMT_B5G5R5A1_UNORM:
case WINED3DFMT_B5G6R5_UNORM:
case WINED3DFMT_B4G4R4X4_UNORM:
case WINED3DFMT_B4G4R4A4_UNORM:
case WINED3DFMT_B2G3R3_UNORM:
case WINED3DFMT_P8_UINT_A8_UNORM:
case WINED3DFMT_P8_UINT:
break;
default:
FIXME("Unsupported format %s.\n", debug_d3dformat(format->id));
return FALSE;
}
*redSize = format->red_size;
*greenSize = format->green_size;
*blueSize = format->blue_size;
*alphaSize = format->alpha_size;
*totalSize = *redSize + *greenSize + *blueSize + *alphaSize;
TRACE("Returning red: %d, green: %d, blue: %d, alpha: %d, total: %d for format %s.\n",
*redSize, *greenSize, *blueSize, *alphaSize, *totalSize, debug_d3dformat(format->id));
return TRUE;
}
/* Helper function for retrieving depth/stencil info for ChoosePixelFormat and wglChoosePixelFormatARB */
BOOL getDepthStencilBits(const struct wined3d_format *format, BYTE *depthSize, BYTE *stencilSize)
{
......
......@@ -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 getColorBits(const struct wined3d_format *format,
BYTE *redSize, BYTE *greenSize, BYTE *blueSize, BYTE *alphaSize, BYTE *totalSize) 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment