コード例 #1
0
ファイル: transfer_in.py プロジェクト: osanj/lava
    def test_arb_example_std140(self):
        layout = Layout.STD430

        struct_a = Struct(
            [
                Scalar.int(),
                Vector.uvec2()  # actually bvec2
            ],
            layout,
            type_name="structA")

        struct_b = Struct([
            Vector.uvec3(),
            Vector.vec2(),
            Array(Scalar.float(), 2, layout),
            Vector.vec2(),
            Array(Matrix(3, 3, DataType.FLOAT, layout), 2, layout)
        ],
                          layout,
                          type_name="structB")

        container = Struct([
            Scalar.float(),
            Vector.vec2(),
            Vector.vec3(), struct_a,
            Scalar.float(),
            Array(Scalar.float(), 2, layout),
            Matrix(2, 3, DataType.FLOAT, layout),
            Array(struct_b, 2, layout)
        ], layout)

        self.run_test(container, [struct_a, struct_b],
                      BufferUsage.STORAGE_BUFFER)
コード例 #2
0
    def test_manually(self):
        # byte cache test
        buffer_usage = BufferUsage.STORAGE_BUFFER
        buffer_layout = Layout.STD430
        buffer_order = Order.ROW_MAJOR

        struct1 = Struct([Vector.vec3(), Vector.ivec2()],
                         buffer_layout,
                         member_names=["a", "b"],
                         type_name="structB")
        struct2 = Struct(
            [Scalar.double(), Scalar.double(), struct1],
            buffer_layout,
            type_name="structC")

        structs = [struct1, struct2]

        variables = [
            Scalar.uint(),
            Array(Vector.vec2(), (5, 2, 3), buffer_layout),
            Array(Scalar.float(), 5, buffer_layout),
            struct2,  # this struct needs padding at the end
            Scalar.uint(),
            Array(struct1, (2, 3), buffer_layout)
        ]

        container = Struct(variables, buffer_layout, type_name="block")

        cache = ByteCache(container)

        print("")
        print("")
        pprint.pprint(cache.values)
        print(cache[-1][0][0]["a"])
        print("")
        print("")
        pprint.pprint(cache)
        print(cache[-1][0][0])
        print("")
        print("")
        pprint.pprint(cache.get_as_dict())