Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/arb_program_shader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index b1837041293..de32587050d 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -226,7 +226,7 @@ struct recorded_instruction
struct shader_arb_ctx_priv { - char addr_reg[20]; + char addr_reg[50]; enum { /* plain GL_ARB_vertex_program or GL_ARB_fragment_program */
D3d9 is very lax WRT map access to buffers and there isn't really much of a reason for us to restrict read access to non-DEFAULT resources.
On the other hand, we'd still really like to be able to ensure that DEFAULT, DYNAMIC | WRITEONLY buffers get allocated in the proper memory region and get efficient data uploads, so keep the restriction for DEFAULT resources.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46849 Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Once we start using glBufferStorage() to create GL buffers (with MAP_WRITE_BIT / MAP_READ_BIT depending on resource access flags) we'll be depending on undefined behavior ("MAP_READ_BIT - "... "No GL error is generated if the pointer is used to query a mapping which excludes this flag, but the result is undefined and system errors (possibly including program termination) may occur.") for test_writeonly_resource() in device.c and possibly actual applications (not Vietcong though, it uses a WRITEONLY SYSTEMMEM buffer). The test works for me on both Nvidia and AMD but I realize it's not great...
dlls/d3d9/buffer.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index 43321b3202b..46d11e7de09 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -316,6 +316,9 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device * desc.usage = usage & WINED3DUSAGE_MASK; desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); + /* Buffers are always readable. */ + if (pool != D3DPOOL_DEFAULT) + desc.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0;
@@ -639,6 +642,9 @@ HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *de desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); + /* Buffers are always readable. */ + if (pool != D3DPOOL_DEFAULT) + desc.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0;
Hi,
While running your changed tests, 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=52149
Your paranoid android.
=== debian9 (32 bit WoW report) ===
d3d9: d3d9ex.c:3133: Test failed: Expected message 0x46 for window 0x1, but didn't receive it, i=0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Mon, 13 May 2019 at 23:05, Matteo Bruni mbruni@codeweavers.com wrote:
D3d9 is very lax WRT map access to buffers and there isn't really much of a reason for us to restrict read access to non-DEFAULT resources.
On the other hand, we'd still really like to be able to ensure that DEFAULT, DYNAMIC | WRITEONLY buffers get allocated in the proper memory region and get efficient data uploads, so keep the restriction for DEFAULT resources.
So another, perhaps clearer, way to frame this is that we ignore D3DUSAGE_WRITEONLY for pools other than D3DPOOL_DEFAULT.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d8/buffer.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index 822730ff6dc..8598766ce9e 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -309,6 +309,9 @@ HRESULT vertexbuffer_init(struct d3d8_vertexbuffer *buffer, struct d3d8_device * desc.usage = usage & WINED3DUSAGE_MASK; desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); + /* Buffers are always readable. */ + if (pool != D3DPOOL_DEFAULT) + desc.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0;
@@ -628,6 +631,9 @@ HRESULT indexbuffer_init(struct d3d8_indexbuffer *buffer, struct d3d8_device *de desc.usage = (usage & WINED3DUSAGE_MASK) | WINED3DUSAGE_STATICDECL; desc.bind_flags = 0; desc.access = wined3daccess_from_d3dpool(pool, usage) | map_access_from_usage(usage); + /* Buffers are always readable. */ + if (pool != D3DPOOL_DEFAULT) + desc.access |= WINED3D_RESOURCE_ACCESS_MAP_R | WINED3D_RESOURCE_ACCESS_MAP_W; desc.misc_flags = 0; desc.structure_byte_stride = 0;
Hi,
While running your changed tests, 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=52150
Your paranoid android.
=== debian9 (32 bit WoW report) ===
d3d9: d3d9ex.c:3133: Test failed: Expected message 0x46 for window 0x1, but didn't receive it, i=0.
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index d1ae2ceb513..ac68d2e7fd8 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -5346,9 +5346,10 @@ static void context_unload_numbered_arrays(struct wined3d_context *context) } }
-static void context_load_numbered_arrays(struct wined3d_context *context, +static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *context_gl, const struct wined3d_stream_info *stream_info, const struct wined3d_state *state) { + struct wined3d_context *context = &context_gl->c; const struct wined3d_shader *vs = state->shader[WINED3D_SHADER_TYPE_VERTEX]; const struct wined3d_gl_info *gl_info = context->gl_info; GLuint current_bo; @@ -5552,7 +5553,7 @@ void context_update_stream_sources(struct wined3d_context *context, const struct if (context->d3d_info->ffp_generic_attributes || use_vs(state)) { TRACE("Loading numbered arrays.\n"); - context_load_numbered_arrays(context, &context->stream_info, state); + wined3d_context_gl_load_numbered_arrays(wined3d_context_gl(context), &context->stream_info, state); return; }
Hi,
While running your changed tests, 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=52151
Your paranoid android.
=== debian9 (32 bit WoW report) ===
d3d9: d3d9ex.c:3133: Test failed: Expected message 0x46 for window 0x1, but didn't receive it, i=0.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/context.c | 18 +++++++++--------- dlls/wined3d/state.c | 4 ++-- dlls/wined3d/wined3d_private.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index ac68d2e7fd8..073380fa99b 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -5543,24 +5543,24 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c checkGLcall("Loading numbered arrays"); }
-void context_update_stream_sources(struct wined3d_context *context, const struct wined3d_state *state) +void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl, + const struct wined3d_state *state) { - - if (context->use_immediate_mode_draw) + if (context_gl->c.use_immediate_mode_draw) return;
- context_unload_vertex_data(context); - if (context->d3d_info->ffp_generic_attributes || use_vs(state)) + context_unload_vertex_data(&context_gl->c); + if (context_gl->c.d3d_info->ffp_generic_attributes || use_vs(state)) { TRACE("Loading numbered arrays.\n"); - wined3d_context_gl_load_numbered_arrays(wined3d_context_gl(context), &context->stream_info, state); + wined3d_context_gl_load_numbered_arrays(context_gl, &context_gl->c.stream_info, state); return; }
TRACE("Loading named arrays.\n"); - context_unload_numbered_arrays(context); - context_load_vertex_data(context, &context->stream_info, state); - context->namedArraysLoaded = TRUE; + context_unload_numbered_arrays(&context_gl->c); + context_load_vertex_data(&context_gl->c, &context_gl->c.stream_info, state); + context_gl->c.namedArraysLoaded = TRUE; }
static void apply_texture_blit_state(const struct wined3d_gl_info *gl_info, struct gl_texture *texture, diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 729100adb21..08423e831fd 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -3863,14 +3863,14 @@ static void streamsrc(struct wined3d_context *context, const struct wined3d_stat { if (isStateDirty(context, STATE_VDECL)) return; - context_update_stream_sources(context, state); + wined3d_context_gl_update_stream_sources(wined3d_context_gl(context), state); }
static void vdecl_miscpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { if (isStateDirty(context, STATE_STREAMSRC)) return; - context_update_stream_sources(context, state); + wined3d_context_gl_update_stream_sources(wined3d_context_gl(context), state); }
static void vertexdeclaration(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 13f8b570cc1..35291639505 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2072,6 +2072,8 @@ HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl, const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN; +void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl, + const struct wined3d_state *state) DECLSPEC_HIDDEN;
struct wined3d_fb_state { @@ -2266,8 +2268,6 @@ void context_texture_update(struct wined3d_context *context, void context_unload_tex_coords(const struct wined3d_context *context) DECLSPEC_HIDDEN; void context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, GLenum binding) DECLSPEC_HIDDEN; -void context_update_stream_sources(struct wined3d_context *context, - const struct wined3d_state *state) DECLSPEC_HIDDEN;
/***************************************************************************** * Internal representation of a light
Hi,
While running your changed tests, 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=52152
Your paranoid android.
=== debian9 (32 bit WoW report) ===
d3d9: d3d9ex.c:3133: Test failed: Expected message 0x46 for window 0x1, but didn't receive it, i=0.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I haven't tested performance (I don't expect significant effects), I wrote the patch mostly to clean up GL traces a bit.
dlls/wined3d/context.c | 20 ++++++++++++++++++-- dlls/wined3d/wined3d_private.h | 5 ++++- 2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 073380fa99b..fbbf89c4baa 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -5370,9 +5370,23 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c if (context->numbered_array_mask & (1u << i)) context_unload_numbered_array(context, i); if (!use_vs(state) && i == WINED3D_FFP_DIFFUSE) - GL_EXTCALL(glVertexAttrib4f(i, 1.0f, 1.0f, 1.0f, 1.0f)); + { + if (!(context_gl->default_attrib_value_set & (1u << i)) || !context_gl->diffuse_attrib_to_1) + { + GL_EXTCALL(glVertexAttrib4f(i, 1.0f, 1.0f, 1.0f, 1.0f)); + context_gl->diffuse_attrib_to_1 = 1; + } + } else - GL_EXTCALL(glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f)); + { + if (!(context_gl->default_attrib_value_set & (1u << i))) + { + GL_EXTCALL(glVertexAttrib4f(i, 0.0f, 0.0f, 0.0f, 0.0f)); + if (i == WINED3D_FFP_DIFFUSE) + context_gl->diffuse_attrib_to_1 = 0; + } + } + context_gl->default_attrib_value_set |= 1u << i; continue; }
@@ -5392,6 +5406,7 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c * mode instead. */ if (context->numbered_array_mask & (1u << i)) context_unload_numbered_array(context, i); + context_gl->default_attrib_value_set &= ~(1u << i); continue; }
@@ -5538,6 +5553,7 @@ static void wined3d_context_gl_load_numbered_arrays(struct wined3d_context_gl *c break;
} + context_gl->default_attrib_value_set &= ~(1u << i); } } checkGLcall("Loading numbered arrays"); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 35291639505..aad0f25982f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2022,7 +2022,10 @@ struct wined3d_context_gl struct wined3d_context c;
uint32_t fog_enabled : 1; - uint32_t padding : 31; + uint32_t diffuse_attrib_to_1 : 1; + uint32_t padding : 30; + + uint32_t default_attrib_value_set;
GLenum *texture_type;
On Mon, 13 May 2019 at 23:04, Matteo Bruni mbruni@codeweavers.com wrote:
@@ -226,7 +226,7 @@ struct recorded_instruction
struct shader_arb_ctx_priv {
- char addr_reg[20];
- char addr_reg[50];
Ideally you'd make this use a wined3d_string_buffer, of course.