Пример #1
0
    def test_copy(self):
        data = np.arange(128, dtype=np.float32)
        definition = Struct([Array(ScalarFloat(), len(data), Layout.STD140)], Layout.STD140)

        buffer_a = lv.BufferCPU(self.session, definition, lv.BufferCPU.USAGE_STORAGE)
        buffer_b = lv.BufferCPU(self.session, definition, lv.BufferCPU.USAGE_STORAGE)

        buffer_a[0] = data
        buffer_a.flush()
        buffer_a.copy_to(buffer_b)
        buffer_b.fetch()

        self.assertTrue((buffer_a[0] == buffer_b[0]).all())
Пример #2
0
    def test_definition_check(self):
        glsl = """
            #version 450
            #extension GL_ARB_separate_shader_objects : enable

            layout(std140, binding = 0) buffer BufferA {
                float[720][1280][3] image;
            };

            void main() {}
            """
        shader = self.shader_from_txt(glsl, verbose=False)
        incompatible_definition = Struct(
            [Array(ScalarFloat(),
                   (721, 1281, 4), Layout.STD140)], Layout.STD140)
        incompatible_buffer = lv.BufferCPU(self.session,
                                           incompatible_definition,
                                           lv.BufferCPU.USAGE_STORAGE)
        self.assertRaises(LavaError,
                          lv.Stage,
                          shader=shader,
                          bindings={0: incompatible_buffer})