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

D3D12_RT_FORMAT_ARRAY constructor is incorrect and corrupts memory #292

Closed
Marlax0 opened this issue Dec 21, 2021 · 0 comments · Fixed by #294
Closed

D3D12_RT_FORMAT_ARRAY constructor is incorrect and corrupts memory #292

Marlax0 opened this issue Dec 21, 2021 · 0 comments · Fixed by #294
Assignees
Labels
bug An issue for something that does not behave as expected.

Comments

@Marlax0
Copy link

Marlax0 commented Dec 21, 2021

The constructor for D3D12_RT_FORMAT_ARRAY has its Buffer.MemoryCopy 'source' and 'destination' parameters swapped.

public unsafe D3D12_RT_FORMAT_ARRAY(DXGI_FORMAT* pFormats, uint NumFormats)
{
    Unsafe.SkipInit(out this);
    NumRenderTargets = NumFormats;
    Buffer.MemoryCopy(Unsafe.AsPointer(ref RTFormats), pFormats, sizeof(_RTFormats_e__FixedBuffer), sizeof(_RTFormats_e__FixedBuffer));
}

In my case this set the source DXGI_FORMAT to DXGI_FORMAT_UNKNOWN, and set an unrelated local variable to null...

Avoiding the constructor works as expected.

D3D12_RT_FORMAT_ARRAY renderTargetFormatArray = new();

renderTargetFormatArray.NumRenderTargets = 1;
renderTargetFormatArray.RTFormats[0]     = DXGI_FORMAT_R16G16B16A16_FLOAT;
@Marlax0 Marlax0 added bug An issue for something that does not behave as expected. untriaged An issue that has not been triaged by the repo maintainers. labels Dec 21, 2021
@tannergooding tannergooding removed the untriaged An issue that has not been triaged by the repo maintainers. label Dec 21, 2021
@tannergooding tannergooding self-assigned this Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue for something that does not behave as expected.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants