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)
{
heap_free(adapter->gl_info.formats);
heap_free(adapter->formats);
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",
adapter->luid.HighPart, adapter->luid.LowPart, adapter);
adapter->formats = NULL;
adapter->format_count = 0;
if (wined3d_creation_flags & WINED3D_NO3D)
return wined3d_adapter_no3d_init(adapter);
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]
&& !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
{
/* TODO: Add support for non-power-of-two compressed textures. */
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D]
& (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;
}
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)
{
int fmt_idx;
@ -1947,7 +1947,7 @@ static struct wined3d_format *get_format_internal(struct wined3d_gl_info *gl_inf
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)
@ -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;
unsigned int i, j;
gl_info->format_count = WINED3D_FORMAT_COUNT;
if (!(gl_info->formats = heap_calloc(gl_info->format_count
+ ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*gl_info->formats))))
adapter->format_count = WINED3D_FORMAT_COUNT;
if (!(adapter->formats = heap_calloc(adapter->format_count
+ ARRAY_SIZE(typeless_depth_stencil_formats), sizeof(*adapter->formats))))
{
ERR("Failed to allocate memory.\n");
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)
{
if (!(format = get_format_internal(gl_info, formats[i].id)))
if (!(format = get_format_internal(adapter, formats[i].id)))
goto fail;
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;
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;
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;
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)
{
if (!(format = get_format_internal(gl_info, ddi_formats[i].id)))
if (!(format = get_format_internal(adapter, ddi_formats[i].id)))
goto fail;
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)
{
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;
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;
fail:
heap_free(gl_info->formats);
heap_free(adapter->formats);
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;
unsigned int 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;
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
* "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;
unsigned int 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;
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. */
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;
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])
{
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;
struct wined3d_format *format = &adapter->formats[i];
GLenum rt_internal = format->rtInternal;
GLint value;
if (!format->glInternal)
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);
}
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;
@ -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)
{
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;
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 (!(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;
break;
}
@ -3324,8 +3325,10 @@ static BOOL check_filter(const struct wined3d_gl_info *gl_info, GLenum internal)
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;
unsigned int fmt_idx, i;
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)
{
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;
@ -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)
{
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 */
filtered = check_filter(gl_info, gl_info->formats[fmt_idx].glInternal);
filtered = check_filter(gl_info, adapter->formats[fmt_idx].glInternal);
if (filtered)
{
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;
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);
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);
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);
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);
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);
/* 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
* conversion for this format. */
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);
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);
}
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
* fixups here. */
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);
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);
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);
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);
}
if (!gl_info->supported[NV_TEXTURE_SHADER])
{
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);
}
if (gl_info->supported[ARB_TEXTURE_COMPRESSION_RGTC] || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
{
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);
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);
}
else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC])
{
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);
}
@ -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])))
{
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);
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]
&& (!gl_info->supported[ARB_FRAGMENT_SHADER] || !gl_info->supported[ARB_VERTEX_SHADER])))
{
idx = get_format_idx(WINED3DFMT_YUY2);
gl_info->formats[idx].glInternal = 0;
adapter->formats[idx].glInternal = 0;
idx = get_format_idx(WINED3DFMT_UYVY);
gl_info->formats[idx].glInternal = 0;
adapter->formats[idx].glInternal = 0;
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM]
|| (gl_info->supported[ARB_FRAGMENT_SHADER] && gl_info->supported[ARB_VERTEX_SHADER]))
{
idx = get_format_idx(WINED3DFMT_YV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
adapter->formats[idx].height_scale.numerator = 3;
adapter->formats[idx].height_scale.denominator = 2;
adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
idx = get_format_idx(WINED3DFMT_NV12);
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
gl_info->formats[idx].height_scale.numerator = 3;
gl_info->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
format_set_flag(&adapter->formats[idx], WINED3DFMT_FLAG_HEIGHT_SCALE);
adapter->formats[idx].height_scale.numerator = 3;
adapter->formats[idx].height_scale.denominator = 2;
adapter->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12);
}
else
{
idx = get_format_idx(WINED3DFMT_YV12);
gl_info->formats[idx].glInternal = 0;
adapter->formats[idx].glInternal = 0;
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])
{
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);
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);
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);
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);
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);
}
if (gl_info->supported[ARB_TEXTURE_RG])
{
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);
}
if (gl_info->supported[ARB_FRAGMENT_PROGRAM] || gl_info->supported[ARB_FRAGMENT_SHADER])
{
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])
{
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])
@ -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.
* 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);
gl_info->formats[idx].gl_vtx_type = GL_FLOAT;
adapter->formats[idx].gl_vtx_type = GL_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])
{
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);
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);
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)
{
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
@ -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])
{
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()
@ -3609,7 +3612,7 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[EXT_DEPTH_BOUNDS_TEST])
{
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
@ -3618,12 +3621,12 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
{
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))
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
* WINED3DFMT_FLAG_DECOMPRESS. */
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);
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);
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);
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);
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);
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)
@ -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;
unsigned int 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;
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;
}
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 i, j;
@ -3728,9 +3732,9 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
{
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;
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;
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;
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;
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;
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;
copy_format(typeless_ds_format, ds_format);
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)
&& 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;
copy_format(depth_view_format, ds_format);
}
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;
copy_format(stencil_view_format, ds_format);
}
@ -3777,16 +3781,17 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
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;
if (!gl_info->fbo_ops.glGenerateMipmap)
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)
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);
}
static void init_format_depth_bias_scale(struct wined3d_caps_gl_ctx *ctx,
const struct wined3d_d3d_info *d3d_info)
static void init_format_depth_bias_scale(struct wined3d_adapter *adapter,
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;
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)
{
@ -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;
if (!init_format_base_info(gl_info)) return FALSE;
if (!init_format_block_info(gl_info)) goto fail;
if (!init_format_decompress_info(gl_info)) goto fail;
if (!init_format_base_info(adapter)) return FALSE;
if (!init_format_block_info(adapter)) goto fail;
if (!init_format_decompress_info(adapter)) goto fail;
if (!ctx) /* WINED3D_NO3D */
return TRUE;
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);
init_format_fbo_compat_info(ctx);
init_format_filter_info(gl_info, adapter->driver_info.vendor);
if (!init_typeless_formats(gl_info)) goto fail;
init_format_gen_mipmap_info(gl_info);
init_format_depth_bias_scale(ctx, &adapter->d3d_info);
init_format_fbo_compat_info(adapter, ctx);
init_format_filter_info(adapter, gl_info);
if (!init_typeless_formats(adapter)) goto fail;
init_format_gen_mipmap_info(adapter, gl_info);
init_format_depth_bias_scale(adapter, ctx);
return TRUE;
fail:
heap_free(gl_info->formats);
gl_info->formats = NULL;
heap_free(adapter->formats);
adapter->formats = NULL;
return FALSE;
}
const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
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;
int idx = get_format_idx(format_id);
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",
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))
{
for (i = 0; i < ARRAY_SIZE(typeless_depth_stencil_formats); ++i)
{
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",
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;

View File

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