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

[d3d8/9] LockRect offsets should be aligned between faces for cube textures #4674

Open
WinterSnowfall opened this issue Feb 6, 2025 · 2 comments

Comments

@WinterSnowfall
Copy link
Contributor

Wine has the following test that is shared between d3d8 and d3d9: https://github.com/wine-mirror/wine/blob/7b57598dcfc9198aa9cf6ac4ce17e2328db1379d/dlls/d3d8/tests/device.c#L9111-L9143

It suggests the expectation is that lock offsets are aligned to 16-bits between cube faces (mip levels are continuous just like in a regular texture). Currently we luck out with formats that are natively aligned, such as L8 and A8, but return shifted offsets for faces > 0 with D3DFMT_A8R8G8B8... which is a rather common format.

Though I've been able to largely ascertain the problem, I'm afraid it's a bit beyond my brainpower to come up with a proper fix.

I have confirmed that messing with the offset in D3D9DeviceEx::LockImage can indeed make the test pass, for example if I shift the offset for all D3DFMT_A8R8G8B8 face 1 mips by 8, that will pass the validations for that face, but getting everything aligned as per expectations is beyond me.

@doitsujin
Copy link
Owner

doitsujin commented Feb 9, 2025

Currently we luck out with formats that are natively aligned, such as L8 and A8, but return shifted offsets for faces > 0 with D3DFMT_A8R8G8B8

Not sure I follow, how can it be possible for a smaller format to naturally meet stricter alignment requirements than a larger format?

I don't really understand what the test is testing either, does this mean that cube array layers need to be padded to start at 16 byte boundaries or something?

@WinterSnowfall
Copy link
Contributor Author

Not sure I follow, how can it be possible for a smaller format to naturally meet stricter alignment requirements than a larger format?

Not entirely sure either to be honest (otherwise I might have known what to do in order to fix it 🐸), but the point was L8 and A8 go through the same tests and pass them.

I don't really understand what the test is testing either, does this mean that cube array layers need to be padded to start at 16 byte boundaries or something?

Face boundaries within those arrays need to be, yes. The tests pass with flying colors on native at least.

Additionally, we also fail other things within the test_miptree_layout Wine test with ATI1/2 textures, but I'd treat that as a separate problem as it looks like we get a lot more than the alignment wrong here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants