[PATCH 4/6] wined3d: Move the draw buffer array to the context.

Henri Verbeet hverbeet at codeweavers.com
Fri Jul 30 03:15:26 CDT 2010


---
 dlls/wined3d/context.c         |   21 +++++++++++++--------
 dlls/wined3d/device.c          |    8 ++------
 dlls/wined3d/wined3d_private.h |    2 +-
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 2ddb02b..7e3e813 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1408,6 +1408,10 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3
             gl_info->limits.buffers * sizeof(*ret->blit_targets));
     if (!ret->blit_targets) goto out;
 
+    ret->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+            gl_info->limits.buffers * sizeof(*ret->draw_buffers));
+    if (!ret->draw_buffers) goto out;
+
     ret->free_occlusion_query_size = 4;
     ret->free_occlusion_queries = HeapAlloc(GetProcessHeap(), 0,
             ret->free_occlusion_query_size * sizeof(*ret->free_occlusion_queries));
@@ -1558,6 +1562,7 @@ struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3
 out:
     HeapFree(GetProcessHeap(), 0, ret->free_event_queries);
     HeapFree(GetProcessHeap(), 0, ret->free_occlusion_queries);
+    HeapFree(GetProcessHeap(), 0, ret->draw_buffers);
     HeapFree(GetProcessHeap(), 0, ret->blit_targets);
     HeapFree(GetProcessHeap(), 0, ret->pshader_const_dirty);
     HeapFree(GetProcessHeap(), 0, ret->vshader_const_dirty);
@@ -1593,6 +1598,7 @@ void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context)
         destroy = FALSE;
     }
 
+    HeapFree(GetProcessHeap(), 0, context->draw_buffers);
     HeapFree(GetProcessHeap(), 0, context->blit_targets);
     HeapFree(GetProcessHeap(), 0, context->vshader_const_dirty);
     HeapFree(GetProcessHeap(), 0, context->pshader_const_dirty);
@@ -1953,19 +1959,19 @@ static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit
                 for (i = 0; i < gl_info->limits.buffers; ++i)
                 {
                     if (device->render_targets[i])
-                        device->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
+                        context->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
                     else
-                        device->draw_buffers[i] = GL_NONE;
+                        context->draw_buffers[i] = GL_NONE;
                 }
 
                 if (gl_info->supported[ARB_DRAW_BUFFERS])
                 {
-                    GL_EXTCALL(glDrawBuffersARB(gl_info->limits.buffers, device->draw_buffers));
+                    GL_EXTCALL(glDrawBuffersARB(gl_info->limits.buffers, context->draw_buffers));
                     checkGLcall("glDrawBuffers()");
                 }
                 else
                 {
-                    glDrawBuffer(device->draw_buffers[0]);
+                    glDrawBuffer(context->draw_buffers[0]);
                     checkGLcall("glDrawBuffer()");
                 }
             } else {
@@ -2139,18 +2145,17 @@ void context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceIm
     else
     {
         const struct wined3d_gl_info *gl_info = context->gl_info;
-        GLenum buffers[gl_info->limits.buffers];
 
         for (i = 0; i < gl_info->limits.buffers; ++i)
         {
             if (i < rt_count && rts[i])
-                buffers[i] = GL_COLOR_ATTACHMENT0 + i;
+                context->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
             else
-                buffers[i] = GL_NONE;
+                context->draw_buffers[i] = GL_NONE;
         }
 
         ENTER_GL();
-        GL_EXTCALL(glDrawBuffersARB(gl_info->limits.buffers, buffers));
+        GL_EXTCALL(glDrawBuffersARB(gl_info->limits.buffers, context->draw_buffers));
         checkGLcall("glDrawBuffers()");
         LEAVE_GL();
 
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d74b1f4..7f6eb8e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1802,12 +1802,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
 
     This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
             sizeof(*This->render_targets) * gl_info->limits.buffers);
-    This->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
-            sizeof(GLenum) * gl_info->limits.buffers);
 
     This->NumberOfPalettes = 1;
     This->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*));
-    if(!This->palettes || !This->render_targets || !This->draw_buffers) {
+    if (!This->palettes || !This->render_targets)
+    {
         ERR("Out of memory!\n");
         hr = E_OUTOFMEMORY;
         goto err_out;
@@ -1946,7 +1945,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
 
 err_out:
     HeapFree(GetProcessHeap(), 0, This->render_targets);
-    HeapFree(GetProcessHeap(), 0, This->draw_buffers);
     HeapFree(GetProcessHeap(), 0, This->swapchains);
     This->NumberOfSwapChains = 0;
     if(This->palettes) {
@@ -2150,9 +2148,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
     This->NumberOfPalettes = 0;
 
     HeapFree(GetProcessHeap(), 0, This->render_targets);
-    HeapFree(GetProcessHeap(), 0, This->draw_buffers);
     This->render_targets = NULL;
-    This->draw_buffers = NULL;
 
     This->d3d_initialized = FALSE;
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8b7a0b1..4205dd5 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1060,6 +1060,7 @@ struct wined3d_context
     GLuint                  fbo_draw_binding;
     BOOL rebind_fbo;
     IWineD3DSurfaceImpl **blit_targets;
+    GLenum *draw_buffers;
 
     /* Queries */
     GLuint *free_occlusion_queries;
@@ -1637,7 +1638,6 @@ struct IWineD3DDeviceImpl
     UINT                    currentPalette;
 
     /* For rendering to a texture using glCopyTexImage */
-    GLenum                  *draw_buffers;
     GLuint                  depth_blt_texture;
     GLuint                  depth_blt_rb;
     UINT                    depth_blt_rb_w;
-- 
1.7.1




More information about the wine-patches mailing list