[PATCH 5/7] wined3d: Copy channel info for typed formats from typeless formats.
Józef Kucia
jkucia at codeweavers.com
Tue Feb 9 19:14:28 CST 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/utils.c | 83 +++++++++++++++++++-----------------------
dlls/wined3d/wined3d_private.h | 1 +
2 files changed, 38 insertions(+), 46 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 52bfd1b..18468ac 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -57,27 +57,12 @@ static const struct wined3d_format_channels formats[] =
{WINED3DFMT_DXT3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_DXT4, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_DXT5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
- {WINED3DFMT_BC1_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
- {WINED3DFMT_BC1_UNORM_SRGB, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
- {WINED3DFMT_BC2_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
- {WINED3DFMT_BC2_UNORM_SRGB, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
- {WINED3DFMT_BC3_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
- {WINED3DFMT_BC3_UNORM_SRGB, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_MULTI2_ARGB8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_G8R8_G8B8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_R8G8_B8G8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
- /* IEEE formats */
- {WINED3DFMT_R32_FLOAT, 32, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0},
- {WINED3DFMT_R32G32_FLOAT, 32, 32, 0, 0, 0, 32, 0, 0, 8, 0, 0},
- {WINED3DFMT_R32G32B32_FLOAT, 32, 32, 32, 0, 0, 32, 64, 0, 12, 0, 0},
- {WINED3DFMT_R32G32B32A32_FLOAT, 32, 32, 32, 32, 0, 32, 64, 96, 16, 0, 0},
/* Hmm? */
{WINED3DFMT_R8G8_SNORM_Cx, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
- /* Float */
- {WINED3DFMT_R16_FLOAT, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
- {WINED3DFMT_R16G16_FLOAT, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
{WINED3DFMT_R16G16_SINT, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
- {WINED3DFMT_R16G16B16A16_FLOAT, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
{WINED3DFMT_R16G16B16A16_SINT, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
/* Palettized formats */
{WINED3DFMT_P8_UINT_A8_UNORM, 0, 0, 0, 8, 0, 0, 0, 8, 2, 0, 0},
@@ -93,22 +78,13 @@ static const struct wined3d_format_channels formats[] =
{WINED3DFMT_B5G5R5A1_UNORM, 5, 5, 5, 1, 10, 5, 0, 15, 2, 0, 0},
{WINED3DFMT_B4G4R4A4_UNORM, 4, 4, 4, 4, 8, 4, 0, 12, 2, 0, 0},
{WINED3DFMT_B2G3R3_UNORM, 3, 3, 2, 0, 5, 2, 0, 0, 1, 0, 0},
- {WINED3DFMT_R8_UNORM, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_A8_UNORM, 0, 0, 0, 8, 0, 0, 0, 0, 1, 0, 0},
{WINED3DFMT_B2G3R3A8_UNORM, 3, 3, 2, 8, 5, 2, 0, 8, 2, 0, 0},
{WINED3DFMT_B4G4R4X4_UNORM, 4, 4, 4, 0, 8, 4, 0, 0, 2, 0, 0},
- {WINED3DFMT_R10G10B10A2_UNORM, 10, 10, 10, 2, 0, 10, 20, 30, 4, 0, 0},
{WINED3DFMT_R10G10B10A2_UINT, 10, 10, 10, 2, 0, 10, 20, 30, 4, 0, 0},
{WINED3DFMT_R10G10B10A2_SNORM, 10, 10, 10, 2, 0, 10, 20, 30, 4, 0, 0},
- {WINED3DFMT_R8G8B8A8_UNORM, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
- {WINED3DFMT_R8G8B8A8_UNORM_SRGB, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
- {WINED3DFMT_R8G8B8A8_UINT, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
- {WINED3DFMT_R8G8B8A8_SINT, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
{WINED3DFMT_R8G8B8X8_UNORM, 8, 8, 8, 0, 0, 8, 16, 0, 4, 0, 0},
- {WINED3DFMT_R16G16_UNORM, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
{WINED3DFMT_B10G10R10A2_UNORM, 10, 10, 10, 2, 20, 10, 0, 30, 4, 0, 0},
- {WINED3DFMT_R16G16B16A16_UNORM, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
- {WINED3DFMT_R8G8_UNORM, 8, 8, 0, 0, 0, 8, 0, 0, 2, 0, 0},
{WINED3DFMT_R16_UNORM, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
/* Luminance */
{WINED3DFMT_L8_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
@@ -127,19 +103,15 @@ static const struct wined3d_format_channels formats[] =
{WINED3DFMT_D16_LOCKABLE, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 0},
{WINED3DFMT_D32_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 0},
{WINED3DFMT_S1_UINT_D15_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 2, 15, 1},
- {WINED3DFMT_D24_UNORM_S8_UINT, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 8},
{WINED3DFMT_X8D24_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 0},
{WINED3DFMT_S4X4_UINT_D24_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 4},
{WINED3DFMT_D16_UNORM, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 0},
{WINED3DFMT_D32_FLOAT, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 0},
{WINED3DFMT_S8_UINT_D24_FLOAT, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 8},
{WINED3DFMT_VERTEXDATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {WINED3DFMT_R16_UINT, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
{WINED3DFMT_R32_UINT, 32, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0},
{WINED3DFMT_R32G32_UINT, 32, 32, 0, 0, 0, 32, 0, 0, 8, 0, 0},
{WINED3DFMT_R32G32B32_UINT, 32, 32, 32, 0, 0, 32, 64, 0, 12, 0, 0},
- {WINED3DFMT_R32G32B32A32_UINT, 32, 32, 32, 32, 0, 32, 64, 96, 16, 0, 0},
- {WINED3DFMT_R32G32B32A32_SINT, 32, 32, 32, 32, 0, 32, 64, 96, 16, 0, 0},
{WINED3DFMT_R16G16B16A16_SNORM, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
/* Vendor-specific formats */
{WINED3DFMT_ATI1N, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
@@ -1436,8 +1408,7 @@ static inline int getFmtIdx(enum wined3d_format_id format_id)
{
/* First check if the format is at the position of its value.
* This will catch the argb formats before the loop is entered. */
- if (format_id < (sizeof(formats) / sizeof(*formats))
- && formats[format_id].id == format_id)
+ if (format_id < ARRAY_SIZE(formats) && formats[format_id].id == format_id)
{
return format_id;
}
@@ -1445,10 +1416,10 @@ static inline int getFmtIdx(enum wined3d_format_id format_id)
{
unsigned int i;
- for (i = 0; i < (sizeof(formats) / sizeof(*formats)); ++i)
- {
+ for (i = 0; i < ARRAY_SIZE(formats); ++i)
if (formats[i].id == format_id) return i;
- }
+ for (i = 0; i < ARRAY_SIZE(typed_formats); ++i)
+ if (typed_formats[i].id == format_id) return ARRAY_SIZE(formats) + i;
}
return -1;
}
@@ -1471,17 +1442,18 @@ static void format_clear_flag(struct wined3d_format *format, unsigned int flag)
static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
{
- UINT format_count = sizeof(formats) / sizeof(*formats);
unsigned int i, j;
- gl_info->formats = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, format_count * sizeof(*gl_info->formats));
- if (!gl_info->formats)
+ gl_info->format_count = ARRAY_SIZE(formats) + ARRAY_SIZE(typed_formats);
+
+ if (!(gl_info->formats = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
+ gl_info->format_count * sizeof(*gl_info->formats))))
{
ERR("Failed to allocate memory.\n");
return FALSE;
}
- for (i = 0; i < format_count; ++i)
+ for (i = 0; i < ARRAY_SIZE(formats); ++i)
{
struct wined3d_format *format = &gl_info->formats[i];
format->id = formats[i].id;
@@ -1515,19 +1487,38 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
{C_FLOAT, WINED3DFMT_FLAG_FLOAT},
};
- struct wined3d_format *format;
- int fmt_idx;
+ struct wined3d_format *format, *typeless_format;
+ int fmt_idx, typeless_fmt_idx;
DWORD flags = 0;
- fmt_idx = getFmtIdx(typed_formats[i].id);
- if (fmt_idx == -1)
+ fmt_idx = ARRAY_SIZE(formats) + i;
+ typeless_fmt_idx = getFmtIdx(typed_formats[i].typeless_id);
+ if (typeless_fmt_idx == -1)
{
- ERR("Format %s (%#x) not found.\n",
- debug_d3dformat(typed_formats[i].id), typed_formats[i].id);
+ ERR("Typeless format %s (%#x) not found.\n",
+ debug_d3dformat(typed_formats[i].typeless_id), typed_formats[i].typeless_id);
HeapFree(GetProcessHeap(), 0, gl_info->formats);
return FALSE;
}
+
format = &gl_info->formats[fmt_idx];
+ typeless_format = &gl_info->formats[typeless_fmt_idx];
+
+ format->id = typed_formats[i].id;
+ format->red_size = typeless_format->red_size;
+ format->green_size = typeless_format->green_size;
+ format->blue_size = typeless_format->blue_size;
+ format->alpha_size = typeless_format->alpha_size;
+ format->red_offset = typeless_format->red_offset;
+ format->green_offset = typeless_format->green_offset;
+ format->blue_offset = typeless_format->blue_offset;
+ format->alpha_offset = typeless_format->alpha_offset;
+ format->byte_count = typeless_format->byte_count;
+ format->depth_size = typeless_format->depth_size;
+ format->stencil_size = typeless_format->stencil_size;
+ format->block_width = typeless_format->block_width;
+ format->block_height = typeless_format->block_height;
+ format->block_byte_count = typeless_format->block_byte_count;
for (j = 0; j < ARRAY_SIZE(channel_flags); ++j)
{
@@ -2159,7 +2150,7 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
if (gl_info->supported[ARB_INTERNALFORMAT_QUERY2])
{
- for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)
+ for (i = 0; i < gl_info->format_count; ++i)
{
GLint value;
struct wined3d_format *format = &gl_info->formats[i];
@@ -2270,7 +2261,7 @@ 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 < sizeof(formats) / sizeof(*formats); ++i)
+ for (i = 0; i < gl_info->format_count; ++i)
{
struct wined3d_format *format = &gl_info->formats[i];
@@ -2880,7 +2871,7 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_
format_set_flag(&gl_info->formats[idx], WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_RENDERTARGET);
}
- for (i = 0; i < sizeof(formats) / sizeof(*formats); ++i)
+ for (i = 0; i < gl_info->format_count; ++i)
{
struct wined3d_format *format = &gl_info->formats[i];
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 142cb93..b4b5cd7 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1828,6 +1828,7 @@ struct wined3d_gl_info
struct wined3d_fbo_ops fbo_ops;
struct wined3d_format *formats;
+ unsigned int format_count;
};
struct wined3d_driver_info
--
2.4.10
More information about the wine-patches
mailing list