wined3d: Move formats from gl_info to wined3d_adapter.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-08-30 14:54:49 +02:00 committed by Alexandre Julliard
parent 25c3d9938a
commit 5080d3c1c1
4 changed files with 127 additions and 121 deletions

View File

@ -73,7 +73,7 @@ UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount)
static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) static void wined3d_adapter_cleanup(struct wined3d_adapter *adapter)
{ {
heap_free(adapter->gl_info.formats); heap_free(adapter->formats);
heap_free(adapter->cfgs); heap_free(adapter->cfgs);
} }
@ -2512,6 +2512,9 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int o
TRACE("Allocated LUID %08x:%08x for adapter %p.\n", TRACE("Allocated LUID %08x:%08x for adapter %p.\n",
adapter->luid.HighPart, adapter->luid.LowPart, adapter); adapter->luid.HighPart, adapter->luid.LowPart, adapter);
adapter->formats = NULL;
adapter->format_count = 0;
if (wined3d_creation_flags & WINED3D_NO3D) if (wined3d_creation_flags & WINED3D_NO3D)
return wined3d_adapter_no3d_init(adapter); return wined3d_adapter_no3d_init(adapter);
return wined3d_adapter_opengl_init(adapter, wined3d_creation_flags); return wined3d_adapter_opengl_init(adapter, wined3d_creation_flags);

View File

@ -2656,7 +2656,6 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D && !gl_info->supported[ARB_TEXTURE_RECTANGLE] if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D && !gl_info->supported[ARB_TEXTURE_RECTANGLE]
&& !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT]) && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
{ {
/* TODO: Add support for non-power-of-two compressed textures. */ /* TODO: Add support for non-power-of-two compressed textures. */
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
& (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_HEIGHT_SCALE)) & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_HEIGHT_SCALE))

View File

@ -1936,7 +1936,7 @@ static inline int get_format_idx(enum wined3d_format_id format_id)
return -1; return -1;
} }
static struct wined3d_format *get_format_internal(struct wined3d_gl_info *gl_info, static struct wined3d_format *get_format_internal(const struct wined3d_adapter *adapter,
enum wined3d_format_id format_id) enum wined3d_format_id format_id)
{ {
int fmt_idx; int fmt_idx;
@ -1947,7 +1947,7 @@ static struct wined3d_format *get_format_internal(struct wined3d_gl_info *gl_inf
return NULL; return NULL;
} }
return &gl_info->formats[fmt_idx]; return &adapter->formats[fmt_idx];
} }
static void copy_format(struct wined3d_format *dst_format, const struct wined3d_format *src_format) static void copy_format(struct wined3d_format *dst_format, const struct wined3d_format *src_format)
@ -1999,14 +1999,14 @@ static enum wined3d_channel_type map_channel_type(char t)
} }
} }
static BOOL init_format_base_info(struct wined3d_gl_info *gl_info) static BOOL init_format_base_info(struct wined3d_adapter *adapter)
{ {
struct wined3d_format *format; struct wined3d_format *format;
unsigned int i, j; unsigned int i, j;
gl_info->format_count = WINED3D_FORMAT_COUNT; adapter->format_count = WINED3D_FORMAT_COUNT;
if (!(gl_info->formats = heap_calloc(gl_info->format_count if (!(adapter->formats = heap_calloc(adapter->format_count
+ ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*gl_info->formats)))) + ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*adapter->formats))))
{ {
ERR("Failed to allocate memory.\n"); ERR("Failed to allocate memory.\n");
return FALSE; return FALSE;
@ -2014,7 +2014,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
for (i = 0; i < ARRAY_SIZE(formats); ++i) for (i = 0; i < ARRAY_SIZE(formats); ++i)
{ {
if (!(format = get_format_internal(gl_info, formats[i].id))) if (!(format = get_format_internal(adapter, formats[i].id)))
goto fail; goto fail;
format->id = formats[i].id; format->id = formats[i].id;
@ -2039,10 +2039,10 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
const struct wined3d_format *typeless_format; const struct wined3d_format *typeless_format;
DWORD flags = 0; DWORD flags = 0;
if (!(format = get_format_internal(gl_info, typed_formats[i].id))) if (!(format = get_format_internal(adapter, typed_formats[i].id)))
goto fail; goto fail;
if (!(typeless_format = get_format_internal(gl_info, typed_formats[i].typeless_id))) if (!(typeless_format = get_format_internal(adapter, typed_formats[i].typeless_id)))
goto fail; goto fail;
format->id = typed_formats[i].id; format->id = typed_formats[i].id;
@ -2082,7 +2082,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
for (i = 0; i < ARRAY_SIZE(ddi_formats); ++i) for (i = 0; i < ARRAY_SIZE(ddi_formats); ++i)
{ {
if (!(format = get_format_internal(gl_info, ddi_formats[i].id))) if (!(format = get_format_internal(adapter, ddi_formats[i].id)))
goto fail; goto fail;
format->ddi_format = ddi_formats[i].ddi_format; format->ddi_format = ddi_formats[i].ddi_format;
@ -2090,7 +2090,7 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
for (i = 0; i < ARRAY_SIZE(format_base_flags); ++i) for (i = 0; i < ARRAY_SIZE(format_base_flags); ++i)
{ {
if (!(format = get_format_internal(gl_info, format_base_flags[i].id))) if (!(format = get_format_internal(adapter, format_base_flags[i].id)))
goto fail; goto fail;
format_set_flag(format, format_base_flags[i].flags); format_set_flag(format, format_base_flags[i].flags);
@ -2099,18 +2099,18 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
return TRUE; return TRUE;
fail: fail:
heap_free(gl_info->formats); heap_free(adapter->formats);
return FALSE; return FALSE;
} }
static BOOL init_format_block_info(struct wined3d_gl_info *gl_info) static BOOL init_format_block_info(struct wined3d_adapter *adapter)
{ {
struct wined3d_format *format; struct wined3d_format *format;
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_block_info); ++i) for (i = 0; i < ARRAY_SIZE(format_block_info); ++i)
{ {
if (!(format = get_format_internal(gl_info, format_block_info[i].id))) if (!(format = get_format_internal(adapter, format_block_info[i].id)))
return FALSE; return FALSE;
format->block_width = format_block_info[i].block_width; format->block_width = format_block_info[i].block_width;
@ -2135,14 +2135,14 @@ static BOOL init_format_block_info(struct wined3d_gl_info *gl_info)
* *
* Affected applications include "Heroes VI", "From Dust", "Halo Online" and * Affected applications include "Heroes VI", "From Dust", "Halo Online" and
* "Eldorado". */ * "Eldorado". */
static BOOL init_format_decompress_info(struct wined3d_gl_info *gl_info) static BOOL init_format_decompress_info(struct wined3d_adapter *adapter)
{ {
struct wined3d_format *format; struct wined3d_format *format;
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_decompress_info); ++i) for (i = 0; i < ARRAY_SIZE(format_decompress_info); ++i)
{ {
if (!(format = get_format_internal(gl_info, format_decompress_info[i].id))) if (!(format = get_format_internal(adapter, format_decompress_info[i].id)))
return FALSE; return FALSE;
format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= WINED3DFMT_FLAG_DECOMPRESS; format->flags[WINED3D_GL_RES_TYPE_TEX_3D] |= WINED3DFMT_FLAG_DECOMPRESS;
@ -2723,7 +2723,8 @@ static void query_format_flag(struct wined3d_gl_info *gl_info, struct wined3d_fo
} }
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx) static void init_format_fbo_compat_info(const struct wined3d_adapter *adapter,
struct wined3d_caps_gl_ctx *ctx)
{ {
const struct wined3d_gl_info *gl_info = ctx->gl_info; const struct wined3d_gl_info *gl_info = ctx->gl_info;
unsigned int i, type; unsigned int i, type;
@ -2731,12 +2732,12 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2]) if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
{ {
for (i = 0; i < gl_info->format_count; ++i) for (i = 0; i < adapter->format_count; ++i)
{ {
GLint value;
struct wined3d_format *format = &gl_info->formats[i];
BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE; BOOL fallback_fmt_used = FALSE, regular_fmt_used = FALSE;
struct wined3d_format *format = &adapter->formats[i];
GLenum rt_internal = format->rtInternal; GLenum rt_internal = format->rtInternal;
GLint value;
if (!format->glInternal) if (!format->glInternal)
continue; continue;
@ -2845,9 +2846,9 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
gl_info->gl_ops.gl.p_glReadBuffer(GL_COLOR_ATTACHMENT0); gl_info->gl_ops.gl.p_glReadBuffer(GL_COLOR_ATTACHMENT0);
} }
for (i = 0; i < gl_info->format_count; ++i) for (i = 0; i < adapter->format_count; ++i)
{ {
struct wined3d_format *format = &gl_info->formats[i]; struct wined3d_format *format = &adapter->formats[i];
if (!format->glInternal) continue; if (!format->glInternal) continue;
@ -3125,7 +3126,7 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
for (i = 0; i < ARRAY_SIZE(format_texture_info); ++i) for (i = 0; i < ARRAY_SIZE(format_texture_info); ++i)
{ {
if (!(format = get_format_internal(gl_info, format_texture_info[i].id))) if (!(format = get_format_internal(adapter, format_texture_info[i].id)))
return FALSE; return FALSE;
if (!gl_info->supported[format_texture_info[i].extension]) if (!gl_info->supported[format_texture_info[i].extension])
@ -3189,7 +3190,7 @@ static BOOL init_format_texture_info(struct wined3d_adapter *adapter, struct win
{ {
if (format_srgb_info[j].base_format_id == format->id) if (format_srgb_info[j].base_format_id == format->id)
{ {
if (!(srgb_format = get_format_internal(gl_info, format_srgb_info[j].srgb_format_id))) if (!(srgb_format = get_format_internal(adapter, format_srgb_info[j].srgb_format_id)))
return FALSE; return FALSE;
break; break;
} }
@ -3324,8 +3325,10 @@ static BOOL check_filter(const struct wined3d_gl_info *gl_info, GLenum internal)
return ret; return ret;
} }
static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor) static void init_format_filter_info(struct wined3d_adapter *adapter,
struct wined3d_gl_info *gl_info)
{ {
enum wined3d_pci_vendor vendor = adapter->driver_info.vendor;
struct wined3d_format *format; struct wined3d_format *format;
unsigned int fmt_idx, i; unsigned int fmt_idx, i;
static const enum wined3d_format_id fmts16[] = static const enum wined3d_format_id fmts16[] =
@ -3365,7 +3368,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3
for (i = 0; i < ARRAY_SIZE(fmts16); ++i) for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{ {
fmt_idx = get_format_idx(fmts16[i]); fmt_idx = get_format_idx(fmts16[i]);
format_set_flag(&gl_info->formats[fmt_idx], WINED3DFMT_FLAG_FILTERING); format_set_flag(&adapter->formats[fmt_idx], WINED3DFMT_FLAG_FILTERING);
} }
} }
return; return;
@ -3374,10 +3377,10 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3
for (i = 0; i < ARRAY_SIZE(fmts16); ++i) for (i = 0; i < ARRAY_SIZE(fmts16); ++i)
{ {
fmt_idx = get_format_idx(fmts16[i]); fmt_idx = get_format_idx(fmts16[i]);
format = &gl_info->formats[fmt_idx]; format = &adapter->formats[fmt_idx];
if (!format->glInternal) continue; /* Not supported by GL */ if (!format->glInternal) continue; /* Not supported by GL */
filtered = check_filter(gl_info, gl_info->formats[fmt_idx].glInternal); filtered = check_filter(gl_info, adapter->formats[fmt_idx].glInternal);
if (filtered) if (filtered)
{ {
TRACE("Format %s supports filtering\n", debug_d3dformat(fmts16[i])); TRACE("Format %s supports filtering\n", debug_d3dformat(fmts16[i]));
@ -3396,23 +3399,23 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
int idx; int idx;
idx = get_format_idx(WINED3DFMT_R16_FLOAT); idx = get_format_idx(WINED3DFMT_R16_FLOAT);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R32_FLOAT); idx = get_format_idx(WINED3DFMT_R32_FLOAT);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R16G16_UNORM); idx = get_format_idx(WINED3DFMT_R16G16_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R16G16_FLOAT); idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R32G32_FLOAT); idx = get_format_idx(WINED3DFMT_R32G32_FLOAT);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
/* GL_ATI_envmap_bumpmap in theory supports R8G8_SNORM but is no longer supported by /* GL_ATI_envmap_bumpmap in theory supports R8G8_SNORM but is no longer supported by
@ -3423,10 +3426,10 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
* returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader * returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
* conversion for this format. */ * conversion for this format. */
idx = get_format_idx(WINED3DFMT_R8G8_SNORM); idx = get_format_idx(WINED3DFMT_R8G8_SNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_R16G16_SNORM); idx = get_format_idx(WINED3DFMT_R16G16_SNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} }
else else
@ -3434,40 +3437,40 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* Emulate using unsigned formats. This requires load-time conversion in addition to the /* Emulate using unsigned formats. This requires load-time conversion in addition to the
* fixups here. */ * fixups here. */
idx = get_format_idx(WINED3DFMT_R8G8_SNORM); idx = get_format_idx(WINED3DFMT_R8G8_SNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); 1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_R16G16_SNORM); idx = get_format_idx(WINED3DFMT_R16G16_SNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); 1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_R8G8B8A8_SNORM); idx = get_format_idx(WINED3DFMT_R8G8B8A8_SNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 1, CHANNEL_SOURCE_Z, 1, CHANNEL_SOURCE_W); 1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 1, CHANNEL_SOURCE_Z, 1, CHANNEL_SOURCE_W);
idx = get_format_idx(WINED3DFMT_R5G5_SNORM_L6_UNORM); idx = get_format_idx(WINED3DFMT_R5G5_SNORM_L6_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE); 1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE);
} }
if (!gl_info->supported[NV_TEXTURE_SHADER]) if (!gl_info->supported[NV_TEXTURE_SHADER])
{ {
idx = get_format_idx(WINED3DFMT_R8G8_SNORM_L8X8_UNORM); idx = get_format_idx(WINED3DFMT_R8G8_SNORM_L8X8_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W); 1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W);
} }
if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC]) if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
{ {
idx = get_format_idx(WINED3DFMT_ATI1N); idx = get_format_idx(WINED3DFMT_ATI1N);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X);
idx = get_format_idx(WINED3DFMT_ATI2N); idx = get_format_idx(WINED3DFMT_ATI2N);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} }
else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC]) else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC])
{ {
idx = get_format_idx(WINED3DFMT_ATI2N); idx = get_format_idx(WINED3DFMT_ATI2N);
gl_info->formats[idx].color_fixup= create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} }
@ -3475,81 +3478,81 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))) || (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER])))
{ {
idx = get_format_idx(WINED3DFMT_YUY2); idx = get_format_idx(WINED3DFMT_YUY2);
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2); adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YUY2);
idx = get_format_idx(WINED3DFMT_UYVY); idx = get_format_idx(WINED3DFMT_UYVY);
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY); adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_UYVY);
} }
else if (!gl_info->supported[APPLE_YCBCR_422] && (!gl_info->supported[ARB_FRAGMENT_PROGRAM] else if (!gl_info->supported[APPLE_YCBCR_422] && (!gl_info->supported[ARB_FRAGMENT_PROGRAM]
&& (!gl_info->supported[ARB_FRAGMENT_SHADER] || !gl_info->supported[ARB_VERTEX_SHADER]))) && (!gl_info->supported[ARB_FRAGMENT_SHADER] || !gl_info->supported[ARB_VERTEX_SHADER])))
{ {
idx = get_format_idx(WINED3DFMT_YUY2); idx = get_format_idx(WINED3DFMT_YUY2);
gl_info->formats[idx].glInternal = 0; adapter->formats[idx].glInternal = 0;
idx = get_format_idx(WINED3DFMT_UYVY); idx = get_format_idx(WINED3DFMT_UYVY);
gl_info->formats[idx].glInternal = 0; adapter->formats[idx].glInternal = 0;
} }
if (gl_info->supported[ARB_FRAGMENT_PROGRAM] if (gl_info->supported[ARB_FRAGMENT_PROGRAM]
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER])) || (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))
{ {
idx = get_format_idx(WINED3DFMT_YV12); idx = get_format_idx(WINED3DFMT_YV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE); format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3; adapter->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2; adapter->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12); adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
idx = get_format_idx(WINED3DFMT_NV12); idx = get_format_idx(WINED3DFMT_NV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE); format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3; adapter->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2; adapter->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12); adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
} }
else else
{ {
idx = get_format_idx(WINED3DFMT_YV12); idx = get_format_idx(WINED3DFMT_YV12);
gl_info->formats[idx].glInternal = 0; adapter->formats[idx].glInternal = 0;
idx = get_format_idx(WINED3DFMT_NV12); idx = get_format_idx(WINED3DFMT_NV12);
gl_info->formats[idx].glInternal = 0; adapter->formats[idx].glInternal = 0;
} }
if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT])
{ {
idx = get_format_idx(WINED3DFMT_A8_UNORM); idx = get_format_idx(WINED3DFMT_A8_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_X); 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_ZERO, 0, CHANNEL_SOURCE_X);
idx = get_format_idx(WINED3DFMT_L8A8_UNORM); idx = get_format_idx(WINED3DFMT_L8A8_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y);
idx = get_format_idx(WINED3DFMT_L4A4_UNORM); idx = get_format_idx(WINED3DFMT_L4A4_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y);
idx = get_format_idx(WINED3DFMT_L16_UNORM); idx = get_format_idx(WINED3DFMT_L16_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE);
idx = get_format_idx(WINED3DFMT_INTZ); idx = get_format_idx(WINED3DFMT_INTZ);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X);
} }
if (gl_info->supported[ARB_TEXTURE_RG]) if (gl_info->supported[ARB_TEXTURE_RG])
{ {
idx = get_format_idx(WINED3DFMT_L8_UNORM); idx = get_format_idx(WINED3DFMT_L8_UNORM);
gl_info->formats[idx].color_fixup = create_color_fixup_desc( adapter->formats[idx].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE); 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE);
} }
if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER]) if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
{ {
idx = get_format_idx(WINED3DFMT_P8_UINT); idx = get_format_idx(WINED3DFMT_P8_UINT);
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8); adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_P8);
} }
if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA]) if (gl_info->supported[ARB_VERTEX_ARRAY_BGRA])
{ {
idx = get_format_idx(WINED3DFMT_B8G8R8A8_UNORM); idx = get_format_idx(WINED3DFMT_B8G8R8A8_UNORM);
gl_info->formats[idx].gl_vtx_format = GL_BGRA; adapter->formats[idx].gl_vtx_format = GL_BGRA;
} }
if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX]) if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX])
@ -3557,28 +3560,28 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though. /* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though.
* It is the job of the vertex buffer code to make sure that the vbos have the right format */ * It is the job of the vertex buffer code to make sure that the vbos have the right format */
idx = get_format_idx(WINED3DFMT_R16G16_FLOAT); idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
gl_info->formats[idx].gl_vtx_type = GL_FLOAT; adapter->formats[idx].gl_vtx_type = GL_FLOAT;
idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT); idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT);
gl_info->formats[idx].gl_vtx_type = GL_FLOAT; adapter->formats[idx].gl_vtx_type = GL_FLOAT;
} }
if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL]) if (!gl_info->supported[ARB_HALF_FLOAT_PIXEL])
{ {
idx = get_format_idx(WINED3DFMT_R16_FLOAT); idx = get_format_idx(WINED3DFMT_R16_FLOAT);
format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE); format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
idx = get_format_idx(WINED3DFMT_R16G16_FLOAT); idx = get_format_idx(WINED3DFMT_R16G16_FLOAT);
format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE); format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT); idx = get_format_idx(WINED3DFMT_R16G16B16A16_FLOAT);
format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE); format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
} }
if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16) if (gl_info->quirks & WINED3D_QUIRK_BROKEN_RGBA16)
{ {
idx = get_format_idx(WINED3DFMT_R16G16B16A16_UNORM); idx = get_format_idx(WINED3DFMT_R16G16B16A16_UNORM);
format_clear_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE); format_clear_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
} }
/* ATI instancing hack: Although ATI cards do not support Shader Model /* ATI instancing hack: Although ATI cards do not support Shader Model
@ -3597,7 +3600,7 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER]) if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER])
{ {
idx = get_format_idx(WINED3DFMT_INST); idx = get_format_idx(WINED3DFMT_INST);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE); format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
} }
/* Depth bound test. To query if the card supports it CheckDeviceFormat() /* Depth bound test. To query if the card supports it CheckDeviceFormat()
@ -3609,7 +3612,7 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST]) if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
{ {
idx = get_format_idx(WINED3DFMT_NVDB); idx = get_format_idx(WINED3DFMT_NVDB);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE); format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE);
} }
/* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ /* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
@ -3618,12 +3621,12 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]) if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
{ {
idx = get_format_idx(WINED3DFMT_RESZ); idx = get_format_idx(WINED3DFMT_RESZ);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET); format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
} }
for (i = 0; i < gl_info->format_count; ++i) for (i = 0; i < adapter->format_count; ++i)
{ {
struct wined3d_format *format = &gl_info->formats[i]; struct wined3d_format *format = &adapter->formats[i];
if (!(format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_TEXTURE)) if (!(format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_TEXTURE))
continue; continue;
@ -3648,17 +3651,17 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
/* These formats are not supported for 3D textures. See also /* These formats are not supported for 3D textures. See also
* WINED3DFMT_FLAG_DECOMPRESS. */ * WINED3DFMT_FLAG_DECOMPRESS. */
idx = get_format_idx(WINED3DFMT_ATI1N); idx = get_format_idx(WINED3DFMT_ATI1N);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_ATI2N); idx = get_format_idx(WINED3DFMT_ATI2N);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC4_UNORM); idx = get_format_idx(WINED3DFMT_BC4_UNORM);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC4_SNORM); idx = get_format_idx(WINED3DFMT_BC4_SNORM);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC5_UNORM); idx = get_format_idx(WINED3DFMT_BC5_UNORM);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
idx = get_format_idx(WINED3DFMT_BC5_SNORM); idx = get_format_idx(WINED3DFMT_BC5_SNORM);
gl_info->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE; adapter->formats[idx].flags[WINED3D_GL_RES_TYPE_TEX_3D] &= ~WINED3DFMT_FLAG_TEXTURE;
} }
static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int component_count) static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int component_count)
@ -3689,14 +3692,15 @@ static unsigned int calculate_vertex_attribute_size(GLenum type, unsigned int co
} }
} }
static BOOL init_format_vertex_info(struct wined3d_gl_info *gl_info) static BOOL init_format_vertex_info(const struct wined3d_adapter *adapter,
struct wined3d_gl_info *gl_info)
{ {
struct wined3d_format *format; struct wined3d_format *format;
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(format_vertex_info); ++i) for (i = 0; i < ARRAY_SIZE(format_vertex_info); ++i)
{ {
if (!(format = get_format_internal(gl_info, format_vertex_info[i].id))) if (!(format = get_format_internal(adapter, format_vertex_info[i].id)))
return FALSE; return FALSE;
if (!gl_info->supported[format_vertex_info[i].extension]) if (!gl_info->supported[format_vertex_info[i].extension])
@ -3719,7 +3723,7 @@ static BOOL init_format_vertex_info(struct wined3d_gl_info *gl_info)
return TRUE; return TRUE;
} }
static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info) static BOOL init_typeless_formats(const struct wined3d_adapter *adapter)
{ {
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT]; unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
unsigned int i, j; unsigned int i, j;
@ -3728,9 +3732,9 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
{ {
struct wined3d_format *format, *typeless_format; struct wined3d_format *format, *typeless_format;
if (!(format = get_format_internal(gl_info, typed_formats[i].id))) if (!(format = get_format_internal(adapter, typed_formats[i].id)))
return FALSE; return FALSE;
if (!(typeless_format = get_format_internal(gl_info, typed_formats[i].typeless_id))) if (!(typeless_format = get_format_internal(adapter, typed_formats[i].typeless_id)))
return FALSE; return FALSE;
memcpy(flags, typeless_format->flags, sizeof(flags)); memcpy(flags, typeless_format->flags, sizeof(flags));
@ -3745,12 +3749,12 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
struct wined3d_format *depth_view_format, *stencil_view_format; struct wined3d_format *depth_view_format, *stencil_view_format;
enum wined3d_format_id format_id; enum wined3d_format_id format_id;
if (!(typeless_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].typeless_id))) if (!(typeless_format = get_format_internal(adapter, typeless_depth_stencil_formats[i].typeless_id)))
return FALSE; return FALSE;
if (!(ds_format = get_format_internal(gl_info, typeless_depth_stencil_formats[i].depth_stencil_id))) if (!(ds_format = get_format_internal(adapter, typeless_depth_stencil_formats[i].depth_stencil_id)))
return FALSE; return FALSE;
typeless_ds_format = &gl_info->formats[WINED3D_FORMAT_COUNT + i]; typeless_ds_format = &adapter->formats[WINED3D_FORMAT_COUNT + i];
typeless_ds_format->id = typeless_depth_stencil_formats[i].typeless_id; typeless_ds_format->id = typeless_depth_stencil_formats[i].typeless_id;
copy_format(typeless_ds_format, ds_format); copy_format(typeless_ds_format, ds_format);
for (j = 0; j < ARRAY_SIZE(typeless_ds_format->flags); ++j) for (j = 0; j < ARRAY_SIZE(typeless_ds_format->flags); ++j)
@ -3762,13 +3766,13 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
if ((format_id = typeless_depth_stencil_formats[i].depth_view_id) if ((format_id = typeless_depth_stencil_formats[i].depth_view_id)
&& typeless_depth_stencil_formats[i].separate_depth_view_format) && typeless_depth_stencil_formats[i].separate_depth_view_format)
{ {
if (!(depth_view_format = get_format_internal(gl_info, format_id))) if (!(depth_view_format = get_format_internal(adapter, format_id)))
return FALSE; return FALSE;
copy_format(depth_view_format, ds_format); copy_format(depth_view_format, ds_format);
} }
if ((format_id = typeless_depth_stencil_formats[i].stencil_view_id)) if ((format_id = typeless_depth_stencil_formats[i].stencil_view_id))
{ {
if (!(stencil_view_format = get_format_internal(gl_info, format_id))) if (!(stencil_view_format = get_format_internal(adapter, format_id)))
return FALSE; return FALSE;
copy_format(stencil_view_format, ds_format); copy_format(stencil_view_format, ds_format);
} }
@ -3777,16 +3781,17 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
return TRUE; return TRUE;
} }
static void init_format_gen_mipmap_info(struct wined3d_gl_info *gl_info) static void init_format_gen_mipmap_info(const struct wined3d_adapter *adapter,
struct wined3d_gl_info *gl_info)
{ {
unsigned int i, j; unsigned int i, j;
if (!gl_info->fbo_ops.glGenerateMipmap) if (!gl_info->fbo_ops.glGenerateMipmap)
return; return;
for (i = 0; i < gl_info->format_count; ++i) for (i = 0; i < adapter->format_count; ++i)
{ {
struct wined3d_format *format = &gl_info->formats[i]; struct wined3d_format *format = &adapter->formats[i];
for (j = 0; j < ARRAY_SIZE(format->flags); ++j) for (j = 0; j < ARRAY_SIZE(format->flags); ++j)
if (!(~format->flags[j] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING))) if (!(~format->flags[j] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)))
@ -3935,15 +3940,15 @@ static float wined3d_adapter_find_polyoffset_scale(struct wined3d_caps_gl_ctx *c
return (float)(1u << cur); return (float)(1u << cur);
} }
static void init_format_depth_bias_scale(struct wined3d_caps_gl_ctx *ctx, static void init_format_depth_bias_scale(struct wined3d_adapter *adapter,
const struct wined3d_d3d_info *d3d_info) struct wined3d_caps_gl_ctx *ctx)
{ {
const struct wined3d_gl_info *gl_info = ctx->gl_info; const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
unsigned int i; unsigned int i;
for (i = 0; i < gl_info->format_count; ++i) for (i = 0; i < adapter->format_count; ++i)
{ {
struct wined3d_format *format = &gl_info->formats[i]; struct wined3d_format *format = &adapter->formats[i];
if (format->flags[WINED3D_GL_RES_TYPE_RB] & WINED3DFMT_FLAG_DEPTH) if (format->flags[WINED3D_GL_RES_TYPE_RB] & WINED3DFMT_FLAG_DEPTH)
{ {
@ -3969,35 +3974,34 @@ BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, struct wi
{ {
struct wined3d_gl_info *gl_info = &adapter->gl_info; struct wined3d_gl_info *gl_info = &adapter->gl_info;
if (!init_format_base_info(gl_info)) return FALSE; if (!init_format_base_info(adapter)) return FALSE;
if (!init_format_block_info(gl_info)) goto fail; if (!init_format_block_info(adapter)) goto fail;
if (!init_format_decompress_info(gl_info)) goto fail; if (!init_format_decompress_info(adapter)) goto fail;
if (!ctx) /* WINED3D_NO3D */ if (!ctx) /* WINED3D_NO3D */
return TRUE; return TRUE;
if (!init_format_texture_info(adapter, gl_info)) goto fail; if (!init_format_texture_info(adapter, gl_info)) goto fail;
if (!init_format_vertex_info(gl_info)) goto fail; if (!init_format_vertex_info(adapter, gl_info)) goto fail;
apply_format_fixups(adapter, gl_info); apply_format_fixups(adapter, gl_info);
init_format_fbo_compat_info(ctx); init_format_fbo_compat_info(adapter, ctx);
init_format_filter_info(gl_info, adapter->driver_info.vendor); init_format_filter_info(adapter, gl_info);
if (!init_typeless_formats(gl_info)) goto fail; if (!init_typeless_formats(adapter)) goto fail;
init_format_gen_mipmap_info(gl_info); init_format_gen_mipmap_info(adapter, gl_info);
init_format_depth_bias_scale(ctx, &adapter->d3d_info); init_format_depth_bias_scale(adapter, ctx);
return TRUE; return TRUE;
fail: fail:
heap_free(gl_info->formats); heap_free(adapter->formats);
gl_info->formats = NULL; adapter->formats = NULL;
return FALSE; return FALSE;
} }
const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter, const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
enum wined3d_format_id format_id, unsigned int resource_usage) enum wined3d_format_id format_id, unsigned int resource_usage)
{ {
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
const struct wined3d_format *format; const struct wined3d_format *format;
int idx = get_format_idx(format_id); int idx = get_format_idx(format_id);
unsigned int i; unsigned int i;
@ -4006,22 +4010,22 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *ad
{ {
FIXME("Can't find format %s (%#x) in the format lookup table.\n", FIXME("Can't find format %s (%#x) in the format lookup table.\n",
debug_d3dformat(format_id), format_id); debug_d3dformat(format_id), format_id);
return &gl_info->formats[get_format_idx(WINED3DFMT_UNKNOWN)]; return &adapter->formats[get_format_idx(WINED3DFMT_UNKNOWN)];
} }
format = &gl_info->formats[idx]; format = &adapter->formats[idx];
if (resource_usage & WINED3DUSAGE_DEPTHSTENCIL && wined3d_format_is_typeless(format)) if (resource_usage & WINED3DUSAGE_DEPTHSTENCIL && wined3d_format_is_typeless(format))
{ {
for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i) for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i)
{ {
if (typeless_depth_stencil_formats[i].typeless_id == format_id) if (typeless_depth_stencil_formats[i].typeless_id == format_id)
return &gl_info->formats[WINED3D_FORMAT_COUNT + i]; return &adapter->formats[WINED3D_FORMAT_COUNT + i];
} }
FIXME("Cannot find depth/stencil typeless format %s (%#x).\n", FIXME("Cannot find depth/stencil typeless format %s (%#x).\n",
debug_d3dformat(format_id), format_id); debug_d3dformat(format_id), format_id);
return &gl_info->formats[get_format_idx(WINED3DFMT_UNKNOWN)]; return &adapter->formats[get_format_idx(WINED3DFMT_UNKNOWN)];
} }
return format; return format;

View File

@ -2599,9 +2599,6 @@ struct wined3d_gl_info
HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs); HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
struct opengl_funcs gl_ops; struct opengl_funcs gl_ops;
struct wined3d_fbo_ops fbo_ops; struct wined3d_fbo_ops fbo_ops;
struct wined3d_format *formats;
unsigned int format_count;
}; };
/* The driver names reflect the lowest GPU supported /* The driver names reflect the lowest GPU supported
@ -2682,6 +2679,9 @@ struct wined3d_adapter
UINT64 vram_bytes_used; UINT64 vram_bytes_used;
LUID luid; LUID luid;
struct wined3d_format *formats;
unsigned int format_count;
const struct wined3d_vertex_pipe_ops *vertex_pipe; const struct wined3d_vertex_pipe_ops *vertex_pipe;
const struct fragment_pipeline *fragment_pipe; const struct fragment_pipeline *fragment_pipe;
const struct wined3d_shader_backend_ops *shader_backend; const struct wined3d_shader_backend_ops *shader_backend;