Homebrew How does stride work in GPU_SetAttributeBuffers?

cal64

Well-Known Member
OP
Newcomer
Joined
Oct 31, 2016
Messages
65
Trophies
0
Age
30
XP
436
Country
France
Alright, I'm sorry, last technical question:
How does one adjust the "Stride" setting in the above-mentionned function from ctrulib? It's not a direct argument that one can feed to the function, and it seems to rely on the values of the attributeFormats and the bufferPermutations arguments.

Thanks for reading, any help is very appreciated! (Sorry for my potentially broken english!)
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,032
Country
United States
Alright, I'm sorry, last technical question:
How does one adjust the "Stride" setting in the above-mentionned function from ctrulib? It's not a direct argument that one can feed to the function, and it seems to rely on the values of the attributeFormats and the bufferPermutations arguments.

Thanks for reading, any help is very appreciated! (Sorry for my potentially broken english!)
Its complicated - beyond the scope of a forum reply. The simplest answer is that data elements must be tightly packed. There are padding elements that you can use but it is probably best to avoid them given the limited amount of memory. Most libraries like citro take care of the stride for you - take a look at the source.
 

cal64

Well-Known Member
OP
Newcomer
Joined
Oct 31, 2016
Messages
65
Trophies
0
Age
30
XP
436
Country
France
Isn't there any documentation on how it's implemented in the GPU?
Thanks for helping by the way!
 

cal64

Well-Known Member
OP
Newcomer
Joined
Oct 31, 2016
Messages
65
Trophies
0
Age
30
XP
436
Country
France
Alright, @elhobbs , really sorry to bother you again, but I promise this should be the last time. So, from my understanding by looking at the citro3d source, there is only one stride setting per buffer. Is that correct? Also could you maybe (if thats not too annoying) explain what permutations are? And finally, by looking at the portal3ds source, I got that when drawing from md2 files, smea would use 3 buffers because of the layout of the models in memory? Is that it too?

Oh also once it is processed by ctrulib in which register is stride set? Is it in GPU_ATTRIBBUFFERi_CONFIG1/2?

This should be it (sorry that's like 4 questions in one post), thanks for your help so far, I understand I must sound quite annoying with this, but really you've been extremely helpful so far, I can't thank you enough!
 
Last edited by cal64,

Hayleia

Well-Known Member
Member
Joined
Feb 26, 2015
Messages
1,485
Trophies
0
XP
1,294
Country
France
Last time I had to deal with strides (that was not with citro3d but I expect it works the same here), here is what it meant.

You want to render shit. Your stuff is described with attributes. You know, a triangle is 3 points, 1 point is 3 coordinates and maybe a color or texture coordinates or both.
See that "maybe"? Here's the problem.

The rasterizer knows the buffer describing your triangles will be in the form "triangle;triangle;triangle;...", so "point;point;point;point;point;point;point;point;point;...".
But it doesn't know if it will be in the form "X,Y,Z,color;X,Y,Z,color;X,Y,Z,color;..." or "X,Y,Z,texX,texY;X,Y,Z,texX,texY;X,Y,Z,texX,texY;..." or whatever.
Well the stride specifies the size of a "X,Y,Z,color" or "X,Y,Z,texX,texY;" group, so that the rasterizer knows where the next element is.
 

cal64

Well-Known Member
OP
Newcomer
Joined
Oct 31, 2016
Messages
65
Trophies
0
Age
30
XP
436
Country
France
Last time I had to deal with strides (that was not with citro3d but I expect it works the same here), here is what it meant.

You want to render shit. Your stuff is described with attributes. You know, a triangle is 3 points, 1 point is 3 coordinates and maybe a color or texture coordinates or both.
See that "maybe"? Here's the problem.

The rasterizer knows the buffer describing your triangles will be in the form "triangle;triangle;triangle;...", so "point;point;point;point;point;point;point;point;point;...".
But it doesn't know if it will be in the form "X,Y,Z,color;X,Y,Z,color;X,Y,Z,color;..." or "X,Y,Z,texX,texY;X,Y,Z,texX,texY;X,Y,Z,texX,texY;..." or whatever.
Well the stride specifies the size of a "X,Y,Z,color" or "X,Y,Z,texX,texY;" group, so that the rasterizer knows where the next element is.
Well, that I already got, what I meant is do strides work per-buffer?

--------------------- MERGED ---------------------------

Actually it's really just the way it's all setup in the GPU that confuses me...
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,032
Country
United States
Alright, @elhobbs , really sorry to bother you again, but I promise this should be the last time. So, from my understanding by looking at the citro3d source, there is only one stride setting per buffer. Is that correct? Also could you maybe (if thats not too annoying) explain what permutations are? And finally, by looking at the portal3ds source, I got that when drawing from md2 files, smea would use 3 buffers because of the layout of the models in memory? Is that it too?

Oh also once it is processed by ctrulib in which register is stride set? Is it in GPU_ATTRIBBUFFERi_CONFIG1/2?

This should be it (sorry that's like 4 questions in one post), thanks for your help so far, I understand I must sound quite annoying with this, but really you've been extremely helpful so far, I can't thank you enough!
That is a lot of questions - that are not easily answered. Your best bet is to read this - https://www.3dbrew.org/wiki/GPU/Internal_Registers#Geometry_pipeline_registers and then compare it to citro3d. To specifically answer one of your questions - the stride is per buffer in config2 bits 16 to 23.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Maximumbeans @ Maximumbeans: butte