Page 1 of 1

gsKit documentation? here ?

Posted: Mon Apr 16, 2007 4:12 am
by cosmito
Hi

I've got it from
svn://svn.ps2dev.org/ps2/trunk/gsKit

OK. In the README when can find :
Project Layout
-----------------------------------------------------------------------

A source or binary release of gsKit will include the following
directories:

gsKit/lib - gsKit compiled libraries.
gsKit/doc - gsKit documentation.
gsKit/examples - Example projects demonstrating use of gsKit.
gsKit/ee - ee root directory.
gsKit/ee/gs - gsKit source root.
gsKit/ee/gs/include - gsKit include files.
gsKit/ee/gs/src - gsKit source files.
gsKit/ee/dma - dmaKit source root.
gsKit/ee/dma/include - dmaKit include files.
gsKit/ee/dms/src - dmaKit source files.
gsKit/vu1 - VU1 assembly files.
So, why is the gsKit/doc folder is missing from the SVN ?
Is it somewhere else ?

Posted: Tue Apr 17, 2007 5:45 am
by tmator_
There is no doc here, you can do it :)

If you need help, see sample or ask on the forum

Posted: Thu Apr 19, 2007 2:13 am
by Neovanglist
Blame me :)

I have a quite nice docset I've been working on however it is not complete yet.

For now you can get long way by looking at the examples in examples/.

They document how to use just about every feature of gsKit, as I use them for regression testing. (And they are quite simple code wise)

There are big changes in progress on gsKit (VU1/mskpath3/etc) and when I release the new version of gsKit it'll be with a finished .pdf document.

Posted: Mon Nov 16, 2009 7:21 am
by barf
Still no documentation for this?

So how would I use gsKit to
---
1) set resolution 480p
2) load and image from hdd0:/+MyProject/images/image01.png
3) display that image on the screen?
4) use any button on the stick, f ex R2, to circle through 576p, 576i, 480p and 480i
---

Posted: Mon Nov 16, 2009 10:48 pm
by ragnarok2040
1)
  • gsGlobal = gsKit_init_global();
    gsGlobal->Mode = GS_MODE_DTV_480P;
    gsGlobal->Interlace = GS_NONINTERLACED;
    gsGlobal->Field = GS_FRAME;
    gsGlobal->Width = 720;
    gsGlobal->Height = 480;
    gsKit_init_screen(gsGlobal);
2)
  • Make sure libpng support is compiled into gsKit.
    Load the relevant iop modules for hdd access.
    Mount your +MyProject partition into a free partition slot

    gsKit_texture_png(gsGlobal, myTexture, pfs0:/images/image01.png);
3)
  • Draw a textured primitive using your texture and texture's information.
    If you're in persistent mode, you don't need to redraw in a loop just
    If you're in oneshot mode, you need to redraw your primitive every loop.
    The examples show how to do this.
4)
  • You need to initialize your controller using libpad.
    Change the relevant attributes as listed in 1 to define the mode you want.
    Then call gsKit_init_screen(gsGlobal); which will reset gsKit.
    You'll need to reupload your textures and such.
    Look at gsInit.c for the display attributes you can use per mode as you can magnify your draw buffer for larger screens without sacrificing vram. The vsync example has multiple examples for different modes.
I tried to answer your questions as best as I could. Specific answers would require quite a large amount of space, heh. The best way to understand gsKit, at least for drawing, would be to look at libgs's source and its examples in ps2sdk, then compare the libraries together.

A guide to gsKit:

Global Init:
This gsKit_init_global function allocates memory, sets sane defaults for the gsGlobal values, and returns the structure as a pointer to its location. This is done before all else.

DMAKit Init:
The examples show how to do this. GSKit is a GIF (path3) only library so you should only need dmaKit_init(...); and dmaKit_chan_init(DMA_CHANNEL_GIF);. I think the FROMSPR and TOSPR channel inits are leftovers when gsKit still used scratchpad ram. This is done prior to using any function of gsKit except for gsKit_init_global.

Screen Init:
The gsKit_init_screen function will reset the mode and initialize the screen defined in the gsGlobal. It also sets up the drawing environment as well, so changes to your drawing environment values in gsGlobal will be reflected in the reset screen.

DE Info:
The drawing environment registers are static, so if you change a register, it changes it for every primitive drawn after the change. You can change, draw a primitive, change again, to do it on a per-primitive basis. The problem is that they're lumped in with the generic registers used for drawing as well. You can generally tell what a drawing environment register is by seeing if it has its own setter. Libgs is a great example for this. The textured primitives change the texture registers in order to map the texture onto them.

DMA Info:
GSKit uses two "pools" of dma space.
A "pool" is allocated memory to store the queue.
The "queue" is what you are currently drawing and is stored in the pool.
Drawing something specific on the PS2 takes multiple primitives, so the method is to start a dma chain(queue) for the express purpose of drawing the specific "something". GSKit takes this approach but separates it, so your primitives are stored in either a persistent queue or oneshot queue. The larger the queue gets, the more it fills the pool so it's quite possible to "flood" the pool.

Queues:
Persistent mode is the "Set it and forget it" pool, where you draw everything once, and it stays in the pool until you manually clear the queue.
Oneshot mode is a double-buffered pool, where when the queue is executed, the pool is switched allowing you to fill it again.

Primitives:
You call a function with the primitive's attributes as its parameters and it gets drawn by gsKit by filling the queue with tags that are filled by the parameters.

Primitive tags:
A "qword" is a 128-bit integer.
Primitives are made up of multiple tags or qwords. These tags set various information about the primitive. Generally, the last vertex point for the primitive (XYZ2) will kick off drawing. If you use (XYZ3) the drawing won't start. GSKit uses 64-bit memaligned pools so you need to do the first 64-bits, increment, do the next 64-bits, increment, etc... You can look at gsPrimitive.c in order to see how to draw primitives in reglist format or packed format.

Primitive tag formats:
REGLIST allows you to start the primitive using specific registers, then each qword following is 64x2 filled with data for each register in the order * NLOOP from the GIF_AD tag. If the registers are odd, then the last 64-bits is ignored. The point primitive is a good example for this.
PACKED is where each qword is data+register, where the first 64 bits are filled with data, and the last 64 bits is the register to put the data. The linestrip primitive is a good example for this.
I'm pretty sure only registers 0x00 - 0x0F are allowed in reglist mode.

Primitive coordinates:
The primitive coordinate system is handled by gsKit and offsets the coordinates for drawn primitives by the offset amount. This lets you draw primitives using negative coordinates. GSKit uses 2048 as the default offset value. Basically, think of a grid, and then your draw buffer starting at the offset point. Primitives coordinates would need to be at that offset point or higher to draw within your draw buffer.

I think that's about it for now :?. My fingers are getting tired :D.

Posted: Tue Nov 24, 2009 11:45 pm
by barf
Thanks! That was quiet an essay Ragnarok2040!

I also found something I will investigate here about the interlace/noninterlaced toggle http://ps2homebrewing.wordpress.com/tag/gskit/

Posted: Wed Nov 25, 2009 12:38 am
by ragnarok2040
I also found this: http://playstation2-linux.com/download/ ... l_hack.txt

It shows how to setup the read/merge circuits for removing the interlace flicker without any offset correction code. Double-buffering in gsKit is incompatible with that method, though, as it only enables one read circuit and switches the buffers for it to read. It's useful information for anyone wanting to implement a flicker-filtered single buffer interlaced display mode, though.

The macros to set the registers are all in gsInit.h.

Posted: Wed Nov 25, 2009 12:40 am
by barf
Here is an example doing more or less the same I asked for but using BMP instead. This example uses the MASS instead of internal HDD, but that’s OK.

http://ps2homebrewing.wordpress.com/200 ... de-part-2/

It also has the toggle of PAL/NTSC / non-interlaced/interlaced