Skip to content

Commit

Permalink
optimize ConcreteTextureCollection.PlatformApply() (#1605)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast authored May 24, 2024
1 parent b455aa9 commit 6191d4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ internal void PlatformApply()
{
GL.ActiveTexture(WebGLTextureUnit.TEXTURE0 + i);
GL.CheckGLError();
_targets[i] = ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>()._glTarget;
GL.BindTexture(((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>()._glTarget, ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>()._glTexture);
ConcreteTexture ctexture = ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>();
_targets[i] = ctexture._glTarget;
GL.BindTexture(ctexture._glTarget, ctexture._glTexture);
GL.CheckGLError();

_contextStrategy.Metrics_AddTextureCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ internal void PlatformApply(D3D11.CommonShaderStage shaderStage)

if (texture != null && !texture.IsDisposed)
{
shaderStage.SetShaderResource(i, ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>().GetShaderResourceView());
ConcreteTexture ctexture = ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>();
shaderStage.SetShaderResource(i, ctexture.GetShaderResourceView());

_contextStrategy.Metrics_AddTextureCount();
}
Expand Down
5 changes: 3 additions & 2 deletions MonoGame.Framework/Graphics/.GL/ConcreteTextureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ internal void PlatformApply()
{
GL.ActiveTexture(TextureUnit.Texture0 + i);
GL.CheckGLError();
_targets[i] = ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>()._glTarget;
GL.BindTexture(((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>()._glTarget, ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>()._glTexture);
ConcreteTexture ctexture = ((IPlatformTexture)texture).GetTextureStrategy<ConcreteTexture>();
_targets[i] = ctexture._glTarget;
GL.BindTexture(ctexture._glTarget, ctexture._glTexture);
GL.CheckGLError();

_contextStrategy.Metrics_AddTextureCount();
Expand Down

0 comments on commit 6191d4f

Please sign in to comment.