From c15dfb87e9708f2ada3fc726e537107b02cfc874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Fri, 4 Jul 2008 15:01:26 -0500 Subject: [PATCH] wined3d: Create fragment processing state templates and select one. For now the atifs selection sticks to the old rules, thus it is bound to the available and selected shader capabilities. We may want to change that in the future. --- dlls/wined3d/ati_fragment_shader.c | 4 ++++ dlls/wined3d/directx.c | 19 ++++++++++++++++++- dlls/wined3d/state.c | 4 ++++ dlls/wined3d/wined3d_private.h | 2 ++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index 83779170a7c..adc88d61e17 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -893,6 +893,10 @@ static void init_state_table() { ATIFSStateTable[STATE_RENDER(WINED3DRS_TEXTUREFACTOR)].representative = STATE_RENDER(WINED3DRS_TEXTUREFACTOR); } +const struct StateEntryTemplate atifs_fragmentstate_template[] = { + {0 /* Terminate */, { 0, 0 }}, +}; + /* GL_ATI_fragment_shader backend.It borrows a lot from a the * ARB shader backend, currently the whole vertex processing * code. This code would also forward pixel shaders, but if diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index c1f68f8cf65..b4215196f4a 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2890,6 +2890,20 @@ static const shader_backend_t *select_shader_backend(UINT Adapter, WINED3DDEVTYP return ret; } +static const struct StateEntryTemplate *select_fragment_implementation(UINT Adapter, WINED3DDEVTYPE DeviceType) { + int vs_selected_mode; + int ps_selected_mode; + + select_shader_mode(&GLINFO_LOCATION, DeviceType, &ps_selected_mode, &vs_selected_mode); + if (ps_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_ARB) { + return ffp_fragmentstate_template; + } else if (ps_selected_mode != SHADER_NONE && !GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { + return atifs_fragmentstate_template; + } else { + return ffp_fragmentstate_template; + } +} + /* 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 */ @@ -3393,6 +3407,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, IWineD3DDeviceImpl *object = NULL; IWineD3DImpl *This = (IWineD3DImpl *)iface; WINED3DDISPLAYMODE mode; + const struct StateEntryTemplate *frag_pipeline = NULL; int i; /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter @@ -3446,8 +3461,10 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, select_shader_mode(&GLINFO_LOCATION, DeviceType, &object->ps_selected_mode, &object->vs_selected_mode); object->shader_backend = select_shader_backend(Adapter, DeviceType); + frag_pipeline = select_fragment_implementation(Adapter, DeviceType); + compile_state_table(object->StateTable, object->multistate_funcs, - ffp_vertexstate_template, NULL, misc_state_template, + ffp_vertexstate_template, frag_pipeline, misc_state_template, object->shader_backend->StateTable_remove); /* Prefer the vtable with functions optimized for single dirtifyable objects if the shader diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 2813d924739..60089cedb70 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -5246,6 +5246,10 @@ const struct StateEntryTemplate ffp_vertexstate_template[] = { {0 /* Terminate */, { 0, 0 }}, }; +const struct StateEntryTemplate ffp_fragmentstate_template[] = { + {0 /* Terminate */, { 0, 0 }}, +}; + static int num_handlers(APPLYSTATEFUNC *funcs) { unsigned int i; for(i = 0; funcs[i]; i++); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 706fdffcb8e..af0ee3bf16c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -595,6 +595,8 @@ struct StateEntryTemplate extern const struct StateEntryTemplate misc_state_template[]; extern const struct StateEntryTemplate ffp_vertexstate_template[]; +extern const struct StateEntryTemplate ffp_fragmentstate_template[]; +extern const struct StateEntryTemplate atifs_fragmentstate_template[]; /* "Base" state table */ extern const struct StateEntry FFPStateTable[];