void FEnvQueryInstance::ExecuteOneStep(double InTimeLimit) { if (!Owner.IsValid()) { Status = EEnvQueryStatus::OwnerLost; return; } FEnvQueryOptionInstance& OptionItem = Options[OptionIndex]; CONDITIONAL_SCOPE_CYCLE_COUNTER(STAT_AI_EnvQuery_GeneratorTime, CurrentTest < 0); CONDITIONAL_SCOPE_CYCLE_COUNTER(STAT_AI_EnvQuery_TestTime, CurrentTest >= 0); bool bStepDone = true; TimeLimit = InTimeLimit; if (CurrentTest < 0) { DEC_DWORD_STAT_BY(STAT_AI_EnvQuery_NumItems, Items.Num()); RawData.Reset(); Items.Reset(); ItemType = OptionItem.ItemType; ValueSize = ((UEnvQueryItemType*)ItemType->GetDefaultObject())->GetValueSize(); OptionItem.GenerateDelegate.Execute(*this); FinalizeGeneration(); } else { const int32 ItemsAlreadyProcessed = CurrentTestStartingItem; OptionItem.TestDelegates[CurrentTest].Execute(*this); bStepDone = CurrentTestStartingItem >= Items.Num() || bFoundSingleResult // or no items processed ==> this means error || (ItemsAlreadyProcessed == CurrentTestStartingItem); if (bStepDone) { FinalizeTest(); } } if (bStepDone) { #if WITH_EDITOR if (bStoreDebugInfo) { DebugData.Store(this); } #endif // WITH_EDITOR CurrentTest++; CurrentTestStartingItem = 0; } // sort results or switch to next option when all tests are performed if (Status == EEnvQueryStatus::Processing && (OptionItem.TestDelegates.Num() == CurrentTest || NumValidItems <= 0)) { if (NumValidItems > 0) { // found items, sort and finish FinalizeQuery(); } else { // no items here, go to next option or finish if (OptionIndex + 1 >= Options.Num()) { // out of options, finish processing without errors FinalizeQuery(); } else { // not doing it always for debugging purposes OptionIndex++; CurrentTest = -1; } } } }
int main(int argc, char *argv[]) { const int winWidth = 800, winHeight = 600; Display *x_dpy; Window win; EGLSurface egl_surf; EGLContext egl_ctx; EGLDisplay egl_dpy; char *dpyName = NULL; GLboolean printInfo = GL_FALSE; EGLint egl_major, egl_minor; const char *s; if (!InitTest(argc, argv)) { return -1; } x_dpy = XOpenDisplay(dpyName); if (!x_dpy) { printf("Error: couldn't open display %s\n", dpyName ? dpyName : getenv("DISPLAY")); return -1; } egl_dpy = eglGetDisplay(x_dpy); if (!egl_dpy) { printf("Error: eglGetDisplay() failed\n"); return -1; } if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { printf("Error: eglInitialize() failed\n"); return -1; } s = eglQueryString(egl_dpy, EGL_VERSION); printf("EGL_VERSION = %s\n", s); s = eglQueryString(egl_dpy, EGL_VENDOR); printf("EGL_VENDOR = %s\n", s); s = eglQueryString(egl_dpy, EGL_EXTENSIONS); printf("EGL_EXTENSIONS = %s\n", s); s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); printf("EGL_CLIENT_APIS = %s\n", s); make_x_window(x_dpy, egl_dpy, "OpenGL ES 2.x tri", 0, 0, winWidth, winHeight, &win, &egl_ctx, &egl_surf); XMapWindow(x_dpy, win); if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { printf("Error: eglMakeCurrent() failed\n"); return -1; } if (printInfo) { printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); } InitRendering(); LoadData(testHelper->app()->defaultBuiltinDatasetIndex()); // render once testHelper->app()->resizeView(winWidth, winHeight); testHelper->app()->applyBuiltinDatasetCameraParameters(testHelper->app()->defaultBuiltinDatasetIndex()); testHelper->app()->render(); eglSwapBuffers(egl_dpy, egl_surf); // begin the event loop if not in testing mode bool testPassed = true; if (!testHelper->isTesting()) { event_loop(x_dpy, win, egl_dpy, egl_surf); } else { testPassed = DoTesting(); } FinalizeTest(); eglDestroyContext(egl_dpy, egl_ctx); eglDestroySurface(egl_dpy, egl_surf); eglTerminate(egl_dpy); XDestroyWindow(x_dpy, win); XCloseDisplay(x_dpy); return testPassed ? 0 : 1; }