sceGuGetMemory Question

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

Moderators: cheriff, TyRaNiD

Post Reply
roland
Posts: 13
Joined: Sat Feb 11, 2006 9:11 pm

sceGuGetMemory Question

Post by roland »

Hi

I was wondering if anyone here could help me..

I am trying to draw 40x22 Faces on the Screen and I can not get it to work.. It works fine with 32x18 and I strongly think I am simply having Memory allocation Problems:

Code: Select all


#define FACE_MAX_W 40
#define FACE_MAX_H 22

typedef struct Vertex_Color
{
	unsigned int color;
	float x,y,z;
} Vertex_Color;

face_horizGridStep = FACE_MAX_W;
face_vertiGridStep = FACE_MAX_H;

	int res_horizStep = SCR_WIDTH/face_horizGridStep;
	int res_vertiStep = SCR_HEIGHT/face_vertiGridStep;

	Vertex_Color * faces = (struct Vertex_Color*)sceGuGetMemory(face_horizGridStep*face_vertiGridStep*6*sizeof(Vertex_Color));

	// Build the grid
	int counter = 0;
	int intcnt = 0;

	for &#40;x = 0; x < face_horizGridStep; x++&#41; 
	&#123;
		for &#40;y = 0; y < face_vertiGridStep; y++&#41; 
		&#123;                 
			faces&#91;counter&#93;.color = GU_ABGR&#40;0xff,0,0,0&#41;;
			faces&#91;counter&#93;.x = &#40;x * res_horizStep&#41;+&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter&#93;.y = &#40;y * res_vertiStep&#41;+&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter++&#93;.z = 0;

			faces&#91;counter&#93;.color = GU_ABGR&#40;0xff,0,0,0&#41;;
			faces&#91;counter&#93;.x = &#40;&#40;x + 1&#41; * res_horizStep&#41;-&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter&#93;.y = &#40;y * res_vertiStep&#41;+&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter++&#93;.z = 0;

			faces&#91;counter&#93;.color = GU_ABGR&#40;0xff,0,0,0&#41;;
			faces&#91;counter&#93;.x = &#40;x * res_horizStep&#41;+&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter&#93;.y = &#40;&#40;y + 1&#41; * res_vertiStep&#41;-&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter++&#93;.z = 0;


			faces&#91;counter&#93;.color = GU_ABGR&#40;0xff,0,0,0&#41;;
			faces&#91;counter&#93;.x = &#40;&#40;x + 1&#41; * res_horizStep&#41;-&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter&#93;.y = &#40;y * res_vertiStep&#41;+&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter++&#93;.z = 0;

			faces&#91;counter&#93;.color = GU_ABGR&#40;0xff,0,0,0&#41;;
			faces&#91;counter&#93;.x = &#40;&#40;x + 1&#41; * res_horizStep&#41;-&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter&#93;.y = &#40;&#40;y + 1&#41; * res_vertiStep&#41;-&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter++&#93;.z = 0;

			faces&#91;counter&#93;.color = GU_ABGR&#40;0xff,0,0,0&#41;;
			faces&#91;counter&#93;.x = &#40;x * res_horizStep&#41;+&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter&#93;.y = &#40;&#40;y +1&#41; * res_vertiStep&#41;-&#40;intensity_map&#91;intcnt&#93;/4&#41;; 
			faces&#91;counter++&#93;.z = 0;
			intcnt++;
		&#125;
	&#125;

	sceGumDrawArray&#40;GU_TRIANGLES,GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_2D,counter,0,faces&#41;;

sceGuGetMemory in this case is allocting 40*22*6*16 = 84480 Bytes which should by ok right?!?

The Max List Size (if that is of any concern here, I am quite unsure!) is the usual with 262144 (from the Samples)..

is sceGuGetMemory allocating in VRAM or standard RAM? How much is there to allocate and what's the maximum that can be done!?

Your help is greatly appreciated

Roland
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

Code: Select all

Vertex_Color * faces = &#40;struct Vertex_Color*&#41;sceGuGetMemory&#40;face_horizGridStep*face_vertiGridStep*6*sizeof&#40;Vertex_Color&#41;&#41;;
you define as a new type of Vertex_Color so you do not need the struct keyword for above casting

and just some notes:

Code: Select all

void* sceGuGetMemory &#40; int size &#41;;
Note:
This function is NOT for permanent memory allocation, the memory will be invalid as soon as you start filling the same display list again.
10011011 00101010 11010111 10001001 10111010
Post Reply