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