Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 22, 2013, 09:51 PM   #1
mif
macrumors Demi-God
 
Join Date: Feb 2010
Location: home
Slow access to VRAM

I am wondering what have changed in Mountain Lion? I found a way to draw directly to the screen but it is much slower than in Snow Leopard. 8 fps versus 145 fps.
Code:
unsigned char *get_display_base_address()
{
	kern_return_t		kr;
	io_connect_t		framebuffer;
	io_iterator_t		iter;
	io_service_t		ioServicePort;
	mach_vm_address_t	vram = 0;
	mach_vm_size_t		shmemSize;
	mach_port_t			masterPort;
	
	kr = IOMasterPort(bootstrap_port, &masterPort);
	if (kr == KERN_SUCCESS)
        {
		kr = IOServiceGetMatchingServices(masterPort, IOServiceMatching(IOFRAMEBUFFER_CONFORMSTO), &iter);
		if (kr == KERN_SUCCESS)
		{
			ioServicePort = IOIteratorNext(iter);
			IOObjectRelease(iter);
			kr = IOServiceOpen(ioServicePort, mach_task_self(), kIOFBSharedConnectType, &framebuffer);
			IOObjectRelease(ioServicePort);
			if (kr == KERN_SUCCESS)
			{
				kr = IOConnectMapMemory(framebuffer, 110, mach_task_self(), &vram, &shmemSize, kIOMapAnywhere);
				IOServiceClose(framebuffer);
			}
		}
	}
	return (unsigned char *)vram + 0x180000;	//return (unsigned char *)CGDisplayBaseAddress(CGMainDisplayID());
}
__________________
"Every day, in every way, i am feeling better and better" - Dreyfus
mif is offline   0 Reply With Quote
Old Aug 23, 2013, 01:17 PM   #2
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
Quote:
Originally Posted by mif View Post
I am wondering what have changed in Mountain Lion? I found a way to draw directly to the screen but it is much slower than in Snow Leopard. 8 fps versus 145 fps.
Code:
unsigned char *get_display_base_address()
{
	kern_return_t		kr;
	io_connect_t		framebuffer;
	io_iterator_t		iter;
	io_service_t		ioServicePort;
	mach_vm_address_t	vram = 0;
	mach_vm_size_t		shmemSize;
	mach_port_t			masterPort;
	
	kr = IOMasterPort(bootstrap_port, &masterPort);
	if (kr == KERN_SUCCESS)
        {
		kr = IOServiceGetMatchingServices(masterPort, IOServiceMatching(IOFRAMEBUFFER_CONFORMSTO), &iter);
		if (kr == KERN_SUCCESS)
		{
			ioServicePort = IOIteratorNext(iter);
			IOObjectRelease(iter);
			kr = IOServiceOpen(ioServicePort, mach_task_self(), kIOFBSharedConnectType, &framebuffer);
			IOObjectRelease(ioServicePort);
			if (kr == KERN_SUCCESS)
			{
				kr = IOConnectMapMemory(framebuffer, 110, mach_task_self(), &vram, &shmemSize, kIOMapAnywhere);
				IOServiceClose(framebuffer);
			}
		}
	}
	return (unsigned char *)vram + 0x180000;	//return (unsigned char *)CGDisplayBaseAddress(CGMainDisplayID());
}
Mountain Lion's window server uses a 'page flipping' design for double buffering. This is much faster in general, but tends to mess up direct access.
Catfish_Man is offline   0 Reply With Quote
Old Aug 27, 2013, 01:11 AM   #3
mif
Thread Starter
macrumors Demi-God
 
Join Date: Feb 2010
Location: home
Thanks, i did not know that.
__________________
"Every day, in every way, i am feeling better and better" - Dreyfus
mif is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
MSI R9 280X 6GB VRAM - yes 6GB VRAM stmp Mac Pro 5 May 15, 2014 02:43 AM
Camera access from lockscreen is slow to respond kristoffer4 iOS 7 1 Nov 11, 2013 10:13 AM
Will Parallels slow down access to my Sonnet Tempo? SvK Mac Pro 3 Mar 7, 2013 06:56 PM
DNS slow Internet / no access iampaulb Mac OS X Server, Xserve, and Networking 14 Feb 5, 2013 07:32 AM
2nd Hard drive slow to access SteelBlueTJ Mac Pro 1 Aug 25, 2012 02:38 PM

Forum Jump

All times are GMT -5. The time now is 12:32 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC