Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/context.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 37abf19d73e..bdd291b74f5 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2846,6 +2846,8 @@ void context_apply_blit_state(struct wined3d_context *context, const struct wine } context_invalidate_state(context, STATE_SAMPLER(sampler)); } + context_invalidate_compute_state(context, STATE_COMPUTE_SHADER_RESOURCE_BINDING); + context_invalidate_state(context, STATE_GRAPHICS_SHADER_RESOURCE_BINDING);
if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d8/buffer.c | 4 ++++ dlls/d3d8/device.c | 2 ++ dlls/d3d8/texture.c | 6 ++++++ dlls/d3d9/buffer.c | 4 ++++ dlls/d3d9/device.c | 2 ++ dlls/d3d9/texture.c | 6 ++++++ dlls/ddraw/surface.c | 1 + dlls/wined3d/buffer.c | 2 +- dlls/wined3d/device.c | 10 ++++++---- dlls/wined3d/resource.c | 3 ++- dlls/wined3d/texture.c | 10 ++++++---- dlls/wined3d/utils.c | 2 ++ dlls/wined3d/wined3d_private.h | 5 ----- include/wine/wined3d.h | 3 ++- 14 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index fb6b7bc1e92..93917d4fdcf 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -288,6 +288,8 @@ HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device *
desc.byte_width = size; desc.usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -577,6 +579,8 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 12d02538351..cf158daab17 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1165,6 +1165,8 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width desc.usage = usage & WINED3DUSAGE_MASK; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index f7ccdc7e34b..f7e8fd36b9f 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -1110,6 +1110,8 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; @@ -1158,6 +1160,8 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = edge_length; @@ -1205,6 +1209,8 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; desc.height = height; diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 36a6ae3f902..b12167eb8be 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -289,6 +289,8 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *
desc.byte_width = size; desc.usage = usage & WINED3DUSAGE_MASK; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; @@ -576,6 +578,8 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index a3f410a7b97..39281330aa1 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1392,6 +1392,8 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width desc.usage = usage & WINED3DUSAGE_MASK; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 0858be99220..52cefbf9e28 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1314,6 +1314,8 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = width; @@ -1399,6 +1401,8 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = edge_length; @@ -1470,6 +1474,8 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev desc.usage |= WINED3DUSAGE_TEXTURE; if (pool == D3DPOOL_SCRATCH) desc.usage |= WINED3DUSAGE_SCRATCH; + if (pool == D3DPOOL_MANAGED) + desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage); desc.width = width; desc.height = height; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index d201d9d4146..c1d5646c09d 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6176,6 +6176,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; /* Managed textures have the system memory flag set. */ desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; + wined3d_desc.usage |= WINED3DUSAGE_MANAGED; } else if (desc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) { diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 5b3419d29e0..940fc4c2c0d 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1386,7 +1386,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d debug_d3dformat(buffer->resource.format->id), buffer->resource.heap_memory);
if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING - || wined3d_resource_access_is_managed(desc->access)) + || desc->usage & WINED3DUSAGE_MANAGED) { /* SWvp and managed buffers always return the same pointer in buffer * maps and retain data in DISCARD maps. Keep a system memory copy of diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index b50d6677ab2..f98c02d99c0 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3805,10 +3805,12 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device, return WINED3DERR_INVALIDCALL; }
- if (src_texture->resource.access & WINED3D_RESOURCE_ACCESS_GPU - || src_texture->resource.usage & WINED3DUSAGE_SCRATCH) + if ((src_texture->resource.access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)) + == WINED3D_RESOURCE_ACCESS_GPU + || src_texture->resource.usage & WINED3DUSAGE_SCRATCH + || src_texture->resource.usage & WINED3DUSAGE_MANAGED) { - WARN("Source resource is GPU accessible or a scratch resource.\n"); + WARN("Source resource doesn't allow both CPU and GPU access or is a managed resource.\n"); return WINED3DERR_INVALIDCALL; } if (dst_texture->resource.access & WINED3D_RESOURCE_ACCESS_CPU) @@ -4742,7 +4744,7 @@ void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device) { TRACE("Checking resource %p for eviction.\n", resource);
- if (wined3d_resource_access_is_managed(resource->access) && !resource->map_count) + if (resource->usage & WINED3DUSAGE_MANAGED && !resource->map_count) { TRACE("Evicting %p.\n", resource); wined3d_cs_emit_unload_resource(device->cs, resource); diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 9df0a0923b2..8669100f138 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -37,6 +37,7 @@ static void resource_check_usage(DWORD usage) | WINED3DUSAGE_STATICDECL | WINED3DUSAGE_OVERLAY | WINED3DUSAGE_SCRATCH + | WINED3DUSAGE_MANAGED | WINED3DUSAGE_PRIVATE | WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE @@ -253,7 +254,7 @@ DWORD CDECL wined3d_resource_set_priority(struct wined3d_resource *resource, DWO { DWORD prev;
- if (!wined3d_resource_access_is_managed(resource->access)) + if (~resource->usage & WINED3DUSAGE_MANAGED) { WARN("Called on non-managed resource %p, ignoring.\n", resource); return 0; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index a3d834e8f53..283f35cd525 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1389,16 +1389,18 @@ void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture,
DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod) { + unsigned int access = texture->resource.access; + unsigned int usage = texture->resource.usage; DWORD old = texture->lod;
TRACE("texture %p, lod %u.\n", texture, lod);
/* The d3d9:texture test shows that SetLOD is ignored on non-managed * textures. The call always returns 0, and GetLOD always returns 0. */ - if (!wined3d_resource_access_is_managed(texture->resource.access)) + if (~usage & WINED3DUSAGE_MANAGED) { - TRACE("Ignoring LOD on texture with resource access %s.\n", - wined3d_debug_resource_access(texture->resource.access)); + TRACE("Ignoring LOD on texture with resource access %s, usage %s.\n", + wined3d_debug_resource_access(access), debug_d3dusage(usage)); return 0; }
@@ -2896,7 +2898,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc } format = wined3d_get_format(device->adapter, desc->format, desc->usage);
- if (desc->usage & WINED3DUSAGE_DYNAMIC && (wined3d_resource_access_is_managed(desc->access) + if (desc->usage & WINED3DUSAGE_DYNAMIC && (desc->usage & WINED3DUSAGE_MANAGED || desc->usage & WINED3DUSAGE_SCRATCH)) { WARN("Attempted to create a dynamic texture with access %s and usage %s.\n", diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 6e60c5ae3db..373a3087344 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4525,6 +4525,8 @@ const char *debug_d3dusage(DWORD usage) WINED3DUSAGE_TO_STR(WINED3DUSAGE_RESTRICT_SHARED_RESOURCE); WINED3DUSAGE_TO_STR(WINED3DUSAGE_DMAP); WINED3DUSAGE_TO_STR(WINED3DUSAGE_TEXTAPI); + WINED3DUSAGE_TO_STR(WINED3DUSAGE_MANAGED); + WINED3DUSAGE_TO_STR(WINED3DUSAGE_PRIVATE); WINED3DUSAGE_TO_STR(WINED3DUSAGE_LEGACY_CUBEMAP); WINED3DUSAGE_TO_STR(WINED3DUSAGE_TEXTURE); WINED3DUSAGE_TO_STR(WINED3DUSAGE_OWNDC); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 33d248fcfdd..b780020b071 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3072,11 +3072,6 @@ const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN; const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d, const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
-static inline BOOL wined3d_resource_access_is_managed(unsigned int access) -{ - return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)); -} - struct wined3d_resource_ops { ULONG (*resource_incref)(struct wined3d_resource *resource); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 1b3a46e6567..d8322ef017e 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -928,9 +928,10 @@ enum wined3d_shader_type #define WINED3DUSAGE_RESTRICT_SHARED_RESOURCE 0x00002000 #define WINED3DUSAGE_DMAP 0x00004000 #define WINED3DUSAGE_TEXTAPI 0x10000000 -#define WINED3DUSAGE_MASK 0x10007bff +#define WINED3DUSAGE_MASK 0x10007bfb
#define WINED3DUSAGE_SCRATCH 0x00200000 +#define WINED3DUSAGE_MANAGED 0x00000004 #define WINED3DUSAGE_PRIVATE 0x00400000 #define WINED3DUSAGE_LEGACY_CUBEMAP 0x00800000 #define WINED3DUSAGE_TEXTURE 0x01000000
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43430
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
On Tue, 23 Oct 2018 at 20:39, Matteo Bruni mbruni@codeweavers.com wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
dlls/d3d8/buffer.c | 4 ++++ dlls/d3d8/device.c | 2 ++ dlls/d3d8/texture.c | 6 ++++++ dlls/d3d9/buffer.c | 4 ++++ dlls/d3d9/device.c | 2 ++ dlls/d3d9/texture.c | 6 ++++++ dlls/ddraw/surface.c | 1 + dlls/wined3d/buffer.c | 2 +- dlls/wined3d/device.c | 10 ++++++---- dlls/wined3d/resource.c | 3 ++- dlls/wined3d/texture.c | 10 ++++++---- dlls/wined3d/utils.c | 2 ++ dlls/wined3d/wined3d_private.h | 5 ----- include/wine/wined3d.h | 3 ++- 14 files changed, 44 insertions(+), 16 deletions(-)
Well, maybe. A few questions though:
- You had tests, right? Does this really make sense for textures as well? - What is the conceptual model? I.e., after this series, what is the difference between a D3DPOOL_SYSTEMMEM and a D3DPOOL_MANAGED resource? - Does it really make sense that D3DPOOL_MANAGED resources are evicted on wined3d_device_evict_managed_resources(), but D3DPOOL_SYSTEMMEM resources are potentially kept on the GPU?
On Wed, Oct 24, 2018 at 9:53 AM Henri Verbeet hverbeet@gmail.com wrote:
Well, maybe. A few questions though:
Great questions, in fact. Replies inline.
- You had tests, right? Does this really make sense for textures as well?
I'm attaching one of the tests for reference but indeed I completely forgot to test textures :/ It turns out that D3DPOOL_SYSTEMMEM textures, as expected, aren't supposed to be usable in draws (with d3d8/d3d9, the draw returns E_FAIL, weirdly with ddraw it's EndScene() that fails). I made wined3daccess_from_d3dpool() also take a resource type parameter and only add GPU access in the buffer case. I think I like it better now but let me know if you see it otherwise.
- What is the conceptual model? I.e., after this series, what is the
difference between a D3DPOOL_SYSTEMMEM and a D3DPOOL_MANAGED resource?
There isn't much of a difference for buffers, admittedly. The docs suggest that resource updates might follow a slightly different policy between the two, which I'm not sure is really testable. Textures are going to stay as they were, which means, among other things, that we need to keep WINED3DUSAGE_SCRATCH around.
- Does it really make sense that D3DPOOL_MANAGED resources are
evicted on wined3d_device_evict_managed_resources(), but D3DPOOL_SYSTEMMEM resources are potentially kept on the GPU?
Good point, I updated the patches accordingly. From my understanding of the docs, I think the system memory copy of D3DPOOL_SYSTEMMEM buffers is always valid / current in d3d so native EvictManagedResources() can simply ignore those. Going further on that line of thought, I realized that we should probably PIN_SYSMEM those buffers and a new test confirms that to be the case.
Am 2018-10-26 um 17:23 schrieb Matteo Bruni:
There isn't much of a difference for buffers, admittedly. The docs suggest that resource updates might follow a slightly different policy between the two, which I'm not sure is really testable. Textures are going to stay as they were, which means, among other things, that we need to keep WINED3DUSAGE_SCRATCH around.
D3DUSAGE_SYSTEMMEMORY buffers might do more useful things with D3DLOCK_DISCARD / D3DLOCK_NOOVERWRITE. It might be worth extending test_map_synchronisation to cover different buffer pools.
On Sat, 27 Oct 2018 at 01:11, Stefan Dösinger stefandoesinger@gmail.com wrote:
Am 2018-10-26 um 17:23 schrieb Matteo Bruni:
There isn't much of a difference for buffers, admittedly. The docs suggest that resource updates might follow a slightly different policy between the two, which I'm not sure is really testable. Textures are going to stay as they were, which means, among other things, that we need to keep WINED3DUSAGE_SCRATCH around.
D3DUSAGE_SYSTEMMEMORY buffers might do more useful things with D3DLOCK_DISCARD / D3DLOCK_NOOVERWRITE. It might be worth extending test_map_synchronisation to cover different buffer pools.
My understanding is that it doesn't really work that way, but you do raise an interesting point. My current understanding (with all the usual "but it depends" caveats) of the various pool/usage combinations is the following:
- DEFAULT pool buffers are conceptually in VRAM. They're uploaded on creation, and (in d3d9) never modified afterwards. - DEFAULT pool + DYNAMIC, WRITEONLY usage buffers are conceptually in GTT/GART memory. They're expected to be updated often, and you want to use DISCARD/NOOVERWRITE to do so. - MANAGED pool buffers can bounce around VRAM/GTT/system memory as the runtime/driver see fit. You don't want to use these. - SYSTEMMEMORY pool buffers are in system memory. They're uploaded for each draw, not unlike "user memory" draws. You don't really want to use these either. MSDN claims you'd use these when you're concerned about GTT memory usage.
As for the point you raise about map synchronisation, an implication of the above would be that mapping SYSTEMMEMORY buffers never blocks, beyond perhaps the draw-time upload. One test I'd find interesting would be to compare the performance characteristics of draws of various sizes out of huge MANAGED and SYSTEMMEMORY buffers.
Am 27.10.2018 um 14:48 schrieb Henri Verbeet hverbeet@gmail.com:
As for the point you raise about map synchronisation, an implication of the above would be that mapping SYSTEMMEMORY buffers never blocks, beyond perhaps the draw-time upload.
From what I have seen in real games (e.g. World of Warcraft, Call of Duty Modern Warfare 2) textures are probably more interesting here than buffers. Both games use UpdateTexture with sysmem, D3DUSAGE_DYNAMIC source textures that they later map with DISCARD. When I worked on the command stream I honored that DISCARD flag, but I never wrote tests to show that it is correct to do so.
Sorry for the long reply, TLDR: behavior with D3DPOOL_SYSTEMMEM and D3DPOOL_MANAGED buffers is not uniform among vendors, except for DISCARD which is always ignored. Mapping D3DPOOL_SYSTEMMEM textures never blocks.
Read further below for the gritty details...
On Sat, Oct 27, 2018 at 3:44 PM Stefan Dösinger stefandoesinger@gmail.com wrote:
Am 27.10.2018 um 14:48 schrieb Henri Verbeet hverbeet@gmail.com:
As for the point you raise about map synchronisation, an implication of the above would be that mapping SYSTEMMEMORY buffers never blocks, beyond perhaps the draw-time upload.
That checks out, but interestingly only on Nvidia. I hacked a pair of QueryPerformanceCounter() calls around the second buffer map in the loop in test_map_synchronization() and augmented the test to also try with D3DPOOL_SYSTEMMEM buffers. On Nvidia, the whole Lock() / Unlock() dance is virtually instant (~2 μs according to QueryPerformanceCounter(), which is clearly at the limits of its resolution but nevertheless seems to give decently consistent and usable results) for D3DPOOL_SYSTEMMEM, regardless of the map flags. D3DPOOL_DEFAULT buffers behave as you would expect, i.e. mapping the buffer without flags right after a "large" draw blocks (it takes ~100 ms for me), NOOVERWRITE map is almost as fast as the D3DPOOL_SYSTEMMEM case (~2.5 μs), DISCARD takes just slightly longer (~20 μs). Ah, updating the D3DPOOL_SYSTEMMEM buffer with NOOVERWRITE (or otherwise) won't update the data in use by the draw, so the map is "synchronized" as far as the test is concerned. I also tested D3DPOOL_MANAGED and their results probably make sense too, although they aren't entirely what I expected. The no flags map case takes 1 ms for me, while the others usually take around 160 μs (although I have seen those sporadically take ~500 μs too). The 0 flags case in particular takes way longer than the SYSTEMMEM case but still 2 orders of magnitude less than the D3DPOOL_DEFAULT case. I guess one possible way to explain it is that, for managed buffers, the driver needs to copy the buffer back to system memory but doesn't need to wait for the draw to complete (at least on the GPU, I guess it might need to complete "dispatching" the draw to the GPU, whatever that means).
AMD, on the other hand, doesn't behave like that. Mapping a D3DPOOL_SYSTEMMEM buffer without the NOOVERWRITE flag does block to some degree. OTOH, mapping a SYSTEMMEM buffer with NOOVERWRITE is unsynchronized i.e. updating data used by the draw will affect the draw results. MANAGED buffers seem to have the same performance characteristics as SYSTEMMEM WRT maps, including NOOVERWRITE having a visible effect.
One test I'd find interesting would be to compare the performance characteristics of draws of various sizes out of huge MANAGED and SYSTEMMEMORY buffers.
Just one more hack to test_map_synchronization() and there you are :) I added one more QPC() call before the draw and restructured the test to create increasingly large buffers, both drawing just from a portion of the buffer and drawing from the whole buffer. On Nvidia, map time for D3DPOOL_MANAGED buffers is proportional with the size of the buffer and not affected by the triangle count. Draw time for D3DPOOL_SYSTEMMEM, on the other hand, is proportional with the triangle count and not affected by the buffer size. I think that also matches our understanding, with the driver only uploading the data strictly required by the draw. I haven't tested it yet but I assume that it works similarly for indexed draws, where d3d can exploit the min vertex index + vertex count to only upload the required subset of the vertex buffer. The only other significant change with larger buffers / draws is the map time for no flags D3DPOOL_DEFAULT buffer maps, which is proportional to the triangle count. That makes perfect sense, the map has to wait for the draw to complete. No other draw or map duration change in a significant manner with larger buffer sizes / triangle counts. On AMD, map duration is not measurably affected by buffer size or triangle count in any buffer pool - flag combination, aside from the D3DPOOL_DEFAULT no flags case, which blocks until the previous draw is completed. Not much to see with draw duration either, they are generally "instant" with DEFAULT and SYSTEMMEM pool buffers and take a bit longer (on the order of 100 μs) with MANAGED. No significant changes with different buffer size and triangle count values.
I guess all of this means that applications need to cope with both behaviors (or, more likely, don't care) and we can probably get away with pretty much anything.
From what I have seen in real games (e.g. World of Warcraft, Call of Duty Modern Warfare 2) textures are probably more interesting here than buffers. Both games use UpdateTexture with sysmem, D3DUSAGE_DYNAMIC source textures that they later map with DISCARD. When I worked on the command stream I honored that DISCARD flag, but I never wrote tests to show that it is correct to do so.
Good point. I wrote another quick test and it looks like D3DPOOL_SYSTEMMEM texture maps never block. Actually the DISCARD flag seems to be ignored in the case of D3DPOOL_SYSTEMMEM textures, texture data is unchanged from the previous map. This seems to be the case for both Nvidia and AMD. Perhaps interestingly, the UpdateTexture() call also never blocks, as far as I can see. Nothing surprising otherwise, except that apparently the readback after a draw seems to take longer if the texture data was actually changed compared to just mapped and not modified (e.g. it's pretty consistent at 2 - 2.5 ms vs 3.7 ms on Nvidia). I guess I shouldn't read too much into it.
To complete testing coverage of DISCARD, I also wrote a test for buffers. It turns out that DISCARD is ignored for SYSTEMMEM or MANAGED buffers, the map pointer and the buffer contents are unchanged after the DISCARD map.
If it's useful I can clean up those tests / hacks a bit and share them. Otherwise I'm probably going to make proper tests only for the DISCARD thing (i.e. what's not timing-related).
On 13/11/2018 20:41, Matteo Bruni wrote:
If it's useful I can clean up those tests / hacks a bit and share them. Otherwise I'm probably going to make proper tests only for the DISCARD thing (i.e. what's not timing-related).
Hi,
For Gallium nine multithreading, we wanted to have a behaviour as close as possible to Windows.
We did tests on buffers with different flag configurations to figure out how it behaves with threading (on windows you can force the app to single core and thus disable windows d3d9 multithreading, and trigger different output). We did test on Nvidia, AMD and Intel Win10.
We also tested what happens if you:
. Write to the buffer after having unmapped it, before a draw. Same thing after a draw: Is the change taken into account for the next draw ?
. Map write draw write unmap. What is used ?
etc and what happens when you do the same thing without d3d9 multithreading (app bound to one core)
We also teste behaviour with different flags combined together for lock (surprisingly D3DLOCK_DONOTWAIT is respected on nvidia and will return D3DERR_WASSTILLDRAWING except for DYNAMIC buffers for example. The spec says the flag is invalid.)
We found that for most flag configurations, the vendors do different things, except for a few.
Especially we found MANAGED buffer upload behaviour to be consistent.
We noticed indeed SYSTEMMEM doesn't DISCARD.
I can unearth the tests and some of the results if you are interested.
Yours,
Axel Davy
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/d3d9_private.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index fc6e4af6501..be5f28a5278 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -304,11 +304,11 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i case WINED3D_RESOURCE_ACCESS_GPU: return D3DPOOL_DEFAULT; case WINED3D_RESOURCE_ACCESS_CPU: - if (usage & WINED3DUSAGE_SCRATCH) - return D3DPOOL_SCRATCH; - return D3DPOOL_SYSTEMMEM; + return D3DPOOL_SCRATCH; case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU: - return D3DPOOL_MANAGED; + if (usage & WINED3DUSAGE_MANAGED) + return D3DPOOL_MANAGED; + return D3DPOOL_SYSTEMMEM; } }
@@ -321,9 +321,9 @@ static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; return WINED3D_RESOURCE_ACCESS_GPU; case D3DPOOL_MANAGED: + case D3DPOOL_SYSTEMMEM: return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; - case D3DPOOL_SYSTEMMEM: case D3DPOOL_SCRATCH: return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; default:
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43431
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d8/d3d8_private.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 40a0f0a38d4..a9dc72f566b 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -291,11 +291,11 @@ static inline D3DPOOL d3dpool_from_wined3daccess(unsigned int access, unsigned i case WINED3D_RESOURCE_ACCESS_GPU: return D3DPOOL_DEFAULT; case WINED3D_RESOURCE_ACCESS_CPU: - if (usage & WINED3DUSAGE_SCRATCH) - return D3DPOOL_SCRATCH; - return D3DPOOL_SYSTEMMEM; + return D3DPOOL_SCRATCH; case WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU: - return D3DPOOL_MANAGED; + if (usage & WINED3DUSAGE_MANAGED) + return D3DPOOL_MANAGED; + return D3DPOOL_SYSTEMMEM; } }
@@ -308,9 +308,9 @@ static inline unsigned int wined3daccess_from_d3dpool(D3DPOOL pool, unsigned int return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; return WINED3D_RESOURCE_ACCESS_GPU; case D3DPOOL_MANAGED: + case D3DPOOL_SYSTEMMEM: return WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; - case D3DPOOL_SYSTEMMEM: case D3DPOOL_SCRATCH: return WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; default:
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43432
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45279 Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Deus Ex is also helped by this patch.
dlls/ddraw/vertexbuffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c index 3ad8f7e1bdd..6a1f010bd31 100644 --- a/dlls/ddraw/vertexbuffer.c +++ b/dlls/ddraw/vertexbuffer.c @@ -125,7 +125,8 @@ static HRESULT d3d_vertex_buffer_create_wined3d_buffer(struct d3d_vertex_buffer desc.usage |= WINED3DUSAGE_DYNAMIC; desc.bind_flags = WINED3D_BIND_VERTEX_BUFFER; if (buffer->Caps & D3DVBCAPS_SYSTEMMEMORY) - desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; + desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_GPU + | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; else desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0;
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43433
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d8/buffer.c | 2 -- dlls/d3d8/device.c | 2 -- dlls/d3d8/texture.c | 6 ------ dlls/d3d9/buffer.c | 2 -- dlls/d3d9/device.c | 2 -- dlls/d3d9/texture.c | 6 ------ dlls/wined3d/device.c | 6 ++---- dlls/wined3d/resource.c | 7 +++---- dlls/wined3d/surface.c | 2 +- dlls/wined3d/texture.c | 4 ++-- include/wine/wined3d.h | 1 - 11 files changed, 8 insertions(+), 32 deletions(-)
diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index 93917d4fdcf..da9d5317b22 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -577,8 +577,6 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de
desc.byte_width = size; desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index cf158daab17..a9a71d62363 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -1163,8 +1163,6 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width desc.multisample_type = multisample_type; desc.multisample_quality = multisample_quality; desc.usage = usage & WINED3DUSAGE_MASK; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index f7e8fd36b9f..5fe83d65f7b 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -1108,8 +1108,6 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device, desc.multisample_quality = 0; desc.usage = usage & WINED3DUSAGE_MASK; desc.usage |= WINED3DUSAGE_TEXTURE; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) @@ -1158,8 +1156,6 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic desc.multisample_quality = 0; desc.usage = usage & WINED3DUSAGE_MASK; desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) @@ -1207,8 +1203,6 @@ HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *dev desc.multisample_quality = 0; desc.usage = usage & WINED3DUSAGE_MASK; desc.usage |= WINED3DUSAGE_TEXTURE; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage); diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index b12167eb8be..c854556e723 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -576,8 +576,6 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de
desc.byte_width = size; desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.bind_flags = WINED3D_BIND_INDEX_BUFFER; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 39281330aa1..3e549c956b8 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1390,8 +1390,6 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width desc.multisample_type = multisample_type; desc.multisample_quality = multisample_quality; desc.usage = usage & WINED3DUSAGE_MASK; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index 52cefbf9e28..609b5e7def7 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -1312,8 +1312,6 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device, desc.multisample_quality = 0; desc.usage = wined3dusage_from_d3dusage(usage); desc.usage |= WINED3DUSAGE_TEXTURE; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) @@ -1399,8 +1397,6 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic desc.multisample_quality = 0; desc.usage = wined3dusage_from_d3dusage(usage); desc.usage |= WINED3DUSAGE_LEGACY_CUBEMAP | WINED3DUSAGE_TEXTURE; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage) @@ -1472,8 +1468,6 @@ HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *dev desc.multisample_quality = 0; desc.usage = wined3dusage_from_d3dusage(usage); desc.usage |= WINED3DUSAGE_TEXTURE; - if (pool == D3DPOOL_SCRATCH) - desc.usage |= WINED3DUSAGE_SCRATCH; if (pool == D3DPOOL_MANAGED) desc.usage |= WINED3DUSAGE_MANAGED; desc.access = wined3daccess_from_d3dpool(pool, usage); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index f98c02d99c0..d402bb01518 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3466,7 +3466,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device, return WINED3D_OK; }
- if (texture && texture->resource.usage & WINED3DUSAGE_SCRATCH) + if (texture && ~texture->resource.access & WINED3D_RESOURCE_ACCESS_GPU) { WARN("Rejecting attempt to set scratch texture.\n"); return WINED3DERR_INVALIDCALL; @@ -3805,9 +3805,7 @@ HRESULT CDECL wined3d_device_update_texture(struct wined3d_device *device, return WINED3DERR_INVALIDCALL; }
- if ((src_texture->resource.access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)) - == WINED3D_RESOURCE_ACCESS_GPU - || src_texture->resource.usage & WINED3DUSAGE_SCRATCH + if (~src_texture->resource.access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU) || src_texture->resource.usage & WINED3DUSAGE_MANAGED) { WARN("Source resource doesn't allow both CPU and GPU access or is a managed resource.\n"); diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 8669100f138..eef8e9f9f7a 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -36,7 +36,6 @@ static void resource_check_usage(DWORD usage) | WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_STATICDECL | WINED3DUSAGE_OVERLAY - | WINED3DUSAGE_SCRATCH | WINED3DUSAGE_MANAGED | WINED3DUSAGE_PRIVATE | WINED3DUSAGE_LEGACY_CUBEMAP @@ -88,9 +87,9 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource_check_usage(usage);
- if (usage & WINED3DUSAGE_SCRATCH && access & WINED3D_RESOURCE_ACCESS_GPU) + if (usage & WINED3DUSAGE_MANAGED && ~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU)) { - ERR("Trying to create a scratch resource with access flags %s.\n", + ERR("Trying to create a managed resource with access flags %s.\n", wined3d_debug_resource_access(access)); return WINED3DERR_INVALIDCALL; } @@ -151,7 +150,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * * Use 2D textures, the texture code will pad to a power of 2 size. */ gl_type = WINED3D_GL_RES_TYPE_TEX_2D; } - else if (usage & WINED3DUSAGE_SCRATCH) + else if (~access & WINED3D_RESOURCE_ACCESS_GPU) { /* Needed for proper format information. */ gl_type = base_type; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 71693adc589..131132797e5 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -633,7 +633,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr desc.format = dst_format->id; desc.multisample_type = WINED3D_MULTISAMPLE_NONE; desc.multisample_quality = 0; - desc.usage = WINED3DUSAGE_SCRATCH | WINED3DUSAGE_PRIVATE; + desc.usage = WINED3DUSAGE_PRIVATE; desc.access = WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.width = wined3d_texture_get_level_width(src_texture, texture_level); desc.height = wined3d_texture_get_level_height(src_texture, texture_level); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 283f35cd525..7dcac1352cf 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -2899,7 +2899,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc format = wined3d_get_format(device->adapter, desc->format, desc->usage);
if (desc->usage & WINED3DUSAGE_DYNAMIC && (desc->usage & WINED3DUSAGE_MANAGED - || desc->usage & WINED3DUSAGE_SCRATCH)) + || ~desc->access & WINED3D_RESOURCE_ACCESS_GPU)) { WARN("Attempted to create a dynamic texture with access %s and usage %s.\n", wined3d_debug_resource_access(desc->access), debug_d3dusage(desc->usage)); @@ -2920,7 +2920,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc /* level_count == 0 returns an error as well. */ if (level_count != 1 || layer_count != 1 || desc->resource_type == WINED3D_RTYPE_TEXTURE_3D) { - if (!(desc->usage & WINED3DUSAGE_SCRATCH)) + if (desc->access & WINED3D_RESOURCE_ACCESS_GPU) { WARN("Attempted to create a mipmapped/cube/array/volume NPOT " "texture without unconditional NPOT support.\n"); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index d8322ef017e..d4088e3cf81 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -930,7 +930,6 @@ enum wined3d_shader_type #define WINED3DUSAGE_TEXTAPI 0x10000000 #define WINED3DUSAGE_MASK 0x10007bfb
-#define WINED3DUSAGE_SCRATCH 0x00200000 #define WINED3DUSAGE_MANAGED 0x00000004 #define WINED3DUSAGE_PRIVATE 0x00400000 #define WINED3DUSAGE_LEGACY_CUBEMAP 0x00800000
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43434
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply
=== debian9 (build log) ===
error: patch failed: dlls/wined3d/buffer.c:1386 Task: Patch failed to apply