Crash in OpenGL mode

Hello,

I am trying to run the Unreal engine (custom built from git sources, version 4.5.1) in OpenGL mode in Windows, because I need to do some OpenGL integration. However, whenever I try to force OpenGL RHI using the -opengl (or -opengl4) flags, I get a crash due to an invalid memory access in the nvoglv64.dll after this code was executed:

GLCrashTest.exe!FOpenGLDynamicRHI::RHIDrawIndexedPrimitive(FRHIIndexBuffer * IndexBufferRHI, unsigned int PrimitiveType, int BaseVertexIndex, unsigned int MinIndex, unsigned int NumVertices, unsigned int StartIndex, unsigned int NumPrimitives, unsigned int NumInstances) Line 2594 C++
GLCrashTest.exe!DrawIndexedPrimitive_Internal(FRHIIndexBuffer * IndexBuffer, unsigned int PrimitiveType, int BaseVertexIndex, unsigned int MinIndex, unsigned int NumVertices, unsigned int StartIndex, unsigned int NumPrimitives, unsigned int NumInstances) Line 1924 C++
GLCrashTest.exe!FSlateRHIRenderingPolicy::DrawElements(FRHICommandListImmediate & RHICmdList, FSlateBackBuffer & BackBuffer, const FMatrix & ViewProjectionMatrix, const TArray<FSlateRenderBatch,FDefaultAllocator> & RenderBatches) Line 415 C++
GLCrashTest.exe!FSlateRHIRenderer::DrawWindow_RenderThread(FRHICommandListImmediate & RHICmdList, const FSlateRHIRenderer::FViewportInfo & ViewportInfo, const FSlateWindowElementList & WindowElementList, bool bLockToVsync) Line 439 C++
GLCrashTest.exe!TGraphTask<FSlateRHIRenderer::DrawWindows_Private'::28’::EURCMacro_SlateDrawWindowsCommand>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 684 C++
GLCrashTest.exe!FTaskThread::ProcessTasks(int QueueIndex, bool bAllowStall) Line 338 C++
GLCrashTest.exe!FTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 177 C++
GLCrashTest.exe!RenderingThreadMain(FEvent * TaskGraphBoundSyncEvent) Line 268 C++
GLCrashTest.exe!FRenderingThread::Run() Line 387 C++
GLCrashTest.exe!FRunnableThreadWin::Run() Line 73 C++
GLCrashTest.exe!FRunnableThreadWin::GuardedRun() Line 48 C++

I have traced the code through, this seems to happen on the first frame that is being rendered. However, I am getting this crash only when running from either Visual Studio or from command line - when I start the code from the Unreal editor, it seems to work.

This procedure can be used to reproduce the issue:

Create test project

  • start Unreal Editor
  • Create new project GLCrashTest: New Project, select C++, Basic Code, No starter content, name it GLCrashTest
  • Once Visual Studio opens, select configuration “Development Client” (not the default “Development Editor” - we aren’t going to develop the editor code!)
  • In the Configuration Manager check that the GLCrashTest Development Game configuration is activated to be built (it isn’t by default for me). If it isn’t, activate it (checkbox in the Build column).
  • Build the project (F7)

Run the editor and cook the project

  • Open the project settings and enable OpenGL support for the project
    Settings->Platforms->Windows, Targetted RHIs, check OpenGL3 (SM4) in addition to all DirectX
  • Cook the project
    File->Cook content for Windows

Start the project from Visual Studio (F5)

  • The app should start in D3D mode. It will show black window, that is normal, because we picked “No starter content”. Check that you are running in DX11 mode - window title should be showing “GLCrashTest (64-bit, PCD3D_SM5)”. Close the app (ALT+F4)

This should start and run normally.

Switch to OpenGL mode

  • right click project GLCrashTest in Solution Explorer, Properties
  • Change the configuration to “Development_Game”
  • Configuration Properties->Debugging, set the Command Arguments to “-opengl” (without quotes). If you are using the Unreal extension for Visual Studio, you can set it there instead.
  • Run the application again (F5)

For me it crashes with “Unhandled exception at 0x000000000505FD11 in GLCrashTest.exe: 0xC0000005: Access violation reading location 0x0000000000000000.”, the stack points to some weird place in the nvoglv64.dll

I have tested and managed to reproduce this behaviour with 4.5, 4.6, master, promoted and release branches on Github. I am using the Community edition Visual Studio 2013, my GPU is GeForce GTX570 and driver version 344.75 in .

Hi ,

Thank you for bringing this to our attention, and for the very clear repro steps. I was able to reproduce this easily, and have entered a report about the results to have this investigated further (UE-6202).

Thanks a lot, .

Hi ,

Just wanted to provide you with a quick update on this. This is apparently an issue related to NVidia drivers, and we are waiting for a fix from them to resolve this. We do not currently have any estimate on when we will see a fix.

Aha, ok.

Thanks for the info. I will keep an eye on the new drivers then.

I had packaged my game in Shader Model 5 and OpenGL 3 (ES 2).

I had successfully run them individually either Shader Model 5 or OpenGL 3 (ES 2).

Is there any way to change them at runtime from Shader Model 5 to OpenGL 3 (ES 2) or OpenGL 3 (ES 2) to Shader Model 5?