wined3d: Derive format component counts from the component info.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-09-10 01:02:48 +04:30 committed by Alexandre Julliard
parent 9781ef76fa
commit 19a532ca0a
2 changed files with 40 additions and 38 deletions

View File

@ -600,48 +600,47 @@ struct wined3d_format_vertex_info
{
enum wined3d_format_id id;
enum wined3d_ffp_emit_idx emit_idx;
unsigned int component_count;
GLenum gl_vtx_type;
enum wined3d_gl_extension extension;
};
static const struct wined3d_format_vertex_info format_vertex_info[] =
{
{WINED3DFMT_R32_FLOAT, WINED3D_FFP_EMIT_FLOAT1, 1, GL_FLOAT},
{WINED3DFMT_R32G32_FLOAT, WINED3D_FFP_EMIT_FLOAT2, 2, GL_FLOAT},
{WINED3DFMT_R32G32B32_FLOAT, WINED3D_FFP_EMIT_FLOAT3, 3, GL_FLOAT},
{WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_FFP_EMIT_FLOAT4, 4, GL_FLOAT},
{WINED3DFMT_B8G8R8A8_UNORM, WINED3D_FFP_EMIT_D3DCOLOR, 4, GL_UNSIGNED_BYTE},
{WINED3DFMT_R8G8B8A8_UINT, WINED3D_FFP_EMIT_UBYTE4, 4, GL_UNSIGNED_BYTE},
{WINED3DFMT_R16G16_UINT, WINED3D_FFP_EMIT_INVALID, 2, GL_UNSIGNED_SHORT},
{WINED3DFMT_R16G16_SINT, WINED3D_FFP_EMIT_SHORT2, 2, GL_SHORT},
{WINED3DFMT_R16G16B16A16_SINT, WINED3D_FFP_EMIT_SHORT4, 4, GL_SHORT},
{WINED3DFMT_R8G8B8A8_UNORM, WINED3D_FFP_EMIT_UBYTE4N, 4, GL_UNSIGNED_BYTE},
{WINED3DFMT_R16G16_SNORM, WINED3D_FFP_EMIT_SHORT2N, 2, GL_SHORT},
{WINED3DFMT_R16G16B16A16_SNORM, WINED3D_FFP_EMIT_SHORT4N, 4, GL_SHORT},
{WINED3DFMT_R16G16_UNORM, WINED3D_FFP_EMIT_USHORT2N, 2, GL_UNSIGNED_SHORT},
{WINED3DFMT_R16G16B16A16_UNORM, WINED3D_FFP_EMIT_USHORT4N, 4, GL_UNSIGNED_SHORT},
{WINED3DFMT_R10G10B10X2_UINT, WINED3D_FFP_EMIT_UDEC3, 3, GL_UNSIGNED_SHORT},
{WINED3DFMT_R10G10B10X2_SNORM, WINED3D_FFP_EMIT_DEC3N, 3, GL_SHORT},
{WINED3DFMT_R10G10B10A2_UNORM, WINED3D_FFP_EMIT_INVALID, 4, GL_UNSIGNED_INT_2_10_10_10_REV,
{WINED3DFMT_R32_FLOAT, WINED3D_FFP_EMIT_FLOAT1, GL_FLOAT},
{WINED3DFMT_R32G32_FLOAT, WINED3D_FFP_EMIT_FLOAT2, GL_FLOAT},
{WINED3DFMT_R32G32B32_FLOAT, WINED3D_FFP_EMIT_FLOAT3, GL_FLOAT},
{WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_FFP_EMIT_FLOAT4, GL_FLOAT},
{WINED3DFMT_B8G8R8A8_UNORM, WINED3D_FFP_EMIT_D3DCOLOR, GL_UNSIGNED_BYTE},
{WINED3DFMT_R8G8B8A8_UINT, WINED3D_FFP_EMIT_UBYTE4, GL_UNSIGNED_BYTE},
{WINED3DFMT_R16G16_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_SHORT},
{WINED3DFMT_R16G16_SINT, WINED3D_FFP_EMIT_SHORT2, GL_SHORT},
{WINED3DFMT_R16G16B16A16_SINT, WINED3D_FFP_EMIT_SHORT4, GL_SHORT},
{WINED3DFMT_R8G8B8A8_UNORM, WINED3D_FFP_EMIT_UBYTE4N, GL_UNSIGNED_BYTE},
{WINED3DFMT_R16G16_SNORM, WINED3D_FFP_EMIT_SHORT2N, GL_SHORT},
{WINED3DFMT_R16G16B16A16_SNORM, WINED3D_FFP_EMIT_SHORT4N, GL_SHORT},
{WINED3DFMT_R16G16_UNORM, WINED3D_FFP_EMIT_USHORT2N, GL_UNSIGNED_SHORT},
{WINED3DFMT_R16G16B16A16_UNORM, WINED3D_FFP_EMIT_USHORT4N, GL_UNSIGNED_SHORT},
{WINED3DFMT_R10G10B10X2_UINT, WINED3D_FFP_EMIT_UDEC3, GL_UNSIGNED_SHORT},
{WINED3DFMT_R10G10B10X2_SNORM, WINED3D_FFP_EMIT_DEC3N, GL_SHORT},
{WINED3DFMT_R10G10B10A2_UNORM, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_INT_2_10_10_10_REV,
ARB_VERTEX_TYPE_2_10_10_10_REV},
{WINED3DFMT_R16G16_FLOAT, WINED3D_FFP_EMIT_FLOAT16_2, 2, GL_HALF_FLOAT},
{WINED3DFMT_R16G16B16A16_FLOAT, WINED3D_FFP_EMIT_FLOAT16_4, 4, GL_HALF_FLOAT},
{WINED3DFMT_R8G8B8A8_SNORM, WINED3D_FFP_EMIT_INVALID, 4, GL_BYTE},
{WINED3DFMT_R8G8B8A8_SINT, WINED3D_FFP_EMIT_INVALID, 4, GL_BYTE},
{WINED3DFMT_R16G16B16A16_UINT, WINED3D_FFP_EMIT_INVALID, 4, GL_UNSIGNED_SHORT},
{WINED3DFMT_R8_UNORM, WINED3D_FFP_EMIT_INVALID, 1, GL_UNSIGNED_BYTE},
{WINED3DFMT_R8_UINT, WINED3D_FFP_EMIT_INVALID, 1, GL_UNSIGNED_BYTE},
{WINED3DFMT_R8_SINT, WINED3D_FFP_EMIT_INVALID, 1, GL_BYTE},
{WINED3DFMT_R16_UINT, WINED3D_FFP_EMIT_INVALID, 1, GL_UNSIGNED_SHORT},
{WINED3DFMT_R16_SINT, WINED3D_FFP_EMIT_INVALID, 1, GL_SHORT},
{WINED3DFMT_R32_UINT, WINED3D_FFP_EMIT_INVALID, 1, GL_UNSIGNED_INT},
{WINED3DFMT_R32_SINT, WINED3D_FFP_EMIT_INVALID, 1, GL_INT},
{WINED3DFMT_R32G32_UINT, WINED3D_FFP_EMIT_INVALID, 2, GL_UNSIGNED_INT},
{WINED3DFMT_R32G32_SINT, WINED3D_FFP_EMIT_INVALID, 2, GL_INT},
{WINED3DFMT_R32G32B32_UINT, WINED3D_FFP_EMIT_INVALID, 3, GL_UNSIGNED_INT},
{WINED3DFMT_R32G32B32A32_UINT, WINED3D_FFP_EMIT_INVALID, 4, GL_UNSIGNED_INT},
{WINED3DFMT_R32G32B32A32_SINT, WINED3D_FFP_EMIT_INVALID, 4, GL_INT},
{WINED3DFMT_R16G16_FLOAT, WINED3D_FFP_EMIT_FLOAT16_2, GL_HALF_FLOAT},
{WINED3DFMT_R16G16B16A16_FLOAT, WINED3D_FFP_EMIT_FLOAT16_4, GL_HALF_FLOAT},
{WINED3DFMT_R8G8B8A8_SNORM, WINED3D_FFP_EMIT_INVALID, GL_BYTE},
{WINED3DFMT_R8G8B8A8_SINT, WINED3D_FFP_EMIT_INVALID, GL_BYTE},
{WINED3DFMT_R16G16B16A16_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_SHORT},
{WINED3DFMT_R8_UNORM, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_BYTE},
{WINED3DFMT_R8_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_BYTE},
{WINED3DFMT_R8_SINT, WINED3D_FFP_EMIT_INVALID, GL_BYTE},
{WINED3DFMT_R16_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_SHORT},
{WINED3DFMT_R16_SINT, WINED3D_FFP_EMIT_INVALID, GL_SHORT},
{WINED3DFMT_R32_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_INT},
{WINED3DFMT_R32_SINT, WINED3D_FFP_EMIT_INVALID, GL_INT},
{WINED3DFMT_R32G32_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_INT},
{WINED3DFMT_R32G32_SINT, WINED3D_FFP_EMIT_INVALID, GL_INT},
{WINED3DFMT_R32G32B32_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_INT},
{WINED3DFMT_R32G32B32A32_UINT, WINED3D_FFP_EMIT_INVALID, GL_UNSIGNED_INT},
{WINED3DFMT_R32G32B32A32_SINT, WINED3D_FFP_EMIT_INVALID, GL_INT},
};
struct wined3d_format_texture_info
@ -2038,6 +2037,7 @@ static BOOL init_format_base_info(struct wined3d_adapter *adapter)
for (i = 0; i < ARRAY_SIZE(typed_formats); ++i)
{
const struct wined3d_format *typeless_format;
unsigned int component_count = 0;
DWORD flags = 0;
if (!(format = get_format_internal(adapter, typed_formats[i].id)))
@ -2073,6 +2073,8 @@ static BOOL init_format_base_info(struct wined3d_adapter *adapter)
flags |= WINED3DFMT_FLAG_INTEGER;
if (channel_type == WINED3D_CHANNEL_TYPE_FLOAT)
flags |= WINED3DFMT_FLAG_FLOAT;
if (channel_type != WINED3D_CHANNEL_TYPE_UNUSED)
++component_count;
if (channel_type == WINED3D_CHANNEL_TYPE_DEPTH && !format->depth_size)
{
@ -2081,6 +2083,7 @@ static BOOL init_format_base_info(struct wined3d_adapter *adapter)
}
}
format->component_count = component_count;
format_set_flag(format, flags);
}
@ -3683,9 +3686,8 @@ static BOOL init_format_vertex_info(const struct wined3d_adapter *adapter,
continue;
format->emit_idx = format_vertex_info[i].emit_idx;
format->component_count = format_vertex_info[i].component_count;
format->gl_vtx_type = format_vertex_info[i].gl_vtx_type;
format->gl_vtx_format = format_vertex_info[i].component_count;
format->gl_vtx_format = format->component_count;
}
return TRUE;

View File

@ -4326,6 +4326,7 @@ struct wined3d_format
enum wined3d_format_id id;
D3DDDIFORMAT ddi_format;
unsigned int component_count;
DWORD red_size;
DWORD green_size;
DWORD blue_size;
@ -4343,7 +4344,6 @@ struct wined3d_format
UINT block_byte_count;
enum wined3d_ffp_emit_idx emit_idx;
GLint component_count;
GLenum gl_vtx_type;
GLint gl_vtx_format;