Closed Bug 1379413 Opened 2 years ago Closed 2 years ago

Use a run-time test for constant buffer offsetting

Categories

(Core :: Graphics: Layers, enhancement)

40 Branch
enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla56
Tracking Status
firefox56 --- fixed

People

(Reporter: dvander, Assigned: dvander)

References

Details

(Whiteboard: [gfx-noted])

Attachments

(2 files)

Right now we allow constant buffer offsetting on Windows 8 only if the driver says it supports it. We assume Windows 7 doesn't support it, due to comments from NVIDIA and hints on MSDN.

Unfortunately even Windows 8 and 10 are not perfect. Intel HD Graphics 2/3xxx report true for this feature, but are broken: binding buffer offsets to multiple slots does not work. We've also seen NVIDIA bugs on our own infrastructure where leaving an offset-based slot bound too long causes the driver to stop drawing.

Rather than try to blacklist all the quirks or devices with quirks, I'd like to do a simple runtime test when we initialize the device.
This creates a 2x2 texture and tries to render a color to it by reading from registers. Each register is bound to a different offset from the same buffer. If it doesn't work, we disable ID3D11DeviceContext1::[V|P]SSetConstantBuffers1.
Attachment #8884675 - Flags: review?(bas)
I'd like to report when this fails in about:support. We added a way to do this a while ago via gfxConfig, but we never actually used it for anything. The mechanism is an enumerated list of flags called "fallbacks" that can be toggled on, with an optional message. When toggled they show up in the Graphics section of about:support.

It still appears to work, despite never being used, it just needed some IPDL help to work with the GPU process.

These flags are not automatically added to Telemetry, so I stuck a bit in the "advancedLayers" object of the telemetry environment.
Attachment #8884676 - Flags: review?(bas)
Where did you read these microsoft hints at?

VSSetConstantBuffers and PSSetConstantBuffers were made mandatory in 11.1 but are optional under 11, and both are available on windows 7 with the platform update.

If nvidia is claiming no support then they can rightly fix the driver.
Attachment #8884675 - Flags: review?(bas) → review+
Comment on attachment 8884676 [details] [diff] [review]
part 2, report failures

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

Great stuff. I would really like to see data on this.

::: gfx/ipc/GfxMessageUtils.h
@@ +232,5 @@
>  template <>
> +struct ParamTraits<mozilla::gfx::Fallback>
> +  : public ContiguousEnumSerializer<
> +             mozilla::gfx::Fallback,
> +             mozilla::gfx::Fallback::NO_CONSTANT_BUFFER_OFFSETTING,

I hate that we have to have the enum values duplicated here :s.
Attachment #8884676 - Flags: review?(bas) → review+
(In reply to Danial Horton from comment #3)
> Where did you read these microsoft hints at?
> 
> VSSetConstantBuffers and PSSetConstantBuffers were made mandatory in 11.1
> but are optional under 11, and both are available on windows 7 with the
> platform update.
> 
> If nvidia is claiming no support then they can rightly fix the driver.

It's very confusing to me. The feature is probably mandatory under D3D_FEATURE_LEVEL_11_1, but you can't requested that level on Windows 7. The docs claim it is always supported on D3D_FEATURE_LEVEL_10_0+, but this is not true as my old Windows 8 laptop doesn't support it. NVIDIA [1] claims it is not reliable on Windows 7 but references an MSDN doc that doesn't mention Windows 7.

To make things more confusing, D3D11 allows you to query whether these features are supported, and that documentation says these features are always supported on 9.x feature levels due to emulation. But that would seem to imply it would always return true, since you can only check its status on the 11.1 API, and they claim 10.0 feature level supports it. Either way: it is definitely not supported on my ancient Windows 8 laptop.

Unfortunately no matter what, it's pretty unlikely that vendors will fix old bugs, much less get them backported to old drivers, and then manage to get those updates to users on old hardware. So we're stuck testing the hard way.

If you'd like, I have a standalone exe that tests all the aspects of this feature - you could run it on your Windows 7 machine and report back the results.

[1] https://developer.nvidia.com/content/constant-buffers-without-constant-pain-0
(In reply to Danial Horton from comment #3)
> Where did you read these microsoft hints at?
> 
> VSSetConstantBuffers and PSSetConstantBuffers were made mandatory in 11.1
> but are optional under 11, and both are available on windows 7 with the
> platform update.
> 
> If nvidia is claiming no support then they can rightly fix the driver.

it was VSSetConstantBuffers1 and PSSetConstantBuffers1 that i meant (oops)

These are exposed under windows 7 with the platform update (runtime level 11.1), but after a talk with a game developer friend overnight he also has confirmed it is extremely spotty on windows 7.
Pushed by danderson@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3cbaaeb4f8c2
Use a runtime test for constant buffer offsetting. (bug 1379413 part 1, r=bas)
https://hg.mozilla.org/integration/mozilla-inbound/rev/0b438dce0908
Report when constant buffer offsetting doesn't work. (bug 1379413 part 2, r=bas)
https://hg.mozilla.org/mozilla-central/rev/3cbaaeb4f8c2
https://hg.mozilla.org/mozilla-central/rev/0b438dce0908
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
See Also: → 1433696
You need to log in before you can comment on or make changes to this bug.