From: Henri Verbeet Subject: [PATCH 3/5] wined3d: Use the texture draw binding instead of the surface draw binding. Message-Id: <1408533603-30259-3-git-send-email-hverbeet@codeweavers.com> Date: Wed, 20 Aug 2014 13:20:01 +0200 --- dlls/wined3d/arb_program_shader.c | 4 ++-- dlls/wined3d/context.c | 6 +++--- dlls/wined3d/device.c | 12 +++++++----- dlls/wined3d/drawprim.c | 10 +++++----- dlls/wined3d/surface.c | 24 ++++++++++++------------ dlls/wined3d/swapchain.c | 10 +++++----- dlls/wined3d/texture.c | 10 ++-------- 7 files changed, 36 insertions(+), 40 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 9105f67..e694b72 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7680,8 +7680,8 @@ HRESULT arbfp_blit_surface(struct wined3d_device *device, DWORD filter, context_release(context); - surface_validate_location(dst_surface, dst_surface->resource.draw_binding); - surface_invalidate_location(dst_surface, ~dst_surface->resource.draw_binding); + surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding); + surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding); return WINED3D_OK; } diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 18a0e87..1044f99 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2245,7 +2245,7 @@ void context_apply_blit_state(struct wined3d_context *context, const struct wine { wined3d_texture_load(rt->container, context, FALSE); - context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, rt, NULL, rt->resource.draw_binding); + context_apply_fbo_state_blit(context, GL_FRAMEBUFFER, rt, NULL, rt->container->resource.draw_binding); if (rt->resource.format->id != WINED3DFMT_NULL) rt_mask = 1; else @@ -2330,7 +2330,7 @@ BOOL context_apply_clear_state(struct wined3d_context *context, const struct win ++i; } context_apply_fbo_state(context, GL_FRAMEBUFFER, context->blit_targets, fb->depth_stencil, - rt_count ? rts[0]->resource.draw_binding : WINED3D_LOCATION_TEXTURE_RGB); + rt_count ? rts[0]->container->resource.draw_binding : WINED3D_LOCATION_TEXTURE_RGB); } else { @@ -2436,7 +2436,7 @@ void context_state_fb(struct wined3d_context *context, const struct wined3d_stat else { context_apply_fbo_state(context, GL_FRAMEBUFFER, fb->render_targets, fb->depth_stencil, - fb->render_targets[0]->resource.draw_binding); + fb->render_targets[0]->container->resource.draw_binding); } } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1c3f811..c650066 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -310,7 +310,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c { struct wined3d_surface *rt = fb->render_targets[i]; if (rt) - surface_load_location(rt, rt->resource.draw_binding); + surface_load_location(rt, rt->container->resource.draw_binding); } } @@ -337,7 +337,8 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c if (flags & WINED3DCLEAR_ZBUFFER) { - DWORD location = render_offscreen ? fb->depth_stencil->resource.draw_binding : WINED3D_LOCATION_DRAWABLE; + DWORD location = render_offscreen ? fb->depth_stencil->container->resource.draw_binding + : WINED3D_LOCATION_DRAWABLE; if (!render_offscreen && fb->depth_stencil != device->onscreen_depth_stencil) device_switch_onscreen_ds(device, context, fb->depth_stencil); @@ -369,7 +370,8 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c if (flags & WINED3DCLEAR_ZBUFFER) { - DWORD location = render_offscreen ? fb->depth_stencil->resource.draw_binding : WINED3D_LOCATION_DRAWABLE; + DWORD location = render_offscreen ? fb->depth_stencil->container->resource.draw_binding + : WINED3D_LOCATION_DRAWABLE; surface_modify_ds_location(fb->depth_stencil, location, ds_rect.right, ds_rect.bottom); @@ -388,8 +390,8 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c if (rt) { - surface_validate_location(rt, rt->resource.draw_binding); - surface_invalidate_location(rt, ~rt->resource.draw_binding); + surface_validate_location(rt, rt->container->resource.draw_binding); + surface_invalidate_location(rt, ~rt->container->resource.draw_binding); } } diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index c1ef633..621e3f2 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -616,8 +616,8 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co struct wined3d_surface *target = device->fb.render_targets[i]; if (target) { - surface_load_location(target, target->resource.draw_binding); - surface_invalidate_location(target, ~target->resource.draw_binding); + surface_load_location(target, target->container->resource.draw_binding); + surface_invalidate_location(target, ~target->container->resource.draw_binding); } } } @@ -638,8 +638,8 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co * Z-compare function into account, but we could skip loading the * depthstencil for D3DCMP_NEVER and D3DCMP_ALWAYS as well. Also note * that we never copy the stencil data.*/ - DWORD location = context->render_offscreen ? - device->fb.depth_stencil->resource.draw_binding : WINED3D_LOCATION_DRAWABLE; + DWORD location = context->render_offscreen ? device->fb.depth_stencil->container->resource.draw_binding + : WINED3D_LOCATION_DRAWABLE; if (state->render_states[WINED3D_RS_ZWRITEENABLE] || state->render_states[WINED3D_RS_ZENABLE]) { struct wined3d_surface *ds = device->fb.depth_stencil; @@ -671,7 +671,7 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co if (device->fb.depth_stencil && state->render_states[WINED3D_RS_ZWRITEENABLE]) { struct wined3d_surface *ds = device->fb.depth_stencil; - DWORD location = context->render_offscreen ? ds->resource.draw_binding : WINED3D_LOCATION_DRAWABLE; + DWORD location = context->render_offscreen ? ds->container->resource.draw_binding : WINED3D_LOCATION_DRAWABLE; surface_modify_ds_location(ds, location, ds->ds_current_size.cx, ds->ds_current_size.cy); } diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 695afc0..23c9fd3 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -750,7 +750,7 @@ static void surface_unmap(struct wined3d_surface *surface) } if (surface->container->swapchain && surface->container->swapchain->front_buffer == surface) - surface_load_location(surface, surface->resource.draw_binding); + surface_load_location(surface, surface->container->resource.draw_binding); else if (surface->resource.format->flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) FIXME("Depth / stencil buffer locking is not implemented.\n"); } @@ -4133,8 +4133,8 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE src_surface->container->color_key_flags = old_color_key_flags; src_surface->container->src_blt_color_key = old_blt_key; - surface_validate_location(dst_surface, dst_surface->resource.draw_binding); - surface_invalidate_location(dst_surface, ~dst_surface->resource.draw_binding); + surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding); + surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding); return WINED3D_OK; } @@ -4720,7 +4720,8 @@ HRESULT surface_load_location(struct wined3d_surface *surface, DWORD location) context_release(context); return WINED3D_OK; } - else if (location & surface->locations && surface->resource.draw_binding != WINED3D_LOCATION_DRAWABLE) + else if (location & surface->locations + && surface->container->resource.draw_binding != WINED3D_LOCATION_DRAWABLE) { /* Already up to date, nothing to do. */ return WINED3D_OK; @@ -5763,8 +5764,8 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC return WINED3DERR_INVALIDCALL; } - if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_surface->resource.draw_binding, &src_rect, - dst_surface, dst_surface->resource.draw_binding, &dst_rect))) + if (SUCCEEDED(wined3d_surface_depth_blt(src_surface, src_surface->container->resource.draw_binding, + &src_rect, dst_surface, dst_surface->container->resource.draw_binding, &dst_rect))) return WINED3D_OK; } } @@ -5814,7 +5815,7 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC if (SUCCEEDED(surface_upload_from_surface(dst_surface, &dst_point, src_surface, &src_rect))) { if (!wined3d_resource_is_offscreen(&dst_surface->resource)) - surface_load_location(dst_surface, dst_surface->resource.draw_binding); + surface_load_location(dst_surface, dst_surface->container->resource.draw_binding); return WINED3D_OK; } } @@ -5850,10 +5851,10 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC TRACE("Using FBO blit.\n"); surface_blt_fbo(device, filter, - src_surface, src_surface->resource.draw_binding, &src_rect, - dst_surface, dst_surface->resource.draw_binding, &dst_rect); - surface_validate_location(dst_surface, dst_surface->resource.draw_binding); - surface_invalidate_location(dst_surface, ~dst_surface->resource.draw_binding); + src_surface, src_surface->container->resource.draw_binding, &src_rect, + dst_surface, dst_surface->container->resource.draw_binding, &dst_rect); + surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding); + surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding); return WINED3D_OK; } @@ -5949,7 +5950,6 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text } surface->container = container; - wined3d_resource_update_draw_binding(&surface->resource); surface_validate_location(surface, WINED3D_LOCATION_SYSMEM); list_init(&surface->renderbuffers); list_init(&surface->overlays); diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 609b862..2d1a93b 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -513,7 +513,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT } else { - surface_load_location(back_buffer, back_buffer->resource.draw_binding); + surface_load_location(back_buffer, back_buffer->container->resource.draw_binding); } if (swapchain->render_to_fbo) @@ -585,8 +585,8 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT */ if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP) { - surface_validate_location(back_buffer, back_buffer->resource.draw_binding); - surface_invalidate_location(back_buffer, ~back_buffer->resource.draw_binding); + surface_validate_location(back_buffer, back_buffer->container->resource.draw_binding); + surface_invalidate_location(back_buffer, ~back_buffer->container->resource.draw_binding); } } @@ -1144,10 +1144,10 @@ void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) { UINT i; - wined3d_resource_update_draw_binding(&swapchain->front_buffer->resource); + wined3d_resource_update_draw_binding(&swapchain->front_buffer->container->resource); for (i = 0; i < swapchain->desc.backbuffer_count; ++i) { - wined3d_resource_update_draw_binding(&swapchain->back_buffers[i]->resource); + wined3d_resource_update_draw_binding(&swapchain->back_buffers[i]->container->resource); } } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index b90a80f..07667f3 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -64,6 +64,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc WARN("Failed to initialize resource, returning %#x\n", hr); return hr; } + wined3d_resource_update_draw_binding(&texture->resource); texture->texture_ops = texture_ops; texture->sub_resources = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -147,15 +148,8 @@ static void wined3d_texture_cleanup(struct wined3d_texture *texture) void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain) { - unsigned int i, count; - texture->swapchain = swapchain; - - count = texture->level_count * texture->layer_count; - for (i = 0; i < count; ++i) - { - wined3d_resource_update_draw_binding(wined3d_texture_get_sub_resource(texture, i)); - } + wined3d_resource_update_draw_binding(&texture->resource); } void wined3d_texture_set_dirty(struct wined3d_texture *texture) -- 1.7.10.4