Homebrew [Release] Caelina - OpenGL Driver

  • Thread starter Thread starter machinamentum
  • Start date Start date
  • Views Views 30,837
  • Replies Replies 118
  • Likes Likes 33
I tried a modified GPU_SetAttributeBuffers that let me specific the stride as well. If the stride was larger than the sum of the attribute sizes then it did not work.
 
Lol, I have butchered test code committed where I was trying similar stuff: https://github.com/cpp3ds/gl3ds/blob/master/src/varray.c#L2376

I'll have to revisit it when I get some time. The GPU is a bit better documented now than it was.
That's interesting. I've delved deeper into this and it seems like Citra ignores those bits anyways (changing them on hardware doesn't seem to do anything at all either). I think alternatively if the stride is always 4-byte aligned, we could calculate the excess padding needed and just set the extra attribute components to be padding.
EDIT: in addition to this, unused vertex attributes can be set to unsigned byte with 8 bit or 16 bit sizes then you could produce a stride of 1-byte alignment
 
Last edited by machinamentum,
That's interesting. I've delved deeper into this and it seems like Citra ignores those bits anyways (changing them on hardware doesn't seem to do anything at all either). I think alternatively if the stride is always 4-byte aligned, we could calculate the excess padding needed and just set the extra attribute components to be padding.
EDIT: in addition to this, unused vertex attributes can be set to unsigned byte with 8 bit or 16 bit sizes then you could produce a stride of 1-byte alignment
This does not match my tests (which may be flawed and I may be misunderstanding what you are stating). The last I tested this citra will use the supplied stride appropriately where as the hardware will hang if it is not packed.
 
This does not match my tests (which may be flawed and I may be misunderstanding what you are stating). The last I tested this citra will use the supplied stride appropriately where as the hardware will hang if it is not packed.
I was writing to GPUREG_ATTRIBUFFERi_CONFIG2 after calling GPU_SetAttributeBuffers, but it seems doing so doesn't overwrite the value there. I tried changing the GPU_SetAttributeBuffers code as well and I've gotten the same result as you described.

EDIT: I've got a POC working using the padding method I've previously described. Idk why ctrulib's GPU_SetAttributeBuffers hasn't been updated to include support for padding in the size table.
 
Last edited by machinamentum,
I was writing to GPUREG_ATTRIBUFFERi_CONFIG2 after calling GPU_SetAttributeBuffers, but it seems doing so doesn't overwrite the value there. I tried changing the GPU_SetAttributeBuffers code as well and I've gotten the same result as you described.

EDIT: I've got a POC working using the padding method I've previously described. Idk why ctrulib's GPU_SetAttributeBuffers hasn't been updated to include support for padding in the size table.
this method allows using non packed strides with arbitrary gaps?
 
this method allows using non packed strides with arbitrary gaps?
The smallest amount of padding the hardware supports is 4 bytes (8, 12, 16 are also available), so i assume it would work with any stride where (stride % 4 == 0) as long as enough buffer components are available. I've yet to get 1-byte padding working using 1-byte vertex attributes.
 
Last edited by machinamentum,
The smallest amount of padding the hardware supports is 4 bytes (8, 12, 16 are also available), so i assume it would work with any stride where (stride % 4 == 0) as long as enough buffer components are available. I've yet to get 1-byte padding working using 1-byte vertex attributes.
Hmm. I am not sure if that is worth the effort. The approach I was taking was to fast path attribute buffers with packed attributes created with glGenBuffers. For non buffered I assumed it was in generally memory and needed to be moved to linear and I would pack it into a temporary buffer in linear.
 
When compiling nehe example 1 I get:
"c:/Users/Kaleb/Downloads/Hacking/Nintendo/3DS/Caelina-master/examples/nehe/lesson01/source/main.cpp:8:19: fatal error: GL/gl.h: No such file or directory"
"compilation terminated."
"make[1]: *** [main.o] Error 1"
"make: *** [build] Error 2"
Fix?
 
When compiling nehe example 1 I get:
"c:/Users/Kaleb/Downloads/Hacking/Nintendo/3DS/Caelina-master/examples/nehe/lesson01/source/main.cpp:8:19: fatal error: GL/gl.h: No such file or directory"
"compilation terminated."
"make[1]: *** [main.o] Error 1"
"make: *** [build] Error 2"
Fix?
You need the headers provided in the release download in your compiler's path. The typical install location for the headers is <devkitPro>/libctru/include and the location for the libs is <devkitPro>/libctru/lib. If you have nihstro, you can add that to your path then just "make install" in the "libcaelina" folder; it'll put the headers and libs in the correct places.
 
You need the headers provided in the release download in your compiler's path. The typical install location for the headers is <devkitPro>/libctru/include and the location for the libs is <devkitPro>/libctru/lib. If you have nihstro, you can add that to your path then just "make install" in the "libcaelina" folder; it'll put the headers and libs in the correct places.
-snip-

EDIT: Forgot what header files were for a second. :P
 
Last edited by YugamiSekai,
Error when compiling (after installing Git Bash):
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
make -f MakefileGLESv1
make[1]: Entering directory `/c/devkitPro/libctru/lib/libcaelina'
clear_shader.vsh
/nihstro-assemble --input /c/devkitPro/libctru/lib/libcaelina/data/clear_shader.vsh --output ../clear_shader.vsh.shbin
make[2]: /nihstro-assemble: Command not found
make[2]: *** [clear_shader.vsh.o] Error 127
make[1]: *** [build_GLESv1] Error 2
make[1]: Leaving directory `/c/devkitPro/libctru/lib/libcaelina'
make: *** [all] Error 2
 
Error when compiling (after installing Git Bash):
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
make -f MakefileGLESv1
make[1]: Entering directory `/c/devkitPro/libctru/lib/libcaelina'
clear_shader.vsh
/nihstro-assemble --input /c/devkitPro/libctru/lib/libcaelina/data/clear_shader.vsh --output ../clear_shader.vsh.shbin
make[2]: /nihstro-assemble: Command not found
make[2]: *** [clear_shader.vsh.o] Error 127
make[1]: *** [build_GLESv1] Error 2
make[1]: Leaving directory `/c/devkitPro/libctru/lib/libcaelina'
make: *** [all] Error 2
You need to have nihstro to build from source. Then set an environment variable called NIHSTRO pointing to the directory of where nihstro-assemble was built.

EDIT: Git isn't a requirement to build, but it'll give you that error if you just downloaded the zipped source instead of cloning the repository using git.
 
Last edited by machinamentum,
You need to have nihstro to build from source. Then set an environment variable called NIHSTRO pointing to the directory of where nihstro-assemble was built.

EDIT: Git isn't a requirement to build, but it'll give you that error if you just downloaded the zipped source instead of cloning the repository using git.
Do you know where I can find a precompiled nihstro?
 
You need to have nihstro to build from source. Then set an environment variable called NIHSTRO pointing to the directory of where nihstro-assemble was built.
Got nihstro binaries and setting a path doesn't work (unless I'm doing it wrong, I'm editing the PATH variable in both system and user variables).
 
Got nihstro binaries and setting a path doesn't work (unless I'm doing it wrong, I'm editing the PATH variable in both system and user variables).
You don't need to add it to the PATH variable, you need to create a new variable called NIHSTRO pointing to the directory. If you don't want to add a new variable you could also replace $(NIHSTRO) with the full path in the makefile
 
You don't need to add it to the PATH variable, you need to create a new variable called NIHSTRO pointing to the directory. If you don't want to add a new variable you could also replace $(NIHSTRO) with the full path in the makefile
Makefile used /nihstro-assemble. Had to take the slash out and it's finally compiled.
 
@machinamentum I'd like to try your lib but seems that the code needs some update to build with the lastes ctrulib version.

Is there any chance that you update the code?
 

Site & Scene News

Popular threads in this forum