stagedraw: simplify copydepth pass via r_framebuffer_copy

On top of being less code, this is a tiny bit more efficient.
This commit is contained in:
Andrei Alexeyev 2023-04-09 04:02:31 +02:00
parent b50b57803e
commit 00408b62d0
No known key found for this signature in database
GPG key ID: 72D26128040B9690
4 changed files with 1 additions and 30 deletions

View file

@ -1,7 +0,0 @@
#version 330 core
#include "interface/standard.glslh"
void main(void) {
gl_FragDepth = texture(tex, texCoord).r;
}

View file

@ -1 +0,0 @@
objects = copy_depth.frag standardnotex.vert

View file

@ -21,7 +21,6 @@ glsl_files = files(
'calabi-yau-quintic.frag.glsl',
'calabi-yau-quintic.vert.glsl',
'circle_distort.frag.glsl',
'copy_depth.frag.glsl',
'cutscene.frag.glsl',
'envmap_reflect.frag.glsl',
'extra_bg.frag.glsl',

View file

@ -47,7 +47,6 @@ static struct {
struct {
ShaderProgram *fxaa;
ShaderProgram *copy_depth;
} shaders;
PostprocessShader *viewport_pp;
@ -291,7 +290,6 @@ void stage_draw_pre_init(void) {
NULL);
preload_resources(RES_SHADER_PROGRAM, RESF_PERMANENT,
"copy_depth",
"ingame_menu",
"powersurge_effect",
"powersurge_feedback",
@ -341,7 +339,6 @@ void stage_draw_init(void) {
stagedraw.hud_text.shader = res_shader("text_hud");
stagedraw.hud_text.font = res_font("standard");
stagedraw.shaders.fxaa = res_shader("fxaa");
stagedraw.shaders.copy_depth = res_shader("copy_depth");
r_shader_standard();
@ -578,25 +575,8 @@ static bool fxaa_rule(Framebuffer *fb) {
}
static bool copydepth_rule(Framebuffer *fb) {
r_state_push();
r_enable(RCAP_DEPTH_TEST);
r_depth_func(DEPTH_ALWAYS);
r_blend(BLEND_NONE);
r_shader_ptr(stagedraw.shaders.copy_depth);
Framebuffer *target_fb = r_framebuffer_current();
FramebufferAttachment prev_outputs[FRAMEBUFFER_MAX_OUTPUTS];
FramebufferAttachment outputs[FRAMEBUFFER_MAX_OUTPUTS];
for(int i = 0; i < FRAMEBUFFER_MAX_OUTPUTS; ++i) {
outputs[i] = FRAMEBUFFER_ATTACH_NONE;
}
r_framebuffer_get_output_attachments(target_fb, prev_outputs);
r_framebuffer_set_output_attachments(target_fb, outputs);
draw_framebuffer_attachment(fb, VIEWPORT_W, VIEWPORT_H, FRAMEBUFFER_ATTACH_DEPTH);
r_framebuffer_set_output_attachments(target_fb, prev_outputs);
r_state_pop();
r_framebuffer_copy(target_fb, fb, BUFFER_DEPTH);
return false;
}