X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect_chain_test.cpp;fp=effect_chain_test.cpp;h=b7877f5686fa706d662d53d9002d1336fe3dd22f;hp=551cdbcaabd607d1cc50f762f00190e1b99a3816;hb=8ee9712bae3cff206b3e3205748633edb33cbbcf;hpb=e683d4e49549b2d4c6906d2ebc4184904f4fe9f8 diff --git a/effect_chain_test.cpp b/effect_chain_test.cpp index 551cdbc..b7877f5 100644 --- a/effect_chain_test.cpp +++ b/effect_chain_test.cpp @@ -1547,4 +1547,37 @@ TEST(ComputeShaderTest, Render8BitTo8Bit) { expect_equal(data, out_data, 3, 2); } +// A compute shader to mirror the inputs, in 2x2 blocks. +class MirrorComputeEffect : public Effect { +public: + MirrorComputeEffect() {} + string effect_type_id() const override { return "MirrorComputeEffect"; } + bool is_compute_shader() const override { return true; } + string output_fragment_shader() override { return read_file("mirror.comp"); } + void get_compute_dimensions(unsigned output_width, unsigned output_height, + unsigned *x, unsigned *y, unsigned *z) const override { + *x = output_width / 2; + *y = output_height / 2; + *z = 1; + } +}; + +TEST(ComputeShaderTest, Mirror) { + float data[] = { + 0.0f, 0.25f, 0.3f, 0.8f, + 0.75f, 1.0f, 1.0f, 0.2f, + }; + float expected_data[] = { + 0.8f, 0.3f, 0.25f, 0.0f, + 0.2f, 1.0f, 1.0f, 0.75f, + }; + float out_data[8]; + EffectChainTester tester(data, 4, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + tester.get_chain()->add_effect(new MirrorComputeEffect()); + tester.get_chain()->add_effect(new OneToOneEffect()); + tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR); + + expect_equal(expected_data, out_data, 4, 2); +} + } // namespace movit