How does stride work in GPU_SetAttributeBuffers?

Discussion in '3DS - Homebrew Development and Emulators' started by cal64, Jan 22, 2017.

  1. cal64
    OP

    cal64 Advanced Member

    Newcomer
    50
    5
    Oct 31, 2016
    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!)
     
  2. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    813
    300
    Jul 28, 2008
    United States
    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.
     
  3. cal64
    OP

    cal64 Advanced Member

    Newcomer
    50
    5
    Oct 31, 2016
    France
    Isn't there any documentation on how it's implemented in the GPU?
    Thanks for helping by the way!
     
  4. cal64
    OP

    cal64 Advanced Member

    Newcomer
    50
    5
    Oct 31, 2016
    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, Jan 25, 2017
  5. Hayleia

    Hayleia GBAtemp Maniac

    Member
    1,485
    1,136
    Feb 26, 2015
    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.
     
  6. cal64
    OP

    cal64 Advanced Member

    Newcomer
    50
    5
    Oct 31, 2016
    France
    Well, that I already got, what I meant is do strides work per-buffer?

    — Posts automatically merged - Please don't double post! —

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

    elhobbs GBAtemp Advanced Fan

    Member
    813
    300
    Jul 28, 2008
    United States
    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.