[PATCH 3/5] wined3d: Introduce a separate structure for framebuffer state.

Henri Verbeet hverbeet at codeweavers.com
Wed May 18 15:30:15 CDT 2011


---
 dlls/wined3d/arb_program_shader.c |    4 +-
 dlls/wined3d/context.c            |   10 ++--
 dlls/wined3d/device.c             |   98 ++++++++++++++++++-------------------
 dlls/wined3d/drawprim.c           |    8 ++--
 dlls/wined3d/glsl_shader.c        |    6 +-
 dlls/wined3d/shader.c             |    2 +-
 dlls/wined3d/state.c              |   16 +++---
 dlls/wined3d/surface.c            |   23 +++++----
 dlls/wined3d/swapchain.c          |   13 +++--
 dlls/wined3d/utils.c              |    2 +-
 dlls/wined3d/wined3d_private.h    |   11 +++-
 11 files changed, 99 insertions(+), 94 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index b3d40b2..55b31bc 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -649,7 +649,7 @@ static void shader_arb_load_constants(const struct wined3d_context *context, cha
     {
         struct wined3d_shader *pshader = stateBlock->state.pixel_shader;
         const struct arb_ps_compiled_shader *gl_shader = priv->compiled_fprog;
-        UINT rt_height = device->render_targets[0]->resource.height;
+        UINT rt_height = device->fb.render_targets[0]->resource.height;
 
         /* Load DirectX 9 float constants for pixel shader */
         device->highest_dirty_ps_const = shader_arb_load_constantsF(pshader, gl_info, GL_FRAGMENT_PROGRAM_ARB,
@@ -4630,7 +4630,7 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS,
         }
         else
         {
-            UINT rt_height = device->render_targets[0]->resource.height;
+            UINT rt_height = device->fb.render_targets[0]->resource.height;
             shader_arb_ps_local_constants(compiled, context, state, rt_height);
         }
 
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 26fc7a9..0b7f10f 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2224,10 +2224,11 @@ BOOL context_apply_clear_state(struct wined3d_context *context, struct wined3d_d
 BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_device *device)
 {
     const struct StateEntry *state_table = device->StateTable;
+    const struct wined3d_fb_state *fb = &device->fb;
     unsigned int i;
 
     if (!context_validate_rt_config(context->gl_info->limits.buffers,
-            device->render_targets, device->depth_stencil))
+            fb->render_targets, fb->depth_stencil))
         return FALSE;
 
     /* Preload resources before FBO setup. Texture preload in particular may
@@ -2240,7 +2241,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
 
     if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
     {
-        context_validate_onscreen_formats(device, context, device->depth_stencil);
+        context_validate_onscreen_formats(device, context, fb->depth_stencil);
 
         if (!context->render_offscreen)
         {
@@ -2251,8 +2252,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
         else
         {
             ENTER_GL();
-            context_apply_fbo_state(context, GL_FRAMEBUFFER, device->render_targets,
-                    device->depth_stencil, SFLAG_INTEXTURE);
+            context_apply_fbo_state(context, GL_FRAMEBUFFER, fb->render_targets, fb->depth_stencil, SFLAG_INTEXTURE);
             glReadBuffer(GL_NONE);
             checkGLcall("glReadBuffer");
             LEAVE_GL();
@@ -2261,7 +2261,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
 
     if (context->draw_buffer_dirty)
     {
-        context_apply_draw_buffers(context, context->gl_info->limits.buffers, device->render_targets);
+        context_apply_draw_buffers(context, context->gl_info->limits.buffers, fb->render_targets);
         context->draw_buffer_dirty = FALSE;
     }
 
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 00706ee..0cbb766 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1166,12 +1166,12 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
     device->updateStateBlock = device->stateBlock;
     wined3d_stateblock_incref(device->updateStateBlock);
 
-    device->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
-            sizeof(*device->render_targets) * gl_info->limits.buffers);
+    device->fb.render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+            sizeof(*device->fb.render_targets) * gl_info->limits.buffers);
 
     device->palette_count = 1;
     device->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*));
-    if (!device->palettes || !device->render_targets)
+    if (!device->palettes || !device->fb.render_targets)
     {
         ERR("Out of memory!\n");
         hr = E_OUTOFMEMORY;
@@ -1232,19 +1232,19 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
     if (swapchain->back_buffers && swapchain->back_buffers[0])
     {
         TRACE("Setting rendertarget to %p.\n", swapchain->back_buffers);
-        device->render_targets[0] = swapchain->back_buffers[0];
+        device->fb.render_targets[0] = swapchain->back_buffers[0];
     }
     else
     {
         TRACE("Setting rendertarget to %p.\n", swapchain->front_buffer);
-        device->render_targets[0] = swapchain->front_buffer;
+        device->fb.render_targets[0] = swapchain->front_buffer;
     }
-    wined3d_surface_incref(device->render_targets[0]);
+    wined3d_surface_incref(device->fb.render_targets[0]);
 
     /* Depth Stencil support */
-    device->depth_stencil = device->auto_depth_stencil;
-    if (device->depth_stencil)
-        wined3d_surface_incref(device->depth_stencil);
+    device->fb.depth_stencil = device->auto_depth_stencil;
+    if (device->fb.depth_stencil)
+        wined3d_surface_incref(device->fb.depth_stencil);
 
     hr = device->shader_backend->shader_alloc_private(device);
     if (FAILED(hr))
@@ -1322,7 +1322,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
     return WINED3D_OK;
 
 err_out:
-    HeapFree(GetProcessHeap(), 0, device->render_targets);
+    HeapFree(GetProcessHeap(), 0, device->fb.render_targets);
     HeapFree(GetProcessHeap(), 0, device->swapchains);
     device->swapchain_count = 0;
     if (device->palettes)
@@ -1487,13 +1487,13 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
         wined3d_surface_decref(surface);
     }
 
-    if (device->depth_stencil)
+    if (device->fb.depth_stencil)
     {
-        surface = device->depth_stencil;
+        surface = device->fb.depth_stencil;
 
         TRACE("Releasing depth/stencil buffer %p.\n", surface);
 
-        device->depth_stencil = NULL;
+        device->fb.depth_stencil = NULL;
         if (wined3d_surface_decref(surface)
                 && surface != device->auto_depth_stencil)
             ERR("Something is still holding a reference to depth/stencil buffer %p.\n", surface);
@@ -1512,9 +1512,9 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
         wined3d_device_set_render_target(device, i, NULL, FALSE);
     }
 
-    surface = device->render_targets[0];
+    surface = device->fb.render_targets[0];
     TRACE("Setting rendertarget 0 to NULL\n");
-    device->render_targets[0] = NULL;
+    device->fb.render_targets[0] = NULL;
     TRACE("Releasing the render target at %p\n", surface);
     wined3d_surface_decref(surface);
 
@@ -1537,8 +1537,8 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
     device->palettes = NULL;
     device->palette_count = 0;
 
-    HeapFree(GetProcessHeap(), 0, device->render_targets);
-    device->render_targets = NULL;
+    HeapFree(GetProcessHeap(), 0, device->fb.render_targets);
+    device->fb.render_targets = NULL;
 
     device->d3d_initialized = FALSE;
 
@@ -4025,7 +4025,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
 
     if (flags & (WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL))
     {
-        struct wined3d_surface *ds = device->depth_stencil;
+        struct wined3d_surface *ds = device->fb.depth_stencil;
         if (!ds)
         {
             WARN("Clearing depth and/or stencil without a depth stencil buffer attached, returning WINED3DERR_INVALIDCALL\n");
@@ -4034,8 +4034,8 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
         }
         else if (flags & WINED3DCLEAR_TARGET)
         {
-            if(ds->resource.width < device->render_targets[0]->resource.width ||
-               ds->resource.height < device->render_targets[0]->resource.height)
+            if (ds->resource.width < device->fb.render_targets[0]->resource.width
+                    || ds->resource.height < device->fb.render_targets[0]->resource.height)
             {
                 WARN("Silently ignoring depth and target clear with mismatching sizes\n");
                 return WINED3D_OK;
@@ -4046,7 +4046,7 @@ HRESULT CDECL wined3d_device_clear(struct wined3d_device *device, DWORD rect_cou
     device_get_draw_rect(device, &draw_rect);
 
     return device_clear_render_targets(device, device->adapter->gl_info.limits.buffers,
-            device->render_targets, device->depth_stencil, rect_count, rects,
+            device->fb.render_targets, device->fb.depth_stencil, rect_count, rects,
             &draw_rect, flags, &c, depth, stencil);
 }
 
@@ -4480,8 +4480,8 @@ HRESULT CDECL wined3d_device_validate_device(struct wined3d_device *device, DWOR
     if (state->render_states[WINED3DRS_ZENABLE] || state->render_states[WINED3DRS_ZWRITEENABLE] ||
         state->render_states[WINED3DRS_STENCILENABLE])
     {
-        struct wined3d_surface *ds = device->depth_stencil;
-        struct wined3d_surface *target = device->render_targets[0];
+        struct wined3d_surface *ds = device->fb.depth_stencil;
+        struct wined3d_surface *target = device->fb.render_targets[0];
 
         if(ds && target
                 && (ds->resource.width < target->resource.width || ds->resource.height < target->resource.height))
@@ -5042,7 +5042,7 @@ HRESULT CDECL wined3d_device_get_render_target(struct wined3d_device *device,
         return WINED3DERR_INVALIDCALL;
     }
 
-    *render_target = device->render_targets[render_target_idx];
+    *render_target = device->fb.render_targets[render_target_idx];
     if (*render_target)
         wined3d_surface_incref(*render_target);
 
@@ -5055,7 +5055,7 @@ HRESULT CDECL wined3d_device_get_depth_stencil(struct wined3d_device *device, st
 {
     TRACE("device %p, depth_stencil %p.\n", device, depth_stencil);
 
-    *depth_stencil = device->depth_stencil;
+    *depth_stencil = device->fb.depth_stencil;
     TRACE("Returning depth/stencil surface %p.\n", *depth_stencil);
 
     if (!*depth_stencil)
@@ -5080,7 +5080,7 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
         return WINED3DERR_INVALIDCALL;
     }
 
-    prev = device->render_targets[render_target_idx];
+    prev = device->fb.render_targets[render_target_idx];
     if (render_target == prev)
     {
         TRACE("Trying to do a NOP SetRenderTarget operation.\n");
@@ -5102,7 +5102,7 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
 
     if (render_target)
         wined3d_surface_incref(render_target);
-    device->render_targets[render_target_idx] = render_target;
+    device->fb.render_targets[render_target_idx] = render_target;
     /* Release after the assignment, to prevent device_resource_released()
      * from seeing the surface as still in use. */
     if (prev)
@@ -5114,8 +5114,8 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
         /* Set the viewport and scissor rectangles, if requested. Tests show
          * that stateblock recording is ignored, the change goes directly
          * into the primary stateblock. */
-        device->stateBlock->state.viewport.Height = device->render_targets[0]->resource.height;
-        device->stateBlock->state.viewport.Width  = device->render_targets[0]->resource.width;
+        device->stateBlock->state.viewport.Height = device->fb.render_targets[0]->resource.height;
+        device->stateBlock->state.viewport.Width  = device->fb.render_targets[0]->resource.width;
         device->stateBlock->state.viewport.X      = 0;
         device->stateBlock->state.viewport.Y      = 0;
         device->stateBlock->state.viewport.MaxZ   = 1.0f;
@@ -5134,26 +5134,25 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device,
 
 HRESULT CDECL wined3d_device_set_depth_stencil(struct wined3d_device *device, struct wined3d_surface *depth_stencil)
 {
-    struct wined3d_surface *tmp;
+    struct wined3d_surface *prev = device->fb.depth_stencil;
 
     TRACE("device %p, depth_stencil %p, old depth_stencil %p.\n",
-            device, depth_stencil, device->depth_stencil);
+            device, depth_stencil, prev);
 
-    if (device->depth_stencil == depth_stencil)
+    if (prev == depth_stencil)
     {
         TRACE("Trying to do a NOP SetRenderTarget operation.\n");
         return WINED3D_OK;
     }
 
-    if (device->depth_stencil)
+    if (prev)
     {
         if (device->swapchains[0]->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
-                || device->depth_stencil->flags & SFLAG_DISCARD)
+                || prev->flags & SFLAG_DISCARD)
         {
-            surface_modify_ds_location(device->depth_stencil, SFLAG_DS_DISCARDED,
-                    device->depth_stencil->resource.width,
-                    device->depth_stencil->resource.height);
-            if (device->depth_stencil == device->onscreen_depth_stencil)
+            surface_modify_ds_location(prev, SFLAG_DS_DISCARDED,
+                    prev->resource.width, prev->resource.height);
+            if (prev == device->onscreen_depth_stencil)
             {
                 wined3d_surface_decref(device->onscreen_depth_stencil);
                 device->onscreen_depth_stencil = NULL;
@@ -5161,14 +5160,13 @@ HRESULT CDECL wined3d_device_set_depth_stencil(struct wined3d_device *device, st
         }
     }
 
-    tmp = device->depth_stencil;
-    device->depth_stencil = depth_stencil;
-    if (device->depth_stencil)
-        wined3d_surface_incref(device->depth_stencil);
-    if (tmp)
-        wined3d_surface_decref(tmp);
+    device->fb.depth_stencil = depth_stencil;
+    if (depth_stencil)
+        wined3d_surface_incref(depth_stencil);
+    if (prev)
+        wined3d_surface_decref(prev);
 
-    if ((!tmp && depth_stencil) || (!depth_stencil && tmp))
+    if (!prev != !depth_stencil)
     {
         /* Swapping NULL / non NULL depth stencil affects the depth and tests */
         IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_ZENABLE));
@@ -5176,7 +5174,7 @@ HRESULT CDECL wined3d_device_set_depth_stencil(struct wined3d_device *device, st
         IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_STENCILWRITEMASK));
         IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_DEPTHBIAS));
     }
-    else if (tmp && tmp->resource.format->depth_size != device->depth_stencil->resource.format->depth_size)
+    else if (prev && prev->resource.format->depth_size != depth_stencil->resource.format->depth_size)
     {
         IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_DEPTHBIAS));
     }
@@ -5968,17 +5966,17 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso
 
                 for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i)
                 {
-                    if (device->render_targets[i] == surface)
+                    if (device->fb.render_targets[i] == surface)
                     {
                         ERR("Surface %p is still in use as render target %u.\n", surface, i);
-                        device->render_targets[i] = NULL;
+                        device->fb.render_targets[i] = NULL;
                     }
                 }
 
