Texture render target
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c
index ae0f6ac..bfb4bf4 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm.c
@@ -121,27 +121,45 @@ StartDrawing(SDL_Renderer *renderer)
{
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
if(data->drawing)
+ {
+ SDL_LogError(SDL_LOG_CATEGORY_RENDER, "uh-oh, already drawing\n");
return;
+ }
// reset blend mode
- data->currentBlendMode = SDL_BLENDMODE_BLEND;
- fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend;
- data->colorFragmentProgram = in->color;
- data->textureFragmentProgram = in->texture;
- data->textureTintFragmentProgram = in->textureTint;
-
- sceGxmBeginScene(
- data->gxm_context,
- 0,
- data->renderTarget,
- NULL,
- NULL,
- data->displayBufferSync[data->backBufferIndex],
- &data->displaySurface[data->backBufferIndex],
- &data->depthSurface
- );
+// data->currentBlendMode = SDL_BLENDMODE_BLEND;
+// fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend;
+// data->colorFragmentProgram = in->color;
+// data->textureFragmentProgram = in->texture;
+// data->textureTintFragmentProgram = in->textureTint;
+
+ if (renderer->target == NULL) {
+ sceGxmBeginScene(
+ data->gxm_context,
+ 0,
+ data->renderTarget,
+ NULL,
+ NULL,
+ data->displayBufferSync[data->backBufferIndex],
+ &data->displaySurface[data->backBufferIndex],
+ &data->depthSurface
+ );
+ } else {
+ VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) renderer->target->driverdata;
+
+ sceGxmBeginScene(
+ data->gxm_context,
+ 0,
+ vita_texture->tex->gxm_rendertarget,
+ NULL,
+ NULL,
+ NULL,
+ &vita_texture->tex->gxm_colorsurface,
+ &vita_texture->tex->gxm_depthstencil
+ );
+ }
- unset_clip_rectangle(data);
+// unset_clip_rectangle(data);
data->drawing = SDL_TRUE;
}
@@ -232,7 +250,7 @@ VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
return SDL_OutOfMemory();
}
- vita_texture->tex = create_gxm_texture(data, texture->w, texture->h, SCE_GXM_TEXTURE_FORMAT_A8B8G8R8, 0); // TODO: rendertarget support, other formats
+ vita_texture->tex = create_gxm_texture(data, texture->w, texture->h, SCE_GXM_TEXTURE_FORMAT_A8B8G8R8, (texture->access == SDL_TEXTUREACCESS_TARGET));
if (!vita_texture->tex) {
SDL_free(vita_texture);
@@ -329,7 +347,7 @@ VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL
static int
VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
{
- return 0; // TODO
+ return 0; // nothing to do here
}
static void
@@ -751,11 +769,7 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *
}
case SDL_RENDERCMD_SETVIEWPORT: {
-/* SDL_Rect *viewport = &data->drawstate.viewport;
- if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof (SDL_Rect)) != 0) {
- SDL_memcpy(viewport, &cmd->data.viewport.rect, sizeof (SDL_Rect));
- data->drawstate.viewport_dirty = SDL_TRUE;
- }*/
+ // TODO
break;
}
@@ -855,6 +869,9 @@ VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *
cmd = cmd->next;
}
+ sceGxmEndScene(data->gxm_context, NULL, NULL);
+ data->drawing = SDL_FALSE;
+
return 0;
}
@@ -879,10 +896,6 @@ VITA_GXM_RenderPresent(SDL_Renderer *renderer)
{
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
- if(!data->drawing)
- return;
-
- sceGxmEndScene(data->gxm_context, NULL, NULL);
sceGxmFinish(data->gxm_context);
data->displayData.address = data->displayBufferData[data->backBufferIndex];