@@ -54,6 +54,43 @@ module GLSLType =
5454 { M00 = float32 m.M00; M01 = float32 m.M01; M02 = float32 m.M02; M03 = 0.0 f
5555 M10 = float32 m.M10; M11 = float32 m.M11; M12 = float32 m.M12; M13 = 0.0 f }
5656
57+ /// Type representing 2x4 matrices
58+ /// Only used for padding rows of 2x3 matrices
59+ [<Struct; StructLayout( LayoutKind.Sequential) >]
60+ type M24d =
61+ val M00 : float
62+ val M01 : float
63+ val M02 : float
64+ val M03 : float
65+ val M10 : float
66+ val M11 : float
67+ val M12 : float
68+ val M13 : float
69+
70+ static do PrimitiveValueConverter.addConverters [
71+ // padding for 2 row matrices
72+ ( fun ( i : M22f ) -> M24d & i ) :> obj
73+ ( fun ( i : M22d ) -> M24d & i ) :> obj
74+ ( fun ( i : M23f ) -> M24d & i ) :> obj
75+ ( fun ( i : M23d ) -> M24d & i ) :> obj
76+ ]
77+
78+ new ( m : inref < M22f >) =
79+ { M00 = float m.M00; M01 = float m.M01; M02 = 0.0 ; M03 = 0.0
80+ M10 = float m.M10; M11 = float m.M11; M12 = 0.0 ; M13 = 0.0 }
81+
82+ new ( m : inref < M22d >) =
83+ { M00 = m.M00; M01 = m.M01; M02 = 0.0 ; M03 = 0.0
84+ M10 = m.M10; M11 = m.M11; M12 = 0.0 ; M13 = 0.0 }
85+
86+ new ( m : inref < M23f >) =
87+ { M00 = float m.M00; M01 = float m.M01; M02 = float m.M02; M03 = 0.0
88+ M10 = float m.M10; M11 = float m.M11; M12 = float m.M12; M13 = 0.0 }
89+
90+ new ( m : inref < M23d >) =
91+ { M00 = m.M00; M01 = m.M01; M02 = m.M02; M03 = 0.0
92+ M10 = m.M10; M11 = m.M11; M12 = m.M12; M13 = 0.0 }
93+
5794 module Patterns =
5895 open TypeMeta
5996
@@ -64,6 +101,7 @@ module GLSLType =
64101 | MatrixOf r -> ValueSome r
65102 | _ ->
66103 if t = typeof< M24f> then ValueSome ( V2i( 4 , 2 ), typeof< float32>)
104+ elif t = typeof< M24d> then ValueSome ( V2i( 4 , 2 ), typeof< float>)
67105 else ValueNone
68106
69107 let toType =
@@ -83,7 +121,7 @@ module GLSLType =
83121
84122 Float( 16 ), typeof< float16>
85123 Float( 32 ), typeof< float32>
86- Float( 64 ), typeof< float32 >
124+ Float( 64 ), typeof< float >
87125
88126 Vec( 3 , Int( false , 8 )), typeof< C3b>
89127 Vec( 4 , Int( false , 8 )), typeof< C4b>
@@ -103,21 +141,21 @@ module GLSLType =
103141 Vec( 3 , Float( 32 )), typeof< V3f>
104142 Vec( 4 , Float( 32 )), typeof< V4f>
105143
106- Vec( 2 , Float( 64 )), typeof< V2f >
107- Vec( 3 , Float( 64 )), typeof< V3f >
108- Vec( 4 , Float( 64 )), typeof< V4f >
109-
110- Mat( 2 , 2 , Float( 32 )), typeof< Interop.M24f> // Matrix rows need to be padded to 4 elements according to std140
111- Mat( 2 , 3 , Float( 32 )), typeof< Interop.M24f>
112- Mat( 3 , 3 , Float( 32 )), typeof< M34f>
113- Mat( 3 , 4 , Float( 32 )), typeof< M34f>
114- Mat( 4 , 4 , Float( 32 )), typeof< M44f>
115-
116- Mat( 2 , 2 , Float( 64 )), typeof< Interop.M24f >
117- Mat( 2 , 3 , Float( 64 )), typeof< Interop.M24f >
118- Mat( 3 , 3 , Float( 64 )), typeof< M34f >
119- Mat( 3 , 4 , Float( 64 )), typeof< M34f >
120- Mat( 4 , 4 , Float( 64 )), typeof< M44f >
144+ Vec( 2 , Float( 64 )), typeof< V2d >
145+ Vec( 3 , Float( 64 )), typeof< V3d >
146+ Vec( 4 , Float( 64 )), typeof< V4d >
147+
148+ Mat( 2 , 2 , Float( 32 )), typeof< Interop.M24f> // Matrix rows need to be padded to 4 elements according to std140
149+ Mat( 2 , 3 , Float( 32 )), typeof< Interop.M24f>
150+ Mat( 3 , 3 , Float( 32 )), typeof< M34f>
151+ Mat( 3 , 4 , Float( 32 )), typeof< M34f>
152+ Mat( 4 , 4 , Float( 32 )), typeof< M44f>
153+
154+ Mat( 2 , 2 , Float( 64 )), typeof< M22d >
155+ Mat( 2 , 3 , Float( 64 )), typeof< Interop.M24d >
156+ Mat( 3 , 3 , Float( 64 )), typeof< M34d >
157+ Mat( 3 , 4 , Float( 64 )), typeof< M34d >
158+ Mat( 4 , 4 , Float( 64 )), typeof< M44d >
121159 ]
122160
123161 let rec sizeof ( t : GLSLType ) =
0 commit comments