Search Issue Tracker
By Design
Votes
2
Found in
2018.4
2019.3
2019.3.12f1
2020.1
2020.2
Issue ID
1244070
Regression
No
Crash on TexturesD3D11Base::RegisterNativeTexture when Texture2D.CreateExternalTexture() is called
Reproduction steps:
1. Open user's attached project and scene "DDOScene"
2. Delete the ML Agent package from the Package manager
3. Delete "BaseAgent.cs" from the Assets folder
4. Enter Play Mode
-- observe crash
Reproducible with: 2018.4.23f1, 2019.3.14f1, 2020.1.0b9, 2020.2.0a12
-
sniffle63
Sep 11, 2020 16:15
My company is getting this error on 2019.4 randomly and our game is crashing/
-
kayke
Jun 04, 2020 02:17
We appear to be having a similar issue with intermittent crashes in our builds.
Unity 2019.3.15f10x00007FFE8010A924 (d3d11) D3D11CoreCreateDevice
0x00007FFE801093D2 (d3d11) D3D11CoreCreateDevice
0x00007FFE8010C1F3 (d3d11) D3D11CoreCreateDevice
0x00007FFE8010CBCF (d3d11) D3D11CoreCreateDevice
0x00007FFE8010D3C0 (d3d11) D3D11CoreCreateDevice
0x00007FFE801026AA (d3d11) D3D11CoreCreateDevice
0x00007FFE80125FD2 (d3d11) D3D11CoreGetLayeredDeviceSize
0x00007FFE80125F92 (d3d11) D3D11CoreGetLayeredDeviceSize
0x00007FFE1F395079 (UnityPlayer) CreateDefaultSRV
0x00007FFE1F397F27 (UnityPlayer) TexturesD3D11Base::RegisterNativeTexture
0x00007FFE1F38F183 (UnityPlayer) GfxDeviceD3D11Base::RegisterNativeTexture
0x00007FFE1F43CD5C (UnityPlayer) GfxDeviceWorker::RunCommand
0x00007FFE1F44471D (UnityPlayer) GfxDeviceWorker::RunExt
0x00007FFE1F4447F8 (UnityPlayer) GfxDeviceWorker::RunGfxDeviceWorker
0x00007FFE1F767188 (UnityPlayer) Thread::RunThreadWrapper
0x00007FFE86DA7974 (KERNEL32) BaseThreadInitThunk
0x00007FFE86EFA271 (ntdll) RtlUserThreadStart
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Inconsistent behaviour when interacting with different dropdown types with pointer events on parent Visual Element
- Hidden GameObjects won't re-enable when they have call "DontDestroyOnLoad" function
- Overlay Canvas are rendered on each split-screen camera when HDR is enabled
- [Android] The Player loses focus when using UnityEngine.Handheld.StartActivityIndicator() with Facebook SDK
- Build fails with "Building Library/Bee/artifacts/MacStandalonePlayerBuildProgram/gahcy/hj9mx3z/951.0 failed with output:..." errors when Scripting Backend is set to IL2CPP
Resolution Note:
Texture2D.CreateExternalTexture is being used incorrectly. CreateExternalTexture() requires the user to pass in a native texture object. When using Direct3D11 for example, this could be a ID3D11Texture2D* texture. The code provided passes in a pointer to raw pixel data in memory. Unity cannot make the distinction between a valid and invalid pointer being passed in. To render a bitmap onto a RenderTexture, this example code would work:
System.Drawing.Imaging.BitmapData bd =
bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
int pixelSize = 4; // sizeof(ARGB32)
byte[] data = new byte[bmp.Width * bmp.Height * pixelSize];
Debug.Assert(bd.Stride == bd.Width * pixelSize);
Marshal.Copy(bd.Scan0, data, 0, bmp.Width * bmp.Height * pixelSize);
Texture2D tmptex = new Texture2D(bmp.Width, bmp.Height, TextureFormat.BGRA32, false);
tmptex.LoadRawTextureData(data);
tmptex.Apply();
bmp.UnlockBits(bd);
RenderTexture.active = texture;
UnityEngine.Graphics.Blit(tmptex, texture);
Object.DestroyImmediate(tmptex);