Closed Bug 707563 Opened 13 years ago Closed 13 years ago

Intermediate surfaces change rendering of 3d transforms

Categories

(Core :: Graphics, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla11

People

(Reporter: mattwoodrow, Assigned: mattwoodrow)

References

Details

Attachments

(4 files, 1 obsolete file)

Attached file Reduced test case
When a 3d transformed layer is being drawn to a parent that requires an intermediate surface, the object is drawn incorrectly.

This is showing up in http://ikilote.net/Programmation/CSS/Test/transform-style.htm because the transformed layers have a ContainerLayer parent that requires an intermediate surface (due to opacity).

This only occurs in the accelerated layer managers, BasicLayers is unaffacted.

Reduced test case attached - requires a debugger. Set mUseIntermediateSurface = true in DefaultComputeEffectiveTransforms for the parent of the transformed layer, or use the debugging patch from bug 700240 (which sets this on every layer).
When drawn to an intermediate surface, the actual shape is incorrect (as opposed to offset incorrectly).

The only differences in the draw call are the viewport dimensions (and associated projection matrix) and the offset. Looking at the vertex shader, I can't see how either of these values would affect the shape of the transformed object.
The vector was still in homogenous coordinate space when we applied the offset, giving incorrect results.

An alternative here would be to pass the offset as a translation matrix and multiply by that instead.
Attachment #579166 - Flags: review?(bas.schouten)
Comment on attachment 579166 [details] [diff] [review]
Convert vector back into normal coordinate space before applying offset

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

I prefer this approach I think, it's only a vector divide, which is probably cheaper than the 4 dp4s if we passed in a translation matrix. Possibly we could pass along the translation in the mLayerTransform, but that obscures things a little, and we should have cycles to spare on the vertex shaders! Good catch!
Attachment #579166 - Flags: review?(bas.schouten) → review+
https://hg.mozilla.org/mozilla-central/rev/2f9ce0282804
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla11
Attached patch Fix v2 (obsolete) — Splinter Review
Dividing by W doesn't always give us correct results, so I think this is the only choice.

Untested on d3d9 because my laptop is Optimus and won't run them.
Attachment #581783 - Flags: review?(bas.schouten)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch Fix v3Splinter Review
We determined on IRC that this was caused by the perspective-correct interpolation used in the shaders requires the w component to be intact.

This patch doesn't add a new matrix parameter, but instead just remultiplies by w after applying the offset.
Attachment #581866 - Flags: review?(bas.schouten)
Attachment #581783 - Attachment is obsolete: true
Attachment #581783 - Flags: review?(bas.schouten)
Attachment #581866 - Flags: review?(bas.schouten) → review+
Is this bug related to this: http://dabblet.com/gist/1489886 rendering like this: http://yfrog.com/gzczrpp ?
Depends on: 711809
https://hg.mozilla.org/integration/mozilla-inbound/rev/0da67b6beb18

Marek: Yes, that's the problem that this patch fixes.
https://hg.mozilla.org/mozilla-central/rev/0da67b6beb18
Status: REOPENED → RESOLVED
Closed: 13 years ago13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: