diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index c456b5bb48d..8ed049e76f8 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -361,7 +361,11 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT * static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data) { struct wined3d_state *state = &cs->device->state; + struct wined3d_shader_sampler_map_entry *entry; + struct wined3d_shader_resource_view *view; const struct wined3d_cs_draw *op = data; + struct wined3d_shader *shader; + unsigned int i, j; if (!cs->device->adapter->gl_info.supported[ARB_DRAW_ELEMENTS_BASE_VERTEX] && state->load_base_vertex_index != op->base_vertex_idx) @@ -372,12 +376,58 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data) draw_primitive(cs->device, state, op->base_vertex_idx, op->start_idx, op->index_count, op->start_instance, op->instance_count, op->indexed); + + if (op->indexed) + wined3d_resource_release(&state->index_buffer->resource); + for (i = 0; i < ARRAY_SIZE(state->streams); ++i) + { + if (state->streams[i].buffer) + wined3d_resource_release(&state->streams[i].buffer->resource); + } + for (i = 0; i < ARRAY_SIZE(state->textures); ++i) + { + if (state->textures[i]) + wined3d_resource_release(&state->textures[i]->resource); + } + for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i) + { + if (state->fb->render_targets[i]) + wined3d_resource_release(state->fb->render_targets[i]->resource); + } + if (state->fb->depth_stencil) + wined3d_resource_release(state->fb->depth_stencil->resource); + for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) + { + if (!(shader = state->shader[i])) + continue; + + for (j = 0; j < WINED3D_MAX_CBS; ++j) + { + if (state->cb[i][j]) + wined3d_resource_release(&state->cb[i][j]->resource); + } + + for (j = 0; j < shader->reg_maps.sampler_map.count; ++j) + { + entry = &shader->reg_maps.sampler_map.entries[j]; + + if (!(view = state->shader_resource_view[i][entry->resource_idx])) + continue; + + wined3d_resource_release(view->resource); + } + } } void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx, unsigned int index_count, unsigned int start_instance, unsigned int instance_count, BOOL indexed) { + const struct wined3d_state *state = &cs->device->state; + struct wined3d_shader_sampler_map_entry *entry; + struct wined3d_shader_resource_view *view; + struct wined3d_shader *shader; struct wined3d_cs_draw *op; + unsigned int i, j; op = cs->ops->require_space(cs, sizeof(*op)); op->opcode = WINED3D_CS_OP_DRAW; @@ -388,6 +438,47 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned i op->instance_count = instance_count; op->indexed = indexed; + if (indexed) + wined3d_resource_acquire(&state->index_buffer->resource); + for (i = 0; i < ARRAY_SIZE(state->streams); ++i) + { + if (state->streams[i].buffer) + wined3d_resource_acquire(&state->streams[i].buffer->resource); + } + for (i = 0; i < ARRAY_SIZE(state->textures); ++i) + { + if (state->textures[i]) + wined3d_resource_acquire(&state->textures[i]->resource); + } + for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i) + { + if (state->fb->render_targets[i]) + wined3d_resource_acquire(state->fb->render_targets[i]->resource); + } + if (state->fb->depth_stencil) + wined3d_resource_acquire(state->fb->depth_stencil->resource); + for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) + { + if (!(shader = state->shader[i])) + continue; + + for (j = 0; j < WINED3D_MAX_CBS; ++j) + { + if (state->cb[i][j]) + wined3d_resource_acquire(&state->cb[i][j]->resource); + } + + for (j = 0; j < shader->reg_maps.sampler_map.count; ++j) + { + entry = &shader->reg_maps.sampler_map.entries[j]; + + if (!(view = state->shader_resource_view[i][entry->resource_idx])) + continue; + + wined3d_resource_acquire(view->resource); + } + } + cs->ops->submit(cs); }