view Renderer/test_render/Tapestry.h @ 283:55ea4465b1a2

fix test_render
author e065746@localhost.localdomain
date Fri, 05 Jun 2009 16:49:12 +0900
parents
children
line wrap: on
line source

#ifndef INCLUDED_TAPESTRY
#define INCLUDED_TAPESTRY

#ifndef INCLUDED_TYPES
#  include "types.h"
#endif

#ifndef INCLUDED_VIEWER_TYPES
#  include "viewer_types.h"
#endif

/**
 * image file name と tapestry DB の binary tree
 *
 * // PPE
 * main memory の tapestry DB (Array)
 * tapestry DB への accessor 
 *
 *   TapestryPtr getTapestry(int TapestryID);
 *   TilePtr getTile(TapestryPtr tapsetry, int tx, int ty, int scale);
 *
 * SPE が生成する tapestry List (in CreateSpan)
 *   (no texture image)
 *   @in  TapestryDBPtr, Tapestry ID, x, y, tx, ty, px, py
 *     x, y   : polygon の中の平面座標
 *     tx, ty : texture の座標
 *     px, py : texture の分割数
 *
 *   @out (TilePtr, tix1, tiy1, tix2, tiy2)*
 * 
 *
 * SPE に渡す tapestry List
 *   @in Tile
 *
 * // SPE
 * SPE 内部での tapestry DB (Hash)
 *   TapestryID, scale, TilePtr, Tile
 *
 *
 * SPE 内部での tapestry DB への accessor
 *   TileEntryPtr getTile(int TapestryID, int tx, int ty, int scale);
 *
 *   if (TileEntry == NULL) {
 *      DMA read
 *   }
 *  
 *
 * Rendering
 *   1pass Zbuffer と Texture の有無の判定
 *     if (zbuffer ok) {
 *       if (texture ある) {
 *         zbuffer 、linebunf に書き込む
 *       } else {
 *         texture の load list に加える
 *         zbuffer だけ更新しておく
 *       }
 *     } else {
 *       無視
 *     }
 *
 *    1pass で texture が一杯になったら、中断して
 *    ここまでのを書き込んどけ
 *
 *
 *    2pass rgb の書き込み
 *
 *    if (zbuffer の値が自分と一緒) {
 *       read した texture みて
 *       書き込め!
 *    }
 *
 */
struct texture_block {
    
};

typedef struct {
    uint32 pixel[TEXTURE_BLOCK_SIZE]; // 8*8
    uint32 *texture_addr;
    int pad[3];
} Tile, *TilePtr;

#define MAX_TILE 128

/**
 * TileList 中の Tile の追い出しは、現在 FIFO で実装している
 */
class TileList {
public:
    int curIndex;
    int pad[3];
    Tile tile[MAX_TILE];

    TileList(void) {
	curIndex = 0;
    }

    /**
     * 次に扱う tile を取得する
     *
     * @return tile
     *
     * tile[] をリングバスっぽく扱うことで
     * FIFO を実現することに。
     */
    TilePtr nextTile(void) {
	TilePtr t = &tile[curIndex];
	curIndex = (curIndex + 1) % MAX_TILE;
	return t;
    }

    /**
     * TileList のクリア
     * //tile 自体は clear する必要は無い
     * あるかもしれない
     */
    void clear(void) {
	curIndex = 0;
    }
};

typedef TileList* TileListPtr;

#endif