GPUShaderCreateInfo: Add explicit early_fragment_test
This commit is contained in:
@@ -62,6 +62,10 @@ void ShaderCreateInfo::finalize()
|
||||
pass_resources_.extend(info.pass_resources_);
|
||||
typedef_sources_.extend_non_duplicates(info.typedef_sources_);
|
||||
|
||||
if (info.early_fragment_test_) {
|
||||
early_fragment_test_ = true;
|
||||
}
|
||||
|
||||
validate(info);
|
||||
|
||||
auto assert_no_overlap = [&](const bool test, const StringRefNull error) {
|
||||
|
||||
@@ -271,6 +271,8 @@ struct ShaderCreateInfo {
|
||||
bool finalized_ = false;
|
||||
/** If true, all resources will have an automatic location assigned. */
|
||||
bool auto_resource_location_ = false;
|
||||
/** If true, force depth and stencil tests to always happen before fragment shader invocation. */
|
||||
bool early_fragment_test_ = false;
|
||||
/**
|
||||
* Maximum length of all the resource names including each null terminator.
|
||||
* Only for names used by gpu::ShaderInterface.
|
||||
@@ -521,6 +523,16 @@ struct ShaderCreateInfo {
|
||||
return *(Self *)this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force fragment tests before fragment shader invocation.
|
||||
* IMPORTANT: This is incompatible with using the gl_FragDepth output.
|
||||
*/
|
||||
Self &early_fragment_test(bool enable)
|
||||
{
|
||||
early_fragment_test_ = enable;
|
||||
return *(Self *)this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only needed if geometry shader is enabled.
|
||||
* IMPORTANT: Input and output instance name will have respectively "_in" and "_out" suffix
|
||||
|
||||
@@ -576,6 +576,9 @@ std::string GLShader::fragment_interface_declare(const ShaderCreateInfo &info) c
|
||||
pre_main += " gpu_BaryCoordNoPersp = stable_bary_(gl_BaryCoordNoPerspAMD);\n";
|
||||
}
|
||||
}
|
||||
if (info.early_fragment_test_) {
|
||||
ss << "layout(early_fragment_tests) in;\n";
|
||||
}
|
||||
ss << "\n/* Outputs. */\n";
|
||||
for (const ShaderCreateInfo::FragOut &output : info.fragment_outputs_) {
|
||||
ss << "layout(location = " << output.index;
|
||||
|
||||
Reference in New Issue
Block a user