forked from Ports/perfect_dark
Perform a depth only clear right before rendering the gun.
This commit is contained in:
5 files changed
+29
-10
No files matched your search
@@ -1065,12 +1065,23 @@ bool gfx_opengl_start_draw_to_framebuffer(int fb_id, float noise_scale) {
|
||||
}
|
||||
}
|
||||
|
||||
void gfx_opengl_clear_framebuffer() {
|
||||
void gfx_opengl_clear_framebuffer(bool clear_color, bool clear_depth) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDepthMask(current_depth_mask ? GL_TRUE : GL_FALSE);
|
||||
|
||||
GLbitfield mask = 0;
|
||||
if (clear_color) {
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
mask |= GL_COLOR_BUFFER_BIT;
|
||||
}
|
||||
if (clear_depth) {
|
||||
glDepthMask(GL_TRUE);
|
||||
mask |= GL_DEPTH_BUFFER_BIT;
|
||||
}
|
||||
glClear(mask);
|
||||
if (clear_depth) {
|
||||
glDepthMask(current_depth_mask ? GL_TRUE : GL_FALSE);
|
||||
}
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
|
||||
@@ -2502,6 +2502,10 @@ static void gfx_run_dl(Gfx* cmd) {
|
||||
case G_RDPFLUSH_EXT:
|
||||
gfx_flush();
|
||||
break;
|
||||
case G_CLEAR_DEPTH_EXT:
|
||||
gfx_flush();
|
||||
gfx_rapi->clear_framebuffer(false, true);
|
||||
break;
|
||||
case G_RDPPIPESYNC:
|
||||
case G_RDPFULLSYNC:
|
||||
case G_RDPLOADSYNC:
|
||||
@@ -2659,7 +2663,7 @@ extern "C" void gfx_run(Gfx* commands) {
|
||||
gfx_rapi->start_frame();
|
||||
gfx_rapi->start_draw_to_framebuffer(game_renders_to_framebuffer ? game_framebuffer : 0,
|
||||
(float)gfx_current_dimensions.height / SCREEN_HEIGHT);
|
||||
gfx_rapi->clear_framebuffer();
|
||||
gfx_rapi->clear_framebuffer(true, false);
|
||||
rdp.viewport_or_scissor_changed = true;
|
||||
rendering_state.viewport = {};
|
||||
rendering_state.scissor = {};
|
||||
@@ -2669,7 +2673,7 @@ extern "C" void gfx_run(Gfx* commands) {
|
||||
|
||||
if (game_renders_to_framebuffer) {
|
||||
gfx_rapi->start_draw_to_framebuffer(0, 1);
|
||||
gfx_rapi->clear_framebuffer();
|
||||
gfx_rapi->clear_framebuffer(true, true);
|
||||
|
||||
if (gfx_msaa_level > 1) {
|
||||
bool different_size = gfx_current_dimensions.width != gfx_current_game_window_viewport.width ||
|
||||
@@ -2732,7 +2736,7 @@ extern "C" void gfx_resize_framebuffer(int fb, uint32_t width, uint32_t height,
|
||||
|
||||
extern "C" void gfx_set_framebuffer(int fb, float noise_scale) {
|
||||
gfx_rapi->start_draw_to_framebuffer(fb, noise_scale);
|
||||
gfx_rapi->clear_framebuffer();
|
||||
gfx_rapi->clear_framebuffer(true, true);
|
||||
}
|
||||
|
||||
extern "C" void gfx_copy_framebuffer(int fb_dst, int fb_src, int left, int top, int use_back) {
|
||||
|
||||
@@ -44,7 +44,7 @@ struct GfxRenderingAPI {
|
||||
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 flip_y, bool use_back);
|
||||
void (*clear_framebuffer)(void);
|
||||
void (*clear_framebuffer)(bool clear_color, bool clear_depth);
|
||||
void (*resolve_msaa_color_buffer)(int fb_id_target, int fb_id_source);
|
||||
void* (*get_framebuffer_texture_id)(int fb_id);
|
||||
void (*select_texture_fb)(int fb_id);
|
||||
|
||||
+2
-1
@@ -126,7 +126,6 @@ Gfx *zbufConfigureRdp(Gfx *gdl)
|
||||
Gfx *zbufClear(Gfx *gdl)
|
||||
{
|
||||
#ifdef PLATFORM_N64
|
||||
// no reason to do a Z clear on PC, we already do it at frame start
|
||||
s32 left;
|
||||
s32 right;
|
||||
|
||||
@@ -150,6 +149,8 @@ Gfx *zbufClear(Gfx *gdl)
|
||||
|
||||
gDPFillRectangle(gdl++, left, 0, right, playerGetFbHeight() - 1);
|
||||
gDPPipeSync(gdl++);
|
||||
#else
|
||||
gDPClearDepthEXT(gdl++);
|
||||
#endif
|
||||
|
||||
return gdl;
|
||||
|
||||
@@ -195,6 +195,7 @@
|
||||
#define G_COPYFB_EXT 0x41
|
||||
#define G_IMAGERECT_EXT 0x42
|
||||
#define G_RDPFLUSH_EXT 0x43
|
||||
#define G_CLEAR_DEPTH_EXT 0x44
|
||||
|
||||
/* G_EXTRAGEOMETRYMODE flags */
|
||||
|
||||
@@ -300,6 +301,8 @@
|
||||
|
||||
#define gDPFlushEXT(pkt) gDPNoParam(pkt, G_RDPFLUSH_EXT)
|
||||
|
||||
#define gDPClearDepthEXT(pkt) gDPNoParam(pkt, G_CLEAR_DEPTH_EXT)
|
||||
|
||||
#undef gDPFillRectangleScaled
|
||||
#define gDPFillRectangleScaled(pkt, x1, y1, x2, y2) gDPFillRectangleEXT(pkt, (x1) * g_ScaleX, y1, (x2) * g_ScaleX, y2)
|
||||
|
||||
|
||||
Reference in new issue
Block a user