-
Notifications
You must be signed in to change notification settings - Fork 185
WIP: Fix incorrect calculations of row pitch in d3d12 implementation #48
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
base: master
Are you sure you want to change the base?
Conversation
|
A minor adjustment needs to be made to support all platforms that have D3D12 support. I'll try to update this branch with the necessary change. |
|
I try to write in a Texture2D with a native unity plugin in d3d12 mode and I don't understand how the row pitch of the texture works. |
|
There is padding added for efficiency reasons. Width x pixel size doesn't work. This PR changes the pitch calculation, but it doesn't work on all D3D12 platforms, and I haven't had time to include the fix we use internally to support all D3D12 platforms. |
|
Could you give me this padding computing formula for PC ? |
|
I don't remember the exact details, but the fomula stays unchanged. The only difference is the preprocessor defined used to get the alignment ( |
|
I carried out some tests. |
|
Basically, the pitch has to be a multiple of 256 IIRC. If you found the define, then you can just use the code in this PR. |
|
But my understanding might be wrong, because 5374 is not divisble by 256. |
|
I found a formula but I can't explain why it is correct :-) |
With a 160x144 texture, the pitch would be aligned to be 1024 pixels wide, not 768 as D3D12 calculates it to be. This was causing issues on our end, where we would be drawing pixels with offsets that would accumulate over each row of pixels.
The width does not need to be a power of 2 - it turns out it just needs to be a multiple of 256, which is what
D3D12_TEXTURE_DATA_PITCH_ALIGNMENTis defined to be.