Skip to content

Commit

Permalink
honor the pcw over the isp/tsp instruction word for uv_16bit, gouraud…
Browse files Browse the repository at this point in the history
…, offset and texture settings
  • Loading branch information
inolen committed Oct 20, 2017
1 parent 747fddb commit f6dbdbc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/guest/pvr/ta_types.h
Expand Up @@ -70,7 +70,7 @@ union isp {
uint32_t dcalc_ctrl : 1;
uint32_t cache_bypass : 1;
uint32_t uv_16bit : 1;
uint32_t gouraud_shading : 1;
uint32_t gouraud : 1;
uint32_t offset : 1;
uint32_t texture : 1;
uint32_t z_write_disable : 1;
Expand Down Expand Up @@ -134,7 +134,7 @@ union tcw {
union poly_param {
struct {
union pcw pcw;
union isp isp_tsp;
union isp isp;
union tsp tsp;
union tcw tcw;
uint32_t ignore_0;
Expand All @@ -145,7 +145,7 @@ union poly_param {

struct {
union pcw pcw;
union isp isp_tsp;
union isp isp;
union tsp tsp;
union tcw tcw;
float face_color_a;
Expand All @@ -156,7 +156,7 @@ union poly_param {

struct {
union pcw pcw;
union isp isp_tsp;
union isp isp;
union tsp tsp;
union tcw tcw;
uint32_t ignore_0;
Expand All @@ -175,7 +175,7 @@ union poly_param {

struct {
union pcw pcw;
union isp isp_tsp;
union isp isp;
union tsp tsp0;
union tcw tcw0;
union tsp tsp1;
Expand All @@ -186,7 +186,7 @@ union poly_param {

struct {
union pcw pcw;
union isp isp_tsp;
union isp isp;
union tsp tsp0;
union tcw tcw0;
union tsp tsp1;
Expand All @@ -205,7 +205,7 @@ union poly_param {

struct {
union pcw pcw;
union isp isp_tsp;
union isp isp;
union tsp tsp;
union tcw tcw;
uint32_t base_color;
Expand All @@ -216,7 +216,7 @@ union poly_param {

struct {
union pcw pcw;
union isp isp_tsp;
union isp isp;
uint32_t reserved[6];
} modvol;
};
Expand Down
22 changes: 13 additions & 9 deletions src/guest/pvr/tr.c
Expand Up @@ -21,11 +21,12 @@ struct tr {
const union vert_param *last_vertex;
int list_type;
int vert_type;
/* poly params */
uint8_t face_color[4];
uint8_t face_offset_color[4];
/* sprite params */
uint8_t sprite_color[4];
uint8_t sprite_offset_color[4];
int merged_surfs;
};

static int compressed_mipmap_offsets[] = {
Expand Down Expand Up @@ -292,8 +293,6 @@ static void tr_commit_surf(struct tr *tr, struct tr_context *rc) {
if (prev_surf && tr_can_merge_surfs(prev_surf, new_surf)) {
/* merge the new verts into the prev surface */
prev_surf->num_verts += new_surf->num_verts;

tr->merged_surfs++;
} else {
/* default sort the new surface */
struct tr_list *list = &rc->lists[tr->list_type];
Expand Down Expand Up @@ -458,18 +457,22 @@ static void tr_parse_poly_param(struct tr *tr, const struct ta_context *ctx,
break;
}

/* setup the new surface */
/* setup the new surface
note, bits 0-3 of the global pcw override the respective bits in the global
isp/tsp instruction word, so use the pcw for the uv_16bit, gouraud, offset,
and texture settings */
struct ta_surface *surf = tr_reserve_surf(tr, rc, 0);
surf->depth_write = !param->type0.isp_tsp.z_write_disable;
surf->depth_write = !param->type0.isp.z_write_disable;
surf->depth_func =
translate_depth_func(param->type0.isp_tsp.depth_compare_mode);
surf->cull = translate_cull(param->type0.isp_tsp.culling_mode);
translate_depth_func(param->type0.isp.depth_compare_mode);
surf->cull = translate_cull(param->type0.isp.culling_mode);
surf->src_blend = translate_src_blend_func(param->type0.tsp.src_alpha_instr);
surf->dst_blend = translate_dst_blend_func(param->type0.tsp.dst_alpha_instr);
surf->shade = translate_shade_mode(param->type0.tsp.texture_shading_instr);
surf->ignore_alpha = !param->type0.tsp.use_alpha;
surf->ignore_texture_alpha = param->type0.tsp.ignore_tex_alpha;
surf->offset_color = param->type0.isp_tsp.offset;
surf->offset_color = param->type0.pcw.offset;
surf->pt_alpha_test = tr->list_type == TA_LIST_PUNCH_THROUGH;
surf->pt_alpha_ref = (float)ctx->pt_alpha_ref / 0xff;

Expand Down Expand Up @@ -722,7 +725,8 @@ static void tr_reset(struct tr *tr, struct tr_context *rc) {
tr->vert_type = TA_NUM_VERTS;
memset(tr->face_color, 0, sizeof(tr->face_color));
memset(tr->face_offset_color, 0, sizeof(tr->face_offset_color));
tr->merged_surfs = 0;
memset(tr->sprite_color, 0, sizeof(tr->sprite_color));
memset(tr->sprite_offset_color, 0, sizeof(tr->sprite_offset_color));

/* reset render context state */
rc->num_params = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/tracer.c
Expand Up @@ -358,7 +358,7 @@ static void tracer_param_tooltip(struct tracer *tracer, struct tr_param *rp) {
const union poly_param *param =
(const union poly_param *)(tracer->ctx.params + rp->offset);

igText("isp_tsp: 0x%x", param->type0.isp_tsp.full);
igText("isp: 0x%x", param->type0.isp.full);
igText("tsp: 0x%x", param->type0.tsp.full);
igText("tcw: 0x%x", param->type0.tcw.full);

Expand Down

0 comments on commit f6dbdbc

Please sign in to comment.