Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 2d5bc77ed7..c95e1a003e 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3524,7 +3524,7 @@ static HRESULT WINAPI d3d9_device_GetVertexShader(IDirect3DDevice9Ex *iface, IDi TRACE("iface %p, shader %p.\n", iface, shader);
wined3d_mutex_lock(); - if ((wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device))) + if ((wined3d_shader = wined3d_stateblock_get_state(device->state)->vs)) { shader_impl = wined3d_shader_get_parent(wined3d_shader); *shader = &shader_impl->IDirect3DVertexShader9_iface;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 3 --- 1 file changed, 3 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index c95e1a003e..6f35b3caab 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3507,9 +3507,6 @@ static HRESULT WINAPI d3d9_device_SetVertexShader(IDirect3DDevice9Ex *iface, IDi wined3d_mutex_lock(); wined3d_stateblock_set_vertex_shader(device->update_state, shader_obj ? shader_obj->wined3d_shader : NULL); - if (!device->recording) - wined3d_device_set_vertex_shader(device->wined3d_device, - shader_obj ? shader_obj->wined3d_shader : NULL); wined3d_mutex_unlock();
return D3D_OK;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/d3d9_private.h | 2 +- dlls/d3d9/device.c | 35 ++++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h index a7072162d5..bc9a3b98b2 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -114,7 +114,7 @@ struct d3d9_device
DWORD auto_mipmaps; /* D3D9_MAX_TEXTURE_UNITS */
- unsigned int max_user_clip_planes; + unsigned int max_user_clip_planes, vs_uniform_count;
UINT implicit_swapchain_count; struct wined3d_swapchain **implicit_swapchains; diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 6f35b3caab..ad2f04dd04 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3570,23 +3570,24 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantF(IDirect3DDevice9Ex *i UINT reg_idx, float *data, UINT count) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
- if (reg_idx + count > D3D9_MAX_VERTEX_SHADER_CONSTANTF) + if (!data) + return D3DERR_INVALIDCALL; + + if (reg_idx >= device->vs_uniform_count || reg_idx + count > device->vs_uniform_count) { WARN("Trying to access %u constants, but d3d9 only supports %u\n", - reg_idx + count, D3D9_MAX_VERTEX_SHADER_CONSTANTF); + reg_idx + count, device->vs_uniform_count); return D3DERR_INVALIDCALL; }
wined3d_mutex_lock(); - hr = wined3d_device_get_vs_consts_f(device->wined3d_device, - reg_idx, count, (struct wined3d_vec4 *)data); + memcpy(data, &wined3d_stateblock_get_state(device->state)->vs_consts_f[reg_idx], count * sizeof(struct wined3d_vec4)); wined3d_mutex_unlock();
- return hr; + return D3D_OK; }
static HRESULT WINAPI d3d9_device_SetVertexShaderConstantI(IDirect3DDevice9Ex *iface, @@ -3612,16 +3613,19 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantI(IDirect3DDevice9Ex *i UINT reg_idx, int *data, UINT count) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
+ if (!data || reg_idx >= WINED3D_MAX_CONSTS_I) + return WINED3DERR_INVALIDCALL; + if (count > WINED3D_MAX_CONSTS_I - reg_idx) + count = WINED3D_MAX_CONSTS_I - reg_idx; + wined3d_mutex_lock(); - hr = wined3d_device_get_vs_consts_i(device->wined3d_device, - reg_idx, count, (struct wined3d_ivec4 *)data); + memcpy(data, &wined3d_stateblock_get_state(device->state)->vs_consts_i[reg_idx], count * sizeof(struct wined3d_ivec4)); wined3d_mutex_unlock();
- return hr; + return D3D_OK; }
static HRESULT WINAPI d3d9_device_SetVertexShaderConstantB(IDirect3DDevice9Ex *iface, @@ -3645,15 +3649,19 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantB(IDirect3DDevice9Ex *i UINT reg_idx, BOOL *data, UINT count) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr;
TRACE("iface %p, reg_idx %u, data %p, count %u.\n", iface, reg_idx, data, count);
+ if (!data || reg_idx >= WINED3D_MAX_CONSTS_B) + return WINED3DERR_INVALIDCALL; + if (count > WINED3D_MAX_CONSTS_B - reg_idx) + count = WINED3D_MAX_CONSTS_B - reg_idx; + wined3d_mutex_lock(); - hr = wined3d_device_get_vs_consts_b(device->wined3d_device, reg_idx, count, data); + memcpy(data, &wined3d_stateblock_get_state(device->state)->vs_consts_b[reg_idx], count * sizeof(*data)); wined3d_mutex_unlock();
- return hr; + return D3D_OK; }
static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface, @@ -4609,6 +4617,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_get_device_caps(wined3d, adapter, device_type, &caps); device->max_user_clip_planes = caps.MaxUserClipPlanes; + device->vs_uniform_count = caps.MaxVertexShaderConst; if (flags & D3DCREATE_ADAPTERGROUP_DEVICE) count = caps.NumberOfAdaptersInGroup;
On Sat, 8 Feb 2020 at 07:42, Zebediah Figura z.figura12@gmail.com wrote:
- if (reg_idx >= device->vs_uniform_count || reg_idx + count > device->vs_uniform_count) {
"reg_idx + count" can overflow. In principle that's an existing issue, but previously wined3d_device_get_vs_consts_f() would have caught it.
- hr = wined3d_device_get_vs_consts_i(device->wined3d_device,
reg_idx, count, (struct wined3d_ivec4 *)data);
- memcpy(data, &wined3d_stateblock_get_state(device->state)->vs_consts_i[reg_idx], count * sizeof(struct wined3d_ivec4));
It's just a tought, but the following may be slightly more natural:
const struct wined3d_ivec4 *src = wined3d_stateblock_get_state(device->state)->vs_consts_i; memcpy(data, &src[reg_idx], count * sizeof(*src));
On 2/10/20 8:37 AM, Henri Verbeet wrote:
On Sat, 8 Feb 2020 at 07:42, Zebediah Figura z.figura12@gmail.com wrote:
- if (reg_idx >= device->vs_uniform_count || reg_idx + count > device->vs_uniform_count) {
"reg_idx + count" can overflow. In principle that's an existing issue, but previously wined3d_device_get_vs_consts_f() would have caught it.
Ah, right. I should have wondered why it was written that way to begin with...
- hr = wined3d_device_get_vs_consts_i(device->wined3d_device,
reg_idx, count, (struct wined3d_ivec4 *)data);
- memcpy(data, &wined3d_stateblock_get_state(device->state)->vs_consts_i[reg_idx], count * sizeof(struct wined3d_ivec4));
It's just a tought, but the following may be slightly more natural:
const struct wined3d_ivec4 *src =
wined3d_stateblock_get_state(device->state)->vs_consts_i; memcpy(data, &src[reg_idx], count * sizeof(*src));
Yeah, probably.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 10 ---------- 1 file changed, 10 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index ad2f04dd04..284ea831c6 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3556,11 +3556,6 @@ static HRESULT WINAPI d3d9_device_SetVertexShaderConstantF(IDirect3DDevice9Ex *i wined3d_mutex_lock(); hr = wined3d_stateblock_set_vs_consts_f(device->update_state, reg_idx, count, (const struct wined3d_vec4 *)data); - if (SUCCEEDED(hr) && !device->recording) - { - hr = wined3d_device_set_vs_consts_f(device->wined3d_device, - reg_idx, count, (const struct wined3d_vec4 *)data); - } wined3d_mutex_unlock();
return hr; @@ -3601,9 +3596,6 @@ static HRESULT WINAPI d3d9_device_SetVertexShaderConstantI(IDirect3DDevice9Ex *i wined3d_mutex_lock(); hr = wined3d_stateblock_set_vs_consts_i(device->update_state, reg_idx, count, (const struct wined3d_ivec4 *)data); - if (SUCCEEDED(hr) && !device->recording) - hr = wined3d_device_set_vs_consts_i(device->wined3d_device, - reg_idx, count, (const struct wined3d_ivec4 *)data); wined3d_mutex_unlock();
return hr; @@ -3638,8 +3630,6 @@ static HRESULT WINAPI d3d9_device_SetVertexShaderConstantB(IDirect3DDevice9Ex *i
wined3d_mutex_lock(); hr = wined3d_stateblock_set_vs_consts_b(device->update_state, reg_idx, count, data); - if (SUCCEEDED(hr) && !device->recording) - hr = wined3d_device_set_vs_consts_b(device->wined3d_device, reg_idx, count, data); wined3d_mutex_unlock();
return hr;
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=64736
Your paranoid android.
=== debian10 (64 bit WoW report) ===
d3d9: d3d9ex: Timeout device: Timeout stateblock: Timeout
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 284ea831c6..96e1e10252 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -3870,7 +3870,7 @@ static HRESULT WINAPI d3d9_device_GetPixelShader(IDirect3DDevice9Ex *iface, IDir if (!shader) return D3DERR_INVALIDCALL;
wined3d_mutex_lock(); - if ((wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device))) + if ((wined3d_shader = wined3d_stateblock_get_state(device->state)->ps)) { shader_impl = wined3d_shader_get_parent(wined3d_shader); *shader = &shader_impl->IDirect3DPixelShader9_iface;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com