diff options
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_context.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp index 3c84e6466..222baa177 100644 --- a/src/shader_recompiler/backend/spirv/emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/emit_context.cpp | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | #include <climits> | 7 | #include <climits> |
| 8 | #include <string_view> | 8 | #include <string_view> |
| 9 | 9 | ||
| 10 | #include <boost/container/static_vector.hpp> | ||
| 11 | |||
| 10 | #include <fmt/format.h> | 12 | #include <fmt/format.h> |
| 11 | 13 | ||
| 12 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| @@ -496,6 +498,7 @@ EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_inf | |||
| 496 | DefineImages(program.info, image_binding); | 498 | DefineImages(program.info, image_binding); |
| 497 | DefineAttributeMemAccess(program.info); | 499 | DefineAttributeMemAccess(program.info); |
| 498 | DefineGlobalMemoryFunctions(program.info); | 500 | DefineGlobalMemoryFunctions(program.info); |
| 501 | DefineRescalingInput(program.info); | ||
| 499 | } | 502 | } |
| 500 | 503 | ||
| 501 | EmitContext::~EmitContext() = default; | 504 | EmitContext::~EmitContext() = default; |
| @@ -996,6 +999,38 @@ void EmitContext::DefineGlobalMemoryFunctions(const Info& info) { | |||
| 996 | define(&StorageDefinitions::U32x4, storage_types.U32x4, U32[4], sizeof(u32[4])); | 999 | define(&StorageDefinitions::U32x4, storage_types.U32x4, U32[4], sizeof(u32[4])); |
| 997 | } | 1000 | } |
| 998 | 1001 | ||
| 1002 | void EmitContext::DefineRescalingInput(const Info& info) { | ||
| 1003 | if (!info.uses_rescaling_uniform) { | ||
| 1004 | return; | ||
| 1005 | } | ||
| 1006 | boost::container::static_vector<Id, 2> members{F32[1]}; | ||
| 1007 | u32 member_index{0}; | ||
| 1008 | const u32 num_texture_words{Common::DivCeil(runtime_info.num_textures, 32u)}; | ||
| 1009 | if (runtime_info.num_textures > 0) { | ||
| 1010 | rescaling_textures_type = TypeArray(U32[1], Const(num_texture_words)); | ||
| 1011 | Decorate(rescaling_textures_type, spv::Decoration::ArrayStride, 4u); | ||
| 1012 | members.push_back(rescaling_textures_type); | ||
| 1013 | rescaling_textures_member_index = ++member_index; | ||
| 1014 | } | ||
| 1015 | const Id push_constant_struct{TypeStruct(std::span(members.data(), members.size()))}; | ||
| 1016 | Decorate(push_constant_struct, spv::Decoration::Block); | ||
| 1017 | Name(push_constant_struct, "ResolutionInfo"); | ||
| 1018 | MemberDecorate(push_constant_struct, 0u, spv::Decoration::Offset, 0u); | ||
| 1019 | MemberName(push_constant_struct, 0u, "down_factor"); | ||
| 1020 | if (runtime_info.num_textures > 0) { | ||
| 1021 | MemberDecorate(push_constant_struct, rescaling_textures_member_index, | ||
| 1022 | spv::Decoration::Offset, 4u); | ||
| 1023 | MemberName(push_constant_struct, rescaling_textures_member_index, "rescaling_textures"); | ||
| 1024 | } | ||
| 1025 | const Id pointer_type{TypePointer(spv::StorageClass::PushConstant, push_constant_struct)}; | ||
| 1026 | rescaling_push_constants = AddGlobalVariable(pointer_type, spv::StorageClass::PushConstant); | ||
| 1027 | Name(rescaling_push_constants, "rescaling_push_constants"); | ||
| 1028 | |||
| 1029 | if (profile.supported_spirv >= 0x00010400) { | ||
| 1030 | interfaces.push_back(rescaling_push_constants); | ||
| 1031 | } | ||
| 1032 | } | ||
| 1033 | |||
| 999 | void EmitContext::DefineConstantBuffers(const Info& info, u32& binding) { | 1034 | void EmitContext::DefineConstantBuffers(const Info& info, u32& binding) { |
| 1000 | if (info.constant_buffer_descriptors.empty()) { | 1035 | if (info.constant_buffer_descriptors.empty()) { |
| 1001 | return; | 1036 | return; |