forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help with textures

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
bumper



Joined: 06 Oct 2005
Posts: 10

PostPosted: Thu Oct 06, 2005 6:20 am    Post subject: Need help with textures Reply with quote

Hi,

I am playing around with the pspsdk and I would like to replace the texture of the cube sample with a 32-bit one.

So i removed the logo.o in the Makefile and I created a 32x32x32-bit texture in the code, plus I modified few lines to replace the 64x64 4444 texture with 32x32 8888 texture.

My texture is totally white but at the screen I have strange black lines on it.

I cannot show you a screenshot but there is several black lines on the white texture. With the 32x32 texture, they are strangely located from 0px to 16px or from 16px to 32px.

I tried with a 256x256 texture and the black lines are only present at the top of the texture.

It looks like some data have been written in the texture memory area but that is not the case.

Here are the code (its compiled with c++):

Code:
static unsigned short __attribute__((aligned(16))) pixels[32*32*4];


Code:
unsigned char *pData = (unsigned char *)pixels;

for (int y = 0 ; y < 32 ; ++y)
{
   for (int x = 0 ; x < 32 ; ++x)
   {
      *(pData++) = 255;
      *(pData++) = 255;
      *(pData++) = 255;
      *(pData++) = 255;
   }
}


Code:
sceGuTexMode(GU_PSM_8888, 0, 0, 0);
sceGuTexImage(0,32, 32, 32, pixels);
sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);


1) Any idea about my corrupted texture (black lines) ?

2) Another question not related to the previous one, can I use malloc and free with the PSPSDK ? I noted that there is no dynamic allocation at all in the samples. I know that there is reserved memory area, where can I find info about that ?

Thanks in advance for any help
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Oct 06, 2005 6:30 am    Post subject: Re: Need help with textures Reply with quote

bumper wrote:
1) Any idea about my corrupted texture (black lines) ?

Flush the data cache. sceKernelDcacheWritebackAll()
Quote:

2) Another question not related to the previous one, can I use malloc and free with the PSPSDK ?
Yes.
Back to top
View user's profile Send private message
bumper



Joined: 06 Oct 2005
Posts: 10

PostPosted: Thu Oct 06, 2005 6:44 am    Post subject: Reply with quote

I tried sceKernelDcacheWritebackAll() and there is no change.

Something else, when I launch the demo, some black lines on the texture (but not all) progressively disappear after 1 or 2 seconds :S
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Oct 06, 2005 6:59 am    Post subject: Reply with quote

Paste your full code at rafb.net/paste
Back to top
View user's profile Send private message
bumper



Joined: 06 Oct 2005
Posts: 10

PostPosted: Thu Oct 06, 2005 7:07 am    Post subject: Reply with quote

Thanks for helping

http://rafb.net/paste/results/vLoxIb95.html
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Oct 06, 2005 7:33 am    Post subject: Reply with quote

I also saw the black lines. I added sceKernelDcacheWritebackAll() at line 143 (before "for(;;)") and they went away.
Back to top
View user's profile Send private message
bumper



Joined: 06 Oct 2005
Posts: 10

PostPosted: Thu Oct 06, 2005 7:49 am    Post subject: Reply with quote

Thanks Jim!

I tried to put sceKernelDcacheWritebackAll() just after SetupCallbacks like the envmap sample and at that place it did nothing.

Now it works great :)

btw I do not understand what does sceKernelDcacheWritebackAll(), could you please explain me what is the data cache and what lines are affected by that call ?
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Oct 06, 2005 8:31 am    Post subject: Reply with quote

CPUs have a small cache of fast on-board memory that is used to avoid accessing slower main memory when possible. The CPU takes care of writing that cache back to main memory at some unknown later time. The GU doesn't know about this cache and accesses the main memory directly, so anytime you want to put something in memory and have the GU access it, you need to tell the CPU to make sure that the contents of the cache are written back to main memory first.
Back to top
View user's profile Send private message
bumper



Joined: 06 Oct 2005
Posts: 10

PostPosted: Thu Oct 06, 2005 8:47 am    Post subject: Reply with quote

Thx again :)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group