Commit ff6d7de8 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Add support for variable-sized format structures.

In order to move GL-specific fields into their own structure. Signed-off-by: 's avatarJózef Kucia <jkucia@codeweavers.com> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 6a38579d
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
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