Commit c739c387 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Add a per context structure for context management.

parent 890f63a1
......@@ -1181,6 +1181,7 @@ void drawPrimitive(IWineD3DDevice *iface,
int i;
DWORD dirtyState, idx;
BYTE shift;
WineD3DContext *context;
/* Signals other modules that a drawing is in progress and the stateblock finalized */
This->isInDraw = TRUE;
......@@ -1197,13 +1198,16 @@ void drawPrimitive(IWineD3DDevice *iface,
/* Ok, we will be updating the screen from here onwards so grab the lock */
ENTER_GL();
/* TODO: Find the correct context for the render target / thread */
context = &This->contexts[This->activeContext];
/* Apply dirty states */
for(i=0; i < This->numDirtyEntries; i++) {
dirtyState = This->dirtyArray[i];
idx = dirtyState >> 5;
shift = dirtyState & 0x1f;
This->isStateDirty[idx] &= ~(1 << shift);
StateTable[dirtyState].apply(dirtyState, This->stateBlock);
StateTable[dirtyState].apply(dirtyState, This->stateBlock, context);
}
This->numDirtyEntries = 0; /* This makes the whole list clean */
......
......@@ -1169,8 +1169,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
per drawprim (and leave set - it will sort itself out due to last_was_rhw */
myDevice->last_was_rhw = TRUE;
/* Apply the projection and world matrices, it sets up orthogonal projection due to last_was_rhw */
StateTable[STATE_TRANSFORM(WINED3DTS_PROJECTION)].apply(STATE_TRANSFORM(WINED3DTS_PROJECTION), myDevice->stateBlock);
StateTable[STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))].apply(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), myDevice->stateBlock);
StateTable[STATE_TRANSFORM(WINED3DTS_PROJECTION)].apply(STATE_TRANSFORM(WINED3DTS_PROJECTION), myDevice->stateBlock, &myDevice->contexts[myDevice->activeContext]);
StateTable[STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))].apply(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), myDevice->stateBlock, &myDevice->contexts[myDevice->activeContext]);
/* Will reapply the projection matrix too */
IWineD3DDeviceImpl_MarkStateDirty(myDevice, STATE_VDECL);
......@@ -2497,8 +2497,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
*/
myDevice->last_was_rhw = TRUE;
/* Apply the projection matrix, it sets up orthogonal projection due to last_was_rhw */
StateTable[STATE_TRANSFORM(WINED3DTS_PROJECTION)].apply(STATE_TRANSFORM(WINED3DTS_PROJECTION), myDevice->stateBlock);
StateTable[STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))].apply(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), myDevice->stateBlock);
StateTable[STATE_TRANSFORM(WINED3DTS_PROJECTION)].apply(STATE_TRANSFORM(WINED3DTS_PROJECTION), myDevice->stateBlock, &myDevice->contexts[myDevice->activeContext]);
StateTable[STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0))].apply(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), myDevice->stateBlock, &myDevice->contexts[myDevice->activeContext]);
/* That will reapply the projection matrix too */
IWineD3DDeviceImpl_MarkStateDirty(myDevice, STATE_VDECL);
......
......@@ -405,8 +405,16 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
(((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
/* The new context manager that should deal with onscreen and offscreen rendering */
typedef struct WineD3DContext {
/* TODO: Dirty State list */
/* TODO: Render target / swapchain this ctx belongs to */
/* TODO: Thread this ctx belongs to */
/* TODO: Per context state chaches */
} WineD3DContext;
/* Routines and structures related to state management */
typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock);
typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *ctx);
#define STATE_RENDER(a) (a)
#define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
......@@ -511,7 +519,7 @@ typedef struct IWineD3DImpl
extern const IWineD3DVtbl IWineD3D_Vtbl;
/** Hacked out start of a context manager!! **/
/** Hacked out start of a context manager!! - Subject to removal **/
typedef struct glContext {
int Width;
int Height;
......@@ -639,7 +647,7 @@ typedef struct IWineD3DDeviceImpl
HRESULT state;
BOOL d3d_initialized;
/* Screen buffer resources */
/* Screen buffer resources - subject to removal */
glContext contextCache[CONTEXT_CACHE];
/* A flag to check for proper BeginScene / EndScene call pairs */
......@@ -681,6 +689,9 @@ typedef struct IWineD3DDeviceImpl
WineDirect3DVertexStridedData *up_strided;
BOOL useDrawStridedSlow;
/* Context management */
WineD3DContext contexts[1]; /* Dynamic array later */
UINT activeContext; /* Only 0 for now */
} IWineD3DDeviceImpl;
extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
......
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