[PATCH] WineD3D: Start the state splitup=0A=

Stefan Doesinger stefan at codeweavers.com
Tue Jul 1 18:23:44 CDT 2008


=0A=
The idea of this patchset is to split the monolithic state set into 3 =
parts, vertex processing, fragment processing and=0A=
other states(depth, stencil, scissor, ...). The states will be provided =
in templates which can be (mostly)=0A=
independently combined, and are merged into a single state table at =
device creation time. This way we retain the=0A=
advantages of the single state table and having the advantage of =
separated pipeline implementations which can be=0A=
combined without any manually written glue code=0A=
---=0A=
 dlls/wined3d/ati_fragment_shader.c |    2 +-=0A=
 dlls/wined3d/context.c             |    8 ++++----=0A=
 dlls/wined3d/device.c              |    4 ++--=0A=
 dlls/wined3d/directx.c             |    2 ++=0A=
 dlls/wined3d/state.c               |   11 +++++++++--=0A=
 dlls/wined3d/wined3d_private.h     |    4 +++-=0A=
 6 files changed, 21 insertions(+), 10 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/ati_fragment_shader.c =
b/dlls/wined3d/ati_fragment_shader.c=0A=
index 99f1fd4..8377917 100644=0A=
--- a/dlls/wined3d/ati_fragment_shader.c=0A=
+++ b/dlls/wined3d/ati_fragment_shader.c=0A=
@@ -859,7 +859,7 @@ struct StateEntry ATIFSStateTable[STATE_HIGHEST + 1];=0A=
 static void init_state_table() {=0A=
     unsigned int i;=0A=
     const DWORD rep =3D STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP);=0A=
-    memcpy(ATIFSStateTable, arb_program_shader_backend.StateTable, =
sizeof(ATIFSStateTable));=0A=
+    memcpy(ATIFSStateTable, =
arb_program_shader_backend.StateTable_remove, sizeof(ATIFSStateTable));=0A=
 =0A=
     for(i =3D 0; i < MAX_TEXTURES; i++) {=0A=
         ATIFSStateTable[STATE_TEXTURESTAGE(i, =
WINED3DTSS_COLOROP)].apply =3D set_tex_op_atifs;=0A=
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c=0A=
index 6f5424c..b09707b 100644=0A=
--- a/dlls/wined3d/context.c=0A=
+++ b/dlls/wined3d/context.c=0A=
@@ -102,7 +102,7 @@ static WineD3DContext =
*AddContextToArray(IWineD3DDeviceImpl *This, HWND win_hand=0A=
     /* Mark all states dirty to force a proper initialization of the =
states on the first use of the context=0A=
      */=0A=
     for(state =3D 0; state <=3D STATE_HIGHEST; state++) {=0A=
-        Context_MarkStateDirty(This->contexts[This->numContexts], =
state, This->shader_backend->StateTable);=0A=
+        Context_MarkStateDirty(This->contexts[This->numContexts], =
state, This->StateTable);=0A=
     }=0A=
 =0A=
     This->numContexts++;=0A=
@@ -641,7 +641,7 @@ static inline void set_blit_dimension(UINT width, =
UINT height) {=0A=
  =
*************************************************************************=
****/=0A=
 static inline void SetupForBlit(IWineD3DDeviceImpl *This, =
WineD3DContext *context, UINT width, UINT height) {=0A=
     int i;=0A=
-    const struct StateEntry *StateTable =3D =
This->shader_backend->StateTable;=0A=
+    const struct StateEntry *StateTable =3D This->StateTable;=0A=
 =0A=
     TRACE("Setting up context %p for blitting\n", context);=0A=
     if(context->last_was_blit) {=0A=
@@ -836,7 +836,7 @@ static inline WineD3DContext =
*FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf=0A=
     BOOL oldRenderOffscreen =3D This->render_offscreen;=0A=
     const WINED3DFORMAT oldFmt =3D ((IWineD3DSurfaceImpl *) =
This->lastActiveRenderTarget)->resource.format;=0A=
     const WINED3DFORMAT newFmt =3D ((IWineD3DSurfaceImpl *) =
target)->resource.format;=0A=
-    const struct StateEntry *StateTable =3D =
This->shader_backend->StateTable;=0A=
+    const struct StateEntry *StateTable =3D This->StateTable;=0A=
 =0A=
     /* To compensate the lack of format switching with some offscreen =
rendering methods and on onscreen buffers=0A=
      * the alpha blend state changes with different render target =
formats=0A=
@@ -1034,7 +1034,7 @@ void ActivateContext(IWineD3DDeviceImpl *This, =
IWineD3DSurface *target, ContextU=0A=
     BYTE                          shift;=0A=
     WineD3DContext                *context;=0A=
     GLint                         drawBuffer=3D0;=0A=
-    const struct StateEntry       *StateTable =3D =
This->shader_backend->StateTable;=0A=
+    const struct StateEntry       *StateTable =3D This->StateTable;=0A=
 =0A=
     TRACE("(%p): Selecting context for render target %p, thread %d\n", =
This, target, tid);=0A=
     if(This->lastActiveRenderTarget !=3D target || tid !=3D =
This->lastThread) {=0A=
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c=0A=
index 26c1c9c..74bb676 100644=0A=
--- a/dlls/wined3d/device.c=0A=
+++ b/dlls/wined3d/device.c=0A=
@@ -4507,7 +4507,7 @@ static HRESULT WINAPI =
IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if=0A=
     }=0A=
 =0A=
     if(Stage > This->stateBlock->lowest_disabled_stage &&=0A=
-       This->shader_backend->StateTable[STATE_TEXTURESTAGE(0, =
Type)].representative =3D=3D STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP)) {=0A=
+       This->StateTable[STATE_TEXTURESTAGE(0, Type)].representative =
=3D=3D STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP)) {=0A=
         /* Colorop change above lowest disabled stage? That won't =
change anything in the gl setup=0A=
          * Changes in other states are important on disabled stages too=0A=
          */=0A=
@@ -7977,7 +7977,7 @@ const DWORD =
SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S] =3D {=0A=
 };=0A=
 =0A=
 void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD =
state) {=0A=
-    DWORD rep =3D =
This->shader_backend->StateTable[state].representative;=0A=
+    DWORD rep =3D This->StateTable[state].representative;=0A=
     DWORD idx;=0A=
     BYTE shift;=0A=
     UINT i;=0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index 8811d0a..f121cde 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -3446,6 +3446,8 @@ static HRESULT  WINAPI =
IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,=0A=
     select_shader_mode(&GLINFO_LOCATION, DeviceType, =
&object->ps_selected_mode, &object->vs_selected_mode);=0A=
     object->shader_backend =3D select_shader_backend(Adapter, =
DeviceType);=0A=
 =0A=
+    compile_state_table(object->StateTable, =
object->shader_backend->StateTable_remove);=0A=
+=0A=
     /* Prefer the vtable with functions optimized for single =
dirtifyable objects if the shader=0A=
      * model can deal with that. It is essentially the same, just with =
adjusted=0A=
      * Set*ShaderConstantF implementations=0A=
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c=0A=
index 1fc1309..94a27fa 100644=0A=
--- a/dlls/wined3d/state.c=0A=
+++ b/dlls/wined3d/state.c=0A=
@@ -446,7 +446,7 @@ static void state_blend(DWORD state, =
IWineD3DStateBlockImpl *stateblock, WineD3D=0A=
     /* colorkey fixup for stage 0 alphaop depends on =
WINED3DRS_ALPHABLENDENABLE state,=0A=
         so it may need updating */=0A=
     if (stateblock->renderState[WINED3DRS_COLORKEYENABLE]) {=0A=
-        const struct StateEntry *StateTable =3D =
stateblock->wineD3DDevice->shader_backend->StateTable;=0A=
+        const struct StateEntry *StateTable =3D =
stateblock->wineD3DDevice->StateTable;=0A=
         StateTable[STATE_TEXTURESTAGE(0, =
WINED3DTSS_ALPHAOP)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), =
stateblock, context);=0A=
     }=0A=
 }=0A=
@@ -496,7 +496,7 @@ static void state_alpha(DWORD state, =
IWineD3DStateBlockImpl *stateblock, WineD3D=0A=
     }=0A=
 =0A=
     if(enable_ckey || context->last_was_ckey) {=0A=
-        const struct StateEntry *StateTable =3D =
stateblock->wineD3DDevice->shader_backend->StateTable;=0A=
+        const struct StateEntry *StateTable =3D =
stateblock->wineD3DDevice->StateTable;=0A=
         StateTable[STATE_TEXTURESTAGE(0, =
WINED3DTSS_ALPHAOP)].apply(STATE_TEXTURESTAGE(0, WINED3DTSS_ALPHAOP), =
stateblock, context);=0A=
     }=0A=
     context->last_was_ckey =3D enable_ckey;=0A=
@@ -4885,3 +4885,10 @@ const struct StateEntry FFPStateTable[] =3D=0A=
     { /* STATE_MATERIAL                             */      =
STATE_RENDER(WINED3DRS_SPECULARENABLE),             =
state_specularenable},=0A=
     { /* STATE_FRONTFACE                            */      =
STATE_FRONTFACE,                                    frontface           =
},=0A=
 };=0A=
+=0A=
+/* Remove the temptable, but instead pass a fragment pipeline table, =
vertex pipeline and misc pipeline=0A=
+ * table in=0A=
+ */=0A=
+void compile_state_table(struct StateEntry *StateTable, const struct =
StateEntry *temptable) {=0A=
+    memcpy(StateTable, temptable, sizeof(*StateTable) * (STATE_HIGHEST =
+ 1));=0A=
+}=0A=
diff --git a/dlls/wined3d/wined3d_private.h =
b/dlls/wined3d/wined3d_private.h=0A=
index d1456d2..5e988df 100644=0A=
--- a/dlls/wined3d/wined3d_private.h=0A=
+++ b/dlls/wined3d/wined3d_private.h=0A=
@@ -302,7 +302,7 @@ typedef struct {=0A=
     void (*shader_get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info =
*gl_info, struct shader_caps *caps);=0A=
     void (*shader_dll_load_init)(void);=0A=
     void (*shader_fragment_enable)(IWineD3DDevice *iface, BOOL enable);=0A=
-    const struct StateEntry *StateTable;=0A=
+    const struct StateEntry *StateTable_remove; /* TODO: This has to go =
away */=0A=
 } shader_backend_t;=0A=
 =0A=
 extern const shader_backend_t atifs_shader_backend;=0A=
@@ -588,6 +588,7 @@ struct StateEntry=0A=
 =0A=
 /* "Base" state table */=0A=
 extern const struct StateEntry FFPStateTable[];=0A=
+void compile_state_table(struct StateEntry *StateTable, const struct =
StateEntry *temptable);=0A=
 =0A=
 /* The new context manager that should deal with onscreen and offscreen =
rendering */=0A=
 struct WineD3DContext {=0A=
@@ -812,6 +813,7 @@ struct IWineD3DDeviceImpl=0A=
     const shader_backend_t *shader_backend;=0A=
     hash_table_t *glsl_program_lookup;=0A=
     void *shader_priv;=0A=
+    struct StateEntry StateTable[STATE_HIGHEST + 1];=0A=
 =0A=
     /* To store */=0A=
     BOOL                    view_ident;        /* true iff view matrix =
is identity                */=0A=
-- =0A=
1.5.4.5=0A=
=0A=

------=_NextPart_000_005D_01C8E026.9C812EB0--




More information about the wine-patches mailing list