wined3d: Store GL view class for each wined3d format.

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 2016-06-07 13:24:37 +02:00 committed by Alexandre Julliard
parent 424532c5bd
commit e76d178959
2 changed files with 135 additions and 0 deletions

View File

@ -2453,6 +2453,137 @@ static void init_format_fbo_compat_info(struct wined3d_caps_gl_ctx *ctx)
gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
}
static GLenum lookup_gl_view_class(GLenum internal_format)
{
static const struct
{
GLenum internal_format;
GLenum view_class;
}
view_classes[] =
{
/* 128-bit */
{GL_RGBA32F, GL_VIEW_CLASS_128_BITS},
{GL_RGBA32UI, GL_VIEW_CLASS_128_BITS},
{GL_RGBA32I, GL_VIEW_CLASS_128_BITS},
/* 96-bit */
{GL_RGB32F, GL_VIEW_CLASS_96_BITS},
{GL_RGB32UI, GL_VIEW_CLASS_96_BITS},
{GL_RGB32I, GL_VIEW_CLASS_96_BITS},
/* 64-bit */
{GL_RGBA16F, GL_VIEW_CLASS_64_BITS},
{GL_RG32F, GL_VIEW_CLASS_64_BITS},
{GL_RGBA16UI, GL_VIEW_CLASS_64_BITS},
{GL_RG32UI, GL_VIEW_CLASS_64_BITS},
{GL_RGBA16I, GL_VIEW_CLASS_64_BITS},
{GL_RG32I, GL_VIEW_CLASS_64_BITS},
{GL_RGBA16, GL_VIEW_CLASS_64_BITS},
{GL_RGBA16_SNORM, GL_VIEW_CLASS_64_BITS},
/* 48-bit */
{GL_RGB16, GL_VIEW_CLASS_48_BITS},
{GL_RGB16_SNORM, GL_VIEW_CLASS_48_BITS},
{GL_RGB16F, GL_VIEW_CLASS_48_BITS},
{GL_RGB16UI, GL_VIEW_CLASS_48_BITS},
{GL_RGB16I, GL_VIEW_CLASS_48_BITS},
/* 32-bit */
{GL_RG16F, GL_VIEW_CLASS_32_BITS},
{GL_R11F_G11F_B10F, GL_VIEW_CLASS_32_BITS},
{GL_R32F, GL_VIEW_CLASS_32_BITS},
{GL_RGB10_A2UI, GL_VIEW_CLASS_32_BITS},
{GL_RGBA8UI, GL_VIEW_CLASS_32_BITS},
{GL_RG16UI, GL_VIEW_CLASS_32_BITS},
{GL_R32UI, GL_VIEW_CLASS_32_BITS},
{GL_RGBA8I, GL_VIEW_CLASS_32_BITS},
{GL_RG16I, GL_VIEW_CLASS_32_BITS},
{GL_R32I, GL_VIEW_CLASS_32_BITS},
{GL_RGB10_A2, GL_VIEW_CLASS_32_BITS},
{GL_RGBA8, GL_VIEW_CLASS_32_BITS},
{GL_RG16, GL_VIEW_CLASS_32_BITS},
{GL_RGBA8_SNORM, GL_VIEW_CLASS_32_BITS},
{GL_RG16_SNORM, GL_VIEW_CLASS_32_BITS},
{GL_SRGB8_ALPHA8, GL_VIEW_CLASS_32_BITS},
{GL_RGB9_E5, GL_VIEW_CLASS_32_BITS},
/* 24-bit */
{GL_RGB8, GL_VIEW_CLASS_24_BITS},
{GL_RGB8_SNORM, GL_VIEW_CLASS_24_BITS},
{GL_SRGB8, GL_VIEW_CLASS_24_BITS},
{GL_RGB8UI, GL_VIEW_CLASS_24_BITS},
{GL_RGB8I, GL_VIEW_CLASS_24_BITS},
/* 16-bit */
{GL_R16F, GL_VIEW_CLASS_16_BITS},
{GL_RG8UI, GL_VIEW_CLASS_16_BITS},
{GL_R16UI, GL_VIEW_CLASS_16_BITS},
{GL_RG8I, GL_VIEW_CLASS_16_BITS},
{GL_R16I, GL_VIEW_CLASS_16_BITS},
{GL_RG8, GL_VIEW_CLASS_16_BITS},
{GL_R16, GL_VIEW_CLASS_16_BITS},
{GL_RG8_SNORM, GL_VIEW_CLASS_16_BITS},
{GL_R16_SNORM, GL_VIEW_CLASS_16_BITS},
/* 8-bit */
{GL_R8UI, GL_VIEW_CLASS_8_BITS},
{GL_R8I, GL_VIEW_CLASS_8_BITS},
{GL_R8, GL_VIEW_CLASS_8_BITS},
{GL_R8_SNORM, GL_VIEW_CLASS_8_BITS},
/* RGTC1 */
{GL_COMPRESSED_RED_RGTC1, GL_VIEW_CLASS_RGTC1_RED},
{GL_COMPRESSED_SIGNED_RED_RGTC1, GL_VIEW_CLASS_RGTC1_RED},
/* RGTC2 */
{GL_COMPRESSED_RG_RGTC2, GL_VIEW_CLASS_RGTC2_RG},
{GL_COMPRESSED_SIGNED_RG_RGTC2, GL_VIEW_CLASS_RGTC2_RG},
/* BPTC unorm */
{GL_COMPRESSED_RGBA_BPTC_UNORM, GL_VIEW_CLASS_BPTC_UNORM},
{GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_VIEW_CLASS_BPTC_UNORM},
/* BPTC float */
{GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_VIEW_CLASS_BPTC_FLOAT},
{GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_VIEW_CLASS_BPTC_FLOAT},
/* DXT1 RGB */
{GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_VIEW_CLASS_S3TC_DXT1_RGB},
{GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_VIEW_CLASS_S3TC_DXT1_RGB},
/* DXT1 RGBA */
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_VIEW_CLASS_S3TC_DXT1_RGBA},
{GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_VIEW_CLASS_S3TC_DXT1_RGBA},
/* DXT3 */
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_VIEW_CLASS_S3TC_DXT3_RGBA},
{GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_VIEW_CLASS_S3TC_DXT3_RGBA},
/* DXT5 */
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_VIEW_CLASS_S3TC_DXT5_RGBA},
{GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_VIEW_CLASS_S3TC_DXT5_RGBA},
};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(view_classes); ++i)
{
if (view_classes[i].internal_format == internal_format)
return view_classes[i].view_class;
}
return GL_NONE;
}
static void query_view_class(struct wined3d_format *format)
{
GLenum internal_view_class, gamma_view_class, rt_view_class;
internal_view_class = lookup_gl_view_class(format->glInternal);
gamma_view_class = lookup_gl_view_class(format->glGammaInternal);
rt_view_class = lookup_gl_view_class(format->rtInternal);
if (internal_view_class == gamma_view_class || gamma_view_class == rt_view_class)
{
format->gl_view_class = internal_view_class;
TRACE("Format %s is member of GL view class %#x.\n",
debug_d3dformat(format->id), format->gl_view_class);
}
else
{
format->gl_view_class = GL_NONE;
}
}
static void query_internal_format(struct wined3d_adapter *adapter,
struct wined3d_format *format, const struct wined3d_format_texture_info *texture_info,
struct wined3d_gl_info *gl_info, BOOL srgb_write_supported, BOOL srgb_format)
@ -2522,6 +2653,8 @@ static void query_internal_format(struct wined3d_adapter *adapter,
}
}
query_view_class(format);
if (format->glInternal && format->flags[WINED3D_GL_RES_TYPE_RB]
& (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{

View File

@ -3537,6 +3537,8 @@ struct wined3d_format
struct color_fixup_desc color_fixup;
void (*convert)(const BYTE *src, BYTE *dst, UINT src_row_pitch, UINT src_slice_pitch,
UINT dst_row_pitch, UINT dst_slice_pitch, UINT width, UINT height, UINT depth);
GLenum gl_view_class;
};
const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info,