def test_detection_type_bools(self): glsl = """ #version 450 #extension GL_ARB_separate_shader_objects : enable layout({layout}, binding = 0) buffer Buffer {{ bool var1; bool[720][1280] var2; bvec2 var3; bvec3 var4; bvec4 var5; bvec3[5] var6; }}; void main() {{}} """ for layout in (Layout.STD140, Layout.STD430): # the vulkan spir-v compiler turns bools into uints expected_definition = Struct([ Scalar.uint(), Array(Scalar.uint(), (720, 1280), layout), Vector.uvec2(), Vector.uvec3(), Vector.uvec4(), Array(Vector.uvec3(), 5, layout) ], layout) shader = self.shader_from_txt(glsl.format(layout=layout), verbose=False) shader.inspect() detected_definition, _ = shader.code.get_block(0) equal = expected_definition.compare(detected_definition, quiet=True) self.assertTrue(equal)
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)