Commit d374d850 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Clear all render targets in an MRT setup.

parent 74015090
......@@ -473,7 +473,9 @@ void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target
{
if (surface_is_offscreen(render_target))
{
UINT clear_size = (context->gl_info->limits.buffers - 1) * sizeof(*context->blit_targets);
context->blit_targets[0] = render_target;
if (clear_size) memset(&context->blit_targets[1], 0, clear_size);
context_apply_fbo_state(context, target, context->blit_targets, depth_stencil);
}
else
......@@ -2059,30 +2061,64 @@ void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImp
/* Context activation is done by the caller. */
void context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceImpl *device,
IWineD3DSurfaceImpl *render_target, IWineD3DSurfaceImpl *depth_stencil)
UINT rt_count, IWineD3DSurfaceImpl **rts, IWineD3DSurfaceImpl *depth_stencil)
{
const struct StateEntry *state_table = device->StateTable;
GLenum buffer;
UINT i;
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
context_validate_onscreen_formats(device, context, depth_stencil);
ENTER_GL();
context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, render_target, depth_stencil);
if (surface_is_offscreen(rts[0]))
{
for (i = 0; i < rt_count; ++i)
{
context->blit_targets[i] = rts[i];
}
while (i < context->gl_info->limits.buffers)
{
context->blit_targets[i] = NULL;
++i;
}
context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, depth_stencil);
}
else
{
context_apply_fbo_state(context, GL_FRAMEBUFFER, NULL, NULL);
}
LEAVE_GL();
}
if (!surface_is_offscreen(render_target))
buffer = surface_get_gl_buffer(render_target);
else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
buffer = GL_COLOR_ATTACHMENT0;
if (!surface_is_offscreen(rts[0]))
{
ENTER_GL();
context_set_draw_buffer(context, surface_get_gl_buffer(rts[0]));
LEAVE_GL();
}
else
buffer = device->offscreenBuffer;
{
const struct wined3d_gl_info *gl_info = context->gl_info;
GLenum buffers[gl_info->limits.buffers];
ENTER_GL();
context_set_draw_buffer(context, buffer);
LEAVE_GL();
for (i = 0; i < gl_info->limits.buffers; ++i)
{
if (i < rt_count && rts[i])
buffers[i] = GL_COLOR_ATTACHMENT0 + i;
else
buffers[i] = GL_NONE;
}
ENTER_GL();
GL_EXTCALL(glDrawBuffersARB(gl_info->limits.buffers, buffers));
checkGLcall("glDrawBuffers()");
LEAVE_GL();
context->draw_buffer_dirty = TRUE;
}
if (context->last_was_blit)
{
......
......@@ -4726,10 +4726,11 @@ static BOOL ffp_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_
return FALSE;
}
static HRESULT ffp_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color)
static HRESULT ffp_blit_color_fill(IWineD3DDeviceImpl *device,
IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color)
{
return IWineD3DDeviceImpl_ClearSurface(device, dst_surface, 1 /* Number of rectangles */,
(const WINED3DRECT*)dst_rect, WINED3DCLEAR_TARGET, fill_color, 0.0f /* Z */, 0 /* Stencil */);
return device_clear_render_targets(device, 1 /* rt_count */, &dst_surface, 1 /* rect_count */,
(const WINED3DRECT *)dst_rect, WINED3DCLEAR_TARGET, fill_color, 0.0f /* depth */, 0 /* stencil */);
}
const struct blit_shader ffp_blit = {
......
......@@ -1161,7 +1161,7 @@ void context_alloc_occlusion_query(struct wined3d_context *context,
struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
void context_apply_blit_state(struct wined3d_context *context, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
void context_apply_clear_state(struct wined3d_context *context, IWineD3DDeviceImpl *device,
IWineD3DSurfaceImpl *render_target, IWineD3DSurfaceImpl *depth_stencil) DECLSPEC_HIDDEN;
UINT rt_count, IWineD3DSurfaceImpl **rts, IWineD3DSurfaceImpl *depth_stencil) DECLSPEC_HIDDEN;
void context_apply_draw_state(struct wined3d_context *context, IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
IWineD3DSurfaceImpl *render_target, IWineD3DSurfaceImpl *depth_stencil) DECLSPEC_HIDDEN;
......@@ -1686,6 +1686,9 @@ struct IWineD3DDeviceImpl
struct WineD3DRectPatch *currentPatch;
};
HRESULT device_clear_render_targets(IWineD3DDeviceImpl *device,
UINT rt_count, IWineD3DSurfaceImpl **rts, UINT rect_count, const WINED3DRECT *rects,
DWORD flags, WINED3DCOLOR color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
BOOL device_context_add(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
void device_context_remove(IWineD3DDeviceImpl *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
void device_get_draw_rect(IWineD3DDeviceImpl *device, RECT *rect) DECLSPEC_HIDDEN;
......@@ -1702,8 +1705,6 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
void device_switch_onscreen_ds(IWineD3DDeviceImpl *device, struct wined3d_context *context,
IWineD3DSurfaceImpl *depth_stencil) DECLSPEC_HIDDEN;
void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN;
void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN;
void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment