textures, blitting, array in VRAM, and etc...

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
outtony
Posts: 26
Joined: Thu Oct 13, 2005 2:46 am
Location: Slovakia
Contact:

textures, blitting, array in VRAM, and etc...

Post by outtony »

hello, everyone.
i have some few questions.

1st: i tried to programmed some tests, few models from maya with one texture coded to 5650 or 4444 16 bit - just for test.

now i coded own convertor for textures from 4bit indexed and 16bit palette 5650 up to 32b 8888 format. Tester for 8kb cache (if converted texture will be equal or less than 8kb), swizzler and etc..... (any improvments?)
BUT, in ogl i had a managment of textures, that could bind any texture. I used
glBindTexture(GL_TEXTURE_2D, texture_id);

is this command(s) equal?

sceGuTexMode(GU_PSM_5650,0,0,0); //propably needed?
sceGuTexImage(0,128,128,128,texture_data);

if i want to put texture to vram (in ogl automatically, if vram was free enought), i have to use
void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void* src, int dx, int dy, int destw, void* dest);
and then dest is a pointer to data, so i should call:

sceGuTexMode(GU_PSM_5650,0,0,0);
sceGuTexImage(0,128,128,128,dest);

is palette of indexed texure possible to load to vram too?

2nd: HOW can I in hell put vertices and other stuff in array to VRAM?

i am using model with indexes:

sceGumDrawArray (GU_TRIANGLES, GU_TEXTURE_8BIT|GU_COLOR_4444|GU_VERTEX_32BITF|GU_TRANSFORM_3D|GU_INDEX_16BIT, 8172, model_i_start, model_start);

this components are for max mem saving:
GU_TEXTURE_8BIT
GU_COLOR_4444
GU_VERTEX_32BITF
GU_INDEX_16BIT

i tried to reduce it more, but it was little bit unnatural. could it be reduced more? why in the hell, there's no GU_VERTEX_16BITF? in a lot of models, it should be enought

PS: sorry for my terrible english ;-)
-----------------------------
Tony

www.n3.sk
holger
Posts: 204
Joined: Thu Aug 18, 2005 10:57 am

Post by holger »

Use pspgl if you want access the GE using OpenGL semantics. Prefer the SVN version if you provide your data in PSP native format, or Jeremy's tree if you want to let the library handle the texture and vertex format conversion.
User avatar
outtony
Posts: 26
Joined: Thu Oct 13, 2005 2:46 am
Location: Slovakia
Contact:

Post by outtony »

holger wrote:Use pspgl if you want access the GE using OpenGL semantics. Prefer the SVN version if you provide your data in PSP native format, or Jeremy's tree if you want to let the library handle the texture and vertex format conversion.
dont wanna use pspgl, just tring to find native equivalent.

SVN version or Jeremy's tree? gee, i want to do it by myself :) that's why I am asking :)
-----------------------------
Tony

www.n3.sk
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Re: textures, blitting, array in VRAM, and etc...

Post by jsgf »

outtony wrote:BUT, in ogl i had a managment of textures, that could bind any texture. I used
glBindTexture(GL_TEXTURE_2D, texture_id);
Have a look at PSPGL (http://www.goop.org/psp/gl/).

LibGU is lower level than GL, and does no texture management for you.
sceGuTexMode(GU_PSM_5650,0,0,0); //propably needed?
sceGuTexImage(0,128,128,128,texture_data);

if i want to put texture to vram (in ogl automatically, if vram was free enought), i have to use
void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void* src, int dx, int dy, int destw, void* dest);
and then dest is a pointer to data, so i should call:

sceGuTexMode(GU_PSM_5650,0,0,0);
sceGuTexImage(0,128,128,128,dest);
Yep, that's basically right. You need to make sure the texture has been flushed out of the CPU cache if you've modified it.
is palette of indexed texure possible to load to vram too?
Yep.
2nd: HOW can I in hell put vertices and other stuff in array to VRAM?

i am using model with indexes:

sceGumDrawArray (GU_TRIANGLES, GU_TEXTURE_8BIT|GU_COLOR_4444|GU_VERTEX_32BITF|GU_TRANSFORM_3D|GU_INDEX_16BIT, 8172, model_i_start, model_start);

this components are for max mem saving:
GU_TEXTURE_8BIT
GU_COLOR_4444
GU_VERTEX_32BITF
GU_INDEX_16BIT

i tried to reduce it more, but it was little bit unnatural. could it be reduced more? why in the hell, there's no GU_VERTEX_16BITF? in a lot of models, it should be enought
You can use GU_VERTEX_16BIT, which is integral, so you need to scale everything by 32767. You can use the model matrix to scale your model down to the size you actually want.

Similarly, 8-bit texture coords are integral, so you need to use the texture matrix to scale them to the 0..1 range for texture coords (which I haven't had much success with), or change the texture scaling (using sceGuTexScale).

If you're new to the PSP, then the big gotcha is cache management. PSPGL handles all this for you, but otherwise see http://www.goop.org/psp/cache-howto.html.
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Re: textures, blitting, array in VRAM, and etc...

Post by jsgf »

outtony wrote:if i want to put texture to vram (in ogl automatically, if vram was free enought), i have to use
void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void* src, int dx, int dy, int destw, void* dest);
and then dest is a pointer to data, so i should call:

sceGuTexMode(GU_PSM_5650,0,0,0);
sceGuTexImage(0,128,128,128,dest);
Oh, one other thing. After the copy, you'll need:

Code: Select all

    sceGuTexSync();    // make sure the copy finishes before starting to use it
    sceGuTexFlush();   // clear the previous texture out of the GE texture cache
When you're switching between textures which are already VRAM resident, you just need the sceGuTexFlush.
User avatar
outtony
Posts: 26
Joined: Thu Oct 13, 2005 2:46 am
Location: Slovakia
Contact:

Re: textures, blitting, array in VRAM, and etc...

Post by outtony »

jsgf wrote: Have a look at PSPGL (http://www.goop.org/psp/gl/).
LibGU is lower level than GL, and does no texture management for you.
i am looking for psp native replacement, or some way to code it

is palette of indexed texure possible to load to vram too?
>Yep.

how?

2nd: HOW can I in hell put vertices and other stuff in array to VRAM?
that link is about cache, not about vram
-----------------------------
Tony

www.n3.sk
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Re: textures, blitting, array in VRAM, and etc...

Post by jsgf »

outtony wrote:
jsgf wrote: Have a look at PSPGL (http://www.goop.org/psp/gl/).
LibGU is lower level than GL, and does no texture management for you.
i am looking for psp native replacement, or some way to code it
Well, the code for PSPGL is full of useful stuff.
is palette of indexed texure possible to load to vram too?
>Yep.
how?
Copy it there and point to it. VRAM is directly accessable to the CPU; its just memory as far as software is concerned. sceGeEdramGetAddr() returns a pointer to the start.
2nd: HOW can I in hell put vertices and other stuff in array to VRAM?
that link is about cache, not about vram
Right. VRAM is just memory, so you can copy your vertex data there. But it's cachable, so you need to make sure you've flushed it.
holger
Posts: 204
Joined: Thu Aug 18, 2005 10:57 am

Re: textures, blitting, array in VRAM, and etc...

Post by holger »

outtony wrote:
jsgf wrote:Have a look at PSPGL (http://www.goop.org/psp/gl/).
LibGU is lower level than GL, and does no texture management for you.
i am looking for psp native replacement, or some way to code it
pspgl is native... what did you believed the 'psp' stands for? ;)
outtony wrote:
is palette of indexed texure possible to load to vram too?
>Yep.

how?
2nd: HOW can I in hell put vertices and other stuff in array to VRAM?
use sceGuCopyImage, you can also copy vertex data using these calls (pass stride and buffer width so that your data is continously transferred). Alternatively you can also access the DMAC directly or use memcpy, if you don't care about CPU load.
User avatar
outtony
Posts: 26
Joined: Thu Oct 13, 2005 2:46 am
Location: Slovakia
Contact:

Re: textures, blitting, array in VRAM, and etc...

Post by outtony »

oh, that's truth :)
-----------------------------
Tony

www.n3.sk
User avatar
outtony
Posts: 26
Joined: Thu Oct 13, 2005 2:46 am
Location: Slovakia
Contact:

Re: textures, blitting, array in VRAM, and etc...

Post by outtony »

holger wrote: pspgl is native... what did you believed the 'psp' stands for? ;)
yp, and that "native" gl doesnt support a lot of stuff (at the moment)
for ex. sprites primitive or vertex weights...
-----------------------------
Tony

www.n3.sk
holger
Posts: 204
Joined: Thu Aug 18, 2005 10:57 am

Post by holger »

please take a closer look, Jeremy's tree has them incorporated as extensions. More are not too hard to add.
User avatar
outtony
Posts: 26
Joined: Thu Oct 13, 2005 2:46 am
Location: Slovakia
Contact:

Post by outtony »

holger wrote:please take a closer look, Jeremy's tree has them incorporated as extensions. More are not too hard to add.
I can't google any information about it. Could you please tell me, where can I find any informations? thank you ;-)
-----------------------------
Tony

www.n3.sk
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Post by jsgf »

outtony wrote:
holger wrote:please take a closer look, Jeremy's tree has them incorporated as extensions. More are not too hard to add.
I can't google any information about it. Could you please tell me, where can I find any informations? thank you ;-)
I wrote:Have a look at PSPGL (http://www.goop.org/psp/gl/).
I don't currently have a vertex weight extension that I like yet, but I did just implement Bezier patch surfaces...

Sprites are on my TODO list, but they're trivial to add (not interesting enough to get around to).
dankydoo
Posts: 11
Joined: Tue Mar 29, 2005 2:39 am

Post by dankydoo »

Ahh, yes, I was hoping that you would implement Bezier patches soon....are they in your repository yet?

dankydoo
jsgf
Posts: 254
Joined: Tue Jul 12, 2005 11:02 am
Contact:

Post by jsgf »

dankydoo wrote:Ahh, yes, I was hoping that you would implement Bezier patches soon....are they in your repository yet?
Soon, probably within a few hours. I want to clean things up a little bit and publish some demo binaries to show things off. Spot lighting+bezier surfaces looks really cool.
Post Reply