What is GPUREG_ATTRIBBUFFERi_CONFIG0?

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

  1. cal64
    OP

    cal64 Member

    Newcomer
    43
    4
    Oct 31, 2016
    Belgium
    I've been looking at the portal3ds source code, and can't figure out what the GPUREG_ATTRIBBUFFERi_CONFIG0 register is for, as I can't find it in the internal registers page of 3dbrew. That being said, I suspect it to be an early define for GPUREG_ATTRIBBUFFERi_OFFSET.
    But then, what's the difference between it
    and GPUREG_VERTEX_OFFSET?

    Any help is appreciated!!
     
    Last edited by cal64, Jan 21, 2017
  2. Skyshadow101

    Skyshadow101 The Sky Is The Limit!

    Member
    926
    319
    May 22, 2016
    United States
    The Underground
    -snip- Nvm
     
  3. TheCruel

    TheCruel Developer

    Banned
    1,351
    2,884
    Dec 6, 2013
    United States
  4. cal64
    OP

    cal64 Member

    Newcomer
    43
    4
    Oct 31, 2016
    Belgium
  5. cal64
    OP

    cal64 Member

    Newcomer
    43
    4
    Oct 31, 2016
    Belgium
    From my current understanding, I got that GPUREG_ATTRIBBUFFERi_OFFSET is essentially an equivalent for the offset in vertexattribformat in opengl, defining where each vertex attribute is, while GPUREG_VERTEX_OFFSET sets where the first vertex to draw is.

    Is that it, or am I completely wrong? Sorry to keep insisting but that would really help!
     
  6. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    806
    296
    Jul 28, 2008
    United States
    There is a base address used by all attribute buffers at GPUREG_ATTRIBBUFFERS_LOC. When you configure each of the individual attribute buffers the data is specified as an offset from the shared base using GPUREG_ATTRIBBUFFERSi_OFFSET.
    GPUREG_VERTEX_OFFSET is generally left at 0 in homebrew. I suspect it has something to do with offsetting values referenced in GPUREG_INDEXBUFFER_CONFIG or possibly GPUREG_DRAWARRAYS or GPUREG_DRAWELEMENTS - not really sure though as I have not seen it used.
     
  7. cal64
    OP

    cal64 Member

    Newcomer
    43
    4
    Oct 31, 2016
    Belgium
    Thank you so much for all of this, this is really helping out! As for VERTEX_OFFSET being left to 0, it appears, in the case of portal3ds, that GPUREG_ATTRIBBUFFERSi_OFFSET is set the first vertex of whatever there is to draw everytime there's something to draw, thus defeating the purpose of the VERTEX_OFFSET register, I suppose.
    That's what I got from the source regarding what you said, althought I'm probably wrong :) . The whole point of this for me is to learn this kind of thing, so if you have any thoughts regarding what I said here, feel free to share them, as talking about this kind of stuff really makes it easier to understand and learn! (Again, thanks a lot for your help, and sorry for my potentially broken english!)
     
  8. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    806
    296
    Jul 28, 2008
    United States
    GPUREG_ATTRIBBUFFERSi_OFFSET points to a buffer with vertex data. GPUREG_INDEXBUFFER_CONFIG is used to generate primitives based on the order in the index buffer. the index buffer format only allows bytes or shorts for the index values. in theory GPUREG_VERTEX_OFFSET could be used to start further along in the buffer. I suspect it is something along the lines of glDrawElements vs glDrawElementsBaseVertex, but I am not really sure.
     
  9. cal64
    OP

    cal64 Member

    Newcomer
    43
    4
    Oct 31, 2016
    Belgium
    While I didn't quite get the last part with the OpenGL correlation you made, I meant by "defeating the purpose" that while using the VERTEX_OFFSET register was possible, it would only cause the models to not be drawn fully. The only proper use of it I can think of would be to draw each model without adjusting GPUREG_ATTRIBBUFFERSi_OFFSET every time, and instead use the VERTEX_OFFSET register to separate the models from one another, however that does not seem feasible to me because of the way things are layed out in memory (the structs would prevent being able to keep the synchronisation between GPUREG_ATTRIBBUFFERSi_OFFSET and the vertex attributes from one model to the next, but then again maybe I'm not visualizing things right here. Would that be correct?) Also the VERTEX_OFFSET register is also left at 0 when using drawarray calls.

    Thanks again, and by the way please tell me if I'm getting annoying with this :).
     
    Last edited by cal64, Jan 22, 2017
  10. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    806
    296
    Jul 28, 2008
    United States
    If that did not make sense then I recommend that you ignore the vertex offset register and leave it at 0.
     
  11. cal64
    OP

    cal64 Member

    Newcomer
    43
    4
    Oct 31, 2016
    Belgium
    I just didn't get what you meant by that (I'm assuming you're talking about the OpenGL part...?). I didn't mean to sound rude, I'm sorry if I did.

    EDIT: Ooh, Got it. Well, thanks to you I've got all the info I needed. Thank you, you're the best!
     
    Last edited by cal64, Jan 24, 2017