Closed Bug 707563 Opened 12 years ago Closed 12 years ago

Intermediate surfaces change rendering of 3d transforms


(Core :: Graphics, defect)

Not set





(Reporter: mattwoodrow, Assigned: mattwoodrow)




(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 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+
Closed: 12 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)
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: rendering like this: ?
Depends on: 711809

Marek: Yes, that's the problem that this patch fixes.
Closed: 12 years ago12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.