Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
b7935e51
Commit
b7935e51
authored
Nov 20, 2013
by
Jamie Madill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper handling of D3D9Ex device removed.
BUG=313210 Change-Id: I85dae10bc2ec38a1e9c09f318b8f6b9196466d60
parent
bf551589
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
26 deletions
+50
-26
Renderer9.cpp
src/libGLESv2/renderer/d3d9/Renderer9.cpp
+45
-26
Renderer9.h
src/libGLESv2/renderer/d3d9/Renderer9.h
+5
-0
No files found.
src/libGLESv2/renderer/d3d9/Renderer9.cpp
View file @
b7935e51
...
@@ -131,8 +131,6 @@ Renderer9::Renderer9(egl::Display *display, HDC hDc, bool softwareDevice) : Rend
...
@@ -131,8 +131,6 @@ Renderer9::Renderer9(egl::Display *display, HDC hDc, bool softwareDevice) : Rend
Renderer9
::~
Renderer9
()
Renderer9
::~
Renderer9
()
{
{
releaseDeviceResources
();
if
(
mDevice
)
if
(
mDevice
)
{
{
// If the device is lost, reset it first to prevent leaving the driver in an unstable state
// If the device is lost, reset it first to prevent leaving the driver in an unstable state
...
@@ -140,12 +138,19 @@ Renderer9::~Renderer9()
...
@@ -140,12 +138,19 @@ Renderer9::~Renderer9()
{
{
resetDevice
();
resetDevice
();
}
}
SafeRelease
(
mDevice
);
}
}
deinitialize
();
}
void
Renderer9
::
deinitialize
()
{
releaseDeviceResources
();
SafeRelease
(
mDevice
);
SafeRelease
(
mDeviceEx
);
SafeRelease
(
mDeviceEx
);
SafeRelease
(
mD3d9
);
SafeRelease
(
mD3d9
);
SafeRelease
(
mD3d9Ex
);
if
(
mDeviceWindow
)
if
(
mDeviceWindow
)
{
{
...
@@ -153,8 +158,6 @@ Renderer9::~Renderer9()
...
@@ -153,8 +158,6 @@ Renderer9::~Renderer9()
mDeviceWindow
=
NULL
;
mDeviceWindow
=
NULL
;
}
}
SafeRelease
(
mD3d9Ex
);
mD3d9Module
=
NULL
;
mD3d9Module
=
NULL
;
}
}
...
@@ -2095,22 +2098,8 @@ bool Renderer9::isDeviceLost()
...
@@ -2095,22 +2098,8 @@ bool Renderer9::isDeviceLost()
// set notify to true to broadcast a message to all contexts of the device loss
// set notify to true to broadcast a message to all contexts of the device loss
bool
Renderer9
::
testDeviceLost
(
bool
notify
)
bool
Renderer9
::
testDeviceLost
(
bool
notify
)
{
{
HRESULT
status
=
S_OK
;
HRESULT
status
=
getDeviceStatusCode
();
bool
isLost
=
(
FAILED
(
status
)
||
d3d9
::
isDeviceLostError
(
status
));
if
(
mDeviceEx
)
{
status
=
mDeviceEx
->
CheckDeviceState
(
NULL
);
}
else
if
(
mDevice
)
{
status
=
mDevice
->
TestCooperativeLevel
();
}
else
{
// No device yet, so no reset required
}
bool
isLost
=
FAILED
(
status
)
||
d3d9
::
isDeviceLostError
(
status
);
if
(
isLost
)
if
(
isLost
)
{
{
...
@@ -2129,7 +2118,7 @@ bool Renderer9::testDeviceLost(bool notify)
...
@@ -2129,7 +2118,7 @@ bool Renderer9::testDeviceLost(bool notify)
return
isLost
;
return
isLost
;
}
}
bool
Renderer9
::
testDeviceResettabl
e
()
HRESULT
Renderer9
::
getDeviceStatusCod
e
()
{
{
HRESULT
status
=
D3D_OK
;
HRESULT
status
=
D3D_OK
;
...
@@ -2142,9 +2131,14 @@ bool Renderer9::testDeviceResettable()
...
@@ -2142,9 +2131,14 @@ bool Renderer9::testDeviceResettable()
status
=
mDevice
->
TestCooperativeLevel
();
status
=
mDevice
->
TestCooperativeLevel
();
}
}
return
status
;
}
bool
Renderer9
::
testDeviceResettable
()
{
// On D3D9Ex, DEVICELOST represents a hung device that needs to be restarted
// On D3D9Ex, DEVICELOST represents a hung device that needs to be restarted
// DEVICEREMOVED indicates the device has been stopped and must be recreated
// DEVICEREMOVED indicates the device has been stopped and must be recreated
switch
(
status
)
switch
(
getDeviceStatusCode
()
)
{
{
case
D3DERR_DEVICENOTRESET
:
case
D3DERR_DEVICENOTRESET
:
case
D3DERR_DEVICEHUNG
:
case
D3DERR_DEVICEHUNG
:
...
@@ -2152,8 +2146,8 @@ bool Renderer9::testDeviceResettable()
...
@@ -2152,8 +2146,8 @@ bool Renderer9::testDeviceResettable()
case
D3DERR_DEVICELOST
:
case
D3DERR_DEVICELOST
:
return
(
mDeviceEx
!=
NULL
);
return
(
mDeviceEx
!=
NULL
);
case
D3DERR_DEVICEREMOVED
:
case
D3DERR_DEVICEREMOVED
:
UNIMPLEMENTED
(
);
ASSERT
(
mDeviceEx
!=
NULL
);
return
fals
e
;
return
tru
e
;
default
:
default
:
return
false
;
return
false
;
}
}
...
@@ -2168,14 +2162,23 @@ bool Renderer9::resetDevice()
...
@@ -2168,14 +2162,23 @@ bool Renderer9::resetDevice()
HRESULT
result
=
D3D_OK
;
HRESULT
result
=
D3D_OK
;
bool
lost
=
testDeviceLost
(
false
);
bool
lost
=
testDeviceLost
(
false
);
int
attempts
=
3
;
int
attempts
=
3
;
bool
removedDevice
=
(
getDeviceStatusCode
()
==
D3DERR_DEVICEREMOVED
);
while
(
lost
&&
attempts
>
0
)
while
(
lost
&&
attempts
>
0
)
{
{
if
(
mDeviceEx
)
if
(
mDeviceEx
)
{
{
Sleep
(
500
);
// Give the graphics driver some CPU time
Sleep
(
500
);
// Give the graphics driver some CPU time
if
(
removedDevice
)
{
result
=
resetRemovedDevice
();
}
else
{
result
=
mDeviceEx
->
ResetEx
(
&
presentParameters
,
NULL
);
result
=
mDeviceEx
->
ResetEx
(
&
presentParameters
,
NULL
);
}
}
}
else
else
{
{
result
=
mDevice
->
TestCooperativeLevel
();
result
=
mDevice
->
TestCooperativeLevel
();
...
@@ -2201,13 +2204,29 @@ bool Renderer9::resetDevice()
...
@@ -2201,13 +2204,29 @@ bool Renderer9::resetDevice()
return
false
;
return
false
;
}
}
// If the device was removed, we already finished re-initialization in resetRemovedDevice
if
(
!
removedDevice
)
{
// reset device defaults
// reset device defaults
initializeDevice
();
initializeDevice
();
}
mDeviceLost
=
false
;
mDeviceLost
=
false
;
return
true
;
return
true
;
}
}
HRESULT
Renderer9
::
resetRemovedDevice
()
{
// From http://msdn.microsoft.com/en-us/library/windows/desktop/bb172554(v=vs.85).aspx:
// The hardware adapter has been removed. Application must destroy the device, do enumeration of
// adapters and create another Direct3D device. If application continues rendering without
// calling Reset, the rendering calls will succeed. Applies to Direct3D 9Ex only.
ASSERT
(
mDeviceEx
!=
NULL
);
deinitialize
();
return
(
initialize
()
==
EGL_SUCCESS
?
S_OK
:
S_FALSE
);
}
DWORD
Renderer9
::
getAdapterVendor
()
const
DWORD
Renderer9
::
getAdapterVendor
()
const
{
{
return
mAdapterIdentifier
.
VendorId
;
return
mAdapterIdentifier
.
VendorId
;
...
...
src/libGLESv2/renderer/d3d9/Renderer9.h
View file @
b7935e51
...
@@ -233,6 +233,8 @@ class Renderer9 : public Renderer
...
@@ -233,6 +233,8 @@ class Renderer9 : public Renderer
private
:
private
:
DISALLOW_COPY_AND_ASSIGN
(
Renderer9
);
DISALLOW_COPY_AND_ASSIGN
(
Renderer9
);
void
deinitialize
();
void
applyUniformnfv
(
gl
::
Uniform
*
targetUniform
,
const
GLfloat
*
v
);
void
applyUniformnfv
(
gl
::
Uniform
*
targetUniform
,
const
GLfloat
*
v
);
void
applyUniformniv
(
gl
::
Uniform
*
targetUniform
,
const
GLint
*
v
);
void
applyUniformniv
(
gl
::
Uniform
*
targetUniform
,
const
GLint
*
v
);
void
applyUniformnbv
(
gl
::
Uniform
*
targetUniform
,
const
GLint
*
v
);
void
applyUniformnbv
(
gl
::
Uniform
*
targetUniform
,
const
GLint
*
v
);
...
@@ -252,6 +254,9 @@ class Renderer9 : public Renderer
...
@@ -252,6 +254,9 @@ class Renderer9 : public Renderer
D3DPRESENT_PARAMETERS
getDefaultPresentParameters
();
D3DPRESENT_PARAMETERS
getDefaultPresentParameters
();
void
releaseDeviceResources
();
void
releaseDeviceResources
();
HRESULT
getDeviceStatusCode
();
HRESULT
resetRemovedDevice
();
UINT
mAdapter
;
UINT
mAdapter
;
D3DDEVTYPE
mDeviceType
;
D3DDEVTYPE
mDeviceType
;
bool
mSoftwareDevice
;
// FIXME: Deprecate
bool
mSoftwareDevice
;
// FIXME: Deprecate
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment