mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
wined3d: Select onscreen contexts based on the thread id.
This commit is contained in:
parent
a1f83aae8e
commit
13f24c3808
3 changed files with 25 additions and 5 deletions
|
@ -312,6 +312,7 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
|
||||||
}
|
}
|
||||||
ret->surface = (IWineD3DSurface *) target;
|
ret->surface = (IWineD3DSurface *) target;
|
||||||
ret->isPBuffer = win == 0;
|
ret->isPBuffer = win == 0;
|
||||||
|
ret->tid = GetCurrentThreadId();
|
||||||
|
|
||||||
TRACE("Successfully created new context %p\n", ret);
|
TRACE("Successfully created new context %p\n", ret);
|
||||||
|
|
||||||
|
@ -641,7 +642,7 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextUsage usage) {
|
void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextUsage usage) {
|
||||||
DWORD tid = This->createParms.BehaviorFlags & WINED3DCREATE_MULTITHREADED ? GetCurrentThreadId() : 0;
|
DWORD tid = GetCurrentThreadId();
|
||||||
int i;
|
int i;
|
||||||
DWORD dirtyState, idx;
|
DWORD dirtyState, idx;
|
||||||
BYTE shift;
|
BYTE shift;
|
||||||
|
@ -650,7 +651,7 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
|
||||||
|
|
||||||
TRACE("(%p): Selecting context for render target %p, thread %d\n", This, target, tid);
|
TRACE("(%p): Selecting context for render target %p, thread %d\n", This, target, tid);
|
||||||
|
|
||||||
if(This->lastActiveRenderTarget != target) {
|
if(This->lastActiveRenderTarget != target || tid != This->lastThread) {
|
||||||
IWineD3DSwapChain *swapchain = NULL;
|
IWineD3DSwapChain *swapchain = NULL;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
BOOL readTexture = wined3d_settings.offscreen_rendering_mode != ORM_FBO && This->render_offscreen;
|
BOOL readTexture = wined3d_settings.offscreen_rendering_mode != ORM_FBO && This->render_offscreen;
|
||||||
|
@ -658,7 +659,18 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
|
||||||
hr = IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **) &swapchain);
|
hr = IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **) &swapchain);
|
||||||
if(hr == WINED3D_OK && swapchain) {
|
if(hr == WINED3D_OK && swapchain) {
|
||||||
TRACE("Rendering onscreen\n");
|
TRACE("Rendering onscreen\n");
|
||||||
context = ((IWineD3DSwapChainImpl *) swapchain)->context[0];
|
|
||||||
|
context = NULL;
|
||||||
|
for(i = 0; i < ((IWineD3DSwapChainImpl *) swapchain)->num_contexts; i++) {
|
||||||
|
if(((IWineD3DSwapChainImpl *) swapchain)->context[i]->tid == tid) {
|
||||||
|
context = ((IWineD3DSwapChainImpl *) swapchain)->context[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!context) {
|
||||||
|
/* TODO: Create a new context for the thread */
|
||||||
|
FIXME("Context creation for a new thread not implemented yet\n");
|
||||||
|
}
|
||||||
This->render_offscreen = FALSE;
|
This->render_offscreen = FALSE;
|
||||||
/* The context != This->activeContext will catch a NOP context change. This can occur
|
/* The context != This->activeContext will catch a NOP context change. This can occur
|
||||||
* if we are switching back to swapchain rendering in case of FBO or Back Buffer offscreen
|
* if we are switching back to swapchain rendering in case of FBO or Back Buffer offscreen
|
||||||
|
@ -682,10 +694,16 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
|
||||||
Context_MarkStateDirty(context, STATE_VDECL);
|
Context_MarkStateDirty(context, STATE_VDECL);
|
||||||
Context_MarkStateDirty(context, STATE_VIEWPORT);
|
Context_MarkStateDirty(context, STATE_VIEWPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
TRACE("Rendering offscreen\n");
|
TRACE("Rendering offscreen\n");
|
||||||
This->render_offscreen = TRUE;
|
This->render_offscreen = TRUE;
|
||||||
|
|
||||||
|
if(tid != This->lastThread) {
|
||||||
|
FIXME("Offscreen rendering is only supported from the creation thread yet\n");
|
||||||
|
FIXME("Expect a crash now ...\n");
|
||||||
|
}
|
||||||
|
|
||||||
switch(wined3d_settings.offscreen_rendering_mode) {
|
switch(wined3d_settings.offscreen_rendering_mode) {
|
||||||
case ORM_FBO:
|
case ORM_FBO:
|
||||||
/* FBOs do not need a different context. Stay with whatever context is active at the moment */
|
/* FBOs do not need a different context. Stay with whatever context is active at the moment */
|
||||||
|
|
|
@ -1851,6 +1851,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPR
|
||||||
}
|
}
|
||||||
IWineD3DSurface_AddRef(This->render_targets[0]);
|
IWineD3DSurface_AddRef(This->render_targets[0]);
|
||||||
This->activeContext = swapchain->context[0];
|
This->activeContext = swapchain->context[0];
|
||||||
|
This->lastThread = GetCurrentThreadId();
|
||||||
|
|
||||||
/* Depth Stencil support */
|
/* Depth Stencil support */
|
||||||
This->stencilBufferTarget = This->depthStencilBuffer;
|
This->stencilBufferTarget = This->depthStencilBuffer;
|
||||||
|
|
|
@ -736,8 +736,9 @@ struct IWineD3DDeviceImpl
|
||||||
|
|
||||||
/* Context management */
|
/* Context management */
|
||||||
WineD3DContext **contexts; /* Dynamic array containing pointers to context structures */
|
WineD3DContext **contexts; /* Dynamic array containing pointers to context structures */
|
||||||
WineD3DContext *activeContext; /* Only 0 for now */
|
WineD3DContext *activeContext;
|
||||||
UINT numContexts; /* Always 1 for now */
|
DWORD lastThread;
|
||||||
|
UINT numContexts;
|
||||||
WineD3DContext *pbufferContext; /* The context that has a pbuffer as drawable */
|
WineD3DContext *pbufferContext; /* The context that has a pbuffer as drawable */
|
||||||
DWORD pbufferWidth, pbufferHeight; /* Size of the buffer drawable */
|
DWORD pbufferWidth, pbufferHeight; /* Size of the buffer drawable */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue