ddraw: Store material handles in the global table.
This commit is contained in:
parent
2799c95dd2
commit
b9eb9a7453
4 changed files with 42 additions and 12 deletions
|
@ -303,14 +303,6 @@ static ULONG WINAPI d3d_device_inner_Release(IUnknown *iface)
|
|||
case DDRAW_HANDLE_FREE:
|
||||
break;
|
||||
|
||||
case DDRAW_HANDLE_MATERIAL:
|
||||
{
|
||||
struct d3d_material *m = entry->object;
|
||||
FIXME("Material handle %#lx (%p) not unset properly.\n", i + 1, m);
|
||||
m->Handle = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case DDRAW_HANDLE_MATRIX:
|
||||
{
|
||||
/* No FIXME here because this might happen because of sloppy applications. */
|
||||
|
@ -2936,7 +2928,7 @@ static HRESULT WINAPI d3d_device3_SetLightState(IDirect3DDevice3 *iface,
|
|||
{
|
||||
struct d3d_material *m;
|
||||
|
||||
if (!(m = ddraw_get_object(&device->handle_table, value - 1, DDRAW_HANDLE_MATERIAL)))
|
||||
if (!(m = ddraw_get_object(NULL, value - 1, DDRAW_HANDLE_MATERIAL)))
|
||||
{
|
||||
WARN("Invalid material handle.\n");
|
||||
wined3d_mutex_unlock();
|
||||
|
|
|
@ -37,6 +37,8 @@ static HINSTANCE instance;
|
|||
/* value of ForceRefreshRate */
|
||||
DWORD force_refresh_rate = 0;
|
||||
|
||||
static struct ddraw_handle_table global_handle_table;
|
||||
|
||||
/* Structure for converting DirectDrawEnumerateA to DirectDrawEnumerateExA */
|
||||
struct callback_info
|
||||
{
|
||||
|
@ -137,6 +139,9 @@ DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddr
|
|||
{
|
||||
struct ddraw_handle_entry *entry;
|
||||
|
||||
if (!t)
|
||||
t = &global_handle_table;
|
||||
|
||||
if (t->free_entries)
|
||||
{
|
||||
DWORD idx = t->free_entries - t->entries;
|
||||
|
@ -181,6 +186,9 @@ void *ddraw_free_handle(struct ddraw_handle_table *t, DWORD handle, enum ddraw_h
|
|||
struct ddraw_handle_entry *entry;
|
||||
void *object;
|
||||
|
||||
if (!t)
|
||||
t = &global_handle_table;
|
||||
|
||||
if (handle == DDRAW_INVALID_HANDLE || handle >= t->entry_count)
|
||||
{
|
||||
WARN("Invalid handle %#lx passed.\n", handle);
|
||||
|
@ -206,6 +214,9 @@ void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_ha
|
|||
{
|
||||
struct ddraw_handle_entry *entry;
|
||||
|
||||
if (!t)
|
||||
t = &global_handle_table;
|
||||
|
||||
if (handle == DDRAW_INVALID_HANDLE || handle >= t->entry_count)
|
||||
{
|
||||
WARN("Invalid handle %#lx passed.\n", handle);
|
||||
|
@ -815,6 +826,12 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!ddraw_handle_table_init(&global_handle_table, 64))
|
||||
{
|
||||
UnregisterClassA(DDRAW_WINDOW_CLASS_NAME, inst);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* On Windows one can force the refresh rate that DirectDraw uses by
|
||||
* setting an override value in dxdiag. This is documented in KB315614
|
||||
* (main article), KB230002, and KB217348. By comparing registry dumps
|
||||
|
@ -866,6 +883,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
|
|||
if (WARN_ON(ddraw))
|
||||
{
|
||||
struct ddraw *ddraw;
|
||||
unsigned int i;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(ddraw, &global_ddraw_list, struct ddraw, ddraw_list_entry)
|
||||
{
|
||||
|
@ -884,6 +902,26 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
|
|||
surface->ref2, surface->ref1, surface->gamma_count);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < global_handle_table.entry_count; ++i)
|
||||
{
|
||||
struct ddraw_handle_entry *entry = &global_handle_table.entries[i];
|
||||
|
||||
switch (entry->type)
|
||||
{
|
||||
case DDRAW_HANDLE_FREE:
|
||||
break;
|
||||
|
||||
case DDRAW_HANDLE_MATERIAL:
|
||||
WARN("Material handle %#x (%p) not unset properly.\n", i + 1, entry->object);
|
||||
break;
|
||||
|
||||
default:
|
||||
WARN("Handle %#x (%p) has unknown type %#x.\n", i + 1, entry->object, entry->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ddraw_handle_table_destroy(&global_handle_table);
|
||||
}
|
||||
|
||||
if (reserved) break;
|
||||
|
|
|
@ -143,7 +143,7 @@ static ULONG WINAPI d3d_material3_Release(IDirect3DMaterial3 *iface)
|
|||
if (material->Handle)
|
||||
{
|
||||
wined3d_mutex_lock();
|
||||
ddraw_free_handle(&material->ddraw->d3ddevice->handle_table, material->Handle - 1, DDRAW_HANDLE_MATERIAL);
|
||||
ddraw_free_handle(NULL, material->Handle - 1, DDRAW_HANDLE_MATERIAL);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ static HRESULT WINAPI d3d_material3_GetHandle(IDirect3DMaterial3 *iface,
|
|||
material->active_device = device_impl;
|
||||
if (!material->Handle)
|
||||
{
|
||||
DWORD h = ddraw_allocate_handle(&device_impl->handle_table, material, DDRAW_HANDLE_MATERIAL);
|
||||
DWORD h = ddraw_allocate_handle(NULL, material, DDRAW_HANDLE_MATERIAL);
|
||||
if (h == DDRAW_INVALID_HANDLE)
|
||||
{
|
||||
ERR("Failed to allocate a material handle.\n");
|
||||
|
|
|
@ -627,7 +627,7 @@ static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DM
|
|||
|
||||
wined3d_mutex_lock();
|
||||
|
||||
if (!(m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, material - 1, DDRAW_HANDLE_MATERIAL)))
|
||||
if (!(m = ddraw_get_object(NULL, material - 1, DDRAW_HANDLE_MATERIAL)))
|
||||
{
|
||||
WARN("Invalid material handle %#lx.\n", material);
|
||||
wined3d_mutex_unlock();
|
||||
|
|
Loading…
Add table
Reference in a new issue