summaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/CMakeLists.txt1
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate_program.cpp8
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate_program.h3
-rw-r--r--src/shader_recompiler/host_translate_info.h18
4 files changed, 26 insertions, 4 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt
index f801a9f72..164e94071 100644
--- a/src/shader_recompiler/CMakeLists.txt
+++ b/src/shader_recompiler/CMakeLists.txt
@@ -211,6 +211,7 @@ add_library(shader_recompiler STATIC
211 frontend/maxwell/translate/translate.h 211 frontend/maxwell/translate/translate.h
212 frontend/maxwell/translate_program.cpp 212 frontend/maxwell/translate_program.cpp
213 frontend/maxwell/translate_program.h 213 frontend/maxwell/translate_program.h
214 host_translate_info.h
214 ir_opt/collect_shader_info_pass.cpp 215 ir_opt/collect_shader_info_pass.cpp
215 ir_opt/constant_propagation_pass.cpp 216 ir_opt/constant_propagation_pass.cpp
216 ir_opt/dead_code_elimination_pass.cpp 217 ir_opt/dead_code_elimination_pass.cpp
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
index e52170e3e..5250509c1 100644
--- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp
@@ -13,6 +13,7 @@
13#include "shader_recompiler/frontend/maxwell/structured_control_flow.h" 13#include "shader_recompiler/frontend/maxwell/structured_control_flow.h"
14#include "shader_recompiler/frontend/maxwell/translate/translate.h" 14#include "shader_recompiler/frontend/maxwell/translate/translate.h"
15#include "shader_recompiler/frontend/maxwell/translate_program.h" 15#include "shader_recompiler/frontend/maxwell/translate_program.h"
16#include "shader_recompiler/host_translate_info.h"
16#include "shader_recompiler/ir_opt/passes.h" 17#include "shader_recompiler/ir_opt/passes.h"
17 18
18namespace Shader::Maxwell { 19namespace Shader::Maxwell {
@@ -120,7 +121,7 @@ void AddNVNStorageBuffers(IR::Program& program) {
120} // Anonymous namespace 121} // Anonymous namespace
121 122
122IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool, 123IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Block>& block_pool,
123 Environment& env, Flow::CFG& cfg) { 124 Environment& env, Flow::CFG& cfg, const HostTranslateInfo& host_info) {
124 IR::Program program; 125 IR::Program program;
125 program.syntax_list = BuildASL(inst_pool, block_pool, env, cfg); 126 program.syntax_list = BuildASL(inst_pool, block_pool, env, cfg);
126 program.blocks = GenerateBlocks(program.syntax_list); 127 program.blocks = GenerateBlocks(program.syntax_list);
@@ -150,8 +151,9 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo
150 RemoveUnreachableBlocks(program); 151 RemoveUnreachableBlocks(program);
151 152
152 // Replace instructions before the SSA rewrite 153 // Replace instructions before the SSA rewrite
153 Optimization::LowerFp16ToFp32(program); 154 if (!host_info.support_float16) {
154 155 Optimization::LowerFp16ToFp32(program);
156 }
155 Optimization::SsaRewritePass(program); 157 Optimization::SsaRewritePass(program);
156 158
157 Optimization::GlobalMemoryToStorageBufferPass(program); 159 Optimization::GlobalMemoryToStorageBufferPass(program);
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.h b/src/shader_recompiler/frontend/maxwell/translate_program.h
index 1e5536443..a84814811 100644
--- a/src/shader_recompiler/frontend/maxwell/translate_program.h
+++ b/src/shader_recompiler/frontend/maxwell/translate_program.h
@@ -8,13 +8,14 @@
8#include "shader_recompiler/frontend/ir/basic_block.h" 8#include "shader_recompiler/frontend/ir/basic_block.h"
9#include "shader_recompiler/frontend/ir/program.h" 9#include "shader_recompiler/frontend/ir/program.h"
10#include "shader_recompiler/frontend/maxwell/control_flow.h" 10#include "shader_recompiler/frontend/maxwell/control_flow.h"
11#include "shader_recompiler/host_translate_info.h"
11#include "shader_recompiler/object_pool.h" 12#include "shader_recompiler/object_pool.h"
12 13
13namespace Shader::Maxwell { 14namespace Shader::Maxwell {
14 15
15[[nodiscard]] IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, 16[[nodiscard]] IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool,
16 ObjectPool<IR::Block>& block_pool, Environment& env, 17 ObjectPool<IR::Block>& block_pool, Environment& env,
17 Flow::CFG& cfg); 18 Flow::CFG& cfg, const HostTranslateInfo& host_info);
18 19
19[[nodiscard]] IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b, 20[[nodiscard]] IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b,
20 Environment& env_vertex_b); 21 Environment& env_vertex_b);
diff --git a/src/shader_recompiler/host_translate_info.h b/src/shader_recompiler/host_translate_info.h
new file mode 100644
index 000000000..94a584219
--- /dev/null
+++ b/src/shader_recompiler/host_translate_info.h
@@ -0,0 +1,18 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7namespace Shader {
8
9// Try to keep entries here to a minimum
10// They can accidentally change the cached information in a shader
11
12/// Misc information about the host
13struct HostTranslateInfo {
14 bool support_float16{}; ///< True when the device supports 16-bit floats
15 bool support_int64{}; ///< True when the device supports 64-bit integers
16};
17
18} // namespace Shader