| View previous topic :: View next topic |
| Author |
Message |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Tue Jan 31, 2006 6:38 pm Post subject: Anyone had success with >8bpp indexed textures? |
|
|
I've played with them a bit, but I can't get them to come out right. Is there something stupid I'm overlooking? I'm assuming the index is little-endian, and the CLUT is just linear in memory, and then doing the equivalent of | Code: | sceGuClutMode(GU_PSM_8888, 0, 0xff, 0);
sceGuClutLoad(65536/8, myclut); |
(BTW, "a2" for sceGuClutMode() need to be 0xff; I think its a bit mask which is applied to something, but I'm not quite sure what.)
I'm wondering if large CLUTs need to be uploaded/installed in pieces or something.
Any ideas? |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Tue Jan 31, 2006 8:54 pm Post subject: |
|
|
/**
* Upload CLUT (Color Lookup Table)
*
* NOTE: Data must be aligned to 1 quad word (16 bytes)
*
* @param num_blocks - How many blocks of 8 entries to upload (32*8 is 256 colors)
* @param cbp - Pointer to palette (16 byte aligned)
**/
void sceGuClutLoad(int num_blocks, const void* cbp);
a) make sure myclut was aligned on 16 byte on allocation
b) you're trying to submit (65536/8) * 8 = 65536 entries. Yet a CLUT4 has only 16 and a CLUT8 only 256 entries. So the only two possible parameters for num_blocks would be 2 or 32. |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Wed Feb 01, 2006 4:55 am Post subject: |
|
|
| Raphael wrote: | | a) make sure myclut was aligned on 16 byte on allocation |
Yup, got that.
| Quote: | | b) you're trying to submit (65536/8) * 8 = 65536 entries. Yet a CLUT4 has only 16 and a CLUT8 only 256 entries. So the only two possible parameters for num_blocks would be 2 or 32. |
No, you missed my point. The hardware appears to also support 16 and 32 bit CLUT indices (see src/gu/doc/commands.txt for command 195), but I can't get them to do anything useful. |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Wed Feb 01, 2006 5:55 am Post subject: |
|
|
Well, apart from the fact that I don't get the point, why anyone would use a 16 or even 32bit indexed palette as it's only memory waste and nothing else... did you set
sceGuTexMode(GU_PSM_T16, maxmips, a2, swizzle) and also upload the texture correctly? I'd guess the GU needs to know the tex mod
Also GU_PSM_T16 isn't mentioned in the description of the function although it is defined in the gu header. So probably it's not correctly implemented yet?
You could however send the raw commands to the gu and try your luck. Should be something like this:
| Code: |
sceGuSendCommandi(0xC3, 6); // Texture Pixel Storage Format CLUT16
sceGuSendCommandi(0xC5, (11b | (0xff << 8)) ); // Set CLUT8888 (bit order could be wrong)
sceGuSendCommand(0xB0, ((int)CLUT) & 0xfffffff ); // send 24 LSB of clut pointer
sceGuSendCommand(0xB1, ((int)CLUT) >> 24 ); // send 4 MSB of clut pointer
sceGuSendCommandi(0xC4, 65536/8); // Set number of Colors and upload the data
|
I haven't tried anything like that yet, though. But if the GU really supports it, this has to work. |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Wed Feb 01, 2006 8:02 am Post subject: |
|
|
| Raphael wrote: | | Well, apart from the fact that I don't get the point, why anyone would use a 16 or even 32bit indexed palette as it's only memory waste and nothing else... |
I've been working on two uses:- Using the depth buffer as a texture, and using the CLUT to tint the depth buffer in interesting ways. chp has a demo where you can use the depth buffer as an 8bpp format texture (by scaling it down so it ignores every second byte), but using it in 16bpp format could be useful.
- for general colour transforms: if render into a texture with 16bpp, then you can use the texture as a 16-bit index texture, and apply arbitrary colour transforms with the CLUT.
But I haven't had much success with either of these. It seems to only use the lower 8 bits of the index either way (though it does seem to treat them as 16-bit indices).
I suspect the other arguments to sceGuClutMode() are the key. I wonder if you can only use 2^8 CLUT entries at once, but the other params to ClutMode define how your 16/32bpp index gets mapped to the 2^8 entries...
| Quote: | sceGuTexMode(GU_PSM_T16, maxmips, a2, swizzle) and also upload the texture correctly? I'd guess the GU needs to know the tex mod
Also GU_PSM_T16 isn't mentioned in the description of the function although it is defined in the gu header. So probably it's not correctly implemented yet? |
I don't think there's anything special to implement. The existing sceGuClutMode/ClutLoad are equivalent to your open-coded versions. |
|
| Back to top |
|
 |
