diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-07-26 03:26:23 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2021-11-16 22:11:28 +0100 |
commit | 656adee630cb1de738ed4dc6cf1cbc35af40f64f (patch) | |
tree | 5c5ec069a136655476180ce03fc24ccd911b3871 /src/shader_recompiler/backend/spirv/emit_context.cpp | |
parent | shader/rescaling_pass: Patch more instructions (diff) | |
download | yuzu-656adee630cb1de738ed4dc6cf1cbc35af40f64f.tar yuzu-656adee630cb1de738ed4dc6cf1cbc35af40f64f.tar.gz yuzu-656adee630cb1de738ed4dc6cf1cbc35af40f64f.tar.bz2 yuzu-656adee630cb1de738ed4dc6cf1cbc35af40f64f.tar.lz yuzu-656adee630cb1de738ed4dc6cf1cbc35af40f64f.tar.xz yuzu-656adee630cb1de738ed4dc6cf1cbc35af40f64f.tar.zst yuzu-656adee630cb1de738ed4dc6cf1cbc35af40f64f.zip |
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 @@ #include <climits> #include <string_view> +#include <boost/container/static_vector.hpp> + #include <fmt/format.h> #include "common/common_types.h" @@ -496,6 +498,7 @@ EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_inf DefineImages(program.info, image_binding); DefineAttributeMemAccess(program.info); DefineGlobalMemoryFunctions(program.info); + DefineRescalingInput(program.info); } EmitContext::~EmitContext() = default; @@ -996,6 +999,38 @@ void EmitContext::DefineGlobalMemoryFunctions(const Info& info) { define(&StorageDefinitions::U32x4, storage_types.U32x4, U32[4], sizeof(u32[4])); } +void EmitContext::DefineRescalingInput(const Info& info) { + if (!info.uses_rescaling_uniform) { + return; + } + boost::container::static_vector<Id, 2> members{F32[1]}; + u32 member_index{0}; + const u32 num_texture_words{Common::DivCeil(runtime_info.num_textures, 32u)}; + if (runtime_info.num_textures > 0) { + rescaling_textures_type = TypeArray(U32[1], Const(num_texture_words)); + Decorate(rescaling_textures_type, spv::Decoration::ArrayStride, 4u); + members.push_back(rescaling_textures_type); + rescaling_textures_member_index = ++member_index; + } + const Id push_constant_struct{TypeStruct(std::span(members.data(), members.size()))}; + Decorate(push_constant_struct, spv::Decoration::Block); + Name(push_constant_struct, "ResolutionInfo"); + MemberDecorate(push_constant_struct, 0u, spv::Decoration::Offset, 0u); + MemberName(push_constant_struct, 0u, "down_factor"); + if (runtime_info.num_textures > 0) { + MemberDecorate(push_constant_struct, rescaling_textures_member_index, + spv::Decoration::Offset, 4u); + MemberName(push_constant_struct, rescaling_textures_member_index, "rescaling_textures"); + } + const Id pointer_type{TypePointer(spv::StorageClass::PushConstant, push_constant_struct)}; + rescaling_push_constants = AddGlobalVariable(pointer_type, spv::StorageClass::PushConstant); + Name(rescaling_push_constants, "rescaling_push_constants"); + + if (profile.supported_spirv >= 0x00010400) { + interfaces.push_back(rescaling_push_constants); + } +} + void EmitContext::DefineConstantBuffers(const Info& info, u32& binding) { if (info.constant_buffer_descriptors.empty()) { return; |