Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/d3d8_private.h | 2 ++ dlls/d3d8/device.c | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 26451255c0..0fcc8bd7a0 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -131,6 +131,8 @@ struct d3d8_device DWORD in_destruction : 1; DWORD padding : 14;
+ unsigned int vs_uniform_count; + /* The d3d8 API supports only one implicit swapchain (no D3DCREATE_ADAPTERGROUP_DEVICE, * no GetSwapchain, GetBackBuffer doesn't accept a swapchain number). */ struct wined3d_swapchain *implicit_swapchain; diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index ef1b3afde9..90dec4aaa7 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2991,26 +2991,29 @@ static HRESULT WINAPI d3d8_device_SetVertexShaderConstant(IDirect3DDevice8 *ifac }
static HRESULT WINAPI d3d8_device_GetVertexShaderConstant(IDirect3DDevice8 *iface, - DWORD start_register, void *data, DWORD count) + DWORD start_idx, void *constants, DWORD count) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; + const struct wined3d_vec4 *src;
- TRACE("iface %p, start_register %u, data %p, count %u.\n", - iface, start_register, data, count); + TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
- if (start_register + count > D3D8_MAX_VERTEX_SHADER_CONSTANTF) + if (!constants) + return D3DERR_INVALIDCALL; + + if (start_idx >= device->vs_uniform_count || count > device->vs_uniform_count - start_idx) { - WARN("Trying to access %u constants, but d3d8 only supports %u\n", - start_register + count, D3D8_MAX_VERTEX_SHADER_CONSTANTF); + WARN("Trying to access %u constants, but d3d8 only supports %u.\n", + start_idx + count, device->vs_uniform_count); return D3DERR_INVALIDCALL; }
wined3d_mutex_lock(); - hr = wined3d_device_get_vs_consts_f(device->wined3d_device, start_register, count, data); + src = wined3d_stateblock_get_state(device->state)->vs_consts_f; + memcpy(constants, &src[start_idx], count * sizeof(*src)); wined3d_mutex_unlock();
- return hr; + return D3D_OK; }
static HRESULT WINAPI d3d8_device_GetVertexShaderDeclaration(IDirect3DDevice8 *iface, @@ -3668,6 +3671,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine struct wined3d_swapchain_desc swapchain_desc; struct wined3d_swapchain *wined3d_swapchain; struct d3d8_swapchain *d3d_swapchain; + struct wined3d_caps caps; HRESULT hr;
static const enum wined3d_feature_level feature_levels[] = @@ -3702,6 +3706,9 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine return hr; }
+ wined3d_get_device_caps(wined3d, adapter, device_type, &caps); + device->vs_uniform_count = caps.MaxVertexShaderConst; + if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_PRIMARY, &device->state))) { ERR("Failed to create primary stateblock, hr %#x.\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/device.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 90dec4aaa7..c2112445d8 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2983,8 +2983,6 @@ static HRESULT WINAPI d3d8_device_SetVertexShaderConstant(IDirect3DDevice8 *ifac
wined3d_mutex_lock(); hr = wined3d_stateblock_set_vs_consts_f(device->update_state, start_register, count, data); - if (SUCCEEDED(hr) && !device->recording) - hr = wined3d_device_set_vs_consts_f(device->wined3d_device, start_register, count, data); wined3d_mutex_unlock();
return hr;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index c2112445d8..cf44fa2baa 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3240,7 +3240,7 @@ static HRESULT WINAPI d3d8_device_GetPixelShader(IDirect3DDevice8 *iface, DWORD return D3DERR_INVALIDCALL;
wined3d_mutex_lock(); - if ((object = wined3d_device_get_pixel_shader(device->wined3d_device))) + if ((object = wined3d_stateblock_get_state(device->state)->ps)) { struct d3d8_pixel_shader *d3d8_shader; d3d8_shader = wined3d_shader_get_parent(object); @@ -3273,7 +3273,7 @@ static HRESULT WINAPI d3d8_device_DeletePixelShader(IDirect3DDevice8 *iface, DWO return D3DERR_INVALIDCALL; }
- if (wined3d_device_get_pixel_shader(device->wined3d_device) == shader_impl->wined3d_shader) + if (wined3d_stateblock_get_state(device->state)->ps == shader_impl->wined3d_shader) IDirect3DDevice8_SetPixelShader(iface, 0);
wined3d_mutex_unlock();
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/device.c | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index cf44fa2baa..957f663174 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3207,8 +3207,6 @@ static HRESULT WINAPI d3d8_device_SetPixelShader(IDirect3DDevice8 *iface, DWORD if (!shader) { wined3d_stateblock_set_pixel_shader(device->update_state, NULL); - if (!device->recording) - wined3d_device_set_pixel_shader(device->wined3d_device, NULL); wined3d_mutex_unlock(); return D3D_OK; } @@ -3222,8 +3220,6 @@ static HRESULT WINAPI d3d8_device_SetPixelShader(IDirect3DDevice8 *iface, DWORD
TRACE("Setting shader %p.\n", shader_impl); wined3d_stateblock_set_pixel_shader(device->update_state, shader_impl->wined3d_shader); - if (!device->recording) - wined3d_device_set_pixel_shader(device->wined3d_device, shader_impl->wined3d_shader); wined3d_mutex_unlock();
return D3D_OK;
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=65585
Your paranoid android.
=== debian10 (32 bit Chinese:China report) ===
d3d8: device: Timeout
Report validation errors: d3d8:device has unaccounted for todo messages d3d8:device has unaccounted for skip messages d3d8:device has no done line (or it is garbled)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/device.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 957f663174..7dc2f7fbbc 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3298,19 +3298,22 @@ static HRESULT WINAPI d3d8_device_SetPixelShaderConstant(IDirect3DDevice8 *iface }
static HRESULT WINAPI d3d8_device_GetPixelShaderConstant(IDirect3DDevice8 *iface, - DWORD start_register, void *data, DWORD count) + DWORD start_idx, void *constants, DWORD count) { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; + const struct wined3d_vec4 *src;
- TRACE("iface %p, start_register %u, data %p, count %u.\n", - iface, start_register, data, count); + TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count); + + if (!constants || start_idx >= WINED3D_MAX_PS_CONSTS_F || start_idx + count > WINED3D_MAX_PS_CONSTS_F) + return WINED3DERR_INVALIDCALL;
wined3d_mutex_lock(); - hr = wined3d_device_get_ps_consts_f(device->wined3d_device, start_register, count, data); + src = wined3d_stateblock_get_state(device->state)->ps_consts_f; + memcpy(constants, &src[start_idx], count * sizeof(*src)); wined3d_mutex_unlock();
- return hr; + return D3D_OK; }
static HRESULT WINAPI d3d8_device_GetPixelShaderFunction(IDirect3DDevice8 *iface,
On Fri, 21 Feb 2020 at 05:57, Zebediah Figura z.figura12@gmail.com wrote:
- if (!constants || start_idx >= WINED3D_MAX_PS_CONSTS_F || start_idx + count > WINED3D_MAX_PS_CONSTS_F)
return WINED3DERR_INVALIDCALL;
"start_idx + count" can potentially overflow.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d8/device.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 7dc2f7fbbc..3f20045362 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3290,8 +3290,6 @@ static HRESULT WINAPI d3d8_device_SetPixelShaderConstant(IDirect3DDevice8 *iface
wined3d_mutex_lock(); hr = wined3d_stateblock_set_ps_consts_f(device->update_state, start_register, count, data); - if (SUCCEEDED(hr) && !device->recording) - hr = wined3d_device_set_ps_consts_f(device->wined3d_device, start_register, count, data); wined3d_mutex_unlock();
return hr;