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

[d3d9] Determine depth bias r-factors #2931

Closed
wants to merge 1 commit into from

Conversation

K0bin
Copy link
Collaborator

@K0bin K0bin commented Sep 16, 2022

Ref: #2892

I've only tested it on Nvidia and it seems to work.

@K0bin K0bin added the d3d9 label Sep 16, 2022
src/d3d9/d3d9_depth_bias.cpp Outdated Show resolved Hide resolved
src/d3d9/d3d9_depth_bias.cpp Outdated Show resolved Hide resolved
gl_Position = vec4(
-1.0f + coord.x,
-1.0f + 3.0f * coord.y,
gl_VertexIndex == 2 ? 1.0 : 0.0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a gradient?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

For floating-point depth attachment, there is no single minimum resolvable
difference. In this case, the minimum resolvable difference for a given polygon is dependent on the
maximum exponent, e, in the range of z values spanned by the primitive. If n is the number of bits
in the floating-point mantissa, the minimum resolvable difference, r, for the given primitive is
defined as: 2^(e-n)

Emphasis mine. But because of that we can't really solve it with a simple factor. I went with the factor for a range from 0-1 as a best effort.

The top left vertex is supposed to be at depth 0 because that's what we read back for the depth bias.

@K0bin
Copy link
Collaborator Author

K0bin commented Sep 16, 2022

Unfortunately it doesn't seem to fix some of the depth bias problems and returns rather weird values for AMD.

On Nvidia, I get 1/(1<<23) for D24 and D32 and 1/(1<<15) for D16. Wine calculates the same values.

CME got:

info: Using depth bias r-factor: 1.52588e-05 for format: VK_FORMAT_D16_UNORM
info: Using depth bias r-factor: 1.52588e-05 for format: VK_FORMAT_D16_UNORM_S8_UINT
info: Using depth bias r-factor: 1.21072e-07 for format: VK_FORMAT_D32_SFLOAT
info: Using depth bias r-factor: 1.21072e-07 for format: VK_FORMAT_D32_SFLOAT_S8_UINT

which doesn't match what Wine calculates.

@misyltoad
Copy link
Collaborator

@CME42 Can you try with nodcc

@K0bin K0bin force-pushed the detect-depth-bias-r branch 3 times, most recently from e42c0f9 to 0c4c12d Compare September 19, 2022 14:39
@K0bin K0bin force-pushed the detect-depth-bias-r branch from 0c4c12d to d7870fe Compare September 19, 2022 14:41
@K0bin K0bin mentioned this pull request Sep 22, 2022
@K0bin K0bin closed this Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants