-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
3DS: Initial accelerated renderer #9598
base: SDL2
Are you sure you want to change the base?
Conversation
Thank you for your efforts! After debugging, I found out that this was down to an incorrect implementation of diff --git a/src/render/n3ds/SDL_render_n3ds.c b/src/render/n3ds/SDL_render_n3ds.c
index bb26480ea..a38586448 100644
--- a/src/render/n3ds/SDL_render_n3ds.c
+++ b/src/render/n3ds/SDL_render_n3ds.c
@@ -666,8 +666,15 @@ N3DS_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert
switch (cmd->command) {
case SDL_RENDERCMD_SETVIEWPORT: {
SDL_Rect *viewport = &cmd->data.viewport.rect;
- C3D_SetViewport(viewport->x, viewport->y, viewport->w, viewport->h);
- C3D_SetScissor(GPU_SCISSOR_NORMAL, viewport->x, viewport->y, viewport->x + viewport->w, viewport->y + viewport->h);
+ if (data->boundTarget) {
+ C3D_SetViewport(viewport->x, viewport->y, viewport->w, viewport->h);
+ } else {
+ // Handle the tilted render target of the 3DS display.
+ C3D_SetViewport(
+ data->renderTarget->frameBuf.width - viewport->h - viewport->y,
+ data->renderTarget->frameBuf.height - viewport->w - viewport->x,
+ viewport->h, viewport->w);
+ }
break;
}
@@ -687,7 +694,7 @@ N3DS_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vert
case SDL_RENDERCMD_SETCLIPRECT: {
const SDL_Rect *rect = &cmd->data.cliprect.rect;
- if(cmd->data.cliprect.enabled){
+ if (cmd->data.cliprect.enabled) {
C3D_SetScissor(GPU_SCISSOR_NORMAL, rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
} else {
C3D_SetScissor(GPU_SCISSOR_DISABLE, 0, 0, 0, 0); |
And here's a further patch that makes rectangle drawing work properly. This gets |
Cool, thanks. I've added both patches to the branch. A couple of additional notes:
|
This should fix the viewport being upside down. The issue with |
I hadn't actually tried it without the modifications, so that looks like a separate issue. I've pushed the relevant changes to get |
Please remove those changes before this PR is ready for review. testdrawchessboard is the only window surface test we have, and rely on it to catch regressions. |
Indeed, batching was broken. As was updating textures (I haven't figured out all the edge cases for hardware-accelerated texture swizzling, so I'm disabling it - for an initial implementation, this is probably good enough). This seems to make all the simpler tests I've thrown at it work, now - EDIT: 3ds_patch4.txt - fixes a few minor issues, but not render targets. Apologies for the pull request spam; I initially wrote this code in a day to get the general approach right, and I didn't realize it was quite this wonky... |
Thanks. I've added both of these to the branch, along with a couple of extra fixes.
I've split this into a separate PR: #9664 |
… now - requires a lot of fixes (vertex coordinates, shader, etc.) to get anywhere.
Co-authored-by: asiekierka <[email protected]>
Co-authored-by: asiekierka <[email protected]>
Co-authored-by: asiekierka <[email protected]>
Co-authored-by: asiekierka <[email protected]>
Co-authored-by: asiekierka <[email protected]>
8024360
to
e2de292
Compare
This is a rebased version of @asiekierka's original branch from #6251 (comment), with some additional fixes to get
testgeometry
to partially work.testgeometry
now displays, however the viewport is incorrect and it hangs when exiting the application. The rest of the test programs don't produce useful results.I'm not that familiar with 3DS GPU programming (or GPU programming in general), so any help would be appreciated.