static void texture2d_sub_resource_add_dirty_region(struct wined3d_resource *sub_resource, const struct wined3d_box *dirty_region) { struct wined3d_surface *surface = surface_from_resource(sub_resource); struct wined3d_context *context; context = context_acquire(surface->resource.device, NULL); wined3d_resource_prepare_map_memory(&surface->resource, context); wined3d_resource_load_location(&surface->resource, context, surface->resource.map_binding); context_release(context); wined3d_resource_invalidate_location(&surface->resource, ~surface->resource.map_binding); }
void *wined3d_resource_map_internal(struct wined3d_resource *resource, DWORD flags) { struct wined3d_device *device = resource->device; struct wined3d_context *context = NULL; void *mem; if (device->d3d_initialized) context = context_acquire(device, NULL); if (!wined3d_resource_prepare_map_memory(resource, context)) { WARN("Out of memory.\n"); context_release(context); return NULL; } if (flags & WINED3D_MAP_DISCARD) { switch (resource->map_binding) { case WINED3D_LOCATION_BUFFER: resource->map_buffer = wined3d_device_get_bo(device, resource->size, GL_STREAM_DRAW_ARB, GL_PIXEL_UNPACK_BUFFER_ARB, context); break; case WINED3D_LOCATION_SYSMEM: wined3d_resource_allocate_sysmem(resource); break; default: if (resource->access_fence) ERR("Location %s does not support DISCARD maps.\n", wined3d_debug_location(resource->map_binding)); if (resource->pool != WINED3D_POOL_DEFAULT) FIXME("Discard used on %s pool resource.\n", debug_d3dpool(resource->pool)); } wined3d_resource_validate_location(resource, resource->map_binding); } else { wined3d_resource_load_location(resource, context, resource->map_binding); } mem = wined3d_resource_get_map_ptr(resource, context, flags); if (context) context_release(context); return mem; }