Henri Verbeet : wined3d: Introduce a separate structure for OpenGL device information.
Alexandre Julliard
julliard at winehq.org
Fri Oct 26 14:23:56 CDT 2018
Module: wine
Branch: master
Commit: 09c4e23ed558599b25d1d599d4360d2c878f809a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=09c4e23ed558599b25d1d599d4360d2c878f809a
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Fri Oct 26 17:01:06 2018 +0330
wined3d: Introduce a separate structure for OpenGL device information.
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/context.c | 6 +++---
dlls/wined3d/device.c | 6 +++---
dlls/wined3d/directx.c | 12 ++++++------
dlls/wined3d/wined3d_private.h | 16 +++++++++++++---
4 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 3d1a483..800634e 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -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];
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 17ef5d9..8b202fc 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -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])
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index f4aabb5..e65db79 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -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);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 88dce65..3abe5e6 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -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);
More information about the wine-cvs
mailing list