Skip to content

Commit

Permalink
Simplify texture uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
ragnarok2040 committed Sep 11, 2010
1 parent 82ec07a commit cefe02f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ee/draw/include/draw.h
Expand Up @@ -33,7 +33,7 @@ extern "C" {
void draw_wait_finish(void);

// Creates a dma chain filled with image information
qword_t *draw_texture_transfer(qword_t *q, void *src, int size, int width, int height, int psm, int dest, int dest_width);
qword_t *draw_texture_transfer(qword_t *q, void *src, int width, int height, int psm, int dest, int dest_width);

// Flush the texture cache
qword_t *draw_texture_flush(qword_t *q);
Expand Down
2 changes: 1 addition & 1 deletion ee/draw/samples/texture/texture.c
Expand Up @@ -94,7 +94,7 @@ void load_texture(packet_t *packet, texbuffer_t *texbuf)

q = packet->data;

q = draw_texture_transfer(q,flower,size_flower,256,256,GS_PSM_24,texbuf->address,texbuf->width);
q = draw_texture_transfer(q,flower,256,256,GS_PSM_24,texbuf->address,texbuf->width);
q = draw_texture_flush(q);

dma_wait_fast();
Expand Down
67 changes: 65 additions & 2 deletions ee/draw/src/draw.c
Expand Up @@ -215,12 +215,75 @@ qword_t *draw_texture_flush(qword_t *q)

}

qword_t *draw_texture_transfer(qword_t *q, void *src, int bytes, int width, int height, int psm, int dest, int dest_width)
qword_t *draw_texture_transfer(qword_t *q, void *src, int width, int height, int psm, int dest, int dest_width)
{

int i;
int remaining;
int qwords = bytes >> 4;
int qwords;

switch (psm)
{
case GS_PSM_8:
{
qwords = (width*height)>>4;
break;
}

case GS_PSM_32:
case GS_PSM_24:
{
qwords = (width*height)>>2;
break;
}

case GS_PSM_4:
{
qwords = (width*height)>>5;
break;
}

case GS_PSM_16:
case GS_PSM_16S:
{
qwords = (width*height)>>3;
break;
}

default:
{
switch (psm)
{
case GS_PSM_8H:
{
qwords = (width*height)>>4;
break;
}

case GS_PSMZ_32:
case GS_PSMZ_24:
{
qwords = (width*height)>>2;
break;
}

case GS_PSMZ_16:
case GS_PSMZ_16S:
{
qwords = (width*height)>>3;
break;
}

case GS_PSM_4HL:
case GS_PSM_4HH:
{
qwords = (width*height)>>5;
break;
}
}
break;
}
}

// Determine number of iterations based on the number of qwords
// that can be handled per dmatag
Expand Down

0 comments on commit cefe02f

Please sign in to comment.