From 3acea61ec05c54671e6e2b1254b35130a8b502c8 Mon Sep 17 00:00:00 2001 From: Csaba Hruska Date: Sat, 22 Sep 2018 12:13:15 +0200 Subject: support pipelines without color output --- lambdacube-compiler.cabal | 2 +- src/LambdaCube/Compiler/CoreToIR.hs | 16 +++++++--------- testdata/uniformparam02.out | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lambdacube-compiler.cabal b/lambdacube-compiler.cabal index 6d47d950..8edcd5d6 100644 --- a/lambdacube-compiler.cabal +++ b/lambdacube-compiler.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: lambdacube-compiler -version: 0.6.1.0 +version: 0.6.2.0 homepage: http://lambdacube3d.com synopsis: LambdaCube 3D is a DSL to program GPUs description: LambdaCube 3D is a domain specific language and library that makes it diff --git a/src/LambdaCube/Compiler/CoreToIR.hs b/src/LambdaCube/Compiler/CoreToIR.hs index feb1d6e2..357702f5 100644 --- a/src/LambdaCube/Compiler/CoreToIR.hs +++ b/src/LambdaCube/Compiler/CoreToIR.hs @@ -39,6 +39,7 @@ import qualified LambdaCube.Compiler.Core as I import LambdaCube.Compiler.Infer (neutType', makeCaseFunPars') import Debug.Trace +import Text.Printf import Data.Version import Paths_lambdacube_compiler (version) @@ -112,20 +113,17 @@ getCommands backend e = case e of pUniforms' = snd <$> Map.filter ((\case UTexture2D{} -> False; _ -> True) . fst) pUniforms - imageSemantics = getSemantics e - imageTypes = getImageInputTypes e - outImageType - = case imageTypes of - [] -> error "Component-free pipelines are not supported." - [x] -> x - xs -> flip fromMaybe (lookup IR.Color $ zip imageSemantics xs) $ - error "Multiple outputs, but no Color buffer?" + imageSemantics = getSemantics e + imageTypes = getImageInputTypes e + outputValues = case imageTypes of + [] -> error "Component-free pipelines are not supported." + xs -> take 1 [IR.Parameter "f0" ty | (IR.Color, ty) <- zip imageSemantics xs] -- TODO: support multiple output prg = IR.Program { IR.programUniforms = pUniforms' , IR.programStreams = Map.fromList $ zip vertexInput $ map (uncurry IR.Parameter) input , IR.programInTextures = snd <$> Map.filter ((\case UUniform{} -> False; _ -> True) . fst) pUniforms - , IR.programOutput = pure $ IR.Parameter "f0" outImageType + , IR.programOutput = Vector.fromList outputValues , IR.vertexShader = show vertSrc , IR.geometryShader = mempty -- TODO , IR.fragmentShader = show fragSrc diff --git a/testdata/uniformparam02.out b/testdata/uniformparam02.out index 65c6f23c..dc824ba3 100644 --- a/testdata/uniformparam02.out +++ b/testdata/uniformparam02.out @@ -18,7 +18,7 @@ Pipeline fromList [ ( "vi1" , Parameter { name = "position4" , ty = V4F } ) ] , programInTextures = fromList [] - , programOutput = [ Parameter { name = "f0" , ty = V4F } ] + , programOutput = [] , vertexShader = """ #version 330 core -- cgit v1.2.3