<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Display list proper form</title>
<description> I have never been able to get display lists to work. That changes today. 

Here is how I build my display list (in my Player class, which represents the avatar on screen):


void Player::buildDisplayList(){

static const u32 TEMP_SIZE = 16384;

if(displayList)
free(displayList);
displayList = NULL;

u8* tmpDisplayList = (u8*)(memalign(32, TEMP_SIZE));

if(!tmpDisplayList){
// PANIC!
exit(1);
}

DCInvalidateRange((void*)tmpDisplayList, TEMP_SIZE);

memset(tmpDisplayList, 0, TEMP_SIZE);

GX_BeginDispList(tmpDisplayList, TEMP_SIZE);

GX_ClearVtxDesc();
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);

// Color info
u8 r = 0x00;
u8 g = 0x00;
u8 b = 0xFF;

GX_Begin(GX_QUADS, GX_VTXFMT_CLR, 24); 

// Right now we&amp;#039;re just rendering a box.

GX_Position3f32(-1.0f,1.0f,1.0f); 
GX_Color4u8(r, g, b, 0xff);
GX_Position3f32(1.0f,1.0f,1.0f); 
GX_Color4u8(r, g, b, 0xff);
GX_Position3f32(1.0f,1.0f,-1.0f); 
GX_Color4u8(r, g, b, 0xff);
GX_Position3f32(-1.0f,1.0f,-1.0f); 
GX_Color4u8(r, g, b, 0xff);

// ...

GX_End();

// Copy the temporary DL into our permanent display list

actualDLsize = (GX_EndDispList()+31)&amp;~31;

displayList = (u8*)(memalign(32, actualDLsize));

DCInvalidateRange((void*)displayList, actualDLsize);

memcpy(displayList, tmpDisplayList, actualDLsize);

DCFlushRange((void*)displayList, actualDLsize);

// Delete the temporary display list
if(tmpDisplayList)
free(tmpDisplayList);
tmpDisplayList = NULL;

}

...And here is how I call my display list:


void RenderEverything(){

Mtx mv, rot;

guMtxIdentity(mv);
guMtxTransApply(mv, mv, player-&amp;gt;pos.x, player-&amp;gt;pos.y, player-&amp;gt;pos.z);

guMtxIdentity(rot);
guMtxRotDeg(rot, &amp;#039;x&amp;#039;, player-&amp;gt;az);
guMtxRotDeg(rot, &amp;#039;y&amp;#039;, player-&amp;gt;ay);
guMtxRotDeg(rot, &amp;#039;z&amp;#039;, player-&amp;gt;az);

guMtxConcat(mv, rot, mv);

GX_LoadPosMtxImm(mv, GX_PNMTX0);

GX_CallDispList(player-&amp;gt;displayList, player-&amp;gt;actualDLsize);

}

This gives me a big &amp;#039;ol black screen. If I replace the GX_CallDispList with the actual code that was put into the display list (the cube), then it renders just fine. I&amp;#039;m not sure what I am doing wrong. Thanks in advance!</description><link>http://forum.wiibrew.org/read.php?11,62682,62682#msg-62682</link><lastBuildDate>Tue, 18 Aug 2026 07:54:29 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,63300#msg-63300</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,63300#msg-63300</link><description><![CDATA[ I&#039;ve hit another snag, and I&#039;m wondering if it has to do with the display lists. Here is the complete function:<br /><br /><pre class="bbcode">

void Model::buildDisplayList(){

	if(displayList)
		free(displayList);
	displayList = NULL;

	u8* tmpDisplayList = (u8*)(memalign(32, TEMP_DISPLIST_SIZE));

	if(!tmpDisplayList) exit(1); // PANIC!

	DCInvalidateRange((void*)tmpDisplayList, TEMP_DISPLIST_SIZE);

	GX_BeginDispList(tmpDisplayList, TEMP_DISPLIST_SIZE);

	/////////////////////////////////////////////////////////////
	////// Temporary model information:
	/////////////////////////////////////////////////////////////
	static const u8 r = 0x00;
	static const u8 g = 0x00;
	static const u8 b = 0xff;

	GX_SetTevOp(GX_TEVSTAGE0, GX_DECAL);
	GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORDNULL, GX_TEXMAP_NULL, GX_COLOR0A0);
	//
	GX_ClearVtxDesc();
	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
	GX_Begin(GX_QUADS, GX_VTXFMT_CLR, 24);          

		GX_Position3f32(-1.0f,1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);

		GX_Position3f32(-1.0f,-1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,-1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,-1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,-1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);

		GX_Position3f32(-1.0f,1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,-1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,-1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);

		GX_Position3f32(-1.0f,1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,-1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,-1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);

		GX_Position3f32(-1.0f,1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,-1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,-1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);

		GX_Position3f32(1.0f,1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,-1.0f,-1.0f);
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,-1.0f,1.0f);
		GX_Color4u8(r, g, b, 0xff);

	GX_End();

	/////////////////////////////////////////////////////////////
	/////////// end temporary model info
	/////////////////////////////////////////////////////////////			
	/*
	Actual model loading goes here
	*/

			

	// Copy the temporary DL into our permanent display list

	actualDLsize = GX_EndDispList();

	displayList = (u8*)(memalign(32, actualDLsize));

	DCInvalidateRange((void*)displayList, actualDLsize);

	memcpy(displayList, tmpDisplayList, actualDLsize);
	DCFlushRange((void*)displayList, actualDLsize);

	// Clean up
	if(tmpDisplayList)
		free(tmpDisplayList);
	tmpDisplayList = NULL;
}</pre><br />If I replace the call to GX_CallDispList with the "Temporary model information" section, it will the display blue box (with flickering problems but at least it doesn&#039;t crash). That is, if I don&#039;t call a display list and send everything directly to GX, it will work. This leads me to believe that the problem is in the display list. Thoughts?]]></description>
<dc:creator>dancinninja</dc:creator>
<category>Coding</category><pubDate>Thu, 23 Dec 2010 02:10:42 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62825#msg-62825</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62825#msg-62825</link><description><![CDATA[ Basically, you have to create a display list that contains the indices instead of the data itself. Somewhere else, you create the array of data. And when you want to draw, you set the correct array and call the display list. This allows you to use the same display list for many objects in your game that use the same model but are in a different frame of their animations, for example.]]></description>
<dc:creator>technik</dc:creator>
<category>Coding</category><pubDate>Mon, 06 Dec 2010 01:05:27 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62788#msg-62788</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62788#msg-62788</link><description><![CDATA[ I thought that display lists were more static than that. Being able to change the array (color!) would be awesome. I thought I had to pick one or the other, but I can have both? Sign me up. Thanks!]]></description>
<dc:creator>dancinninja</dc:creator>
<category>Coding</category><pubDate>Sun, 05 Dec 2010 03:19:00 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62785#msg-62785</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62785#msg-62785</link><description><![CDATA[ Say for example you were using indexed data for your colors; you would load an array with all possible colors onto the GX hardware (with GX_SetArray) and then when creating the display list you only need to specify 1 value (the index of the color you want) rather than the 4 specific color values. Less data = smaller display list size.<br /><br />Your display lists will also be more reusable, since you can change the values in the arrays without having to recreate the lists (just remember to use GX_InvVtxCache when modifying the arrays).]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Sun, 05 Dec 2010 02:28:42 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62730#msg-62730</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62730#msg-62730</link><description><![CDATA[ technik, absolutely. I have a question about that, though. Would the indexing of data really affect the display list? I thought that the display list took care of packing everything that you put into it.<br /><br />Also, and this may be a stupid question, can you use the index on a dynamic array? Since I&#039;m reading everything in via xml files, I won&#039;t know everything ahead of time.]]></description>
<dc:creator>dancinninja</dc:creator>
<category>Coding</category><pubDate>Thu, 02 Dec 2010 20:20:27 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62723#msg-62723</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62723#msg-62723</link><description><![CDATA[ By the way, as I see you&#039;re trying to get the maximum performance for your application, yoou should definitely start using Indexed data. It will reduce the size of your display lists and improve general system performance]]></description>
<dc:creator>technik</dc:creator>
<category>Coding</category><pubDate>Thu, 02 Dec 2010 09:12:26 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62708#msg-62708</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62708#msg-62708</link><description><![CDATA[ ekeeke, tueidj, you two are absolutely right. Thank you so much! Everything works perfectly now!]]></description>
<dc:creator>dancinninja</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Dec 2010 18:36:29 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62703#msg-62703</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62703#msg-62703</link><description><![CDATA[ This problem was bugging me so I actually wrote some code and did some tests - that memset line is definitely your problem. If I put a similar line in my code I get a black screen, without it everything works as expected. So I can confirm that Display Lists definitely are working in libogc.<br /><br />Edit: Here&#039;s the code I was playing around with, neheGX lesson4: [<a href="http://pastebin.com/raw.php?i=MmSgTMnE" rel="nofollow">pastebin.com</a>]]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Dec 2010 12:10:34 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62702#msg-62702</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62702#msg-62702</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>ekeeke</strong><br /><br />Another possibility is that Display List functions are simply not correctly implemented in libogc, I remember this has already been discussed before but I don&#039;t know the general position on that subject.<br /></div></blockquote><br />I think this is the original thread - [<a href="http://forum.wiibrew.org/read.php?11,9064" rel="nofollow">forum.wiibrew.org</a>]<br /><br />I did try and use lists for static models a while back, I could never get them working either. I noticed Michael did have a workaround but it seems that wiki page has been deleted.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Wed, 01 Dec 2010 06:15:28 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62700#msg-62700</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62700#msg-62700</link><description><![CDATA[ Have you tried using a single buffer (allocated with the max size) to store the display list and use it as pointer for the GX_CallDispList function, with the size returned by GX_EndDispList ? Maybe it&#039;s needing more than the returned size when executing the Display list...<br /><br />Also, try removing the "memset" that is executed before the display list, I don&#039;t think GX function writes goes through the CPU cache so your "memset" might as well be done in cache and later erase what you have written during the display list setup. It&#039;s just an idea, might be irrelevant as I&#039;m not 100% sure to understand how the cache works :/<br /><br />On a general note, i&#039;m not sure the way you are managing data cache while playing with the 2 buffers is correct:<br /><br />DCFlushRange should be used when external controller is going to access RAM which was previously modified by CPU<br />DCInvalidateRange should be used when CPU is going to access an address that was previously modified by external controller.<br /><br />In this case, it seems to me you should invalidate the FIRST buffer after having written the display list since the memset function could have cached that memory range again and when you copy it to the 2nd buffer, zeroes are copied from cache instead of reading the modified values in RAM.<br /><br />Another possibility is that Display List functions are simply not correctly implemented in libogc, I remember this has already been discussed before but I don&#039;t know the general position on that subject.]]></description>
<dc:creator>ekeeke</dc:creator>
<category>Coding</category><pubDate>Tue, 30 Nov 2010 23:52:59 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62698#msg-62698</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62698#msg-62698</link><description><![CDATA[ You are correct. I didn&#039;t want to clutter up the page with all that stuff. There are actually 24 vertices in the original code.]]></description>
<dc:creator>dancinninja</dc:creator>
<category>Coding</category><pubDate>Tue, 30 Nov 2010 23:13:20 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62697#msg-62697</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62697#msg-62697</link><description><![CDATA[ You are passing 24 as parameter to GX_Begin, are you actually drawing 24 vertices before calling GX_End ? Because it&#039;s not the case in the code you posted, you only draw 4 (a 2D quad). I guess you just didn&#039;t copypasted all the code in your post but it does not harm to ask.]]></description>
<dc:creator>ekeeke</dc:creator>
<category>Coding</category><pubDate>Tue, 30 Nov 2010 23:00:25 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62694#msg-62694</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62694#msg-62694</link><description><![CDATA[ The big temporary array is due to the fact that I don&#039;t know how big my display list is going to be. So I make a big one, populate it, and copy over the results. The "GX_VTXFMT_CLR", I apologize for not explaining.<br /><br /><pre class="bbcode">

#define GX_VTXFMT_CLR    GX_VTXFMT1

// In the initialization code:
GX_SetVtxAttrFmt(GX_VTXFMT_CLR, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GX_SetVtxAttrFmt(GX_VTXFMT_CLR, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);</pre><br />I moved the GX_SetVtxDesc functions out of the display list, and I just call them right before I call the display list. I still get nothing. I checked the size of the display list, it&#039;s 416, so there&#039;s clearly SOMETHING in there. Does a display list mean that it&#039;s no longer direct? Meaning I can&#039;t use "GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);" or something? I have no idea.]]></description>
<dc:creator>dancinninja</dc:creator>
<category>Coding</category><pubDate>Tue, 30 Nov 2010 20:07:48 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62693#msg-62693</guid>
<title>Re: Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62693#msg-62693</link><description><![CDATA[ It&#039;s a bit weird that you create the display list in a temporary array and then malloc more memory to duplicate it, but I&#039;ll assume you have your reasons.<br />What is GX_VTXFMT_CLR? I guess it&#039;s a custom define for one of the standard values?<br />Do the *VtxDesc functions work when put in display lists? I thought they just set some flags to signal that the hardware values should be updated when GX_Begin()/GX_Flush() is called... so they wouldn&#039;t be storing any data in the display list.]]></description>
<dc:creator>tueidj</dc:creator>
<category>Coding</category><pubDate>Tue, 30 Nov 2010 19:50:00 +0100</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,62682,62682#msg-62682</guid>
<title>Display list proper form</title><link>http://forum.wiibrew.org/read.php?11,62682,62682#msg-62682</link><description><![CDATA[ I have never been able to get display lists to work. That changes today.<br /><br />Here is how I build my display list (in my Player class, which represents the avatar on screen):<br /><br /><pre class="bbcode">
void Player::buildDisplayList(){
	
	static const u32 TEMP_SIZE = 16384;

	if(displayList)
		free(displayList);
	displayList = NULL;

	u8* tmpDisplayList = (u8*)(memalign(32, TEMP_SIZE));

	if(!tmpDisplayList){
		// PANIC!
		exit(1);
	}

	DCInvalidateRange((void*)tmpDisplayList, TEMP_SIZE);
	
	memset(tmpDisplayList, 0, TEMP_SIZE);

	GX_BeginDispList(tmpDisplayList, TEMP_SIZE);

	GX_ClearVtxDesc();
	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);

	// Color info
	u8 r = 0x00;
	u8 g = 0x00;
	u8 b = 0xFF;

	GX_Begin(GX_QUADS, GX_VTXFMT_CLR, 24);		

		// Right now we&#039;re just rendering a box.

		GX_Position3f32(-1.0f,1.0f,1.0f);  
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,1.0f,1.0f);	  
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(1.0f,1.0f,-1.0f); 
		GX_Color4u8(r, g, b, 0xff);
		GX_Position3f32(-1.0f,1.0f,-1.0f);  
		GX_Color4u8(r, g, b, 0xff);

		// ...

	GX_End();

	// Copy the temporary DL into our permanent display list

	actualDLsize = (GX_EndDispList()+31)&~31;

	displayList = (u8*)(memalign(32, actualDLsize));

	DCInvalidateRange((void*)displayList, actualDLsize);

	memcpy(displayList, tmpDisplayList, actualDLsize);

	DCFlushRange((void*)displayList, actualDLsize);

	// Delete the temporary display list
	if(tmpDisplayList)
		free(tmpDisplayList);
	tmpDisplayList = NULL;

}</pre><br />...And here is how I call my display list:<br /><br /><pre class="bbcode">
void RenderEverything(){

	Mtx mv, rot;

	guMtxIdentity(mv);
	guMtxTransApply(mv, mv, player-&gt;pos.x, player-&gt;pos.y, player-&gt;pos.z);

	guMtxIdentity(rot);
	guMtxRotDeg(rot, &#039;x&#039;, player-&gt;az);
	guMtxRotDeg(rot, &#039;y&#039;, player-&gt;ay);
	guMtxRotDeg(rot, &#039;z&#039;, player-&gt;az);

	guMtxConcat(mv, rot, mv);

	GX_LoadPosMtxImm(mv, GX_PNMTX0);

	GX_CallDispList(player-&gt;displayList, player-&gt;actualDLsize);

}</pre><br />This gives me a big &#039;ol black screen. If I replace the GX_CallDispList with the actual code that was put into the display list (the cube), then it renders just fine. I&#039;m not sure what I am doing wrong. Thanks in advance!]]></description>
<dc:creator>dancinninja</dc:creator>
<category>Coding</category><pubDate>Tue, 30 Nov 2010 07:04:26 +0100</pubDate></item>
</channel>
</rss>