Skip to main content

texture-anim-funcs

source

Variables


*fog-texture-work*

*fog-texture-work*: fog-texture-worksource

texture-anim-h

source

Types


clut16x16

clut16x16: structuresource
Fields
clut: rgba

fog-texture-work

fog-texture-work: structuresource
Fields
corner: vector
const: vector
min-corner: vector
max-corner: vector
fog-near: float
fog-far: float
fog-delta: float
alpha-near: float
alpha-far: float
alpha-delta: float
color: uint32

fog8x256

fog8x256: structuresource
Fields
image: uint8

noise128x128

noise128x128: structuresource
Fields
image: uint8

noise16x16

noise16x16: structuresource
Fields
image: uint8

noise32x32

noise32x32: structuresource
Fields
image: uint8

noise64x64

noise64x64: structuresource
Fields
image: uint8

noise8x8

noise8x8: structuresource
Fields
image: uint8

texture-anim

texture-anim: structuresource
Fields
num-layers: uint32
func: symbol
func-id: basic
init-func: symbol
init-func-id: basic
tex: texture
tex-name: string
extra: vector
color: rgba
frame-time: float
frame-delta: float
frame-mod: float
test: gs-test
alpha: gs-alpha
clamp: gs-clamp
data: texture-anim-layer
Methods
texture-anim-method-9: unknown
texture-anim-method-10: unknown

texture-anim-array

texture-anim-array: arraysource
Fields
type: type
length: int32
allocated-length: int32
content-type: type
data: uint8
array-data: texture-anim
Methods
texture-anim-array-method-9: unknown
texture-anim-array-method-10: unknown

texture-anim-layer

texture-anim-layer: structuresource
Fields
extra: vector
func: symbol
func-id: basic
init-func: symbol
init-func-id: basic
tex: texture
start-time: float
end-time: float
tex-name: basic
test: gs-test
alpha: gs-alpha
clamp: gs-clamp
start-color: vector
start-scale: vector2
start-offset: vector2
start-st-scale: vector2
start-st-offset: vector2
start-qs: vector
start-rot: degrees
start-st-rot: degrees
end-color: vector
end-scale: vector2
end-offset: vector2
end-st-scale: vector2
end-st-offset: vector2
end-qs: vector
end-rot: degrees
end-st-rot: degrees
Methods
texture-anim-layer-method-9: unknown
texture-anim-layer-method-10: unknown

texture-anim-work

texture-anim-work: structuresource
Fields
erase-tmpl: dma-gif-packet
draw-tmpl: dma-gif-packet
draw2-tmpl: dma-gif-packet
fill-tmpl: dma-gif-packet
adgif-tmpl: dma-gif-packet
corner0: vector
corner1: vector
corner2: vector
corner3: vector
const: vector
random: vector
random-index: uint8

Variables


*clut-translate*

*clut-translate*: pointersource

texture-anim-tables

source

Functions


set-cloud-minmax!

set-cloud-minmax!(arg0: float, arg1: float) => nonesource

set-darkjak-texture-morph!

set-darkjak-texture-morph!(arg0: float) => nonesource

set-fog-height!

set-fog-height!(arg0: float) => nonesource

Variables


*bomb-texture-anim-array*

*bomb-texture-anim-array*: texture-anim-arraysource

*darkjak-texture-anim-array*

*darkjak-texture-anim-array*: texture-anim-arraysource

*skull-gem-texture-anim-array*

*skull-gem-texture-anim-array*: texture-anim-arraysource

*sky-texture-anim-array*

*sky-texture-anim-array*: texture-anim-arraysource

*waterfall-b-texture-anim-array*

*waterfall-b-texture-anim-array*: texture-anim-arraysource

*waterfall-texture-anim-array*

*waterfall-texture-anim-array*: texture-anim-arraysource

texture-anim

source

Functions


update-texture-anim

update-texture-anim(id: bucket-id) => nonesource

texture-h

source

Types


adgif-shader

