Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 22, 2013, 08:51 PM   #1
mif
macrumors regular
 
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, 12: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, 12:11 AM   #3
mif
Thread Starter
macrumors regular
 
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:30 AM.

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

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