[PATCH] WineD3D: Remove the atifs shader backend=0A=

Stefan Doesinger stefan at codeweavers.com
Thu Jul 10 10:52:43 CDT 2008


=0A=
Since atifs is only doing the fragment pipeline replacement=0A=
right now there is no need for the shader backend structure=0A=
any longer. The ffp private data is stored in new fragment=0A=
pipeline private data(which could potentially be set to=0A=
equal the shader private data if needed)=0A=
---=0A=
 dlls/wined3d/ati_fragment_shader.c |  104 =
++++++-----------------------------=0A=
 dlls/wined3d/device.c              |   13 +++++=0A=
 dlls/wined3d/directx.c             |    3 -=0A=
 dlls/wined3d/state.c               |    5 ++=0A=
 dlls/wined3d/wined3d_private.h     |    3 +=0A=
 5 files changed, 39 insertions(+), 89 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/ati_fragment_shader.c =
b/dlls/wined3d/ati_fragment_shader.c=0A=
index e4420f1..6fc0aa4 100644=0A=
--- a/dlls/wined3d/ati_fragment_shader.c=0A=
+++ b/dlls/wined3d/ati_fragment_shader.c=0A=
@@ -50,7 +50,6 @@ struct atifs_ffp_desc=0A=
 =0A=
 struct atifs_private_data=0A=
 {=0A=
-    struct shader_arb_priv parent;=0A=
     struct list fragment_shaders; /* A linked list to track fragment =
pipeline replacement shaders */=0A=
 =0A=
 };=0A=
