diff options
| author | 2019-04-27 20:50:35 -0300 | |
|---|---|---|
| committer | 2019-06-20 21:36:12 -0300 | |
| commit | 4e81fc8296c6204645151bbaa23a7d80827a4293 (patch) | |
| tree | e826cbe2f9fd118a82d251854872eb7d300a6078 /src | |
| parent | texture_cache: loose TryReconstructSurface when accurate GPU is not on. (diff) | |
| download | yuzu-4e81fc8296c6204645151bbaa23a7d80827a4293.tar.gz yuzu-4e81fc8296c6204645151bbaa23a7d80827a4293.tar.xz yuzu-4e81fc8296c6204645151bbaa23a7d80827a4293.zip | |
shader: Implement texture buffers
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 16 | ||||
| -rw-r--r-- | src/video_core/shader/decode/texture.cpp | 44 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.h | 2 |
3 files changed, 62 insertions, 0 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index ffb3ec3e0..5b32e1249 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -1232,6 +1232,20 @@ union Instruction { | |||
| 1232 | } texs; | 1232 | } texs; |
| 1233 | 1233 | ||
| 1234 | union { | 1234 | union { |
| 1235 | BitField<28, 1, u64> is_array; | ||
| 1236 | BitField<29, 2, TextureType> texture_type; | ||
| 1237 | BitField<35, 1, u64> aoffi; | ||
| 1238 | BitField<49, 1, u64> nodep_flag; | ||
| 1239 | BitField<50, 1, u64> ms; // Multisample? | ||
| 1240 | BitField<54, 1, u64> cl; | ||
| 1241 | BitField<55, 1, u64> process_mode; | ||
| 1242 | |||
| 1243 | TextureProcessMode GetTextureProcessMode() const { | ||
| 1244 | return process_mode == 0 ? TextureProcessMode::LZ : TextureProcessMode::LL; | ||
| 1245 | } | ||
| 1246 | } tld; | ||
| 1247 | |||
| 1248 | union { | ||
| 1235 | BitField<49, 1, u64> nodep_flag; | 1249 | BitField<49, 1, u64> nodep_flag; |
| 1236 | BitField<53, 4, u64> texture_info; | 1250 | BitField<53, 4, u64> texture_info; |
| 1237 | 1251 | ||
| @@ -1408,6 +1422,7 @@ public: | |||
| 1408 | TXQ, // Texture Query | 1422 | TXQ, // Texture Query |
| 1409 | TXQ_B, // Texture Query Bindless | 1423 | TXQ_B, // Texture Query Bindless |
| 1410 | TEXS, // Texture Fetch with scalar/non-vec4 source/destinations | 1424 | TEXS, // Texture Fetch with scalar/non-vec4 source/destinations |
| 1425 | TLD, // Texture Load | ||
| 1411 | TLDS, // Texture Load with scalar/non-vec4 source/destinations | 1426 | TLDS, // Texture Load with scalar/non-vec4 source/destinations |
| 1412 | TLD4, // Texture Load 4 | 1427 | TLD4, // Texture Load 4 |
| 1413 | TLD4S, // Texture Load 4 with scalar / non - vec4 source / destinations | 1428 | TLD4S, // Texture Load 4 with scalar / non - vec4 source / destinations |
| @@ -1682,6 +1697,7 @@ private: | |||
| 1682 | INST("1101111101001---", Id::TXQ, Type::Texture, "TXQ"), | 1697 | INST("1101111101001---", Id::TXQ, Type::Texture, "TXQ"), |
| 1683 | INST("1101111101010---", Id::TXQ_B, Type::Texture, "TXQ_B"), | 1698 | INST("1101111101010---", Id::TXQ_B, Type::Texture, "TXQ_B"), |
| 1684 | INST("1101-00---------", Id::TEXS, Type::Texture, "TEXS"), | 1699 | INST("1101-00---------", Id::TEXS, Type::Texture, "TEXS"), |
| 1700 | INST("11011100--11----", Id::TLD, Type::Texture, "TLD"), | ||
| 1685 | INST("1101101---------", Id::TLDS, Type::Texture, "TLDS"), | 1701 | INST("1101101---------", Id::TLDS, Type::Texture, "TLDS"), |
| 1686 | INST("110010----111---", Id::TLD4, Type::Texture, "TLD4"), | 1702 | INST("110010----111---", Id::TLD4, Type::Texture, "TLD4"), |
| 1687 | INST("1101111100------", Id::TLD4S, Type::Texture, "TLD4S"), | 1703 | INST("1101111100------", Id::TLD4S, Type::Texture, "TLD4S"), |
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index 4a356dbd4..b22831c64 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp | |||
| @@ -245,6 +245,18 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 245 | } | 245 | } |
| 246 | break; | 246 | break; |
| 247 | } | 247 | } |
| 248 | case OpCode::Id::TLD: { | ||
| 249 | UNIMPLEMENTED_IF_MSG(instr.tld.aoffi, "AOFFI is not implemented"); | ||
| 250 | UNIMPLEMENTED_IF_MSG(instr.tld.ms, "MS is not implemented"); | ||
| 251 | UNIMPLEMENTED_IF_MSG(instr.tld.cl, "CL is not implemented"); | ||
| 252 | |||
| 253 | if (instr.tld.nodep_flag) { | ||
| 254 | LOG_WARNING(HW_GPU, "TLD.NODEP implementation is incomplete"); | ||
| 255 | } | ||
| 256 | |||
| 257 | WriteTexInstructionFloat(bb, instr, GetTldCode(instr)); | ||
| 258 | break; | ||
| 259 | } | ||
| 248 | case OpCode::Id::TLDS: { | 260 | case OpCode::Id::TLDS: { |
| 249 | const Tegra::Shader::TextureType texture_type{instr.tlds.GetTextureType()}; | 261 | const Tegra::Shader::TextureType texture_type{instr.tlds.GetTextureType()}; |
| 250 | const bool is_array{instr.tlds.IsArrayTexture()}; | 262 | const bool is_array{instr.tlds.IsArrayTexture()}; |
| @@ -575,6 +587,38 @@ Node4 ShaderIR::GetTld4Code(Instruction instr, TextureType texture_type, bool de | |||
| 575 | return values; | 587 | return values; |
| 576 | } | 588 | } |
| 577 | 589 | ||
| 590 | Node4 ShaderIR::GetTldCode(Tegra::Shader::Instruction instr) { | ||
| 591 | const auto texture_type{instr.tld.texture_type}; | ||
| 592 | const bool is_array{instr.tld.is_array}; | ||
| 593 | const bool lod_enabled{instr.tld.GetTextureProcessMode() == TextureProcessMode::LL}; | ||
| 594 | const std::size_t coord_count{GetCoordCount(texture_type)}; | ||
| 595 | |||
| 596 | u64 gpr8_cursor{instr.gpr8.Value()}; | ||
| 597 | const Node array_register{is_array ? GetRegister(gpr8_cursor++) : nullptr}; | ||
| 598 | |||
| 599 | std::vector<Node> coords; | ||
| 600 | for (std::size_t i = 0; i < coord_count; ++i) { | ||
| 601 | coords.push_back(GetRegister(gpr8_cursor++)); | ||
| 602 | } | ||
| 603 | |||
| 604 | u64 gpr20_cursor{instr.gpr20.Value()}; | ||
| 605 | // const Node bindless_register{is_bindless ? GetRegister(gpr20_cursor++) : nullptr}; | ||
| 606 | const Node lod{lod_enabled ? GetRegister(gpr20_cursor++) : Immediate(0u)}; | ||
| 607 | // const Node aoffi_register{is_aoffi ? GetRegister(gpr20_cursor++) : nullptr}; | ||
| 608 | // const Node multisample{is_multisample ? GetRegister(gpr20_cursor++) : nullptr}; | ||
| 609 | |||
| 610 | const auto& sampler = GetSampler(instr.sampler, texture_type, is_array, false); | ||
| 611 | |||
| 612 | Node4 values; | ||
| 613 | for (u32 element = 0; element < values.size(); ++element) { | ||
| 614 | auto coords_copy = coords; | ||
| 615 | MetaTexture meta{sampler, array_register, {}, {}, {}, lod, {}, element}; | ||
| 616 | values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); | ||
| 617 | } | ||
| 618 | |||
| 619 | return values; | ||
| 620 | } | ||
| 621 | |||
| 578 | Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is_array) { | 622 | Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is_array) { |
| 579 | const std::size_t type_coord_count = GetCoordCount(texture_type); | 623 | const std::size_t type_coord_count = GetCoordCount(texture_type); |
| 580 | const bool lod_enabled = instr.tlds.GetTextureProcessMode() == TextureProcessMode::LL; | 624 | const bool lod_enabled = instr.tlds.GetTextureProcessMode() == TextureProcessMode::LL; |
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index edcf2288e..1b84c0672 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h | |||
| @@ -277,6 +277,8 @@ private: | |||
| 277 | Node4 GetTld4Code(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, | 277 | Node4 GetTld4Code(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, |
| 278 | bool depth_compare, bool is_array, bool is_aoffi); | 278 | bool depth_compare, bool is_array, bool is_aoffi); |
| 279 | 279 | ||
| 280 | Node4 GetTldCode(Tegra::Shader::Instruction instr); | ||
| 281 | |||
| 280 | Node4 GetTldsCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, | 282 | Node4 GetTldsCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, |
| 281 | bool is_array); | 283 | bool is_array); |
| 282 | 284 | ||