[PATCH] Check the render target capabilities of a format based on WGL pixel formats when available. Again this function is needed for CheckDeviceFormat.

Roderick Colenbrander thunderbird2k at gmx.net
Mon Mar 3 16:17:04 CST 2008


---
 dlls/wined3d/directx.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index e99e728..170b3a5 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -1902,6 +1902,72 @@ static BOOL CheckFilterCapability(WINED3DFORMAT CheckFormat)
     return TRUE;
 }
 
+/* Check the render target capabilities of a format */
+static BOOL CheckRenderTargetCapability(WINED3DFORMAT AdapterFormat, WINED3DFORMAT CheckFormat)
+{
+    UINT Adapter = 0;
+
+    /* Filter out non-RT formats */
+    switch(CheckFormat)
+    {
+        /* Don't offer 8bit, windows doesn't either although we could emulate it */
+        case WINED3DFMT_A8P8:
+        case WINED3DFMT_P8:
+
+        /* No DXTC render targets */
+        case WINED3DFMT_DXT1:
+        case WINED3DFMT_DXT2:
+        case WINED3DFMT_DXT3:
+        case WINED3DFMT_DXT4:
+        case WINED3DFMT_DXT5:
+            return FALSE;
+        default:
+            break;
+    }
+
+    if(wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) {
+        WineD3D_PixelFormat *cfgs = Adapters[Adapter].cfgs;
+        int it;
+        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);
+
+        /* 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))) {
+            TRACE_(d3d_caps)("[FAILED]\n");
+            return FALSE;
+        }
+
+        /* Check if there is a WGL pixel format matching the requirements, the format should also be window drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
+        for (it = 0; it < Adapters[Adapter].nCfgs; ++it) {
+            if (cfgs[it].windowDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&cfgs[it], CheckFormat)) {
+                TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n", cfgs[it].iPixelFormat, debug_d3dformat(CheckFormat));
+                return TRUE;
+            }
+        }
+    } else if(wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER) {
+        /* We can propably use this function in FBO mode too on some drivers to get some basic indication of the capabilities. */
+        WineD3D_PixelFormat *cfgs = Adapters[Adapter].cfgs;
+        int it;
+
+        /* Check if there is a WGL pixel format matching the requirements, the pixel format should also be usable with pbuffers */
+        for (it = 0; it < Adapters[Adapter].nCfgs; ++it) {
+            if (cfgs[it].pbufferDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&cfgs[it], CheckFormat)) {
+                TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n", cfgs[it].iPixelFormat, debug_d3dformat(CheckFormat));
+                return TRUE;
+            }
+        }
+    } else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO){
+        /* For now return TRUE for FBOs until we have some proper checks.
+         * Note that this function will only be called when the format is around for texturing. */
+        return TRUE;
+    }
+    return FALSE;
+}
+
 static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, 
                                               WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) {
     IWineD3DImpl *This = (IWineD3DImpl *)iface;
-- 
1.5.3.4


--========GMX256311204622661809962--



More information about the wine-patches mailing list