wined3d: Only return a pointer to struct GlPixelFormatDesc from getFormatDescEntry().

Henri Verbeet hverbeet at codeweavers.com
Fri Mar 13 04:44:18 CDT 2009


---
 dlls/wined3d/arb_program_shader.c |    2 +-
 dlls/wined3d/context.c            |   22 ++++----
 dlls/wined3d/device.c             |   32 ++++++------
 dlls/wined3d/directx.c            |  100 ++++++++++++++++++++-----------------
 dlls/wined3d/resource.c           |    2 +-
 dlls/wined3d/state.c              |   19 ++-----
 dlls/wined3d/surface_base.c       |   53 ++++++++++---------
 dlls/wined3d/surface_gdi.c        |   16 +++---
 dlls/wined3d/utils.c              |   62 +++++++++++------------
 dlls/wined3d/wined3d_private.h    |   16 ++-----
 10 files changed, 159 insertions(+), 165 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 8d63294..7b622d4 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -3674,7 +3674,7 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, WINED3DFORMAT fmt, GLenum t
     const struct GlPixelFormatDesc *glDesc;
     enum yuv_fixup yuv_fixup;
 
-    getFormatDescEntry(fmt, &GLINFO_LOCATION, &glDesc);
+    glDesc = getFormatDescEntry(fmt, &GLINFO_LOCATION);
 
     if (!is_yuv_fixup(glDesc->color_fixup))
     {
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 6353aa7..bb57130 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -477,7 +477,8 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc, WINED3DF
     TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d, numSamples=%d, pbuffer=%d, findCompatible=%d\n",
           debug_d3dformat(ColorFormat), debug_d3dformat(DepthStencilFormat), auxBuffers, numSamples, pbuffer, findCompatible);
 
-    if(!getColorBits(ColorFormat, &redBits, &greenBits, &blueBits, &alphaBits, &colorBits)) {
+    if (!getColorBits(&This->adapter->gl_info, ColorFormat, &redBits, &greenBits, &blueBits, &alphaBits, &colorBits))
+    {
         ERR("Unable to get color bits for format %s (%#x)!\n", debug_d3dformat(ColorFormat), ColorFormat);
         return 0;
     }
@@ -499,7 +500,7 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc, WINED3DF
     DepthStencilFormat = WINED3DFMT_D24S8;
 
     if(DepthStencilFormat) {
-        getDepthStencilBits(DepthStencilFormat, &depthBits, &stencilBits);
+        getDepthStencilBits(&This->adapter->gl_info, DepthStencilFormat, &depthBits, &stencilBits);
     }
 
     for(matchtry = 0; matchtry < (sizeof(matches) / sizeof(matches[0])) && !iPixelFormat; matchtry++) {
@@ -1256,20 +1257,19 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf
     BOOL readTexture = wined3d_settings.offscreen_rendering_mode != ORM_FBO && This->render_offscreen;
     WineD3DContext *context = This->activeContext;
     BOOL oldRenderOffscreen = This->render_offscreen;
-    const WINED3DFORMAT oldFmt = ((IWineD3DSurfaceImpl *) This->lastActiveRenderTarget)->resource.format;
-    const WINED3DFORMAT newFmt = ((IWineD3DSurfaceImpl *) target)->resource.format;
+    const struct GlPixelFormatDesc *old = ((IWineD3DSurfaceImpl *)This->lastActiveRenderTarget)->resource.format_desc;
+    const struct GlPixelFormatDesc *new = ((IWineD3DSurfaceImpl *)target)->resource.format_desc;
     const struct StateEntry *StateTable = This->StateTable;
 
     /* To compensate the lack of format switching with some offscreen rendering methods and on onscreen buffers
      * the alpha blend state changes with different render target formats
      */
-    if(oldFmt != newFmt) {
-        const struct GlPixelFormatDesc *glDesc;
-        const StaticPixelFormatDesc *old = getFormatDescEntry(oldFmt, NULL, NULL);
-        const StaticPixelFormatDesc *new = getFormatDescEntry(newFmt, &GLINFO_LOCATION, &glDesc);
-
-        /* Disable blending when the alphaMask has changed and when a format doesn't support blending */
-        if((old->alphaMask && !new->alphaMask) || (!old->alphaMask && new->alphaMask) || !(glDesc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) {
+    if (old->format != new->format)
+    {
+        /* Disable blending when the alpha mask has changed and when a format doesn't support blending */
+        if ((old->alpha_mask && !new->alpha_mask) || (!old->alpha_mask && new->alpha_mask)
+                || !(new->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
+        {
             Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
         }
     }
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 54b371a..ab2474e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -705,8 +705,7 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
     IWineD3DDeviceImpl  *This = (IWineD3DDeviceImpl *)iface;    
     IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
     unsigned int Size       = 1;
-    const struct GlPixelFormatDesc *glDesc;
-    const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
+    const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(Format, &GLINFO_LOCATION);
     UINT mul_4w, mul_4h;
     HRESULT hr;
 
@@ -731,15 +730,15 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
         Size = 0;
     } else if (Format == WINED3DFMT_DXT1) {
         /* DXT1 is half byte per pixel */
-        Size = (mul_4w * tableEntry->bpp * mul_4h) >> 1;
+        Size = (mul_4w * glDesc->byte_count * mul_4h) >> 1;
 
     } else if (Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3 ||
                Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5 ||
                Format == WINED3DFMT_ATI2N) {
-        Size = (mul_4w * tableEntry->bpp * mul_4h);
+        Size = (mul_4w * glDesc->byte_count * mul_4h);
     } else {
        /* The pitch is a multiple of 4 bytes */
-        Size = ((Width * tableEntry->bpp) + This->surface_alignment - 1) & ~(This->surface_alignment - 1);
+        Size = ((Width * glDesc->byte_count) + This->surface_alignment - 1) & ~(This->surface_alignment - 1);
         Size *= Height;
     }
 
@@ -812,7 +811,7 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
 
 
     if (WINED3DFMT_UNKNOWN != Format) {
-        object->bytesPerPixel = tableEntry->bpp;
+        object->bytesPerPixel = glDesc->byte_count;
     } else {
         object->bytesPerPixel = 0;
     }
@@ -1200,7 +1199,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
 
     IWineD3DDeviceImpl        *This = (IWineD3DDeviceImpl *)iface;
     IWineD3DVolumeImpl        *object; /** NOTE: impl ref allowed since this is a create function **/
-    const StaticPixelFormatDesc *formatDesc  = getFormatDescEntry(Format, NULL, NULL);
+    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(Format, &GLINFO_LOCATION);
     HRESULT hr;
 
     if(!GL_SUPPORT(EXT_TEXTURE3D)) {
@@ -1218,7 +1217,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
 
     object->lpVtbl = &IWineD3DVolume_Vtbl;
     hr = resource_init(&object->resource, WINED3DRTYPE_VOLUME, This,
-            Width * Height * Depth * formatDesc->bpp, Usage, Format, Pool, parent);
+            Width * Height * Depth * format_desc->byte_count, Usage, Format, Pool, parent);
     if (FAILED(hr))
     {
         WARN("Failed to initialize resource, returning %#x\n", hr);
@@ -1239,7 +1238,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
     object->currentDesc.Width   = Width;
     object->currentDesc.Height  = Height;
     object->currentDesc.Depth   = Depth;
-    object->bytesPerPixel       = formatDesc->bpp;
+    object->bytesPerPixel       = format_desc->byte_count;
 
     /** Note: Volume textures cannot be dxtn, hence no need to check here **/
     object->lockable            = TRUE;
@@ -1630,7 +1629,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
     IUnknown               *bufferParent;
     BOOL                    displaymode_set = FALSE;
     WINED3DDISPLAYMODE      Mode;
-    const StaticPixelFormatDesc *formatDesc;
+    const struct GlPixelFormatDesc *format_desc;
 
     TRACE("(%p) : Created Additional Swap Chain\n", This);
 
@@ -1701,7 +1700,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
     object->orig_width = Mode.Width;
     object->orig_height = Mode.Height;
     object->orig_fmt = Mode.Format;
-    formatDesc  = getFormatDescEntry(Mode.Format, NULL, NULL);
+    format_desc = getFormatDescEntry(Mode.Format, &GLINFO_LOCATION);
 
     if (pPresentationParameters->Windowed &&
         ((pPresentationParameters->BackBufferWidth == 0) ||
@@ -1877,7 +1876,7 @@ error:
         memset(&devmode, 0, sizeof(devmode));
         devmode.dmSize       = sizeof(devmode);
         devmode.dmFields     = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
-        devmode.dmBitsPerPel = formatDesc->bpp * 8;
+        devmode.dmBitsPerPel = format_desc->byte_count * 8;
         devmode.dmPelsWidth  = object->orig_width;
         devmode.dmPelsHeight = object->orig_height;
         ChangeDisplaySettingsExW(This->adapter->DeviceName, &devmode, NULL, CDS_FULLSCREEN, NULL);
@@ -2737,7 +2736,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, U
     DEVMODEW devmode;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     LONG ret;
-    const StaticPixelFormatDesc *formatDesc  = getFormatDescEntry(pMode->Format, NULL, NULL);
+    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(pMode->Format, &GLINFO_LOCATION);
     RECT clip_rc;
 
     TRACE("(%p)->(%d,%p) Mode=%dx%dx@%d, %s\n", This, iSwapChain, pMode, pMode->Width, pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
@@ -2751,7 +2750,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, U
     memset(&devmode, 0, sizeof(devmode));
     devmode.dmSize = sizeof(devmode);
     devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
-    devmode.dmBitsPerPel = formatDesc->bpp * 8;
+    devmode.dmBitsPerPel = format_desc->byte_count * 8;
     devmode.dmPelsWidth  = pMode->Width;
     devmode.dmPelsHeight = pMode->Height;
 
@@ -6981,15 +6980,14 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
             This->cursorHeight = pSur->currentDesc.Height;
             if (SUCCEEDED(IWineD3DSurface_LockRect(pCursorBitmap, &rect, NULL, WINED3DLOCK_READONLY)))
             {
-                const struct GlPixelFormatDesc *glDesc;
-                const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &GLINFO_LOCATION, &glDesc);
+                const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &GLINFO_LOCATION);
                 char *mem, *bits = rect.pBits;
                 GLint intfmt = glDesc->glInternal;
                 GLint format = glDesc->glFormat;
                 GLint type = glDesc->glType;
                 INT height = This->cursorHeight;
                 INT width = This->cursorWidth;
-                INT bpp = tableEntry->bpp;
+                INT bpp = glDesc->byte_count;
                 INT i, sampler;
 
                 /* Reformat the texture memory (pitch and width can be
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index fddc856..2ec60d4 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1709,14 +1709,17 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Ad
     return WINED3D_OK;
 }
 
-static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const WineD3D_PixelFormat *cfg, WINED3DFORMAT Format) {
+static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const WineD3D_GL_Info *gl_info,
+        const WineD3D_PixelFormat *cfg, WINED3DFORMAT Format)
+{
     short redSize, greenSize, blueSize, alphaSize, colorBits;
 
     if(!cfg)
         return FALSE;
 
     if(cfg->iPixelType == WGL_TYPE_RGBA_ARB) { /* Integer RGBA formats */
-        if(!getColorBits(Format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
+        if (!getColorBits(gl_info, Format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
+        {
             ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(Format));
             return FALSE;
         }
@@ -1755,14 +1758,17 @@ static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const WineD3D_Pixe
     return FALSE;
 }
 
-static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const WineD3D_PixelFormat *cfg, WINED3DFORMAT Format) {
+static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const WineD3D_GL_Info *gl_info,
+        const WineD3D_PixelFormat *cfg, WINED3DFORMAT Format)
+{
     short depthSize, stencilSize;
     BOOL lockable = FALSE;
 
     if(!cfg)
         return FALSE;
 
-    if(!getDepthStencilBits(Format, &depthSize, &stencilSize)) {
+    if (!getDepthStencilBits(gl_info, Format, &depthSize, &stencilSize))
+    {
         ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(Format));
         return FALSE;
     }
@@ -1791,6 +1797,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT
     IWineD3DImpl *This = (IWineD3DImpl *)iface;
     int nCfgs;
     const WineD3D_PixelFormat *cfgs;
+    const struct WineD3DAdapter *adapter;
     int it;
 
     WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
@@ -1805,11 +1812,14 @@ static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT
         return WINED3DERR_INVALIDCALL;
     }
 
-    cfgs = This->adapters[Adapter].cfgs;
-    nCfgs = This->adapters[Adapter].nCfgs;
+    adapter = &This->adapters[Adapter];
+    cfgs = adapter->cfgs;
+    nCfgs = adapter->nCfgs;
     for (it = 0; it < nCfgs; ++it) {
-        if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&cfgs[it], RenderTargetFormat)) {
-            if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&cfgs[it], DepthStencilFormat)) {
+        if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, &cfgs[it], RenderTargetFormat))
+        {
+            if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[it], DepthStencilFormat))
+            {
                 TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
                 return WINED3D_OK;
             }
@@ -1826,7 +1836,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
 
     IWineD3DImpl *This = (IWineD3DImpl *)iface;
     const struct GlPixelFormatDesc *glDesc;
-    const StaticPixelFormatDesc *desc;
+    const struct WineD3DAdapter *adapter;
 
     TRACE_(d3d_caps)("(%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
           This,
@@ -1851,22 +1861,21 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
     if(!wined3d_settings.allow_multisampling)
         return WINED3DERR_NOTAVAILABLE;
 
-    desc = getFormatDescEntry(SurfaceFormat, &This->adapters[Adapter].gl_info, &glDesc);
-    if(!desc || !glDesc) {
-        return WINED3DERR_INVALIDCALL;
-    }
+    adapter = &This->adapters[Adapter];
+    glDesc = getFormatDescEntry(SurfaceFormat, &adapter->gl_info);
+    if (!glDesc) return WINED3DERR_INVALIDCALL;
 
     if(glDesc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) {
         int i, nCfgs;
         const WineD3D_PixelFormat *cfgs;
 
-        cfgs = This->adapters[Adapter].cfgs;
-        nCfgs = This->adapters[Adapter].nCfgs;
+        cfgs = adapter->cfgs;
+        nCfgs = adapter->nCfgs;
         for(i=0; i<nCfgs; i++) {
             if(cfgs[i].numSamples != MultiSampleType)
                 continue;
 
-            if(!IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&cfgs[i], SurfaceFormat))
+            if (!IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, &cfgs[i], SurfaceFormat))
                 continue;
 
             TRACE("Found iPixelFormat=%d to support MultiSampleType=%d for format %s\n", cfgs[i].iPixelFormat, MultiSampleType, debug_d3dformat(SurfaceFormat));
@@ -1881,13 +1890,14 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
         int i, nCfgs;
         const WineD3D_PixelFormat *cfgs;
 
-        if(!getColorBits(SurfaceFormat, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
+        if (!getColorBits(&adapter->gl_info, SurfaceFormat, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits))
+        {
             ERR("Unable to color bits for format %#x, can't check multisampling capability!\n", SurfaceFormat);
             return WINED3DERR_NOTAVAILABLE;
         }
 
-        cfgs = This->adapters[Adapter].cfgs;
-        nCfgs = This->adapters[Adapter].nCfgs;
+        cfgs = adapter->cfgs;
+        nCfgs = adapter->nCfgs;
         for(i=0; i<nCfgs; i++) {
             if(cfgs[i].numSamples != MultiSampleType)
                 continue;
@@ -2011,7 +2021,7 @@ static BOOL CheckBumpMapCapability(struct WineD3DAdapter *adapter,
             /* Ask the fixed function pipeline implementation if it can deal
              * with the conversion. If we've got a GL extension giving native
              * support this will be an identity conversion. */
-            getFormatDescEntry(CheckFormat, &adapter->gl_info, &glDesc);
+            glDesc = getFormatDescEntry(CheckFormat, &adapter->gl_info);
             fp = select_fragment_implementation(adapter, DeviceType);
             if (fp->color_fixup_supported(glDesc->color_fixup))
             {
@@ -2032,12 +2042,10 @@ static BOOL CheckDepthStencilCapability(struct WineD3DAdapter *adapter,
         WINED3DFORMAT DisplayFormat, WINED3DFORMAT DepthStencilFormat)
 {
     int it=0;
-    const struct GlPixelFormatDesc *glDesc;
-    const StaticPixelFormatDesc *desc = getFormatDescEntry(DepthStencilFormat, &adapter->gl_info, &glDesc);
+    const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(DepthStencilFormat, &adapter->gl_info);
 
     /* Fail if we weren't able to get a description of the format */
-    if(!desc || !glDesc)
-        return FALSE;
+    if (!glDesc) return FALSE;
 
     /* Only allow depth/stencil formats */
     if(!(glDesc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)))
@@ -2047,8 +2055,10 @@ static BOOL CheckDepthStencilCapability(struct WineD3DAdapter *adapter,
     for (it = 0; it < adapter->nCfgs; ++it)
     {
         WineD3D_PixelFormat *cfg = &adapter->cfgs[it];
-        if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(cfg, DisplayFormat)) {
-            if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(cfg, DepthStencilFormat)) {
+        if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info, cfg, DisplayFormat))
+        {
+            if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&adapter->gl_info, cfg, DepthStencilFormat))
+            {
                 return TRUE;
             }
         }
@@ -2059,12 +2069,10 @@ static BOOL CheckDepthStencilCapability(struct WineD3DAdapter *adapter,
 
 static BOOL CheckFilterCapability(struct WineD3DAdapter *adapter, WINED3DFORMAT CheckFormat)
 {
-    const struct GlPixelFormatDesc *glDesc;
-    const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &adapter->gl_info, &glDesc);
+    const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(CheckFormat, &adapter->gl_info);
 
     /* Fail if we weren't able to get a description of the format */
-    if(!desc || !glDesc)
-        return FALSE;
+    if (!glDesc) return FALSE;
 
     /* The flags entry of a format contains the filtering capability */
     if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING)
@@ -2077,12 +2085,10 @@ static BOOL CheckFilterCapability(struct WineD3DAdapter *adapter, WINED3DFORMAT
 static BOOL CheckRenderTargetCapability(struct WineD3DAdapter *adapter,
         WINED3DFORMAT AdapterFormat, WINED3DFORMAT CheckFormat)
 {
-    const struct GlPixelFormatDesc *glDesc;
-    const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &adapter->gl_info, &glDesc);
+    const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(CheckFormat, &adapter->gl_info);
 
     /* Fail if we weren't able to get a description of the format */
-    if(!desc || !glDesc)
-        return FALSE;
+    if (!glDesc) return FALSE;
 
     /* Filter out non-RT formats */
     if(!(glDesc->Flags & WINED3DFMT_FLAG_RENDERTARGET))
@@ -2094,8 +2100,10 @@ static BOOL CheckRenderTargetCapability(struct WineD3DAdapter *adapter,
         short AdapterRed, AdapterGreen, AdapterBlue, AdapterAlpha, AdapterTotalSize;
         short CheckRed, CheckGreen, CheckBlue, CheckAlpha, CheckTotalSize;
 
-        getColorBits(AdapterFormat, &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
-        getColorBits(CheckFormat, &CheckRed, &CheckGreen, &CheckBlue, &CheckAlpha, &CheckTotalSize);
+        getColorBits(&adapter->gl_info, AdapterFormat,
+                &AdapterRed, &AdapterGreen, &AdapterBlue, &AdapterAlpha, &AdapterTotalSize);
+        getColorBits(&adapter->gl_info, CheckFormat,
+                &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) */
@@ -2108,7 +2116,9 @@ static BOOL CheckRenderTargetCapability(struct WineD3DAdapter *adapter,
          * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
         for (it = 0; it < adapter->nCfgs; ++it)
         {
-            if (cfgs[it].windowDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&cfgs[it], CheckFormat)) {
+            if (cfgs[it].windowDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info,
+                    &cfgs[it], CheckFormat))
+            {
                 TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n", cfgs[it].iPixelFormat, debug_d3dformat(CheckFormat));
                 return TRUE;
             }
@@ -2121,7 +2131,9 @@ static BOOL CheckRenderTargetCapability(struct WineD3DAdapter *adapter,
         /* Check if there is a WGL pixel format matching the requirements, the pixel format should also be usable with pbuffers */
         for (it = 0; it < adapter->nCfgs; ++it)
         {
-            if (cfgs[it].pbufferDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&cfgs[it], CheckFormat)) {
+            if (cfgs[it].pbufferDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info,
+                    &cfgs[it], CheckFormat))
+            {
                 TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n", cfgs[it].iPixelFormat, debug_d3dformat(CheckFormat));
                 return TRUE;
             }
@@ -2189,12 +2201,10 @@ static BOOL CheckSrgbWriteCapability(struct WineD3DAdapter *adapter,
 /* Check if a format support blending in combination with pixel shaders */
 static BOOL CheckPostPixelShaderBlendingCapability(struct WineD3DAdapter *adapter, WINED3DFORMAT CheckFormat)
 {
-    const struct GlPixelFormatDesc *glDesc;
-    const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &adapter->gl_info, &glDesc);
+    const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(CheckFormat, &adapter->gl_info);
 
     /* Fail if we weren't able to get a description of the format */
-    if(!desc || !glDesc)
-        return FALSE;
+    if (!glDesc) return FALSE;
 
     /* The flags entry of a format contains the post pixel shader blending capability */
     if(glDesc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)
@@ -2301,7 +2311,7 @@ static BOOL CheckTextureCapability(struct WineD3DAdapter *adapter,
             /* Ask the shader backend if it can deal with the conversion. If
              * we've got a GL extension giving native support this will be an
              * identity conversion. */
-            getFormatDescEntry(CheckFormat, &adapter->gl_info, &glDesc);
+            glDesc = getFormatDescEntry(CheckFormat, &adapter->gl_info);
             shader_backend = select_shader_backend(adapter, DeviceType);
             if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup))
             {
@@ -2419,7 +2429,7 @@ static BOOL CheckTextureCapability(struct WineD3DAdapter *adapter,
         /* Vendor specific formats */
         case WINED3DFMT_ATI2N:
             if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {
-                getFormatDescEntry(CheckFormat, &adapter->gl_info, &glDesc);
+                glDesc = getFormatDescEntry(CheckFormat, &adapter->gl_info);
                 shader_backend = select_shader_backend(adapter, DeviceType);
                 fp = select_fragment_implementation(adapter, DeviceType);
                 if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup)
@@ -2496,7 +2506,7 @@ static BOOL CheckSurfaceCapability(struct WineD3DAdapter *adapter, WINED3DFORMAT
     if(CheckDepthStencilCapability(adapter, AdapterFormat, CheckFormat)) return TRUE;
 
     /* If opengl can't process the format natively, the blitter may be able to convert it */
-    getFormatDescEntry(CheckFormat, &adapter->gl_info, &format_desc);
+    format_desc = getFormatDescEntry(CheckFormat, &adapter->gl_info);
     blitter = select_blit_implementation(adapter, DeviceType);
     if (blitter->color_fixup_supported(format_desc->color_fixup))
     {
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 34015f8..898b732 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -35,7 +35,7 @@ HRESULT resource_init(struct IWineD3DResourceClass *resource, WINED3DRESOURCETYP
     resource->ref = 1;
     resource->pool = pool;
     resource->format = format;
-    getFormatDescEntry(format, &device->adapter->gl_info, &resource->format_desc);
+    resource->format_desc = getFormatDescEntry(format, &device->adapter->gl_info);
     resource->usage = usage;
     resource->size = size;
     resource->priority = 0;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 390bed0..720a548 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -236,7 +236,6 @@ static void state_ambient(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD
 static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     int srcBlend = GL_ZERO;
     int dstBlend = GL_ZERO;
-    const StaticPixelFormatDesc *rtFormat;
     IWineD3DSurfaceImpl *target = (IWineD3DSurfaceImpl *) stateblock->wineD3DDevice->render_targets[0];
 
     /* GL_LINE_SMOOTH needs GL_BLEND to work, according to the red book, and special blending params */
@@ -278,12 +277,10 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
          * returns 1.0, so D3DBLEND_DESTALPHA is GL_ONE, and D3DBLEND_INVDESTALPHA is GL_ZERO
          */
         case WINED3DBLEND_DESTALPHA          :
-            rtFormat = getFormatDescEntry(target->resource.format, NULL, NULL);
-            dstBlend = rtFormat->alphaMask ? GL_DST_ALPHA : GL_ONE;
+            dstBlend = target->resource.format_desc->alpha_mask ? GL_DST_ALPHA : GL_ONE;
             break;
         case WINED3DBLEND_INVDESTALPHA       :
-            rtFormat = getFormatDescEntry(target->resource.format, NULL, NULL);
-            dstBlend = rtFormat->alphaMask ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
+            dstBlend = target->resource.format_desc->alpha_mask ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
             break;
 
         case WINED3DBLEND_SRCALPHASAT        :
@@ -322,12 +319,10 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
         case WINED3DBLEND_SRCALPHASAT        : srcBlend = GL_SRC_ALPHA_SATURATE;  break;
 
         case WINED3DBLEND_DESTALPHA          :
-            rtFormat = getFormatDescEntry(target->resource.format, NULL, NULL);
-            srcBlend = rtFormat->alphaMask ? GL_DST_ALPHA : GL_ONE;
+            srcBlend = target->resource.format_desc->alpha_mask ? GL_DST_ALPHA : GL_ONE;
             break;
         case WINED3DBLEND_INVDESTALPHA       :
-            rtFormat = getFormatDescEntry(target->resource.format, NULL, NULL);
-            srcBlend = rtFormat->alphaMask ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
+            srcBlend = target->resource.format_desc->alpha_mask ? GL_ONE_MINUS_DST_ALPHA : GL_ZERO;
             break;
 
         case WINED3DBLEND_BOTHSRCALPHA       : srcBlend = GL_SRC_ALPHA;
@@ -488,11 +483,10 @@ static void state_alpha(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
 
             if (surf->CKeyFlags & WINEDDSD_CKSRCBLT)
             {
-                const StaticPixelFormatDesc *fmt = getFormatDescEntry(surf->resource.format, NULL, NULL);
                 /* The surface conversion does not do color keying conversion for surfaces that have an alpha
                  * channel on their own. Likewise, the alpha test shouldn't be set up for color keying if the
                  * surface has alpha bits */
-                if (fmt->alphaMask == 0x00000000) enable_ckey = TRUE;
+                if (!surf->resource.format_desc->alpha_mask) enable_ckey = TRUE;
             }
         }
     }
@@ -2930,8 +2924,7 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext
 
             surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0];
 
-            if (surf->CKeyFlags & WINEDDSD_CKSRCBLT
-                    && getFormatDescEntry(surf->resource.format, NULL, NULL)->alphaMask == 0x00000000)
+            if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format_desc->alpha_mask)
             {
                 /* Color keying needs to pass alpha values from the texture through to have the alpha test work
                  * properly. On the other hand applications can still use texture combiners apparently. This code
diff --git a/dlls/wined3d/surface_base.c b/dlls/wined3d/surface_base.c
index 4bd860c..8d04558 100644
--- a/dlls/wined3d/surface_base.c
+++ b/dlls/wined3d/surface_base.c
@@ -508,9 +508,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWin
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-    const struct GlPixelFormatDesc *format_desc;
-    const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(format,
-            &This->resource.wineD3DDevice->adapter->gl_info, &format_desc);
+    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format,
+            &This->resource.wineD3DDevice->adapter->gl_info);
 
     if (This->resource.format != WINED3DFMT_UNKNOWN) {
         FIXME("(%p) : The format of the surface must be WINED3DFORMAT_UNKNOWN\n", This);
@@ -522,19 +521,19 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3D
         This->resource.size = 0;
     } else if (format == WINED3DFMT_DXT1) {
         /* DXT1 is half byte per pixel */
-        This->resource.size = ((max(This->pow2Width, 4) * formatEntry->bpp) * max(This->pow2Height, 4)) >> 1;
+        This->resource.size = ((max(This->pow2Width, 4) * format_desc->byte_count) * max(This->pow2Height, 4)) >> 1;
 
     } else if (format == WINED3DFMT_DXT2 || format == WINED3DFMT_DXT3 ||
                format == WINED3DFMT_DXT4 || format == WINED3DFMT_DXT5) {
-        This->resource.size = ((max(This->pow2Width, 4) * formatEntry->bpp) * max(This->pow2Height, 4));
+        This->resource.size = ((max(This->pow2Width, 4) * format_desc->byte_count) * max(This->pow2Height, 4));
     } else {
         unsigned char alignment = This->resource.wineD3DDevice->surface_alignment;
-        This->resource.size = ((This->pow2Width * formatEntry->bpp) + alignment - 1) & ~(alignment - 1);
+        This->resource.size = ((This->pow2Width * format_desc->byte_count) + alignment - 1) & ~(alignment - 1);
         This->resource.size *= This->pow2Height;
     }
 
     if (format != WINED3DFMT_UNKNOWN) {
-        This->bytesPerPixel = formatEntry->bpp;
+        This->bytesPerPixel = format_desc->byte_count;
     } else {
         This->bytesPerPixel = 0;
     }
@@ -551,12 +550,12 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3D
 
 HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
+    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
     int extraline = 0;
     SYSTEM_INFO sysInfo;
     BITMAPINFO* b_info;
     HDC ddc;
     DWORD *masks;
-    const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(This->resource.format, NULL, NULL);
     UINT usage;
 
     switch (This->bytesPerPixel) {
@@ -628,9 +627,9 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) {
         case WINED3DFMT_R16G16B16A16_UNORM:
             usage = 0;
             b_info->bmiHeader.biCompression = BI_BITFIELDS;
-            masks[0] = formatEntry->redMask;
-            masks[1] = formatEntry->greenMask;
-            masks[2] = formatEntry->blueMask;
+            masks[0] = format_desc->red_mask;
+            masks[1] = format_desc->green_mask;
+            masks[2] = format_desc->blue_mask;
             break;
 
         default:
@@ -919,8 +918,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
     WINED3DLOCKED_RECT  dlock, slock;
     WINED3DFORMAT       dfmt = WINED3DFMT_UNKNOWN, sfmt = WINED3DFMT_UNKNOWN;
     int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
+    const struct GlPixelFormatDesc *sEntry, *dEntry;
     int x, y;
-    const StaticPixelFormatDesc *sEntry, *dEntry;
     const BYTE *sbuf;
     BYTE *dbuf;
     TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
@@ -1099,13 +1098,13 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
         dfmt = This->resource.format;
         slock = dlock;
         sfmt = dfmt;
-        sEntry = getFormatDescEntry(sfmt, NULL, NULL);
+        sEntry = This->resource.format_desc;
         dEntry = sEntry;
     }
     else
     {
         dfmt = This->resource.format;
-        dEntry = getFormatDescEntry(dfmt, NULL, NULL);
+        dEntry = This->resource.format_desc;
         if (Src)
         {
             if(This->resource.format != Src->resource.format) {
@@ -1118,8 +1117,12 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
             }
             IWineD3DSurface_LockRect((IWineD3DSurface *) Src, &slock, NULL, WINED3DLOCK_READONLY);
             sfmt = Src->resource.format;
+            sEntry = Src->resource.format_desc;
+        }
+        else
+        {
+            sEntry = dEntry;
         }
-        sEntry = getFormatDescEntry(sfmt, NULL, NULL);
         if (DestRect)
             IWineD3DSurface_LockRect(iface, &dlock, &xdst, 0);
         else
@@ -1128,7 +1131,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
 
     if (!DDBltFx || !(DDBltFx->dwDDFX)) Flags &= ~WINEDDBLT_DDFX;
 
-    if (sEntry->isFourcc && dEntry->isFourcc)
+    if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_FOURCC)
     {
         if (!DestRect || Src == This)
         {
@@ -1369,9 +1372,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *D
                 }
                 else
                 {
-                    keymask = sEntry->redMask   |
-                            sEntry->greenMask |
-                            sEntry->blueMask;
+                    keymask = sEntry->red_mask
+                            | sEntry->green_mask
+                            | sEntry->blue_mask;
                 }
                 Flags &= ~(WINEDDBLT_KEYSRC | WINEDDBLT_KEYDEST | WINEDDBLT_KEYSRCOVERRIDE | WINEDDBLT_KEYDESTOVERRIDE);
             }
@@ -1563,7 +1566,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
     RECT                lock_src, lock_dst, lock_union;
     const BYTE          *sbuf;
     BYTE                *dbuf;
-    const StaticPixelFormatDesc *sEntry, *dEntry;
+    const struct GlPixelFormatDesc *sEntry, *dEntry;
 
     if (TRACE_ON(d3d_surface))
     {
@@ -1649,7 +1652,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
         assert(This->resource.allocatedMemory != NULL);
         sbuf = This->resource.allocatedMemory + lock_src.top * pitch + lock_src.left * bpp;
         dbuf = This->resource.allocatedMemory + lock_dst.top * pitch + lock_dst.left * bpp;
-        sEntry = getFormatDescEntry(Src->resource.format, NULL, NULL);
+        sEntry = Src->resource.format_desc;
         dEntry = sEntry;
     }
     else
@@ -1663,12 +1666,12 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
         dbuf = dlock.pBits;
         TRACE("Dst is at %p, Src is at %p\n", dbuf, sbuf);
 
-        sEntry = getFormatDescEntry(Src->resource.format, NULL, NULL);
-        dEntry = getFormatDescEntry(This->resource.format, NULL, NULL);
+        sEntry = Src->resource.format_desc;
+        dEntry = This->resource.format_desc;
     }
 
     /* Handle first the FOURCC surfaces... */
-    if (sEntry->isFourcc && dEntry->isFourcc)
+    if (sEntry->Flags & dEntry->Flags & WINED3DFMT_FLAG_FOURCC)
     {
         TRACE("Fourcc -> Fourcc copy\n");
         if (trans)
@@ -1685,7 +1688,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dst
         memcpy(dbuf, sbuf, This->resource.size);
         goto error;
     }
-    if (sEntry->isFourcc && !dEntry->isFourcc)
+    if ((sEntry->Flags & WINED3DFMT_FLAG_FOURCC) && !(dEntry->Flags & WINED3DFMT_FLAG_FOURCC))
     {
         /* TODO: Use the libtxc_dxtn.so shared library to do
          * software decompression
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index eab5dde..670f423 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -289,7 +289,7 @@ const char* filename)
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     static char *output = NULL;
     static UINT size = 0;
-    const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(This->resource.format, NULL, NULL);
+    const struct GlPixelFormatDesc *format_desc = This->resource.format_desc;
 
     if (This->pow2Width > size) {
         output = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->pow2Width * 3);
@@ -334,10 +334,10 @@ const char* filename)
 
         pix_width = This->bytesPerPixel;
 
-        red_shift = get_shift(formatEntry->redMask);
-        green_shift = get_shift(formatEntry->greenMask);
-        blue_shift = get_shift(formatEntry->blueMask);
-        alpha_shift = get_shift(formatEntry->alphaMask);
+        red_shift = get_shift(format_desc->red_mask);
+        green_shift = get_shift(format_desc->green_mask);
+        blue_shift = get_shift(format_desc->blue_mask);
+        alpha_shift = get_shift(format_desc->alpha_mask);
 
         for (y = 0; y < This->pow2Height; y++) {
             const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
@@ -352,11 +352,11 @@ const char* filename)
                 }
                 src += 1 * pix_width;
 
-                comp = color & formatEntry->redMask;
+                comp = color & format_desc->red_mask;
                 output[3 * x + 0] = red_shift > 0 ? comp >> red_shift : comp << -red_shift;
-                comp = color & formatEntry->greenMask;
+                comp = color & format_desc->green_mask;
                 output[3 * x + 1] = green_shift > 0 ? comp >> green_shift : comp << -green_shift;
-                comp = color & formatEntry->alphaMask;
+                comp = color & format_desc->alpha_mask;
                 output[3 * x + 2] = alpha_shift > 0 ? comp >> alpha_shift : comp << -alpha_shift;
             }
             fwrite(output, 3 * This->pow2Width, 1, f);
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 7385654..7a66432 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -28,6 +28,15 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 
+struct StaticPixelFormatDesc
+{
+    WINED3DFORMAT format;
+    DWORD alphaMask, redMask, greenMask, blueMask;
+    UINT bpp;
+    short depthSize, stencilSize;
+    BOOL isFourcc;
+};
+
 /*****************************************************************************
  * Pixel format array
  *
@@ -38,7 +47,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d);
  * setting a mask like 0x1 for those surfaces is correct. The 64 and 128 bit
  * formats are not usable in 2D rendering because ddraw doesn't support them.
  */
-static const StaticPixelFormatDesc formats[] = {
+static const struct StaticPixelFormatDesc formats[] =
+{
   /* WINED3DFORMAT               alphamask    redmask    greenmask    bluemask     bpp    depth  stencil   isFourcc */
     {WINED3DFMT_UNKNOWN,            0x0,        0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
     /* FourCC formats, kept here to have WINED3DFMT_R8G8B8(=20) at position 20 */
@@ -633,8 +643,7 @@ void init_type_lookup(WineD3D_GL_Info *gl_info) {
 
 #define GLINFO_LOCATION This->adapter->gl_info
 
-const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const WineD3D_GL_Info *gl_info,
-        const struct GlPixelFormatDesc **glDesc)
+const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const WineD3D_GL_Info *gl_info)
 {
     int idx = getFmtIdx(fmt);
 
@@ -643,19 +652,8 @@ const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const WineD3D
         /* Get the caller a valid pointer */
         idx = getFmtIdx(WINED3DFMT_UNKNOWN);
     }
-    if(glDesc) {
-        if(!gl_info->gl_formats) {
-            /* If we do not have gl format information, provide a dummy NULL format. This is an easy way to make
-             * all gl caps check return "unsupported" than catching the lack of gl all over the code. ANSI C requires
-             * static variables to be initialized to 0.
-             */
-            static const struct GlPixelFormatDesc dummyFmt;
-            *glDesc = &dummyFmt;
-        } else {
-            *glDesc = &gl_info->gl_formats[idx];
-        }
-    }
-    return &formats[idx];
+
+    return &gl_info->gl_formats[idx];
 }
 
 /*****************************************************************************
@@ -1573,9 +1571,10 @@ unsigned int count_bits(unsigned int mask)
 
 /* Helper function for retrieving color info for ChoosePixelFormat and wglChoosePixelFormatARB.
  * The later function requires individual color components. */
-BOOL getColorBits(WINED3DFORMAT fmt, short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize)
+BOOL getColorBits(const WineD3D_GL_Info *gl_info, WINED3DFORMAT fmt,
+        short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize)
 {
-    const StaticPixelFormatDesc *desc;
+    const struct GlPixelFormatDesc *format_desc;
 
     TRACE("fmt: %s\n", debug_d3dformat(fmt));
     switch(fmt)
@@ -1599,16 +1598,16 @@ BOOL getColorBits(WINED3DFORMAT fmt, short *redSize, short *greenSize, short *bl
             return FALSE;
     }
 
-    desc = getFormatDescEntry(fmt, NULL, NULL);
-    if(!desc)
+    format_desc = getFormatDescEntry(fmt, gl_info);
+    if (!format_desc)
     {
         ERR("Unable to look up format: 0x%x\n", fmt);
         return FALSE;
     }
-    *redSize = count_bits(desc->redMask);
-    *greenSize = count_bits(desc->greenMask);
-    *blueSize = count_bits(desc->blueMask);
-    *alphaSize = count_bits(desc->alphaMask);
+    *redSize = count_bits(format_desc->red_mask);
+    *greenSize = count_bits(format_desc->green_mask);
+    *blueSize = count_bits(format_desc->blue_mask);
+    *alphaSize = count_bits(format_desc->alpha_mask);
     *totalSize = *redSize + *greenSize + *blueSize + *alphaSize;
 
     TRACE("Returning red:  %d, green: %d, blue: %d, alpha: %d, total: %d for fmt=%s\n", *redSize, *greenSize, *blueSize, *alphaSize, *totalSize, debug_d3dformat(fmt));
@@ -1616,9 +1615,9 @@ BOOL getColorBits(WINED3DFORMAT fmt, short *redSize, short *greenSize, short *bl
 }
 
 /* Helper function for retrieving depth/stencil info for ChoosePixelFormat and wglChoosePixelFormatARB */
-BOOL getDepthStencilBits(WINED3DFORMAT fmt, short *depthSize, short *stencilSize)
+BOOL getDepthStencilBits(const WineD3D_GL_Info *gl_info, WINED3DFORMAT fmt, short *depthSize, short *stencilSize)
 {
-    const StaticPixelFormatDesc *desc;
+    const struct GlPixelFormatDesc *format_desc;
 
     TRACE("fmt: %s\n", debug_d3dformat(fmt));
     switch(fmt)
@@ -1638,14 +1637,14 @@ BOOL getDepthStencilBits(WINED3DFORMAT fmt, short *depthSize, short *stencilSize
             return FALSE;
     }
 
-    desc = getFormatDescEntry(fmt, NULL, NULL);
-    if(!desc)
+    format_desc = getFormatDescEntry(fmt, gl_info);
+    if (!format_desc)
     {
         ERR("Unable to look up format: 0x%x\n", fmt);
         return FALSE;
     }
-    *depthSize = desc->depthSize;
-    *stencilSize = desc->stencilSize;
+    *depthSize = format_desc->depth_size;
+    *stencilSize = format_desc->stencil_size;
 
     TRACE("Returning depthSize: %d and stencilSize: %d for fmt=%s\n", *depthSize, *stencilSize, debug_d3dformat(fmt));
     return TRUE;
@@ -2212,8 +2211,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
                 IWineD3DSurfaceImpl *surf;
                 surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0];
 
-                if (surf->CKeyFlags & WINEDDSD_CKSRCBLT
-                        && getFormatDescEntry(surf->resource.format, NULL, NULL)->alphaMask == 0x00000000)
+                if (surf->CKeyFlags & WINEDDSD_CKSRCBLT && !surf->resource.format_desc->alpha_mask)
                 {
                     if (aop == WINED3DTOP_DISABLE)
                     {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index eade311..b545b78 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2096,8 +2096,9 @@ void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int wi
 void surface_set_texture_name(IWineD3DSurface *iface, GLuint name, BOOL srgb_name);
 void surface_set_texture_target(IWineD3DSurface *iface, GLenum target);
 
-BOOL getColorBits(WINED3DFORMAT fmt, short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize);
-BOOL getDepthStencilBits(WINED3DFORMAT fmt, short *depthSize, short *stencilSize);
+BOOL getColorBits(const WineD3D_GL_Info *gl_info, WINED3DFORMAT fmt,
+        short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize);
+BOOL getDepthStencilBits(const WineD3D_GL_Info *gl_info, WINED3DFORMAT fmt, short *depthSize, short *stencilSize);
 
 /* Math utils */
 void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2);
@@ -2499,16 +2500,7 @@ struct GlPixelFormatDesc
     struct color_fixup_desc color_fixup;
 };
 
-typedef struct {
-    WINED3DFORMAT           format;
-    DWORD                   alphaMask, redMask, greenMask, blueMask;
-    UINT                    bpp;
-    short                   depthSize, stencilSize;
-    BOOL                    isFourcc;
-} StaticPixelFormatDesc;
-
-const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
-        const WineD3D_GL_Info *gl_info, const struct GlPixelFormatDesc **glDesc);
+const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const WineD3D_GL_Info *gl_info);
 
 static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
 {
-- 
1.6.0.6



--------------060308060803070700060407--



More information about the wine-patches mailing list