wined3d: Select the shader backend during adapter initialization.

This commit is contained in:
Henri Verbeet 2010-02-02 12:06:57 +01:00 committed by Alexandre Julliard
parent fb21551b2d
commit cee8e9d881
4 changed files with 16 additions and 21 deletions

View File

@ -6924,7 +6924,7 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
for (i = 0; i < PATCHMAP_SIZE; ++i) list_init(&device->patches[i]);
select_shader_mode(&adapter->gl_info, &device->ps_selected_mode, &device->vs_selected_mode);
device->shader_backend = select_shader_backend(adapter, device_type);
device->shader_backend = adapter->shader_backend;
memset(&shader_caps, 0, sizeof(shader_caps));
device->shader_backend->shader_get_caps(device_type, &adapter->gl_info, &shader_caps);

View File

@ -1645,6 +1645,16 @@ static const struct fragment_pipeline *select_fragment_implementation(struct win
else return &ffp_fragment_pipeline;
}
static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter)
{
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;
}
/* Context activation is done by the caller. */
static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
{
@ -2084,6 +2094,7 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
LEAVE_GL();
adapter->fragment_pipe = select_fragment_implementation(adapter);
adapter->shader_backend = select_shader_backend(adapter);
/* In some cases the number of texture stages can be larger than the number
* of samplers. The GF4 for example can use only 2 samplers (no fragment
@ -2990,7 +3001,6 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter,
WINED3DDEVTYPE DeviceType, const struct GlPixelFormatDesc *format_desc)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;
const shader_backend_t *shader_backend;
switch (format_desc->format)
{
@ -3068,8 +3078,7 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter,
/* Ask the shader backend if it can deal with the conversion. If
* we've got a GL extension giving native support this will be an
* identity conversion. */
shader_backend = select_shader_backend(adapter, DeviceType);
if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup))
if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
@ -3185,8 +3194,7 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter,
if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC]
|| gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC])
{
shader_backend = select_shader_backend(adapter, DeviceType);
if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup)
if (adapter->shader_backend->shader_color_fixup_supported(format_desc->color_fixup)
&& adapter->fragment_pipe->color_fixup_supported(format_desc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n");
@ -3826,7 +3834,6 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
int ps_selected_mode;
struct shader_caps shader_caps;
struct fragment_caps fragment_caps;
const shader_backend_t *shader_backend;
DWORD ckey_caps, blit_caps, fx_caps;
TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps);
@ -4203,8 +4210,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
pCaps->VertexTextureFilterCaps = 0;
memset(&shader_caps, 0, sizeof(shader_caps));
shader_backend = select_shader_backend(adapter, DeviceType);
shader_backend->shader_get_caps(DeviceType, &adapter->gl_info, &shader_caps);
adapter->shader_backend->shader_get_caps(DeviceType, &adapter->gl_info, &shader_caps);
memset(&fragment_caps, 0, sizeof(fragment_caps));
adapter->fragment_pipe->get_caps(DeviceType, &adapter->gl_info, &fragment_caps);

View File

@ -2841,16 +2841,6 @@ void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected,
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 blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE device_type)
{
const struct wined3d_gl_info *gl_info = &adapter->gl_info;

View File

@ -1364,6 +1364,7 @@ struct wined3d_adapter
LUID luid;
const struct fragment_pipeline *fragment_pipe;
const shader_backend_t *shader_backend;
};
BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor) DECLSPEC_HIDDEN;
@ -2570,8 +2571,6 @@ 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 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 {