Closed
Bug 1003293
Opened 11 years ago
Closed 11 years ago
OMTC bugs with Optimus and discrete GPU
Categories
(Core :: Graphics: Layers, defect)
Tracking
()
RESOLVED
FIXED
mozilla32
People
(Reporter: vlad, Assigned: vlad)
References
Details
Attachments
(2 files, 2 obsolete files)
909 bytes,
patch
|
bas.schouten
:
review+
|
Details | Diff | Splinter Review |
2.33 KB,
patch
|
vlad
:
review+
|
Details | Diff | Splinter Review |
STR:
1 - run Firefox, enable OMTC in profile
2 - In NVIDIA control panel, set the NVIDIA GPU as the preferred GPU
3 - rename firefox.exe to fx.exe
4 - run fx.exe (with OMTC profile)
Observe broken updates -- it looks like a synchronization issue, and likely on the Optimus side. Frames are painted to the window with portions of the frame black.
Video at: https://www.dropbox.com/s/eh4d4i28co0m47v/VID_20140429_132907.mp4
Assignee | ||
Comment 1•11 years ago
|
||
More data! Every few runs I get a frozen first frame, and a bunch of:
[564] WARNING: Failed to open shared texture: file c:\proj\moz\mozilla-central\gfx\layers\d3d11/TextureD3D11.cpp, line 307
[564] WARNING: failed to lock front buffer: file c:\proj\moz\mozilla-central\gfx\layers\composite/ImageHost.cpp, line 86
[564] ###!!! ASSERTION: Could not create texture: 'texture', file c:/proj/moz/mozilla-central/gfx/layers/d3d11/CompositorD3D11.cpp, line 435
etc. messages.
I also got a display driver reset warning for the Intel GPU at one point.
Are we somehow ending up in a mixed Intel-NVIDIA rendering situation? (More mixed than normal with Optimus, i.e. more than just the present happening on the intel gpu?)
Assignee | ||
Comment 2•11 years ago
|
||
When the above happens (the freeze and errors), I see this in the debugger output:
D3D11: Removing Device.
First-chance exception at 0x000007FEF4E9B7CC in fx.exe: Microsoft C++ exception: _com_error at memory location 0x000000A03283C798.
First-chance exception at 0x000007FEF4E9B7CC in fx.exe: Microsoft C++ exception: _com_error at memory location 0x000000A03283C798.
First-chance exception at 0x000007FEF4E9B7CC in fx.exe: Microsoft C++ exception: _com_error at memory location 0x000000A03283DF80.
...
The _com_errors are being thrown inside D3D, all from under this call in our code at CompositorD3D11.cpp line 638:
mDevice->CreateShaderResourceView(source->GetD3D11Texture(), nullptr, byRef(view));
Comment 3•11 years ago
|
||
(In reply to Vladimir Vukicevic [:vlad] [:vladv] from comment #2)
> When the above happens (the freeze and errors), I see this in the debugger
> output:
>
> D3D11: Removing Device.
> First-chance exception at 0x000007FEF4E9B7CC in fx.exe: Microsoft C++
> exception: _com_error at memory location 0x000000A03283C798.
> First-chance exception at 0x000007FEF4E9B7CC in fx.exe: Microsoft C++
> exception: _com_error at memory location 0x000000A03283C798.
> First-chance exception at 0x000007FEF4E9B7CC in fx.exe: Microsoft C++
> exception: _com_error at memory location 0x000000A03283DF80.
> ...
>
> The _com_errors are being thrown inside D3D, all from under this call in our
> code at CompositorD3D11.cpp line 638:
>
> mDevice->CreateShaderResourceView(source->GetD3D11Texture(), nullptr,
> byRef(view));
This is just indicative of a driver crash :(.
Fwiw, I don't see these display driver crashes on my machine, but we should probably work out 1. What's triggering them. and 2. How to deal with a driver crash more gracefully.
Assignee | ||
Comment 4•11 years ago
|
||
Razer Blade 14", intel 10.18.10.3412, nvidia 331.65. Updating to .3496 now.
Assignee | ||
Comment 5•11 years ago
|
||
I have not 100% confirmed this, but I think this actually has nothing to do with Optimus, it's just exacerbated by it.
Our compositor is using a D3D11 device. D2D uses/requires a D3D 10.1 device. Despite these being created on the same DXGI adapter, they are separate devices -- we have to explicitly synchronize any resources (textures) between the two, which we don't seem to do any of right now. And indeed, what I'm seeing looks exactly like synchronization problems.
See http://msdn.microsoft.com/en-us/library/windows/desktop/ee913554%28v=vs.85%29.aspx -- "Synchronized Shared Surfaces"
And the thread at http://www.gamedev.net/topic/547920-how-to-use-d2d-with-d3d11/?view=findpost&p=4529618
IMO, this needs to block OMTC on Windows.
Flags: needinfo?(msreckovic)
Comment 6•11 years ago
|
||
Sorry, needinfo went to "wrong" account (milan@mozilla.com is the "right" one), so I didn't see it.
Blocks: 899785
Updated•11 years ago
|
Flags: needinfo?(msreckovic)
Comment 7•11 years ago
|
||
(In reply to Vladimir Vukicevic [:vlad] [:vladv] from comment #5)
> I have not 100% confirmed this, but I think this actually has nothing to do
> with Optimus, it's just exacerbated by it.
>
> Our compositor is using a D3D11 device. D2D uses/requires a D3D 10.1
> device. Despite these being created on the same DXGI adapter, they are
> separate devices -- we have to explicitly synchronize any resources
> (textures) between the two, which we don't seem to do any of right now. And
> indeed, what I'm seeing looks exactly like synchronization problems.
>
> See
> http://msdn.microsoft.com/en-us/library/windows/desktop/ee913554%28v=vs.
> 85%29.aspx -- "Synchronized Shared Surfaces"
> And the thread at
> http://www.gamedev.net/topic/547920-how-to-use-d2d-with-d3d11/
> ?view=findpost&p=4529618
>
> IMO, this needs to block OMTC on Windows.
Hmm? We create our D2D surfaces on a dedicated D3D 10.1 adapter created for the client side, see:
http://mxr.mozilla.org/mozilla-central/source/gfx/layers/d3d11/TextureD3D11.cpp#232
Our -compositor- uses D3D11, and we synchronize with that here:
Client: http://mxr.mozilla.org/mozilla-central/source/gfx/layers/d3d11/TextureD3D11.cpp#179
Host: http://mxr.mozilla.org/mozilla-central/source/gfx/layers/d3d11/TextureD3D11.cpp#317
So all the synchronization should be happening as required.
Flags: needinfo?(vladimir)
Assignee | ||
Comment 8•11 years ago
|
||
Hmm, quite. Right now we create a D3D10 Texture, and then open its share handle from the D3D11 device. Bas and I talked about trying to do the opposite; I'll give this a shot and report back.
Assignee | ||
Comment 9•11 years ago
|
||
(In reply to Vladimir Vukicevic [:vlad] [:vladv] from comment #8)
> Hmm, quite. Right now we create a D3D10 Texture, and then open its share
> handle from the D3D11 device. Bas and I talked about trying to do the
> opposite; I'll give this a shot and report back.
This totally works. No rendering artifacts. Attached is the patch I used; it's a little hacky, but it works.
Cleaner would be to pass the D3DTexture11 to the compositor directly instead of passing it as a shared handle, and have TextureClientD3D11 keep around both the D3D10 and D3D11 texture.
But worst case we can put this behind IsOptimus for now, as Bas suggested; but it feels like we should just do this everywhere.
Flags: needinfo?(vladimir)
Comment 10•11 years ago
|
||
(In reply to Vladimir Vukicevic [:vlad] [:vladv] from comment #9)
> Created attachment 8420670 [details] [diff] [review]
> (prototype) create texture using D3D11
>
> (In reply to Vladimir Vukicevic [:vlad] [:vladv] from comment #8)
> > Hmm, quite. Right now we create a D3D10 Texture, and then open its share
> > handle from the D3D11 device. Bas and I talked about trying to do the
> > opposite; I'll give this a shot and report back.
>
> This totally works. No rendering artifacts. Attached is the patch I used;
> it's a little hacky, but it works.
>
> Cleaner would be to pass the D3DTexture11 to the compositor directly instead
> of passing it as a shared handle, and have TextureClientD3D11 keep around
> both the D3D10 and D3D11 texture.
>
> But worst case we can put this behind IsOptimus for now, as Bas suggested;
> but it feels like we should just do this everywhere.
I'm concerned about paying the cost of two texture creations on the Client thread instead of one. So I'm all for taking this approach, but I would like to see it behind IsOptimus until we can come up with something better (I bet if we use D3D11 on both sides we might be fine, which we should start doing fairly soon with D2D 1.1). There's also the fact that on a lot of drivers texture creation grabs a lock which could cause blocking of the compositor thread (http://msdn.microsoft.com/en-us/library/windows/desktop/ff476130%28v=vs.85%29.aspx), briefly, but for no good reason.
Assignee | ||
Comment 11•11 years ago
|
||
So it turns out the bug here isn't about D3D11/D3D10 synchronization, but it's about IsOptimus() and DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE.
IsOptimus() seemed to be broken -- the module on my system that was actually loaded is nvumdshimx.dll, even though I only have nvumdshim.dll in system32. I suspect the NV driver is moving things into place, or maybe this is because it's 64-bit. Regardless, this fixes IsOptimus, and with that fix, this corruption goes away; we should take this patch.
But, two questions come up.. First, given that the d3d11/d3d10 texture creation thing *also* fixes things even when FLAG_GDI_COMPATIBLE is used, does that change any of our decisions around that flag? Second, the dropdown issue only appears with circa-2010 drivers (or maybe older hardware?). Should we change that flag usage to just set it on older drivers, and leave it to 0 on modern hardware? I don't think we -want- DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE.
Assignee: nobody → vladimir
Attachment #8420670 -
Attachment is obsolete: true
Attachment #8421169 -
Flags: review?(jmuizelaar)
Attachment #8421169 -
Flags: review?(bas)
Assignee | ||
Comment 12•11 years ago
|
||
This is an alternative approach... IsOptimus can then go away.
Attachment #8421177 -
Flags: review?(bas)
Comment 13•11 years ago
|
||
Comment on attachment 8421169 [details] [diff] [review]
Fix IsOptimus()
Review of attachment 8421169 [details] [diff] [review]:
-----------------------------------------------------------------
They're valid questions, if we can easily dump it I'm in favor, I'm not too interested in jumping through too many hoops though :-).
Attachment #8421169 -
Flags: review?(bas) → review+
Comment 14•11 years ago
|
||
Comment on attachment 8421177 [details] [diff] [review]
Alternatively, nuke the GDI_COMPAT flag always
Review of attachment 8421177 [details] [diff] [review]:
-----------------------------------------------------------------
Don't we still want it for the client-side-D3D11-creation code?
Comment 15•11 years ago
|
||
This makes us also nuke the flag when resizing the window.
Attachment #8421177 -
Attachment is obsolete: true
Attachment #8421177 -
Flags: review?(bas)
Updated•11 years ago
|
Attachment #8423434 -
Flags: review?(vladimir)
Assignee | ||
Comment 16•11 years ago
|
||
Comment on attachment 8423434 [details] [diff] [review]
Nuke the GDI_COMPAT flag v2
Looks good, please land the IsOptimus fix as well (even though we won't use it anywhere after this, leaving it broken is a footgun though)
Attachment #8423434 -
Flags: review?(vladimir) → review+
Comment 17•11 years ago
|
||
Comment 18•11 years ago
|
||
Comment 19•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/a1bd40106a99
https://hg.mozilla.org/mozilla-central/rev/812ba047a9af
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in
before you can comment on or make changes to this bug.
Description
•