lambdacube3d / lambdacube-ir

LambdaCube 3D intermediate representation of 3D graphics pipelines. See:
https://lambdacube3d.wordpress.com/2013/10/12/introducing-the-lambdacube-intermediate-representation/
8 stars 3 forks source link

src/LambdaCube/Compiler/CoreToIR.hs:(528,24)-(530,61): Non-exhaustive patterns in case #7

Open pippijn opened 3 years ago

pippijn commented 3 years ago

Reproducing test case (paste in editor.html to see the error):

makeFrame (time :: Float)
          (texture :: Texture)
          (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float))
    = imageFrame ((emptyColorImage (V4 0 0 0.4 1)))
  `overlay`
      prims
    & mapPrimitives (\(p,n,uvw) -> (p, V2 uvw%x (1 - uvw%y) ))
    & mapPrimitives (\(x) -> x)
    & rasterizePrimitives (TriangleCtx CullBack PolygonFill NoOffset LastVertex) ((Smooth))
    & mapFragments (\((uv)) -> ((texture2D (Sampler PointFilter MirroredRepeat texture) uv)))
    & accumulateWith ((ColorOp NoBlending (V4 True True True True)))

main = renderFrame $
   makeFrame (Uniform "time")
             (Texture2DSlot "diffuseTexture")
             (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw"))

The relevant part is mapPrimitives (\(x) -> x). I'm sure this code is wrong, but the error message isn't helping me understand why.

csabahruska commented 3 years ago

The graphics pipeline codegen is too rigid. It expects one or zero mapPrimitives operator.

pippijn commented 3 years ago

Ok, so any function composition should be done within that operator's argument. Thanks! I'll leave the issue open because I think the compiler should either tell the user about this or transform the input to function composition.