| View previous topic :: View next topic |
| Author |
Message |
bumper
Joined: 06 Oct 2005 Posts: 10
|
Posted: Thu Oct 06, 2005 6:20 am Post subject: Need help with textures |
|
|
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 |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Oct 06, 2005 6:30 am Post subject: Re: Need help with textures |
|
|
| 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 |
|
 |
bumper
Joined: 06 Oct 2005 Posts: 10
|
Posted: Thu Oct 06, 2005 6:44 am Post subject: |
|
|
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 |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Oct 06, 2005 6:59 am Post subject: |
|
|
| Paste your full code at rafb.net/paste |
|
| Back to top |
|
 |
bumper
Joined: 06 Oct 2005 Posts: 10
|
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Oct 06, 2005 7:33 am Post subject: |
|
|
| I also saw the black lines. I added sceKernelDcacheWritebackAll() at line 143 (before "for(;;)") and they went away. |
|
| Back to top |
|
 |
bumper
Joined: 06 Oct 2005 Posts: 10
|
Posted: Thu Oct 06, 2005 7:49 am Post subject: |
|
|
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 |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Oct 06, 2005 8:31 am Post subject: |
|
|
| 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 |
|
 |
bumper
Joined: 06 Oct 2005 Posts: 10
|
Posted: Thu Oct 06, 2005 8:47 am Post subject: |
|
|
| Thx again :) |
|
| Back to top |
|
 |
|