From e28fd3d0a533695242d17350dd929ad3bb56c429 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 17:05:23 -0400 Subject: Implement Bindless Samplers and TEX_B in the IR. --- src/video_core/shader/decode/texture.cpp | 58 ++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 6 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index a775b402b..23f2ad999 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -57,6 +57,23 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { GetTexCode(instr, texture_type, process_mode, depth_compare, is_array, is_aoffi)); break; } + case OpCode::Id::TEX_B: { + UNIMPLEMENTED_IF_MSG(instr.tex.UsesMiscMode(TextureMiscMode::AOFFI), + "AOFFI is not implemented"); + + if (instr.tex.UsesMiscMode(TextureMiscMode::NODEP)) { + LOG_WARNING(HW_GPU, "TEX.NODEP implementation is incomplete"); + } + + const TextureType texture_type{instr.tex.texture_type}; + const bool is_array = instr.tex.array != 0; + const bool depth_compare = instr.tex.UsesMiscMode(TextureMiscMode::DC); + const auto process_mode = instr.tex.GetTextureProcessMode(); + WriteTexInstructionFloat(bb, instr, + GetTexCode(instr, texture_type, process_mode, depth_compare, + is_array, true, instr.gpr20)); + break; + } case OpCode::Id::TEXS: { const TextureType texture_type{instr.texs.GetTextureType()}; const bool is_array{instr.texs.IsArrayTexture()}; @@ -250,10 +267,36 @@ const Sampler& ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, Textu // Otherwise create a new mapping for this sampler const std::size_t next_index = used_samplers.size(); - const Sampler entry{offset, next_index, type, is_array, is_shadow}; + const Sampler entry{offset, next_index, type, is_array, is_shadow, false}; return *used_samplers.emplace(entry).first; } +const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, + TextureType type, bool is_array, bool is_shadow) { + + const Node sampler_register = GetRegister(reg); + const Node base_sampler = TrackCbuf(sampler_register, global_code, static_cast(global_code.size())); + const auto cbuf = std::get_if(base_sampler); + const auto cbuf_offset_imm = std::get_if(cbuf->GetOffset()); + ASSERT(cbuf_offset_imm != nullptr); + const auto cbuf_offset = cbuf_offset_imm->GetValue(); + const auto cbuf_index = cbuf->GetIndex(); + const std::pair cbuf_pair = {cbuf_index, cbuf_offset}; + + // If this sampler has already been used, return the existing mapping. + if (used_bindless_samplers.count(cbuf_pair) > 0) { + const auto& sampler = used_bindless_samplers[cbuf_pair]; + ASSERT(sampler.GetType() == type && sampler.IsArray() == is_array && + sampler.IsShadow() == is_shadow); + return sampler; + } + + // Otherwise create a new mapping for this sampler + const std::size_t next_index = used_bindless_samplers.size(); + const Sampler entry{0, next_index, type, is_array, is_shadow, true}; + return (*used_bindless_samplers.emplace(std::make_pair(cbuf_pair, entry)).first).second; +} + void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { u32 dest_elem = 0; for (u32 elem = 0; elem < 4; ++elem) { @@ -325,8 +368,8 @@ void ShaderIR::WriteTexsInstructionHalfFloat(NodeBlock& bb, Instruction instr, Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, TextureProcessMode process_mode, std::vector coords, - Node array, Node depth_compare, u32 bias_offset, - std::vector aoffi) { + Node array, Node depth_compare, u32 bias_offset, std::vector aoffi, bool is_bindless, + Register bindless_reg) { const bool is_array = array; const bool is_shadow = depth_compare; @@ -334,7 +377,9 @@ Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, (texture_type == TextureType::TextureCube && is_array && is_shadow), "This method is not supported."); - const auto& sampler = GetSampler(instr.sampler, texture_type, is_array, is_shadow); + const auto& sampler = !is_bindless + ? GetSampler(instr.sampler, texture_type, is_array, is_shadow) + : GetBindlessSampler(bindless_reg, texture_type, is_array, is_shadow); const bool lod_needed = process_mode == TextureProcessMode::LZ || process_mode == TextureProcessMode::LL || @@ -384,7 +429,7 @@ Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, TextureProcessMode process_mode, bool depth_compare, bool is_array, - bool is_aoffi) { + bool is_aoffi, bool is_bindless, Register bindless_reg) { const bool lod_bias_enabled{ (process_mode != TextureProcessMode::None && process_mode != TextureProcessMode::LZ)}; @@ -423,7 +468,8 @@ Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, dc = GetRegister(parameter_register++); } - return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, 0, aoffi); + return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, 0, aoffi, is_bindless, + bindless_reg); } Node4 ShaderIR::GetTexsCode(Instruction instr, TextureType texture_type, -- cgit v1.2.3 From fe392fff2425c10c9683a4058c779d352b9855ec Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 17:56:16 -0400 Subject: Unify both sampler types. --- src/video_core/shader/decode/texture.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 23f2ad999..3ac04f6b7 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -267,7 +267,7 @@ const Sampler& ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, Textu // Otherwise create a new mapping for this sampler const std::size_t next_index = used_samplers.size(); - const Sampler entry{offset, next_index, type, is_array, is_shadow, false}; + const Sampler entry{offset, next_index, type, is_array, is_shadow}; return *used_samplers.emplace(entry).first; } @@ -281,20 +281,22 @@ const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, ASSERT(cbuf_offset_imm != nullptr); const auto cbuf_offset = cbuf_offset_imm->GetValue(); const auto cbuf_index = cbuf->GetIndex(); - const std::pair cbuf_pair = {cbuf_index, cbuf_offset}; + const u64 cbuf_key = (cbuf_index << 32) | cbuf_offset; // If this sampler has already been used, return the existing mapping. - if (used_bindless_samplers.count(cbuf_pair) > 0) { - const auto& sampler = used_bindless_samplers[cbuf_pair]; - ASSERT(sampler.GetType() == type && sampler.IsArray() == is_array && - sampler.IsShadow() == is_shadow); - return sampler; + const auto itr = + std::find_if(used_samplers.begin(), used_samplers.end(), + [&](const Sampler& entry) { return entry.GetOffset() == cbuf_key; }); + if (itr != used_samplers.end()) { + ASSERT(itr->GetType() == type && itr->IsArray() == is_array && + itr->IsShadow() == is_shadow); + return *itr; } // Otherwise create a new mapping for this sampler - const std::size_t next_index = used_bindless_samplers.size(); - const Sampler entry{0, next_index, type, is_array, is_shadow, true}; - return (*used_bindless_samplers.emplace(std::make_pair(cbuf_pair, entry)).first).second; + const std::size_t next_index = used_samplers.size(); + const Sampler entry{cbuf_index, cbuf_offset, next_index, type, is_array, is_shadow}; + return *used_samplers.emplace(entry).first; } void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { -- cgit v1.2.3 From ac3ba9a33e0d1e14061fc0f341b69cb85ea2e6a6 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 19:02:24 -0400 Subject: Corrections to TEX_B --- src/video_core/shader/decode/texture.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 3ac04f6b7..300f1abad 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -65,10 +65,10 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { LOG_WARNING(HW_GPU, "TEX.NODEP implementation is incomplete"); } - const TextureType texture_type{instr.tex.texture_type}; - const bool is_array = instr.tex.array != 0; - const bool depth_compare = instr.tex.UsesMiscMode(TextureMiscMode::DC); - const auto process_mode = instr.tex.GetTextureProcessMode(); + const TextureType texture_type{instr.tex_b.texture_type}; + const bool is_array = instr.tex_b.array != 0; + const bool depth_compare = instr.tex_b.UsesMiscMode(TextureMiscMode::DC); + const auto process_mode = instr.tex_b.GetTextureProcessMode(); WriteTexInstructionFloat(bb, instr, GetTexCode(instr, texture_type, process_mode, depth_compare, is_array, true, instr.gpr20)); @@ -462,6 +462,7 @@ Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, if (is_aoffi) { aoffi = GetAoffiCoordinates(GetRegister(parameter_register++), coord_count, false); } + const u32 bindless_offset = (is_bindless ? 1 : 0); Node dc{}; if (depth_compare) { -- cgit v1.2.3 From 189bd1980cc405d512eb8b19307df76976344e6e Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 19:13:53 -0400 Subject: Implement TMML_B --- src/video_core/shader/decode/texture.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 300f1abad..ddb7755b8 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -40,7 +40,7 @@ static std::size_t GetCoordCount(TextureType texture_type) { u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { const Instruction instr = {program_code[pc]}; const auto opcode = OpCode::Decode(instr); - + bool is_bindless = false; switch (opcode->get().GetId()) { case OpCode::Id::TEX: { if (instr.tex.UsesMiscMode(TextureMiscMode::NODEP)) { @@ -185,6 +185,8 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { } break; } + case OpCode::Id::TMML_B: + is_bindless = true; case OpCode::Id::TMML: { UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV), "NDV is not implemented"); @@ -195,7 +197,9 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { auto texture_type = instr.tmml.texture_type.Value(); const bool is_array = instr.tmml.array != 0; - const auto& sampler = GetSampler(instr.sampler, texture_type, is_array, false); + const auto& sampler = !is_bindless + ? GetSampler(instr.sampler, texture_type, is_array, false) + : GetBindlessSampler(instr.gpr20, texture_type, is_array, false); std::vector coords; @@ -271,11 +275,12 @@ const Sampler& ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, Textu return *used_samplers.emplace(entry).first; } -const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, - TextureType type, bool is_array, bool is_shadow) { +const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, TextureType type, + bool is_array, bool is_shadow) { const Node sampler_register = GetRegister(reg); - const Node base_sampler = TrackCbuf(sampler_register, global_code, static_cast(global_code.size())); + const Node base_sampler = + TrackCbuf(sampler_register, global_code, static_cast(global_code.size())); const auto cbuf = std::get_if(base_sampler); const auto cbuf_offset_imm = std::get_if(cbuf->GetOffset()); ASSERT(cbuf_offset_imm != nullptr); -- cgit v1.2.3 From 4841440382c72047d68bb2c0ce7a7defadab7d3d Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 19:46:11 -0400 Subject: Implement TXQ_B --- src/video_core/shader/decode/texture.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index ddb7755b8..3eac75bef 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -151,6 +151,8 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { WriteTexsInstructionFloat(bb, instr, values); break; } + case OpCode::Id::TXQ_B: + is_bindless = true; case OpCode::Id::TXQ: { if (instr.txq.UsesMiscMode(TextureMiscMode::NODEP)) { LOG_WARNING(HW_GPU, "TXQ.NODEP implementation is incomplete"); @@ -160,7 +162,10 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { // Sadly, not all texture instructions specify the type of texture their sampler // uses. This must be fixed at a later instance. const auto& sampler = - GetSampler(instr.sampler, Tegra::Shader::TextureType::Texture2D, false, false); + !is_bindless + ? GetSampler(instr.sampler, Tegra::Shader::TextureType::Texture2D, false, false) + : GetBindlessSampler(instr.gpr8, Tegra::Shader::TextureType::Texture2D, false, + false); u32 indexer = 0; switch (instr.txq.query_type) { @@ -171,7 +176,8 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { } MetaTexture meta{sampler, {}, {}, {}, {}, {}, {}, element}; const Node value = - Operation(OperationCode::TextureQueryDimensions, meta, GetRegister(instr.gpr8)); + Operation(OperationCode::TextureQueryDimensions, meta, + GetRegister(instr.gpr8.Value() + (is_bindless ? 1 : 0))); SetTemporal(bb, indexer++, value); } for (u32 i = 0; i < indexer; ++i) { -- cgit v1.2.3 From fd4e994de3196dfdd2a3f2caf4ca8934e719c296 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 27 Mar 2019 07:11:50 -0400 Subject: Refactor GetTextureCode and GetTexCode to use an optional instead of optional parameters --- src/video_core/shader/decode/texture.cpp | 47 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 3eac75bef..5d670b24e 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -54,7 +54,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { const auto process_mode = instr.tex.GetTextureProcessMode(); WriteTexInstructionFloat( bb, instr, - GetTexCode(instr, texture_type, process_mode, depth_compare, is_array, is_aoffi)); + GetTexCode(instr, texture_type, process_mode, depth_compare, is_array, is_aoffi, {})); break; } case OpCode::Id::TEX_B: { @@ -69,9 +69,9 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { const bool is_array = instr.tex_b.array != 0; const bool depth_compare = instr.tex_b.UsesMiscMode(TextureMiscMode::DC); const auto process_mode = instr.tex_b.GetTextureProcessMode(); - WriteTexInstructionFloat(bb, instr, - GetTexCode(instr, texture_type, process_mode, depth_compare, - is_array, true, instr.gpr20)); + WriteTexInstructionFloat( + bb, instr, + GetTexCode(instr, texture_type, process_mode, depth_compare, is_array, {instr.gpr20})); break; } case OpCode::Id::TEXS: { @@ -162,10 +162,10 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { // Sadly, not all texture instructions specify the type of texture their sampler // uses. This must be fixed at a later instance. const auto& sampler = - !is_bindless - ? GetSampler(instr.sampler, Tegra::Shader::TextureType::Texture2D, false, false) - : GetBindlessSampler(instr.gpr8, Tegra::Shader::TextureType::Texture2D, false, - false); + is_bindless + ? GetBindlessSampler(instr.gpr8, Tegra::Shader::TextureType::Texture2D, false, + false) + : GetSampler(instr.sampler, Tegra::Shader::TextureType::Texture2D, false, false); u32 indexer = 0; switch (instr.txq.query_type) { @@ -203,9 +203,9 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { auto texture_type = instr.tmml.texture_type.Value(); const bool is_array = instr.tmml.array != 0; - const auto& sampler = !is_bindless - ? GetSampler(instr.sampler, texture_type, is_array, false) - : GetBindlessSampler(instr.gpr20, texture_type, is_array, false); + const auto& sampler = is_bindless + ? GetBindlessSampler(instr.gpr20, texture_type, is_array, false) + : GetSampler(instr.sampler, texture_type, is_array, false); std::vector coords; @@ -381,25 +381,26 @@ void ShaderIR::WriteTexsInstructionHalfFloat(NodeBlock& bb, Instruction instr, Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, TextureProcessMode process_mode, std::vector coords, - Node array, Node depth_compare, u32 bias_offset, std::vector aoffi, bool is_bindless, - Register bindless_reg) { + Node array, Node depth_compare, u32 bias_offset, std::vector aoffi, std::optional bindless_reg) { const bool is_array = array; const bool is_shadow = depth_compare; + const bool is_bindless = bindless_reg.has_value(); UNIMPLEMENTED_IF_MSG((texture_type == TextureType::Texture3D && (is_array || is_shadow)) || (texture_type == TextureType::TextureCube && is_array && is_shadow), "This method is not supported."); - const auto& sampler = !is_bindless - ? GetSampler(instr.sampler, texture_type, is_array, is_shadow) - : GetBindlessSampler(bindless_reg, texture_type, is_array, is_shadow); + const auto& sampler = is_bindless + ? GetBindlessSampler(*bindless_reg, texture_type, is_array, is_shadow) + : GetSampler(instr.sampler, texture_type, is_array, is_shadow); const bool lod_needed = process_mode == TextureProcessMode::LZ || process_mode == TextureProcessMode::LL || process_mode == TextureProcessMode::LLA; - // LOD selection (either via bias or explicit textureLod) not supported in GL for - // sampler2DArrayShadow and samplerCubeArrayShadow. + // LOD selection (either via bias or explicit textureLod) not + // supported in GL for sampler2DArrayShadow and + // samplerCubeArrayShadow. const bool gl_lod_supported = !((texture_type == Tegra::Shader::TextureType::Texture2D && is_array && is_shadow) || (texture_type == Tegra::Shader::TextureType::TextureCube && is_array && is_shadow)); @@ -417,8 +418,9 @@ Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, lod = Immediate(0.0f); break; case TextureProcessMode::LB: - // If present, lod or bias are always stored in the register indexed by the gpr20 - // field with an offset depending on the usage of the other registers + // If present, lod or bias are always stored in the register + // indexed by the gpr20 field with an offset depending on the + // usage of the other registers bias = GetRegister(instr.gpr20.Value() + bias_offset); break; case TextureProcessMode::LL: @@ -442,7 +444,7 @@ Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, TextureProcessMode process_mode, bool depth_compare, bool is_array, - bool is_aoffi, bool is_bindless, Register bindless_reg) { + bool is_aoffi, std::optional bindless_reg) { const bool lod_bias_enabled{ (process_mode != TextureProcessMode::None && process_mode != TextureProcessMode::LZ)}; @@ -482,8 +484,7 @@ Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, dc = GetRegister(parameter_register++); } - return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, 0, aoffi, is_bindless, - bindless_reg); + return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, 0, aoffi, bindless_reg); } Node4 ShaderIR::GetTexsCode(Instruction instr, TextureType texture_type, -- cgit v1.2.3 From c60b0b8432953fbbd7434578fd0858073b908392 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Thu, 28 Mar 2019 19:45:19 -0400 Subject: Fix TMML --- src/video_core/shader/decode/texture.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 5d670b24e..99385c46e 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -226,17 +226,19 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { coords.push_back(GetRegister(instr.gpr8.Value() + 1)); texture_type = TextureType::Texture2D; } - + u32 indexer = 0; for (u32 element = 0; element < 2; ++element) { + if (!instr.tmml.IsComponentEnabled(element)) { + continue; + } auto params = coords; MetaTexture meta{sampler, {}, {}, {}, {}, {}, {}, element}; const Node value = Operation(OperationCode::TextureQueryLod, meta, std::move(params)); - SetTemporal(bb, element, value); + SetTemporal(bb, indexer++, value); } - for (u32 element = 0; element < 2; ++element) { - SetRegister(bb, instr.gpr0.Value() + element, GetTemporal(element)); + for (u32 i = 0; i < indexer; ++i) { + SetRegister(bb, instr.gpr0.Value() + i, GetTemporal(i)); } - break; } case OpCode::Id::TLDS: { -- cgit v1.2.3 From 492040bd9ce40f86f9845699d68104d31d272155 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 7 Apr 2019 08:30:26 -0400 Subject: Move ConstBufferAccessor to Maxwell3d, correct mistakes and clang format. --- src/video_core/shader/decode/texture.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 99385c46e..dd5310c36 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -153,6 +153,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { } case OpCode::Id::TXQ_B: is_bindless = true; + [[fallthrough]]; case OpCode::Id::TXQ: { if (instr.txq.UsesMiscMode(TextureMiscMode::NODEP)) { LOG_WARNING(HW_GPU, "TXQ.NODEP implementation is incomplete"); @@ -193,6 +194,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { } case OpCode::Id::TMML_B: is_bindless = true; + [[fallthrough]]; case OpCode::Id::TMML: { UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV), "NDV is not implemented"); @@ -285,7 +287,6 @@ const Sampler& ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, Textu const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, TextureType type, bool is_array, bool is_shadow) { - const Node sampler_register = GetRegister(reg); const Node base_sampler = TrackCbuf(sampler_register, global_code, static_cast(global_code.size())); -- cgit v1.2.3 From ef8be408d321f4f15f0731c46118834bb757be1a Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 8 Apr 2019 12:07:56 -0400 Subject: Adapt Bindless to work with AOFFI --- src/video_core/shader/decode/texture.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/video_core/shader/decode/texture.cpp') diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index dd5310c36..fa65ac9a9 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -67,11 +67,12 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { const TextureType texture_type{instr.tex_b.texture_type}; const bool is_array = instr.tex_b.array != 0; + const bool is_aoffi = instr.tex.UsesMiscMode(TextureMiscMode::AOFFI); const bool depth_compare = instr.tex_b.UsesMiscMode(TextureMiscMode::DC); const auto process_mode = instr.tex_b.GetTextureProcessMode(); - WriteTexInstructionFloat( - bb, instr, - GetTexCode(instr, texture_type, process_mode, depth_compare, is_array, {instr.gpr20})); + WriteTexInstructionFloat(bb, instr, + GetTexCode(instr, texture_type, process_mode, depth_compare, + is_array, is_aoffi, {instr.gpr20})); break; } case OpCode::Id::TEXS: { @@ -384,7 +385,9 @@ void ShaderIR::WriteTexsInstructionHalfFloat(NodeBlock& bb, Instruction instr, Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, TextureProcessMode process_mode, std::vector coords, - Node array, Node depth_compare, u32 bias_offset, std::vector aoffi, std::optional bindless_reg) { + Node array, Node depth_compare, u32 bias_offset, + std::vector aoffi, + std::optional bindless_reg) { const bool is_array = array; const bool is_shadow = depth_compare; const bool is_bindless = bindless_reg.has_value(); @@ -451,7 +454,14 @@ Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, const bool lod_bias_enabled{ (process_mode != TextureProcessMode::None && process_mode != TextureProcessMode::LZ)}; + const bool is_bindless = bindless_reg.has_value(); + u64 parameter_register = instr.gpr20.Value(); + if (is_bindless) { + ++parameter_register; + } + + const u32 bias_lod_offset = (is_bindless ? 1 : 0); if (lod_bias_enabled) { ++parameter_register; } @@ -478,7 +488,6 @@ Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, if (is_aoffi) { aoffi = GetAoffiCoordinates(GetRegister(parameter_register++), coord_count, false); } - const u32 bindless_offset = (is_bindless ? 1 : 0); Node dc{}; if (depth_compare) { @@ -487,7 +496,8 @@ Node4 ShaderIR::GetTexCode(Instruction instr, TextureType texture_type, dc = GetRegister(parameter_register++); } - return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, 0, aoffi, bindless_reg); + return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, bias_lod_offset, + aoffi, bindless_reg); } Node4 ShaderIR::GetTexsCode(Instruction instr, TextureType texture_type, @@ -523,7 +533,8 @@ Node4 ShaderIR::GetTexsCode(Instruction instr, TextureType texture_type, dc = GetRegister(depth_register); } - return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, bias_offset, {}); + return GetTextureCode(instr, texture_type, process_mode, coords, array, dc, bias_offset, {}, + {}); } Node4 ShaderIR::GetTld4Code(Instruction instr, TextureType texture_type, bool depth_compare, -- cgit v1.2.3