Dear Friends at Epic,
Hi there!
I just upgraded Solus to 4.5, and now the game is broken because I am creating FCanvas to render to from code.
The same code worked great in 4.4!
The constructor changed in 4.5, but other than that my code is the same as what worked in 4.4
void ASolusPDAButtonMesh::InitializeTextureRender(FVector2D IN_Dimensions)
{
Dimensions = IN_Dimensions;
RenderTex = CastChecked<UTextureRenderTarget2D>(StaticConstructObject(UTextureRenderTarget2D::StaticClass()));
RenderTex->AddToRoot();
RenderTex->ClearColor = FLinearColor(0,0,0,1); //0.2
RenderTex->bNeedsTwoCopies = false;
RenderTex->bHDR = false;
//Set pixel format to include alpha //try 960 //floatRGBA = additive
RenderTex->InitCustomFormat(Dimensions.X, Dimensions.Y, EPixelFormat::PF_A16B16G16R16 , true); //linear gamma
RenderTex->UpdateResourceImmediate();
/*
//Create New Canvas
Canvas = NULL;
//Canvas = new FCanvas((FTextureRenderTarget2DResource*) RenderTex->Resource, NULL, 0,0,0);
Canvas = new FCanvas((FTextureRenderTarget2DResource*) RenderTex->Resource,NULL, GetWorld(), ERHIFeatureLevel::SM4);
Canvas->Clear(RenderTex->ClearColor);
*/
#Crash
If I uncomment the commented out section where I create the FCanvas, the game crashes with this message, very consistently:
[2014.10.21-21.44.45:359][220]LogWindows: === Critical error: ===
Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.5\Engine\Source\Runtime\RenderCore\Private\RenderingThread.cpp] [Line: 641]
Rendering thread exception:
Assertion failed: IsInGameThread() [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.5\Engine\Source\Runtime\Engine\Private\GlobalShader.cpp] [Line: 341]
KERNELBASE.dll!UnknownFunction (0x000007fefd089e5d) + 0 bytes [UnknownFile:0]
UE4Editor-Core.dll!UnknownFunction (0x000007fedcd571b4) + 0 bytes [UnknownFile:0]
UE4Editor-Core.dll!UnknownFunction (0x000007fedcbe98b8) + 0 bytes [UnknownFile:0]
UE4Editor-Core.dll!UnknownFunction (0x000007fedcbce882) + 0 bytes [UnknownFile:0]
UE4Editor-Engine.dll!UnknownFunction (0x000007feda63cb4a) + 0 bytes [UnknownFile:0]
UE4Editor-Engine.dll!UnknownFunction (0x000007feda44ae4a) + 0 bytes [UnknownFile:0]
UE4Editor-Engine.dll!UnknownFunction (0x000007feda42a66f) + 0 bytes [UnknownFile:0]
UE4Editor-Engine.dll!UnknownFunction (0x000007fedb0a282b) + 0 bytes [UnknownFile:0]
UE4Editor-Engine.dll!UnknownFunction (0x000007fedb0add62) + 0 bytes [UnknownFile:0]
UE4Editor-Core.dll!UnknownFunction (0x000007fedcb06504) + 0 bytes [UnknownFile:0]
UE4Editor-Core.dll!UnknownFunction (0x000007fedcb0668d) + 0 bytes [UnknownFile:0]
UE4Editor-RenderCore.dll!UnknownFunction (0x000007fede41fc33) + 0 bytes [UnknownFile:0]
UE4Editor-RenderCore.dll!UnknownFunction (0x000007fede4200c9) + 0 bytes [UnknownFile:0]
UE4Editor-Core.dll!UnknownFunction (0x000007fedcd56316) + 0 bytes [UnknownFile:0]
UE4Editor-Core.dll!UnknownFunction (0x000007fedcd4ad3d) + 0 bytes [UnknownFile:0]
kernel32.dll!UnknownFunction (0x000000007704652d) + 0 bytes [UnknownFile:0]
ntdll.dll!UnknownFunction (0x000000007717c521) + 0 bytes [UnknownFile:0]
ntdll.dll!UnknownFunction (0x000000007717c521) + 0 bytes [UnknownFile:0]
#Render Thread?!
Why is it crashing on IsInGameThread() ?!
I am not doing anything fancy at all, the only relevant code and the only code that is crashing the game is what I’ve posted above, and again, it is just the lines that I commented out, the making of the new FCanvas!
#Help
Please help!
I need a way to make an FCanvas and draw to it in 4.5!
#I tried CanvasRenderTarget2D As Well
I tried using Tan’s CanvasRenderTarget2D as well, and I also got a crash!
The crash is precisely and only on the line where I try to create the CanvasRenderTarget2D using entirely and only the code that is part of the Engine itself:
RenderTex =
UCanvasRenderTarget2D::CreateCanvasRenderTarget2D( //<~~~ Crash is here
UCanvasRenderTarget2D::StaticClass(),
Dimensions.X, Dimensions.Y
);
#Full Code
void ASolusPDAButtonMesh::InitializeTextureRender(FVector2D IN_Dimensions)
{
Dimensions = IN_Dimensions;
/*
RenderTex =
UCanvasRenderTarget2D::CreateCanvasRenderTarget2D( //<~~~ Crash is here
UCanvasRenderTarget2D::StaticClass(),
Dimensions.X, Dimensions.Y
);
RenderTex->AddToRoot();
RenderTex->ClearColor = FLinearColor(0,0,0,1); //0.2
RenderTex->bNeedsTwoCopies = false;
RenderTex->bHDR = false;
//Set pixel format to include alpha //try 960 //floatRGBA = additive
RenderTex->InitCustomFormat(Dimensions.X, Dimensions.Y, EPixelFormat::PF_A16B16G16R16 , true); //linear gamma
//Add Binding!
RenderTex->OnCanvasRenderTargetUpdate.AddDynamic(this, &ASolusPDAButtonMesh::OnCanvasRenderTargetUpdate);
*/
#Crash
[2014.10.21-22.26.26:834][281]LogWindows: === Critical error: ===
Fatal error!
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000188
UE4Editor-Engine.dll!UnknownFunction (0x000007feda4607a9) + 0 bytes [UnknownFile:0]
UE4Editor-Engine.dll!UnknownFunction (0x000007feda41e0d3) + 0 bytes [UnknownFile:0]
UE4Editor-Solus.dll!ASolusPDAButtonMesh::InitializeTextureRender() (0x000007fed106b3a7) + 0 bytes [c:\solus\source\solus\base\soluspdabuttonmesh.cpp:88]
UE4Editor-Solus.dll!ASolusPCSoul::CreatePDAMeshButton() (0x000007fed104e741) + 0 bytes [c:\solus\source\solus\soluspc\soluspcsoul.cpp:268]
UE4Editor-Solus.dll!ASolusPCSleepMenu::SolusSleepMenu_CreatePDAScreenButtons() (0x000007fed10b2a70) + 170 bytes [c:\solus\source\solus\soluspc\soluspcsleepmenu.cpp:90]
UE4Editor-Solus.dll!ASolusPCSleepMenu::SolusSleepMenu_Open() (0x000007fed10b37f5) + 8 bytes [c:\solus\source\solus\soluspc\soluspcsleepmenu.cpp:79]
UE4Editor-CoreUObject.dll!UnknownFunction (0x000007feddf96394) + 0 bytes [UnknownFile:0]
#Help!
I have no way to render to textures from code in 4.5!