[PATCH 4/7] wined3d: Introduce table with typed format channels.
Józef Kucia
jkucia at codeweavers.com
Tue Feb 9 19:14:27 CST 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/utils.c | 129 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 88 insertions(+), 41 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 1650ff3..52bfd1b 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -174,34 +174,53 @@ static const struct wined3d_format_channels formats[] =
{WINED3DFMT_BC5_TYPELESS, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
};
-struct wined3d_format_class_info
+enum wined3d_channel_type
+{
+ C_UNUSED,
+ C_UNORM,
+ C_SNORM,
+ C_UINT,
+ C_SINT,
+ C_FLOAT,
+ C_DEPTH,
+ C_STENCIL
+};
+
+struct wined3d_typed_format_info
{
enum wined3d_format_id id;
enum wined3d_format_id typeless_id;
+ enum wined3d_channel_type red_channel;
+ enum wined3d_channel_type green_channel;
+ enum wined3d_channel_type blue_channel;
+ enum wined3d_channel_type alpha_channel;
};
/**
* The last entry for a given typeless format defines its internal format.
*/
-static const struct wined3d_format_class_info format_class_info[] =
+static const struct wined3d_typed_format_info typed_formats[] =
{
- {WINED3DFMT_R32G32B32A32_UINT, WINED3DFMT_R32G32B32A32_TYPELESS},
- {WINED3DFMT_R32G32B32A32_SINT, WINED3DFMT_R32G32B32A32_TYPELESS},
- {WINED3DFMT_R32G32B32A32_FLOAT, WINED3DFMT_R32G32B32A32_TYPELESS},
- {WINED3DFMT_R32G32B32_FLOAT, WINED3DFMT_R32G32B32_TYPELESS},
- {WINED3DFMT_R16G16B16A16_UNORM, WINED3DFMT_R16G16B16A16_TYPELESS},
- {WINED3DFMT_R16G16B16A16_FLOAT, WINED3DFMT_R16G16B16A16_TYPELESS},
- {WINED3DFMT_R32G32_FLOAT, WINED3DFMT_R32G32_TYPELESS},
- {WINED3DFMT_R10G10B10A2_UNORM, WINED3DFMT_R10G10B10A2_TYPELESS},
- {WINED3DFMT_R8G8B8A8_UNORM_SRGB, WINED3DFMT_R8G8B8A8_TYPELESS},
- {WINED3DFMT_R8G8B8A8_UNORM, WINED3DFMT_R8G8B8A8_TYPELESS},
- {WINED3DFMT_R16G16_UNORM, WINED3DFMT_R16G16_TYPELESS},
- {WINED3DFMT_R16G16_FLOAT, WINED3DFMT_R16G16_TYPELESS},
- {WINED3DFMT_R32_FLOAT, WINED3DFMT_R32_TYPELESS},
- {WINED3DFMT_D24_UNORM_S8_UINT, WINED3DFMT_R24G8_TYPELESS},
- {WINED3DFMT_R8G8_UNORM, WINED3DFMT_R8G8_TYPELESS},
- {WINED3DFMT_R16_FLOAT, WINED3DFMT_R16_TYPELESS},
- {WINED3DFMT_R8_UNORM, WINED3DFMT_R8_TYPELESS},
+ {WINED3DFMT_R32G32B32A32_UINT, WINED3DFMT_R32G32B32A32_TYPELESS, C_UINT, C_UINT, C_UINT, C_UINT},
+ {WINED3DFMT_R32G32B32A32_SINT, WINED3DFMT_R32G32B32A32_TYPELESS, C_SINT, C_SINT, C_SINT, C_SINT},
+ {WINED3DFMT_R32G32B32A32_FLOAT, WINED3DFMT_R32G32B32A32_TYPELESS, C_FLOAT, C_FLOAT, C_FLOAT, C_FLOAT},
+ {WINED3DFMT_R32G32B32_FLOAT, WINED3DFMT_R32G32B32_TYPELESS, C_FLOAT, C_FLOAT, C_FLOAT},
+ {WINED3DFMT_R16G16B16A16_UNORM, WINED3DFMT_R16G16B16A16_TYPELESS, C_UNORM, C_UNORM, C_UNORM, C_UNORM},
+ {WINED3DFMT_R16G16B16A16_FLOAT, WINED3DFMT_R16G16B16A16_TYPELESS, C_FLOAT, C_FLOAT, C_FLOAT, C_FLOAT},
+ {WINED3DFMT_R32G32_FLOAT, WINED3DFMT_R32G32_TYPELESS, C_FLOAT, C_FLOAT},
+ {WINED3DFMT_R10G10B10A2_UNORM, WINED3DFMT_R10G10B10A2_TYPELESS, C_UNORM, C_UNORM, C_UNORM, C_UNORM},
+ {WINED3DFMT_R8G8B8A8_UINT, WINED3DFMT_R8G8B8A8_TYPELESS, C_UINT, C_UINT, C_UINT, C_UINT},
+ {WINED3DFMT_R8G8B8A8_SINT, WINED3DFMT_R8G8B8A8_TYPELESS, C_SINT, C_SINT, C_SINT, C_SINT},
+ {WINED3DFMT_R8G8B8A8_UNORM_SRGB, WINED3DFMT_R8G8B8A8_TYPELESS, C_UNORM, C_UNORM, C_UNORM, C_UNORM},
+ {WINED3DFMT_R8G8B8A8_UNORM, WINED3DFMT_R8G8B8A8_TYPELESS, C_UNORM, C_UNORM, C_UNORM, C_UNORM},
+ {WINED3DFMT_R16G16_UNORM, WINED3DFMT_R16G16_TYPELESS, C_UNORM, C_UNORM},
+ {WINED3DFMT_R16G16_FLOAT, WINED3DFMT_R16G16_TYPELESS, C_FLOAT, C_FLOAT},
+ {WINED3DFMT_R32_FLOAT, WINED3DFMT_R32_TYPELESS, C_FLOAT},
+ {WINED3DFMT_D24_UNORM_S8_UINT, WINED3DFMT_R24G8_TYPELESS, C_DEPTH, C_STENCIL},
+ {WINED3DFMT_R8G8_UNORM, WINED3DFMT_R8G8_TYPELESS, C_UNORM, C_UNORM},
+ {WINED3DFMT_R16_UINT, WINED3DFMT_R16_TYPELESS, C_UINT},
+ {WINED3DFMT_R16_FLOAT, WINED3DFMT_R16_TYPELESS, C_FLOAT},
+ {WINED3DFMT_R8_UNORM, WINED3DFMT_R8_TYPELESS, C_UNORM},
{WINED3DFMT_BC1_UNORM_SRGB, WINED3DFMT_BC1_TYPELESS},
{WINED3DFMT_BC1_UNORM, WINED3DFMT_BC1_TYPELESS},
{WINED3DFMT_BC2_UNORM_SRGB, WINED3DFMT_BC2_TYPELESS},
@@ -234,20 +253,8 @@ static const struct wined3d_format_base_flags format_base_flags[] =
{WINED3DFMT_R8G8B8X8_UNORM, WINED3DFMT_FLAG_GETDC},
{WINED3DFMT_ATI1N, WINED3DFMT_FLAG_BROKEN_PITCH},
{WINED3DFMT_ATI2N, WINED3DFMT_FLAG_BROKEN_PITCH},
- {WINED3DFMT_R32_FLOAT, WINED3DFMT_FLAG_FLOAT},
- {WINED3DFMT_R32G32_FLOAT, WINED3DFMT_FLAG_FLOAT},
- {WINED3DFMT_R32G32B32_FLOAT, WINED3DFMT_FLAG_FLOAT},
- {WINED3DFMT_R32G32B32A32_FLOAT, WINED3DFMT_FLAG_FLOAT},
- {WINED3DFMT_R16_FLOAT, WINED3DFMT_FLAG_FLOAT},
- {WINED3DFMT_R16G16_FLOAT, WINED3DFMT_FLAG_FLOAT},
- {WINED3DFMT_R16G16B16A16_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_D32_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_S8_UINT_D24_FLOAT, WINED3DFMT_FLAG_FLOAT},
- {WINED3DFMT_R8G8B8A8_UINT, WINED3DFMT_FLAG_INTEGER},
- {WINED3DFMT_R8G8B8A8_SINT, WINED3DFMT_FLAG_INTEGER},
- {WINED3DFMT_R16_UINT, WINED3DFMT_FLAG_INTEGER},
- {WINED3DFMT_R32G32B32A32_UINT, WINED3DFMT_FLAG_INTEGER},
- {WINED3DFMT_R32G32B32A32_SINT, WINED3DFMT_FLAG_INTEGER},
};
struct wined3d_format_block_info
@@ -1465,7 +1472,7 @@ 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);
- UINT i;
+ unsigned int i, j;
gl_info->formats = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, format_count * sizeof(*gl_info->formats));
if (!gl_info->formats)
@@ -1494,7 +1501,47 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
format->block_byte_count = formats[i].bpp;
}
- for (i = 0; i < (sizeof(format_base_flags) / sizeof(*format_base_flags)); ++i)
+ for (i = 0; i < ARRAY_SIZE(typed_formats); ++i)
+ {
+ static const struct
+ {
+ enum wined3d_channel_type channel_type;
+ DWORD flag;
+ }
+ channel_flags[] =
+ {
+ {C_UINT, WINED3DFMT_FLAG_INTEGER},
+ {C_SINT, WINED3DFMT_FLAG_INTEGER},
+ {C_FLOAT, WINED3DFMT_FLAG_FLOAT},
+ };
+
+ struct wined3d_format *format;
+ int fmt_idx;
+ DWORD flags = 0;
+
+ fmt_idx = getFmtIdx(typed_formats[i].id);
+ if (fmt_idx == -1)
+ {
+ ERR("Format %s (%#x) not found.\n",
+ debug_d3dformat(typed_formats[i].id), typed_formats[i].id);
+ HeapFree(GetProcessHeap(), 0, gl_info->formats);
+ return FALSE;
+ }
+ format = &gl_info->formats[fmt_idx];
+
+ for (j = 0; j < ARRAY_SIZE(channel_flags); ++j)
+ {
+ if (typed_formats[i].red_channel == channel_flags[j].channel_type
+ || typed_formats[i].green_channel == channel_flags[j].channel_type
+ || typed_formats[i].blue_channel == channel_flags[j].channel_type
+ || typed_formats[i].alpha_channel == channel_flags[j].channel_type)
+ flags |= channel_flags[j].flag;
+ }
+
+ format_set_flag(format, flags);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(format_base_flags); ++i)
{
int fmt_idx = getFmtIdx(format_base_flags[i].id);
@@ -2906,24 +2953,24 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
unsigned int i, j;
- for (i = 0; i < ARRAY_SIZE(format_class_info); ++i)
+ for (i = 0; i < ARRAY_SIZE(typed_formats); ++i)
{
struct wined3d_format *format, *typeless_format;
- int fmt_idx = getFmtIdx(format_class_info[i].id);
- int typeless_fmt_idx = getFmtIdx(format_class_info[i].typeless_id);
+ int fmt_idx = getFmtIdx(typed_formats[i].id);
+ int typeless_fmt_idx = getFmtIdx(typed_formats[i].typeless_id);
if (fmt_idx == -1)
{
ERR("Format %s (%#x) not found.\n",
- debug_d3dformat(format_class_info[i].id),
- format_class_info[i].id);
+ debug_d3dformat(typed_formats[i].id),
+ typed_formats[i].id);
return FALSE;
}
if (typeless_fmt_idx == -1)
{
ERR("Format %s (%#x) not found.\n",
- debug_d3dformat(format_class_info[i].typeless_id),
- format_class_info[i].typeless_id);
+ debug_d3dformat(typed_formats[i].typeless_id),
+ typed_formats[i].typeless_id);
return FALSE;
}
@@ -2932,7 +2979,7 @@ static BOOL init_typeless_formats(struct wined3d_gl_info *gl_info)
memcpy(flags, typeless_format->flags, sizeof(flags));
*typeless_format = *format;
- typeless_format->id = format_class_info[i].typeless_id;
+ typeless_format->id = typed_formats[i].typeless_id;
for (j = 0; j < ARRAY_SIZE(typeless_format->flags); ++j)
typeless_format->flags[j] |= flags[j];
}
--
2.4.10
More information about the wine-patches
mailing list