[PATCH] wined3d: Decrement reference count and take the lock atomically for cached objects.