From 84103460bdab8a3f57f29817d7be2ceaf93ee2c3 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 8 Apr 2011 20:22:52 +0200 Subject: [PATCH] wined3d: Check FBO completeness after the read / draw buffers are specified. Unless the driver implements ARB_ES2_compatibility / GL4.1, FBO completeness depends on what read / draw buffers are set. --- dlls/wined3d/context.c | 25 ++++++++++++++++++++++--- dlls/wined3d/surface.c | 4 ++++ dlls/wined3d/swapchain.c | 1 + dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index c2bdd3c2bc5..be2ad3c1d31 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -299,7 +299,7 @@ static void context_attach_surface_fbo(const struct wined3d_context *context, } /* GL locking is done by the caller */ -static void context_check_fbo_status(struct wined3d_context *context, GLenum target) +void context_check_fbo_status(struct wined3d_context *context, GLenum target) { const struct wined3d_gl_info *gl_info = context->gl_info; GLenum status; @@ -499,8 +499,6 @@ static void context_apply_fbo_state(struct wined3d_context *context, GLenum targ context->current_fbo = NULL; context_bind_fbo(context, target, NULL); } - - context_check_fbo_status(context, target); } /* GL locking is done by the caller */ @@ -2056,6 +2054,13 @@ void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImp context->draw_buffer_dirty = FALSE; } + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + ENTER_GL(); + context_check_fbo_status(context, GL_FRAMEBUFFER); + LEAVE_GL(); + } + SetupForBlit(device, context); } @@ -2119,6 +2124,13 @@ BOOL context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceIm context_apply_draw_buffers(context, rt_count, rts); context->draw_buffer_dirty = TRUE; + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + ENTER_GL(); + context_check_fbo_status(context, GL_FRAMEBUFFER); + LEAVE_GL(); + } + if (context->last_was_blit) { device->frag_pipe->enable_extension(TRUE); @@ -2186,6 +2198,13 @@ BOOL context_apply_draw_state(struct wined3d_context *context, IWineD3DDeviceImp context->draw_buffer_dirty = FALSE; } + if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) + { + ENTER_GL(); + context_check_fbo_status(context, GL_FRAMEBUFFER); + LEAVE_GL(); + } + if (context->last_was_blit) { device->frag_pipe->enable_extension(TRUE); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 801eb5760d5..c2d92ed7c13 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -3416,6 +3416,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT glReadBuffer(GL_COLOR_ATTACHMENT0); checkGLcall("glReadBuffer()"); } + context_check_fbo_status(context, GL_READ_FRAMEBUFFER); LEAVE_GL(); if (dst_location == SFLAG_INDRAWABLE) @@ -3438,6 +3439,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, dst_surface, NULL, dst_location); context_set_draw_buffer(context, GL_COLOR_ATTACHMENT0); } + context_check_fbo_status(context, GL_DRAW_FRAMEBUFFER); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_COLORWRITEENABLE)); @@ -3516,9 +3518,11 @@ static void wined3d_surface_depth_blt_fbo(IWineD3DDeviceImpl *device, IWineD3DSu context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER, NULL, src_surface, SFLAG_INTEXTURE); glReadBuffer(GL_NONE); checkGLcall("glReadBuffer()"); + context_check_fbo_status(context, GL_READ_FRAMEBUFFER); context_apply_fbo_state_blit(context, GL_DRAW_FRAMEBUFFER, NULL, dst_surface, SFLAG_INTEXTURE); context_set_draw_buffer(context, GL_NONE); + context_check_fbo_status(context, GL_DRAW_FRAMEBUFFER); if (gl_mask & GL_DEPTH_BUFFER_BIT) { diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 5be670505fd..6db92d6fd02 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -302,6 +302,7 @@ static void swapchain_blit(IWineD3DSwapChainImpl *This, struct wined3d_context * ENTER_GL(); context_apply_fbo_state_blit(context, GL_READ_FRAMEBUFFER, backbuffer, NULL, SFLAG_INTEXTURE); glReadBuffer(GL_COLOR_ATTACHMENT0); + context_check_fbo_status(context, GL_READ_FRAMEBUFFER); context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, NULL); context_set_draw_buffer(context, GL_BACK); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index d78d504c77d..4ef1cb672e9 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1218,6 +1218,7 @@ void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target void context_attach_depth_stencil_fbo(struct wined3d_context *context, GLenum fbo_target, IWineD3DSurfaceImpl *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN; void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint *fbo) DECLSPEC_HIDDEN; +void context_check_fbo_status(struct wined3d_context *context, GLenum target) DECLSPEC_HIDDEN; struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target, const struct wined3d_format *ds_format) DECLSPEC_HIDDEN; void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;