Просмотр исходного кода

shader: Implement early Z tests

ReinUsesLisp 5 лет назад
Родитель
Сommit
a83579b50a

+ 3 - 0
src/shader_recompiler/backend/spirv/emit_spirv.cpp

@@ -178,6 +178,9 @@ void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) {
         if (program.info.stores_frag_depth) {
             ctx.AddExecutionMode(main, spv::ExecutionMode::DepthReplacing);
         }
+        if (ctx.profile.force_early_z) {
+            ctx.AddExecutionMode(main, spv::ExecutionMode::EarlyFragmentTests);
+        }
         break;
     default:
         throw NotImplementedException("Stage {}", program.stage);

+ 1 - 0
src/shader_recompiler/profile.h

@@ -53,6 +53,7 @@ struct Profile {
 
     std::array<AttributeType, 32> generic_input_types{};
     bool convert_depth_mode{};
+    bool force_early_z{};
 
     InputTopology input_topology{};
 

+ 1 - 0
src/video_core/renderer_vulkan/vk_pipeline_cache.cpp

@@ -934,6 +934,7 @@ Shader::Profile PipelineCache::MakeProfile(const GraphicsPipelineCacheKey& key,
         profile.input_topology = Shader::InputTopology::TrianglesAdjacency;
         break;
     }
+    profile.force_early_z = key.state.early_z != 0;
     return profile;
 }