sandberg
Joined: 05 Oct 2005 Posts: 90 Location: Denmark
|
Posted: Wed Feb 01, 2006 9:16 am Post subject: |
|
|
| jsgf wrote: |
I suspect the other arguments to sceGuClutMode() are the key. I wonder if you can only use 2^8 CLUT entries at once, but the other params to ClutMode define how your 16/32bpp index gets mapped to the 2^8 entries...
|
I played around with these parameters a some point, for the same reason as you, but I didn't get to understand it all and haven't looked at it since.
As I remember the second argument is a shift value and the third is a mask (or the other way around, try setting one to zero and play with the other, the shift value is quite easy to find). The last parameter is probably the interesting part, which I never got to understand, only getting some strange stuff that didn't make sense.
I you figure out the last part, please post, since I could still use it :) _________________ Br, Sandberg |
|
| Back to top |
|
 |
rinco
Joined: 21 Jan 2005 Posts: 255 Location: Canberra, Australia
|
Posted: Wed Feb 01, 2006 7:15 pm Post subject: |
|
|
| I also spent many hours trying to get 16 or 32bpp CLUT to work with SDL video (so noiz2sa can do hw accelerated blits and rects). In the end I decided that not enough is known about the parameters to sceGuClutMode - and gave up. |
|
| Back to top |
|
 |
subbie
Joined: 05 May 2005 Posts: 122
|
Posted: Thu Feb 02, 2006 3:21 am Post subject: |
|
|
I have a question. Are you trying to make an index table greater then 256 entries? I am a little confused on what your trying to do. Like on my project iris I use cluts but reduce textures to less then 256 entries but each entrie in the clut is 32bit 8888 rgba.
Also when you render your texture you making to the proper mode?
Like if your going to use a 16bit/32bit clut (in size, not color depth), setting the texture mode to GU_PSM_T16/GU_PSM_T32. |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Thu Feb 02, 2006 3:43 am Post subject: |
|
|
| I'm generating a 64k entry table with RGBA8888 colours in each entry, and then using a 16bit-per-pixel texture with the mode set to GU_PSM_T16. |
|
| Back to top |
|
 |
ayatollah
Joined: 04 Sep 2005 Posts: 15
|
Posted: Thu Feb 02, 2006 8:44 am Post subject: |
|
|
Well in the official Docs of Library 1.5 it says:
** Please do not spread me like butter on a hot summer day **
Yes edited by blackdroid. |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Thu Feb 02, 2006 8:51 am Post subject: |
|
|
| ayatollah wrote: | | Well in the official Docs of Library 1.5 it says: |
Hey! Don't ever do that! It's an absolute no-no to post any official docs here. |
|
| Back to top |
|
 |
PeterM
Joined: 31 Dec 2005 Posts: 125 Location: Edinburgh, UK
|
Posted: Thu Feb 02, 2006 8:51 am Post subject: |
|
|
| Why are you posting official Sony SDK material here?! Can a moderator please delete this? |
|
| Back to top |
|
 |
Raphael

Joined: 17 Jan 2006 Posts: 646 Location: Germany
|
Posted: Fri Feb 03, 2006 2:42 am Post subject: |
|
|
Come to think, since we mask the indices with 0xff, only the lower 8bit would be used, thus only 256 of the 65536 or more only be used. So we'd have to apply a mask 0xffff, but this isn't possible, because the mask sent can be only 8bit wide. However there's the shift argument as sandberg said and if it does what I suspect, you'd have to call sceGuClutMode with the appropriate shift bit, so you can reach the higher regions of the CLUT. This would mean that you really can only use 256CLUT entries at once, and have to change the shift bit everytime you want to access higher values. So it would be a real pain in the ass to make it work as we want.
But that's just my enlightening thoughts I came up with. |
|
| Back to top |
|
 |
jsgf
Joined: 12 Jul 2005 Posts: 254
|
Posted: Fri Feb 03, 2006 3:36 am Post subject: |
|
|
| Yeah, I'm not sure what they were thinking. You could use it to do channel-by-channel remappings in 3 passes. |
|
| Back to top |
|
 |
|