Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
9928a4c4
Commit
9928a4c4
authored
17 years ago
by
Stefan Dösinger
Committed by
Alexandre Julliard
17 years ago
Browse files
Options
Downloads
Patches
Plain Diff
wined3d: Offscreen rendering from foreign threads.
parent
f13f4887
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/wined3d/context.c
+44
-21
44 additions, 21 deletions
dlls/wined3d/context.c
with
44 additions
and
21 deletions
dlls/wined3d/context.c
+
44
−
21
View file @
9928a4c4
...
...
@@ -628,6 +628,27 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
}
}
/*****************************************************************************
* findThreadContextForSwapChain
*
* Searches a swapchain for all contexts and picks one for the thread tid.
* If none can be found the swapchain is requested to create a new context
*
*****************************************************************************/
static
WineD3DContext
*
findThreadContextForSwapChain
(
IWineD3DSwapChain
*
swapchain
,
DWORD
tid
)
{
int
i
;
for
(
i
=
0
;
i
<
((
IWineD3DSwapChainImpl
*
)
swapchain
)
->
num_contexts
;
i
++
)
{
if
(((
IWineD3DSwapChainImpl
*
)
swapchain
)
->
context
[
i
]
->
tid
==
tid
)
{
return
((
IWineD3DSwapChainImpl
*
)
swapchain
)
->
context
[
i
];
}
}
/* Create a new context for the thread */
return
IWineD3DSwapChainImpl_CreateContextForThread
(
swapchain
);
}
/*****************************************************************************
* ActivateContext
*
...
...
@@ -660,17 +681,8 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
if
(
hr
==
WINED3D_OK
&&
swapchain
)
{
TRACE
(
"Rendering onscreen
\n
"
);
context
=
NULL
;
for
(
i
=
0
;
i
<
((
IWineD3DSwapChainImpl
*
)
swapchain
)
->
num_contexts
;
i
++
)
{
if
(((
IWineD3DSwapChainImpl
*
)
swapchain
)
->
context
[
i
]
->
tid
==
tid
)
{
context
=
((
IWineD3DSwapChainImpl
*
)
swapchain
)
->
context
[
i
];
}
}
context
=
findThreadContextForSwapChain
(
swapchain
,
tid
);
if
(
!
context
)
{
/* Create a new context for the thread */
context
=
IWineD3DSwapChainImpl_CreateContextForThread
(
swapchain
);
}
This
->
render_offscreen
=
FALSE
;
/* 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
...
...
@@ -685,6 +697,10 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
glDrawBuffer
(
GL_FRONT
);
checkGLcall
(
"glDrawBuffer(GL_FRONT)"
);
}
}
else
if
(
wined3d_settings
.
offscreen_rendering_mode
==
ORM_PBUFFER
)
{
if
(
This
->
pbufferContext
&&
tid
==
This
->
pbufferContext
->
tid
)
{
This
->
pbufferContext
->
tid
=
0
;
}
}
IWineD3DSwapChain_Release
(
swapchain
);
...
...
@@ -699,21 +715,20 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
TRACE
(
"Rendering offscreen
\n
"
);
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
)
{
case
ORM_FBO
:
/* FBOs do not need a different context. Stay with whatever context is active at the moment */
if
(
This
->
activeContext
)
{
if
(
This
->
activeContext
&&
tid
==
This
->
lastThread
)
{
context
=
This
->
activeContext
;
}
else
{
/* This may happen if the app jumps streight into offscreen rendering
* Start using the context of the primary swapchain
* Start using the context of the primary swapchain. tid == 0 is no problem
* for findThreadContextForSwapChain.
*
* Can also happen on thread switches - in that case findThreadContextForSwapChain
* is perfect to call.
*/
context
=
((
IWineD3D
SwapChain
Impl
*
)
This
->
swapchains
[
0
]
)
->
context
[
0
]
;
context
=
findThreadContextFor
SwapChain
(
This
->
swapchains
[
0
]
,
tid
)
;
}
break
;
...
...
@@ -738,6 +753,10 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
}
if
(
This
->
pbufferContext
)
{
if
(
This
->
pbufferContext
->
tid
!=
0
&&
This
->
pbufferContext
->
tid
!=
tid
)
{
FIXME
(
"The PBuffr context is only supported for one thread for now!
\n
"
);
}
This
->
pbufferContext
->
tid
=
tid
;
context
=
This
->
pbufferContext
;
break
;
}
else
{
...
...
@@ -748,13 +767,17 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
case
ORM_BACKBUFFER
:
/* Stay with the currently active context for back buffer rendering */
if
(
This
->
activeContext
)
{
if
(
This
->
activeContext
&&
tid
==
This
->
lastThread
)
{
context
=
This
->
activeContext
;
}
else
{
/* This may happen if the app jumps streight into offscreen rendering
* Start using the context of the primary swapchain
* Start using the context of the primary swapchain. tid == 0 is no problem
* for findThreadContextForSwapChain.
*
* Can also happen on thread switches - in that case findThreadContextForSwapChain
* is perfect to call.
*/
context
=
((
IWineD3D
SwapChain
Impl
*
)
This
->
swapchains
[
0
]
)
->
context
[
0
]
;
context
=
findThreadContextFor
SwapChain
(
This
->
swapchains
[
0
]
,
tid
)
;
}
glDrawBuffer
(
This
->
offscreenBuffer
);
checkGLcall
(
"glDrawBuffer(This->offscreenBuffer)"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment