Commit 3f217577 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of select_shader_mode().

parent f90bdedd
......@@ -2247,16 +2247,14 @@ static enum wined3d_pci_device wined3d_guess_card(const struct wined3d_gl_info *
return select_card_fallback_nvidia(gl_info);
}
static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info)
static const struct fragment_pipeline *select_fragment_implementation(const struct wined3d_gl_info *gl_info,
const struct wined3d_shader_backend_ops *shader_backend_ops)
{
int vs_selected_mode, ps_selected_mode;
select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
if (ps_selected_mode == SHADER_GLSL)
if (shader_backend_ops == &glsl_shader_backend)
return &glsl_fragment_pipe;
if (ps_selected_mode == SHADER_ARB)
if (shader_backend_ops == &arb_program_shader_backend)
return &arbfp_fragment_pipeline;
if (ps_selected_mode == SHADER_ATI)
if (gl_info->supported[ATI_FRAGMENT_SHADER])
return &atifs_fragment_pipeline;
if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
return &nvts_fragment_pipeline;
......@@ -2267,22 +2265,35 @@ static const struct fragment_pipeline *select_fragment_implementation(const stru
static const struct wined3d_shader_backend_ops *select_shader_backend(const struct wined3d_gl_info *gl_info)
{
int vs_selected_mode, ps_selected_mode;
select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) return &glsl_shader_backend;
if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) return &arb_program_shader_backend;
BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
if (wined3d_settings.vs_mode == VS_NONE && wined3d_settings.ps_mode == PS_NONE)
return &none_shader_backend;
if (glsl && gl_info->supported[ARB_FRAGMENT_SHADER])
return &glsl_shader_backend;
if (glsl && gl_info->supported[ARB_VERTEX_SHADER])
{
/* Geforce4 cards support GLSL but for vertex shaders only. Further
* its reported GLSL caps are wrong. This combined with the fact that
* GLSL won't offer more features or performance, use ARB shaders only
* on this card. */
if (gl_info->supported[NV_VERTEX_PROGRAM] && !gl_info->supported[NV_VERTEX_PROGRAM2])
return &arb_program_shader_backend;
return &glsl_shader_backend;
}
if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
return &arb_program_shader_backend;
return &none_shader_backend;
}
static const struct blit_shader *select_blit_implementation(const struct wined3d_gl_info *gl_info)
static const struct blit_shader *select_blit_implementation(const struct wined3d_gl_info *gl_info,
const struct wined3d_shader_backend_ops *shader_backend_ops)
{
int vs_selected_mode, ps_selected_mode;
select_shader_mode(gl_info, &ps_selected_mode, &vs_selected_mode);
if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL)
&& gl_info->supported[ARB_FRAGMENT_PROGRAM]) return &arbfp_blit;
else return &ffp_blit;
if ((shader_backend_ops == &glsl_shader_backend
|| shader_backend_ops == &arb_program_shader_backend)
&& gl_info->supported[ARB_FRAGMENT_PROGRAM])
return &arbfp_blit;
return &ffp_blit;
}
static void parse_extension_string(struct wined3d_gl_info *gl_info, const char *extensions,
......@@ -2753,9 +2764,9 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter)
checkGLcall("extension detection");
adapter->fragment_pipe = select_fragment_implementation(gl_info);
adapter->shader_backend = select_shader_backend(gl_info);
adapter->blitter = select_blit_implementation(gl_info);
adapter->fragment_pipe = select_fragment_implementation(gl_info, adapter->shader_backend);
adapter->blitter = select_blit_implementation(gl_info, adapter->shader_backend);
adapter->fragment_pipe->get_caps(gl_info, &fragment_caps);
gl_info->limits.texture_stages = fragment_caps.MaxTextureBlendStages;
......
......@@ -3338,31 +3338,6 @@ UINT wined3d_log2i(UINT32 x)
return (i = x >> 16) ? (x = i >> 8) ? l[x] + 24 : l[i] + 16 : (i = x >> 8) ? l[i] + 8 : l[x];
}
/* Set the shader type for this device, depending on the given capabilities
* and the user preferences in wined3d_settings. */
void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected)
{
BOOL glsl = wined3d_settings.glslRequested && gl_info->glsl_version >= MAKEDWORD_VERSION(1, 20);
if (wined3d_settings.vs_mode == VS_NONE) *vs_selected = SHADER_NONE;
else if (gl_info->supported[ARB_VERTEX_SHADER] && glsl)
{
/* Geforce4 cards support GLSL but for vertex shaders only. Further its reported GLSL caps are
* wrong. This combined with the fact that glsl won't offer more features or performance, use ARB
* shaders only on this card. */
if (gl_info->supported[NV_VERTEX_PROGRAM] && !gl_info->supported[NV_VERTEX_PROGRAM2]) *vs_selected = SHADER_ARB;
else *vs_selected = SHADER_GLSL;
}
else if (gl_info->supported[ARB_VERTEX_PROGRAM]) *vs_selected = SHADER_ARB;
else *vs_selected = SHADER_NONE;
if (wined3d_settings.ps_mode == PS_NONE) *ps_selected = SHADER_NONE;
else if (gl_info->supported[ARB_FRAGMENT_SHADER] && glsl) *ps_selected = SHADER_GLSL;
else if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) *ps_selected = SHADER_ARB;
else if (gl_info->supported[ATI_FRAGMENT_SHADER]) *ps_selected = SHADER_ATI;
else *ps_selected = SHADER_NONE;
}
const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *gl_info, enum wined3d_blit_op blit_op,
const RECT *src_rect, DWORD src_usage, enum wined3d_pool src_pool, const struct wined3d_format *src_format,
const RECT *dst_rect, DWORD dst_usage, enum wined3d_pool dst_pool, const struct wined3d_format *dst_format)
......
......@@ -252,11 +252,6 @@ static inline float float_24_to_32(DWORD in)
#define ORM_BACKBUFFER 0
#define ORM_FBO 1
#define SHADER_ARB 1
#define SHADER_GLSL 2
#define SHADER_ATI 3
#define SHADER_NONE 4
#define RTL_READDRAW 1
#define RTL_READTEX 2
......@@ -2581,8 +2576,6 @@ void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *s
UINT wined3d_log2i(UINT32 x) DECLSPEC_HIDDEN;
unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN;
void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected) DECLSPEC_HIDDEN;
struct wined3d_shader_lconst
{
struct list entry;
......
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