From 1169533a74cb8769327ad1a3a362f7d43325157f Mon Sep 17 00:00:00 2001 From: CamilleLaVey Date: Tue, 28 Jul 2026 11:20:23 -0400 Subject: [PATCH] [TEST] Debug TICEntry shader pass --- src/shader_recompiler/environment.h | 5 -- src/shader_recompiler/ir_opt/texture_pass.cpp | 2 +- .../renderer_vulkan/vk_compute_pipeline.cpp | 13 +---- src/video_core/shader_environment.cpp | 54 +++---------------- src/video_core/shader_environment.h | 5 -- 5 files changed, 11 insertions(+), 68 deletions(-) diff --git a/src/shader_recompiler/environment.h b/src/shader_recompiler/environment.h index d46d1c890e..20381cf467 100644 --- a/src/shader_recompiler/environment.h +++ b/src/shader_recompiler/environment.h @@ -78,11 +78,6 @@ public: [[nodiscard]] virtual TextureType ReadTextureType(u32 raw_handle) = 0; - [[nodiscard]] virtual u32 ResolveBindlessHandle(u32 cbuf_index, u32 cbuf_offset, - u32 raw_handle) { - return raw_handle; - } - [[nodiscard]] virtual TexturePixelFormat ReadTexturePixelFormat(u32 raw_handle) = 0; [[nodiscard]] virtual bool IsTexturePixelFormatInteger(u32 raw_handle) = 0; diff --git a/src/shader_recompiler/ir_opt/texture_pass.cpp b/src/shader_recompiler/ir_opt/texture_pass.cpp index cd306038ff..0d0144fcab 100644 --- a/src/shader_recompiler/ir_opt/texture_pass.cpp +++ b/src/shader_recompiler/ir_opt/texture_pass.cpp @@ -502,7 +502,7 @@ u32 GetTextureHandle(Environment& env, const ConstBufferAddr& cbuf) { const u32 lhs_raw{env.ReadCbufValue(cbuf.index, cbuf.offset) << cbuf.shift_left}; const u32 rhs_raw{env.ReadCbufValue(secondary_index, secondary_offset) << cbuf.secondary_shift_left}; - return env.ResolveBindlessHandle(cbuf.index, cbuf.offset, lhs_raw | rhs_raw); + return lhs_raw | rhs_raw; } [[maybe_unused]] TextureType ReadTextureType(Environment& env, const ConstBufferAddr& cbuf) { diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 7fd435438b..006bfc0a09 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -18,7 +18,6 @@ #include "video_core/renderer_vulkan/vk_pipeline_cache.h" #include "video_core/renderer_vulkan/vk_scheduler.h" #include "video_core/renderer_vulkan/vk_update_descriptor.h" -#include "video_core/shader_environment.h" #include "video_core/shader_notify.h" #include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -149,7 +148,6 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute, const auto& qmd{kepler_compute.launch_description}; const auto& cbufs{qmd.const_buffer_config}; const bool via_header_index{qmd.linked_tsc != 0}; - const u32 tic_limit{kepler_compute.regs.tic.limit}; const auto read_handle{[&](const auto& desc, u32 index) { ASSERT(((qmd.const_buffer_enable_mask >> desc.cbuf_index) & 1) != 0); const u32 index_offset{index << desc.size_shift}; @@ -164,17 +162,10 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute, secondary_offset}; const u32 lhs_raw{gpu_memory.Read(addr) << desc.shift_left}; const u32 rhs_raw{gpu_memory.Read(separate_addr) << desc.secondary_shift_left}; - const u32 combined{VideoCommon::ResolveBindlessHandleTable( - gpu_memory, addr, lhs_raw | rhs_raw, - TexturePair(lhs_raw | rhs_raw, via_header_index).first, tic_limit)}; - return TexturePair(combined, via_header_index); + return TexturePair(lhs_raw | rhs_raw, via_header_index); } } - const u32 single_raw{gpu_memory.Read(addr)}; - return TexturePair(VideoCommon::ResolveBindlessHandleTable( - gpu_memory, addr, single_raw, - TexturePair(single_raw, via_header_index).first, tic_limit), - via_header_index); + return TexturePair(gpu_memory.Read(addr), via_header_index); }}; const auto add_image{[&](const auto& desc, bool blacklist) { for (u32 index = 0; index < desc.count; ++index) { diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index d22c37fb74..5aae6712a0 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp @@ -281,37 +281,17 @@ std::optional GenericEnvironment::TryFindSize() { return std::nullopt; } -u32 ResolveBindlessHandleTable(Tegra::MemoryManager& gpu_memory, GPUVAddr record_addr, - u32 raw_handle, u32 tic_index, u32 tic_limit) { - static constexpr u32 HandleRecordSize = 16; - static constexpr u32 MaxHandleTableBytes = 64 * 1024; - - if (tic_index <= tic_limit) { - return raw_handle; - } - const u32 addr_low{gpu_memory.Read(record_addr)}; - const u32 addr_high{gpu_memory.Read(record_addr + 4)}; - const u32 table_size{gpu_memory.Read(record_addr + 8)}; - const GPUVAddr table_addr{(static_cast(addr_high) << 32) | - static_cast(addr_low)}; - if (table_addr == 0 || table_size < HandleRecordSize || table_size > MaxHandleTableBytes) { - return raw_handle; - } - const u32 count{table_size / HandleRecordSize}; - for (u32 i = 0; i < count; ++i) { - const GPUVAddr entry_addr{table_addr + static_cast(i) * HandleRecordSize}; - const u32 handle{gpu_memory.Read(entry_addr)}; - const u32 live{gpu_memory.Read(entry_addr + 4)}; - if (live != 0 && handle != 0 && handle <= tic_limit) { - return handle; - } - } - return raw_handle; -} - Tegra::Texture::TICEntry GenericEnvironment::ReadTextureInfo(GPUVAddr tic_addr, u32 tic_limit, bool via_header_index, u32 raw) { const auto handle{Tegra::Texture::TexturePair(raw, via_header_index)}; + if (handle.first > tic_limit) { + LOG_DEBUG(Shader, + "TIC index out of range: raw=0x{:08x} tic_index={} tsc_index={} tic_limit={} " + "tic_addr=0x{:x} via_header_index={} stage={} program_base=0x{:x} " + "start_address=0x{:x}", + raw, handle.first, handle.second, tic_limit, tic_addr, via_header_index, + static_cast(stage), program_base, start_address); + } ASSERT(handle.first <= tic_limit); const GPUVAddr descriptor_addr{tic_addr + handle.first * sizeof(Tegra::Texture::TICEntry)}; Tegra::Texture::TICEntry entry; @@ -459,24 +439,6 @@ u32 ComputeEnvironment::ReadCbufValue(u32 cbuf_index, u32 cbuf_offset) { return value; } -u32 ComputeEnvironment::ResolveBindlessHandle(u32 cbuf_index, u32 cbuf_offset, u32 raw_handle) { - const auto& regs{kepler_compute->regs}; - const auto& qmd{kepler_compute->launch_description}; - const auto pair{Tegra::Texture::TexturePair(raw_handle, qmd.linked_tsc != 0)}; - if (pair.first <= regs.tic.limit) { - return raw_handle; - } - if (((qmd.const_buffer_enable_mask.Value() >> cbuf_index) & 1) == 0) { - return raw_handle; - } - const auto& cbuf{qmd.const_buffer_config[cbuf_index]}; - if (cbuf_offset + 12 > cbuf.size) { - return raw_handle; - } - return ResolveBindlessHandleTable(*gpu_memory, cbuf.Address() + cbuf_offset, raw_handle, - pair.first, regs.tic.limit); -} - Shader::TextureType ComputeEnvironment::ReadTextureType(u32 handle) { const auto& regs{kepler_compute->regs}; const auto& qmd{kepler_compute->launch_description}; diff --git a/src/video_core/shader_environment.h b/src/video_core/shader_environment.h index d0b897c1a4..95c6d72f89 100644 --- a/src/video_core/shader_environment.h +++ b/src/video_core/shader_environment.h @@ -29,9 +29,6 @@ class Memorymanager; namespace VideoCommon { -[[nodiscard]] u32 ResolveBindlessHandleTable(Tegra::MemoryManager& gpu_memory, GPUVAddr record_addr, - u32 raw_handle, u32 tic_index, u32 tic_limit); - class GenericEnvironment : public Shader::Environment { public: explicit GenericEnvironment() = default; @@ -143,8 +140,6 @@ public: u32 ReadCbufValue(u32 cbuf_index, u32 cbuf_offset) override; - u32 ResolveBindlessHandle(u32 cbuf_index, u32 cbuf_offset, u32 raw_handle) override; - Shader::TextureType ReadTextureType(u32 handle) override; Shader::TexturePixelFormat ReadTexturePixelFormat(u32 handle) override;