1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
|
-- generated file, do not modify!
-- 2016-11-14T21:30:02.094169000000Z
module LambdaCube.IR where
import Prelude
import Data.Generic
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Data.StrMap (StrMap(..))
import Data.Map (Map(..))
import Data.List (List(..))
import LambdaCube.LinearBase
import Data.Argonaut.Encode.Combinators ((~>), (:=))
import Data.Argonaut.Decode.Combinators ((.?))
import Data.Argonaut.Core (jsonEmptyObject)
import Data.Argonaut.Printer (printJson)
import Data.Argonaut.Encode (class EncodeJson, encodeJson)
import Data.Argonaut.Decode (class DecodeJson, decodeJson)
type StreamName = Int
type ProgramName = Int
type TextureName = Int
type SamplerName = Int
type UniformName = String
type SlotName = Int
type FrameBufferComponent = Int
type TextureUnit = Int
type RenderTargetName = Int
type TextureUnitMapping = StrMap TextureUnit
data ArrayValue
= VBoolArray (Array Bool)
| VIntArray (Array Int32)
| VWordArray (Array Word32)
| VFloatArray (Array Float)
data Value
= VBool Bool
| VV2B V2B
| VV3B V3B
| VV4B V4B
| VWord Word32
| VV2U V2U
| VV3U V3U
| VV4U V4U
| VInt Int32
| VV2I V2I
| VV3I V3I
| VV4I V4I
| VFloat Float
| VV2F V2F
| VV3F V3F
| VV4F V4F
| VM22F M22F
| VM23F M23F
| VM24F M24F
| VM32F M32F
| VM33F M33F
| VM34F M34F
| VM42F M42F
| VM43F M43F
| VM44F M44F
data InputType
= Bool
| V2B
| V3B
| V4B
| Word
| V2U
| V3U
| V4U
| Int
| V2I
| V3I
| V4I
| Float
| V2F
| V3F
| V4F
| M22F
| M23F
| M24F
| M32F
| M33F
| M34F
| M42F
| M43F
| M44F
| STexture1D
| STexture2D
| STextureCube
| STexture1DArray
| STexture2DArray
| STexture2DRect
| FTexture1D
| FTexture2D
| FTexture3D
| FTextureCube
| FTexture1DArray
| FTexture2DArray
| FTexture2DMS
| FTexture2DMSArray
| FTextureBuffer
| FTexture2DRect
| ITexture1D
| ITexture2D
| ITexture3D
| ITextureCube
| ITexture1DArray
| ITexture2DArray
| ITexture2DMS
| ITexture2DMSArray
| ITextureBuffer
| ITexture2DRect
| UTexture1D
| UTexture2D
| UTexture3D
| UTextureCube
| UTexture1DArray
| UTexture2DArray
| UTexture2DMS
| UTexture2DMSArray
| UTextureBuffer
| UTexture2DRect
data PointSpriteCoordOrigin
= LowerLeft
| UpperLeft
data PointSize
= PointSize Float
| ProgramPointSize
data PolygonOffset
= NoOffset
| Offset Float Float
data FrontFace
= CCW
| CW
data PolygonMode
= PolygonPoint PointSize
| PolygonLine Float
| PolygonFill
data ProvokingVertex
= FirstVertex
| LastVertex
data CullMode
= CullNone
| CullFront FrontFace
| CullBack FrontFace
data ComparisonFunction
= Never
| Less
| Equal
| Lequal
| Greater
| Notequal
| Gequal
| Always
type DepthFunction = ComparisonFunction
data StencilOperation
= OpZero
| OpKeep
| OpReplace
| OpIncr
| OpIncrWrap
| OpDecr
| OpDecrWrap
| OpInvert
data BlendEquation
= FuncAdd
| FuncSubtract
| FuncReverseSubtract
| Min
| Max
data BlendingFactor
= Zero
| One
| SrcColor
| OneMinusSrcColor
| DstColor
| OneMinusDstColor
| SrcAlpha
| OneMinusSrcAlpha
| DstAlpha
| OneMinusDstAlpha
| ConstantColor
| OneMinusConstantColor
| ConstantAlpha
| OneMinusConstantAlpha
| SrcAlphaSaturate
data LogicOperation
= Clear
| And
| AndReverse
| Copy
| AndInverted
| Noop
| Xor
| Or
| Nor
| Equiv
| Invert
| OrReverse
| CopyInverted
| OrInverted
| Nand
| Set
data StencilOps
= StencilOps
{ frontStencilOp :: StencilOperation
, backStencilOp :: StencilOperation
}
data StencilTest
= StencilTest
{ stencilComparision :: ComparisonFunction
, stencilReference :: Int32
, stencilMask :: Word32
}
data StencilTests
= StencilTests StencilTest StencilTest
data FetchPrimitive
= Points
| Lines
| Triangles
| LinesAdjacency
| TrianglesAdjacency
data OutputPrimitive
= TrianglesOutput
| LinesOutput
| PointsOutput
data ColorArity
= Red
| RG
| RGB
| RGBA
data Blending
= NoBlending
| BlendLogicOp LogicOperation
| Blend
{ colorEqSrc :: BlendEquation
, alphaEqSrc :: BlendEquation
, colorFSrc :: BlendingFactor
, colorFDst :: BlendingFactor
, alphaFSrc :: BlendingFactor
, alphaFDst :: BlendingFactor
, color :: V4F
}
data RasterContext
= PointCtx PointSize Float PointSpriteCoordOrigin
| LineCtx Float ProvokingVertex
| TriangleCtx CullMode PolygonMode PolygonOffset ProvokingVertex
data FragmentOperation
= DepthOp DepthFunction Bool
| StencilOp StencilTests StencilOps StencilOps
| ColorOp Blending Value
data AccumulationContext
= AccumulationContext
{ accViewportName :: Maybe String
, accOperations :: List FragmentOperation
}
data TextureDataType
= FloatT ColorArity
| IntT ColorArity
| WordT ColorArity
| ShadowT
data TextureType
= Texture1D TextureDataType Int
| Texture2D TextureDataType Int
| Texture3D TextureDataType
| TextureCube TextureDataType
| TextureRect TextureDataType
| Texture2DMS TextureDataType Int Int Bool
| TextureBuffer TextureDataType
data MipMap
= Mip Int Int
| NoMip
| AutoMip Int Int
data Filter
= Nearest
| Linear
| NearestMipmapNearest
| NearestMipmapLinear
| LinearMipmapNearest
| LinearMipmapLinear
data EdgeMode
= Repeat
| MirroredRepeat
| ClampToEdge
| ClampToBorder
data ImageSemantic
= Depth
| Stencil
| Color
data ImageRef
= TextureImage TextureName Int (Maybe Int)
| Framebuffer ImageSemantic
data ClearImage
= ClearImage
{ imageSemantic :: ImageSemantic
, clearValue :: Value
}
data Command
= SetRasterContext RasterContext
| SetAccumulationContext AccumulationContext
| SetRenderTarget RenderTargetName
| SetProgram ProgramName
| SetSamplerUniform UniformName TextureUnit
| SetTexture TextureUnit TextureName
| SetSampler TextureUnit (Maybe SamplerName)
| RenderSlot SlotName
| RenderStream StreamName
| ClearRenderTarget (Array ClearImage)
| GenerateMipMap TextureUnit
| SaveImage FrameBufferComponent ImageRef
| LoadImage ImageRef FrameBufferComponent
data SamplerDescriptor
= SamplerDescriptor
{ samplerWrapS :: EdgeMode
, samplerWrapT :: Maybe EdgeMode
, samplerWrapR :: Maybe EdgeMode
, samplerMinFilter :: Filter
, samplerMagFilter :: Filter
, samplerBorderColor :: Value
, samplerMinLod :: Maybe Float
, samplerMaxLod :: Maybe Float
, samplerLodBias :: Float
, samplerCompareFunc :: Maybe ComparisonFunction
}
data TextureDescriptor
= TextureDescriptor
{ textureType :: TextureType
, textureSize :: Value
, textureSemantic :: ImageSemantic
, textureSampler :: SamplerDescriptor
, textureBaseLevel :: Int
, textureMaxLevel :: Int
}
data Parameter
= Parameter
{ name :: String
, ty :: InputType
}
data Program
= Program
{ programUniforms :: StrMap InputType
, programStreams :: StrMap Parameter
, programInTextures :: StrMap InputType
, programOutput :: Array Parameter
, vertexShader :: String
, geometryShader :: Maybe String
, fragmentShader :: String
}
data Slot
= Slot
{ slotName :: String
, slotStreams :: StrMap InputType
, slotUniforms :: StrMap InputType
, slotPrimitive :: FetchPrimitive
, slotPrograms :: Array ProgramName
}
data StreamData
= StreamData
{ streamData :: StrMap ArrayValue
, streamType :: StrMap InputType
, streamPrimitive :: FetchPrimitive
, streamPrograms :: Array ProgramName
}
data TargetItem
= TargetItem
{ targetSemantic :: ImageSemantic
, targetRef :: Maybe ImageRef
}
data RenderTarget
= RenderTarget
{ renderTargets :: Array TargetItem
}
data Backend
= WebGL1
| OpenGL33
data Pipeline
= Pipeline
{ info :: String
, backend :: Backend
, textures :: Array TextureDescriptor
, samplers :: Array SamplerDescriptor
, targets :: Array RenderTarget
, programs :: Array Program
, slots :: Array Slot
, streams :: Array StreamData
, commands :: Array Command
}
derive instance genericInputType :: Generic InputType
instance showInputType :: Show InputType where show = gShow
instance eqInputType :: Eq InputType where eq = gEq
derive instance genericFetchPrimitive :: Generic FetchPrimitive
instance showFetchPrimitive :: Show FetchPrimitive where show = gShow
instance eqFetchPrimitive :: Eq FetchPrimitive where eq = gEq
derive instance genericColorArity :: Generic ColorArity
instance showColorArity :: Show ColorArity where show = gShow
instance eqColorArity :: Eq ColorArity where eq = gEq
derive instance genericTextureDataType :: Generic TextureDataType
instance showTextureDataType :: Show TextureDataType where show = gShow
instance eqTextureDataType :: Eq TextureDataType where eq = gEq
derive instance genericImageSemantic :: Generic ImageSemantic
instance showImageSemantic :: Show ImageSemantic where show = gShow
instance eqImageSemantic :: Eq ImageSemantic where eq = gEq
derive instance genericPipeline :: Generic Pipeline
instance showPipeline :: Show Pipeline where show = gShow
instance eqPipeline :: Eq Pipeline where eq = gEq
instance encodeJsonArrayValue :: EncodeJson ArrayValue where
encodeJson v = case v of
VBoolArray arg0 -> "tag" := "VBoolArray" ~> "arg0" := arg0 ~> jsonEmptyObject
VIntArray arg0 -> "tag" := "VIntArray" ~> "arg0" := arg0 ~> jsonEmptyObject
VWordArray arg0 -> "tag" := "VWordArray" ~> "arg0" := arg0 ~> jsonEmptyObject
VFloatArray arg0 -> "tag" := "VFloatArray" ~> "arg0" := arg0 ~> jsonEmptyObject
instance decodeJsonArrayValue :: DecodeJson ArrayValue where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"VBoolArray" -> VBoolArray <$> obj .? "arg0"
"VIntArray" -> VIntArray <$> obj .? "arg0"
"VWordArray" -> VWordArray <$> obj .? "arg0"
"VFloatArray" -> VFloatArray <$> obj .? "arg0"
_ -> Left ("decodeJsonArrayValue - unknown tag: " <> tag)
instance encodeJsonValue :: EncodeJson Value where
encodeJson v = case v of
VBool arg0 -> "tag" := "VBool" ~> "arg0" := arg0 ~> jsonEmptyObject
VV2B arg0 -> "tag" := "VV2B" ~> "arg0" := arg0 ~> jsonEmptyObject
VV3B arg0 -> "tag" := "VV3B" ~> "arg0" := arg0 ~> jsonEmptyObject
VV4B arg0 -> "tag" := "VV4B" ~> "arg0" := arg0 ~> jsonEmptyObject
VWord arg0 -> "tag" := "VWord" ~> "arg0" := arg0 ~> jsonEmptyObject
VV2U arg0 -> "tag" := "VV2U" ~> "arg0" := arg0 ~> jsonEmptyObject
VV3U arg0 -> "tag" := "VV3U" ~> "arg0" := arg0 ~> jsonEmptyObject
VV4U arg0 -> "tag" := "VV4U" ~> "arg0" := arg0 ~> jsonEmptyObject
VInt arg0 -> "tag" := "VInt" ~> "arg0" := arg0 ~> jsonEmptyObject
VV2I arg0 -> "tag" := "VV2I" ~> "arg0" := arg0 ~> jsonEmptyObject
VV3I arg0 -> "tag" := "VV3I" ~> "arg0" := arg0 ~> jsonEmptyObject
VV4I arg0 -> "tag" := "VV4I" ~> "arg0" := arg0 ~> jsonEmptyObject
VFloat arg0 -> "tag" := "VFloat" ~> "arg0" := arg0 ~> jsonEmptyObject
VV2F arg0 -> "tag" := "VV2F" ~> "arg0" := arg0 ~> jsonEmptyObject
VV3F arg0 -> "tag" := "VV3F" ~> "arg0" := arg0 ~> jsonEmptyObject
VV4F arg0 -> "tag" := "VV4F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM22F arg0 -> "tag" := "VM22F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM23F arg0 -> "tag" := "VM23F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM24F arg0 -> "tag" := "VM24F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM32F arg0 -> "tag" := "VM32F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM33F arg0 -> "tag" := "VM33F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM34F arg0 -> "tag" := "VM34F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM42F arg0 -> "tag" := "VM42F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM43F arg0 -> "tag" := "VM43F" ~> "arg0" := arg0 ~> jsonEmptyObject
VM44F arg0 -> "tag" := "VM44F" ~> "arg0" := arg0 ~> jsonEmptyObject
instance decodeJsonValue :: DecodeJson Value where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"VBool" -> VBool <$> obj .? "arg0"
"VV2B" -> VV2B <$> obj .? "arg0"
"VV3B" -> VV3B <$> obj .? "arg0"
"VV4B" -> VV4B <$> obj .? "arg0"
"VWord" -> VWord <$> obj .? "arg0"
"VV2U" -> VV2U <$> obj .? "arg0"
"VV3U" -> VV3U <$> obj .? "arg0"
"VV4U" -> VV4U <$> obj .? "arg0"
"VInt" -> VInt <$> obj .? "arg0"
"VV2I" -> VV2I <$> obj .? "arg0"
"VV3I" -> VV3I <$> obj .? "arg0"
"VV4I" -> VV4I <$> obj .? "arg0"
"VFloat" -> VFloat <$> obj .? "arg0"
"VV2F" -> VV2F <$> obj .? "arg0"
"VV3F" -> VV3F <$> obj .? "arg0"
"VV4F" -> VV4F <$> obj .? "arg0"
"VM22F" -> VM22F <$> obj .? "arg0"
"VM23F" -> VM23F <$> obj .? "arg0"
"VM24F" -> VM24F <$> obj .? "arg0"
"VM32F" -> VM32F <$> obj .? "arg0"
"VM33F" -> VM33F <$> obj .? "arg0"
"VM34F" -> VM34F <$> obj .? "arg0"
"VM42F" -> VM42F <$> obj .? "arg0"
"VM43F" -> VM43F <$> obj .? "arg0"
"VM44F" -> VM44F <$> obj .? "arg0"
_ -> Left ("decodeJsonValue - unknown tag: " <> tag)
instance encodeJsonInputType :: EncodeJson InputType where
encodeJson v = case v of
Bool -> "tag" := "Bool" ~> jsonEmptyObject
V2B -> "tag" := "V2B" ~> jsonEmptyObject
V3B -> "tag" := "V3B" ~> jsonEmptyObject
V4B -> "tag" := "V4B" ~> jsonEmptyObject
Word -> "tag" := "Word" ~> jsonEmptyObject
V2U -> "tag" := "V2U" ~> jsonEmptyObject
V3U -> "tag" := "V3U" ~> jsonEmptyObject
V4U -> "tag" := "V4U" ~> jsonEmptyObject
Int -> "tag" := "Int" ~> jsonEmptyObject
V2I -> "tag" := "V2I" ~> jsonEmptyObject
V3I -> "tag" := "V3I" ~> jsonEmptyObject
V4I -> "tag" := "V4I" ~> jsonEmptyObject
Float -> "tag" := "Float" ~> jsonEmptyObject
V2F -> "tag" := "V2F" ~> jsonEmptyObject
V3F -> "tag" := "V3F" ~> jsonEmptyObject
V4F -> "tag" := "V4F" ~> jsonEmptyObject
M22F -> "tag" := "M22F" ~> jsonEmptyObject
M23F -> "tag" := "M23F" ~> jsonEmptyObject
M24F -> "tag" := "M24F" ~> jsonEmptyObject
M32F -> "tag" := "M32F" ~> jsonEmptyObject
M33F -> "tag" := "M33F" ~> jsonEmptyObject
M34F -> "tag" := "M34F" ~> jsonEmptyObject
M42F -> "tag" := "M42F" ~> jsonEmptyObject
M43F -> "tag" := "M43F" ~> jsonEmptyObject
M44F -> "tag" := "M44F" ~> jsonEmptyObject
STexture1D -> "tag" := "STexture1D" ~> jsonEmptyObject
STexture2D -> "tag" := "STexture2D" ~> jsonEmptyObject
STextureCube -> "tag" := "STextureCube" ~> jsonEmptyObject
STexture1DArray -> "tag" := "STexture1DArray" ~> jsonEmptyObject
STexture2DArray -> "tag" := "STexture2DArray" ~> jsonEmptyObject
STexture2DRect -> "tag" := "STexture2DRect" ~> jsonEmptyObject
FTexture1D -> "tag" := "FTexture1D" ~> jsonEmptyObject
FTexture2D -> "tag" := "FTexture2D" ~> jsonEmptyObject
FTexture3D -> "tag" := "FTexture3D" ~> jsonEmptyObject
FTextureCube -> "tag" := "FTextureCube" ~> jsonEmptyObject
FTexture1DArray -> "tag" := "FTexture1DArray" ~> jsonEmptyObject
FTexture2DArray -> "tag" := "FTexture2DArray" ~> jsonEmptyObject
FTexture2DMS -> "tag" := "FTexture2DMS" ~> jsonEmptyObject
FTexture2DMSArray -> "tag" := "FTexture2DMSArray" ~> jsonEmptyObject
FTextureBuffer -> "tag" := "FTextureBuffer" ~> jsonEmptyObject
FTexture2DRect -> "tag" := "FTexture2DRect" ~> jsonEmptyObject
ITexture1D -> "tag" := "ITexture1D" ~> jsonEmptyObject
ITexture2D -> "tag" := "ITexture2D" ~> jsonEmptyObject
ITexture3D -> "tag" := "ITexture3D" ~> jsonEmptyObject
ITextureCube -> "tag" := "ITextureCube" ~> jsonEmptyObject
ITexture1DArray -> "tag" := "ITexture1DArray" ~> jsonEmptyObject
ITexture2DArray -> "tag" := "ITexture2DArray" ~> jsonEmptyObject
ITexture2DMS -> "tag" := "ITexture2DMS" ~> jsonEmptyObject
ITexture2DMSArray -> "tag" := "ITexture2DMSArray" ~> jsonEmptyObject
ITextureBuffer -> "tag" := "ITextureBuffer" ~> jsonEmptyObject
ITexture2DRect -> "tag" := "ITexture2DRect" ~> jsonEmptyObject
UTexture1D -> "tag" := "UTexture1D" ~> jsonEmptyObject
UTexture2D -> "tag" := "UTexture2D" ~> jsonEmptyObject
UTexture3D -> "tag" := "UTexture3D" ~> jsonEmptyObject
UTextureCube -> "tag" := "UTextureCube" ~> jsonEmptyObject
UTexture1DArray -> "tag" := "UTexture1DArray" ~> jsonEmptyObject
UTexture2DArray -> "tag" := "UTexture2DArray" ~> jsonEmptyObject
UTexture2DMS -> "tag" := "UTexture2DMS" ~> jsonEmptyObject
UTexture2DMSArray -> "tag" := "UTexture2DMSArray" ~> jsonEmptyObject
UTextureBuffer -> "tag" := "UTextureBuffer" ~> jsonEmptyObject
UTexture2DRect -> "tag" := "UTexture2DRect" ~> jsonEmptyObject
instance decodeJsonInputType :: DecodeJson InputType where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Bool" -> pure Bool
"V2B" -> pure V2B
"V3B" -> pure V3B
"V4B" -> pure V4B
"Word" -> pure Word
"V2U" -> pure V2U
"V3U" -> pure V3U
"V4U" -> pure V4U
"Int" -> pure Int
"V2I" -> pure V2I
"V3I" -> pure V3I
"V4I" -> pure V4I
"Float" -> pure Float
"V2F" -> pure V2F
"V3F" -> pure V3F
"V4F" -> pure V4F
"M22F" -> pure M22F
"M23F" -> pure M23F
"M24F" -> pure M24F
"M32F" -> pure M32F
"M33F" -> pure M33F
"M34F" -> pure M34F
"M42F" -> pure M42F
"M43F" -> pure M43F
"M44F" -> pure M44F
"STexture1D" -> pure STexture1D
"STexture2D" -> pure STexture2D
"STextureCube" -> pure STextureCube
"STexture1DArray" -> pure STexture1DArray
"STexture2DArray" -> pure STexture2DArray
"STexture2DRect" -> pure STexture2DRect
"FTexture1D" -> pure FTexture1D
"FTexture2D" -> pure FTexture2D
"FTexture3D" -> pure FTexture3D
"FTextureCube" -> pure FTextureCube
"FTexture1DArray" -> pure FTexture1DArray
"FTexture2DArray" -> pure FTexture2DArray
"FTexture2DMS" -> pure FTexture2DMS
"FTexture2DMSArray" -> pure FTexture2DMSArray
"FTextureBuffer" -> pure FTextureBuffer
"FTexture2DRect" -> pure FTexture2DRect
"ITexture1D" -> pure ITexture1D
"ITexture2D" -> pure ITexture2D
"ITexture3D" -> pure ITexture3D
"ITextureCube" -> pure ITextureCube
"ITexture1DArray" -> pure ITexture1DArray
"ITexture2DArray" -> pure ITexture2DArray
"ITexture2DMS" -> pure ITexture2DMS
"ITexture2DMSArray" -> pure ITexture2DMSArray
"ITextureBuffer" -> pure ITextureBuffer
"ITexture2DRect" -> pure ITexture2DRect
"UTexture1D" -> pure UTexture1D
"UTexture2D" -> pure UTexture2D
"UTexture3D" -> pure UTexture3D
"UTextureCube" -> pure UTextureCube
"UTexture1DArray" -> pure UTexture1DArray
"UTexture2DArray" -> pure UTexture2DArray
"UTexture2DMS" -> pure UTexture2DMS
"UTexture2DMSArray" -> pure UTexture2DMSArray
"UTextureBuffer" -> pure UTextureBuffer
"UTexture2DRect" -> pure UTexture2DRect
_ -> Left ("decodeJsonInputType - unknown tag: " <> tag)
instance encodeJsonPointSpriteCoordOrigin :: EncodeJson PointSpriteCoordOrigin where
encodeJson v = case v of
LowerLeft -> "tag" := "LowerLeft" ~> jsonEmptyObject
UpperLeft -> "tag" := "UpperLeft" ~> jsonEmptyObject
instance decodeJsonPointSpriteCoordOrigin :: DecodeJson PointSpriteCoordOrigin where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"LowerLeft" -> pure LowerLeft
"UpperLeft" -> pure UpperLeft
_ -> Left ("decodeJsonPointSpriteCoordOrigin - unknown tag: " <> tag)
instance encodeJsonPointSize :: EncodeJson PointSize where
encodeJson v = case v of
PointSize arg0 -> "tag" := "PointSize" ~> "arg0" := arg0 ~> jsonEmptyObject
ProgramPointSize -> "tag" := "ProgramPointSize" ~> jsonEmptyObject
instance decodeJsonPointSize :: DecodeJson PointSize where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"PointSize" -> PointSize <$> obj .? "arg0"
"ProgramPointSize" -> pure ProgramPointSize
_ -> Left ("decodeJsonPointSize - unknown tag: " <> tag)
instance encodeJsonPolygonOffset :: EncodeJson PolygonOffset where
encodeJson v = case v of
NoOffset -> "tag" := "NoOffset" ~> jsonEmptyObject
Offset arg0 arg1 -> "tag" := "Offset" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
instance decodeJsonPolygonOffset :: DecodeJson PolygonOffset where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"NoOffset" -> pure NoOffset
"Offset" -> Offset <$> obj .? "arg0" <*> obj .? "arg1"
_ -> Left ("decodeJsonPolygonOffset - unknown tag: " <> tag)
instance encodeJsonFrontFace :: EncodeJson FrontFace where
encodeJson v = case v of
CCW -> "tag" := "CCW" ~> jsonEmptyObject
CW -> "tag" := "CW" ~> jsonEmptyObject
instance decodeJsonFrontFace :: DecodeJson FrontFace where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"CCW" -> pure CCW
"CW" -> pure CW
_ -> Left ("decodeJsonFrontFace - unknown tag: " <> tag)
instance encodeJsonPolygonMode :: EncodeJson PolygonMode where
encodeJson v = case v of
PolygonPoint arg0 -> "tag" := "PolygonPoint" ~> "arg0" := arg0 ~> jsonEmptyObject
PolygonLine arg0 -> "tag" := "PolygonLine" ~> "arg0" := arg0 ~> jsonEmptyObject
PolygonFill -> "tag" := "PolygonFill" ~> jsonEmptyObject
instance decodeJsonPolygonMode :: DecodeJson PolygonMode where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"PolygonPoint" -> PolygonPoint <$> obj .? "arg0"
"PolygonLine" -> PolygonLine <$> obj .? "arg0"
"PolygonFill" -> pure PolygonFill
_ -> Left ("decodeJsonPolygonMode - unknown tag: " <> tag)
instance encodeJsonProvokingVertex :: EncodeJson ProvokingVertex where
encodeJson v = case v of
FirstVertex -> "tag" := "FirstVertex" ~> jsonEmptyObject
LastVertex -> "tag" := "LastVertex" ~> jsonEmptyObject
instance decodeJsonProvokingVertex :: DecodeJson ProvokingVertex where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"FirstVertex" -> pure FirstVertex
"LastVertex" -> pure LastVertex
_ -> Left ("decodeJsonProvokingVertex - unknown tag: " <> tag)
instance encodeJsonCullMode :: EncodeJson CullMode where
encodeJson v = case v of
CullNone -> "tag" := "CullNone" ~> jsonEmptyObject
CullFront arg0 -> "tag" := "CullFront" ~> "arg0" := arg0 ~> jsonEmptyObject
CullBack arg0 -> "tag" := "CullBack" ~> "arg0" := arg0 ~> jsonEmptyObject
instance decodeJsonCullMode :: DecodeJson CullMode where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"CullNone" -> pure CullNone
"CullFront" -> CullFront <$> obj .? "arg0"
"CullBack" -> CullBack <$> obj .? "arg0"
_ -> Left ("decodeJsonCullMode - unknown tag: " <> tag)
instance encodeJsonComparisonFunction :: EncodeJson ComparisonFunction where
encodeJson v = case v of
Never -> "tag" := "Never" ~> jsonEmptyObject
Less -> "tag" := "Less" ~> jsonEmptyObject
Equal -> "tag" := "Equal" ~> jsonEmptyObject
Lequal -> "tag" := "Lequal" ~> jsonEmptyObject
Greater -> "tag" := "Greater" ~> jsonEmptyObject
Notequal -> "tag" := "Notequal" ~> jsonEmptyObject
Gequal -> "tag" := "Gequal" ~> jsonEmptyObject
Always -> "tag" := "Always" ~> jsonEmptyObject
instance decodeJsonComparisonFunction :: DecodeJson ComparisonFunction where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Never" -> pure Never
"Less" -> pure Less
"Equal" -> pure Equal
"Lequal" -> pure Lequal
"Greater" -> pure Greater
"Notequal" -> pure Notequal
"Gequal" -> pure Gequal
"Always" -> pure Always
_ -> Left ("decodeJsonComparisonFunction - unknown tag: " <> tag)
instance encodeJsonStencilOperation :: EncodeJson StencilOperation where
encodeJson v = case v of
OpZero -> "tag" := "OpZero" ~> jsonEmptyObject
OpKeep -> "tag" := "OpKeep" ~> jsonEmptyObject
OpReplace -> "tag" := "OpReplace" ~> jsonEmptyObject
OpIncr -> "tag" := "OpIncr" ~> jsonEmptyObject
OpIncrWrap -> "tag" := "OpIncrWrap" ~> jsonEmptyObject
OpDecr -> "tag" := "OpDecr" ~> jsonEmptyObject
OpDecrWrap -> "tag" := "OpDecrWrap" ~> jsonEmptyObject
OpInvert -> "tag" := "OpInvert" ~> jsonEmptyObject
instance decodeJsonStencilOperation :: DecodeJson StencilOperation where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"OpZero" -> pure OpZero
"OpKeep" -> pure OpKeep
"OpReplace" -> pure OpReplace
"OpIncr" -> pure OpIncr
"OpIncrWrap" -> pure OpIncrWrap
"OpDecr" -> pure OpDecr
"OpDecrWrap" -> pure OpDecrWrap
"OpInvert" -> pure OpInvert
_ -> Left ("decodeJsonStencilOperation - unknown tag: " <> tag)
instance encodeJsonBlendEquation :: EncodeJson BlendEquation where
encodeJson v = case v of
FuncAdd -> "tag" := "FuncAdd" ~> jsonEmptyObject
FuncSubtract -> "tag" := "FuncSubtract" ~> jsonEmptyObject
FuncReverseSubtract -> "tag" := "FuncReverseSubtract" ~> jsonEmptyObject
Min -> "tag" := "Min" ~> jsonEmptyObject
Max -> "tag" := "Max" ~> jsonEmptyObject
instance decodeJsonBlendEquation :: DecodeJson BlendEquation where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"FuncAdd" -> pure FuncAdd
"FuncSubtract" -> pure FuncSubtract
"FuncReverseSubtract" -> pure FuncReverseSubtract
"Min" -> pure Min
"Max" -> pure Max
_ -> Left ("decodeJsonBlendEquation - unknown tag: " <> tag)
instance encodeJsonBlendingFactor :: EncodeJson BlendingFactor where
encodeJson v = case v of
Zero -> "tag" := "Zero" ~> jsonEmptyObject
One -> "tag" := "One" ~> jsonEmptyObject
SrcColor -> "tag" := "SrcColor" ~> jsonEmptyObject
OneMinusSrcColor -> "tag" := "OneMinusSrcColor" ~> jsonEmptyObject
DstColor -> "tag" := "DstColor" ~> jsonEmptyObject
OneMinusDstColor -> "tag" := "OneMinusDstColor" ~> jsonEmptyObject
SrcAlpha -> "tag" := "SrcAlpha" ~> jsonEmptyObject
OneMinusSrcAlpha -> "tag" := "OneMinusSrcAlpha" ~> jsonEmptyObject
DstAlpha -> "tag" := "DstAlpha" ~> jsonEmptyObject
OneMinusDstAlpha -> "tag" := "OneMinusDstAlpha" ~> jsonEmptyObject
ConstantColor -> "tag" := "ConstantColor" ~> jsonEmptyObject
OneMinusConstantColor -> "tag" := "OneMinusConstantColor" ~> jsonEmptyObject
ConstantAlpha -> "tag" := "ConstantAlpha" ~> jsonEmptyObject
OneMinusConstantAlpha -> "tag" := "OneMinusConstantAlpha" ~> jsonEmptyObject
SrcAlphaSaturate -> "tag" := "SrcAlphaSaturate" ~> jsonEmptyObject
instance decodeJsonBlendingFactor :: DecodeJson BlendingFactor where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Zero" -> pure Zero
"One" -> pure One
"SrcColor" -> pure SrcColor
"OneMinusSrcColor" -> pure OneMinusSrcColor
"DstColor" -> pure DstColor
"OneMinusDstColor" -> pure OneMinusDstColor
"SrcAlpha" -> pure SrcAlpha
"OneMinusSrcAlpha" -> pure OneMinusSrcAlpha
"DstAlpha" -> pure DstAlpha
"OneMinusDstAlpha" -> pure OneMinusDstAlpha
"ConstantColor" -> pure ConstantColor
"OneMinusConstantColor" -> pure OneMinusConstantColor
"ConstantAlpha" -> pure ConstantAlpha
"OneMinusConstantAlpha" -> pure OneMinusConstantAlpha
"SrcAlphaSaturate" -> pure SrcAlphaSaturate
_ -> Left ("decodeJsonBlendingFactor - unknown tag: " <> tag)
instance encodeJsonLogicOperation :: EncodeJson LogicOperation where
encodeJson v = case v of
Clear -> "tag" := "Clear" ~> jsonEmptyObject
And -> "tag" := "And" ~> jsonEmptyObject
AndReverse -> "tag" := "AndReverse" ~> jsonEmptyObject
Copy -> "tag" := "Copy" ~> jsonEmptyObject
AndInverted -> "tag" := "AndInverted" ~> jsonEmptyObject
Noop -> "tag" := "Noop" ~> jsonEmptyObject
Xor -> "tag" := "Xor" ~> jsonEmptyObject
Or -> "tag" := "Or" ~> jsonEmptyObject
Nor -> "tag" := "Nor" ~> jsonEmptyObject
Equiv -> "tag" := "Equiv" ~> jsonEmptyObject
Invert -> "tag" := "Invert" ~> jsonEmptyObject
OrReverse -> "tag" := "OrReverse" ~> jsonEmptyObject
CopyInverted -> "tag" := "CopyInverted" ~> jsonEmptyObject
OrInverted -> "tag" := "OrInverted" ~> jsonEmptyObject
Nand -> "tag" := "Nand" ~> jsonEmptyObject
Set -> "tag" := "Set" ~> jsonEmptyObject
instance decodeJsonLogicOperation :: DecodeJson LogicOperation where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Clear" -> pure Clear
"And" -> pure And
"AndReverse" -> pure AndReverse
"Copy" -> pure Copy
"AndInverted" -> pure AndInverted
"Noop" -> pure Noop
"Xor" -> pure Xor
"Or" -> pure Or
"Nor" -> pure Nor
"Equiv" -> pure Equiv
"Invert" -> pure Invert
"OrReverse" -> pure OrReverse
"CopyInverted" -> pure CopyInverted
"OrInverted" -> pure OrInverted
"Nand" -> pure Nand
"Set" -> pure Set
_ -> Left ("decodeJsonLogicOperation - unknown tag: " <> tag)
instance encodeJsonStencilOps :: EncodeJson StencilOps where
encodeJson v = case v of
StencilOps r ->
"tag" := "StencilOps" ~>
"frontStencilOp" := r.frontStencilOp ~>
"backStencilOp" := r.backStencilOp ~>
jsonEmptyObject
instance decodeJsonStencilOps :: DecodeJson StencilOps where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"StencilOps" -> do
frontStencilOp <- obj .? "frontStencilOp"
backStencilOp <- obj .? "backStencilOp"
pure $ StencilOps
{ frontStencilOp:frontStencilOp
, backStencilOp:backStencilOp
}
_ -> Left ("decodeJsonStencilOps - unknown tag: " <> tag)
instance encodeJsonStencilTest :: EncodeJson StencilTest where
encodeJson v = case v of
StencilTest r ->
"tag" := "StencilTest" ~>
"stencilComparision" := r.stencilComparision ~>
"stencilReference" := r.stencilReference ~>
"stencilMask" := r.stencilMask ~>
jsonEmptyObject
instance decodeJsonStencilTest :: DecodeJson StencilTest where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"StencilTest" -> do
stencilComparision <- obj .? "stencilComparision"
stencilReference <- obj .? "stencilReference"
stencilMask <- obj .? "stencilMask"
pure $ StencilTest
{ stencilComparision:stencilComparision
, stencilReference:stencilReference
, stencilMask:stencilMask
}
_ -> Left ("decodeJsonStencilTest - unknown tag: " <> tag)
instance encodeJsonStencilTests :: EncodeJson StencilTests where
encodeJson v = case v of
StencilTests arg0 arg1 -> "tag" := "StencilTests" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
instance decodeJsonStencilTests :: DecodeJson StencilTests where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"StencilTests" -> StencilTests <$> obj .? "arg0" <*> obj .? "arg1"
_ -> Left ("decodeJsonStencilTests - unknown tag: " <> tag)
instance encodeJsonFetchPrimitive :: EncodeJson FetchPrimitive where
encodeJson v = case v of
Points -> "tag" := "Points" ~> jsonEmptyObject
Lines -> "tag" := "Lines" ~> jsonEmptyObject
Triangles -> "tag" := "Triangles" ~> jsonEmptyObject
LinesAdjacency -> "tag" := "LinesAdjacency" ~> jsonEmptyObject
TrianglesAdjacency -> "tag" := "TrianglesAdjacency" ~> jsonEmptyObject
instance decodeJsonFetchPrimitive :: DecodeJson FetchPrimitive where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Points" -> pure Points
"Lines" -> pure Lines
"Triangles" -> pure Triangles
"LinesAdjacency" -> pure LinesAdjacency
"TrianglesAdjacency" -> pure TrianglesAdjacency
_ -> Left ("decodeJsonFetchPrimitive - unknown tag: " <> tag)
instance encodeJsonOutputPrimitive :: EncodeJson OutputPrimitive where
encodeJson v = case v of
TrianglesOutput -> "tag" := "TrianglesOutput" ~> jsonEmptyObject
LinesOutput -> "tag" := "LinesOutput" ~> jsonEmptyObject
PointsOutput -> "tag" := "PointsOutput" ~> jsonEmptyObject
instance decodeJsonOutputPrimitive :: DecodeJson OutputPrimitive where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"TrianglesOutput" -> pure TrianglesOutput
"LinesOutput" -> pure LinesOutput
"PointsOutput" -> pure PointsOutput
_ -> Left ("decodeJsonOutputPrimitive - unknown tag: " <> tag)
instance encodeJsonColorArity :: EncodeJson ColorArity where
encodeJson v = case v of
Red -> "tag" := "Red" ~> jsonEmptyObject
RG -> "tag" := "RG" ~> jsonEmptyObject
RGB -> "tag" := "RGB" ~> jsonEmptyObject
RGBA -> "tag" := "RGBA" ~> jsonEmptyObject
instance decodeJsonColorArity :: DecodeJson ColorArity where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Red" -> pure Red
"RG" -> pure RG
"RGB" -> pure RGB
"RGBA" -> pure RGBA
_ -> Left ("decodeJsonColorArity - unknown tag: " <> tag)
instance encodeJsonBlending :: EncodeJson Blending where
encodeJson v = case v of
NoBlending -> "tag" := "NoBlending" ~> jsonEmptyObject
BlendLogicOp arg0 -> "tag" := "BlendLogicOp" ~> "arg0" := arg0 ~> jsonEmptyObject
Blend r ->
"tag" := "Blend" ~>
"colorEqSrc" := r.colorEqSrc ~>
"alphaEqSrc" := r.alphaEqSrc ~>
"colorFSrc" := r.colorFSrc ~>
"colorFDst" := r.colorFDst ~>
"alphaFSrc" := r.alphaFSrc ~>
"alphaFDst" := r.alphaFDst ~>
"color" := r.color ~>
jsonEmptyObject
instance decodeJsonBlending :: DecodeJson Blending where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"NoBlending" -> pure NoBlending
"BlendLogicOp" -> BlendLogicOp <$> obj .? "arg0"
"Blend" -> do
colorEqSrc <- obj .? "colorEqSrc"
alphaEqSrc <- obj .? "alphaEqSrc"
colorFSrc <- obj .? "colorFSrc"
colorFDst <- obj .? "colorFDst"
alphaFSrc <- obj .? "alphaFSrc"
alphaFDst <- obj .? "alphaFDst"
color <- obj .? "color"
pure $ Blend
{ colorEqSrc:colorEqSrc
, alphaEqSrc:alphaEqSrc
, colorFSrc:colorFSrc
, colorFDst:colorFDst
, alphaFSrc:alphaFSrc
, alphaFDst:alphaFDst
, color:color
}
_ -> Left ("decodeJsonBlending - unknown tag: " <> tag)
instance encodeJsonRasterContext :: EncodeJson RasterContext where
encodeJson v = case v of
PointCtx arg0 arg1 arg2 -> "tag" := "PointCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject
LineCtx arg0 arg1 -> "tag" := "LineCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
TriangleCtx arg0 arg1 arg2 arg3 -> "tag" := "TriangleCtx" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> "arg3" := arg3 ~> jsonEmptyObject
instance decodeJsonRasterContext :: DecodeJson RasterContext where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"PointCtx" -> PointCtx <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2"
"LineCtx" -> LineCtx <$> obj .? "arg0" <*> obj .? "arg1"
"TriangleCtx" -> TriangleCtx <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" <*> obj .? "arg3"
_ -> Left ("decodeJsonRasterContext - unknown tag: " <> tag)
instance encodeJsonFragmentOperation :: EncodeJson FragmentOperation where
encodeJson v = case v of
DepthOp arg0 arg1 -> "tag" := "DepthOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
StencilOp arg0 arg1 arg2 -> "tag" := "StencilOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject
ColorOp arg0 arg1 -> "tag" := "ColorOp" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
instance decodeJsonFragmentOperation :: DecodeJson FragmentOperation where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"DepthOp" -> DepthOp <$> obj .? "arg0" <*> obj .? "arg1"
"StencilOp" -> StencilOp <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2"
"ColorOp" -> ColorOp <$> obj .? "arg0" <*> obj .? "arg1"
_ -> Left ("decodeJsonFragmentOperation - unknown tag: " <> tag)
instance encodeJsonAccumulationContext :: EncodeJson AccumulationContext where
encodeJson v = case v of
AccumulationContext r ->
"tag" := "AccumulationContext" ~>
"accViewportName" := r.accViewportName ~>
"accOperations" := r.accOperations ~>
jsonEmptyObject
instance decodeJsonAccumulationContext :: DecodeJson AccumulationContext where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"AccumulationContext" -> do
accViewportName <- obj .? "accViewportName"
accOperations <- obj .? "accOperations"
pure $ AccumulationContext
{ accViewportName:accViewportName
, accOperations:accOperations
}
_ -> Left ("decodeJsonAccumulationContext - unknown tag: " <> tag)
instance encodeJsonTextureDataType :: EncodeJson TextureDataType where
encodeJson v = case v of
FloatT arg0 -> "tag" := "FloatT" ~> "arg0" := arg0 ~> jsonEmptyObject
IntT arg0 -> "tag" := "IntT" ~> "arg0" := arg0 ~> jsonEmptyObject
WordT arg0 -> "tag" := "WordT" ~> "arg0" := arg0 ~> jsonEmptyObject
ShadowT -> "tag" := "ShadowT" ~> jsonEmptyObject
instance decodeJsonTextureDataType :: DecodeJson TextureDataType where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"FloatT" -> FloatT <$> obj .? "arg0"
"IntT" -> IntT <$> obj .? "arg0"
"WordT" -> WordT <$> obj .? "arg0"
"ShadowT" -> pure ShadowT
_ -> Left ("decodeJsonTextureDataType - unknown tag: " <> tag)
instance encodeJsonTextureType :: EncodeJson TextureType where
encodeJson v = case v of
Texture1D arg0 arg1 -> "tag" := "Texture1D" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
Texture2D arg0 arg1 -> "tag" := "Texture2D" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
Texture3D arg0 -> "tag" := "Texture3D" ~> "arg0" := arg0 ~> jsonEmptyObject
TextureCube arg0 -> "tag" := "TextureCube" ~> "arg0" := arg0 ~> jsonEmptyObject
TextureRect arg0 -> "tag" := "TextureRect" ~> "arg0" := arg0 ~> jsonEmptyObject
Texture2DMS arg0 arg1 arg2 arg3 -> "tag" := "Texture2DMS" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> "arg3" := arg3 ~> jsonEmptyObject
TextureBuffer arg0 -> "tag" := "TextureBuffer" ~> "arg0" := arg0 ~> jsonEmptyObject
instance decodeJsonTextureType :: DecodeJson TextureType where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Texture1D" -> Texture1D <$> obj .? "arg0" <*> obj .? "arg1"
"Texture2D" -> Texture2D <$> obj .? "arg0" <*> obj .? "arg1"
"Texture3D" -> Texture3D <$> obj .? "arg0"
"TextureCube" -> TextureCube <$> obj .? "arg0"
"TextureRect" -> TextureRect <$> obj .? "arg0"
"Texture2DMS" -> Texture2DMS <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2" <*> obj .? "arg3"
"TextureBuffer" -> TextureBuffer <$> obj .? "arg0"
_ -> Left ("decodeJsonTextureType - unknown tag: " <> tag)
instance encodeJsonMipMap :: EncodeJson MipMap where
encodeJson v = case v of
Mip arg0 arg1 -> "tag" := "Mip" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
NoMip -> "tag" := "NoMip" ~> jsonEmptyObject
AutoMip arg0 arg1 -> "tag" := "AutoMip" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
instance decodeJsonMipMap :: DecodeJson MipMap where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Mip" -> Mip <$> obj .? "arg0" <*> obj .? "arg1"
"NoMip" -> pure NoMip
"AutoMip" -> AutoMip <$> obj .? "arg0" <*> obj .? "arg1"
_ -> Left ("decodeJsonMipMap - unknown tag: " <> tag)
instance encodeJsonFilter :: EncodeJson Filter where
encodeJson v = case v of
Nearest -> "tag" := "Nearest" ~> jsonEmptyObject
Linear -> "tag" := "Linear" ~> jsonEmptyObject
NearestMipmapNearest -> "tag" := "NearestMipmapNearest" ~> jsonEmptyObject
NearestMipmapLinear -> "tag" := "NearestMipmapLinear" ~> jsonEmptyObject
LinearMipmapNearest -> "tag" := "LinearMipmapNearest" ~> jsonEmptyObject
LinearMipmapLinear -> "tag" := "LinearMipmapLinear" ~> jsonEmptyObject
instance decodeJsonFilter :: DecodeJson Filter where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Nearest" -> pure Nearest
"Linear" -> pure Linear
"NearestMipmapNearest" -> pure NearestMipmapNearest
"NearestMipmapLinear" -> pure NearestMipmapLinear
"LinearMipmapNearest" -> pure LinearMipmapNearest
"LinearMipmapLinear" -> pure LinearMipmapLinear
_ -> Left ("decodeJsonFilter - unknown tag: " <> tag)
instance encodeJsonEdgeMode :: EncodeJson EdgeMode where
encodeJson v = case v of
Repeat -> "tag" := "Repeat" ~> jsonEmptyObject
MirroredRepeat -> "tag" := "MirroredRepeat" ~> jsonEmptyObject
ClampToEdge -> "tag" := "ClampToEdge" ~> jsonEmptyObject
ClampToBorder -> "tag" := "ClampToBorder" ~> jsonEmptyObject
instance decodeJsonEdgeMode :: DecodeJson EdgeMode where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Repeat" -> pure Repeat
"MirroredRepeat" -> pure MirroredRepeat
"ClampToEdge" -> pure ClampToEdge
"ClampToBorder" -> pure ClampToBorder
_ -> Left ("decodeJsonEdgeMode - unknown tag: " <> tag)
instance encodeJsonImageSemantic :: EncodeJson ImageSemantic where
encodeJson v = case v of
Depth -> "tag" := "Depth" ~> jsonEmptyObject
Stencil -> "tag" := "Stencil" ~> jsonEmptyObject
Color -> "tag" := "Color" ~> jsonEmptyObject
instance decodeJsonImageSemantic :: DecodeJson ImageSemantic where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Depth" -> pure Depth
"Stencil" -> pure Stencil
"Color" -> pure Color
_ -> Left ("decodeJsonImageSemantic - unknown tag: " <> tag)
instance encodeJsonImageRef :: EncodeJson ImageRef where
encodeJson v = case v of
TextureImage arg0 arg1 arg2 -> "tag" := "TextureImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> "arg2" := arg2 ~> jsonEmptyObject
Framebuffer arg0 -> "tag" := "Framebuffer" ~> "arg0" := arg0 ~> jsonEmptyObject
instance decodeJsonImageRef :: DecodeJson ImageRef where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"TextureImage" -> TextureImage <$> obj .? "arg0" <*> obj .? "arg1" <*> obj .? "arg2"
"Framebuffer" -> Framebuffer <$> obj .? "arg0"
_ -> Left ("decodeJsonImageRef - unknown tag: " <> tag)
instance encodeJsonClearImage :: EncodeJson ClearImage where
encodeJson v = case v of
ClearImage r ->
"tag" := "ClearImage" ~>
"imageSemantic" := r.imageSemantic ~>
"clearValue" := r.clearValue ~>
jsonEmptyObject
instance decodeJsonClearImage :: DecodeJson ClearImage where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"ClearImage" -> do
imageSemantic <- obj .? "imageSemantic"
clearValue <- obj .? "clearValue"
pure $ ClearImage
{ imageSemantic:imageSemantic
, clearValue:clearValue
}
_ -> Left ("decodeJsonClearImage - unknown tag: " <> tag)
instance encodeJsonCommand :: EncodeJson Command where
encodeJson v = case v of
SetRasterContext arg0 -> "tag" := "SetRasterContext" ~> "arg0" := arg0 ~> jsonEmptyObject
SetAccumulationContext arg0 -> "tag" := "SetAccumulationContext" ~> "arg0" := arg0 ~> jsonEmptyObject
SetRenderTarget arg0 -> "tag" := "SetRenderTarget" ~> "arg0" := arg0 ~> jsonEmptyObject
SetProgram arg0 -> "tag" := "SetProgram" ~> "arg0" := arg0 ~> jsonEmptyObject
SetSamplerUniform arg0 arg1 -> "tag" := "SetSamplerUniform" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
SetTexture arg0 arg1 -> "tag" := "SetTexture" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
SetSampler arg0 arg1 -> "tag" := "SetSampler" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
RenderSlot arg0 -> "tag" := "RenderSlot" ~> "arg0" := arg0 ~> jsonEmptyObject
RenderStream arg0 -> "tag" := "RenderStream" ~> "arg0" := arg0 ~> jsonEmptyObject
ClearRenderTarget arg0 -> "tag" := "ClearRenderTarget" ~> "arg0" := arg0 ~> jsonEmptyObject
GenerateMipMap arg0 -> "tag" := "GenerateMipMap" ~> "arg0" := arg0 ~> jsonEmptyObject
SaveImage arg0 arg1 -> "tag" := "SaveImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
LoadImage arg0 arg1 -> "tag" := "LoadImage" ~> "arg0" := arg0 ~> "arg1" := arg1 ~> jsonEmptyObject
instance decodeJsonCommand :: DecodeJson Command where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"SetRasterContext" -> SetRasterContext <$> obj .? "arg0"
"SetAccumulationContext" -> SetAccumulationContext <$> obj .? "arg0"
"SetRenderTarget" -> SetRenderTarget <$> obj .? "arg0"
"SetProgram" -> SetProgram <$> obj .? "arg0"
"SetSamplerUniform" -> SetSamplerUniform <$> obj .? "arg0" <*> obj .? "arg1"
"SetTexture" -> SetTexture <$> obj .? "arg0" <*> obj .? "arg1"
"SetSampler" -> SetSampler <$> obj .? "arg0" <*> obj .? "arg1"
"RenderSlot" -> RenderSlot <$> obj .? "arg0"
"RenderStream" -> RenderStream <$> obj .? "arg0"
"ClearRenderTarget" -> ClearRenderTarget <$> obj .? "arg0"
"GenerateMipMap" -> GenerateMipMap <$> obj .? "arg0"
"SaveImage" -> SaveImage <$> obj .? "arg0" <*> obj .? "arg1"
"LoadImage" -> LoadImage <$> obj .? "arg0" <*> obj .? "arg1"
_ -> Left ("decodeJsonCommand - unknown tag: " <> tag)
instance encodeJsonSamplerDescriptor :: EncodeJson SamplerDescriptor where
encodeJson v = case v of
SamplerDescriptor r ->
"tag" := "SamplerDescriptor" ~>
"samplerWrapS" := r.samplerWrapS ~>
"samplerWrapT" := r.samplerWrapT ~>
"samplerWrapR" := r.samplerWrapR ~>
"samplerMinFilter" := r.samplerMinFilter ~>
"samplerMagFilter" := r.samplerMagFilter ~>
"samplerBorderColor" := r.samplerBorderColor ~>
"samplerMinLod" := r.samplerMinLod ~>
"samplerMaxLod" := r.samplerMaxLod ~>
"samplerLodBias" := r.samplerLodBias ~>
"samplerCompareFunc" := r.samplerCompareFunc ~>
jsonEmptyObject
instance decodeJsonSamplerDescriptor :: DecodeJson SamplerDescriptor where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"SamplerDescriptor" -> do
samplerWrapS <- obj .? "samplerWrapS"
samplerWrapT <- obj .? "samplerWrapT"
samplerWrapR <- obj .? "samplerWrapR"
samplerMinFilter <- obj .? "samplerMinFilter"
samplerMagFilter <- obj .? "samplerMagFilter"
samplerBorderColor <- obj .? "samplerBorderColor"
samplerMinLod <- obj .? "samplerMinLod"
samplerMaxLod <- obj .? "samplerMaxLod"
samplerLodBias <- obj .? "samplerLodBias"
samplerCompareFunc <- obj .? "samplerCompareFunc"
pure $ SamplerDescriptor
{ samplerWrapS:samplerWrapS
, samplerWrapT:samplerWrapT
, samplerWrapR:samplerWrapR
, samplerMinFilter:samplerMinFilter
, samplerMagFilter:samplerMagFilter
, samplerBorderColor:samplerBorderColor
, samplerMinLod:samplerMinLod
, samplerMaxLod:samplerMaxLod
, samplerLodBias:samplerLodBias
, samplerCompareFunc:samplerCompareFunc
}
_ -> Left ("decodeJsonSamplerDescriptor - unknown tag: " <> tag)
instance encodeJsonTextureDescriptor :: EncodeJson TextureDescriptor where
encodeJson v = case v of
TextureDescriptor r ->
"tag" := "TextureDescriptor" ~>
"textureType" := r.textureType ~>
"textureSize" := r.textureSize ~>
"textureSemantic" := r.textureSemantic ~>
"textureSampler" := r.textureSampler ~>
"textureBaseLevel" := r.textureBaseLevel ~>
"textureMaxLevel" := r.textureMaxLevel ~>
jsonEmptyObject
instance decodeJsonTextureDescriptor :: DecodeJson TextureDescriptor where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"TextureDescriptor" -> do
textureType <- obj .? "textureType"
textureSize <- obj .? "textureSize"
textureSemantic <- obj .? "textureSemantic"
textureSampler <- obj .? "textureSampler"
textureBaseLevel <- obj .? "textureBaseLevel"
textureMaxLevel <- obj .? "textureMaxLevel"
pure $ TextureDescriptor
{ textureType:textureType
, textureSize:textureSize
, textureSemantic:textureSemantic
, textureSampler:textureSampler
, textureBaseLevel:textureBaseLevel
, textureMaxLevel:textureMaxLevel
}
_ -> Left ("decodeJsonTextureDescriptor - unknown tag: " <> tag)
instance encodeJsonParameter :: EncodeJson Parameter where
encodeJson v = case v of
Parameter r ->
"tag" := "Parameter" ~>
"name" := r.name ~>
"ty" := r.ty ~>
jsonEmptyObject
instance decodeJsonParameter :: DecodeJson Parameter where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Parameter" -> do
name <- obj .? "name"
ty <- obj .? "ty"
pure $ Parameter
{ name:name
, ty:ty
}
_ -> Left ("decodeJsonParameter - unknown tag: " <> tag)
instance encodeJsonProgram :: EncodeJson Program where
encodeJson v = case v of
Program r ->
"tag" := "Program" ~>
"programUniforms" := r.programUniforms ~>
"programStreams" := r.programStreams ~>
"programInTextures" := r.programInTextures ~>
"programOutput" := r.programOutput ~>
"vertexShader" := r.vertexShader ~>
"geometryShader" := r.geometryShader ~>
"fragmentShader" := r.fragmentShader ~>
jsonEmptyObject
instance decodeJsonProgram :: DecodeJson Program where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Program" -> do
programUniforms <- obj .? "programUniforms"
programStreams <- obj .? "programStreams"
programInTextures <- obj .? "programInTextures"
programOutput <- obj .? "programOutput"
vertexShader <- obj .? "vertexShader"
geometryShader <- obj .? "geometryShader"
fragmentShader <- obj .? "fragmentShader"
pure $ Program
{ programUniforms:programUniforms
, programStreams:programStreams
, programInTextures:programInTextures
, programOutput:programOutput
, vertexShader:vertexShader
, geometryShader:geometryShader
, fragmentShader:fragmentShader
}
_ -> Left ("decodeJsonProgram - unknown tag: " <> tag)
instance encodeJsonSlot :: EncodeJson Slot where
encodeJson v = case v of
Slot r ->
"tag" := "Slot" ~>
"slotName" := r.slotName ~>
"slotStreams" := r.slotStreams ~>
"slotUniforms" := r.slotUniforms ~>
"slotPrimitive" := r.slotPrimitive ~>
"slotPrograms" := r.slotPrograms ~>
jsonEmptyObject
instance decodeJsonSlot :: DecodeJson Slot where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Slot" -> do
slotName <- obj .? "slotName"
slotStreams <- obj .? "slotStreams"
slotUniforms <- obj .? "slotUniforms"
slotPrimitive <- obj .? "slotPrimitive"
slotPrograms <- obj .? "slotPrograms"
pure $ Slot
{ slotName:slotName
, slotStreams:slotStreams
, slotUniforms:slotUniforms
, slotPrimitive:slotPrimitive
, slotPrograms:slotPrograms
}
_ -> Left ("decodeJsonSlot - unknown tag: " <> tag)
instance encodeJsonStreamData :: EncodeJson StreamData where
encodeJson v = case v of
StreamData r ->
"tag" := "StreamData" ~>
"streamData" := r.streamData ~>
"streamType" := r.streamType ~>
"streamPrimitive" := r.streamPrimitive ~>
"streamPrograms" := r.streamPrograms ~>
jsonEmptyObject
instance decodeJsonStreamData :: DecodeJson StreamData where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"StreamData" -> do
streamData <- obj .? "streamData"
streamType <- obj .? "streamType"
streamPrimitive <- obj .? "streamPrimitive"
streamPrograms <- obj .? "streamPrograms"
pure $ StreamData
{ streamData:streamData
, streamType:streamType
, streamPrimitive:streamPrimitive
, streamPrograms:streamPrograms
}
_ -> Left ("decodeJsonStreamData - unknown tag: " <> tag)
instance encodeJsonTargetItem :: EncodeJson TargetItem where
encodeJson v = case v of
TargetItem r ->
"tag" := "TargetItem" ~>
"targetSemantic" := r.targetSemantic ~>
"targetRef" := r.targetRef ~>
jsonEmptyObject
instance decodeJsonTargetItem :: DecodeJson TargetItem where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"TargetItem" -> do
targetSemantic <- obj .? "targetSemantic"
targetRef <- obj .? "targetRef"
pure $ TargetItem
{ targetSemantic:targetSemantic
, targetRef:targetRef
}
_ -> Left ("decodeJsonTargetItem - unknown tag: " <> tag)
instance encodeJsonRenderTarget :: EncodeJson RenderTarget where
encodeJson v = case v of
RenderTarget r ->
"tag" := "RenderTarget" ~>
"renderTargets" := r.renderTargets ~>
jsonEmptyObject
instance decodeJsonRenderTarget :: DecodeJson RenderTarget where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"RenderTarget" -> do
renderTargets <- obj .? "renderTargets"
pure $ RenderTarget
{ renderTargets:renderTargets
}
_ -> Left ("decodeJsonRenderTarget - unknown tag: " <> tag)
instance encodeJsonBackend :: EncodeJson Backend where
encodeJson v = case v of
WebGL1 -> "tag" := "WebGL1" ~> jsonEmptyObject
OpenGL33 -> "tag" := "OpenGL33" ~> jsonEmptyObject
instance decodeJsonBackend :: DecodeJson Backend where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"WebGL1" -> pure WebGL1
"OpenGL33" -> pure OpenGL33
_ -> Left ("decodeJsonBackend - unknown tag: " <> tag)
instance encodeJsonPipeline :: EncodeJson Pipeline where
encodeJson v = case v of
Pipeline r ->
"tag" := "Pipeline" ~>
"info" := r.info ~>
"backend" := r.backend ~>
"textures" := r.textures ~>
"samplers" := r.samplers ~>
"targets" := r.targets ~>
"programs" := r.programs ~>
"slots" := r.slots ~>
"streams" := r.streams ~>
"commands" := r.commands ~>
jsonEmptyObject
instance decodeJsonPipeline :: DecodeJson Pipeline where
decodeJson json = do
obj <- decodeJson json
tag <- obj .? "tag"
case tag of
"Pipeline" -> do
info <- obj .? "info"
backend <- obj .? "backend"
textures <- obj .? "textures"
samplers <- obj .? "samplers"
targets <- obj .? "targets"
programs <- obj .? "programs"
slots <- obj .? "slots"
streams <- obj .? "streams"
commands <- obj .? "commands"
pure $ Pipeline
{ info:info
, backend:backend
, textures:textures
, samplers:samplers
, targets:targets
, programs:programs
, slots:slots
, streams:streams
, commands:commands
}
_ -> Left ("decodeJsonPipeline - unknown tag: " <> tag)
|