[PATCH 2/4] wined3d: Add support for the NULL format.

Henri Verbeet hverbeet at codeweavers.com
Wed Jan 26 12:45:03 CST 2011


Note that there's no reason this couldn't be supported with just EXT_fbo as
well, except for lack of testing. Compared to the previous version of this
patch this also takes NULL render targets into account when updating the draw
buffers, as pointed out by Stefan. However, it's worth noting that the NVIDIA
drivers don't seem to take draw buffers into account when determining FBO
completeness.
---
 dlls/wined3d/context.c   |    7 ++++---
 dlls/wined3d/directx.c   |    5 +++++
 dlls/wined3d/utils.c     |    7 +++++++
 include/wine/wined3d.idl |    1 +
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index d9bb5d8..b7abc0f 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -271,7 +271,7 @@ static void context_attach_surface_fbo(const struct wined3d_context *context,
 
     TRACE("Attach surface %p to %u\n", surface, idx);
 
-    if (surface)
+    if (surface && surface->resource.format->id != WINED3DFMT_NULL)
     {
         switch (location)
         {
@@ -1932,7 +1932,7 @@ static void context_apply_draw_buffers(struct wined3d_context *context, UINT rt_
 
             for (i = 0; i < gl_info->limits.buffers; ++i)
             {
-                if (i < rt_count && rts[i])
+                if (i < rt_count && rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL)
                     context->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
                 else
                     context->draw_buffers[i] = GL_NONE;
@@ -2062,7 +2062,8 @@ static BOOL context_validate_rt_config(UINT rt_count,
 
     for (i = 0; i < rt_count; ++i)
     {
-        if (rts[i]) return TRUE;
+        if (rts[i] && rts[i]->resource.format->id != WINED3DFMT_NULL)
+            return TRUE;
     }
 
     WARN("Invalid render target config, need at least one attachment.\n");
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index e39bd3a..85d50ec 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -3470,6 +3470,11 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, const struct
             TRACE_(d3d_caps)("[FAILED]\n");
             return FALSE;
 
+        case WINED3DFMT_NULL:
+            if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
+                return TRUE;
+            return FALSE;
+
         case WINED3DFMT_UNKNOWN:
             return FALSE;
 
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index c114f10..6a529ea 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -133,6 +133,7 @@ static const struct StaticPixelFormatDesc formats[] =
     {WINED3DFMT_INTZ,                       0x0,        0x0,        0x0,        0x0,        4,      24,     8},
     {WINED3DFMT_NVHU,                       0x0,        0x0,        0x0,        0x0,        2,      0,      0},
     {WINED3DFMT_NVHS,                       0x0,        0x0,        0x0,        0x0,        2,      0,      0},
+    {WINED3DFMT_NULL,                       0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4,      0,      0},
 };
 
 struct wined3d_format_base_flags
@@ -158,6 +159,7 @@ static const struct wined3d_format_base_flags format_base_flags[] =
     {WINED3DFMT_G8R8_G8B8,          WINED3DFMT_FLAG_FOURCC},
     {WINED3DFMT_R8G8_B8G8,          WINED3DFMT_FLAG_FOURCC},
     {WINED3DFMT_INTZ,               WINED3DFMT_FLAG_FOURCC},
+    {WINED3DFMT_NULL,               WINED3DFMT_FLAG_FOURCC},
     {WINED3DFMT_P8_UINT,            WINED3DFMT_FLAG_GETDC},
     {WINED3DFMT_B8G8R8_UNORM,       WINED3DFMT_FLAG_GETDC},
     {WINED3DFMT_B8G8R8A8_UNORM,     WINED3DFMT_FLAG_GETDC},
@@ -868,6 +870,10 @@ static const struct wined3d_format_texture_info format_texture_info[] =
             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH
             | WINED3DFMT_FLAG_STENCIL,
             ARB_FRAMEBUFFER_OBJECT,     NULL},
+    {WINED3DFMT_NULL,                   GL_RGBA8,                         GL_RGBA8,                               0,
+            GL_RGBA,                    GL_UNSIGNED_INT_8_8_8_8_REV,      0,
+            WINED3DFMT_FLAG_RENDERTARGET,
+            ARB_FRAMEBUFFER_OBJECT,     NULL},
 };
 
 static inline int getFmtIdx(enum wined3d_format_id format_id)
@@ -1740,6 +1746,7 @@ const char *debug_d3dformat(enum wined3d_format_id format_id)
         FMT_TO_STR(WINED3DFMT_B8G8R8A8_UNORM);
         FMT_TO_STR(WINED3DFMT_B8G8R8X8_UNORM);
         FMT_TO_STR(WINED3DFMT_INTZ);
+        FMT_TO_STR(WINED3DFMT_NULL);
 #undef FMT_TO_STR
         default:
         {
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index 523d7fc..90d0a79 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -275,6 +275,7 @@ enum wined3d_format_id
     WINED3DFMT_NVHU                         = WINEMAKEFOURCC('N','V','H','U'),
     WINED3DFMT_NVHS                         = WINEMAKEFOURCC('N','V','H','S'),
     WINED3DFMT_INTZ                         = WINEMAKEFOURCC('I','N','T','Z'),
+    WINED3DFMT_NULL                         = WINEMAKEFOURCC('N','U','L','L'),
 
     WINED3DFMT_FORCE_DWORD = 0xffffffff
 };
-- 
1.7.3.4




More information about the wine-patches mailing list