Giter VIP home page Giter VIP logo

Comments (4)

 avatar commented on July 28, 2024

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.

 avatar commented on July 28, 2024

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.

rasky avatar rasky commented on July 28, 2024

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.

 avatar commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.