Using PSPGE for graphic engine

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
dridri
Posts: 34
Joined: Fri Jul 31, 2009 1:47 am

Using PSPGE for graphic engine

Post by dridri »

Im creating a Graphic Engine, but i dont want to use the PSPGu, because the PSPGu is not the better way for that. It's too slow, example :

Code: Select all

void myEngineEnable(int state){
    sceGuEnable(state);
}
It's too much, because the CPU makes two calls for one operation.


All compiles okay, but the program stops at sceGeSyncList, and I d'ont know why.
Initialization :

Code: Select all

static unsigned int __attribute__((aligned(16))) ge_init_list[] = { ...... }; //The same as PSPGU

unsigned int __attribute__((aligned(16))) DisplayList[262144] = { 0 };
void createContext(){
	libge_context = &libge_contexts[0];
	ge_edram_address = (u32)sceGeEdramGetAddr();

	// initialize graphics hardware
	ge_list_executed[0] = sceGeListEnQueue((void*)((unsigned int)ge_init_list & 0x1fffffff), 0, 0, 0);
	sceGeListSync(ge_list_executed[0], 0); //This works good, so the PSPGE is initialized ?!

	libge_context->dList.start = DisplayList;
	libge_context->dList.current = libge_context->dList.start;
	libge_context->clear_color = 0xffffffff;


	//The same as PSPGU, in sceGuStart
	static int dither_matrix[16] = {
		-4, 0,-3, 1,
		 2,-2, 3,-1,
		-3, 1,-4, 0,
		 3,-1, 2,-2
	};
	geSetDither((ScePspIMatrix4*)dither_matrix);
	geSendCommandi&#40;CMD_PATCH_DIVIDE, &#40;16 << 8&#41;|16&#41;;
	geSendCommandi&#40;CMD_MATERIAL, GU_AMBIENT|GU_DIFFUSE|GU_SPECULAR&#41;;
	geSendCommandf&#40;CMD_SPECULAR, 1.0f&#41;;
	geSendCommandf&#40;CMD_TEX_SCALE_U, 1.0f&#41;;
	geSendCommandf&#40;CMD_TEX_SCALE_V, 1.0f&#41;;
&#125;
//initialization of my Lib

Code: Select all

void Init&#40;&#41;&#123;
	createContext&#40;&#41;;

	geDrawBuffer&#40;GU_PSM_8888, 0, 512&#41;;
	geDispBuffer&#40;&#40;void*&#41;&#40;512*272*4&#41;, 480, 272&#41;;
	geScissor&#40;0, 0, 480, 272&#41;;

	geAmbientColor&#40;0xffffffff&#41;;
	geDisable&#40;GE_DEPTH_TEST&#41;;
	geEnable&#40;GE_TEXTURE_2D&#41;;

	geDrawSync&#40;&#41;; //The bug is in this function
&#125;
//The sync function

Code: Select all

void geDrawSync&#40;&#41;&#123;
	*&#40;libge_context->dList.current++&#41; = 0x0f000000;
	*&#40;libge_context->dList.current++&#41; = 0x0c000000;
	*&#40;libge_context->dList.current++&#41; = 0x00000000;
	*&#40;libge_context->dList.current++&#41; = 0x00000000;

	ge_list_executed&#91;0&#93; = sceGeListEnQueue&#40;libge_context->dList.start, libge_context->dList.current, 0, NULL&#41;;
	pspDebugScreenPrintf&#40;"SyncList...\n"&#41;;
	sceGeListSync&#40;ge_list_executed&#91;0&#93;, PSP_GE_LIST_DONE&#41;;
	//The program stops running here &#40;i can see "SyncList..." on screen, but not "Ok"
	pspDebugScreenPrintf&#40;"Ok\n"&#41;;
	sceGeDrawSync&#40;PSP_GE_LIST_DRAWING_DONE&#41;;

	libge_context->dList.current = libge_context->dList.start; //Reset list
&#125;
Thanks to people who knows PSPGE and want help me ...
I'm French, and 15 years old, so my English is not good...
dridri
Posts: 34
Joined: Fri Jul 31, 2009 1:47 am

Post by dridri »

I resolved the problem ! Very simple ^^.

The PSPGE uses a GPU local address for the displayList, so :

Code: Select all

libge_context->dList.start = &#40;u32*&#41;&#40;&#40;u32&#41;DisplayList | 0x40000000&#41;;
I'm French, and 15 years old, so my English is not good...
svxs
Posts: 15
Joined: Fri Jun 19, 2009 10:03 am

Post by svxs »

My advice is to not reinvent the wheel. If the GU functions do it fine by themselves, why wrap them? If you're intent on it, then use a macro:

Code: Select all

#define myEngineEnable&#40;State&#41; sceGuEnable&#40;State&#41;
Not much point in a library that renames standardized/common functions from the SDK, though.
dridri
Posts: 34
Joined: Fri Jul 31, 2009 1:47 am

Post by dridri »

svxs wrote:My advice is to not reinvent the wheel. If the GU functions do it fine by themselves, why wrap them?
That's the difference, in reality certain things are not good inthe PSPGU, and I want to make a low-level library.
I'm French, and 15 years old, so my English is not good...
fungos
Posts: 41
Joined: Wed Oct 31, 2007 10:43 am
Location: cwb br
Contact:

Re: Using PSPGE for graphic engine

Post by fungos »

dridri wrote:example :

Code: Select all

void myEngineEnable&#40;int state&#41;&#123;
    sceGuEnable&#40;state&#41;;
&#125;
It's too much, because the CPU makes two calls for one operation.
svxs wrote:

Code: Select all

#define myEngineEnable&#40;State&#41; sceGuEnable&#40;State&#41;
Or, you can inline it when doing wrapping. I think it is better than macro if you have a decent compiler as gcc.
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Re: Using PSPGE for graphic engine

Post by jojojoris »

dridri wrote:

Code: Select all

void myEngineEnable&#40;int state&#41;&#123;
    sceGuEnable&#40;state&#41;;
&#125;
It's too much, because the CPU makes two calls for one operation.
Do you know what a compiler does??? I think it doesn't make any sense since to compiler does optimalisation which will probable reduce the actual number CPU calls to a minimum.

Code: Select all

int main&#40;&#41;&#123;
     SetupCallbacks&#40;&#41;;
     makeNiceGame&#40;&#41;;
     sceKernelExitGame&#40;&#41;;
&#125;
Post Reply