Skip to content

Commit

Permalink
Error on creating Effect with byte array and range MonoGame#7794 (Mon…
Browse files Browse the repository at this point in the history
  • Loading branch information
bartimaeusnek authored Jun 6, 2024
1 parent 6417e82 commit b82f8fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion MonoGame.Framework/Graphics/Effect/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private MGFXHeader ReadHeader(byte[] effectCode, int index)
header.Version = (int)effectCode[index++];
header.Profile = (int)effectCode[index++];
header.EffectKey = BitConverter.ToInt32(effectCode, index); index += 4;
header.HeaderSize = index;
header.HeaderSize = 10;

if (header.Signature != MGFXHeader.MGFXSignature)
throw new Exception("This does not appear to be a MonoGame MGFX file!");
Expand Down
11 changes: 11 additions & 0 deletions Tests/Framework/Graphics/EffectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ namespace MonoGame.Tests.Graphics
[TestFixture]
internal class EffectTest : GraphicsDeviceTestFixtureBase
{
[Test]
public void EffectConstructorShouldAllowIndexAndCount()
{
byte[] mgfxo = EffectResource.BasicEffect.Bytecode;
var index = 100000;
var byteArray = new byte[index + mgfxo.Length];
mgfxo.CopyTo(byteArray, index);
Effect effect = null;
Assert.DoesNotThrow(() => { effect = new Effect(game.GraphicsDevice, byteArray, index, mgfxo.Length); });
effect.Dispose();
}

[Test]
public void EffectPassShouldSetTexture()
Expand Down

0 comments on commit b82f8fb

Please sign in to comment.