Open Bug 1403933 Opened 7 years ago Updated 2 years ago

Support standard swizzle in D3D11 texture

Categories

(Core :: Graphics: Layers, enhancement, P2)

54 Branch
enhancement

Tracking

()

Tracking Status
firefox57 --- fix-optional
firefox58 --- wontfix
firefox59 --- ?

People

(Reporter: jya, Unassigned, NeedInfo)

Details

(Keywords: feature, Whiteboard: [gfx-noted])

Attachments

(1 file, 1 obsolete file)

From discussing with AMD, we have performance issue with some media playback.

Their investigation pointed the problem to Firefox lack of use of standard swizzle

"the standard swizzle format is preferred when host CPU accesses to the surface are required alongside GPU accesses (e.g. host access shared surface).


I suspect that Firefox is creating a host shareable surface chain as render targets, to use both for SW decode and accelerated decode.

RS1 may have done a shadow surface with transparent blt from that shared surface to an AMD internal in the SW decode case, whereas on RS2 the shared surface is now directly accessible and used, but the runtime converts the format on the CPU and therefore suffers the perf hit. It may have been a combination of parameters gone wrong.

Supporting standard swizzle in the SW decode path on Firefox may be the solution here (and it may be the reason why the other browsers don't show the issue if they support that swizzle format directly or if their surface allocation strategy is different).

So if that hypothesis is correct, then that would explain the observed behavior.
"

We want to create the texture in D3D11 using ID3D11Device3::CreateTexture2D1 (if available, should be able to QI the device to the ‘3’ version to check)
and pass D3D11_TEXTURE_LAYOUT_64K_STANDARD_SWIZZLE for the TextureLayout parameter (as documented in https://msdn.microsoft.com/en-us/library/windows/desktop/dn899166(v=vs.85).aspx)

This feature should be available in D3D11.3
Keywords: feature
Priority: -- → P2
Whiteboard: [gfx-noted]
Matt, I'm a newbie under the (gfx/layers) code base and not sure whether the hacks in this patch is appropriate.  It would be appreciated if you can give me some feedback.  Thanks !
Attachment #8930811 - Flags: feedback?(matt.woodrow)
Comment on attachment 8930811 [details] [diff] [review]
Create D3D11 texture with standard swizzle layout if possible.

Review of attachment 8930811 [details] [diff] [review]:
-----------------------------------------------------------------

This looks, does it fix the performance issue that was reported?

Do you know how expensive the CheckFeatureSupport call is? We have similar code in D3D11Checks/DeviceManagerDx, so we could move the helper into that where we can do the checks on device creation and avoid needing to do it every frame.
Attachment #8930811 - Flags: feedback?(matt.woodrow) → feedback+
Thanks Matt,

I took your feedback and rewrite the patch which reduces the overhead of calling CheckFeatureSupport.

For now, I cannot verify it as there's no graphic cards supporting standard swizzle in the office.
For AMD, according to document [1], the feature should be supported by Vega architecture. I don't know which NV card has already supported it. As far as I can test, none of GTX 960M & GTX 1070 supports the feature.

[1] https://radeon.com/_downloads/vega-whitepaper-11.6.17.pdf


I'll request the device to verify and r? if it works.
Attachment #8930811 - Attachment is obsolete: true
(In reply to Kilik Kuo [:kikuo] from comment #3)
> For now, I cannot verify it as there's no graphic cards supporting standard
> swizzle in the office.

being called standard, aren't all cards supposed to support this?

AMD suggested using standard swizzle as that's what everyone else is doing, trying to explain the difference in performance seen in Firefox and other tools.

So shouldn't it indicate an issue in CheckFeatureSupport rather than the card not supporting it?
(In reply to Jean-Yves Avenard [:jya] from comment #4)
> (In reply to Kilik Kuo [:kikuo] from comment #3)
> > For now, I cannot verify it as there's no graphic cards supporting standard
> > swizzle in the office.
> 
> being called standard, aren't all cards supposed to support this?

The "D3D11_TEXTURE_LAYOUT_64K_STANDARD_SWIZZLE" is revealed in D3D11.3 (and D3D12).
It's a hardware feature. I believe that graphic card vendors may develop their own texture layout for optimization on their device.
But they also need to bridge the gap between this MS-defined API to their own implementations.

> 
> AMD suggested using standard swizzle as that's what everyone else is doing,
> trying to explain the difference in performance seen in Firefox and other
> tools.
> 
> So shouldn't it indicate an issue in CheckFeatureSupport rather than the
> card not supporting it?

Chromium doesn't call CheckFeatureSupport for texture layout capability either and I don't think that there's an issue in CheckFeatureSupport according to the HRESULT I got and the document I read.
Supporting standard swizzle might be a solution to the performance issues but there are still factors we are not sure about 
i.e. different surface allocation strategies.

I'll dig further though, any suggestions is appreciated
Assignee: nobody → kikuo
Hi Paul,

I tried to work on this bug and tested on an AMD VGA card, i.e. AMD R5-240.
A weird thing is even the HRESULT from ID3D11Device3::CheckFeatureSupport is S_OK, but the variable field "StandardSwizzle" from D3D11_FEATURE_DATA_D3D11_OPTIONS2 is always FALSE. It means that the hardware and driver don't support D3D11 standard swizzle.  The runtime should set this field to TRUE if the driver and hardware support.

I'm wondering if there's any specific SDK or driver I need to make it work.
Or do you know which AMD VGA card is able to support D3D11 standard swizzle ?
According to [1] page 11, it seems that only VEGA cards with feature level D3D12_1 supports, is that right ?


[1] https://radeon.com/_downloads/vega-whitepaper-11.6.17.pdf
Flags: needinfo?(paul.blinzer)
Assignee: kilik.kuo → nobody
Didn't see the needinfo request. Will check which cards support it. Seems that Swizzle support is exposed on the VEGA cards and in the Raven APUs right now for sure. However standard swizzle should be supported at other API levels and products too. 
Need to check what hardware supports it.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: