View unanswered posts | View active topics It is currently Thu Nov 23, 2017 5:46 pm



Reply to topic  [ 3 posts ] 
 GX indirect data shows only in Dolphin but not on the Wii 
Author Message

Joined: Mon Aug 21, 2017 11:31 am
Posts: 3
I want to load a model from a custom file format into something that I can pass to GX. I have confirmed this code to be working, however nothing is displayed on the Wii when I give the loaded data to GX. I think I have narrowed down the problem to the fact that I am dynamically allocating the arrays with the data. I put together a test to confirm this.

Not dynamic:
Code:
...
f32 verts[]   ATTRIBUTE_ALIGN(32)   = {
   -1.0F, 0.0F, -1.5F,
   1.0F, -0.0F, -1.0F,
   -1.0F, -0.6F, 0.0F
};

u8 colors[]   ATTRIBUTE_ALIGN(32)   = {
   0, 255, 255, 255
};

GX_SetArray(GX_VA_POS, verts, 3 * sizeof(f32));
GX_SetArray(GX_VA_CLR0, colors, 4 * sizeof(u8));
...

Dynamic:
Code:
...
u8 *vertsp = (f32*)(memalign(32, 9 * sizeof(f32)));
u8 *colorsp = (u8*)(memalign(32, 4 * sizeof(u8)));

for(int i = 0; i < 9; i++) {
   vertsp[i] = verts[i];
}
for(int i = 0; i < 4; i++) {
   colorsp[i] = colors[i];
}

GX_SetArray(GX_VA_POS, vertsp, 3 * sizeof(f32));
GX_SetArray(GX_VA_CLR0, colorsp, 4 * sizeof(u8));
...


The first code works but second one doesn't.
I am guessing this has something to do with the way the Wii handles dynamic memory compared to Dolphin.
How would I make this work on the Wii?


Sat Sep 23, 2017 12:46 am
Profile
Site Admin

Joined: Tue Aug 09, 2005 3:21 am
Posts: 1209
Location: UK
It's cache related - you need to use DCFlushRange to ensure the data is written to memory before GPU can see it. With the non dynamic arrays this is done by loading the dol in the first place.

Code:
u8 *vertsp = (f32*)(memalign(32, 9 * sizeof(f32)));
u8 *colorsp = (u8*)(memalign(32, 4 * sizeof(u8)));

for(int i = 0; i < 9; i++) {
   vertsp[i] = verts[i];
}
for(int i = 0; i < 4; i++) {
   colorsp[i] = colors[i];
}

DCFlushRange(vertsp, 9 * sizeof(f32));
DCFlushRange(colorsp, 4 * sizeof(u8));

GX_SetArray(GX_VA_POS, vertsp, 3 * sizeof(f32));
GX_SetArray(GX_VA_CLR0, colorsp, 4 * sizeof(u8));

_________________
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog


Sun Sep 24, 2017 6:54 pm
Profile ICQ WWW

Joined: Mon Aug 21, 2017 11:31 am
Posts: 3
I tried it and now it works perfectly.
Thank you very much!


Mon Sep 25, 2017 11:24 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
  Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.
Get devkitPro at SourceForge.net. Fast, secure and Free Open Source software downloads