wined3d: Introduce a separate structure for OpenGL device information.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-10-26 16:43:06 +03:30 committed by Alexandre Julliard
parent 32e46a9805
commit 09c4e23ed5
4 changed files with 25 additions and 15 deletions

View File

@ -1745,7 +1745,7 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC
/* Context activation is done by the caller. */
void context_bind_dummy_textures(const struct wined3d_context *context)
{
const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
const struct wined3d_dummy_textures *textures = &wined3d_device_gl(context->device)->dummy_textures;
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int i;
@ -2286,7 +2286,7 @@ BOOL wined3d_adapter_gl_create_context(struct wined3d_context *context,
/* If this happens to be the first context for the device, dummy textures
* are not created yet. In that case, they will be created (and bound) by
* create_dummy_textures right after this context is initialized. */
if (device->dummy_textures.tex_2d)
if (wined3d_device_gl(device)->dummy_textures.tex_2d)
context_bind_dummy_textures(context);
/* Initialise all rectangles to avoid resetting unused ones later. */
@ -2520,7 +2520,7 @@ void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint nam
void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name)
{
const struct wined3d_dummy_textures *textures = &context->device->dummy_textures;
const struct wined3d_dummy_textures *textures = &wined3d_device_gl(context->device)->dummy_textures;
const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD unit = context->active_texture;
DWORD old_texture_type = context->texture_type[unit];

View File

@ -523,7 +523,7 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
wined3d_decref(device->wined3d);
device->wined3d = NULL;
heap_free(device);
heap_free(wined3d_device_gl(device));
TRACE("Freed device %p.\n", device);
}
@ -610,7 +610,7 @@ out:
/* Context activation is done by the caller. */
static void create_dummy_textures(struct wined3d_device *device, struct wined3d_context *context)
{
struct wined3d_dummy_textures *textures = &device->dummy_textures;
struct wined3d_dummy_textures *textures = &wined3d_device_gl(device)->dummy_textures;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int i;
@ -744,7 +744,7 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
/* Context activation is done by the caller. */
static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d_context *context)
{
struct wined3d_dummy_textures *dummy_textures = &device->dummy_textures;
struct wined3d_dummy_textures *dummy_textures = &wined3d_device_gl(device)->dummy_textures;
const struct wined3d_gl_info *gl_info = context->gl_info;
if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE])

View File

@ -2419,7 +2419,7 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, unsigned int adapte
const enum wined3d_feature_level *feature_levels, unsigned int feature_level_count,
struct wined3d_device_parent *device_parent, struct wined3d_device **device)
{
struct wined3d_device *object;
struct wined3d_device_gl *device_gl;
HRESULT hr;
TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, "
@ -2430,20 +2430,20 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, unsigned int adapte
if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL;
if (!(object = heap_alloc_zero(sizeof(*object))))
if (!(device_gl = heap_alloc_zero(sizeof(*device_gl))))
return E_OUTOFMEMORY;
if (FAILED(hr = device_init(object, wined3d, adapter_idx,
if (FAILED(hr = device_init(&device_gl->d, wined3d, adapter_idx,
device_type, focus_window, flags, surface_alignment,
feature_levels, feature_level_count, device_parent)))
{
WARN("Failed to initialize device, hr %#x.\n", hr);
heap_free(object);
heap_free(device_gl);
return hr;
}
TRACE("Created device %p.\n", object);
*device = object;
TRACE("Created device %p.\n", device_gl);
*device = &device_gl->d;
device_parent->ops->wined3d_device_created(device_parent, *device);

View File

@ -3029,9 +3029,6 @@ struct wined3d_device
/* The Wine logo texture */
struct wined3d_texture *logo_texture;
/* Textures for when no other textures are mapped */
struct wined3d_dummy_textures dummy_textures;
/* Default sampler used to emulate the direct resource access without using wined3d_sampler */
struct wined3d_sampler *default_sampler;
struct wined3d_sampler *null_sampler;
@ -3059,6 +3056,19 @@ void device_resource_add(struct wined3d_device *device, struct wined3d_resource
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
struct wined3d_device_gl
{
struct wined3d_device d;
/* Textures for when no other textures are bound. */
struct wined3d_dummy_textures dummy_textures;
};
static inline struct wined3d_device_gl *wined3d_device_gl(struct wined3d_device *device)
{
return CONTAINING_RECORD(device, struct wined3d_device_gl, d);
}
static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
{
DWORD idx = state / (sizeof(*context->isStateDirty) * CHAR_BIT);