port: fix new fb effects when MSAA is on

This commit is contained in:
fgsfds committed 2023-10-16 23:06:00 +02:00
1 parent 79f8a35c33
commit dbebe7e626
6 files changed
+46 -10

No files matched your search

+5 -2
View File
@@ -1110,7 +1110,7 @@ void gfx_opengl_select_texture_fb(int fb_id) {
glBindTexture(GL_TEXTURE_2D, framebuffers[fb_id].clrbuf);
}
void gfx_opengl_copy_framebuffer(int fb_dst, int fb_src, int left, int top, bool use_back) {
void gfx_opengl_copy_framebuffer(int fb_dst, int fb_src, int left, int top, bool flip_y, bool use_back) {
if (!gfx_framebuffers_enabled || fb_dst >= (int)framebuffers.size() || fb_src >= (int)framebuffers.size()) {
return;
}
@@ -1144,9 +1144,12 @@ void gfx_opengl_copy_framebuffer(int fb_dst, int fb_src, int left, int top, bool
glBindFramebuffer(GL_READ_FRAMEBUFFER, src.fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst.fbo);
if (fb_src == 0) {
if (flip_y) {
// flip the dst rect to mirror the image vertically
std::swap(dstY0, dstY1);
}
if (fb_src == 0) {
glReadBuffer(use_back ? GL_BACK : GL_FRONT);
} else {
glReadBuffer(GL_COLOR_ATTACHMENT0);
+16 -7
View File
@@ -2883,14 +2883,23 @@ extern "C" void gfx_set_framebuffer(int fb, float noise_scale) {
}
extern "C" void gfx_copy_framebuffer(int fb_dst, int fb_src, int left, int top, int use_back) {
if (fb_src == 0 && left > 0 && top > 0) {
// upscale the position
left = left * gfx_current_dimensions.width / gfx_current_native_viewport.width;
top = top * gfx_current_dimensions.height / gfx_current_native_viewport.height;
// flip Y
top = gfx_current_dimensions.height - top - 1;
const bool is_main_fb = (fb_src == 0);
if (is_main_fb) {
if (left > 0 && top > 0) {
// upscale the position
left = left * gfx_current_dimensions.width / gfx_current_native_viewport.width;
top = top * gfx_current_dimensions.height / gfx_current_native_viewport.height;
// flip Y
top = gfx_current_dimensions.height - top - 1;
}
if (use_back && gfx_msaa_level > 1) {
// read from the framebuffer we've been rendering to
fb_src = game_framebuffer;
}
}
gfx_rapi->copy_framebuffer(fb_dst, fb_src, left, top, (bool)use_back);
gfx_rapi->copy_framebuffer(fb_dst, fb_src, left, top, is_main_fb, (bool)use_back);
}
extern "C" void gfx_reset_framebuffer(void) {
+1 -1
View File
@@ -44,7 +44,7 @@ struct GfxRenderingAPI {
bool opengl_invert_y, bool render_target, bool has_depth_buffer,
bool can_extract_depth);
bool (*start_draw_to_framebuffer)(int fb_id, float noise_scale);
void (*copy_framebuffer)(int fb_dst, int fb_src, int left, int top, bool use_back);
void (*copy_framebuffer)(int fb_dst, int fb_src, int left, int top, bool flip_y, bool use_back);
void (*clear_framebuffer)(void);
void (*resolve_msaa_color_buffer)(int fb_id_target, int fb_id_source);
void* (*get_framebuffer_texture_id)(int fb_id);
+1
View File
@@ -28,6 +28,7 @@ void videoSetFramebuffer(s32 target);
void videoResetFramebuffer(void);
void videoCopyFramebuffer(s32 dst, s32 src, s32 left, s32 top);
void videoResizeFramebuffer(s32 target, u32 w, u32 h, s32 upscale, s32 autoresize);
s32 videoFramebuffersSupported(void);
void videoResetTextureCache(void);
void videoFreeCachedTexture(const void *texptr);
+5
View File
@@ -163,6 +163,11 @@ void videoResetFramebuffer(void)
return gfx_reset_framebuffer();
}
s32 videoFramebuffersSupported(void)
{
return gfx_framebuffers_enabled;
}
void videoResizeFramebuffer(s32 target, u32 w, u32 h, s32 upscale, s32 autoresize)
{
gfx_resize_framebuffer(target, w, h, upscale, autoresize);
+18
View File
@@ -284,6 +284,12 @@ Gfx *bviewDrawMotionBlur(Gfx *gdl, u32 colour, u32 alpha)
var8007f844 = 0;
#ifndef PLATFORM_N64
if (!videoFramebuffersSupported()) {
return gdl;
}
#endif
mainOverrideVariable("sfxxx", &sfxxx);
fxxx = sfxxx / 1000.0f;
mainOverrideVariable("sfyyy", &sfyyy);
@@ -510,6 +516,12 @@ Gfx *bviewDrawZoomBlur(Gfx *gdl, u32 colour, s32 alpha, f32 arg3, f32 arg4)
return gdl;
}
#ifndef PLATFORM_N64
if (!videoFramebuffersSupported()) {
return gdl;
}
#endif
strcpy(var800a41c0, "stretchBlurGfx");
gDPPipeSync(gdl++);
@@ -567,15 +579,21 @@ f32 bview0f142d74(s32 arg0, f32 arg1, f32 arg2, f32 arg3)
static inline Gfx *bviewDrawFisheyeLine(Gfx *gdl, s32 viewleft, s32 viewwidth, s32 y, f32 scale)
{
if (!videoFramebuffersSupported()) {
return gdl;
}
const f32 orighalfw = viewwidth * 0.5f;
const f32 xcenter = viewleft + orighalfw;
const f32 halfw = orighalfw * scale;
const s32 left = xcenter - halfw;
const s32 right = xcenter + halfw;
gSPImageRectangleEXT(gdl++,
left << 2, y << 2, viewleft, y,
right << 2, (y + 1) << 2, viewleft + viewwidth, y + 1,
0, videoGetNativeWidth(), videoGetNativeHeight());
return gdl;
}