Commit e4d8a3f3 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Move the various backend selection utility functions to utils.c.

parent 434a23d9
......@@ -155,10 +155,6 @@ static const struct {
**********************************************************/
static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE SurfaceType);
static const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter,
WINED3DDEVTYPE DeviceType);
static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType);
static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType);
GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1];
......@@ -389,39 +385,6 @@ static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
return ref;
}
/* Set the shader type for this device, depending on the given capabilities
* and the user preferences in wined3d_settings. */
static void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected)
{
if (wined3d_settings.vs_mode == VS_NONE) {
*vs_selected = SHADER_NONE;
} else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested) {
/* 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] && wined3d_settings.glslRequested) {
*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;
}
}
/**********************************************************
* IWineD3D parts follows
**********************************************************/
......@@ -3810,72 +3773,6 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface,
return WINED3D_OK;
}
static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType)
{
const shader_backend_t *ret;
int vs_selected_mode;
int ps_selected_mode;
select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) {
ret = &glsl_shader_backend;
} else if (vs_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_ARB) {
ret = &arb_program_shader_backend;
} else {
ret = &none_shader_backend;
}
return ret;
}
static const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter,
WINED3DDEVTYPE DeviceType)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
int vs_selected_mode;
int ps_selected_mode;
select_shader_mode(&adapter->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_fragment_pipeline;
}
else if (ps_selected_mode == SHADER_ATI)
{
return &atifs_fragment_pipeline;
}
else if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2])
{
return &nvts_fragment_pipeline;
}
else if (gl_info->supported[NV_REGISTER_COMBINERS])
{
return &nvrc_fragment_pipeline;
}
else
{
return &ffp_fragment_pipeline;
}
}
static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
int vs_selected_mode;
int ps_selected_mode;
select_shader_mode(&adapter->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;
}
}
/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
subset of a D3DCAPS9 structure. However, it has to come via a void *
as the d3d8 interface cannot import the d3d9 header */
......
......@@ -2772,3 +2772,63 @@ 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)
{
if (wined3d_settings.vs_mode == VS_NONE) *vs_selected = SHADER_NONE;
else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested)
{
/* 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] && wined3d_settings.glslRequested) *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 shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type)
{
int vs_selected_mode, ps_selected_mode;
select_shader_mode(&adapter->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;
return &none_shader_backend;
}
const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter,
WINED3DDEVTYPE device_type)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
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_fragment_pipeline;
else if (ps_selected_mode == SHADER_ATI) return &atifs_fragment_pipeline;
else if (gl_info->supported[NV_REGISTER_COMBINERS]
&& gl_info->supported[NV_TEXTURE_SHADER2]) return &nvts_fragment_pipeline;
else if (gl_info->supported[NV_REGISTER_COMBINERS]) return &nvrc_fragment_pipeline;
else return &ffp_fragment_pipeline;
}
const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
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;
}
......@@ -2525,6 +2525,14 @@ void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED
UINT wined3d_log2i(UINT32 x) DECLSPEC_HIDDEN;
unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN;
const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter,
WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN;
const struct fragment_pipeline *select_fragment_implementation(struct wined3d_adapter *adapter,
WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN;
const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter,
WINED3DDEVTYPE device_type) DECLSPEC_HIDDEN;
void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected) DECLSPEC_HIDDEN;
typedef struct local_constant {
struct list entry;
unsigned int idx;
......
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