Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/accum.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static void draw_screen(GXTexObj *texture, float value)
GX_SetNumChans(1);
GX_SetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX,
0, GX_DF_NONE, GX_AF_NONE);
glparamstate.dirty.bits.dirty_tev = 1;

GX_SetCullMode(GX_CULL_NONE);
glparamstate.dirty.bits.dirty_cull = 1;
Expand Down
3 changes: 3 additions & 0 deletions src/arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ static TemplateSelectionInfo select_template(GLenum type,
info.format.type = num_components == 1 ? GX_TEX_S : GX_TEX_ST;
info.format.size = gl_type_to_gx_size(type);
info.same_type = num_components <= 2;
/* The hardware does not support sending more than 2 texture
* coordinates */
if (num_components > 2) info.format.num_components = 2;
break;
case GX_VA_CLR0:
case GX_VA_CLR1:
Expand Down
34 changes: 23 additions & 11 deletions src/call_lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ typedef struct
{
CommandType type;
union {
struct GXDisplayList {
void *list;
u32 size;
struct client_state cs;
} gxlist;

GLuint gllist; // glCallList

GLenum cap; // glEnable, glDisable
Expand Down Expand Up @@ -109,7 +103,7 @@ typedef struct
struct DrawGeometry {
GLenum mode;
uint16_t count;
struct client_state cs;
union client_state cs;
u32 list_size;
void *gxlist;
} draw_geometry;
Expand Down Expand Up @@ -138,6 +132,8 @@ static GXColor s_current_color;
static float s_current_normal[3];
static bool s_last_draw_used_indexed_data = false;
static uint16_t s_last_draw_sync_token = 0;
static union client_state s_last_client_state;
static bool s_last_client_state_is_valid = false;

#define BUFFER_IS_VALID(buffer) (((uint32_t)buffer) > 1)
#define LIST_IS_USED(index) BUFFER_IS_VALID(call_lists[index].head)
Expand Down Expand Up @@ -200,13 +196,12 @@ static Command *new_command(CommandBuffer **head)
}
}

static void execute_draw_geometry_list(struct DrawGeometry *dg)
static void setup_draw_geometry(struct DrawGeometry *dg,
bool uses_indexed_data)
{
static uint16_t counter = 0;
u8 vtxindex = GX_VTXFMT0;
GXColor current_color;

bool uses_indexed_data = !dg->cs.normal_enabled || !dg->cs.color_enabled;
if (uses_indexed_data && s_last_draw_used_indexed_data) {
bool data_changed = false;
/* If the indexed data has changed, we need to wait until the previous
Expand Down Expand Up @@ -254,6 +249,17 @@ static void execute_draw_geometry_list(struct DrawGeometry *dg)
* so we won't add them unless they are enabled. */

GX_InvVtxCache();
}

static void execute_draw_geometry_list(struct DrawGeometry *dg)
{
bool uses_indexed_data = !dg->cs.normal_enabled || !dg->cs.color_enabled;
if (!s_last_client_state_is_valid ||
s_last_client_state.as_int != dg->cs.as_int) {
setup_draw_geometry(dg, uses_indexed_data);
s_last_client_state = dg->cs;
s_last_client_state_is_valid = true;
}

GX_CallDispList(dg->gxlist, dg->list_size);

Expand All @@ -273,7 +279,7 @@ static void flat_draw_geometry(void *cb_data)

static void run_draw_geometry(struct DrawGeometry *dg)
{
struct client_state cs;
union client_state cs;

/* Update the drawing mode on the list. This required peeping into
* GX_Begin() code. */
Expand Down Expand Up @@ -304,9 +310,11 @@ static void run_draw_geometry(struct DrawGeometry *dg)
glparamstate.draw_count++;

if (glparamstate.stencil.enabled) {
s_last_client_state_is_valid = false;
_ogx_gpu_resources_push();
_ogx_stencil_draw(flat_draw_geometry, dg);
_ogx_gpu_resources_pop();
s_last_client_state_is_valid = false;
}
}

Expand Down Expand Up @@ -771,6 +779,10 @@ void glCallList(GLuint id)
}

done:
/* Until we find a reliable mechanism to ensure that the client state has
* been preserved, avoid reusing it across different lists. */
s_last_client_state_is_valid = false;

if (must_decrement) {
glparamstate.current_call_list.execution_depth--;
}
Expand Down
6 changes: 4 additions & 2 deletions src/clip.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ void _ogx_clip_setup_tev()
void _ogx_clip_enabled(int plane)
{
glparamstate.clip_plane_mask |= 1 << plane;
glparamstate.dirty.bits.dirty_clip_planes = 1;
glparamstate.dirty.bits.dirty_tev = 1;
}

void _ogx_clip_disabled(int plane)
{
glparamstate.clip_plane_mask &= ~(1 << plane);
glparamstate.dirty.bits.dirty_clip_planes = 1;
glparamstate.dirty.bits.dirty_tev = 1;
}

void glClipPlane(GLenum plane, const GLdouble *equation)
Expand All @@ -192,4 +192,6 @@ void glClipPlane(GLenum plane, const GLdouble *equation)
guMtx44Inverse(mv, mv_inverse);
ClipPlane p0 = { equation[0], equation[1], equation[2], equation[3] };
mtx44_multiply(p0, mv_inverse, *p);

glparamstate.dirty.bits.dirty_tev = 1;
}
1 change: 1 addition & 0 deletions src/efb.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void _ogx_efb_restore_texobj(GXTexObj *texobj)
GX_SetNumChans(0);
GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE);
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLORNULL);
glparamstate.dirty.bits.dirty_tev = 1;

GX_SetCullMode(GX_CULL_NONE);
glparamstate.dirty.bits.dirty_cull = 1;
Expand Down
Loading
Loading