Skip to content

Commit

Permalink
Remove double iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Jun 21, 2023
1 parent 1ceae4b commit 53d00ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions osu.Framework/Graphics/OpenGL/Shaders/GLShader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ private protected virtual bool CompileInternal()

if (layout.Elements.Any(e => e.Kind == ResourceKind.TextureReadOnly || e.Kind == ResourceKind.TextureReadWrite))
{
ResourceLayoutElementDescription textureDesc = layout.Elements.First(e => e.Kind == ResourceKind.TextureReadOnly || e.Kind == ResourceKind.TextureReadWrite);
ResourceLayoutElementDescription textureElement = layout.Elements.First(e => e.Kind == ResourceKind.TextureReadOnly || e.Kind == ResourceKind.TextureReadWrite);

if (layout.Elements.All(e => e.Kind != ResourceKind.Sampler))
throw new ProgramLinkingFailedException(name, $"Texture {textureDesc.Name} has no associated sampler.");
throw new ProgramLinkingFailedException(name, $"Texture {textureElement.Name} has no associated sampler.");

var textureElement = layout.Elements.First(e => e.Kind == ResourceKind.TextureReadOnly || e.Kind == ResourceKind.TextureReadWrite);
textureUniforms.Add(new Uniform<int>(renderer, this, textureElement.Name, GL.GetUniformLocation(this, textureElement.Name))
{
Value = textureIndex++
Expand Down
5 changes: 3 additions & 2 deletions osu.Framework/Graphics/Veldrid/Shaders/VeldridShader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ private void compile()

if (layout.Elements.Any(e => e.Kind == ResourceKind.TextureReadOnly || e.Kind == ResourceKind.TextureReadWrite))
{
ResourceLayoutElementDescription textureDesc = layout.Elements.First(e => e.Kind == ResourceKind.TextureReadOnly || e.Kind == ResourceKind.TextureReadWrite);
ResourceLayoutElementDescription textureElement = layout.Elements.First(e => e.Kind == ResourceKind.TextureReadOnly || e.Kind == ResourceKind.TextureReadWrite);

if (layout.Elements.All(e => e.Kind != ResourceKind.Sampler))
throw new InvalidOperationException($"Texture {textureDesc.Name} has no associated sampler.");
throw new InvalidOperationException($"Texture {textureElement.Name} has no associated sampler.");

textureLayouts.Add(new VeldridUniformLayout(set, renderer.Factory.CreateResourceLayout(layout)));
}
Expand Down

0 comments on commit 53d00ee

Please sign in to comment.