Fatal Exception On Drawing with Alpha

Started by Calin Leafshade, Sat 30/08/2014 17:18:12

Previous topic - Next topic

Calin Leafshade

I just got this error:

---------------------------
Illegal exception
---------------------------
An exception 0xC0000094 occurred in ACWIN.EXE at EIP = 0x0046FC3C ; program pointer is +1004, ACI version 3.3.1.1167 CR, gtags (132,511)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.

in "GlobalScript.asc", line 216


Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK   
---------------------------

It occurs when drawing a transparent sprite with alpha onto another 32bit sprite at very specific transparency values. 50 works fine but 58 crashes it. 80 also crashes it.

Any ideas?

Crimson Wizard

0xC0000094, division by zero :P.

Might be some mistake in engine calculations.

Crimson Wizard

Drawing random sprite does not reproduce this.
Can you share more details about what were you doing (like were you using DrawingSurface.DrawImage?), or better a demo game that crashes stably?

Calin Leafshade

I'll make a test case to see if i can reproduce it more reliably.

Crimson Wizard

Sorry for nagging, but do you have just any clues about when this happens? A crash dump maybe?

I am planning to make a proper update to 3.3.0 (with fixed letterbox game), and thinking that I could fix this bug as well (if it is present in 3.3.0).

Crimson Wizard

#5
I found there's a bug in 3.3.0 that makes resulting alpha value overflow with particular combinations of src & dest alphas and overall transparency.

This may be reproduced in following way:
1. A blank (white) room background;
2. One big sprite with gradient of any RGB that changes alpha value from 255 to 0.
3. One simple sprite with alpha = 255.
4. Test room script:
Spoiler

Code: ags

Overlay *o;
DynamicSprite *spr;
int trans;
void Redraw()
{
	if (spr)
		spr.Delete();
	spr = DynamicSprite.CreateFromExistingSprite(1, true);
	DrawingSurface *ds = spr.GetDrawingSurface();
	ds.DrawImage(0, 50, 2, trans);
	ds.Release();
	o = Overlay.CreateGraphical(0, 0, spr.Graphic,  true);
}

function room_AfterFadeIn()
{
	trans = 0;
	Redraw();
}

function on_key_press(eKeyCode keycode)
{
	if (keycode == eKeyEquals && trans < 100)
	{
		trans++;
		Redraw();
	}
	else if (keycode == eKeyHyphen && trans > 0)
	{
		trans--;
		Redraw();
	}
}

[close]
Sprite 1 is an alpha gradient sprite, sprite 2 is a simple sprite.

Result: with certain 'trans' values there are explicitly visible thin stripes on overlay with unexpected colors.
Depending on sprites some combinations give completely transparent areas (where they should not be), others - wrong hues.

I don't have any crashes though, so not completely sure if this is related, but may be.

Crimson Wizard

#6
Ok, I finally reproduced the crash.
Test game:
http://www.mediafire.com/download/a5dz3y3sq54szyl/test_blend_bug.zip

Occurs with transparency = 99.

UPD: Okay, I fixed the crash; the other bug I mentioned is still there, and I am looking into fixing it.

Monsieur OUXX

Quote from: Crimson Wizard on Thu 13/11/2014 13:58:38
I fixed the crash; the other bug I mentioned is still there, and I am looking into fixing it.
You rulez.
 

Crimson Wizard

#8
Quote from: Crimson Wizard on Thu 13/11/2014 13:58:38
UPD: Okay, I fixed the crash; the other bug I mentioned is still there, and I am looking into fixing it.
Ok, this fixed now too. I am very happy today, because that annoyed me a lot. :)

SMF spam blocked by CleanTalk