Skip to content

Commit e75618a

Browse files
committed
tests: Add avm2/pixelbender_rsqrt test
1 parent 43cb67f commit e75618a

File tree

6 files changed

+86
-0
lines changed

6 files changed

+86
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package {
2+
import flash.display.*;
3+
import flash.geom.*;
4+
5+
public class Test extends MovieClip {
6+
[Embed(source = "rsqrt.pbj", mimeType="application/octet-stream")]
7+
public static var ShaderBytes: Class;
8+
9+
public function Test() {
10+
testParameter(0.0);
11+
testParameter(1.0);
12+
testParameter(5.0);
13+
testParameter(9.0);
14+
testParameter(16.0);
15+
testParameter(256.0);
16+
testParameter(-1.0);
17+
testParameter(-16.0);
18+
}
19+
20+
private function testParameter(value:Number) {
21+
trace("Input: " + value);
22+
var input = new BitmapData(1, 1);
23+
var shaderJob = new ShaderJob(new Shader(new ShaderBytes()), input);
24+
25+
shaderJob.shader.data.inputValue.value = [value];
26+
27+
try {
28+
shaderJob.start(true);
29+
trace("Result: " + input.getPixel32(0, 0).toString(16));
30+
} catch (e) {
31+
trace("Error while starting: " + e);
32+
}
33+
trace("=================");
34+
}
35+
}
36+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Input: 0
2+
Result: ffffff00
3+
=================
4+
Input: 1
5+
Result: ffffff00
6+
=================
7+
Input: 5
8+
Result: ffff7200
9+
=================
10+
Input: 9
11+
Result: ffff5500
12+
=================
13+
Input: 16
14+
Result: ffff4000
15+
=================
16+
Input: 256
17+
Result: ffff1000
18+
=================
19+
Input: -1
20+
Result: ffff0000
21+
=================
22+
Input: -16
23+
Result: ffff0000
24+
=================
190 Bytes
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<languageVersion : 1.0;>
2+
3+
kernel rsqrt
4+
< namespace : "Ruffle Tests";
5+
vendor : "Kamil Jarosz";
6+
version : 1;
7+
>
8+
{
9+
input image4 src;
10+
output pixel4 dst;
11+
12+
parameter float inputValue
13+
<
14+
defaultValue:1.0;
15+
>;
16+
17+
void
18+
evaluatePixel()
19+
{
20+
dst = pixel4(1, inverseSqrt(inputValue), 0, 1);
21+
}
22+
}
1.96 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
num_ticks = 1
2+
3+
[player_options]
4+
with_renderer = { optional = false, sample_count = 4 }

0 commit comments

Comments
 (0)