-                if (device->depth_stencil == surface)
+                if (device->fb.depth_stencil == surface)
                 {
                     ERR("Surface %p is still in use as depth/stencil buffer.\n", surface);
-                    device->depth_stencil = NULL;
+                    device->fb.depth_stencil = NULL;
                 }
             }
             break;
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 8b90cf9..4dbba92 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -571,7 +571,7 @@ void drawPrimitive(struct wined3d_device *device, UINT index_count, UINT StartId
         /* Invalidate the back buffer memory so LockRect will read it the next time */
         for (i = 0; i < device->adapter->gl_info.limits.buffers; ++i)
         {
-            struct wined3d_surface *target = device->render_targets[i];
+            struct wined3d_surface *target = device->fb.render_targets[i];
             if (target)
             {
                 surface_load_location(target, SFLAG_INDRAWABLE, NULL);
@@ -583,7 +583,7 @@ void drawPrimitive(struct wined3d_device *device, UINT index_count, UINT StartId
     /* Signals other modules that a drawing is in progress and the stateblock finalized */
     device->isInDraw = TRUE;
 
-    context = context_acquire(device, device->render_targets[0]);
+    context = context_acquire(device, device->fb.render_targets[0]);
     if (!context->valid)
     {
         context_release(context);
@@ -598,7 +598,7 @@ void drawPrimitive(struct wined3d_device *device, UINT index_count, UINT StartId
         return;
     }
 
-    if (device->depth_stencil)
+    if (device->fb.depth_stencil)
     {
         /* Note that this depends on the context_acquire() call above to set
          * context->render_offscreen properly. We don't currently take the
@@ -608,7 +608,7 @@ void drawPrimitive(struct wined3d_device *device, UINT index_count, UINT StartId
         DWORD location = context->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN;
         if (state->render_states[WINED3DRS_ZWRITEENABLE] || state->render_states[WINED3DRS_ZENABLE])
         {
-            struct wined3d_surface *ds = device->depth_stencil;
+            struct wined3d_surface *ds = device->fb.depth_stencil;
             RECT current_rect, draw_rect, r;
 
             if (location == SFLAG_DS_ONSCREEN && ds != device->onscreen_depth_stencil)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index e9b378e..9b8cd5b 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -918,10 +918,10 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
         struct wined3d_shader_buffer *buffer, struct wined3d_shader *shader,
         const struct wined3d_shader_reg_maps *reg_maps, struct shader_glsl_ctx_priv *ctx_priv)
 {
-    struct wined3d_device *device = shader->device;
-    const struct wined3d_state *state = &device->stateBlock->state;
+    const struct wined3d_state *state = &shader->device->stateBlock->state;
     const struct ps_compile_args *ps_args = ctx_priv->cur_ps_args;
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    const struct wined3d_fb_state *fb = &shader->device->fb;
     unsigned int i, extra_constants_needed = 0;
     const local_constant *lconst;
     DWORD map;
@@ -1050,7 +1050,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont
                  */
                 FIXME("Cannot find a free uniform for vpos correction params\n");
                 shader_addline(buffer, "const vec4 ycorrection = vec4(%f, %f, 0.0, 0.0);\n",
-                        context->render_offscreen ? 0.0f : device->render_targets[0]->resource.height,
+                        context->render_offscreen ? 0.0f : fb->render_targets[0]->resource.height,
                         context->render_offscreen ? 1.0f : -1.0f);
             }
             shader_addline(buffer, "vec4 vpos;\n");
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index da82bd8..37ec3af 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -1874,7 +1874,7 @@ void find_ps_compile_args(const struct wined3d_state *state,
     memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
     if (state->render_states[WINED3DRS_SRGBWRITEENABLE])
     {
-        struct wined3d_surface *rt = device->render_targets[0];
+        struct wined3d_surface *rt = device->fb.render_targets[0];
         if (rt->resource.format->flags & WINED3DFMT_FLAG_SRGB_WRITE) args->srgb_correction = 1;
     }
 
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 70e39d7..4819f8d 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -97,7 +97,7 @@ static void state_lighting(DWORD state, struct wined3d_stateblock *stateblock, s
 static void state_zenable(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
 {
     /* No z test without depth stencil buffers */
-    if (!stateblock->device->depth_stencil)
+    if (!stateblock->device->fb.depth_stencil)
     {
         TRACE("No Z buffer - disabling depth test\n");
         glDisable(GL_DEPTH_TEST); /* This also disables z writing in gl */
@@ -284,7 +284,7 @@ static GLenum gl_blend_factor(WINED3DBLEND factor, const struct wined3d_format *
 
 static void state_blend(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
 {
-    struct wined3d_surface *target = stateblock->device->render_targets[0];
+    struct wined3d_surface *target = stateblock->device->fb.render_targets[0];
     const struct wined3d_gl_info *gl_info = context->gl_info;
     GLenum srcBlend, dstBlend;
     WINED3DBLEND d3d_blend;
@@ -794,7 +794,7 @@ static void state_stencil(DWORD state, struct wined3d_stateblock *stateblock, st
     GLint stencilPass_ccw = GL_KEEP;
 
     /* No stencil test without a stencil buffer. */
-    if (!stateblock->device->depth_stencil)
+    if (!stateblock->device->fb.depth_stencil)
     {
         glDisable(GL_STENCIL_TEST);
         checkGLcall("glDisable GL_STENCIL_TEST");
@@ -877,7 +877,7 @@ static void state_stencil(DWORD state, struct wined3d_stateblock *stateblock, st
 
 static void state_stencilwrite2s(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
 {
-    DWORD mask = stateblock->device->depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
+    DWORD mask = stateblock->device->fb.depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
     GL_EXTCALL(glActiveStencilFaceEXT(GL_BACK));
@@ -891,7 +891,7 @@ static void state_stencilwrite2s(DWORD state, struct wined3d_stateblock *statebl
 
 static void state_stencilwrite(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
 {
-    DWORD mask = stateblock->device->depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
+    DWORD mask = stateblock->device->fb.depth_stencil ? stateblock->state.render_states[WINED3DRS_STENCILWRITEMASK] : 0;
 
     glStencilMask(mask);
     checkGLcall("glStencilMask");
@@ -1688,7 +1688,7 @@ static void state_depthbias(DWORD state, struct wined3d_stateblock *stateblock,
     if (stateblock->state.render_states[WINED3DRS_SLOPESCALEDEPTHBIAS]
             || stateblock->state.render_states[WINED3DRS_DEPTHBIAS])
     {
-        struct wined3d_surface *depth = stateblock->device->depth_stencil;
+        struct wined3d_surface *depth = stateblock->device->fb.depth_stencil;
         float scale;
 
         union
@@ -4654,7 +4654,7 @@ static void vertexdeclaration(DWORD state_id, struct wined3d_stateblock *statebl
 
 static void viewport_miscpart(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
 {
-    struct wined3d_surface *target = stateblock->device->render_targets[0];
+    struct wined3d_surface *target = stateblock->device->fb.render_targets[0];
     UINT width, height;
     WINED3DVIEWPORT vp = stateblock->state.viewport;
 
@@ -4810,7 +4810,7 @@ static void light(DWORD state, struct wined3d_stateblock *stateblock, struct win
 
 static void scissorrect(DWORD state, struct wined3d_stateblock *stateblock, struct wined3d_context *context)
 {
-    struct wined3d_surface *target = stateblock->device->render_targets[0];
+    struct wined3d_surface *target = stateblock->device->fb.render_targets[0];
     RECT *pRect = &stateblock->state.scissor_rect;
     UINT height;
     UINT width;
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 862ba07..91b16a6 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -861,7 +861,8 @@ static void surface_map(struct wined3d_surface *surface, const RECT *rect, DWORD
             pass_rect = NULL;
 
         if (!(wined3d_settings.rendertargetlock_mode == RTL_DISABLE
-                && ((surface->container.type == WINED3D_CONTAINER_SWAPCHAIN) || surface == device->render_targets[0])))
+                && ((surface->container.type == WINED3D_CONTAINER_SWAPCHAIN)
+                || surface == device->fb.render_targets[0])))
             surface_load_location(surface, SFLAG_INSYSMEM, pass_rect);
     }
 
@@ -952,7 +953,7 @@ static void surface_unmap(struct wined3d_surface *surface)
     }
 
     if (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
-            || (device->render_targets && surface == device->render_targets[0]))
+            || (device->fb.render_targets && surface == device->fb.render_targets[0]))
     {
         if (wined3d_settings.rendertargetlock_mode == RTL_DISABLE)
         {
@@ -1404,7 +1405,7 @@ static HRESULT surface_bltfast(struct wined3d_surface *dst_surface, DWORD dst_x,
         return WINEDDERR_SURFACEBUSY;
     }
 
-    if (device->inScene && (dst_surface == device->depth_stencil || src_surface == device->depth_stencil))
+    if (device->inScene && (dst_surface == device->fb.depth_stencil || src_surface == device->fb.depth_stencil))
     {
         WARN("Attempt to access the depth / stencil surface while in a scene.\n");
         return WINED3DERR_INVALIDCALL;
@@ -1987,9 +1988,9 @@ void surface_bind(struct wined3d_surface *surface, const struct wined3d_gl_info
 /* This function checks if the primary render target uses the 8bit paletted format. */
 static BOOL primary_render_target_is_p8(struct wined3d_device *device)
 {
-    if (device->render_targets && device->render_targets[0])
+    if (device->fb.render_targets && device->fb.render_targets[0])
     {
-        struct wined3d_surface *render_target = device->render_targets[0];
+        struct wined3d_surface *render_target = device->fb.render_targets[0];
         if ((render_target->resource.usage & WINED3DUSAGE_RENDERTARGET)
                 && (render_target->resource.format->id == WINED3DFMT_P8_UINT))
             return TRUE;
@@ -4159,7 +4160,7 @@ HRESULT d3dfmt_get_conv(struct wined3d_surface *surface, BOOL need_alpha_ck,
              * in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which
              * conflicts with this.
              */
-            if (!((blit_supported && device->render_targets && surface == device->render_targets[0]))
+            if (!((blit_supported && device->fb.render_targets && surface == device->fb.render_targets[0]))
                     || colorkey_active || !use_texturing)
             {
                 format->glFormat = GL_RGBA;
@@ -5245,8 +5246,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(struct wined3d_surface *dst_surfa
 
     /* Early sort out of cases where no render target is used */
     if (!dstSwapchain && !srcSwapchain
-            && src_surface != device->render_targets[0]
-            && dst_surface != device->render_targets[0])
+            && src_surface != device->fb.render_targets[0]
+            && dst_surface != device->fb.render_targets[0])
     {
         TRACE("No surface is render target, not using hardware blit.\n");
         return WINED3DERR_INVALIDCALL;
@@ -5370,16 +5371,16 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(struct wined3d_surface *dst_surfa
     else if (dstSwapchain)
     {
         /* Handled with regular texture -> swapchain blit */
-        if (src_surface == device->render_targets[0])
+        if (src_surface == device->fb.render_targets[0])
             TRACE("Blit from active render target to a swapchain\n");
     }
-    else if (srcSwapchain && dst_surface == device->render_targets[0])
+    else if (srcSwapchain && dst_surface == device->fb.render_targets[0])
     {
         FIXME("Implement blit from a swapchain to the active render target\n");
         return WINED3DERR_INVALIDCALL;
     }
 
-    if ((srcSwapchain || src_surface == device->render_targets[0]) && !dstSwapchain)
+    if ((srcSwapchain || src_surface == device->fb.render_targets[0]) && !dstSwapchain)
     {
         /* Blit from render target to texture */
         BOOL stretchx;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index a57d185..0b32eca 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -406,6 +406,7 @@ static void swapchain_blit(struct wined3d_swapchain *swapchain,
 static HRESULT swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect_in,
         const RECT *dst_rect_in, const RGNDATA *dirty_region, DWORD flags)
 {
+    const struct wined3d_fb_state *fb = &swapchain->device->fb;
     const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
     RECT src_rect, dst_rect;
@@ -615,15 +616,15 @@ static HRESULT swapchain_gl_present(struct wined3d_swapchain *swapchain, const R
             surface_modify_location(swapchain->back_buffers[0], SFLAG_INDRAWABLE, TRUE);
     }
 
-    if (swapchain->device->depth_stencil)
+    if (fb->depth_stencil)
     {
         if (swapchain->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
-                || swapchain->device->depth_stencil->flags & SFLAG_DISCARD)
+                || fb->depth_stencil->flags & SFLAG_DISCARD)
         {
-            surface_modify_ds_location(swapchain->device->depth_stencil, SFLAG_DS_DISCARDED,
-                    swapchain->device->depth_stencil->resource.width,
-                    swapchain->device->depth_stencil->resource.height);
-            if (swapchain->device->depth_stencil == swapchain->device->onscreen_depth_stencil)
+            surface_modify_ds_location(fb->depth_stencil, SFLAG_DS_DISCARDED,
+                    fb->depth_stencil->resource.width,
+                    fb->depth_stencil->resource.height);
+            if (fb->depth_stencil == swapchain->device->onscreen_depth_stencil)
             {
                 wined3d_surface_decref(swapchain->device->onscreen_depth_stencil);
                 swapchain->device->onscreen_depth_stencil = NULL;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index fc32557..25c0512 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2775,7 +2775,7 @@ void gen_ffp_frag_op(struct wined3d_stateblock *stateblock, struct ffp_frag_sett
     DWORD ttff;
     DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2;
     struct wined3d_device *device = stateblock->device;
-    struct wined3d_surface *rt = device->render_targets[0];
+    struct wined3d_surface *rt = device->fb.render_targets[0];
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
 
     for (i = 0; i < gl_info->limits.texture_stages; ++i)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 7f9c037..f642eb3 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1640,6 +1640,12 @@ void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
 /* Multithreaded flag. Removed from the public header to signal that IWineD3D::CreateDevice ignores it */
 #define WINED3DCREATE_MULTITHREADED 0x00000004
 
+struct wined3d_fb_state
+{
+    struct wined3d_surface **render_targets;
+    struct wined3d_surface *depth_stencil;
+};
+
 struct wined3d_device
 {
     LONG ref;
@@ -1711,10 +1717,9 @@ struct wined3d_device
     unsigned int            highest_dirty_ps_const, highest_dirty_vs_const;
 
     /* Render Target Support */
-    struct wined3d_surface **render_targets;
-    struct wined3d_surface *auto_depth_stencil;
+    struct wined3d_fb_state fb;
     struct wined3d_surface *onscreen_depth_stencil;
-    struct wined3d_surface *depth_stencil;
+    struct wined3d_surface *auto_depth_stencil;
 
     /* palettes texture management */
     PALETTEENTRY **palettes;
-- 
1.7.3.4




More information about the wine-patches mailing list