@@ -782,7 +781,7 @@ static void set_tex_op_atifs(DWORD state, =
IWineD3DStateBlockImpl *stateblock, Wi=0A=
     IWineD3DDeviceImpl          *This =3D stateblock->wineD3DDevice;=0A=
     struct atifs_ffp_desc       *desc;=0A=
     struct texture_stage_op     op[MAX_TEXTURES];=0A=
-    struct atifs_private_data   *priv =3D (struct atifs_private_data *) =
This->shader_priv;=0A=
+    struct atifs_private_data   *priv =3D (struct atifs_private_data *) =
This->fragment_priv;=0A=
     DWORD mapped_stage;=0A=
     unsigned int i;=0A=
 =0A=
@@ -1019,64 +1018,24 @@ static void atifs_get_caps(WINED3DDEVTYPE =
devtype, WineD3D_GL_Info *gl_info, str=0A=
     caps->PrimitiveMiscCaps |=3D WINED3DPMISCCAPS_TSSARGTEMP;=0A=
 }=0A=
 =0A=
-const struct fragment_pipeline atifs_fragment_pipeline =3D {=0A=
-    atifs_enable,=0A=
-    atifs_get_caps,=0A=
-    atifs_fragmentstate_template=0A=
-};=0A=
-=0A=
-/* GL_ATI_fragment_shader backend.It borrows a lot from a the=0A=
- * ARB shader backend, currently the whole vertex processing=0A=
- * code. This code would also forward pixel shaders, but if=0A=
- * GL_ARB_fragment_program is supported, the atifs shader backend=0A=
- * is not used.=0A=
- */=0A=
-static void shader_atifs_select(IWineD3DDevice *iface, BOOL usePS, BOOL =
useVS) {=0A=
-    arb_program_shader_backend.shader_select(iface, usePS, useVS);=0A=
-}=0A=
-=0A=
-static void shader_atifs_select_depth_blt(IWineD3DDevice *iface) {=0A=
-    arb_program_shader_backend.shader_select_depth_blt(iface);=0A=
-}=0A=
-=0A=
-static void shader_atifs_deselect_depth_blt(IWineD3DDevice *iface) {=0A=
-    arb_program_shader_backend.shader_deselect_depth_blt(iface);=0A=
-}=0A=
-=0A=
-static void shader_atifs_load_constants(IWineD3DDevice *iface, char =
usePS, char useVS) {=0A=
-    arb_program_shader_backend.shader_load_constants(iface, usePS, =
useVS);=0A=
-}=0A=
-=0A=
-static void shader_atifs_cleanup(IWineD3DDevice *iface) {=0A=
-    arb_program_shader_backend.shader_cleanup(iface);=0A=
-}=0A=
-=0A=
-static void shader_atifs_color_correction(SHADER_OPCODE_ARG* arg) {=0A=
-    arb_program_shader_backend.shader_color_correction(arg);=0A=
-}=0A=
-=0A=
-static void shader_atifs_destroy(IWineD3DBaseShader *iface) {=0A=
-    arb_program_shader_backend.shader_destroy(iface);=0A=
-}=0A=
-=0A=
-static HRESULT shader_atifs_alloc(IWineD3DDevice *iface) {=0A=
+static HRESULT atifs_alloc(IWineD3DDevice *iface) {=0A=
     IWineD3DDeviceImpl *This =3D (IWineD3DDeviceImpl *) iface;=0A=
-    HRESULT hr;=0A=
     struct atifs_private_data *priv;=0A=
-    hr =3D arb_program_shader_backend.shader_alloc_private(iface);=0A=
-    if(FAILED(hr)) return hr;=0A=
 =0A=
-    This->shader_priv =3D HeapReAlloc(GetProcessHeap(), 0, =
This->shader_priv,=0A=
-                                    sizeof(struct atifs_private_data));=0A=
-    priv =3D (struct atifs_private_data *) This->shader_priv;=0A=
+    This->fragment_priv =3D HeapAlloc(GetProcessHeap(), =
HEAP_ZERO_MEMORY, sizeof(struct atifs_private_data));=0A=
+    if(!This->fragment_priv) {=0A=
+        ERR("Out of memory\n");=0A=
+        return E_OUTOFMEMORY;=0A=
+    }=0A=
+    priv =3D (struct atifs_private_data *) This->fragment_priv;=0A=
     list_init(&priv->fragment_shaders);=0A=
     return WINED3D_OK;=0A=
 }=0A=
 =0A=
 #define GLINFO_LOCATION This->adapter->gl_info=0A=
-static void shader_atifs_free(IWineD3DDevice *iface) {=0A=
+static void atifs_free(IWineD3DDevice *iface) {=0A=
     IWineD3DDeviceImpl *This =3D (IWineD3DDeviceImpl *) iface;=0A=
-    struct atifs_private_data *priv =3D (struct atifs_private_data *) =
This->shader_priv;=0A=
+    struct atifs_private_data *priv =3D (struct atifs_private_data *) =
This->fragment_priv;=0A=
     struct ffp_desc *entry, *entry2;=0A=
     struct atifs_ffp_desc *entry_ati;=0A=
 =0A=
@@ -1089,42 +1048,15 @@ static void shader_atifs_free(IWineD3DDevice =
*iface) {=0A=
         HeapFree(GetProcessHeap(), 0, entry);=0A=
     }=0A=
     LEAVE_GL();=0A=
-=0A=
-    /* Not actually needed, but revert what we've done before */=0A=
-    This->shader_priv =3D HeapReAlloc(GetProcessHeap(), 0, =
This->shader_priv,=0A=
-                                    sizeof(struct shader_arb_priv));=0A=
-    arb_program_shader_backend.shader_free_private(iface);=0A=
+    HeapFree(GetProcessHeap(), 0, priv);=0A=
+    This->fragment_priv =3D NULL;=0A=
 }=0A=
 #undef GLINFO_LOCATION=0A=
 =0A=
-static BOOL shader_atifs_dirty_const(IWineD3DDevice *iface) {=0A=
-    return =
arb_program_shader_backend.shader_dirtifyable_constants(iface);=0A=
-}=0A=
-=0A=
-static void shader_atifs_get_caps(WINED3DDEVTYPE devtype, =
WineD3D_GL_Info *gl_info, struct shader_caps *caps) {=0A=
-    arb_program_shader_backend.shader_get_caps(devtype, gl_info, caps);=0A=
-}=0A=
-=0A=
-static void shader_atifs_generate_pshader(IWineD3DPixelShader *iface, =
SHADER_BUFFER *buffer) {=0A=
-    ERR("Should not get here\n");=0A=
-}=0A=
-=0A=
-static void shader_atifs_generate_vshader(IWineD3DVertexShader *iface, =
SHADER_BUFFER *buffer) {=0A=
-    arb_program_shader_backend.shader_generate_vshader(iface, buffer);=0A=
-}=0A=
-=0A=
-const shader_backend_t atifs_shader_backend =3D {=0A=
-    shader_atifs_select,=0A=
-    shader_atifs_select_depth_blt,=0A=
-    shader_atifs_deselect_depth_blt,=0A=
-    shader_atifs_load_constants,=0A=
-    shader_atifs_cleanup,=0A=
-    shader_atifs_color_correction,=0A=
-    shader_atifs_destroy,=0A=
-    shader_atifs_alloc,=0A=
-    shader_atifs_free,=0A=
-    shader_atifs_dirty_const,=0A=
-    shader_atifs_generate_pshader,=0A=
-    shader_atifs_generate_vshader,=0A=
-    shader_atifs_get_caps,=0A=
+const struct fragment_pipeline atifs_fragment_pipeline =3D {=0A=
+    atifs_enable,=0A=
+    atifs_get_caps,=0A=
+    atifs_alloc,=0A=
+    atifs_free,=0A=
+    atifs_fragmentstate_template=0A=
 };=0A=
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c=0A=
index d25e1bc..00d4110 100644=0A=
--- a/dlls/wined3d/device.c=0A=
+++ b/dlls/wined3d/device.c=0A=
@@ -2131,6 +2131,11 @@ static HRESULT WINAPI =
IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPR=0A=
         TRACE("Shader private data couldn't be allocated\n");=0A=
         goto err_out;=0A=
     }=0A=
+    hr =3D This->frag_pipe->alloc_private(iface);=0A=
+    if(FAILED(hr)) {=0A=
+        TRACE("Fragment pipeline private data couldn't be allocated\n");=0A=
+        goto err_out;=0A=
+    }=0A=
 =0A=
     /* Set up some starting GL setup */=0A=
 =0A=
@@ -2198,6 +2203,7 @@ static HRESULT WINAPI =
IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPR=0A=
 =0A=
 err_out:=0A=
     This->shader_backend->shader_free_private(iface);=0A=
+    This->frag_pipe->free_private(iface);=0A=
     HeapFree(GetProcessHeap(), 0, This->render_targets);=0A=
     HeapFree(GetProcessHeap(), 0, This->fbo_color_attachments);=0A=
     HeapFree(GetProcessHeap(), 0, This->draw_buffers);=0A=
@@ -2284,6 +2290,7 @@ static HRESULT WINAPI =
IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, D3DCB_D=0A=
         This->depth_blt_rb_h =3D 0;=0A=
     }=0A=
     This->shader_backend->shader_free_private(iface);=0A=
+    This->frag_pipe->free_private(iface);=0A=
 =0A=
     /* Release the update stateblock */=0A=
     if(IWineD3DStateBlock_Release((IWineD3DStateBlock =
*)This->updateStateBlock) > 0){=0A=
@@ -7218,6 +7225,7 @@ static HRESULT WINAPI =
IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE=0A=
         This->depth_blt_rb_h =3D 0;=0A=
     }=0A=
     This->shader_backend->shader_free_private(iface);=0A=
+    This->frag_pipe->free_private(iface);=0A=
 =0A=
     for (i =3D 0; i < GL_LIMITS(textures); i++) {=0A=
         /* Textures are recreated below */=0A=
@@ -7326,6 +7334,11 @@ static HRESULT WINAPI =
IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE=0A=
         ERR("Failed to recreate shader private data\n");=0A=
         return hr;=0A=
     }=0A=
+    hr =3D This->frag_pipe->alloc_private(iface);=0A=
+    if(FAILED(hr)) {=0A=
+        TRACE("Fragment pipeline private data couldn't be allocated\n");=0A=
+        return hr;=0A=
+    }=0A=
 =0A=
     /* All done. There is no need to reload resources or shaders, this =
will happen automatically on the=0A=
      * first use=0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index 9992ee2..a88f443 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -2879,9 +2879,6 @@ static const shader_backend_t =
*select_shader_backend(UINT Adapter, WINED3DDEVTYP=0A=
     select_shader_mode(&GLINFO_LOCATION, DeviceType, &ps_selected_mode, =
&vs_selected_mode);=0A=
     if (vs_selected_mode =3D=3D SHADER_GLSL || ps_selected_mode =3D=3D =
SHADER_GLSL) {=0A=
         ret =3D &glsl_shader_backend;=0A=
-    } else if (vs_selected_mode =3D=3D SHADER_ARB && ps_selected_mode =
!=3D SHADER_NONE &&=0A=
-              !GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {=0A=
-        ret =3D &atifs_shader_backend;=0A=
     } else if (vs_selected_mode =3D=3D SHADER_ARB || ps_selected_mode =
=3D=3D SHADER_ARB) {=0A=
         ret =3D &arb_program_shader_backend;=0A=
     } else {=0A=
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c=0A=
index 0ea627c..3e45942 100644=0A=
--- a/dlls/wined3d/state.c=0A=
+++ b/dlls/wined3d/state.c=0A=
@@ -4534,11 +4534,16 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE =
devtype, WineD3D_GL_Info *gl_in=0A=
 =0A=
 }=0A=
 =0A=
+static HRESULT ffp_fragment_alloc(IWineD3DDevice *iface) { return =
WINED3D_OK; }=0A=
+static void ffp_fragment_free(IWineD3DDevice *iface) {}=0A=
+=0A=
 #undef GLINFO_LOCATION=0A=
 =0A=
 const struct fragment_pipeline ffp_fragment_pipeline =3D {=0A=
     nvts_enable,=0A=
     ffp_fragment_get_caps,=0A=
+    ffp_fragment_alloc,=0A=
+    ffp_fragment_free,=0A=
     ffp_fragmentstate_template=0A=
 };=0A=
 =0A=
diff --git a/dlls/wined3d/wined3d_private.h =
b/dlls/wined3d/wined3d_private.h=0A=
index 327a14f..d5352ea 100644=0A=
--- a/dlls/wined3d/wined3d_private.h=0A=
+++ b/dlls/wined3d/wined3d_private.h=0A=
@@ -551,6 +551,8 @@ struct fragment_caps {=0A=
 struct fragment_pipeline {=0A=
     void (*enable_extension)(IWineD3DDevice *iface, BOOL enable);=0A=
     void (*get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, =
struct fragment_caps *caps);=0A=
+    HRESULT (*alloc_private)(IWineD3DDevice *iface);=0A=
+    void (*free_private)(IWineD3DDevice *iface);=0A=
     const struct StateEntryTemplate *states;=0A=
 };=0A=
 =0A=
@@ -788,6 +790,7 @@ struct IWineD3DDeviceImpl=0A=
     int ps_selected_mode;=0A=
     const shader_backend_t *shader_backend;=0A=
     void *shader_priv;=0A=
+    void *fragment_priv;=0A=
     struct StateEntry StateTable[STATE_HIGHEST + 1];=0A=
     /* Array of functions for states which are handled by more than one =
pipeline part */=0A=
     APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];=0A=
-- =0A=
1.5.4.5=0A=
=0A=

------=_NextPart_000_0013_01C8E2A2.8F0AAD00--




More information about the wine-patches mailing list