diff --git a/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Descriptors.cs b/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Descriptors.cs index 885b7f5..cdc3b6d 100644 --- a/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Descriptors.cs +++ b/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Descriptors.cs @@ -110,6 +110,8 @@ internal static unsafe partial class VulkanVideoPresenter DepthCompare: image.DepthCompare, Atomic: image.Atomic); + private static readonly System.Collections.Concurrent.ConcurrentDictionary _tracedTextureBindings = new(); + // Render-state discovery for one shader image; the view is acquired later with the draw. private TextureResource ResolveImageBinding(ImageResource image, uint[] words, ShaderProgramInfo program, int index) { @@ -127,11 +129,12 @@ internal static unsafe partial class VulkanVideoPresenter imageIdentifier = ImageRequestBuilders.ValidateTextureOwner(_imageCache, imageIdentifier, resolution); BindImage(imageIdentifier, storage); var descriptor = new TextureDescriptorWords(words); - if (ShouldTraceTextureBindings()) + if (ShouldTraceTextureBindings() && + (!_traceVolumeTextureBindingsOnly || image.Dimension == ImageDimension.Dim3D)) { var cached = _imageCache.GetImage(imageIdentifier); var description = cached.Description; - Console.Error.WriteLine( + var line = $"TextureBinding stage={program.Stage} hash=0x{program.Hash:X16} index={index} " + $"address=0x{new TextureDescriptorWords(words).BaseAddress:X16} " + $"descriptor={descriptor.BaseAddress:X16} size={descriptor.Width + 1}x{descriptor.Height + 1} " + @@ -139,7 +142,14 @@ internal static unsafe partial class VulkanVideoPresenter $"image=0x{description.Data.Address:X16} size=0x{description.Data.Size:X} " + $"extent={description.Extent.Width}x{description.Extent.Height} pitch={description.Pitch} " + $"guestFormat={(uint)description.GuestFormat} imageTile={(uint)description.TileMode} " + - $"backing={cached.Backing.Extent.Width}x{cached.Backing.Extent.Height} format={cached.Backing.Format}"); + $"backing={cached.Backing.Extent.Width}x{cached.Backing.Extent.Height} format={cached.Backing.Format} " + + $"depth={descriptor.Depth + 1} type={descriptor.Type} dcc={descriptor.MetadataCompress} " + + $"metadata=0x{descriptor.MetadataAddress << 8:X} metaKind={description.Metadata.Kind} " + + $"words={string.Join(',', words.Select(static word => word.ToString("X8")))}"; + if (!_traceVolumeTextureBindingsOnly || _tracedTextureBindings.TryAdd(line, 0)) + { + Console.Error.WriteLine(line); + } } return new TextureResource { diff --git a/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Draws.Recording.cs b/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Draws.Recording.cs index 24b12e0..08a48bb 100644 --- a/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Draws.Recording.cs +++ b/src/SharpEmu.Libs/VideoOut/VulkanVideoPresenter.Draws.Recording.cs @@ -91,10 +91,9 @@ internal static unsafe partial class VulkanVideoPresenter "1", StringComparison.Ordinal); private static readonly bool _traceTextureBindingsEnabled = - string.Equals( - Environment.GetEnvironmentVariable("SHARPEMU_TRACE_TEXTURE_BINDINGS"), - "1", - StringComparison.Ordinal); + Environment.GetEnvironmentVariable("SHARPEMU_TRACE_TEXTURE_BINDINGS") is "1" or "volume"; + private static readonly bool _traceVolumeTextureBindingsOnly = + Environment.GetEnvironmentVariable("SHARPEMU_TRACE_TEXTURE_BINDINGS") == "volume"; private static readonly uint _traceGuestImageWidth = uint.TryParse( Environment.GetEnvironmentVariable("SHARPEMU_TRACE_GUEST_IMAGE_WIDTH"),