From: Matteo Bruni Subject: [PATCH 5/5] wined3d: Emulate luminance texture formats on core profile. Message-Id: <1458084254-24198-5-git-send-email-mbruni@codeweavers.com> Date: Wed, 16 Mar 2016 00:24:14 +0100 In-Reply-To: <1458084254-24198-1-git-send-email-mbruni@codeweavers.com> References: <1458084254-24198-1-git-send-email-mbruni@codeweavers.com> Signed-off-by: Matteo Bruni --- dlls/wined3d/directx.c | 2 ++ dlls/wined3d/utils.c | 84 +++++++++++++++++++++++++++++++++++++++-------- dlls/wined3d/wined3d_gl.h | 1 + 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 749876b..2175b49 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -3711,6 +3711,8 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, DWORD TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n"); gl_info->supported[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE] = TRUE; } + if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) + gl_info->supported[WINED3D_GL_LEGACY_FORMATS] = TRUE; wined3d_adapter_init_limits(gl_info); diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index e210a8a..202c638 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -995,30 +995,46 @@ static const struct wined3d_format_texture_info format_texture_info[] = * Macs, so probably the endianness differs. This could be tested as soon as we have a Windows and MacOS on a big * endian machine */ + {WINED3DFMT_UYVY, GL_RG8, GL_RG8, 0, + GL_RG, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_UYVY, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_FILTERING, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, {WINED3DFMT_UYVY, GL_RGB, GL_RGB, 0, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_APPLE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_FILTERING, APPLE_YCBCR_422, NULL}, + {WINED3DFMT_YUY2, GL_RG8, GL_RG8, 0, + GL_RG, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_YUY2, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_FILTERING, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, {WINED3DFMT_YUY2, GL_RGB, GL_RGB, 0, GL_YCBCR_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_FILTERING, APPLE_YCBCR_422, NULL}, + {WINED3DFMT_YV12, GL_R8, GL_R8, 0, + GL_RED, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_YV12, GL_ALPHA, GL_ALPHA, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_FILTERING, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, + {WINED3DFMT_NV12, GL_R8, GL_R8, 0, + GL_RED, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_NV12, GL_ALPHA, GL_ALPHA, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_FILTERING, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, {WINED3DFMT_DXT1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING @@ -1121,10 +1137,14 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_RENDERTARGET, EXT_PACKED_FLOAT}, /* Palettized formats */ + {WINED3DFMT_P8_UINT, GL_R8, GL_R8, 0, + GL_RED, GL_UNSIGNED_BYTE, 0, + 0, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_P8_UINT, GL_ALPHA8, GL_ALPHA8, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0, 0, - 0, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, /* Standard ARGB formats */ {WINED3DFMT_B8G8R8_UNORM, GL_RGB8, GL_RGB8, 0, GL_BGR, GL_UNSIGNED_BYTE, 0, @@ -1174,10 +1194,14 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_VTF, ARB_TEXTURE_RG, NULL}, + {WINED3DFMT_A8_UNORM, GL_R8, GL_R8, 0, + GL_RED, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_A8_UNORM, GL_ALPHA8, GL_ALPHA8, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, {WINED3DFMT_B4G4R4X4_UNORM, GL_RGB4, GL_RGB4, 0, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, @@ -1238,20 +1262,40 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE, ARB_TEXTURE_RG, NULL}, /* Luminance */ + {WINED3DFMT_L8_UNORM, GL_R8, GL_R8, 0, + GL_RED, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_L8_UNORM, GL_LUMINANCE8, GL_SLUMINANCE8_EXT, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, + {WINED3DFMT_L8A8_UNORM, GL_RG8, GL_RG8, 0, + GL_RG, GL_UNSIGNED_BYTE, 0, + WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, {WINED3DFMT_L8A8_UNORM, GL_LUMINANCE8_ALPHA8, GL_SLUMINANCE8_ALPHA8_EXT, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ, - WINED3D_GL_EXT_NONE, NULL}, + WINED3D_GL_LEGACY_FORMATS, NULL}, + {WINED3DFMT_L4A4_UNORM, GL_RG8, GL_RG8, 0, + GL_RG, GL_UNSIGNED_BYTE, 2, + WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, convert_l4a4_unorm}, {WINED3DFMT_L4A4_UNORM, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE4_ALPHA4, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 2, WINED3DFMT_FLAG_FILTERING, - WINED3D_GL_EXT_NONE, convert_l4a4_unorm}, + WINED3D_GL_LEGACY_FORMATS, convert_l4a4_unorm}, + {WINED3DFMT_L16_UNORM, GL_R16, GL_R16, 0, + GL_RED, GL_UNSIGNED_SHORT, 0, + WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, + ARB_TEXTURE_RG, NULL}, + {WINED3DFMT_L16_UNORM, GL_LUMINANCE16, GL_LUMINANCE16, 0, + GL_LUMINANCE, GL_UNSIGNED_SHORT, 0, + WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, + WINED3D_GL_LEGACY_FORMATS, NULL}, /* Bump mapping stuff */ {WINED3DFMT_R8G8_SNORM, GL_RGB8, GL_RGB8, 0, GL_BGR, GL_UNSIGNED_BYTE, 3, @@ -1397,10 +1441,6 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW, ARB_DEPTH_TEXTURE, NULL}, - {WINED3DFMT_L16_UNORM, GL_LUMINANCE16, GL_LUMINANCE16, 0, - GL_LUMINANCE, GL_UNSIGNED_SHORT, 0, - WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, - WINED3D_GL_EXT_NONE, NULL}, {WINED3DFMT_D32_FLOAT, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_SHADOW, @@ -2876,6 +2916,24 @@ static void apply_format_fixups(struct wined3d_adapter *adapter, struct wined3d_ gl_info->formats[idx].height_scale.denominator = 2; gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_NV12); + if (!gl_info->supported[WINED3D_GL_LEGACY_FORMATS]) + { + idx = get_format_idx(WINED3DFMT_A8_UNORM); + gl_info->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_L8_UNORM); + gl_info->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_L8A8_UNORM); + gl_info->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( + 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( + 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE); + } if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) { idx = get_format_idx(WINED3DFMT_INTZ); diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 19c379a..26c4832 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -168,6 +168,7 @@ enum wined3d_gl_extension WINED3D_GL_BLEND_EQUATION, WINED3D_GL_NORMALIZED_TEXRECT, WINED3D_GL_LEGACY_CONTEXT, + WINED3D_GL_LEGACY_FORMATS, WINED3D_GL_VERSION_2_0, WINED3D_GL_VERSION_3_2, WINED3D_GL_VERSION_4_3, -- 2.4.10