Commit bfe70679 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Ask the ffp/shader/blit implementation about format support.

If a format is not supported natively by opengl, a shader may be able to convert it. Up to now, CheckDeviceFormat had magic knowldge which GL extensions lead to which supported format. This patch adds functions that allow CheckDeviceFormat to ask the actual implementation for its capabilities.
parent 438b6bd4
......@@ -2180,6 +2180,23 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info
}
}
static BOOL shader_arb_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt));
switch(fmt) {
case WINED3DFMT_V8U8:
case WINED3DFMT_V16U16:
case WINED3DFMT_X8L8V8U8:
case WINED3DFMT_L6V5U5:
case WINED3DFMT_Q8W8V8U8:
case WINED3DFMT_ATI2N:
TRACE("[OK]\n");
return TRUE;
default:
TRACE("[FAILED\n");
return FALSE;
}
}
const shader_backend_t arb_program_shader_backend = {
shader_arb_select,
shader_arb_select_depth_blt,
......@@ -2194,6 +2211,7 @@ const shader_backend_t arb_program_shader_backend = {
shader_arb_generate_pshader,
shader_arb_generate_vshader,
shader_arb_get_caps,
shader_arb_conv_supported,
};
/* ARB_fragment_program fixed function pipeline replacement definitions */
......@@ -2961,5 +2979,6 @@ const struct fragment_pipeline arbfp_fragment_pipeline = {
arbfp_get_caps,
arbfp_alloc,
arbfp_free,
shader_arb_conv_supported,
arbfp_fragmentstate_template
};
......@@ -1063,10 +1063,24 @@ static void atifs_free(IWineD3DDevice *iface) {
}
#undef GLINFO_LOCATION
static BOOL atifs_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt));
switch(fmt) {
case WINED3DFMT_V8U8:
case WINED3DFMT_V16U16:
TRACE("[OK]\n");
return TRUE;
default:
TRACE("[FAILED\n");
return FALSE;
}
}
const struct fragment_pipeline atifs_fragment_pipeline = {
atifs_enable,
atifs_get_caps,
atifs_alloc,
atifs_free,
atifs_conv_supported,
atifs_fragmentstate_template
};
......@@ -1113,8 +1113,23 @@ static void shader_none_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_inf
pCaps->PixelShaderVersion = 0;
pCaps->PixelShader1xMaxValue = 0.0;
}
#undef GLINFO_LOCATION
static BOOL shader_none_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s", debug_d3dformat(fmt));
switch(fmt) {
/* Faked to make some apps happy. */
case WINED3DFMT_V8U8:
case WINED3DFMT_V16U16:
case WINED3DFMT_L6V5U5:
case WINED3DFMT_X8L8V8U8:
case WINED3DFMT_Q8W8V8U8:
TRACE("[OK]\n");
return TRUE;
default:
TRACE("[FAILED]\n");
return FALSE;
}
}
const shader_backend_t none_shader_backend = {
shader_none_select,
......@@ -1130,6 +1145,7 @@ const shader_backend_t none_shader_backend = {
shader_none_generate_pshader,
shader_none_generate_vshader,
shader_none_get_caps,
shader_none_conv_supported
};
/* *******************************************
......
......@@ -3731,6 +3731,23 @@ static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_inf
TRACE_(d3d_caps)("Hardware pixel shader version %d.%d enabled (GLSL)\n", (pCaps->PixelShaderVersion >> 8) & 0xff, pCaps->PixelShaderVersion & 0xff);
}
static BOOL shader_glsl_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt));
switch(fmt) {
case WINED3DFMT_V8U8:
case WINED3DFMT_V16U16:
case WINED3DFMT_X8L8V8U8:
case WINED3DFMT_L6V5U5:
case WINED3DFMT_Q8W8V8U8:
case WINED3DFMT_ATI2N:
TRACE("[OK]\n");
return TRUE;
default:
TRACE("[FAILED\n");
return FALSE;
}
}
const shader_backend_t glsl_shader_backend = {
shader_glsl_select,
shader_glsl_select_depth_blt,
......@@ -3745,4 +3762,5 @@ const shader_backend_t glsl_shader_backend = {
shader_glsl_generate_pshader,
shader_glsl_generate_vshader,
shader_glsl_get_caps,
shader_glsl_conv_supported,
};
......@@ -673,6 +673,11 @@ static void nvrc_fragment_free(IWineD3DDevice *iface) {}
* register combiners extension(Pre-GF3).
*/
static BOOL nvts_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s: [FAILED]", debug_d3dformat(fmt));
return FALSE;
}
const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
......@@ -805,6 +810,7 @@ const struct fragment_pipeline nvts_fragment_pipeline = {
nvrc_fragment_get_caps,
nvrc_fragment_alloc,
nvrc_fragment_free,
nvts_conv_supported,
nvrc_fragmentstate_template
};
......@@ -813,5 +819,6 @@ const struct fragment_pipeline nvrc_fragment_pipeline = {
nvrc_fragment_get_caps,
nvrc_fragment_alloc,
nvrc_fragment_free,
nvts_conv_supported,
nvrc_fragmentstate_template
};
......@@ -5620,12 +5620,17 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_in
static HRESULT ffp_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
static void ffp_fragment_free(IWineD3DDevice *iface) {}
static BOOL ffp_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s: [FAILED]", debug_d3dformat(fmt));
return FALSE;
}
const struct fragment_pipeline ffp_fragment_pipeline = {
ffp_enable,
ffp_fragment_get_caps,
ffp_fragment_alloc,
ffp_fragment_free,
ffp_conv_supported,
ffp_fragmentstate_template
};
......
......@@ -4648,9 +4648,15 @@ static void ffp_blit_unset(IWineD3DDevice *iface) {
}
}
static BOOL ffp_blit_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking blit format support for format %s: [FAILED]\n", debug_d3dformat(fmt));
return FALSE;
}
const struct blit_shader ffp_blit = {
ffp_blit_alloc,
ffp_blit_free,
ffp_blit_set,
ffp_blit_unset
ffp_blit_unset,
ffp_blit_conv_supported
};
......@@ -413,6 +413,21 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N;
}
if(!GL_SUPPORT(APPLE_YCBCR_422)) {
dst = getFmtIdx(WINED3DFMT_YUY2);
gl_info->gl_formats[dst].glInternal = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YUY2;
dst = getFmtIdx(WINED3DFMT_UYVY);
gl_info->gl_formats[dst].glInternal = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_UYVY;
}
return TRUE;
}
......
......@@ -247,6 +247,7 @@ typedef struct {
void (*shader_generate_pshader)(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer);
void (*shader_generate_vshader)(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer);
void (*shader_get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *caps);
BOOL (*shader_conv_supported)(WINED3DFORMAT conv);
} shader_backend_t;
extern const shader_backend_t atifs_shader_backend;
......@@ -556,6 +557,7 @@ struct fragment_pipeline {
void (*get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *caps);
HRESULT (*alloc_private)(IWineD3DDevice *iface);
void (*free_private)(IWineD3DDevice *iface);
BOOL (*conv_supported)(WINED3DFORMAT conv);
const struct StateEntryTemplate *states;
};
......@@ -581,6 +583,7 @@ struct blit_shader {
void (*free_private)(IWineD3DDevice *iface);
HRESULT (*set_shader)(IWineD3DDevice *iface, WINED3DFORMAT fmt, GLenum textype, UINT width, UINT height);
void (*unset_shader)(IWineD3DDevice *iface);
BOOL (*conv_supported)(WINED3DFORMAT conv);
};
extern const struct blit_shader ffp_blit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment