示例#1
0
int main(int argc, char* argv[])
{
	MicroProfileOnThreadCreate("Main");
	printf("press ctrl-c to quit\n");

	//turn on profiling
	MicroProfileSetForceEnable(true);
	MicroProfileSetEnableAllGroups(true);
	MicroProfileSetForceMetaCounters(true);

	MicroProfileStartContextSwitchTrace();

	StartFakeWork();
	while(!g_nQuit)
	{
		MICROPROFILE_SCOPE(MAIN);
		{
			usleep(16000);
		}
		MicroProfileFlip();
		static bool once = false;
		if(!once)
		{
			once = 1;
			printf("open localhost:%d in chrome to capture profile data\n", MicroProfileWebServerPort());
		}

	}

	StopFakeWork();
	
	MicroProfileShutdown();

	return 0;
}
示例#2
0
文件: main.cpp 项目: Road-Drum/citra
int main(int argc, char* argv[]) {
    Log::Filter log_filter(Log::Level::Info);
    Log::SetFilter(&log_filter);

    MicroProfileOnThreadCreate("Frontend");
    SCOPE_EXIT({
        MicroProfileShutdown();
    });
示例#3
0
文件: citra.cpp 项目: 14923523/citra
/// Application entry point
int main(int argc, char **argv) {
    Config config;
    int option_index = 0;
    bool use_gdbstub = Settings::values.use_gdbstub;
    u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port);
    char *endarg;
    std::string boot_filename;

    static struct option long_options[] = {
        { "gdbport", required_argument, 0, 'g' },
        { "help", no_argument, 0, 'h' },
        { "version", no_argument, 0, 'v' },
        { 0, 0, 0, 0 }
    };

    while (optind < argc) {
        char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index);
        if (arg != -1) {
            switch (arg) {
            case 'g':
                errno = 0;
                gdb_port = strtoul(optarg, &endarg, 0);
                use_gdbstub = true;
                if (endarg == optarg) errno = EINVAL;
                if (errno != 0) {
                    perror("--gdbport");
                    exit(1);
                }
                break;
            case 'h':
                PrintHelp(argv[0]);
                return 0;
            case 'v':
                PrintVersion();
                return 0;
            }
        } else {
            boot_filename = argv[optind];
            optind++;
        }
    }

    Log::Filter log_filter(Log::Level::Debug);
    Log::SetFilter(&log_filter);

    MicroProfileOnThreadCreate("EmuThread");
    SCOPE_EXIT({ MicroProfileShutdown(); });
示例#4
0
int main(int argc, char* argv[])
{

	MICROPROFILE_REGISTER_GROUP("Thread0", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("Thread1", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("Thread2", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("Thread2xx", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("MAIN", "main", 0x88fff00f);


	g_QueueGraphics = MICROPROFILE_GPU_INIT_QUEUE("GPU-Graphics-Queue");

	printf("press 'z' to toggle microprofile drawing\n");
	printf("press 'right shift' to pause microprofile update\n");
	printf("press 'x' to toggle profiling\n");
	printf("press 'c' to toggle enable of all profiler groups\n");
	MicroProfileOnThreadCreate("AA_Main");
	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
		return 1;
	}


	SDL_GL_SetAttribute(SDL_GL_RED_SIZE,    	    8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,  	    8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,   	    8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,  	    8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,  	    24);
	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,  	    8);	
	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,		    32);	
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,	    1);	
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
	SDL_GL_SetSwapInterval(1);

	SDL_Window * pWindow = SDL_CreateWindow("microprofiledemo", 10, 10, WIDTH, HEIGHT, SDL_WINDOW_OPENGL);
	if(!pWindow)
		return 1;

	SDL_GLContext glcontext = SDL_GL_CreateContext(pWindow);

	glewExperimental=1;
	GLenum err=glewInit();
	if(err!=GLEW_OK)
	{
		__BREAK();
	}
	glGetError(); //glew generates an error
		


#if MICROPROFILE_ENABLED
	MicroProfileGpuInitGL();
	MicroProfileDrawInit();
	MP_ASSERT(glGetError() == 0);
	MicroProfileToggleDisplayMode();
	
	MicroProfileInitUI();

	MicroProfileCustomGroup("Custom1", 2, 47, 2.f, MICROPROFILE_CUSTOM_BARS);
	MicroProfileCustomGroupAddTimer("Custom1", "MicroProfile", "Draw");
	MicroProfileCustomGroupAddTimer("Custom1", "MicroProfile", "Detailed View");

	MicroProfileCustomGroup("Custom2", 2, 100, 20.f, MICROPROFILE_CUSTOM_BARS|MICROPROFILE_CUSTOM_BAR_SOURCE_MAX);
	MicroProfileCustomGroupAddTimer("Custom2", "MicroProfile", "Draw");
	MicroProfileCustomGroupAddTimer("Custom2", "MicroProfile", "Detailed View");


	MicroProfileCustomGroup("Custom3", 2, 0, 5.f, MICROPROFILE_CUSTOM_STACK|MICROPROFILE_CUSTOM_STACK_SOURCE_MAX);
	MicroProfileCustomGroupAddTimer("Custom3", "MicroProfile", "Draw");
	MicroProfileCustomGroupAddTimer("Custom3", "MicroProfile", "Detailed View");



	MicroProfileCustomGroup("ThreadSafe", 6, 10, 600.f, MICROPROFILE_CUSTOM_BARS | MICROPROFILE_CUSTOM_STACK);
	MicroProfileCustomGroupAddTimer("ThreadSafe", "ThreadSafe", "main");
	MicroProfileCustomGroupAddTimer("ThreadSafe", "ThreadSafe", "inner0");
	MicroProfileCustomGroupAddTimer("ThreadSafe", "ThreadSafe", "inner1");
	MicroProfileCustomGroupAddTimer("ThreadSafe", "ThreadSafe", "inner2");
	MicroProfileCustomGroupAddTimer("ThreadSafe", "ThreadSafe", "inner3");
	MicroProfileCustomGroupAddTimer("ThreadSafe", "ThreadSafe", "inner4");
#endif
	MICROPROFILE_COUNTER_CONFIG("memory/main", MICROPROFILE_COUNTER_FORMAT_BYTES, 10ll<<30ll, 0);
	MICROPROFILE_COUNTER_CONFIG("memory/gpu/indexbuffers", MICROPROFILE_COUNTER_FORMAT_BYTES, 0, 0);
	MICROPROFILE_COUNTER_CONFIG("memory/gpu/vertexbuffers", MICROPROFILE_COUNTER_FORMAT_BYTES, 0, 0);
	MICROPROFILE_COUNTER_CONFIG("memory/mainx", MICROPROFILE_COUNTER_FORMAT_BYTES, 10000, 0);

	MICROPROFILE_COUNTER_ADD("memory/main", 1000);
	MICROPROFILE_COUNTER_ADD("memory/gpu/vertexbuffers", 1000);
	MICROPROFILE_COUNTER_ADD("memory/gpu/indexbuffers", 200);
	MICROPROFILE_COUNTER_ADD("memory//", 10<<10);
	MICROPROFILE_COUNTER_ADD("memory//main", (32ll<<30ll) + (1ll <<29ll));
	MICROPROFILE_COUNTER_ADD("//memory//mainx/\\//", 1000);
	MICROPROFILE_COUNTER_ADD("//memoryx//mainx/", 1000);
	MICROPROFILE_COUNTER_ADD("//memoryy//main/", -1000000);
	MICROPROFILE_COUNTER_ADD("//\\\\///lala////lelel", 1000);
	MICROPROFILE_COUNTER_CONFIG("engine/frames", MICROPROFILE_COUNTER_FORMAT_DEFAULT, 1000, 0);
	MICROPROFILE_COUNTER_SET("fisk/geder/", 42);
	MICROPROFILE_COUNTER_SET("fisk/aborre/", -2002);
	MICROPROFILE_COUNTER_SET_LIMIT("fisk/aborre/", 120);
	static int Frames = 0;
	static uint64_t FramesX = 0;
	MICROPROFILE_COUNTER_SET_INT64_PTR("frames/int64", &FramesX);
	MICROPROFILE_COUNTER_SET_INT32_PTR("frames/int32", &Frames);

	MICROPROFILE_COUNTER_CONFIG("/test/sinus", MICROPROFILE_COUNTER_FORMAT_BYTES, 0, MICROPROFILE_COUNTER_FLAG_DETAILED);
	MICROPROFILE_COUNTER_CONFIG("/test/cosinus", MICROPROFILE_COUNTER_FORMAT_DEFAULT, 0, MICROPROFILE_COUNTER_FLAG_DETAILED);
	MICROPROFILE_COUNTER_CONFIG("/runtime/sdl_frame_events", MICROPROFILE_COUNTER_FORMAT_DEFAULT, 0, MICROPROFILE_COUNTER_FLAG_DETAILED);

	StartFakeWork();
	while(!g_nQuit)
	{
		Frames++;
		FramesX += 1024*1024;
		MICROPROFILE_SCOPE(MAIN);
		MICROPROFILE_COUNTER_ADD("engine/frames", 1);

		SDL_Event Evt;
		while(SDL_PollEvent(&Evt))
		{
			MICROPROFILE_COUNTER_LOCAL_ADD(SDLFrameEvents, 1);
			HandleEvent(&Evt);
		}

		MICROPROFILE_COUNTER_LOCAL_UPDATE_SET(SDLFrameEvents);
		glClearColor(0.3f,0.4f,0.6f,0.f);
		glViewport(0, 0, WIDTH, HEIGHT);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


#if 1||FAKE_WORK
		{
			MICROPROFILE_SCOPEI("BMain", "Dummy", 0xff3399ff);
			for(uint32_t i = 0; i < 14; ++i)
			{
				MICROPROFILE_SCOPEI("BMain", "1ms", 0xff3399ff);
				MICROPROFILE_META_CPU("Sleep",1);

				usleep(1000);
			}
		}
#endif




		MicroProfileMouseButton(g_MouseDown0, g_MouseDown1);
		MicroProfileMousePosition(g_MouseX, g_MouseY, g_MouseDelta);
		g_MouseDelta = 0;


		MicroProfileFlip(0);
		static float f = 0;
		f += 0.1f;
		int sinus = (int)(10000000 * (sinf(f)));
		int cosinus = int(cosf(f*1.3f) * 100000 + 50000);
		MICROPROFILE_COUNTER_SET("/test/sinus", sinus);
		MICROPROFILE_COUNTER_SET("/test/cosinus", cosinus);
		{
			MICROPROFILE_SCOPEGPUI("MicroProfileDraw", 0x88dd44);
			float projection[16];
			float left = 0.f;
			float right = WIDTH;
			float bottom = HEIGHT;
			float top = 0.f;
			float near = -1.f;
			float far = 1.f;
			memset(&projection[0], 0, sizeof(projection));

			projection[0] = 2.0f / (right - left);
			projection[5] = 2.0f / (top - bottom);
			projection[10] = -2.0f / (far - near);
			projection[12] = - (right + left) / (right - left);
			projection[13] = - (top + bottom) / (top - bottom);
			projection[14] = - (far + near) / (far - near);
			projection[15] = 1.f; 
 
 			glEnable(GL_BLEND);
 			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 			glDisable(GL_DEPTH_TEST);
#if MICROPROFILE_ENABLED
			MicroProfileBeginDraw(WIDTH, HEIGHT, &projection[0]);
			MicroProfileDraw(WIDTH, HEIGHT);
			MicroProfileEndDraw();
#endif
			glDisable(GL_BLEND);
		}

		MICROPROFILE_SCOPEI("MAIN", "Flip", 0xffee00);
		SDL_GL_SwapWindow(pWindow);
	}
	StopFakeWork();

	MicroProfileShutdown();

  	SDL_GL_DeleteContext(glcontext);  
 	SDL_DestroyWindow(pWindow);
 	SDL_Quit();


	return 0;
}
示例#5
0
int main(int argc, char* argv[])
{


	MicroProfileOnThreadCreate("AA_Main");
	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
		return 1;
	}


	SDL_GL_SetAttribute(SDL_GL_RED_SIZE,    	    8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,  	    8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,   	    8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,  	    8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,  	    24);
	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,  	    8);	
	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,		    32);	
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,	    1);	
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
	SDL_GL_SetSwapInterval(1);

	SDL_Window * pWindow = SDL_CreateWindow("microprofiledemo", 10, 10, WIDTH, HEIGHT, SDL_WINDOW_OPENGL);
	if(!pWindow)
		return 1;

	SDL_GLContext glcontext = SDL_GL_CreateContext(pWindow);

	glewExperimental=1;
	GLenum err=glewInit();
	printf("ERROR IS %d\n",err);
	if(err!=GLEW_OK)
	{
		__BREAK();
	}
	glGetError(); //glew generates an error		
	InitGLBuffers();
#if MICROPROFILE_ENABLED
	MicroProfileGpuInitGL();
#endif
	SDL_GL_SetSwapInterval(1);
	while(!g_nQuit)
	{
		MICROPROFILE_SCOPE(MAIN);
		MICROPROFILE_COUNTER_ADD("engine/frames", 1);

		SDL_Event Evt;
		while(SDL_PollEvent(&Evt))
		{
			MICROPROFILE_COUNTER_LOCAL_ADD_ATOMIC(SDLFrameEvents, 1);
			HandleEvent(&Evt);
		}

		MICROPROFILE_COUNTER_LOCAL_UPDATE_SET_ATOMIC(SDLFrameEvents);
		glClearColor(0.3f,0.4f,0.6f,0.f);
		glViewport(0, 0, WIDTH, HEIGHT);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		DrawGLStuff();

		MicroProfileFlip(0);
		MICROPROFILE_SCOPEI("MAIN", "Flip", 0xffee00);
		SDL_GL_SwapWindow(pWindow);

		static bool bOnce = false;
		if(!bOnce)
		{
			bOnce = true;
			printf("open localhost:%d in chrome to capture profile data\n", MicroProfileWebServerPort());
		}
	
	}

	MicroProfileShutdown();
  	SDL_GL_DeleteContext(glcontext);  
 	SDL_DestroyWindow(pWindow);
 	SDL_Quit();


	return 0;
}
示例#6
0
文件: citra.cpp 项目: JamePeng/citra
/// Application entry point
int main(int argc, char** argv) {
    Config config;
    int option_index = 0;
    bool use_gdbstub = Settings::values.use_gdbstub;
    u32 gdb_port = static_cast<u32>(Settings::values.gdbstub_port);
    char* endarg;
#ifdef _WIN32
    int argc_w;
    auto argv_w = CommandLineToArgvW(GetCommandLineW(), &argc_w);

    if (argv_w == nullptr) {
        LOG_CRITICAL(Frontend, "Failed to get command line arguments");
        return -1;
    }
#endif
    std::string boot_filename;

    static struct option long_options[] = {
        {"gdbport", required_argument, 0, 'g'},
        {"help", no_argument, 0, 'h'},
        {"version", no_argument, 0, 'v'},
        {0, 0, 0, 0},
    };

    while (optind < argc) {
        char arg = getopt_long(argc, argv, "g:hv", long_options, &option_index);
        if (arg != -1) {
            switch (arg) {
            case 'g':
                errno = 0;
                gdb_port = strtoul(optarg, &endarg, 0);
                use_gdbstub = true;
                if (endarg == optarg)
                    errno = EINVAL;
                if (errno != 0) {
                    perror("--gdbport");
                    exit(1);
                }
                break;
            case 'h':
                PrintHelp(argv[0]);
                return 0;
            case 'v':
                PrintVersion();
                return 0;
            }
        } else {
#ifdef _WIN32
            boot_filename = Common::UTF16ToUTF8(argv_w[optind]);
#else
            boot_filename = argv[optind];
#endif
            optind++;
        }
    }

#ifdef _WIN32
    LocalFree(argv_w);
#endif

    Log::Filter log_filter(Log::Level::Debug);
    Log::SetFilter(&log_filter);

    MicroProfileOnThreadCreate("EmuThread");
    SCOPE_EXIT({ MicroProfileShutdown(); });
示例#7
0
int main(int argc, char* argv[])
{

	MICROPROFILE_REGISTER_GROUP("Thread0", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("Thread1", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("Thread2", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("Thread2xx", "Threads", 0x88008800);
	MICROPROFILE_REGISTER_GROUP("GPU", "main", 0x88fff00f);
	MICROPROFILE_REGISTER_GROUP("MAIN", "main", 0x88fff00f);

	printf("press 'z' to toggle microprofile drawing\n");
	printf("press 'right shift' to pause microprofile update\n");
	printf("press 'x' to toggle profiling\n");
	printf("press 'c' to toggle enable of all profiler groups\n");
	MicroProfileOnThreadCreate("AA_Main");
	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
		return 1;
	}


	SDL_GL_SetAttribute(SDL_GL_RED_SIZE,    	    8);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,  	    8);
	SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,   	    8);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,  	    8);
	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,  	    24);
	SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,  	    8);	
	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE,		    32);	
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,	    1);	
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
	SDL_GL_SetSwapInterval(1);

	SDL_Window * pWindow = SDL_CreateWindow("microprofiledemo", 10, 10, WIDTH, HEIGHT, SDL_WINDOW_OPENGL);
	if(!pWindow)
		return 1;

	SDL_GLContext glcontext = SDL_GL_CreateContext(pWindow);

	glewExperimental=1;
	GLenum err=glewInit();
	if(err!=GLEW_OK)
	{
		__BREAK();
	}
	glGetError(); //glew generates an error
		


