yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

glasm: Implement forced early Z

This commit is contained in:
ReinUsesLisp 2021-05-21 18:27:37 -03:00 committed by ameerj
parent 6bc54e12a0
commit 84feabac88
2 changed files with 8 additions and 4 deletions

View File

@ -261,7 +261,8 @@ void EmitCode(EmitContext& ctx, const IR::Program& program) {
} }
} }
void SetupOptions(const IR::Program& program, const Profile& profile, std::string& header) { void SetupOptions(const IR::Program& program, const Profile& profile,
const RuntimeInfo& runtime_info, std::string& header) {
const Info& info{program.info}; const Info& info{program.info};
const Stage stage{program.stage}; const Stage stage{program.stage};
@ -296,6 +297,9 @@ void SetupOptions(const IR::Program& program, const Profile& profile, std::strin
header += "OPTION NV_viewport_array2;"; header += "OPTION NV_viewport_array2;";
} }
} }
if (stage == Stage::Fragment && runtime_info.force_early_z != 0) {
header += "OPTION NV_early_fragment_tests;";
}
const auto non_zero_frag_colors{info.stores_frag_color | std::views::drop(1)}; const auto non_zero_frag_colors{info.stores_frag_color | std::views::drop(1)};
if (std::ranges::find(non_zero_frag_colors, true) != non_zero_frag_colors.end()) { if (std::ranges::find(non_zero_frag_colors, true) != non_zero_frag_colors.end()) {
header += "OPTION ARB_draw_buffers;"; header += "OPTION ARB_draw_buffers;";
@ -380,7 +384,7 @@ std::string EmitGLASM(const Profile& profile, const RuntimeInfo& runtime_info, I
Precolor(ctx, program); Precolor(ctx, program);
EmitCode(ctx, program); EmitCode(ctx, program);
std::string header{StageHeader(program.stage)}; std::string header{StageHeader(program.stage)};
SetupOptions(program, profile, header); SetupOptions(program, profile, runtime_info, header);
switch (program.stage) { switch (program.stage) {
case Stage::TessellationControl: case Stage::TessellationControl:
header += fmt::format("VERTICES_OUT {};", program.invocations); header += fmt::format("VERTICES_OUT {};", program.invocations);

View File

@ -219,8 +219,8 @@ Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsProgramKey& key,
return Shader::TessSpacing::Equal; return Shader::TessSpacing::Equal;
}(); }();
break; break;
case Shader::Stage::Geometry: case Shader::Stage::Fragment:
info.force_early_z = key.early_z != 0;
break; break;
default: default:
break; break;