Homebrew [Release] {beta} sf2dlib - Simple and Fast 2D library (using the GPU)

  • Thread starter Thread starter xerpi
  • Start date Start date
  • Views Views 97,198
  • Replies Replies 501
  • Likes Likes 32
Code:
sfillib-master/libsfil/source/sfil_jpeg.c:5:21: fatal error: jpeglib.h: No such file or directory
Not sure if its something I am doing wrong, but there is no jpeglib.h to be found.
 
Xerpi bro,

I have an issue help please

On my app i frequently change textures ( first free texture then create texture). When i change the texture a couple of times ( probably 10) the texture create command stops from loading new textures.


I'm currently loading textures to RAM. I will try to place textures in VRAM to see if i have same results.

Have a nice day.
 
W̶h̶e̶n̶ ̶I̶ ̶t̶r̶y̶ ̶t̶o̶ ̶r̶u̶n̶ ̶m̶y̶ ̶h̶o̶m̶e̶b̶r̶e̶w̶ ̶a̶s̶ ̶a̶ ̶c̶i̶a̶,̶ ̶a̶s̶ ̶s̶o̶o̶n̶ ̶a̶s̶ ̶s̶f̶2̶d̶_̶i̶n̶i̶t̶(̶)̶;̶ ̶i̶s̶ ̶c̶a̶l̶l̶e̶d̶,̶ ̶t̶h̶e̶ ̶s̶y̶s̶t̶e̶m̶ ̶f̶r̶e̶e̶z̶e̶s̶.̶

this might not be the case, i am currently trying to debug sf2dlib and find the exact line of code the freeze occurs.
 
Xerpi bro,

I have an issue help please

On my app i frequently change textures ( first free texture then create texture). When i change the texture a couple of times ( probably 10) the texture create command stops from loading new textures.


I'm currently loading textures to RAM. I will try to place textures in VRAM to see if i have same results.

Have a nice day.

Do you have the code uploaded somewhere (github maybe)?
 
  • Like
Reactions: Marco D
Think I tracked down the problem with CIA.
Code:
void sf2d_end_frame()
{
GPU_FinishDrawing();
printf("22\n");
gfxFlushBuffers();
gfxSwapBuffers();
 
GPUCMD_Finalize();
printf("23\n");
gfxFlushBuffers();
gfxSwapBuffers();
 
GPUCMD_FlushAndRun(NULL);
printf("24\n");
gfxFlushBuffers();
gfxSwapBuffers();
 
gspWaitForP3D();
printf("25\n");
gfxFlushBuffers();
gfxSwapBuffers();
22, 23, and 24 print, but 25 is never printed the system is unresponsive. something must be keeping the system from continuing from gspWaitForP3D(); more debugging is needed.
 
  • Like
Reactions: Margen67
Think I tracked down the problem with CIA.
Code:
void sf2d_end_frame()
{
GPU_FinishDrawing();
printf("22\n");
gfxFlushBuffers();
gfxSwapBuffers();
 
GPUCMD_Finalize();
printf("23\n");
gfxFlushBuffers();
gfxSwapBuffers();
 
GPUCMD_FlushAndRun(NULL);
printf("24\n");
gfxFlushBuffers();
gfxSwapBuffers();
 
gspWaitForP3D();
printf("25\n");
gfxFlushBuffers();
gfxSwapBuffers();
22, 23, and 24 print, but 25 is never printed the system is unresponsive. something must be keeping the system from continuing from gspWaitForP3D(); more debugging is needed.
Take a look at gsSafeWait used in portal3ds. It is in gs.c. Essentially it puts a timeout on the wait functions. Instead of waiting forever for an event it gives up after 40 ms. Every once in a while the wait call will timeout. I am not sure if it an issue with ctrulib or the state of the system as a result of the hacks needed to get homebrew running.
 
Just created the repo. So the RAM is getting overflowed by the command then linearSpaceFree() is less than the new texture.

https://github.com/markwinap/3DS_Nyan_Cat
Cool, I think I've found the problem: inside of some if's you do free_texture(tex) and then instead of assigning the new texture you create to tex, you redeclare tex (sf2d_texture *tex) so the pointer gets lost after exiting the if scope.
 
So i finally got ninjhax working and i still cant get sf2dlib homebrew to work on hardware even as 3dsx.

What are you actually trying to render? As in, what is your code like? Also, are you on the latest ctrulib? Some time ago, there was a similar issue that had to be fixed.
 
  • Like
Reactions: xerpi
What are you actually trying to render? As in, what is your code like? Also, are you on the latest ctrulib? Some time ago, there was a similar issue that had to be fixed.

devkitpro updater is not showing any new versions of ctrulib.

Code:
#include <stdio.h>
#include <3ds.h>
#include <sf2d.h>
 
int main()
{
sf2d_init();
sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
 
consoleInit(GFX_BOTTOM, NULL);
printf("Hello World!");
gfxFlushBuffers();
gfxSwapBuffers();
 
while (aptMainLoop()) {
 
sf2d_start_frame(GFX_TOP, GFX_LEFT);
sf2d_end_frame();
sf2d_swapbuffers();
 
hidScanInput();
if (hidKeysDown() & KEY_START) break;
}
 
gfxSwapBuffers();
 
return 0;
 
}
citra - top screen is a grey color, bottom screen says Hello World!
hardware - top screen is a black color, bottom screen says Hello World! pressing start does nothing, system is completely unresponsive.
 
  • Like
Reactions: Margen67
devkitpro updater is not showing any new versions of ctrulib.

Code:
#include <stdio.h>
#include <3ds.h>
#include <sf2d.h>
 
int main()
{
sf2d_init();
sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));
 
consoleInit(GFX_BOTTOM, NULL);
printf("Hello World!");
gfxFlushBuffers();
gfxSwapBuffers();
 
while (aptMainLoop()) {
 
sf2d_start_frame(GFX_TOP, GFX_LEFT);
sf2d_end_frame();
sf2d_swapbuffers();
 
hidScanInput();
if (hidKeysDown() & KEY_START) break;
}
 
gfxSwapBuffers();
 
return 0;
 
}
citra - top screen is a grey color, bottom screen says Hello World!
hardware - top screen is a black color, bottom screen says Hello World! pressing start does nothing, system is completely unresponsive.


Try building ctrulib manually.
 
  • Like
Reactions: Margen67
Cool, I think I've found the problem: inside of some if's you do free_texture(tex) and then instead of assigning the new texture you create to tex, you redeclare tex (sf2d_texture *tex) so the pointer gets lost after exiting the if scope.


Xerpi thanks a lot for spending your time looking at my code. Based on your comments i will try to work to fix that issue.

Have a nice day bro
 
What good 3d library using gpu there is for 3ds since i want to create a custom port of open hexagon(open source super hexagon)for 3ds

Nothing comprehensive exists publicly that I'm aware of. You'll most likely want an OpenGL implementation. I'm trying to improve ctrgl which is a great start but is now a bit outdated, broken, and incomplete. And I'm working on a SFML port for the 3DS and it will be released in a couple weeks most likely. But even after release it will need a lot more work, so I wouldn't bother trying to port any substantial games now.
 
You need to install the portlibs: https://github.com/xerpi/3ds_portlibs

Just fyi, and in case it helps anyone, "make"-ing this failed on my mac because the preinstalled version of tar doesn't support -xaf (specifically the -a switch, which doesn't seem vital for extraction anyway). I changed all instances in the makefile to -xf and it works fine.

PS: thanks for the great libs, will be trying them out now!
 
  • Like
Reactions: xerpi
Just fyi, and in case it helps anyone, "make"-ing this failed on my mac because the preinstalled version of tar doesn't support -xaf (specifically the -a switch, which doesn't seem vital for extraction anyway). I changed all instances in the makefile to -xf and it works fine.

PS: thanks for the great libs, will be trying them out now!

Thanks for the info! I've updated the Makefile.
 
  • Like
Reactions: hippy dave

Site & Scene News

Popular threads in this forum