#if MICROPROFILE_ENABLED
	MicroProfileGpuInitGL();
	MicroProfileDrawInit();
	MP_ASSERT(glGetError() == 0);
	MicroProfileToggleDisplayMode();
#endif

	StartFakeWork();
	while(!g_nQuit)
	{
		MICROPROFILE_SCOPE(MAIN);

		SDL_Event Evt;
		while(SDL_PollEvent(&Evt))
		{
			HandleEvent(&Evt);
		}

		glClearColor(0.3f,0.4f,0.6f,0.f);
		glViewport(0, 0, WIDTH, HEIGHT);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


#if 1||FAKE_WORK
		{
			MICROPROFILE_SCOPEI("BMain", "Dummy", 0xff3399ff);
			for(uint32_t i = 0; i < 14; ++i)
			{
				MICROPROFILE_SCOPEI("BMain", "1ms", 0xff3399ff);
				MICROPROFILE_META_CPU("Sleep",1);

				usleep(1000);
			}
		}
#endif




		MicroProfileMouseButton(g_MouseDown0, g_MouseDown1);
		MicroProfileMousePosition(g_MouseX, g_MouseY, g_MouseDelta);
		g_MouseDelta = 0;


		MicroProfileFlip();
		{
			MICROPROFILE_SCOPEGPUI("MicroProfileDraw", 0x88dd44);
			float projection[16];
			float left = 0.f;
			float right = WIDTH;
			float bottom = HEIGHT;
			float top = 0.f;
			float near = -1.f;
			float far = 1.f;
			memset(&projection[0], 0, sizeof(projection));

			projection[0] = 2.0f / (right - left);
			projection[5] = 2.0f / (top - bottom);
			projection[10] = -2.0f / (far - near);
			projection[12] = - (right + left) / (right - left);
			projection[13] = - (top + bottom) / (top - bottom);
			projection[14] = - (far + near) / (far - near);
			projection[15] = 1.f; 
 
 			glEnable(GL_BLEND);
 			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 			glDisable(GL_DEPTH_TEST);
#if MICROPROFILE_ENABLED
			MicroProfileBeginDraw(WIDTH, HEIGHT, &projection[0]);
			MicroProfileDraw(WIDTH, HEIGHT);
			MicroProfileEndDraw();
#endif
			glDisable(GL_BLEND);
		}

		MICROPROFILE_SCOPEI("MAIN", "Flip", 0xffee00);
		SDL_GL_SwapWindow(pWindow);
	}
	StopFakeWork();

	MicroProfileShutdown();

  	SDL_GL_DeleteContext(glcontext);  
 	SDL_DestroyWindow(pWindow);
 	SDL_Quit();


	return 0;
}