From: Akihiro Sagawa Subject: [PATCH 1/4] wined3d: Add dirty region members for d3d9 textures. Message-Id: <20191207191507.EB33.375B48EC@gmail.com> Date: Sat, 07 Dec 2019 19:16:05 +0900 Signed-off-by: Akihiro Sagawa --- dlls/d3d9/texture.c | 9 ++++++++- dlls/wined3d/texture.c | 13 +++++++++++++ dlls/wined3d/wined3d_private.h | 7 +++++++ include/wine/wined3d.h | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index ae754b5..2ef27a6 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1369,6 +1369,8 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, } if (!levels) levels = wined3d_log2i(max(width, height)) + 1; + if (pool == D3DPOOL_SYSTEMMEM) + flags |= WINED3D_TEXTURE_CREATE_RECORD_DIRTY_REGIONS; wined3d_mutex_lock(); hr = wined3d_texture_create(device->wined3d_device, &desc, 1, levels, flags, @@ -1449,6 +1451,8 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic } if (!levels) levels = wined3d_log2i(edge_length) + 1; + if (pool == D3DPOOL_SYSTEMMEM) + flags |= WINED3D_TEXTURE_CREATE_RECORD_DIRTY_REGIONS; wined3d_mutex_lock(); hr = wined3d_texture_create(device->wined3d_device, &desc, 6, levels, flags, @@ -1470,6 +1474,7 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) { struct wined3d_resource_desc desc; + DWORD flags = 0; HRESULT hr; if (pool == D3DPOOL_MANAGED && device->d3d_parent->extended) @@ -1513,9 +1518,11 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev } if (!levels) levels = wined3d_log2i(max(max(width, height), depth)) + 1; + if (pool == D3DPOOL_SYSTEMMEM) + flags |= WINED3D_TEXTURE_CREATE_RECORD_DIRTY_REGIONS; wined3d_mutex_lock(); - hr = wined3d_texture_create(device->wined3d_device, &desc, 1, levels, 0, + hr = wined3d_texture_create(device->wined3d_device, &desc, 1, levels, flags, NULL, texture, &d3d9_texture_wined3d_parent_ops, &texture->wined3d_texture); wined3d_mutex_unlock(); if (FAILED(hr)) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 7c9c829..e13d46c 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1098,6 +1098,9 @@ static void wined3d_texture_destroy_object(void *object) heap_free(dc_info); } + if (texture->dirty_regions) + heap_free(texture->dirty_regions); + if (texture->overlay_info) { for (i = 0; i < sub_count; ++i) @@ -3382,6 +3385,16 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc texture->flags |= WINED3D_TEXTURE_GENERATE_MIPMAPS; } + if (flags & WINED3D_TEXTURE_CREATE_RECORD_DIRTY_REGIONS) + { + texture->dirty_regions = heap_calloc(texture->layer_count, sizeof(*texture->dirty_regions)); + if (!texture->dirty_regions) + { + wined3d_texture_cleanup_sync(texture); + return E_OUTOFMEMORY; + } + } + /* Precalculated scaling for 'faked' non power of two texture coords. */ if (texture->resource.gl_type == WINED3D_GL_RES_TYPE_TEX_RECT) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 8f9ad1c..4f5a001 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3538,6 +3538,13 @@ struct wined3d_texture DWORD color_key_flags; } async; + struct wined3d_dirty_region + { + struct wined3d_box *box; + SIZE_T size; + UINT count; + } *dirty_regions; + struct wined3d_overlay_info { struct list entry; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 4b5d4e0..db88e11 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -1565,6 +1565,7 @@ enum wined3d_shader_type #define WINED3D_TEXTURE_CREATE_GET_DC_LENIENT 0x00000004 #define WINED3D_TEXTURE_CREATE_GET_DC 0x00000008 #define WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS 0x00000010 +#define WINED3D_TEXTURE_CREATE_RECORD_DIRTY_REGIONS 0x00000020 #define WINED3D_STANDARD_MULTISAMPLE_PATTERN 0xffffffff