Skip to content

Commit 97df4f2

Browse files
mardyWinterMute
authored andcommitted
ogc: do not clear the EFB when saving it
We don't need to clear the EFB, since we are going to immediately load a texture onto it. But at the same time we must make sure that there is no blending when we loat the new texture onto the EFB, because we want to completely replace its contents.
1 parent 493df51 commit 97df4f2

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/render/ogc/SDL_render_ogc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static void load_efb_from_texture(SDL_Renderer *renderer, SDL_Texture *texture)
107107

108108
OGC_load_texture(ogc_tex->texels, texture->w, texture->h,
109109
ogc_tex->format, SDL_ScaleModeNearest);
110+
OGC_SetBlendMode(renderer, SDL_BLENDMODE_NONE);
110111

111112
/* The viewport is reset when OGC_SetRenderTarget() returns. */
112113
OGC_set_viewport(0, 0, texture->w, texture->h);
@@ -137,7 +138,7 @@ static void load_efb_from_texture(SDL_Renderer *renderer, SDL_Texture *texture)
137138
GX_End();
138139
}
139140

140-
static void save_efb_to_texture(SDL_Texture *texture)
141+
static void save_efb_to_texture(SDL_Texture *texture, bool must_clear)
141142
{
142143
OGC_TextureData *ogc_tex = texture->driverdata;
143144
u32 texture_size;
@@ -148,7 +149,7 @@ static void save_efb_to_texture(SDL_Texture *texture)
148149

149150
GX_SetTexCopySrc(0, 0, texture->w, texture->h);
150151
GX_SetTexCopyDst(texture->w, texture->h, ogc_tex->format, GX_FALSE);
151-
GX_CopyTex(ogc_tex->texels, GX_TRUE);
152+
GX_CopyTex(ogc_tex->texels, must_clear ? GX_TRUE : GX_FALSE);
152153
GX_PixModeSync();
153154
}
154155

@@ -275,14 +276,14 @@ static int OGC_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
275276
u8 desired_efb_pixel_format = GX_PF_RGB8_Z24;
276277

277278
if (data->render_target) {
278-
save_efb_to_texture(data->render_target);
279+
save_efb_to_texture(data->render_target, false);
279280
} else if (data->ops_after_present > 0) {
280281
/* Save the current EFB contents if we already drew something onto
281282
* it. We'll restore it later, when the rendering target is reset
282283
* to NULL (the screen). */
283284
if (!data->saved_efb_texture)
284285
data->saved_efb_texture = create_efb_texture(data, renderer->window);
285-
save_efb_to_texture(data->saved_efb_texture);
286+
save_efb_to_texture(data->saved_efb_texture, false);
286287
}
287288

288289
if (texture) {
@@ -462,7 +463,7 @@ static int OGC_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
462463
data->clear_color = c;
463464
GX_SetCopyClear(c, GX_MAX_Z24);
464465
if (renderer->target) {
465-
save_efb_to_texture(renderer->target);
466+
save_efb_to_texture(renderer->target, true);
466467
} else {
467468
GX_CopyDisp(OGC_video_get_xfb(SDL_GetVideoDevice()), GX_TRUE);
468469
}

0 commit comments

Comments
 (0)