diff options
| author | 2020-01-07 14:53:46 -0400 | |
|---|---|---|
| committer | 2020-01-24 16:43:31 -0400 | |
| commit | 3c34678627eeb1b48375cf70ec38b72691fedd1e (patch) | |
| tree | 4a1ceb51da3946c9551e62f2bea6163db361ae48 /src/video_core/renderer_vulkan | |
| parent | GL Backend: Introduce indexed samplers into the GL backend (diff) | |
| download | yuzu-3c34678627eeb1b48375cf70ec38b72691fedd1e.tar.gz yuzu-3c34678627eeb1b48375cf70ec38b72691fedd1e.tar.xz yuzu-3c34678627eeb1b48375cf70ec38b72691fedd1e.zip | |
Shader_IR: Implement Injectable Custom Variables to the IR.
Diffstat (limited to 'src/video_core/renderer_vulkan')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index dd6d2ef03..bf797dad3 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | |||
| @@ -353,6 +353,7 @@ private: | |||
| 353 | DeclareFragment(); | 353 | DeclareFragment(); |
| 354 | DeclareCompute(); | 354 | DeclareCompute(); |
| 355 | DeclareRegisters(); | 355 | DeclareRegisters(); |
| 356 | DeclareCustomVariables(); | ||
| 356 | DeclarePredicates(); | 357 | DeclarePredicates(); |
| 357 | DeclareLocalMemory(); | 358 | DeclareLocalMemory(); |
| 358 | DeclareSharedMemory(); | 359 | DeclareSharedMemory(); |
| @@ -587,6 +588,15 @@ private: | |||
| 587 | } | 588 | } |
| 588 | } | 589 | } |
| 589 | 590 | ||
| 591 | void DeclareCustomVariables() { | ||
| 592 | const u32 cv_num = ir.GetCustomVariablesAmount(); | ||
| 593 | for (u32 i = 0; i < cv_num; ++i) { | ||
| 594 | const Id id = OpVariable(t_prv_float, spv::StorageClass::Private, v_float_zero); | ||
| 595 | Name(id, fmt::format("custom_var_{}", i)); | ||
| 596 | custom_variables.emplace(i, AddGlobalVariable(id)); | ||
| 597 | } | ||
| 598 | } | ||
| 599 | |||
| 590 | void DeclarePredicates() { | 600 | void DeclarePredicates() { |
| 591 | for (const auto pred : ir.GetPredicates()) { | 601 | for (const auto pred : ir.GetPredicates()) { |
| 592 | const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private, v_false); | 602 | const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private, v_false); |
| @@ -974,6 +984,11 @@ private: | |||
| 974 | return {OpLoad(t_float, registers.at(index)), Type::Float}; | 984 | return {OpLoad(t_float, registers.at(index)), Type::Float}; |
| 975 | } | 985 | } |
| 976 | 986 | ||
| 987 | if (const auto cv = std::get_if<CustomVarNode>(&*node)) { | ||
| 988 | const u32 index = cv->GetIndex(); | ||
| 989 | return {OpLoad(t_float, custom_variables.at(index)), Type::Float}; | ||
| 990 | } | ||
| 991 | |||
| 977 | if (const auto immediate = std::get_if<ImmediateNode>(&*node)) { | 992 | if (const auto immediate = std::get_if<ImmediateNode>(&*node)) { |
| 978 | return {Constant(t_uint, immediate->GetValue()), Type::Uint}; | 993 | return {Constant(t_uint, immediate->GetValue()), Type::Uint}; |
| 979 | } | 994 | } |
| @@ -2505,6 +2520,7 @@ private: | |||
| 2505 | Id out_vertex{}; | 2520 | Id out_vertex{}; |
| 2506 | Id in_vertex{}; | 2521 | Id in_vertex{}; |
| 2507 | std::map<u32, Id> registers; | 2522 | std::map<u32, Id> registers; |
| 2523 | std::map<u32, Id> custom_variables; | ||
| 2508 | std::map<Tegra::Shader::Pred, Id> predicates; | 2524 | std::map<Tegra::Shader::Pred, Id> predicates; |
| 2509 | std::map<u32, Id> flow_variables; | 2525 | std::map<u32, Id> flow_variables; |
| 2510 | Id local_memory{}; | 2526 | Id local_memory{}; |