=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Add support for variable-sized format structures.
Alexandre Julliard
julliard at winehq.org
Thu Sep 20 13:45:34 CDT 2018
Module: wine
Branch: master
Commit: ff6d7de8cad0cd7eb3812b1027619f641e10d0b3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ff6d7de8cad0cd7eb3812b1027619f641e10d0b3
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Thu Sep 20 09:02:00 2018 +0200
wined3d: Add support for variable-sized format structures.
In order to move GL-specific fields into their own structure.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/directx.c | 2 +-
dlls/wined3d/utils.c | 28 +++++++++++++++-------------
dlls/wined3d/wined3d_private.h | 5 +++--
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 345e7b7..8968447 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -2490,7 +2490,7 @@ static BOOL wined3d_adapter_no3d_init(struct wined3d_adapter *adapter)
adapter->vram_bytes_used = 0;
TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes));
- if (!wined3d_adapter_init_format_info(adapter))
+ if (!wined3d_adapter_init_format_info(adapter, sizeof(struct wined3d_format)))
return FALSE;
adapter->vertex_pipe = &none_vertex_pipe;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 4f9fc13..9627b13 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1927,7 +1927,7 @@ static inline int get_format_idx(enum wined3d_format_id format_id)
static struct wined3d_format *get_format_by_idx(const struct wined3d_adapter *adapter, int fmt_idx)
{
- return &adapter->formats[fmt_idx];
+ return (struct wined3d_format *)((BYTE *)adapter->formats + fmt_idx * adapter->format_size);
}
static struct wined3d_format *get_format_internal(const struct wined3d_adapter *adapter,
@@ -1944,10 +1944,11 @@ static struct wined3d_format *get_format_internal(const struct wined3d_adapter *
return get_format_by_idx(adapter, fmt_idx);
}
-static void copy_format(struct wined3d_format *dst_format, const struct wined3d_format *src_format)
+static void copy_format(const struct wined3d_adapter *adapter,
+ struct wined3d_format *dst_format, const struct wined3d_format *src_format)
{
enum wined3d_format_id id = dst_format->id;
- *dst_format = *src_format;
+ memcpy(dst_format, src_format, adapter->format_size);
dst_format->id = id;
}
@@ -1993,13 +1994,14 @@ static enum wined3d_channel_type map_channel_type(char t)
}
}
-static BOOL init_format_base_info(struct wined3d_adapter *adapter)
+static BOOL init_format_base_info(struct wined3d_adapter *adapter, size_t format_size)
{
struct wined3d_format *format;
unsigned int i, j;
+ adapter->format_size = format_size;
if (!(adapter->formats = heap_calloc(WINED3D_FORMAT_COUNT
- + ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*adapter->formats))))
+ + ARRAY_SIZE(typeless_depth_stencil_formats), adapter->format_size)))
{
ERR("Failed to allocate memory.\n");
return FALSE;
@@ -3198,7 +3200,7 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
if (!srgb_format)
continue;
- copy_format(srgb_format, format);
+ copy_format(adapter, srgb_format, format);
if (gl_info->supported[EXT_TEXTURE_SRGB]
&& !(adapter->d3d_info.wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
@@ -3716,7 +3718,7 @@ static BOOL init_typeless_formats(const struct wined3d_adapter *adapter)
return FALSE;
memcpy(flags, typeless_format->flags, sizeof(flags));
- copy_format(typeless_format, format);
+ copy_format(adapter, typeless_format, format);
for (j = 0; j < ARRAY_SIZE(typeless_format->flags); ++j)
typeless_format->flags[j] |= flags[j];
}
@@ -3734,7 +3736,7 @@ static BOOL init_typeless_formats(const struct wined3d_adapter *adapter)
typeless_ds_format = get_format_by_idx(adapter, WINED3D_FORMAT_COUNT + i);
typeless_ds_format->id = typeless_depth_stencil_formats[i].typeless_id;
- copy_format(typeless_ds_format, ds_format);
+ copy_format(adapter, typeless_ds_format, ds_format);
for (j = 0; j < ARRAY_SIZE(typeless_ds_format->flags); ++j)
{
typeless_ds_format->flags[j] = typeless_format->flags[j];
@@ -3746,13 +3748,13 @@ static BOOL init_typeless_formats(const struct wined3d_adapter *adapter)
{
if (!(depth_view_format = get_format_internal(adapter, format_id)))
return FALSE;
- copy_format(depth_view_format, ds_format);
+ copy_format(adapter, depth_view_format, ds_format);
}
if ((format_id = typeless_depth_stencil_formats[i].stencil_view_id))
{
if (!(stencil_view_format = get_format_internal(adapter, format_id)))
return FALSE;
- copy_format(stencil_view_format, ds_format);
+ copy_format(adapter, stencil_view_format, ds_format);
}
}
@@ -3947,9 +3949,9 @@ static void init_format_depth_bias_scale(struct wined3d_adapter *adapter,
}
}
-BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter)
+BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, size_t format_size)
{
- if (!init_format_base_info(adapter)) return FALSE;
+ if (!init_format_base_info(adapter, format_size)) return FALSE;
if (!init_format_block_info(adapter)) goto fail;
if (!init_format_decompress_info(adapter)) goto fail;
@@ -3966,7 +3968,7 @@ BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter, struct
{
struct wined3d_gl_info *gl_info = &adapter->gl_info;
- if (!wined3d_adapter_init_format_info(adapter))
+ if (!wined3d_adapter_init_format_info(adapter, sizeof(struct wined3d_format)))
return FALSE;
if (!init_format_texture_info(adapter, gl_info)) goto fail;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index d8d5b04..a501da1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2667,7 +2667,8 @@ struct wined3d_adapter
UINT64 vram_bytes_used;
LUID luid;
- struct wined3d_format *formats;
+ void *formats;
+ size_t format_size;
const struct wined3d_vertex_pipe_ops *vertex_pipe;
const struct fragment_pipeline *fragment_pipe;
@@ -2690,7 +2691,7 @@ struct wined3d_caps_gl_ctx
GLuint test_program_id;
};
-BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
+BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, size_t format_size) DECLSPEC_HIDDEN;
BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter,
struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list