From 2dcc6333f8cbb959293832f52857bdaeab1918bf Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 20 Oct 2020 19:03:20 -0300 Subject: Fix image binding format (#1625) * Fix image binding format * XML doc --- Ryujinx.Graphics.Gpu/Image/Texture.cs | 13 ------------- Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs | 20 +++++++++++++++++++- Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs | 9 ++++++++- 3 files changed, 27 insertions(+), 15 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Image') diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index e3c3a30a..6778567c 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -897,19 +897,6 @@ namespace Ryujinx.Graphics.Gpu.Image Info.SamplesInY == info.SamplesInY) ? result : TextureViewCompatibility.Incompatible; } - /// - /// Checks if the view format is compatible with this texture format. - /// In general, the formats are considered compatible if the bytes per pixel values are equal, - /// but there are more complex rules for some formats, like compressed or depth-stencil formats. - /// This follows the host API copy compatibility rules. - /// - /// Texture information of the texture view - /// True if the formats are compatible, false otherwise - private bool ViewFormatCompatible(TextureInfo info) - { - return TextureCompatibility.FormatCompatible(Info.FormatInfo, info.FormatInfo); - } - /// /// Gets a texture of the specified target type from this texture. /// This can be used to get an array texture from a non-array texture and vice-versa. diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs index 175f8863..422b66e2 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs @@ -14,6 +14,11 @@ namespace Ryujinx.Graphics.Gpu.Image /// public Target Target { get; } + /// + /// For images, indicates the format specified on the shader. + /// + public Format Format { get; } + /// /// Shader texture handle. /// This is an index into the texture constant buffer. @@ -47,11 +52,13 @@ namespace Ryujinx.Graphics.Gpu.Image /// Constructs the texture binding information structure. /// /// The shader sampler target type + /// Format of the image as declared on the shader /// The shader texture handle (read index into the texture constant buffer) /// The texture's usage flags, indicating how it is used in the shader - public TextureBindingInfo(Target target, int handle, TextureUsageFlags flags) + public TextureBindingInfo(Target target, Format format, int handle, TextureUsageFlags flags) { Target = target; + Format = format; Handle = handle; IsBindless = false; @@ -62,6 +69,16 @@ namespace Ryujinx.Graphics.Gpu.Image Flags = flags; } + /// + /// Constructs the texture binding information structure. + /// + /// The shader sampler target type + /// The shader texture handle (read index into the texture constant buffer) + /// The texture's usage flags, indicating how it is used in the shader + public TextureBindingInfo(Target target, int handle, TextureUsageFlags flags) : this(target, (Format)0, handle, flags) + { + } + /// /// Constructs the bindless texture binding information structure. /// @@ -72,6 +89,7 @@ namespace Ryujinx.Graphics.Gpu.Image public TextureBindingInfo(Target target, int cbufSlot, int cbufOffset, TextureUsageFlags flags) { Target = target; + Format = 0; Handle = 0; IsBindless = true; diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index be78c827..e7800314 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -302,7 +302,14 @@ namespace Ryujinx.Graphics.Gpu.Image { _imageState[stageIndex][index].Texture = hostTexture; - _context.Renderer.Pipeline.SetImage(index, stage, hostTexture); + Format format = binding.Format; + + if (format == 0) + { + format = texture.Format; + } + + _context.Renderer.Pipeline.SetImage(index, stage, hostTexture, format); } } } -- cgit v1.2.3