Comments (4)
Created another version that draws and then waits for the A button to be pressed to do the offscreen drawing, it still crashes in the same spot in display_get
:
#include <libdragon.h>
static surface_t zbuffer;
static unsigned int counter = 0;
static void draw(void) {
rdpq_clear(RGBA32(0, 0, counter & 255, 255));
rdpq_clear_z(0xfffc);
rdpq_mode_begin();
rdpq_set_mode_standard();
rdpq_mode_zbuf(true, true);
rdpq_mode_end();
rdpq_mode_combiner(RDPQ_COMBINER_FLAT);
rdpq_set_prim_color(RGBA32(255, 0, 0, 255));
const float vs[][3] = { { 20, 20, 0 }, { 50, 20, 1 }, { 20, 40, 0.5 } };
rdpq_triangle(&TRIFMT_ZBUF, vs[0], vs[1], vs[2]);
counter++;
}
static void draw_offscreen(void) {
surface_t *screen = display_get();
surface_t buffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
rdpq_attach(screen, NULL);
rdpq_attach(&buffer, &zbuffer);
draw();
rdpq_detach();
rdpq_set_mode_standard();
rdpq_tex_blit(&buffer, 0, 0, NULL);
rdpq_detach_wait();
surface_free(&buffer);
}
int main(void) {
debug_init_isviewer();
debug_init_usblog();
controller_init();
rdpq_init();
rdpq_debug_start();
rdpq_debug_log(true);
display_init(RESOLUTION_640x480, DEPTH_16_BPP, 3, GAMMA_NONE, ANTIALIAS_OFF);
zbuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
surface_t *screen = display_get();
rdpq_attach(screen, &zbuffer);
draw();
rdpq_detach_show();
while (true) {
controller_scan();
struct controller_data pressed = get_keys_pressed();
if (pressed.c[0].A)
break;
}
while(true)
draw_offscreen();
return 0;
}
from libdragon.
Note that it also seems to crash immediately if the first draw is changed to use rspq_detach_wait
, like this:
display_init(RESOLUTION_640x480, DEPTH_16_BPP, 3, GAMMA_NONE, ANTIALIAS_OFF);
zbuffer = surface_alloc(FMT_RGBA16, display_get_width(), display_get_height());
surface_t *screen = display_get();
rdpq_attach(screen, &zbuffer);
draw();
rdpq_detach_wait(); // RSP CRASH
from libdragon.
The reproducer seems to misuse the API: every call to display_get
must have a corresponding display_show
to release the locked framebuffer. One way to do that is to use rdpq_detach_show()
which does that in background without blocking the CPU for the RDP to finish, but any way you need to call display_show()
. Both the examples enter a strict loop where display_get
is called but display_show
is not.
I don't know if this was the original bug that you hit during the jam, or it's a different one, but in this case the reproducer doesn't seem to reproduce it.
from libdragon.
Yes the code above is fixed by adding the missing display_show
. However that wasn't the issue in my game which I am still seeing... closing this as I try to come up with a better reproducer
from libdragon.
Related Issues (20)
- Hello world HOT 1
- Can't draw sprite with rdp unless drawing in software first HOT 2
- ARM platforms not supported in the Dockerfiles on GHCR HOT 3
- [preview] RSP crash (?) with an extremely simple rom using rdpq
- [preview] rdpq validator validates tile for tex0 even if the combiner does not use it HOT 1
- [preview] new joypad library does not work on iQue HOT 1
- [preview] emit an assert when using Opus on a mixer channel not ready for 48 Khz HOT 1
- Add an assertion when using old-school sprite loading with compressed sprites HOT 1
- [preview] regression in mixer causes audio playback issues with XM64 HOT 1
- stat() doesn't work on directories HOT 1
- argument 1 value ‘18446744073709551611’ exceeds maximum object size 9223372036854775807 HOT 1
- Reading directory contents from sdcard on flash cartdrige HOT 4
- identify_accessory() identifies controller pak as rumble pak HOT 6
- Random Crashes / corruptions when using simple ucode
- Backtrace broken in case exception is triggered in tail call
- Missing examples (good first issue!) HOT 2
- rdpq_sprite_blit crop doesn't work with flipping
- PAL50 resolutions are letterboxed
- Improve FatFs speed by merging wf-fatfs changes
- Disable rumble pak on reset/crash HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libdragon.