adgif-shader: structuresource
Fields
quad: qword
prims: gs-reg64
reg-0: uint8
reg-1: uint8
reg-2: uint8
reg-3: uint8
reg-4-u32: gs-reg32
reg-4: uint8
tex0: gs-tex0
tex1: gs-tex1
miptbp1: gs-miptbp
clamp: gs-clamp
clamp-reg: gs-reg64
alpha: gs-alpha
alpha-as-miptb2: gs-miptbp
link-test: link-test-flags
texture-id: texture-id
next: shader-ptr

adgif-shader-array

adgif-shader-array: inline-array-classsource
Fields
type: type
length: int32
allocated-length: int32
_data: uint8
data: adgif-shader

shader-ptr

shader-ptr: uint32source

texture

texture: basicsource
Fields
type: type
w: int16
h: int16
num-mips: uint8
tex1-control: uint8
psm: gs-psm
mip-shift: uint8
clutpsm: uint16
dest: uint16
clutdest: uint16
width: uint8
name: string
size: uint32
uv-dist: float
pad: uint32
masks: texture-masks

texture-base

texture-base: structuresource
Fields
vram-page: uint32
vram-block: uint32
vram-word: uint32

texture-id

texture-id: uint32source
texture-link: structuresource
Fields
next: shader-ptr

texture-mask

texture-mask: structuresource
Fields
mask: vector4w
dist: float
long: uint64
quad: uint128

texture-masks

texture-masks: structuresource
Fields
data: texture-mask

texture-masks-array

texture-masks-array: inline-array-classsource
Fields
type: type
length: int32
allocated-length: int32
_data: uint8
data: texture-masks

texture-page

texture-page: basicsource
Fields
type: type
info: file-info
name: string
id: uint32
length: int32
mip0-size: uint32
size: uint32
segment: texture-page-segment
dram-size: uint32
pad: uint32
data: texture
Methods
relocate(obj: texture-page, loading-heap: kheap, name: pointer) => texture-pagesource

Set up a texture-page when it is loaded. This function is called by the linker when
loading is completed.

remove-data-from-heap(obj: texture-page, heap: kheap) => _type_source

Remove a texture-page's data from main memory.
This is intended to be run on textures that are permanently in VRAM.
This only works if the texture-page was the last thing added to the heap,
and does NO checking to make sure this is the case.
The texture-page and texture records are kept (just metadata), the actual image data is discarded.

get-leftover-block-count(obj: texture-page, num-segments: int, upload-offset: int) => intsource

Unused and somewhat useless function to figure out how many blocks we overflow into the next page.
This could be used with gs-largest-block to figure out how much of a page we use if we don't fit
exactly.

relocate-dests!(obj: texture-page, new-dest: int, segs: int) => nonesource

Update a texture-page so the texture-page and all its textures point to a new vram
address.

add-to-dma-buffer(obj: texture-page, arg0: dma-buffer, arg1: tex-upload-mode) => intsource

Add upload data for a texture-page. This is a simple version for non common-segment textures.

upload-now!(obj: texture-page, arg0: tex-upload-mode) => nonesource

Send the given texture-page to VRAM right now. This function doesn't return until
it has happened, and only should be used during boot.

texture-page-dir

texture-page-dir: basicsource
Fields
type: type
length: int32
entries: texture-page-dir-entry
Methods
relocate(obj: texture-page-dir, arg0: kheap, arg1: pointer) => nonesource

Set up a texture-page-dir when it is loaded.

unlink-shaders-in-heap(obj: texture-page-dir, heap: kheap) => intsource

Unlink all adgif shaders that are in heap.
This iterates through everything so it is somewhat slow.

texture-page-dir-entry

texture-page-dir-entry: structuresource
Fields
length: int16
status: uint16
page: texture-page
link: texture-link

texture-page-segment

texture-page-segment: structuresource
Fields
block-data: pointer
size: uint32
dest: uint32

texture-page-translate-item

texture-page-translate-item: structuresource
Fields
bucket: bucket-id
level-index: uint32
level-texture-page: tpage-category-u32
texture-user: texture-enable-mask-u32

texture-pool

texture-pool: basicsource
Fields
type: type
top: int32
cur: int32
allocate-func: function
font-palette: int32
segment: texture-pool-segment
segment-near: texture-pool-segment
segment-common: texture-pool-segment
common-page: texture-page
common-page-mask: int32
update-sprites-flag: symbol
update-flag: symbol
texture-enable-user: texture-enable-mask
texture-enable-user-menu: texture-enable-mask
ids: uint32
Methods
initialize!(obj: texture-pool) => _type_source

Initialize or reset the state of the texture-pool.

print-usage(obj: texture-pool) => _type_source

Print out how much of a texture-pool is used.
This is not quite right because it does not count the frame or z buffer as used space.

setup-font-texture(obj: texture-pool) => nonesource

Do relocations of font textures.

allocate-defaults(obj: texture-pool) => nonesource

Assign vram for the texture system.

login-level-textures(pool: texture-pool, lev: level, num-tpage-ids: int, tpage-ids: pointer) => nonesource

After all tpages are loaded, call this function to set up level textures.
It'll call texture-page-login on each tpage, and set up texture-page field of level.

add-level-tpage-dma(pool: texture-pool, lev: level, cat: tpage-category, bucket: bucket-id) => nonesource

Add dma to upload a tpage of a level.

allocate-vram-words!(obj: texture-pool, num-words: int) => intsource

Allocate the given number of vram words.

allocate-segment(obj: texture-pool, seg: texture-pool-segment, num-words: int) => texture-pool-segmentsource

Assign vram to the given segment.

unload-page(obj: texture-pool, arg0: texture-page) => nonesource

Unload the given texture-page from the texture-page-dir.

get-common-page-slot-by-id(obj: texture-pool, tpage-id: int) => intsource

Check to see if the given tpage should go in the common page list.
If so, return the slot. Otherwise, return -1.

update-warp-and-hud(obj: texture-pool) => nonesource

Redo the layout of warp/hud/map textures. This should be done when
a new level is added that needs new sprite textures, or a level
is unloaded and its sprite textures are no longer available.

update-sprites(obj: texture-pool) => nonesource

Redo the layout of sprite textures. This should be done when
a new level is added that needs new sprite textures, or a level
is unloaded and its sprite textures are no longer available.

mark-hud-warp-sprite-dirty(obj: texture-pool) => nonesource

Mark that we should update sprite/warp/hud/map before the next use.
This should happen when any level is loaded/unloaded.

lay-out-sprite-tex(obj: texture-pool) => nonesource

Lay out sprite textures from all levels so all can fit into
VRAM at the same time.

lay-out-hud-tex(obj: texture-pool) => nonesource

Lay out hud/map textures from all levels so all can fit into
VRAM at the same time.

lay-out-warp-tex(obj: texture-pool) => nonesource

Lay out warp textures from all levels so all can fit into
VRAM at the same time.
Also update all adgifs.

clear-ids(obj: texture-pool) => nonesource

Forget everything we have in VRAM and invalidate all caching
of common-segment textures.

texture-pool-segment

texture-pool-segment: structuresource
Fields
dest: uint32
size: uint32

texture-relocate-later

texture-relocate-later: basicsource
Fields
type: type
memcpy: symbol
dest: uint32
source: uint32
move: uint32
entry: texture-page-dir-entry
page: texture-page

Functions


texture-mip->segment

texture-mip->segment(arg0: int, arg1: int) => intsource

Figure out which segment of a tpage a given mip level of a texture will be in.
arg0 is the mip level, arg1 is the total number of mips.
higher mip level is lower detail.

Variables


*eyes-texture-base*

*eyes-texture-base*: texture-basesource

*grey-scale-base*

*grey-scale-base*: texture-basesource

*map-texture-base*

*map-texture-base*: texture-basesource

*ocean-envmap-texture-base*

*ocean-envmap-texture-base*: texture-basesource

*ocean-texture-base*

*ocean-texture-base*: texture-basesource

*skull-gem-texture-base*

*skull-gem-texture-base*: texture-basesource

*texture-masks-array*

*texture-masks-array*: texture-masks-arraysource

*texture-masks*

*texture-masks*: texture-maskssource

*texture-page-dir*

*texture-page-dir*: texture-page-dirsource

*texture-page-translate*

*texture-page-translate*: arraysource

*texture-relocate-later*

*texture-relocate-later*: texture-relocate-latersource

ct16-block-table

const ct16-block-table: arraysource

ct16s-block-table

const ct16s-block-table: arraysource

ct32-24-block-table

const ct32-24-block-table: arraysource

mt4-block-table

const mt4-block-table: arraysource

mt8-block-table

const mt8-block-table: arraysource

mz16-block-table

const mz16-block-table: arraysource

mz16s-block-table

const mz16s-block-table: arraysource

mz32-24-block-table

const mz32-24-block-table: arraysource

texture-upload

source
Expand description

this file is loaded immediately before boot textures are loaded.

Variables


*default-envmap-shader*

*default-envmap-shader*: adgif-shadersource

*generic-envmap-texture*

*generic-envmap-texture*: texturesource

texture

source
Expand description

Jak 2 texture system:

At a high level, the responsibility of the texture system is to make sure that each renderer

can use the textures it needs: the texture should be in VRAM at the right point in time, and

the renderer must know where the texture is in VRAM.



An oversimplified explanation is that each "bucket" in the rendering system needs a single

"texture page" (tpage) loaded into VRAM. Each level has a tpage for each category, where the

categories are:



tfrag (background tie/tfrag)

pris (foreground)

shrub (background shrub)

alpha

water

warp

pris2

sprite

map

sky



From the point of view of the rendering code, this oversimplification is basically true.

Renderers use textures by sending "adgif shaders" to the GS. These tell the GS how to use

the texture (mipmapping, size, format) and the location of the texture in VRAM (tbp).

When levels load, they must "log in" their adgif shaders with the texture system, and the texture

system will modify these in place so that things work.



However, behind the scenes, there are many tricks.



Texture data falls into two categories:

- boot

- common



"boot" textures are ones that are loaded on boot, transferred to VRAM, and live there forever.

"common" textures are ones that are loaded as they are needed. There's an area in VRAM

called the "common segment" that holds these.



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

basic texture page methods

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



each "texture page" is a group of textures that are (from the point of view of renderers)

loaded all at once to vram, and contain all the textures needed for one category in one level.



however, the texture system does some tricks:

texture pages are divided into three "segments". The smaller number segments contain high

resolution mipmaps of textures (needed for close up), and the high number segments contain lower ones.

by looking at the distance to the closest object, we can figure out if the near textures

are needed or not, and skip segments if needed.



additionally, some texture pages have a chunk system that allows more specific control.

Functions


adgif-shader-login

adgif-shader-login(arg0: adgif-shader) => texturesource

Initialize an adgif-shader
confirm the texture exists, and add to texture system.
Use the level system to remap the texture-id in the adgif-shader.
If the texture doesn't exist, will load it with loado.

adgif-shader-login-fast

adgif-shader-login-fast(arg0: adgif-shader) => texturesource

Initialize an adgif-shader and register with texture system, but doesn't handle missing textures.
Will remap with level info.

adgif-shader-login-no-remap

adgif-shader-login-no-remap(arg0: adgif-shader) => texturesource

Initialize an adgif-shader like adgif-shader-login, but skips
the level-remap-texture system.

adgif-shader-login-no-remap-fast

adgif-shader-login-no-remap-fast(arg0: adgif-shader) => texturesource

Initialize an adgif-shader and register with texture system, but doesn't handle missing textures.
Does not remap with level info.

adgif-shader-update!

adgif-shader-update!(arg0: adgif-shader, arg1: texture) => nonesource

Update an adgif shader in response to a texture uv-dist change.

adgif-shader<-texture!

adgif-shader<-texture!(arg0: adgif-shader, arg1: texture) => adgif-shadersource

Set up an adgif-shader from a texture.

adgif-shader<-texture-simple!

adgif-shader<-texture-simple!(arg0: adgif-shader, arg1: texture) => adgif-shadersource

dma-buffer-add-ref-texture

dma-buffer-add-ref-texture(dma-buf: dma-buffer, tex-data-ptr: pointer, width: int, height: int, tex-fmt: gs-psm) => nonesource

Add a texture upload to a dma buffer that refers to texture data.
This does not copy the texture data, but instead inserts a refernce.
This also assumes that the GS is currently set up for the right type of image upload.

gs-block-height

gs-block-height(arg0: gs-psm) => intsource

gs-block-width

gs-block-width(arg0: gs-psm) => intsource

gs-blocks-used

gs-blocks-used(arg0: int, arg1: int, arg2: gs-psm) => intsource

gs-find-block

gs-find-block(bx: int, by: int, fmt: gs-psm) => intsource

gs-largest-block

gs-largest-block(arg0: int, arg1: int, arg2: gs-psm) => intsource

gs-page-height

gs-page-height(arg0: gs-psm) => intsource

gs-page-width

gs-page-width(arg0: gs-psm) => intsource

hack-texture

hack-texture(arg0: texture) => floatsource

Some sort of uv hack for hi-res mode

link-texture-by-id(arg0: texture-id, arg1: adgif-shader) => texture-page-dir-entrysource

Link the adgif-shader to the texture specified.

lookup-level-texture-by-name

lookup-level-texture-by-name(arg0: string, arg1: level, arg2: pointer) => texturesource

Like lookup-texture-by-name, but will check texture-pages listed in this level first.
Unclear why these wouldn't be part of the texture-page-dir.

lookup-texture-by-id

lookup-texture-by-id(arg0: texture-id) => texturesource

Get a texture for the given texture-id.
This will do a load that only succeeds on development hardware if it doesn't exist.

lookup-texture-by-id-fast

lookup-texture-by-id-fast(arg0: texture-id) => texturesource

Get a texture for the given id. return #f if it doesn't exist.

lookup-texture-by-name

lookup-texture-by-name(arg0: string, arg1: string, arg2: pointer) => texturesource

Get texture by name. Slow. Return #f if it doesn't exist.

lookup-texture-id-by-name

lookup-texture-id-by-name(arg0: string, arg1: string) => texture-idsource

Get texture id by name. Slow. Return 0 if it doesn't exist.

physical-address

physical-address(ptr: pointer) => pointersource

Convert a pointer (possibly to the uncached mapping) to a 'physical address' that

relocate-later

relocate-later() => symbolsource

The other half to texture-relocate-later: this function does the pending memcpy.

set-dirty-mask!

set-dirty-mask!(arg0: level, arg1: int, arg2: int, arg3: int) => nonesource

Set dirty bits for a levels textures. This tells the texture system to reupload the texture.
even if the old version is still in vram.
Sets bits arg2 -> arg3 for page arg1.

set-skull-gem-masks

set-skull-gem-masks() => nonesource

Set the default-level texture-mask to include masks from three skull gem textures.

texture-bpp

texture-bpp(tex-fmt: gs-psm) => intsource

Get the number of bits per pixel for a texture format.

texture-page-common-allocate

texture-page-common-allocate(pool: texture-pool, tpage: texture-page, heap: kheap, tpage-id: int) => texture-pagesource

Set up a texture that will be uploaded to VRAM as needed by the texture system.
These will go in the 'common' segment.
No upload is actually done.

texture-page-common-boot-allocate

texture-page-common-boot-allocate(pool: texture-pool, tpage: texture-page, heap: kheap, tpage-id: int) => texture-pagesource

Set up texture that is loaded at boot.

texture-page-default-allocate

texture-page-default-allocate(pool: texture-pool, tpage: texture-page, heap: kheap, tpage-id: int) => texture-pagesource

Allocate a texture to be permanently stored in VRAM, and remove it from main memory.
This is only safe to call if the most recently loaded thing is this texture.
This will perform texture uploads, so this should not be called during drawing.

texture-page-dir-inspect

texture-page-dir-inspect(arg0: texture-page-dir, arg1: symbol) => nonesource

texture-page-font-allocate

texture-page-font-allocate(pool: texture-pool, tpage: texture-page, heap: kheap, tpage-id: int) => texture-pagesource

Special allocation for the font textures.
These are temporarily loaded to the common segment, then later moved.

texture-page-level-allocate

texture-page-level-allocate(pool: texture-pool, tpage: texture-page, heap: kheap, tpage-id: int) => texture-pagesource

Allocate function for level textures.

texture-page-login

texture-page-login(tex-id: texture-id, alloc-func: function, heap: kheap) => texture-page-dir-entrysource

Get a texture-page-dir-entry for the given texture.
If the texture page is not loaded, it will attempt to load it with loado, which
would only succeed on development machines.

texture-page-size-check

texture-page-size-check(pool: texture-pool, lev: level, silent: symbol) => intsource

Check sizes for level textures, return a mask with a bit set for each failing tpage.

texture-qwc

texture-qwc(width: int, height: int, tex-fmt: gs-psm) => intsource

Get the number of quadwords (16-bytes), rounded up, for a given texture size/format.

texture-relocate

texture-relocate(dma-buff: dma-buffer, tex: texture, dest-loc: int, dest-fmt: gs-psm, clut-dst: int) => dma-buffersource

Move a texture in VRAM. Unrelated to the texture-relocate-later, which moves textures in RAM.
Will try to move the whole thing, including the clut, assuming you provide a destination for it.
Note that this uses the format/width stuff properly, so it will be slower, but won't scramble your texture.

update-vram-pages

update-vram-pages(pool: texture-pool, dest-seg: texture-pool-segment, tpage: texture-page, mode: tex-upload-mode) => intsource

Copy-pasta version of the above function that just sets ids, but does no uploads.

upload-textures

upload-textures(arg0: texture-pool) => nonesource

Build DMA for all texture uploads.
This should be called after all drawing is done and all masks/distances are set.

upload-vram-data

upload-vram-data(buf: dma-buffer, dest: int, data: pointer, height: int, width: int) => nonesource

Generate DMA data to upload texture. This simply sets up a texture upload to happen in the future.
The texture data itself is referenced, not copied into the dma-buffer.

upload-vram-pages

upload-vram-pages(pool: texture-pool, dest-seg: texture-pool-segment, tpage: texture-page, mode: tex-upload-mode, bucket: bucket-id) => intsource

Build DMA for uploading the given texture-page, only uploading as needed.

upload-vram-pages-pris

upload-vram-pages-pris(pool: texture-pool, dest-seg: texture-pool-segment, tpage: texture-page, bucket: bucket-id, mask: pointer) => intsource

Does nothing on PC.
Build DMA for uploading the given texture-page, only uploading as needed.
Unlike the normal upload-vram-pages, this just takes an array of mask bits,
and only uploads seg 0 (there is no upload mode).
See upload-vram-pages for some more details.

upload-vram-pages-pris-pc

upload-vram-pages-pris-pc(pool: texture-pool, dest-seg: texture-pool-segment, tpage: texture-page, bucket: bucket-id, mask: pointer) => intsource

Build DMA for uploading the given texture-page in pc format.
We don't use the mask system of the original game properly.

Variables


*edit-shader*

*edit-shader*: texture-idsource

*shader-list*

*shader-list*: pairsource

*texture-pool*

*texture-pool*: texture-poolsource

*txt-dma-list*

*txt-dma-list*: dma-buffersource