Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

[D3D12]AccessViolationException in Resource.WriteToSubresource() call #659

Closed
Syncaidius opened this issue Oct 25, 2015 · 2 comments
Closed

Comments

@Syncaidius
Copy link

A System.AccessViolationException occurs when trying to write data to a texture upload heap/resource.

Built/run against SharpDX 3.0.0beta01.
Windows 10 build 10240.
AMD HD 7850 graphics card.

I've also tested with the latest possible version of SharpDX, but issue remains.

It might also be worth noting that the rest of the DX12 samples work fine, but none of those involve any texture interaction.

This was posted over on the samples repository by someone else a month ago. I have a feeling it might have been missed.

sharpdx/SharpDX-Samples#31

The piece of code which triggers the issue is:

            // Create the GPU upload buffer.
            var textureUploadHeap = device.CreateCommittedResource(new HeapProperties(HeapType.Upload), HeapFlags.None, ResourceDescription.Texture2D(Format.R8G8B8A8_UNorm, TextureWidth, TextureHeight), ResourceStates.GenericRead);

            // Copy data to the intermediate upload heap and then schedule a copy 
            // from the upload heap to the Texture2D.
            byte[] textureData = GenerateTextureData();

            var handle = GCHandle.Alloc(textureData, GCHandleType.Pinned);
            var ptr = Marshal.UnsafeAddrOfPinnedArrayElement(textureData, 0);
            textureUploadHeap.WriteToSubresource(0, null, ptr, TexturePixelSize * TextureWidth, textureData.Length);
            handle.Free();

Sample code: https://github.com/sharpdx/SharpDX-Samples/blob/master/Desktop/Direct3D12/HelloTexture/HelloTexture.cs

@Syncaidius Syncaidius changed the title AccessViolationException at the textureUploadHeap.WriteToSubresource() call AccessViolationException in Resource.WriteToSubresource() call Oct 25, 2015
@Syncaidius Syncaidius changed the title AccessViolationException in Resource.WriteToSubresource() call [D3D12]AccessViolationException in Resource.WriteToSubresource() call Oct 25, 2015
@xoofx
Copy link
Member

xoofx commented Dec 24, 2015

Might be a driver bug. If will reopen this issue if you have a C++ version working which is not with SharpDX.

@xoofx xoofx closed this as completed Dec 24, 2015
@XiaYeYue
Copy link

Yes, this is a driver bug. This simple can run up in the lastest driver(16.3 hotfix), but it seems to be wrong that there's some pink blocks in the triangle.

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

No branches or pull requests

3 participants