Commit 09c4e23e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Introduce a separate structure for OpenGL device information.

parent 32e46a98
...@@ -1745,7 +1745,7 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC ...@@ -1745,7 +1745,7 @@ static int context_choose_pixel_format(const struct wined3d_device *device, HDC
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
void context_bind_dummy_textures(const struct wined3d_context *context) 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; const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int i; unsigned int i;
...@@ -2286,7 +2286,7 @@ BOOL wined3d_adapter_gl_create_context(struct wined3d_context *context, ...@@ -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 /* 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 * are not created yet. In that case, they will be created (and bound) by
* create_dummy_textures right after this context is initialized. */ * 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); context_bind_dummy_textures(context);
/* Initialise all rectangles to avoid resetting unused ones later. */ /* 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 ...@@ -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) 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; const struct wined3d_gl_info *gl_info = context->gl_info;
DWORD unit = context->active_texture; DWORD unit = context->active_texture;
DWORD old_texture_type = context->texture_type[unit]; DWORD old_texture_type = context->texture_type[unit];
......
...@@ -523,7 +523,7 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device) ...@@ -523,7 +523,7 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
wined3d_decref(device->wined3d); wined3d_decref(device->wined3d);
device->wined3d = NULL; device->wined3d = NULL;
heap_free(device); heap_free(wined3d_device_gl(device));
TRACE("Freed device %p.\n", device); TRACE("Freed device %p.\n", device);
} }
...@@ -610,7 +610,7 @@ out: ...@@ -610,7 +610,7 @@ out:
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void create_dummy_textures(struct wined3d_device *device, struct wined3d_context *context) 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_d3d_info *d3d_info = context->d3d_info;
const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int i; unsigned int i;
...@@ -744,7 +744,7 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_ ...@@ -744,7 +744,7 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d_context *context) 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; const struct wined3d_gl_info *gl_info = context->gl_info;
if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE]) if (gl_info->supported[ARB_TEXTURE_MULTISAMPLE])
......
...@@ -2419,7 +2419,7 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, unsigned int adapte ...@@ -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, 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_parent *device_parent, struct wined3d_device **device)
{ {
struct wined3d_device *object; struct wined3d_device_gl *device_gl;
HRESULT hr; HRESULT hr;
TRACE("wined3d %p, adapter_idx %u, device_type %#x, focus_window %p, flags %#x, " 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 ...@@ -2430,20 +2430,20 @@ HRESULT CDECL wined3d_device_create(struct wined3d *wined3d, unsigned int adapte
if (adapter_idx >= wined3d->adapter_count) if (adapter_idx >= wined3d->adapter_count)
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
if (!(object = heap_alloc_zero(sizeof(*object)))) if (!(device_gl = heap_alloc_zero(sizeof(*device_gl))))
return E_OUTOFMEMORY; 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, device_type, focus_window, flags, surface_alignment,
feature_levels, feature_level_count, device_parent))) feature_levels, feature_level_count, device_parent)))
{ {
WARN("Failed to initialize device, hr %#x.\n", hr); WARN("Failed to initialize device, hr %#x.\n", hr);
heap_free(object); heap_free(device_gl);
return hr; return hr;
} }
TRACE("Created device %p.\n", object); TRACE("Created device %p.\n", device_gl);
*device = object; *device = &device_gl->d;
device_parent->ops->wined3d_device_created(device_parent, *device); device_parent->ops->wined3d_device_created(device_parent, *device);
......
...@@ -3029,9 +3029,6 @@ struct wined3d_device ...@@ -3029,9 +3029,6 @@ struct wined3d_device
/* The Wine logo texture */ /* The Wine logo texture */
struct wined3d_texture *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 */ /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
struct wined3d_sampler *default_sampler; struct wined3d_sampler *default_sampler;
struct wined3d_sampler *null_sampler; struct wined3d_sampler *null_sampler;
...@@ -3059,6 +3056,19 @@ void device_resource_add(struct wined3d_device *device, struct wined3d_resource ...@@ -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_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; 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) static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
{ {
DWORD idx = state / (sizeof(*context->isStateDirty) * CHAR_BIT); DWORD idx = state / (sizeof(*context->isStateDirty) * CHAR_BIT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment