Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quick fix, crash after too many calls #3

Merged
merged 2 commits into from
Apr 25, 2015
Merged

quick fix, crash after too many calls #3

merged 2 commits into from
Apr 25, 2015

Conversation

Lectem
Copy link
Contributor

@Lectem Lectem commented Apr 25, 2015

I added a pointer check for each sf2d_draw_* function so that app doesnt crash but stop drawing instead.

I don't understand why you would use a pool if it's not to draw it all at once though...

@xerpi
Copy link
Owner

xerpi commented Apr 25, 2015

Good one, basically I use a temporary memory pool to allocate vertices because maybe you only want to draw a rectangle on one frame, and not on the next, so I use this fast pool (mallocing on that pool is just moving an offset) to be able to do that without overhead, and then I set the offset to 0 at the start of each frame.
Btw I think:

if (!vertices) return;

Would be better (if you don't mind).

@Lectem
Copy link
Contributor Author

Lectem commented Apr 25, 2015

I still think that it is more or less useless. I mean, having a simple pool of union of sf2d_vertex_pos_tex and sf2d_vertex_pos_col would suffice for this, the only problem would be if GPU_DrawArray(GPU_TRIANGLE_STRIP, 4); was asynch and that we changed values too fast

@Lectem
Copy link
Contributor Author

Lectem commented Apr 25, 2015

If you really need a pool, make it a cyclic one, if you reach the end, reset it so that we can still draw stuff

@xerpi
Copy link
Owner

xerpi commented Apr 25, 2015

The problem is that the GPU_DrawArray simply adds a command to the GPU command queue, so we must not delete the vertices until we call:

    GPU_FinishDrawing();
    GPUCMD_Finalize();
    GPUCMD_FlushAndRun(NULL);

@Lectem
Copy link
Contributor Author

Lectem commented Apr 25, 2015

I wonder if we couldn't simply do

GPUCMD_FlushAndRun(NULL);
gspWaitForP3D();
GPUCMD_SetBufferOffset(0);

or

GPUCMD_Run(NULL);
gspWaitForP3D();
GPUCMD_SetBufferOffset(0);

so that the the cmd buffer would be treated and just continue issuing new commands.
Anyway, I think you could close the pull request as this subject is another issue

@xerpi
Copy link
Owner

xerpi commented Apr 25, 2015

Right, closed.

@xerpi xerpi closed this Apr 25, 2015
@xerpi xerpi reopened this Apr 25, 2015
xerpi added a commit that referenced this pull request Apr 25, 2015
quick fix, crash after too many calls
@xerpi xerpi merged commit cf84be9 into xerpi:master Apr 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants