diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index b9f2929004c..b18291294e3 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -30,6 +30,7 @@ enum wined3d_cs_op WINED3D_CS_OP_DRAW, WINED3D_CS_OP_SET_VIEWPORT, WINED3D_CS_OP_SET_SCISSOR_RECT, + WINED3D_CS_OP_SET_RENDER_TARGET, }; struct wined3d_cs_present @@ -76,6 +77,13 @@ struct wined3d_cs_set_scissor_rect const RECT *rect; }; +struct wined3d_cs_set_render_target +{ + enum wined3d_cs_op opcode; + UINT render_target_idx; + struct wined3d_surface *render_target; +}; + static void wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data) { const struct wined3d_cs_present *op = data; @@ -198,6 +206,27 @@ void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) cs->ops->submit(cs); } +static void wined3d_cs_exec_set_render_target(struct wined3d_cs *cs, const void *data) +{ + const struct wined3d_cs_set_render_target *op = data; + + cs->state.fb->render_targets[op->render_target_idx] = op->render_target; + device_invalidate_state(cs->device, STATE_FRAMEBUFFER); +} + +void wined3d_cs_emit_set_render_target(struct wined3d_cs *cs, UINT render_target_idx, + struct wined3d_surface *render_target) +{ + struct wined3d_cs_set_render_target *op; + + op = cs->ops->require_space(cs, sizeof(*op)); + op->opcode = WINED3D_CS_OP_SET_RENDER_TARGET; + op->render_target_idx = render_target_idx; + op->render_target = render_target; + + cs->ops->submit(cs); +} + static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = { /* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present, @@ -205,6 +234,7 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw, /* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport, /* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect, + /* WINED3D_CS_OP_SET_RENDER_TARGET */ wined3d_cs_exec_set_render_target, }; static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 5f4cafbbd76..46057c3f4f7 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4032,13 +4032,12 @@ HRESULT CDECL wined3d_device_set_render_target(struct wined3d_device *device, if (render_target) wined3d_surface_incref(render_target); device->fb.render_targets[render_target_idx] = render_target; + wined3d_cs_emit_set_render_target(device->cs, render_target_idx, render_target); /* Release after the assignment, to prevent device_resource_released() * from seeing the surface as still in use. */ if (prev) wined3d_surface_decref(prev); - device_invalidate_state(device, STATE_FRAMEBUFFER); - return WINED3D_OK; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f5665ddb1a1..d8c66b73d77 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2486,6 +2486,8 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, UINT start_idx, UINT index_coun void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region, DWORD flags) DECLSPEC_HIDDEN; +void wined3d_cs_emit_set_render_target(struct wined3d_cs *cs, UINT render_target_idx, + struct wined3d_surface *render_target) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN;