diff options
| author | 2020-05-02 00:45:41 -0400 | |
|---|---|---|
| committer | 2020-05-02 00:45:41 -0400 | |
| commit | e6b4311178b4f87b67eb2383f2a64520c2a8dd25 (patch) | |
| tree | 066f25773f9db49747f26ddf94b23a5007502ff8 /src/video_core/shader/decode | |
| parent | Merge pull request #3859 from jbeich/clang (diff) | |
| parent | shader/texture: Support multiple unknown sampler properties (diff) | |
| download | yuzu-e6b4311178b4f87b67eb2383f2a64520c2a8dd25.tar.gz yuzu-e6b4311178b4f87b67eb2383f2a64520c2a8dd25.tar.xz yuzu-e6b4311178b4f87b67eb2383f2a64520c2a8dd25.zip | |
Merge pull request #3693 from ReinUsesLisp/clean-samplers
shader/texture: Support multiple unknown sampler properties
Diffstat (limited to 'src/video_core/shader/decode')
| -rw-r--r-- | src/video_core/shader/decode/image.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/shader/decode/texture.cpp | 192 |
2 files changed, 116 insertions, 94 deletions
diff --git a/src/video_core/shader/decode/image.cpp b/src/video_core/shader/decode/image.cpp index 85ee9aa5e..60b6ad72a 100644 --- a/src/video_core/shader/decode/image.cpp +++ b/src/video_core/shader/decode/image.cpp | |||
| @@ -485,11 +485,10 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) { | |||
| 485 | Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) { | 485 | Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) { |
| 486 | const auto offset = static_cast<u32>(image.index.Value()); | 486 | const auto offset = static_cast<u32>(image.index.Value()); |
| 487 | 487 | ||
| 488 | const auto it = | 488 | const auto it = std::find_if(std::begin(used_images), std::end(used_images), |
| 489 | std::find_if(std::begin(used_images), std::end(used_images), | 489 | [offset](const Image& entry) { return entry.offset == offset; }); |
| 490 | [offset](const Image& entry) { return entry.GetOffset() == offset; }); | ||
| 491 | if (it != std::end(used_images)) { | 490 | if (it != std::end(used_images)) { |
| 492 | ASSERT(!it->IsBindless() && it->GetType() == it->GetType()); | 491 | ASSERT(!it->is_bindless && it->type == type); |
| 493 | return *it; | 492 | return *it; |
| 494 | } | 493 | } |
| 495 | 494 | ||
| @@ -505,13 +504,12 @@ Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::Im | |||
| 505 | const auto buffer = std::get<1>(result); | 504 | const auto buffer = std::get<1>(result); |
| 506 | const auto offset = std::get<2>(result); | 505 | const auto offset = std::get<2>(result); |
| 507 | 506 | ||
| 508 | const auto it = | 507 | const auto it = std::find_if(std::begin(used_images), std::end(used_images), |
| 509 | std::find_if(std::begin(used_images), std::end(used_images), | 508 | [buffer, offset](const Image& entry) { |
| 510 | [buffer = buffer, offset = offset](const Image& entry) { | 509 | return entry.buffer == buffer && entry.offset == offset; |
| 511 | return entry.GetBuffer() == buffer && entry.GetOffset() == offset; | 510 | }); |
| 512 | }); | ||
| 513 | if (it != std::end(used_images)) { | 511 | if (it != std::end(used_images)) { |
| 514 | ASSERT(it->IsBindless() && it->GetType() == it->GetType()); | 512 | ASSERT(it->is_bindless && it->type == type); |
| 515 | return *it; | 513 | return *it; |
| 516 | } | 514 | } |
| 517 | 515 | ||
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index e68f1d305..8f0bb996e 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp | |||
| @@ -139,15 +139,15 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 139 | } | 139 | } |
| 140 | const Node component = Immediate(static_cast<u32>(instr.tld4s.component)); | 140 | const Node component = Immediate(static_cast<u32>(instr.tld4s.component)); |
| 141 | 141 | ||
| 142 | const SamplerInfo info{TextureType::Texture2D, false, is_depth_compare, false}; | 142 | SamplerInfo info; |
| 143 | const Sampler& sampler = *GetSampler(instr.sampler, info); | 143 | info.is_shadow = is_depth_compare; |
| 144 | const std::optional<Sampler> sampler = GetSampler(instr.sampler, info); | ||
| 144 | 145 | ||
| 145 | Node4 values; | 146 | Node4 values; |
| 146 | for (u32 element = 0; element < values.size(); ++element) { | 147 | for (u32 element = 0; element < values.size(); ++element) { |
| 147 | auto coords_copy = coords; | 148 | MetaTexture meta{*sampler, {}, depth_compare, aoffi, {}, {}, |
| 148 | MetaTexture meta{sampler, {}, depth_compare, aoffi, {}, {}, | 149 | {}, {}, component, element, {}}; |
| 149 | {}, {}, component, element, {}}; | 150 | values[element] = Operation(OperationCode::TextureGather, meta, coords); |
| 150 | values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy)); | ||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | if (instr.tld4s.fp16_flag) { | 153 | if (instr.tld4s.fp16_flag) { |
| @@ -165,18 +165,20 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 165 | "AOFFI is not implemented"); | 165 | "AOFFI is not implemented"); |
| 166 | 166 | ||
| 167 | const bool is_array = instr.txd.is_array != 0; | 167 | const bool is_array = instr.txd.is_array != 0; |
| 168 | u64 base_reg = instr.gpr8.Value(); | ||
| 169 | const auto derivate_reg = instr.gpr20.Value(); | 168 | const auto derivate_reg = instr.gpr20.Value(); |
| 170 | const auto texture_type = instr.txd.texture_type.Value(); | 169 | const auto texture_type = instr.txd.texture_type.Value(); |
| 171 | const auto coord_count = GetCoordCount(texture_type); | 170 | const auto coord_count = GetCoordCount(texture_type); |
| 172 | Node index_var{}; | 171 | u64 base_reg = instr.gpr8.Value(); |
| 173 | const Sampler* sampler = | 172 | Node index_var; |
| 174 | is_bindless | 173 | SamplerInfo info; |
| 175 | ? GetBindlessSampler(base_reg, index_var, {{texture_type, is_array, false, false}}) | 174 | info.type = texture_type; |
| 176 | : GetSampler(instr.sampler, {{texture_type, is_array, false, false}}); | 175 | info.is_array = is_array; |
| 176 | const std::optional<Sampler> sampler = is_bindless | ||
| 177 | ? GetBindlessSampler(base_reg, info, index_var) | ||
| 178 | : GetSampler(instr.sampler, info); | ||
| 177 | Node4 values; | 179 | Node4 values; |
| 178 | if (sampler == nullptr) { | 180 | if (!sampler) { |
| 179 | std::generate(values.begin(), values.end(), [] { return Immediate(0); }); | 181 | std::generate(values.begin(), values.end(), [this] { return Immediate(0); }); |
| 180 | WriteTexInstructionFloat(bb, instr, values); | 182 | WriteTexInstructionFloat(bb, instr, values); |
| 181 | break; | 183 | break; |
| 182 | } | 184 | } |
| @@ -214,14 +216,12 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 214 | is_bindless = true; | 216 | is_bindless = true; |
| 215 | [[fallthrough]]; | 217 | [[fallthrough]]; |
| 216 | case OpCode::Id::TXQ: { | 218 | case OpCode::Id::TXQ: { |
| 217 | // TODO: The new commits on the texture refactor, change the way samplers work. | 219 | Node index_var; |
| 218 | // Sadly, not all texture instructions specify the type of texture their sampler | 220 | const std::optional<Sampler> sampler = is_bindless |
| 219 | // uses. This must be fixed at a later instance. | 221 | ? GetBindlessSampler(instr.gpr8, {}, index_var) |
| 220 | Node index_var{}; | 222 | : GetSampler(instr.sampler, {}); |
| 221 | const Sampler* sampler = | 223 | |
| 222 | is_bindless ? GetBindlessSampler(instr.gpr8, index_var) : GetSampler(instr.sampler); | 224 | if (!sampler) { |
| 223 | |||
| 224 | if (sampler == nullptr) { | ||
| 225 | u32 indexer = 0; | 225 | u32 indexer = 0; |
| 226 | for (u32 element = 0; element < 4; ++element) { | 226 | for (u32 element = 0; element < 4; ++element) { |
| 227 | if (!instr.txq.IsComponentEnabled(element)) { | 227 | if (!instr.txq.IsComponentEnabled(element)) { |
| @@ -267,12 +267,17 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 267 | UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV), | 267 | UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV), |
| 268 | "NDV is not implemented"); | 268 | "NDV is not implemented"); |
| 269 | 269 | ||
| 270 | auto texture_type = instr.tmml.texture_type.Value(); | 270 | const auto texture_type = instr.tmml.texture_type.Value(); |
| 271 | Node index_var{}; | 271 | const bool is_array = instr.tmml.array != 0; |
| 272 | const Sampler* sampler = | 272 | SamplerInfo info; |
| 273 | is_bindless ? GetBindlessSampler(instr.gpr20, index_var) : GetSampler(instr.sampler); | 273 | info.type = texture_type; |
| 274 | 274 | info.is_array = is_array; | |
| 275 | if (sampler == nullptr) { | 275 | Node index_var; |
| 276 | const std::optional<Sampler> sampler = | ||
| 277 | is_bindless ? GetBindlessSampler(instr.gpr20, info, index_var) | ||
| 278 | : GetSampler(instr.sampler, info); | ||
| 279 | |||
| 280 | if (!sampler) { | ||
| 276 | u32 indexer = 0; | 281 | u32 indexer = 0; |
| 277 | for (u32 element = 0; element < 2; ++element) { | 282 | for (u32 element = 0; element < 2; ++element) { |
| 278 | if (!instr.tmml.IsComponentEnabled(element)) { | 283 | if (!instr.tmml.IsComponentEnabled(element)) { |
| @@ -299,12 +304,11 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 299 | coords.push_back(GetRegister(instr.gpr8.Value() + 1)); | 304 | coords.push_back(GetRegister(instr.gpr8.Value() + 1)); |
| 300 | break; | 305 | break; |
| 301 | default: | 306 | default: |
| 302 | UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<u32>(texture_type)); | 307 | UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<int>(texture_type)); |
| 303 | 308 | ||
| 304 | // Fallback to interpreting as a 2D texture for now | 309 | // Fallback to interpreting as a 2D texture for now |
| 305 | coords.push_back(GetRegister(instr.gpr8.Value() + 0)); | 310 | coords.push_back(GetRegister(instr.gpr8.Value() + 0)); |
| 306 | coords.push_back(GetRegister(instr.gpr8.Value() + 1)); | 311 | coords.push_back(GetRegister(instr.gpr8.Value() + 1)); |
| 307 | texture_type = TextureType::Texture2D; | ||
| 308 | } | 312 | } |
| 309 | u32 indexer = 0; | 313 | u32 indexer = 0; |
| 310 | for (u32 element = 0; element < 2; ++element) { | 314 | for (u32 element = 0; element < 2; ++element) { |
| @@ -353,98 +357,103 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) { | |||
| 353 | return pc; | 357 | return pc; |
| 354 | } | 358 | } |
| 355 | 359 | ||
| 356 | ShaderIR::SamplerInfo ShaderIR::GetSamplerInfo(std::optional<SamplerInfo> sampler_info, u32 offset, | 360 | ShaderIR::SamplerInfo ShaderIR::GetSamplerInfo(SamplerInfo info, u32 offset, |
| 357 | std::optional<u32> buffer) { | 361 | std::optional<u32> buffer) { |
| 358 | if (sampler_info) { | 362 | if (info.IsComplete()) { |
| 359 | return *sampler_info; | 363 | return info; |
| 360 | } | 364 | } |
| 361 | const auto sampler = buffer ? registry.ObtainBindlessSampler(*buffer, offset) | 365 | const auto sampler = buffer ? registry.ObtainBindlessSampler(*buffer, offset) |
| 362 | : registry.ObtainBoundSampler(offset); | 366 | : registry.ObtainBoundSampler(offset); |
| 363 | if (!sampler) { | 367 | if (!sampler) { |
| 364 | LOG_WARNING(HW_GPU, "Unknown sampler info"); | 368 | LOG_WARNING(HW_GPU, "Unknown sampler info"); |
| 365 | return SamplerInfo{TextureType::Texture2D, false, false, false}; | 369 | info.type = info.type.value_or(Tegra::Shader::TextureType::Texture2D); |
| 366 | } | 370 | info.is_array = info.is_array.value_or(false); |
| 367 | return SamplerInfo{sampler->texture_type, sampler->is_array != 0, sampler->is_shadow != 0, | 371 | info.is_shadow = info.is_shadow.value_or(false); |
| 368 | sampler->is_buffer != 0}; | 372 | info.is_buffer = info.is_buffer.value_or(false); |
| 373 | return info; | ||
| 374 | } | ||
| 375 | info.type = info.type.value_or(sampler->texture_type); | ||
| 376 | info.is_array = info.is_array.value_or(sampler->is_array != 0); | ||
| 377 | info.is_shadow = info.is_shadow.value_or(sampler->is_shadow != 0); | ||
| 378 | info.is_buffer = info.is_buffer.value_or(sampler->is_buffer != 0); | ||
| 379 | return info; | ||
| 369 | } | 380 | } |
| 370 | 381 | ||
| 371 | const Sampler* ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, | 382 | std::optional<Sampler> ShaderIR::GetSampler(Tegra::Shader::Sampler sampler, |
| 372 | std::optional<SamplerInfo> sampler_info) { | 383 | SamplerInfo sampler_info) { |
| 373 | const auto offset = static_cast<u32>(sampler.index.Value()); | 384 | const auto offset = static_cast<u32>(sampler.index.Value()); |
| 374 | const auto info = GetSamplerInfo(sampler_info, offset); | 385 | const auto info = GetSamplerInfo(sampler_info, offset); |
| 375 | 386 | ||
| 376 | // If this sampler has already been used, return the existing mapping. | 387 | // If this sampler has already been used, return the existing mapping. |
| 377 | const auto it = | 388 | const auto it = std::find_if(used_samplers.begin(), used_samplers.end(), |
| 378 | std::find_if(used_samplers.begin(), used_samplers.end(), | 389 | [offset](const Sampler& entry) { return entry.offset == offset; }); |
| 379 | [offset](const Sampler& entry) { return entry.GetOffset() == offset; }); | ||
| 380 | if (it != used_samplers.end()) { | 390 | if (it != used_samplers.end()) { |
| 381 | ASSERT(!it->IsBindless() && it->GetType() == info.type && it->IsArray() == info.is_array && | 391 | ASSERT(!it->is_bindless && it->type == info.type && it->is_array == info.is_array && |
| 382 | it->IsShadow() == info.is_shadow && it->IsBuffer() == info.is_buffer); | 392 | it->is_shadow == info.is_shadow && it->is_buffer == info.is_buffer); |
| 383 | return &*it; | 393 | return *it; |
| 384 | } | 394 | } |
| 385 | 395 | ||
| 386 | // Otherwise create a new mapping for this sampler | 396 | // Otherwise create a new mapping for this sampler |
| 387 | const auto next_index = static_cast<u32>(used_samplers.size()); | 397 | const auto next_index = static_cast<u32>(used_samplers.size()); |
| 388 | return &used_samplers.emplace_back(next_index, offset, info.type, info.is_array, info.is_shadow, | 398 | return used_samplers.emplace_back(next_index, offset, *info.type, *info.is_array, |
| 389 | info.is_buffer, false); | 399 | *info.is_shadow, *info.is_buffer, false); |
| 390 | } | 400 | } |
| 391 | 401 | ||
| 392 | const Sampler* ShaderIR::GetBindlessSampler(Tegra::Shader::Register reg, Node& index_var, | 402 | std::optional<Sampler> ShaderIR::GetBindlessSampler(Tegra::Shader::Register reg, SamplerInfo info, |
| 393 | std::optional<SamplerInfo> sampler_info) { | 403 | Node& index_var) { |
| 394 | const Node sampler_register = GetRegister(reg); | 404 | const Node sampler_register = GetRegister(reg); |
| 395 | const auto [base_node, tracked_sampler_info] = | 405 | const auto [base_node, tracked_sampler_info] = |
| 396 | TrackBindlessSampler(sampler_register, global_code, static_cast<s64>(global_code.size())); | 406 | TrackBindlessSampler(sampler_register, global_code, static_cast<s64>(global_code.size())); |
| 397 | ASSERT(base_node != nullptr); | 407 | ASSERT(base_node != nullptr); |
| 398 | if (base_node == nullptr) { | 408 | if (base_node == nullptr) { |
| 399 | return nullptr; | 409 | return std::nullopt; |
| 400 | } | 410 | } |
| 401 | 411 | ||
| 402 | if (const auto bindless_sampler_info = | 412 | if (const auto bindless_sampler_info = |
| 403 | std::get_if<BindlessSamplerNode>(&*tracked_sampler_info)) { | 413 | std::get_if<BindlessSamplerNode>(&*tracked_sampler_info)) { |
| 404 | const u32 buffer = bindless_sampler_info->GetIndex(); | 414 | const u32 buffer = bindless_sampler_info->GetIndex(); |
| 405 | const u32 offset = bindless_sampler_info->GetOffset(); | 415 | const u32 offset = bindless_sampler_info->GetOffset(); |
| 406 | const auto info = GetSamplerInfo(sampler_info, offset, buffer); | 416 | info = GetSamplerInfo(info, offset, buffer); |
| 407 | 417 | ||
| 408 | // If this sampler has already been used, return the existing mapping. | 418 | // If this sampler has already been used, return the existing mapping. |
| 409 | const auto it = | 419 | const auto it = std::find_if(used_samplers.begin(), used_samplers.end(), |
| 410 | std::find_if(used_samplers.begin(), used_samplers.end(), | 420 | [buffer = buffer, offset = offset](const Sampler& entry) { |
| 411 | [buffer = buffer, offset = offset](const Sampler& entry) { | 421 | return entry.buffer == buffer && entry.offset == offset; |
| 412 | return entry.GetBuffer() == buffer && entry.GetOffset() == offset; | 422 | }); |
| 413 | }); | ||
| 414 | if (it != used_samplers.end()) { | 423 | if (it != used_samplers.end()) { |
| 415 | ASSERT(it->IsBindless() && it->GetType() == info.type && | 424 | ASSERT(it->is_bindless && it->type == info.type && it->is_array == info.is_array && |
| 416 | it->IsArray() == info.is_array && it->IsShadow() == info.is_shadow); | 425 | it->is_shadow == info.is_shadow); |
| 417 | return &*it; | 426 | return *it; |
| 418 | } | 427 | } |
| 419 | 428 | ||
| 420 | // Otherwise create a new mapping for this sampler | 429 | // Otherwise create a new mapping for this sampler |
| 421 | const auto next_index = static_cast<u32>(used_samplers.size()); | 430 | const auto next_index = static_cast<u32>(used_samplers.size()); |
| 422 | return &used_samplers.emplace_back(next_index, offset, buffer, info.type, info.is_array, | 431 | return used_samplers.emplace_back(next_index, offset, buffer, *info.type, *info.is_array, |
| 423 | info.is_shadow, info.is_buffer, false); | 432 | *info.is_shadow, *info.is_buffer, false); |
| 424 | } else if (const auto array_sampler_info = | 433 | } |
| 425 | std::get_if<ArraySamplerNode>(&*tracked_sampler_info)) { | 434 | if (const auto array_sampler_info = std::get_if<ArraySamplerNode>(&*tracked_sampler_info)) { |
| 426 | const u32 base_offset = array_sampler_info->GetBaseOffset() / 4; | 435 | const u32 base_offset = array_sampler_info->GetBaseOffset() / 4; |
| 427 | index_var = GetCustomVariable(array_sampler_info->GetIndexVar()); | 436 | index_var = GetCustomVariable(array_sampler_info->GetIndexVar()); |
| 428 | const auto info = GetSamplerInfo(sampler_info, base_offset); | 437 | info = GetSamplerInfo(info, base_offset); |
| 429 | 438 | ||
| 430 | // If this sampler has already been used, return the existing mapping. | 439 | // If this sampler has already been used, return the existing mapping. |
| 431 | const auto it = std::find_if( | 440 | const auto it = std::find_if( |
| 432 | used_samplers.begin(), used_samplers.end(), | 441 | used_samplers.begin(), used_samplers.end(), |
| 433 | [base_offset](const Sampler& entry) { return entry.GetOffset() == base_offset; }); | 442 | [base_offset](const Sampler& entry) { return entry.offset == base_offset; }); |
| 434 | if (it != used_samplers.end()) { | 443 | if (it != used_samplers.end()) { |
| 435 | ASSERT(!it->IsBindless() && it->GetType() == info.type && | 444 | ASSERT(!it->is_bindless && it->type == info.type && it->is_array == info.is_array && |
| 436 | it->IsArray() == info.is_array && it->IsShadow() == info.is_shadow && | 445 | it->is_shadow == info.is_shadow && it->is_buffer == info.is_buffer && |
| 437 | it->IsBuffer() == info.is_buffer && it->IsIndexed()); | 446 | it->is_indexed); |
| 438 | return &*it; | 447 | return *it; |
| 439 | } | 448 | } |
| 440 | 449 | ||
| 441 | uses_indexed_samplers = true; | 450 | uses_indexed_samplers = true; |
| 442 | // Otherwise create a new mapping for this sampler | 451 | // Otherwise create a new mapping for this sampler |
| 443 | const auto next_index = static_cast<u32>(used_samplers.size()); | 452 | const auto next_index = static_cast<u32>(used_samplers.size()); |
| 444 | return &used_samplers.emplace_back(next_index, base_offset, info.type, info.is_array, | 453 | return used_samplers.emplace_back(next_index, base_offset, *info.type, *info.is_array, |
| 445 | info.is_shadow, info.is_buffer, true); | 454 | *info.is_shadow, *info.is_buffer, true); |
| 446 | } | 455 | } |
| 447 | return nullptr; | 456 | return std::nullopt; |
| 448 | } | 457 | } |
| 449 | 458 | ||
| 450 | void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { | 459 | void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { |
| @@ -529,10 +538,16 @@ Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type, | |||
| 529 | ASSERT_MSG(texture_type != TextureType::Texture3D || !is_array || !is_shadow, | 538 | ASSERT_MSG(texture_type != TextureType::Texture3D || !is_array || !is_shadow, |
| 530 | "Illegal texture type"); | 539 | "Illegal texture type"); |
| 531 | 540 | ||
| 532 | const SamplerInfo info{texture_type, is_array, is_shadow, false}; | 541 | SamplerInfo info; |
| 542 | info.type = texture_type; | ||
| 543 | info.is_array = is_array; | ||
| 544 | info.is_shadow = is_shadow; | ||
| 545 | info.is_buffer = false; | ||
| 546 | |||
| 533 | Node index_var; | 547 | Node index_var; |
| 534 | const Sampler* sampler = is_bindless ? GetBindlessSampler(*bindless_reg, index_var, info) | 548 | const std::optional<Sampler> sampler = is_bindless |
| 535 | : GetSampler(instr.sampler, info); | 549 | ? GetBindlessSampler(*bindless_reg, info, index_var) |
| 550 | : GetSampler(instr.sampler, info); | ||
| 536 | if (!sampler) { | 551 | if (!sampler) { |
| 537 | return {Immediate(0), Immediate(0), Immediate(0), Immediate(0)}; | 552 | return {Immediate(0), Immediate(0), Immediate(0), Immediate(0)}; |
| 538 | } | 553 | } |
| @@ -683,12 +698,17 @@ Node4 ShaderIR::GetTld4Code(Instruction instr, TextureType texture_type, bool de | |||
| 683 | 698 | ||
| 684 | u64 parameter_register = instr.gpr20.Value(); | 699 | u64 parameter_register = instr.gpr20.Value(); |
| 685 | 700 | ||
| 686 | const SamplerInfo info{texture_type, is_array, depth_compare, false}; | 701 | SamplerInfo info; |
| 687 | Node index_var{}; | 702 | info.type = texture_type; |
| 688 | const Sampler* sampler = is_bindless ? GetBindlessSampler(parameter_register++, index_var, info) | 703 | info.is_array = is_array; |
| 689 | : GetSampler(instr.sampler, info); | 704 | info.is_shadow = depth_compare; |
| 705 | |||
| 706 | Node index_var; | ||
| 707 | const std::optional<Sampler> sampler = | ||
| 708 | is_bindless ? GetBindlessSampler(parameter_register++, info, index_var) | ||
| 709 | : GetSampler(instr.sampler, info); | ||
| 690 | Node4 values; | 710 | Node4 values; |
| 691 | if (sampler == nullptr) { | 711 | if (!sampler) { |
| 692 | for (u32 element = 0; element < values.size(); ++element) { | 712 | for (u32 element = 0; element < values.size(); ++element) { |
| 693 | values[element] = Immediate(0); | 713 | values[element] = Immediate(0); |
| 694 | } | 714 | } |
| @@ -743,12 +763,12 @@ Node4 ShaderIR::GetTldCode(Tegra::Shader::Instruction instr) { | |||
| 743 | // const Node aoffi_register{is_aoffi ? GetRegister(gpr20_cursor++) : nullptr}; | 763 | // const Node aoffi_register{is_aoffi ? GetRegister(gpr20_cursor++) : nullptr}; |
| 744 | // const Node multisample{is_multisample ? GetRegister(gpr20_cursor++) : nullptr}; | 764 | // const Node multisample{is_multisample ? GetRegister(gpr20_cursor++) : nullptr}; |
| 745 | 765 | ||
| 746 | const auto& sampler = *GetSampler(instr.sampler); | 766 | const std::optional<Sampler> sampler = GetSampler(instr.sampler, {}); |
| 747 | 767 | ||
| 748 | Node4 values; | 768 | Node4 values; |
| 749 | for (u32 element = 0; element < values.size(); ++element) { | 769 | for (u32 element = 0; element < values.size(); ++element) { |
| 750 | auto coords_copy = coords; | 770 | auto coords_copy = coords; |
| 751 | MetaTexture meta{sampler, array_register, {}, {}, {}, {}, {}, lod, {}, element, {}}; | 771 | MetaTexture meta{*sampler, array_register, {}, {}, {}, {}, {}, lod, {}, element, {}}; |
| 752 | values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); | 772 | values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); |
| 753 | } | 773 | } |
| 754 | 774 | ||
| @@ -756,7 +776,11 @@ Node4 ShaderIR::GetTldCode(Tegra::Shader::Instruction instr) { | |||
| 756 | } | 776 | } |
| 757 | 777 | ||
| 758 | Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is_array) { | 778 | Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is_array) { |
| 759 | const Sampler& sampler = *GetSampler(instr.sampler); | 779 | SamplerInfo info; |
| 780 | info.type = texture_type; | ||
| 781 | info.is_array = is_array; | ||
| 782 | info.is_shadow = false; | ||
| 783 | const std::optional<Sampler> sampler = GetSampler(instr.sampler, info); | ||
| 760 | 784 | ||
| 761 | const std::size_t type_coord_count = GetCoordCount(texture_type); | 785 | const std::size_t type_coord_count = GetCoordCount(texture_type); |
| 762 | const bool lod_enabled = instr.tlds.GetTextureProcessMode() == TextureProcessMode::LL; | 786 | const bool lod_enabled = instr.tlds.GetTextureProcessMode() == TextureProcessMode::LL; |
| @@ -784,7 +808,7 @@ Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is | |||
| 784 | Node4 values; | 808 | Node4 values; |
| 785 | for (u32 element = 0; element < values.size(); ++element) { | 809 | for (u32 element = 0; element < values.size(); ++element) { |
| 786 | auto coords_copy = coords; | 810 | auto coords_copy = coords; |
| 787 | MetaTexture meta{sampler, array, {}, {}, {}, {}, {}, lod, {}, element, {}}; | 811 | MetaTexture meta{*sampler, array, {}, {}, {}, {}, {}, lod, {}, element, {}}; |
| 788 | values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); | 812 | values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); |
| 789 | } | 813 | } |
| 790 | return values; | 814 | return values; |