Use a single D3D9 device for all LayerManagers

RESOLVED FIXED

Status

()

Core
Graphics
RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: bas, Assigned: bas)

Tracking

unspecified
x86
Windows 7
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(blocking2.0 beta5+)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

8 years ago
We need to use a single IDirect3DDevice9 for all LayerManagerD3D9's. I've created a test application and verified that the approach I'm planning on taking works on all platforms. The single D3D9 device will make it a lot easier to move image layers between managers. And it will also allow ANGLE to more easily work within several windows.

The approach will look as follows:

- Every IDirect3DDevice9 has an implicit swap chain and is bound to a focus window. This implicit swap chain will be 1x1 and be bound to an invisible window.
- Every LayerManagerD3D9 will use IDirect3DDevice9::CreateAdditionalSwapChain to create its own swap chain.
- On device resets the device will be reset and all swap chains will need to be released and re-created.
- On a window resize the swap chain will need to be released and recreated for that window.

Two new classes are planned:

DeviceManagerD3D9 - This class will manage the one D3D9 device. The main relevant method here will be:
SwapChainD3D9 *CreateSwapChain(HWND hWnd);

SwapChainD3D9 - This will be a per LayerManager class and it will expose a Resize method. For device resets the DeviceManagerD3D9 will keep track of all swap chains and recreate them upon device reset, trying to minimize involvement of layer managers.
Sounds great!

> - On a window resize the swap chain will need to be released and recreated for
> that window.

Do we get the resizing behaviour for free for the default swap chain?  Or is this no different than what we have now?  I'm wondering what the impact of this recreation will be on live resize.
(Assignee)

Comment 2

8 years ago
(In reply to comment #1)
> Sounds great!
> 
> > - On a window resize the swap chain will need to be released and recreated for
> > that window.
> 
> Do we get the resizing behaviour for free for the default swap chain?  Or is
> this no different than what we have now?  I'm wondering what the impact of this
> recreation will be on live resize.

We need to do it manually now as well, we just use the Reset function. (Or ResetEx for D3D9Ex)
(Assignee)

Comment 3

8 years ago
Created attachment 463828 [details] [diff] [review]
Make all layer managers use a single device v1

This should do the trick! It depends on Bug 578384 which hasn't landed yet, since this fixes Windows Aero drawing.
Attachment #463828 - Flags: review?(vladimir)
(Assignee)

Comment 4

8 years ago
This is important for ANGLE to work right, and will make a bunch of other things easier.
blocking2.0: --- → ?
(Assignee)

Comment 5

8 years ago
Created attachment 463995 [details] [diff] [review]
Make all layer managers use a single device v2

Updated to use dont_AddRef() on D3D9Create, since the returned interface will be addrefed already.
Attachment #463828 - Attachment is obsolete: true
Attachment #463995 - Flags: review?(vladimir)
Attachment #463828 - Flags: review?(vladimir)
blocking2.0: ? → beta5+
Comment on attachment 463995 [details] [diff] [review]
Make all layer managers use a single device v2

Looks fine I think, the only comment I have is:

>-  mD3DManager->SetShaderMode(LayerManagerD3D9::RGBLAYER);
>+  mD3DManager->deviceManager()->SetShaderMode(DeviceManagerD3D9::RGBLAYER);

It would probably be better/cleaner for this to remain mD3DManager->SetShaderMode(), and have that be an inline function that forwards to deviceManager().  This looks like the main use of mD3DManager->deviceManager(), so would make code look a bit cleaner.
Attachment #463995 - Flags: review?(vladimir) → review+
Blocks: 581212
(Assignee)

Comment 7

8 years ago
Pushed http://hg.mozilla.org/mozilla-central/rev/abe6ec068676.
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED

Updated

8 years ago
Depends on: 586187

Updated

8 years ago
Depends on: 586279
You need to log in before you can comment on or make changes to this bug.