mirror of https://github.com/inolen/redream.git
renamed tile_render_* to tr_*
rename tile_ctx to tile_context
This commit is contained in:
parent
0f6e0df66b
commit
b62f3df83f
|
@ -44,13 +44,13 @@ struct emu {
|
|||
|
||||
mutex_t pending_mutex;
|
||||
cond_t pending_cond;
|
||||
struct tile_ctx *pending_ctx;
|
||||
struct tile_context *pending_ctx;
|
||||
|
||||
volatile int video_state;
|
||||
volatile int video_width;
|
||||
volatile int video_height;
|
||||
|
||||
struct tile_render_context video_ctx;
|
||||
struct tr_context video_ctx;
|
||||
int video_fb_width;
|
||||
int video_fb_height;
|
||||
framebuffer_handle_t video_fb;
|
||||
|
@ -261,7 +261,7 @@ static void emu_finish_render(void *userdata) {
|
|||
}
|
||||
}
|
||||
|
||||
static void emu_start_render(void *userdata, struct tile_ctx *ctx) {
|
||||
static void emu_start_render(void *userdata, struct tile_context *ctx) {
|
||||
struct emu *emu = userdata;
|
||||
|
||||
if (emu->video_state != FRAME_WAITING) {
|
||||
|
@ -315,7 +315,7 @@ static void emu_input_keydown(void *userdata, int port, enum keycode key,
|
|||
|
||||
static void emu_video_context_destroyed(void *userdata) {
|
||||
struct emu *emu = userdata;
|
||||
struct texture_provider *provider = ta_texture_provider(emu->dc->ta);
|
||||
struct tr_provider *provider = ta_texture_provider(emu->dc->ta);
|
||||
|
||||
if (!emu->running) {
|
||||
return;
|
||||
|
@ -326,7 +326,7 @@ static void emu_video_context_destroyed(void *userdata) {
|
|||
/* destroy the video thread */
|
||||
if (emu->multi_threaded) {
|
||||
mutex_lock(emu->pending_mutex);
|
||||
emu->pending_ctx = (struct tile_ctx *)0xdeadbeef;
|
||||
emu->pending_ctx = (struct tile_context *)0xdeadbeef;
|
||||
cond_signal(emu->pending_cond);
|
||||
mutex_unlock(emu->pending_mutex);
|
||||
|
||||
|
@ -365,7 +365,7 @@ static void emu_video_context_destroyed(void *userdata) {
|
|||
|
||||
static void emu_video_context_reset(void *userdata) {
|
||||
struct emu *emu = userdata;
|
||||
struct texture_provider *provider = ta_texture_provider(emu->dc->ta);
|
||||
struct tr_provider *provider = ta_texture_provider(emu->dc->ta);
|
||||
|
||||
emu_video_context_destroyed(userdata);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ void dc_finish_render(struct dreamcast *dc) {
|
|||
dc->finish_render(dc->userdata);
|
||||
}
|
||||
|
||||
void dc_start_render(struct dreamcast *dc, struct tile_ctx *ctx) {
|
||||
void dc_start_render(struct dreamcast *dc, struct tile_context *ctx) {
|
||||
if (!dc->start_render) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ struct pvr;
|
|||
struct scheduler;
|
||||
struct sh4;
|
||||
struct ta;
|
||||
struct tile_ctx;
|
||||
struct tile_context;
|
||||
|
||||
/*
|
||||
* register callbacks
|
||||
|
@ -124,7 +124,7 @@ struct device {
|
|||
* machine
|
||||
*/
|
||||
typedef void (*push_audio_cb)(void *, const int16_t *, int);
|
||||
typedef void (*start_render_cb)(void *, struct tile_ctx *);
|
||||
typedef void (*start_render_cb)(void *, struct tile_context *);
|
||||
typedef void (*finish_render_cb)(void *);
|
||||
typedef void (*poll_input_cb)(void *);
|
||||
|
||||
|
@ -191,7 +191,7 @@ void dc_debug_menu(struct dreamcast *dc, struct nk_context *ctx);
|
|||
|
||||
/* client functionality */
|
||||
void dc_push_audio(struct dreamcast *dc, const int16_t *data, int frames);
|
||||
void dc_start_render(struct dreamcast *dc, struct tile_ctx *ctx);
|
||||
void dc_start_render(struct dreamcast *dc, struct tile_context *ctx);
|
||||
void dc_finish_render(struct dreamcast *dc);
|
||||
void dc_poll_input(struct dreamcast *dc);
|
||||
|
||||
|
|
108
src/hw/pvr/ta.c
108
src/hw/pvr/ta.c
|
@ -21,8 +21,8 @@ DEFINE_AGGREGATE_COUNTER(ta_renders);
|
|||
#define TA_MAX_MACROBLOCK_SIZE \
|
||||
MAX(TA_YUV420_MACROBLOCK_SIZE, TA_YUV422_MACROBLOCK_SIZE)
|
||||
|
||||
struct ta_texture_entry {
|
||||
struct texture_entry;
|
||||
struct ta_texture {
|
||||
struct tr_texture;
|
||||
struct ta *ta;
|
||||
struct list_node free_it;
|
||||
struct rb_node live_it;
|
||||
|
@ -35,7 +35,7 @@ struct ta_texture_entry {
|
|||
|
||||
struct ta {
|
||||
struct device;
|
||||
struct texture_provider provider;
|
||||
struct tr_provider provider;
|
||||
uint8_t *video_ram;
|
||||
struct trace_writer *trace_writer;
|
||||
|
||||
|
@ -47,10 +47,10 @@ struct ta {
|
|||
int yuv_macroblock_count;
|
||||
|
||||
/* tile context pool */
|
||||
struct tile_ctx contexts[TA_MAX_CONTEXTS];
|
||||
struct tile_context contexts[TA_MAX_CONTEXTS];
|
||||
struct list free_contexts;
|
||||
struct list live_contexts;
|
||||
struct tile_ctx *curr_context;
|
||||
struct tile_context *curr_context;
|
||||
|
||||
/* texture cache state */
|
||||
unsigned frame;
|
||||
|
@ -66,7 +66,7 @@ struct ta {
|
|||
struct list invalidated_entries;
|
||||
int num_invalidated;
|
||||
|
||||
struct ta_texture_entry entries[8192];
|
||||
struct ta_texture entries[8192];
|
||||
struct list free_entries;
|
||||
struct rb_tree live_entries;
|
||||
};
|
||||
|
@ -85,13 +85,13 @@ static holly_interrupt_t list_interrupts[] = {
|
|||
|
||||
static int ta_entry_cmp(const struct rb_node *rb_lhs,
|
||||
const struct rb_node *rb_rhs) {
|
||||
const struct ta_texture_entry *lhs =
|
||||
rb_entry(rb_lhs, const struct ta_texture_entry, live_it);
|
||||
texture_key_t lhs_key = tr_texture_key(lhs->tsp, lhs->tcw);
|
||||
const struct ta_texture *lhs =
|
||||
rb_entry(rb_lhs, const struct ta_texture, live_it);
|
||||
tr_texture_key_t lhs_key = tr_texture_key(lhs->tsp, lhs->tcw);
|
||||
|
||||
const struct ta_texture_entry *rhs =
|
||||
rb_entry(rb_rhs, const struct ta_texture_entry, live_it);
|
||||
texture_key_t rhs_key = tr_texture_key(rhs->tsp, rhs->tcw);
|
||||
const struct ta_texture *rhs =
|
||||
rb_entry(rb_rhs, const struct ta_texture, live_it);
|
||||
tr_texture_key_t rhs_key = tr_texture_key(rhs->tsp, rhs->tcw);
|
||||
|
||||
if (lhs_key < rhs_key) {
|
||||
return -1;
|
||||
|
@ -238,8 +238,7 @@ static void ta_clear_textures(struct ta *ta) {
|
|||
while (it) {
|
||||
struct rb_node *next = rb_next(it);
|
||||
|
||||
struct ta_texture_entry *entry =
|
||||
rb_entry(it, struct ta_texture_entry, live_it);
|
||||
struct ta_texture *entry = rb_entry(it, struct ta_texture, live_it);
|
||||
|
||||
entry->dirty = 1;
|
||||
|
||||
|
@ -248,7 +247,7 @@ static void ta_clear_textures(struct ta *ta) {
|
|||
}
|
||||
|
||||
static void ta_dirty_invalidated_textures(struct ta *ta) {
|
||||
list_for_each_entry(entry, &ta->invalidated_entries, struct ta_texture_entry,
|
||||
list_for_each_entry(entry, &ta->invalidated_entries, struct ta_texture,
|
||||
invalid_it) {
|
||||
entry->dirty = 1;
|
||||
entry->invalidated = 0;
|
||||
|
@ -258,7 +257,7 @@ static void ta_dirty_invalidated_textures(struct ta *ta) {
|
|||
}
|
||||
|
||||
static void ta_texture_invalidated(const struct exception *ex, void *data) {
|
||||
struct ta_texture_entry *entry = data;
|
||||
struct ta_texture *entry = data;
|
||||
entry->texture_watch = NULL;
|
||||
|
||||
if (!entry->invalidated) {
|
||||
|
@ -268,7 +267,7 @@ static void ta_texture_invalidated(const struct exception *ex, void *data) {
|
|||
}
|
||||
|
||||
static void ta_palette_invalidated(const struct exception *ex, void *data) {
|
||||
struct ta_texture_entry *entry = data;
|
||||
struct ta_texture *entry = data;
|
||||
entry->palette_watch = NULL;
|
||||
|
||||
if (!entry->invalidated) {
|
||||
|
@ -277,11 +276,11 @@ static void ta_palette_invalidated(const struct exception *ex, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static struct ta_texture_entry *ta_alloc_texture(struct ta *ta, union tsp tsp,
|
||||
union tcw tcw) {
|
||||
static struct ta_texture *ta_alloc_texture(struct ta *ta, union tsp tsp,
|
||||
union tcw tcw) {
|
||||
/* remove from free list */
|
||||
struct ta_texture_entry *entry =
|
||||
list_first_entry(&ta->free_entries, struct ta_texture_entry, free_it);
|
||||
struct ta_texture *entry =
|
||||
list_first_entry(&ta->free_entries, struct ta_texture, free_it);
|
||||
CHECK_NOTNULL(entry);
|
||||
list_remove(&ta->free_entries, &entry->free_it);
|
||||
|
||||
|
@ -299,18 +298,18 @@ static struct ta_texture_entry *ta_alloc_texture(struct ta *ta, union tsp tsp,
|
|||
return entry;
|
||||
}
|
||||
|
||||
static struct ta_texture_entry *ta_find_texture(struct ta *ta, union tsp tsp,
|
||||
union tcw tcw) {
|
||||
struct ta_texture_entry search;
|
||||
static struct ta_texture *ta_find_texture(struct ta *ta, union tsp tsp,
|
||||
union tcw tcw) {
|
||||
struct ta_texture search;
|
||||
search.tsp = tsp;
|
||||
search.tcw = tcw;
|
||||
|
||||
return rb_find_entry(&ta->live_entries, &search, struct ta_texture_entry,
|
||||
live_it, &ta_entry_cb);
|
||||
return rb_find_entry(&ta->live_entries, &search, struct ta_texture, live_it,
|
||||
&ta_entry_cb);
|
||||
}
|
||||
|
||||
static struct tile_ctx *ta_get_context(struct ta *ta, uint32_t addr) {
|
||||
list_for_each_entry(ctx, &ta->live_contexts, struct tile_ctx, it) {
|
||||
static struct tile_context *ta_get_context(struct ta *ta, uint32_t addr) {
|
||||
list_for_each_entry(ctx, &ta->live_contexts, struct tile_context, it) {
|
||||
if (ctx->addr == addr) {
|
||||
return ctx;
|
||||
}
|
||||
|
@ -318,10 +317,10 @@ static struct tile_ctx *ta_get_context(struct ta *ta, uint32_t addr) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct tile_ctx *ta_alloc_context(struct ta *ta, uint32_t addr) {
|
||||
static struct tile_context *ta_alloc_context(struct ta *ta, uint32_t addr) {
|
||||
/* remove from free list */
|
||||
struct tile_ctx *ctx =
|
||||
list_first_entry(&ta->free_contexts, struct tile_ctx, it);
|
||||
struct tile_context *ctx =
|
||||
list_first_entry(&ta->free_contexts, struct tile_context, it);
|
||||
CHECK_NOTNULL(ctx);
|
||||
list_remove(&ta->free_contexts, &ctx->it);
|
||||
|
||||
|
@ -338,16 +337,16 @@ static struct tile_ctx *ta_alloc_context(struct ta *ta, uint32_t addr) {
|
|||
return ctx;
|
||||
}
|
||||
|
||||
static void ta_unlink_context(struct ta *ta, struct tile_ctx *ctx) {
|
||||
static void ta_unlink_context(struct ta *ta, struct tile_context *ctx) {
|
||||
list_remove(&ta->live_contexts, &ctx->it);
|
||||
}
|
||||
|
||||
static void ta_free_context(struct ta *ta, struct tile_ctx *ctx) {
|
||||
static void ta_free_context(struct ta *ta, struct tile_context *ctx) {
|
||||
list_add(&ta->free_contexts, &ctx->it);
|
||||
}
|
||||
|
||||
static struct tile_ctx *ta_demand_context(struct ta *ta, uint32_t addr) {
|
||||
struct tile_ctx *ctx = ta_get_context(ta, addr);
|
||||
static struct tile_context *ta_demand_context(struct ta *ta, uint32_t addr) {
|
||||
struct tile_context *ctx = ta_get_context(ta, addr);
|
||||
|
||||
if (!ctx) {
|
||||
ctx = ta_alloc_context(ta, addr);
|
||||
|
@ -356,19 +355,19 @@ static struct tile_ctx *ta_demand_context(struct ta *ta, uint32_t addr) {
|
|||
return ctx;
|
||||
}
|
||||
|
||||
static void ta_cont_context(struct ta *ta, struct tile_ctx *ctx) {
|
||||
static void ta_cont_context(struct ta *ta, struct tile_context *ctx) {
|
||||
ctx->list_type = TA_NUM_LISTS;
|
||||
ctx->vertex_type = TA_NUM_VERTS;
|
||||
}
|
||||
|
||||
static void ta_init_context(struct ta *ta, struct tile_ctx *ctx) {
|
||||
static void ta_init_context(struct ta *ta, struct tile_context *ctx) {
|
||||
ctx->cursor = 0;
|
||||
ctx->size = 0;
|
||||
ctx->list_type = TA_NUM_LISTS;
|
||||
ctx->vertex_type = TA_NUM_VERTS;
|
||||
}
|
||||
|
||||
static void ta_write_context(struct ta *ta, struct tile_ctx *ctx, void *ptr,
|
||||
static void ta_write_context(struct ta *ta, struct tile_context *ctx, void *ptr,
|
||||
int size) {
|
||||
CHECK_LT(ctx->size + size, (int)sizeof(ctx->params));
|
||||
memcpy(&ctx->params[ctx->size], ptr, size);
|
||||
|
@ -436,7 +435,7 @@ static void ta_write_context(struct ta *ta, struct tile_ctx *ctx, void *ptr,
|
|||
|
||||
static void ta_register_texture_source(struct ta *ta, union tsp tsp,
|
||||
union tcw tcw) {
|
||||
struct ta_texture_entry *entry = ta_find_texture(ta, tsp, tcw);
|
||||
struct ta_texture *entry = ta_find_texture(ta, tsp, tcw);
|
||||
|
||||
if (!entry) {
|
||||
entry = ta_alloc_texture(ta, tsp, tcw);
|
||||
|
@ -505,7 +504,8 @@ static void ta_register_texture_source(struct ta *ta, union tsp tsp,
|
|||
}
|
||||
}
|
||||
|
||||
static void ta_register_texture_sources(struct ta *ta, struct tile_ctx *ctx) {
|
||||
static void ta_register_texture_sources(struct ta *ta,
|
||||
struct tile_context *ctx) {
|
||||
const uint8_t *data = ctx->params;
|
||||
const uint8_t *end = ctx->params + ctx->size;
|
||||
int vertex_type = 0;
|
||||
|
@ -533,7 +533,7 @@ static void ta_register_texture_sources(struct ta *ta, struct tile_ctx *ctx) {
|
|||
}
|
||||
}
|
||||
|
||||
static void ta_save_state(struct ta *ta, struct tile_ctx *ctx) {
|
||||
static void ta_save_state(struct ta *ta, struct tile_context *ctx) {
|
||||
struct pvr *pvr = ta->pvr;
|
||||
struct address_space *space = ta->sh4->memory_if->space;
|
||||
|
||||
|
@ -630,7 +630,7 @@ static void ta_save_state(struct ta *ta, struct tile_ctx *ctx) {
|
|||
}
|
||||
|
||||
static void ta_finish_render(void *data) {
|
||||
struct tile_ctx *ctx = data;
|
||||
struct tile_context *ctx = data;
|
||||
struct ta *ta = ctx->userdata;
|
||||
|
||||
/* ensure the client has finished rendering */
|
||||
|
@ -649,7 +649,7 @@ static void ta_finish_render(void *data) {
|
|||
holly_raise_interrupt(ta->holly, HOLLY_INTC_PCEOTINT);
|
||||
}
|
||||
|
||||
static void ta_start_render(struct ta *ta, struct tile_ctx *ctx) {
|
||||
static void ta_start_render(struct ta *ta, struct tile_context *ctx) {
|
||||
prof_counter_add(COUNTER_ta_renders, 1);
|
||||
|
||||
/* remove context from pool */
|
||||
|
@ -837,12 +837,12 @@ static int ta_init(struct device *dev) {
|
|||
ta->video_ram = memory_translate(dc->memory, "video ram", 0x00000000);
|
||||
|
||||
for (int i = 0; i < array_size(ta->entries); i++) {
|
||||
struct ta_texture_entry *entry = &ta->entries[i];
|
||||
struct ta_texture *entry = &ta->entries[i];
|
||||
list_add(&ta->free_entries, &entry->free_it);
|
||||
}
|
||||
|
||||
for (int i = 0; i < array_size(ta->contexts); i++) {
|
||||
struct tile_ctx *ctx = &ta->contexts[i];
|
||||
struct tile_context *ctx = &ta->contexts[i];
|
||||
list_add(&ta->free_contexts, &ctx->it);
|
||||
}
|
||||
|
||||
|
@ -943,10 +943,10 @@ static void ta_provider_clear_textures(void *data) {
|
|||
ta_clear_textures(ta);
|
||||
}
|
||||
|
||||
static struct texture_entry *ta_provider_find_texture(void *data, union tsp tsp,
|
||||
union tcw tcw) {
|
||||
static struct tr_texture *ta_provider_find_texture(void *data, union tsp tsp,
|
||||
union tcw tcw) {
|
||||
struct ta *ta = data;
|
||||
struct ta_texture_entry *entry = ta_find_texture(ta, tsp, tcw);
|
||||
struct ta_texture *entry = ta_find_texture(ta, tsp, tcw);
|
||||
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
|
@ -957,10 +957,10 @@ static struct texture_entry *ta_provider_find_texture(void *data, union tsp tsp,
|
|||
is broken in the thread synchronization */
|
||||
CHECK_EQ(entry->frame, ta->frame);
|
||||
|
||||
return (struct texture_entry *)entry;
|
||||
return (struct tr_texture *)entry;
|
||||
}
|
||||
|
||||
struct texture_provider *ta_texture_provider(struct ta *ta) {
|
||||
struct tr_provider *ta_texture_provider(struct ta *ta) {
|
||||
if (!ta->provider.userdata) {
|
||||
ta->provider.userdata = ta;
|
||||
ta->provider.clear_textures = &ta_provider_clear_textures;
|
||||
|
@ -999,7 +999,8 @@ REG_W32(pvr_cb, STARTRENDER) {
|
|||
return;
|
||||
}
|
||||
|
||||
struct tile_ctx *ctx = ta_get_context(ta, ta->pvr->PARAM_BASE->base_address);
|
||||
struct tile_context *ctx =
|
||||
ta_get_context(ta, ta->pvr->PARAM_BASE->base_address);
|
||||
CHECK_NOTNULL(ctx);
|
||||
ta_start_render(ta, ctx);
|
||||
}
|
||||
|
@ -1011,7 +1012,7 @@ REG_W32(pvr_cb, TA_LIST_INIT) {
|
|||
return;
|
||||
}
|
||||
|
||||
struct tile_ctx *ctx =
|
||||
struct tile_context *ctx =
|
||||
ta_demand_context(ta, ta->pvr->TA_ISP_BASE->base_address);
|
||||
ta_init_context(ta, ctx);
|
||||
ta->curr_context = ctx;
|
||||
|
@ -1024,7 +1025,8 @@ REG_W32(pvr_cb, TA_LIST_CONT) {
|
|||
return;
|
||||
}
|
||||
|
||||
struct tile_ctx *ctx = ta_get_context(ta, ta->pvr->TA_ISP_BASE->base_address);
|
||||
struct tile_context *ctx =
|
||||
ta_get_context(ta, ta->pvr->TA_ISP_BASE->base_address);
|
||||
CHECK_NOTNULL(ctx);
|
||||
ta_cont_context(ta, ctx);
|
||||
ta->curr_context = ctx;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
struct dreamcast;
|
||||
struct ta;
|
||||
struct texture_provider;
|
||||
struct tr_provider;
|
||||
|
||||
DECLARE_COUNTER(ta_renders);
|
||||
|
||||
|
@ -104,6 +104,6 @@ static inline int ta_texture_size(union tsp tsp, union tcw tcw) {
|
|||
return texture_size;
|
||||
}
|
||||
|
||||
struct texture_provider *ta_texture_provider(struct ta *ta);
|
||||
struct tr_provider *ta_texture_provider(struct ta *ta);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -437,7 +437,7 @@ union vert_param {
|
|||
/* worst case background vertex size, see ISP_BACKGND_T field */
|
||||
#define BG_VERTEX_SIZE ((0b111 * 2 + 3) * 4 * 3)
|
||||
|
||||
struct tile_ctx {
|
||||
struct tile_context {
|
||||
void *user;
|
||||
uint32_t addr;
|
||||
void *userdata;
|
||||
|
|
128
src/hw/pvr/tr.c
128
src/hw/pvr/tr.c
|
@ -9,7 +9,7 @@
|
|||
|
||||
struct tr {
|
||||
struct render_backend *r;
|
||||
struct texture_provider *provider;
|
||||
struct tr_provider *provider;
|
||||
|
||||
/* current global state */
|
||||
const union poly_param *last_poly;
|
||||
|
@ -120,13 +120,18 @@ static inline uint32_t float_to_rgba(float r, float g, float b, float a) {
|
|||
}
|
||||
|
||||
static texture_handle_t tr_demand_texture(struct tr *tr,
|
||||
const struct tile_ctx *ctx,
|
||||
const struct tile_context *ctx,
|
||||
union tsp tsp, union tcw tcw) {
|
||||
/* allow headless tile renderer */
|
||||
if (!tr->provider) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO it's bad that textures are only cached based off tsp / tcw yet the
|
||||
TEXT_CONTROL registers and PAL_RAM_CTRL registers are used here to control
|
||||
texture generation */
|
||||
|
||||
struct texture_entry *entry =
|
||||
struct tr_texture *entry =
|
||||
tr->provider->find_texture(tr->provider->userdata, tsp, tcw);
|
||||
CHECK_NOTNULL(entry);
|
||||
|
||||
|
@ -348,8 +353,7 @@ static texture_handle_t tr_demand_texture(struct tr *tr,
|
|||
return entry->handle;
|
||||
}
|
||||
|
||||
static struct surface *tr_alloc_surf(struct tr *tr,
|
||||
struct tile_render_context *rc,
|
||||
static struct surface *tr_alloc_surf(struct tr *tr, struct tr_context *rc,
|
||||
int copy_from_prev) {
|
||||
CHECK_LT(rc->num_surfs, array_size(rc->surfs));
|
||||
int id = rc->num_surfs++;
|
||||
|
@ -365,15 +369,14 @@ static struct surface *tr_alloc_surf(struct tr *tr,
|
|||
surf->num_verts = 0;
|
||||
|
||||
/* default sort the surface */
|
||||
struct tile_render_list *list = &rc->lists[tr->list_type];
|
||||
struct tr_list *list = &rc->lists[tr->list_type];
|
||||
list->surfs[list->num_surfs] = id;
|
||||
list->num_surfs++;
|
||||
|
||||
return surf;
|
||||
}
|
||||
|
||||
static struct vertex *tr_alloc_vert(struct tr *tr,
|
||||
struct tile_render_context *rc) {
|
||||
static struct vertex *tr_alloc_vert(struct tr *tr, struct tr_context *rc) {
|
||||
CHECK_LT(rc->num_verts, array_size(rc->verts));
|
||||
int id = rc->num_verts++;
|
||||
struct vertex *v = &rc->verts[id];
|
||||
|
@ -386,8 +389,7 @@ static struct vertex *tr_alloc_vert(struct tr *tr,
|
|||
return v;
|
||||
}
|
||||
|
||||
static void tr_discard_incomplete_surf(struct tr *tr,
|
||||
struct tile_render_context *rc) {
|
||||
static void tr_discard_incomplete_surf(struct tr *tr, struct tr_context *rc) {
|
||||
/* free up the last surface if it wasn't finished */
|
||||
if (tr->last_vertex && !tr->last_vertex->type0.pcw.end_of_strip) {
|
||||
rc->num_surfs--;
|
||||
|
@ -436,8 +438,8 @@ static void tr_discard_incomplete_surf(struct tr *tr,
|
|||
tr->face_offset_color[3]); \
|
||||
}
|
||||
|
||||
static int tr_parse_bg_vert(const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc, int offset,
|
||||
static int tr_parse_bg_vert(const struct tile_context *ctx,
|
||||
struct tr_context *rc, int offset,
|
||||
struct vertex *v) {
|
||||
PARSE_XYZ(*(float *)&ctx->bg_vertices[offset],
|
||||
*(float *)&ctx->bg_vertices[offset + 4],
|
||||
|
@ -468,8 +470,8 @@ static int tr_parse_bg_vert(const struct tile_ctx *ctx,
|
|||
return offset;
|
||||
}
|
||||
|
||||
static void tr_parse_bg(struct tr *tr, const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc) {
|
||||
static void tr_parse_bg(struct tr *tr, const struct tile_context *ctx,
|
||||
struct tr_context *rc) {
|
||||
tr->list_type = TA_LIST_OPAQUE;
|
||||
|
||||
/* translate the surface */
|
||||
|
@ -511,9 +513,8 @@ static void tr_parse_bg(struct tr *tr, const struct tile_ctx *ctx,
|
|||
|
||||
/* this offset color implementation is not correct at all, see the
|
||||
Texture/Shading Instruction in the union tsp instruction word */
|
||||
static void tr_parse_poly_param(struct tr *tr, const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc,
|
||||
const uint8_t *data) {
|
||||
static void tr_parse_poly_param(struct tr *tr, const struct tile_context *ctx,
|
||||
struct tr_context *rc, const uint8_t *data) {
|
||||
tr_discard_incomplete_surf(tr, rc);
|
||||
|
||||
const union poly_param *param = (const union poly_param *)data;
|
||||
|
@ -606,9 +607,8 @@ static void tr_parse_poly_param(struct tr *tr, const struct tile_ctx *ctx,
|
|||
}
|
||||
}
|
||||
|
||||
static void tr_parse_vert_param(struct tr *tr, const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc,
|
||||
const uint8_t *data) {
|
||||
static void tr_parse_vert_param(struct tr *tr, const struct tile_context *ctx,
|
||||
struct tr_context *rc, const uint8_t *data) {
|
||||
const union vert_param *param = (const union vert_param *)data;
|
||||
/* if there is no need to change the Global Parameters, a Vertex Parameter
|
||||
for the next polygon may be input immediately after inputting a Vertex
|
||||
|
@ -823,7 +823,7 @@ static void tr_merge_surfs(struct tr *tr, int *low, int *mid, int *high) {
|
|||
memcpy(low, tr->merged, (k - tr->merged) * sizeof(tr->merged[0]));
|
||||
}
|
||||
|
||||
static void tr_sort_surfs(struct tr *tr, struct tile_render_list *list, int low,
|
||||
static void tr_sort_surfs(struct tr *tr, struct tr_list *list, int low,
|
||||
int high) {
|
||||
if (low >= high) {
|
||||
return;
|
||||
|
@ -835,9 +835,9 @@ static void tr_sort_surfs(struct tr *tr, struct tile_render_list *list, int low,
|
|||
tr_merge_surfs(tr, &list->surfs[low], &list->surfs[mid], &list->surfs[high]);
|
||||
}
|
||||
|
||||
static void tr_sort_render_list(struct tr *tr, struct tile_render_context *rc,
|
||||
static void tr_sort_render_list(struct tr *tr, struct tr_context *rc,
|
||||
int list_type) {
|
||||
struct tile_render_list *list = &rc->lists[list_type];
|
||||
struct tr_list *list = &rc->lists[list_type];
|
||||
|
||||
for (int i = 0; i < list->num_surfs; i++) {
|
||||
int idx = list->surfs[i];
|
||||
|
@ -858,8 +858,8 @@ static void tr_sort_render_list(struct tr *tr, struct tile_render_context *rc,
|
|||
tr_sort_surfs(tr, list, 0, list->num_surfs - 1);
|
||||
}
|
||||
|
||||
static void tr_parse_eol(struct tr *tr, const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc, const uint8_t *data) {
|
||||
static void tr_parse_eol(struct tr *tr, const struct tile_context *ctx,
|
||||
struct tr_context *rc, const uint8_t *data) {
|
||||
tr_discard_incomplete_surf(tr, rc);
|
||||
|
||||
tr->last_poly = NULL;
|
||||
|
@ -868,8 +868,8 @@ static void tr_parse_eol(struct tr *tr, const struct tile_ctx *ctx,
|
|||
tr->vertex_type = TA_NUM_VERTS;
|
||||
}
|
||||
|
||||
static void tr_proj_mat(struct tr *tr, const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc) {
|
||||
static void tr_proj_mat(struct tr *tr, const struct tile_context *ctx,
|
||||
struct tr_context *rc) {
|
||||
/* this isn't a traditional projection matrix. xy components coming into the
|
||||
TA are in window space, while the z component is 1/w with +z headed into
|
||||
the screen. these coordinates need to be scaled back into ndc space, and
|
||||
|
@ -899,7 +899,7 @@ static void tr_proj_mat(struct tr *tr, const struct tile_ctx *ctx,
|
|||
rc->projection[15] = 1.0f;
|
||||
}
|
||||
|
||||
static void tr_reset(struct tr *tr, struct tile_render_context *rc) {
|
||||
static void tr_reset(struct tr *tr, struct tr_context *rc) {
|
||||
/* reset global state */
|
||||
tr->last_poly = NULL;
|
||||
tr->last_vertex = NULL;
|
||||
|
@ -913,13 +913,42 @@ static void tr_reset(struct tr *tr, struct tile_render_context *rc) {
|
|||
rc->num_surfs = 0;
|
||||
rc->num_verts = 0;
|
||||
for (int i = 0; i < TA_NUM_LISTS; i++) {
|
||||
struct tile_render_list *list = &rc->lists[i];
|
||||
struct tr_list *list = &rc->lists[i];
|
||||
list->num_surfs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void tr_parse_context(struct tr *tr, const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc) {
|
||||
static void tr_render_list(struct tr *tr, const struct tr_context *rc,
|
||||
int list_type) {
|
||||
const struct tr_list *list = &rc->lists[list_type];
|
||||
const int *sorted_surf = list->surfs;
|
||||
const int *sorted_surf_end = list->surfs + list->num_surfs;
|
||||
|
||||
while (sorted_surf < sorted_surf_end) {
|
||||
r_draw_surface(tr->r, &rc->surfs[*sorted_surf]);
|
||||
sorted_surf++;
|
||||
}
|
||||
}
|
||||
|
||||
void tr_render_context(struct tr *tr, const struct tr_context *rc,
|
||||
int video_width, int video_height) {
|
||||
PROF_ENTER("gpu", "tr_render_context");
|
||||
|
||||
r_clear_viewport(tr->r, video_width, video_height);
|
||||
|
||||
r_begin_surfaces(tr->r, rc->projection, rc->verts, rc->num_verts);
|
||||
|
||||
tr_render_list(tr, rc, TA_LIST_OPAQUE);
|
||||
tr_render_list(tr, rc, TA_LIST_PUNCH_THROUGH);
|
||||
tr_render_list(tr, rc, TA_LIST_TRANSLUCENT);
|
||||
|
||||
r_end_surfaces(tr->r);
|
||||
|
||||
PROF_LEAVE();
|
||||
}
|
||||
|
||||
void tr_parse_context(struct tr *tr, const struct tile_context *ctx,
|
||||
struct tr_context *rc) {
|
||||
PROF_ENTER("gpu", "tr_parse_context");
|
||||
|
||||
const uint8_t *data = ctx->params;
|
||||
|
@ -965,7 +994,7 @@ void tr_parse_context(struct tr *tr, const struct tile_ctx *ctx,
|
|||
}
|
||||
|
||||
/* track info about the parse state for tracer debugging */
|
||||
struct tile_render_param *rp = &rc->params[rc->num_params++];
|
||||
struct tr_param *rp = &rc->params[rc->num_params++];
|
||||
rp->offset = (int)(data - ctx->params);
|
||||
rp->list_type = tr->list_type;
|
||||
rp->vertex_type = tr->list_type;
|
||||
|
@ -986,41 +1015,14 @@ void tr_parse_context(struct tr *tr, const struct tile_ctx *ctx,
|
|||
PROF_LEAVE();
|
||||
}
|
||||
|
||||
static void tr_render_list(struct tr *tr, const struct tile_render_context *rc,
|
||||
int list_type) {
|
||||
const struct tile_render_list *list = &rc->lists[list_type];
|
||||
const int *sorted_surf = list->surfs;
|
||||
const int *sorted_surf_end = list->surfs + list->num_surfs;
|
||||
|
||||
while (sorted_surf < sorted_surf_end) {
|
||||
r_draw_surface(tr->r, &rc->surfs[*sorted_surf]);
|
||||
sorted_surf++;
|
||||
}
|
||||
}
|
||||
|
||||
void tr_render_context(struct tr *tr, const struct tile_render_context *rc,
|
||||
int video_width, int video_height) {
|
||||
PROF_ENTER("gpu", "tr_render_context");
|
||||
|
||||
r_clear_viewport(tr->r, video_width, video_height);
|
||||
|
||||
r_begin_surfaces(tr->r, rc->projection, rc->verts, rc->num_verts);
|
||||
|
||||
tr_render_list(tr, rc, TA_LIST_OPAQUE);
|
||||
tr_render_list(tr, rc, TA_LIST_PUNCH_THROUGH);
|
||||
tr_render_list(tr, rc, TA_LIST_TRANSLUCENT);
|
||||
|
||||
r_end_surfaces(tr->r);
|
||||
|
||||
PROF_LEAVE();
|
||||
}
|
||||
|
||||
void tr_destroy(struct tr *tr) {
|
||||
free(tr);
|
||||
}
|
||||
|
||||
struct tr *tr_create(struct render_backend *r,
|
||||
struct texture_provider *provider) {
|
||||
struct tr *tr_create(struct render_backend *r, struct tr_provider *provider) {
|
||||
/* ensure param / poly / vertex size LUTs are generated */
|
||||
ta_build_tables();
|
||||
|
||||
struct tr *tr = calloc(1, sizeof(struct tr));
|
||||
|
||||
tr->r = r;
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
struct tr;
|
||||
|
||||
typedef uint64_t texture_key_t;
|
||||
typedef uint64_t tr_texture_key_t;
|
||||
|
||||
struct texture_entry {
|
||||
struct tr_texture {
|
||||
union tsp tsp;
|
||||
union tcw tcw;
|
||||
unsigned frame;
|
||||
|
@ -37,13 +37,13 @@ struct texture_entry {
|
|||
/* provides abstraction around providing texture data to the renderer. when
|
||||
emulating the actual ta, textures will be provided from guest memory, but
|
||||
when playing back traces the textures will come from the trace itself */
|
||||
struct texture_provider {
|
||||
struct tr_provider {
|
||||
void *userdata;
|
||||
void (*clear_textures)(void *);
|
||||
struct texture_entry *(*find_texture)(void *, union tsp, union tcw);
|
||||
struct tr_texture *(*find_texture)(void *, union tsp, union tcw);
|
||||
};
|
||||
|
||||
struct tile_render_param {
|
||||
struct tr_param {
|
||||
/* offset of parameter in tile_context param stream */
|
||||
int offset;
|
||||
/* global list and vertex types at time of parsing */
|
||||
|
@ -54,12 +54,12 @@ struct tile_render_param {
|
|||
int last_vert;
|
||||
};
|
||||
|
||||
struct tile_render_list {
|
||||
struct tr_list {
|
||||
int surfs[TA_MAX_SURFS];
|
||||
int num_surfs;
|
||||
};
|
||||
|
||||
struct tile_render_context {
|
||||
struct tr_context {
|
||||
/* transforms incoming windows space coordinates to ndc space */
|
||||
float minz, maxz;
|
||||
float projection[16];
|
||||
|
@ -72,24 +72,23 @@ struct tile_render_context {
|
|||
int num_verts;
|
||||
|
||||
/* sorted list of surfaces corresponding to each of the ta's polygon lists */
|
||||
struct tile_render_list lists[TA_NUM_LISTS];
|
||||
struct tr_list lists[TA_NUM_LISTS];
|
||||
|
||||
/* debug structures for stepping through the param stream in the tracer */
|
||||
struct tile_render_param params[TA_MAX_PARAMS];
|
||||
struct tr_param params[TA_MAX_PARAMS];
|
||||
int num_params;
|
||||
};
|
||||
|
||||
static inline texture_key_t tr_texture_key(union tsp tsp, union tcw tcw) {
|
||||
static inline tr_texture_key_t tr_texture_key(union tsp tsp, union tcw tcw) {
|
||||
return ((uint64_t)tsp.full << 32) | tcw.full;
|
||||
}
|
||||
|
||||
struct tr *tr_create(struct render_backend *rb,
|
||||
struct texture_provider *provider);
|
||||
struct tr *tr_create(struct render_backend *rb, struct tr_provider *provider);
|
||||
void tr_destroy(struct tr *tr);
|
||||
|
||||
void tr_parse_context(struct tr *tr, const struct tile_ctx *ctx,
|
||||
struct tile_render_context *rc);
|
||||
void tr_render_context(struct tr *tr, const struct tile_render_context *rc,
|
||||
void tr_parse_context(struct tr *tr, const struct tile_context *ctx,
|
||||
struct tr_context *rc);
|
||||
void tr_render_context(struct tr *tr, const struct tr_context *rc,
|
||||
int video_width, int video_height);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@ void trace_writer_close(struct trace_writer *writer) {
|
|||
}
|
||||
|
||||
void trace_writer_render_context(struct trace_writer *writer,
|
||||
struct tile_ctx *ctx) {
|
||||
struct tile_context *ctx) {
|
||||
struct trace_cmd cmd = {0};
|
||||
cmd.type = TRACE_CMD_CONTEXT;
|
||||
cmd.context.frame = ctx->frame;
|
||||
|
@ -97,7 +97,7 @@ struct trace_writer *trace_writer_open(const char *filename) {
|
|||
static int trace_patch_overrides(struct trace_cmd *cmd) {
|
||||
while (cmd) {
|
||||
if (cmd->type == TRACE_CMD_TEXTURE) {
|
||||
texture_key_t texture_key =
|
||||
tr_texture_key_t texture_key =
|
||||
tr_texture_key(cmd->texture.tsp, cmd->texture.tcw);
|
||||
|
||||
/* walk backwards and see if this texture overrode a previous command
|
||||
|
@ -106,7 +106,7 @@ static int trace_patch_overrides(struct trace_cmd *cmd) {
|
|||
|
||||
while (prev) {
|
||||
if (prev->type == TRACE_CMD_TEXTURE) {
|
||||
texture_key_t prev_texture_key =
|
||||
tr_texture_key_t prev_texture_key =
|
||||
tr_texture_key(prev->texture.tsp, prev->texture.tcw);
|
||||
|
||||
if (prev_texture_key == texture_key) {
|
||||
|
|
|
@ -31,7 +31,7 @@ struct trace_cmd {
|
|||
const uint8_t *texture;
|
||||
} texture;
|
||||
|
||||
/* slimmed down version of the tile_ctx structure, will need to be in
|
||||
/* slimmed down version of the tile_context structure, will need to be in
|
||||
sync */
|
||||
struct {
|
||||
uint32_t frame;
|
||||
|
@ -66,7 +66,7 @@ void get_next_trace_filename(char *filename, size_t size);
|
|||
|
||||
void trace_writer_close(struct trace_writer *writer);
|
||||
void trace_writer_render_context(struct trace_writer *writer,
|
||||
struct tile_ctx *ctx);
|
||||
struct tile_context *ctx);
|
||||
void trace_writer_insert_texture(struct trace_writer *writer, union tsp tsp,
|
||||
union tcw tcw, unsigned frame,
|
||||
const uint8_t *palette, int palette_size,
|
||||
|
|
|
@ -509,8 +509,8 @@ void r_draw_surface(struct render_backend *r, const struct surface *surf) {
|
|||
glDrawArrays(GL_TRIANGLE_STRIP, surf->first_vert, surf->num_verts);
|
||||
}
|
||||
|
||||
void r_begin_surfaces(struct render_backend *r, const float *projection, const struct vertex *verts,
|
||||
int num_verts) {
|
||||
void r_begin_surfaces(struct render_backend *r, const float *projection,
|
||||
const struct vertex *verts, int num_verts) {
|
||||
/* uniforms will be lazily bound for each program inside of r_draw_surface */
|
||||
r->uniform_token++;
|
||||
r->uniform_mvp = projection;
|
||||
|
|
|
@ -170,8 +170,8 @@ void r_clear_viewport(struct render_backend *r, int width, int height);
|
|||
void r_begin_ortho(struct render_backend *r);
|
||||
void r_end_ortho(struct render_backend *r);
|
||||
|
||||
void r_begin_surfaces(struct render_backend *r, const float *projection, const struct vertex *verts,
|
||||
int num_verts);
|
||||
void r_begin_surfaces(struct render_backend *r, const float *projection,
|
||||
const struct vertex *verts, int num_verts);
|
||||
void r_draw_surface(struct render_backend *r, const struct surface *surf);
|
||||
void r_end_surfaces(struct render_backend *r);
|
||||
|
||||
|
|
82
src/tracer.c
82
src/tracer.c
|
@ -60,8 +60,8 @@ static const char *shademode_names[] = {
|
|||
"DECAL", "MODULATE", "DECAL_ALPHA", "MODULATE_ALPHA",
|
||||
};
|
||||
|
||||
struct tracer_texture_entry {
|
||||
struct texture_entry;
|
||||
struct tracer_texture {
|
||||
struct tr_texture;
|
||||
struct rb_node live_it;
|
||||
struct list_node free_it;
|
||||
};
|
||||
|
@ -71,31 +71,31 @@ struct tracer {
|
|||
struct render_backend *r;
|
||||
struct nuklear *nk;
|
||||
struct tr *tr;
|
||||
struct texture_provider provider;
|
||||
struct tr_provider provider;
|
||||
|
||||
/* trace state */
|
||||
struct trace *trace;
|
||||
struct tile_ctx ctx;
|
||||
struct tile_context ctx;
|
||||
struct trace_cmd *current_cmd;
|
||||
int current_param;
|
||||
int scroll_to_param;
|
||||
|
||||
/* render state */
|
||||
struct tile_render_context rc;
|
||||
struct tracer_texture_entry textures[1024];
|
||||
struct tr_context rc;
|
||||
struct tracer_texture textures[1024];
|
||||
struct rb_tree live_textures;
|
||||
struct list free_textures;
|
||||
};
|
||||
|
||||
static int tracer_texture_cmp(const struct rb_node *rb_lhs,
|
||||
const struct rb_node *rb_rhs) {
|
||||
const struct tracer_texture_entry *lhs =
|
||||
rb_entry(rb_lhs, const struct tracer_texture_entry, live_it);
|
||||
texture_key_t lhs_key = tr_texture_key(lhs->tsp, lhs->tcw);
|
||||
const struct tracer_texture *lhs =
|
||||
rb_entry(rb_lhs, const struct tracer_texture, live_it);
|
||||
tr_texture_key_t lhs_key = tr_texture_key(lhs->tsp, lhs->tcw);
|
||||
|
||||
const struct tracer_texture_entry *rhs =
|
||||
rb_entry(rb_rhs, const struct tracer_texture_entry, live_it);
|
||||
texture_key_t rhs_key = tr_texture_key(rhs->tsp, rhs->tcw);
|
||||
const struct tracer_texture *rhs =
|
||||
rb_entry(rb_rhs, const struct tracer_texture, live_it);
|
||||
tr_texture_key_t rhs_key = tr_texture_key(rhs->tsp, rhs->tcw);
|
||||
|
||||
if (lhs_key < rhs_key) {
|
||||
return -1;
|
||||
|
@ -109,39 +109,38 @@ static int tracer_texture_cmp(const struct rb_node *rb_lhs,
|
|||
static struct rb_callbacks tracer_texture_cb = {&tracer_texture_cmp, NULL,
|
||||
NULL};
|
||||
|
||||
static struct tracer_texture_entry *tracer_find_texture(struct tracer *tracer,
|
||||
union tsp tsp,
|
||||
union tcw tcw) {
|
||||
struct tracer_texture_entry search;
|
||||
static struct tracer_texture *tracer_find_texture(struct tracer *tracer,
|
||||
union tsp tsp,
|
||||
union tcw tcw) {
|
||||
struct tracer_texture search;
|
||||
search.tsp = tsp;
|
||||
search.tcw = tcw;
|
||||
|
||||
return rb_find_entry(&tracer->live_textures, &search,
|
||||
struct tracer_texture_entry, live_it,
|
||||
&tracer_texture_cb);
|
||||
return rb_find_entry(&tracer->live_textures, &search, struct tracer_texture,
|
||||
live_it, &tracer_texture_cb);
|
||||
}
|
||||
|
||||
static struct texture_entry *tracer_provider_find_texture(void *data,
|
||||
union tsp tsp,
|
||||
union tcw tcw) {
|
||||
static struct tr_texture *tracer_provider_find_texture(void *data,
|
||||
union tsp tsp,
|
||||
union tcw tcw) {
|
||||
struct tracer *tracer = data;
|
||||
|
||||
struct tracer_texture_entry *entry = tracer_find_texture(tracer, tsp, tcw);
|
||||
struct tracer_texture *entry = tracer_find_texture(tracer, tsp, tcw);
|
||||
CHECK_NOTNULL(entry, "Texture wasn't available in cache");
|
||||
|
||||
return (struct texture_entry *)entry;
|
||||
return (struct tr_texture *)entry;
|
||||
}
|
||||
|
||||
static void tracer_add_texture(struct tracer *tracer,
|
||||
const struct trace_cmd *cmd) {
|
||||
CHECK_EQ(cmd->type, TRACE_CMD_TEXTURE);
|
||||
|
||||
struct tracer_texture_entry *entry =
|
||||
struct tracer_texture *entry =
|
||||
tracer_find_texture(tracer, cmd->texture.tsp, cmd->texture.tcw);
|
||||
|
||||
if (!entry) {
|
||||
entry = list_first_entry(&tracer->free_textures,
|
||||
struct tracer_texture_entry, free_it);
|
||||
entry = list_first_entry(&tracer->free_textures, struct tracer_texture,
|
||||
free_it);
|
||||
CHECK_NOTNULL(entry);
|
||||
list_remove(&tracer->free_textures, &entry->free_it);
|
||||
|
||||
|
@ -160,7 +159,7 @@ static void tracer_add_texture(struct tracer *tracer,
|
|||
}
|
||||
|
||||
static void tracer_copy_context(const struct trace_cmd *cmd,
|
||||
struct tile_ctx *ctx) {
|
||||
struct tile_context *ctx) {
|
||||
CHECK_EQ(cmd->type, TRACE_CMD_CONTEXT);
|
||||
|
||||
ctx->frame = cmd->context.frame;
|
||||
|
@ -361,8 +360,7 @@ static void tracer_render_scrubber_menu(struct tracer *tracer) {
|
|||
nk_end(ctx);
|
||||
}
|
||||
|
||||
static void tracer_param_tooltip(struct tracer *tracer,
|
||||
struct tile_render_param *rp) {
|
||||
static void tracer_param_tooltip(struct tracer *tracer, struct tr_param *rp) {
|
||||
struct nk_context *ctx = &tracer->nk->ctx;
|
||||
|
||||
if (nk_tooltip_begin(ctx, 300.0f)) {
|
||||
|
@ -650,7 +648,7 @@ static void tracer_render_side_menu(struct tracer *tracer) {
|
|||
nk_layout_row_dynamic(ctx, (float)param_height, 1);
|
||||
|
||||
for (int i = view.begin; i < view.end && i < num_params; i++) {
|
||||
struct tile_render_param *rp = &tracer->rc.params[i];
|
||||
struct tr_param *rp = &tracer->rc.params[i];
|
||||
union pcw pcw = *(const union pcw *)(tracer->ctx.params + rp->offset);
|
||||
|
||||
int selected = (i == tracer->current_param);
|
||||
|
@ -714,8 +712,8 @@ static void tracer_render_side_menu(struct tracer *tracer) {
|
|||
NK_WINDOW_MINIMIZABLE | NK_WINDOW_TITLE)) {
|
||||
nk_layout_row_static(ctx, 40.0f, 40, 5);
|
||||
|
||||
rb_for_each_entry(entry, &tracer->live_textures,
|
||||
struct tracer_texture_entry, live_it) {
|
||||
rb_for_each_entry(entry, &tracer->live_textures, struct tracer_texture,
|
||||
live_it) {
|
||||
struct nk_rect bounds = nk_widget_bounds(ctx);
|
||||
|
||||
nk_image(ctx, nk_image_id((int)entry->handle));
|
||||
|
@ -765,13 +763,13 @@ static void tracer_render_side_menu(struct tracer *tracer) {
|
|||
}
|
||||
|
||||
static void tracer_render_list(struct tracer *tracer,
|
||||
const struct tile_render_context *rc,
|
||||
int list_type, int end, int *stopped) {
|
||||
const struct tr_context *rc, int list_type,
|
||||
int end, int *stopped) {
|
||||
if (*stopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
const struct tile_render_list *list = &tracer->rc.lists[list_type];
|
||||
const struct tr_list *list = &tracer->rc.lists[list_type];
|
||||
const int *sorted_surf = list->surfs;
|
||||
const int *sorted_surf_end = list->surfs + list->num_surfs;
|
||||
|
||||
|
@ -825,17 +823,16 @@ void tracer_run_frame(struct tracer *tracer) {
|
|||
|
||||
/* render context up to the surface of the currently selected param */
|
||||
{
|
||||
struct tile_render_context *rc = &tracer->rc;
|
||||
struct tr_context *rc = &tracer->rc;
|
||||
int stopped = 0;
|
||||
int end = -1;
|
||||
|
||||
if (tracer->current_param >= 0) {
|
||||
struct tile_render_param *rp = &rc->params[tracer->current_param];
|
||||
struct tr_param *rp = &rc->params[tracer->current_param];
|
||||
end = rp->last_surf;
|
||||
}
|
||||
|
||||
r_begin_surfaces(tracer->r, rc->projection, rc->verts,
|
||||
rc->num_verts);
|
||||
r_begin_surfaces(tracer->r, rc->projection, rc->verts, rc->num_verts);
|
||||
|
||||
tracer_render_list(tracer, rc, TA_LIST_OPAQUE, end, &stopped);
|
||||
tracer_render_list(tracer, rc, TA_LIST_PUNCH_THROUGH, end, &stopped);
|
||||
|
@ -878,9 +875,6 @@ void tracer_destroy(struct tracer *tracer) {
|
|||
}
|
||||
|
||||
struct tracer *tracer_create(struct host *host) {
|
||||
/* ensure param / poly / vertex size LUTs are generated */
|
||||
ta_build_tables();
|
||||
|
||||
struct tracer *tracer = calloc(1, sizeof(struct tracer));
|
||||
|
||||
/* setup host, bind event callbacks */
|
||||
|
@ -898,7 +892,7 @@ struct tracer *tracer_create(struct host *host) {
|
|||
|
||||
/* add all textures to free list */
|
||||
for (int i = 0, n = array_size(tracer->textures); i < n; i++) {
|
||||
struct tracer_texture_entry *entry = &tracer->textures[i];
|
||||
struct tracer_texture *entry = &tracer->textures[i];
|
||||
list_add(&tracer->free_textures, &entry->free_it);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue