Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VertexShaderGen: Correct vertex shader output to consider shifted pixel centers. #306

Merged
merged 1 commit into from Apr 25, 2014

Conversation

neobrain
Copy link
Member

On the console GPU, pixel centers are located at 0.58333 in screen space, rather than 0.5 as for common GPUs. Hence, primitives get rasterized incorrectly such that they may get offset by one pixel to the bottom-right.

Explanation of the discovery of this issue in bug report 267 - http://code.google.com/p/dolphin-emu/issues/detail?id=267 . This issue caused a clear quad to function improperly there, hence creating artifacts in an EFB copy which showed up as the oddly colored ground texture.

A hwtest was written for this behavior at https://github.com/dolphin-emu/hwtests/blob/872cd517cc3f8edb20161506109344652bbd02b5/gxtest/source/main.cpp#L500 and indeed it shows that indeed the pixel center is (roughly) at 7/12th in screen space. There's no real confirmation, but at least it's very close to that value, and it just makes a lot of sense given that each pixel is divided into a 12x12 grid of subsamples.

@delroth
Copy link
Member

delroth commented Apr 23, 2014

That's a very, very cool fix.

I don't like how we just cram that uniform in DEPTHPARAMS, but I guess this is not really relevant and is more an overall nit I have with our shaders. LGTM.

// NOTE: If we ever emulate antialiasing, the sample locations set by
// BP registers 0x01-0x04 need to be considered here.
const float pixel_center_correction = 7.0f / 12.0f - 0.5f;
const float pixel_size_x = 2.f / Renderer::EFBToScaledXf(2.f * xfregs.viewport.wd);

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@magumagu
Copy link
Contributor

I'm not completely happy that we still don't understand the rounding... but this is clearly an improvement. LGTM. (I assume you're planning a similar fix for the SW backend?)

@Sonicadvance1
Copy link
Contributor

LGTM.

delroth added a commit that referenced this pull request Apr 25, 2014
VertexShaderGen: Correct vertex shader output to consider shifted pixel centers.
@delroth delroth merged commit 25f5598 into dolphin-emu:master Apr 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants