structured_control_flow: Conditionally invoke demote reorder pass
This is only needed on select drivers when a fragment shader discards/demotes.
This commit is contained in:
parent
862dc2b2b3
commit
4fda7f1c82
7 changed files with 23 additions and 10 deletions
|
@ -20,6 +20,7 @@
|
||||||
#include "shader_recompiler/frontend/maxwell/decode.h"
|
#include "shader_recompiler/frontend/maxwell/decode.h"
|
||||||
#include "shader_recompiler/frontend/maxwell/structured_control_flow.h"
|
#include "shader_recompiler/frontend/maxwell/structured_control_flow.h"
|
||||||
#include "shader_recompiler/frontend/maxwell/translate/translate.h"
|
#include "shader_recompiler/frontend/maxwell/translate/translate.h"
|
||||||
|
#include "shader_recompiler/host_translate_info.h"
|
||||||
#include "shader_recompiler/object_pool.h"
|
#include "shader_recompiler/object_pool.h"
|
||||||
|
|
||||||
namespace Shader::Maxwell {
|
namespace Shader::Maxwell {
|
||||||
|
@ -652,7 +653,7 @@ class TranslatePass {
|
||||||
public:
|
public:
|
||||||
TranslatePass(ObjectPool<IR::Inst>& inst_pool_, ObjectPool<IR::Block>& block_pool_,
|
TranslatePass(ObjectPool<IR::Inst>& inst_pool_, ObjectPool<IR::Block>& block_pool_,
|
||||||
ObjectPool<Statement>& stmt_pool_, Environment& env_, Statement& root_stmt,
|
ObjectPool<Statement>& stmt_pool_, Environment& env_, Statement& root_stmt,
|
||||||
IR::AbstractSyntaxList& syntax_list_)
|
IR::AbstractSyntaxList& syntax_list_, const HostTranslateInfo& host_info)
|
||||||
: stmt_pool{stmt_pool_}, inst_pool{inst_pool_}, block_pool{block_pool_}, env{env_},
|
: stmt_pool{stmt_pool_}, inst_pool{inst_pool_}, block_pool{block_pool_}, env{env_},
|
||||||
syntax_list{syntax_list_} {
|
syntax_list{syntax_list_} {
|
||||||
Visit(root_stmt, nullptr, nullptr);
|
Visit(root_stmt, nullptr, nullptr);
|
||||||
|
@ -660,7 +661,7 @@ public:
|
||||||
IR::Block& first_block{*syntax_list.front().data.block};
|
IR::Block& first_block{*syntax_list.front().data.block};
|
||||||
IR::IREmitter ir(first_block, first_block.begin());
|
IR::IREmitter ir(first_block, first_block.begin());
|
||||||
ir.Prologue();
|
ir.Prologue();
|
||||||
if (uses_demote_to_helper) {
|
if (uses_demote_to_helper && host_info.needs_demote_reorder) {
|
||||||
DemoteCombinationPass();
|
DemoteCombinationPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -977,12 +978,13 @@ private:
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
IR::AbstractSyntaxList BuildASL(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool,
|
IR::AbstractSyntaxList BuildASL(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool,
|
||||||
Environment& env, Flow::CFG& cfg) {
|
Environment& env, Flow::CFG& cfg,
|
||||||
|
const HostTranslateInfo& host_info) {
|
||||||
ObjectPool<Statement> stmt_pool{64};
|
ObjectPool<Statement> stmt_pool{64};
|
||||||
GotoPass goto_pass{cfg, stmt_pool};
|
GotoPass goto_pass{cfg, stmt_pool};
|
||||||
Statement& root{goto_pass.RootStatement()};
|
Statement& root{goto_pass.RootStatement()};
|
||||||
IR::AbstractSyntaxList syntax_list;
|
IR::AbstractSyntaxList syntax_list;
|
||||||
TranslatePass{inst_pool, block_pool, stmt_pool, env, root, syntax_list};
|
TranslatePass{inst_pool, block_pool, stmt_pool, env, root, syntax_list, host_info};
|
||||||
return syntax_list;
|
return syntax_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,13 @@
|
||||||
#include "shader_recompiler/frontend/maxwell/control_flow.h"
|
#include "shader_recompiler/frontend/maxwell/control_flow.h"
|
||||||
#include "shader_recompiler/object_pool.h"
|
#include "shader_recompiler/object_pool.h"
|
||||||
|
|
||||||
namespace Shader::Maxwell {
|
namespace Shader {
|
||||||
|
struct HostTranslateInfo;
|
||||||
|
namespace Maxwell {
|
||||||
|
|
||||||
[[nodiscard]] IR::AbstractSyntaxList BuildASL(ObjectPool<IR::Inst>& inst_pool,
|
[[nodiscard]] IR::AbstractSyntaxList BuildASL(ObjectPool<IR::Inst>& inst_pool,
|
||||||
ObjectPool<IR::Block>& block_pool, Environment& env,
|
ObjectPool<IR::Block>& block_pool, Environment& env,
|
||||||
Flow::CFG& cfg);
|
Flow::CFG& cfg, const HostTranslateInfo& host_info);
|
||||||
|
|
||||||
} // namespace Shader::Maxwell
|
} // namespace Maxwell
|
||||||
|
} // namespace Shader
|
||||||
|
|
|
@ -130,7 +130,7 @@ void AddNVNStorageBuffers(IR::Program& program) {
|
||||||
IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool,
|
IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool,
|
||||||
Environment& env, Flow::CFG& cfg, const HostTranslateInfo& host_info) {
|
Environment& env, Flow::CFG& cfg, const HostTranslateInfo& host_info) {
|
||||||
IR::Program program;
|
IR::Program program;
|
||||||
program.syntax_list = BuildASL(inst_pool, block_pool, env, cfg);
|
program.syntax_list = BuildASL(inst_pool, block_pool, env, cfg, host_info);
|
||||||
program.blocks = GenerateBlocks(program.syntax_list);
|
program.blocks = GenerateBlocks(program.syntax_list);
|
||||||
program.post_order_blocks = PostOrder(program.syntax_list.front());
|
program.post_order_blocks = PostOrder(program.syntax_list.front());
|
||||||
program.stage = env.ShaderStage();
|
program.stage = env.ShaderStage();
|
||||||
|
|
|
@ -11,8 +11,9 @@ namespace Shader {
|
||||||
|
|
||||||
/// Misc information about the host
|
/// Misc information about the host
|
||||||
struct HostTranslateInfo {
|
struct HostTranslateInfo {
|
||||||
bool support_float16{}; ///< True when the device supports 16-bit floats
|
bool support_float16{}; ///< True when the device supports 16-bit floats
|
||||||
bool support_int64{}; ///< True when the device supports 64-bit integers
|
bool support_int64{}; ///< True when the device supports 64-bit integers
|
||||||
|
bool needs_demote_reorder{}; ///< True when the device needs DemoteToHelperInvocation reordered
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Shader
|
} // namespace Shader
|
||||||
|
|
|
@ -156,6 +156,10 @@ public:
|
||||||
return shader_backend;
|
return shader_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsAmd() const {
|
||||||
|
return vendor_name == "ATI Technologies Inc.";
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool TestVariableAoffi();
|
static bool TestVariableAoffi();
|
||||||
static bool TestPreciseBug();
|
static bool TestPreciseBug();
|
||||||
|
|
|
@ -219,6 +219,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
|
||||||
host_info{
|
host_info{
|
||||||
.support_float16 = false,
|
.support_float16 = false,
|
||||||
.support_int64 = device.HasShaderInt64(),
|
.support_int64 = device.HasShaderInt64(),
|
||||||
|
.needs_demote_reorder = device.IsAmd(),
|
||||||
} {
|
} {
|
||||||
if (use_asynchronous_shaders) {
|
if (use_asynchronous_shaders) {
|
||||||
workers = CreateWorkers();
|
workers = CreateWorkers();
|
||||||
|
|
|
@ -325,6 +325,8 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, Tegra::Engines::Maxw
|
||||||
host_info = Shader::HostTranslateInfo{
|
host_info = Shader::HostTranslateInfo{
|
||||||
.support_float16 = device.IsFloat16Supported(),
|
.support_float16 = device.IsFloat16Supported(),
|
||||||
.support_int64 = device.IsShaderInt64Supported(),
|
.support_int64 = device.IsShaderInt64Supported(),
|
||||||
|
.needs_demote_reorder = driver_id == VK_DRIVER_ID_AMD_PROPRIETARY_KHR ||
|
||||||
|
driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue