GPU_SetAttributeBuffers

Discussion in '3DS - Homebrew Development and Emulators' started by elhobbs, Aug 18, 2015.

  1. elhobbs
    OP

    elhobbs GBAtemp Advanced Fan

    Member
    783
    292
    Jul 28, 2008
    United States
    has anyone been able to use a single buffer with attributes in non-identity order?
    so instead of:
    Code:
    GPU_SetAttributeBuffers(
       3, // number of attributes
       (u32*)osConvertVirtToPhys(__linear_heap), // we use the start of linear heap as base since that's where all our buffers are located
       GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 2, GPU_FLOAT) | GPU_ATTRIBFMT(2, 3, GPU_FLOAT), // we want v0, v1 and v2
       0xFF8, // mask : we want v0, v1 and v2
       0x210, // permutation : we use identity
       1, // number of buffers : we have one attribute per buffer
       (u32[]){(u32)vertexBuffer - __linear_heap}, // buffer offsets (placeholders)
       (u64[]){0x210}, // attribute permutations for each buffer
       (u8[]){3} // number of attributes for each buffer
       );
    use :
    Code:
    GPU_SetAttributeBuffers(
    	3, // number of attributes
    	(u32*)osConvertVirtToPhys(__linear_heap), // we use the start of linear heap as base since that's where all our buffers are located
    	GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | GPU_ATTRIBFMT(1, 3, GPU_FLOAT)| GPU_ATTRIBFMT(2, 2, GPU_FLOAT), // we want v0, v1 and v2
    	0xFF8, // mask : we want v0, v1 and v2
    	0x120, // permutation : we use identity
    	1, // number of buffers : we have one attribute per buffer
    	(u32[]){(u32)vertexBuffer - __linear_heap}, // buffer offsets (placeholders)
    	(u64[]){0x120}, // attribute permutations for each buffer
    	(u8[]){3} // number of attributes for each buffer
    	);
    essentially, the first example puts the attributes in the order defined by the shader. The second example is trying to send the attributes out of order in the buffer by adjusting the permutations and attribute format definition. there does appear to be an issue in GPU_SetAttributeBuffers where it does not calculate the stride correctly when the attribute order is not identity, but compensating for that still does not work correctly.