Minor improvement to Vulkan pipeline state and bindings management (#3829)

* Minor improvement to Vulkan pipeline state and bindings management

* Clean up buffer textures too

* Use glBindTextureUnit
This commit is contained in:
gdkchan 2022-11-10 13:38:38 -03:00 committed by GitHub
parent c6d05301aa
commit a6a67a2b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 124 deletions

View file

@ -138,11 +138,6 @@ namespace Ryujinx.Graphics.Vulkan
public void SetImage(int binding, ITexture image, GAL.Format imageFormat)
{
if (image == null)
{
return;
}
if (image is TextureBuffer imageBuffer)
{
_bufferImageRefs[binding] = imageBuffer;
@ -152,6 +147,12 @@ namespace Ryujinx.Graphics.Vulkan
{
_imageRefs[binding] = view.GetView(imageFormat).GetIdentityImageView();
}
else
{
_imageRefs[binding] = null;
_bufferImageRefs[binding] = null;
_bufferImageFormats[binding] = default;
}
SignalDirty(DirtyFlags.Image);
}
@ -215,24 +216,23 @@ namespace Ryujinx.Graphics.Vulkan
public void SetTextureAndSampler(CommandBufferScoped cbs, ShaderStage stage, int binding, ITexture texture, ISampler sampler)
{
if (texture == null)
{
return;
}
if (texture is TextureBuffer textureBuffer)
{
_bufferTextureRefs[binding] = textureBuffer;
}
else
else if (texture is TextureView view)
{
TextureView view = (TextureView)texture;
view.Storage.InsertBarrier(cbs, AccessFlags.AccessShaderReadBit, stage.ConvertToPipelineStageFlags());
_textureRefs[binding] = view.GetImageView();
_samplerRefs[binding] = ((SamplerHolder)sampler)?.GetSampler();
}
else
{
_textureRefs[binding] = null;
_samplerRefs[binding] = null;
_bufferTextureRefs[binding] = null;
}
SignalDirty(DirtyFlags.Texture);
}