-- v2: d3d9/tests: Skip test_sample_attached_rendertarget() without pixel shaders support. wined3d: Don't override texture parameters for COND_NP2 on multisample textures. wined3d: Don't skip FFP projection transform update. d3d9: Don't do instanced draws in DrawPrimitive() and DrawPrimitiveUP().
From: Matteo Bruni mbruni@codeweavers.com
Which is really what it means nowadays: resources created by the CS. It has mostly implications WRT thread safety.
In particular, the flag doesn't mean that the resource doesn't participate in memory accounting (that was split into WINED3DUSAGE_VIDMEM_ACCOUNTING by 723cd0a4ae76ec45320290893c7af7f90b668556), nor that it isn't checked for Reset purposes (we use parent == NULL for that). --- dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/glsl_shader.c | 2 +- dlls/wined3d/resource.c | 6 +++--- dlls/wined3d/surface.c | 2 +- dlls/wined3d/texture.c | 6 +++--- include/wine/wined3d.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index ee693924a24..01785166cba 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7883,7 +7883,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl desc.format = src_texture->resource.format->id; desc.multisample_type = src_texture->resource.multisample_type; desc.multisample_quality = src_texture->resource.multisample_quality; - desc.usage = WINED3DUSAGE_PRIVATE; + desc.usage = WINED3DUSAGE_CS; desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(src_texture, src_level); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 5dfcbb689b7..0c7bd49f686 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -13167,7 +13167,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli desc.format = src_texture->resource.format->id; desc.multisample_type = src_texture->resource.multisample_type; desc.multisample_quality = src_texture->resource.multisample_quality; - desc.usage = WINED3DUSAGE_PRIVATE; + desc.usage = WINED3DUSAGE_CS; desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(src_texture, src_level); diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 9d3fd0a426d..85c55e566b2 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -35,7 +35,7 @@ static void resource_check_usage(uint32_t usage, unsigned int access) | WINED3DUSAGE_OVERLAY | WINED3DUSAGE_SCRATCH | WINED3DUSAGE_MANAGED - | WINED3DUSAGE_PRIVATE + | WINED3DUSAGE_CS | WINED3DUSAGE_LEGACY_CUBEMAP | ~WINED3DUSAGE_MASK;
@@ -221,7 +221,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * adapter_adjust_memory(device->adapter, size); }
- if (!(usage & WINED3DUSAGE_PRIVATE)) + if (!(usage & WINED3DUSAGE_CS)) device_resource_add(device, resource);
return WINED3D_OK; @@ -247,7 +247,7 @@ void resource_cleanup(struct wined3d_resource *resource) adapter_adjust_memory(resource->device->adapter, (INT64)0 - resource->size); }
- if (!(resource->usage & WINED3DUSAGE_PRIVATE)) + if (!(resource->usage & WINED3DUSAGE_CS)) device_resource_released(resource->device, resource);
wined3d_resource_reference(resource); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 87b3d3c38a4..a1ae63a0f78 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -271,7 +271,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_SCRATCH | WINED3DUSAGE_CS; desc.bind_flags = 0; 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); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 8a7f9455bb0..88647a9cdb7 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -418,7 +418,7 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont desc.format = resolve_format_id; desc.multisample_type = src_texture->resource.multisample_type; desc.multisample_quality = src_texture->resource.multisample_quality; - desc.usage = WINED3DUSAGE_PRIVATE; + desc.usage = WINED3DUSAGE_CS; desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(src_texture, src_level); @@ -457,7 +457,7 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont desc.format = resolve_format_id; desc.multisample_type = dst_texture->resource.multisample_type; desc.multisample_quality = dst_texture->resource.multisample_quality; - desc.usage = WINED3DUSAGE_PRIVATE; + desc.usage = WINED3DUSAGE_CS; desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(dst_texture, dst_level); @@ -6268,7 +6268,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit desc.format = src_texture->resource.format->id; desc.multisample_type = src_texture->resource.multisample_type; desc.multisample_quality = src_texture->resource.multisample_quality; - desc.usage = WINED3DUSAGE_PRIVATE; + desc.usage = WINED3DUSAGE_CS; desc.bind_flags = 0; desc.access = WINED3D_RESOURCE_ACCESS_GPU; desc.width = wined3d_texture_get_level_width(src_texture, src_level); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index fcbe094e30b..c7c50cc2f0d 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -930,7 +930,7 @@ enum wined3d_memory_segment_group #define WINED3DUSAGE_MASK 0x10007bf0
#define WINED3DUSAGE_SCRATCH 0x00400000 -#define WINED3DUSAGE_PRIVATE 0x00800000 +#define WINED3DUSAGE_CS 0x00800000 #define WINED3DUSAGE_LEGACY_CUBEMAP 0x01000000 #define WINED3DUSAGE_OWNDC 0x02000000 #define WINED3DUSAGE_STATICDECL 0x04000000
From: Matteo Bruni mbruni@codeweavers.com
On Windows this behavior is hardware dependent. Setting instance_count to 0 makes all our d3d versions consistent in this regard and avoids triggering the FIXME() in wined3d:draw_primitive_immediate_mode(). --- dlls/d3d9/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 1267dc8fca1..31dffbf4b60 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3176,7 +3176,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface, wined3d_primitive_type_from_d3d(primitive_type), 0);
/* Instancing is ignored for non-indexed draws. */ - wined3d_device_context_draw(device->immediate_context, start_vertex, vertex_count, 0, 1); + wined3d_device_context_draw(device->immediate_context, start_vertex, vertex_count, 0, 0);
d3d9_rts_flag_auto_gen_mipmap(device); wined3d_mutex_unlock(); @@ -3274,7 +3274,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface, wined3d_device_apply_stateblock(device->wined3d_device, device->state);
/* Instancing is ignored for non-indexed draws. */ - wined3d_device_context_draw(device->immediate_context, vb_pos / stride, vtx_count, 0, 1); + wined3d_device_context_draw(device->immediate_context, vb_pos / stride, vtx_count, 0, 0);
wined3d_stateblock_set_stream_source(device->state, 0, NULL, 0, 0); d3d9_rts_flag_auto_gen_mipmap(device);
From: Matteo Bruni mbruni@codeweavers.com
In the same vein as e106bbdd39a5f27bce028ed992033eb0a5635f60. --- dlls/wined3d/state.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 2fb75785daf..6dfbc0400bc 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3639,6 +3639,8 @@ static void transform_projection(struct wined3d_context *context, const struct w const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info; struct wined3d_matrix projection;
+ TRACE("context %p, state %p, state_id %lu.\n", context, state, state_id); + gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION); checkGLcall("glMatrixMode(GL_PROJECTION)");
@@ -3669,6 +3671,8 @@ static void vertexdeclaration(struct wined3d_context *context, const struct wine BOOL wasrhw = context->last_was_rhw; unsigned int i;
+ TRACE("context %p, state %p, state_id %lu.\n", context, state, state_id); + transformed = context->stream_info.position_transformed; if (transformed != context->last_was_rhw && !useVertexShaderFunction) updateFog = TRUE; @@ -3685,25 +3689,12 @@ static void vertexdeclaration(struct wined3d_context *context, const struct wine * make sure they're properly set. */ if (!useVertexShaderFunction) { - /* TODO: Move this mainly to the viewport state and only apply when - * the vp has changed or transformed / untransformed was switched. */ if (wasrhw != context->last_was_rhw - && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)) && !isStateDirty(context, STATE_VIEWPORT)) transform_projection(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); - /* World matrix needs reapplication here only if we're switching between rhw and non-rhw - * mode. - * - * If a vertex shader is used, the world matrix changed and then vertex shader unbound - * this check will fail and the matrix not applied again. This is OK because a simple - * world matrix change reapplies the matrix - These checks here are only to satisfy the - * needs of the vertex declaration. - * - * World and view matrix go into the same gl matrix, so only apply them when neither is - * dirty - */ - if (transformed != wasrhw && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))) - && !isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_VIEW))) + /* World matrix needs reapplication here only if we're switching + * between rhw and non-rhw mode. */ + if (transformed != wasrhw) transform_world(context, state, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))); if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_COLORVERTEX))) context_apply_state(context, state, STATE_RENDER(WINED3D_RS_COLORVERTEX)); @@ -3941,8 +3932,9 @@ static void viewport_miscpart_cc(struct wined3d_context *context,
static void viewport_vertexpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - if (!isStateDirty(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION))) - transform_projection(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); + TRACE("context %p, state %p, state_id %lu.\n", context, state, state_id); + + transform_projection(context, state, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); if (!isStateDirty(context, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE)) && state->render_states[WINED3D_RS_POINTSCALEENABLE]) state_pscale(context, state, STATE_RENDER(WINED3D_RS_POINTSCALEENABLE));
From: Matteo Bruni mbruni@codeweavers.com
Those parameters are not supported on multisample textures in the first place (basically, GL mandates ARB_sampler_objects for those).
The combination COND_NP2 + ARB_texture_multisample is not expected to happen without wined3d configuration overrides. --- dlls/wined3d/texture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 88647a9cdb7..96f77806420 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1380,7 +1380,8 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, gl_info->gl_ops.gl.p_glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); }
- if (texture_gl->t.flags & WINED3D_TEXTURE_COND_NP2) + if (texture_gl->t.flags & WINED3D_TEXTURE_COND_NP2 && target != GL_TEXTURE_2D_MULTISAMPLE + && target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY) { /* Conditional non power of two textures use a different clamping * default. If we're using the GL_WINE_normalized_texrect partial
From: Matteo Bruni mbruni@codeweavers.com
--- dlls/d3d9/tests/visual.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 2d54920ddba..705e3d8ff9c 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -26855,6 +26855,7 @@ static void test_sample_attached_rendertarget(void) unsigned int color, i; IDirect3D9 *d3d; ULONG refcount; + D3DCAPS9 caps; BOOL is_warp; HWND window; HRESULT hr; @@ -26904,6 +26905,17 @@ static void test_sample_attached_rendertarget(void) return; }
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) + { + skip("No shader model 2 support, skipping tests.\n"); + IDirect3DDevice9_Release(device); + IDirect3D9_Release(d3d); + DestroyWindow(window); + return; + } + hr = IDirect3DDevice9_CreateQuery(device, D3DQUERYTYPE_EVENT, NULL); if (hr == D3DERR_NOTAVAILABLE) {
On Thu Dec 7 20:11:57 2023 +0000, Matteo Bruni wrote:
Ah, right! I'll try to write a test.
Actually this was tested by Stefan a while ago (see https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/d3d9/tests/visual.c?r...) to be hardware dependent, which should mean that applications can't rely on any particular behavior. I respun the patch to make d3d9 use 0 as instance_count like the others.
This merge request was closed by Matteo Bruni.
Superseded by !4652