summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKosyrev Serge <_deepfire@feelingofgreen.ru>2018-09-19 01:54:55 +0300
committerKosyrev Serge <_deepfire@feelingofgreen.ru>2018-09-19 01:54:55 +0300
commiteef90e5765cbeb5d41b3db9f170ead03c5fd10bd (patch)
tree36ce08675e92ae57cb7ee87ac421706f534dd6b7
parentf5fe9f8ab7bd9e4ba14a990dd8cac3652f7e9dd3 (diff)
getCommands: make program output type depend on pipeline type
-rw-r--r--src/LambdaCube/Compiler/CoreToIR.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/LambdaCube/Compiler/CoreToIR.hs b/src/LambdaCube/Compiler/CoreToIR.hs
index 5d10ad79..30d05916 100644
--- a/src/LambdaCube/Compiler/CoreToIR.hs
+++ b/src/LambdaCube/Compiler/CoreToIR.hs
@@ -95,7 +95,7 @@ addTarget backend a tl = do
95 rt <- addL targetLens $ IR.RenderTarget $ Vector.fromList tl 95 rt <- addL targetLens $ IR.RenderTarget $ Vector.fromList tl
96 second (IR.SetRenderTarget rt:) <$> getCommands backend a 96 second (IR.SetRenderTarget rt:) <$> getCommands backend a
97 97
98getCommands :: Backend -> ExpTV{-FrameBuffer-} -> CG ([IR.Command],[IR.Command]) 98getCommands :: HasCallStack => Backend -> ExpTV{-FrameBuffer-} -> CG ([IR.Command],[IR.Command])
99getCommands backend e = case e of 99getCommands backend e = case e of
100 100
101 A1 "FrameBuffer" (ETuple a) -> return ([], [IR.ClearRenderTarget $ Vector.fromList $ map compFrameBuffer a]) 101 A1 "FrameBuffer" (ETuple a) -> return ([], [IR.ClearRenderTarget $ Vector.fromList $ map compFrameBuffer a])
@@ -112,11 +112,20 @@ getCommands backend e = case e of
112 112
113 pUniforms' = snd <$> Map.filter ((\case UTexture2D{} -> False; _ -> True) . fst) pUniforms 113 pUniforms' = snd <$> Map.filter ((\case UTexture2D{} -> False; _ -> True) . fst) pUniforms
114 114
115 imageSemantics = getSemantics e
116 imageTypes = getImageInputTypes e
117 outImageType
118 = case imageTypes of
119 [] -> error "Component-free pipelines are not supported."
120 [x] -> x
121 xs -> flip fromMaybe (lookup IR.Color $ zip imageSemantics xs) $
122 error "Multiple outputs, but no Color buffer?"
123
115 prg = IR.Program 124 prg = IR.Program
116 { IR.programUniforms = pUniforms' 125 { IR.programUniforms = pUniforms'
117 , IR.programStreams = Map.fromList $ zip vertexInput $ map (uncurry IR.Parameter) input 126 , IR.programStreams = Map.fromList $ zip vertexInput $ map (uncurry IR.Parameter) input
118 , IR.programInTextures = snd <$> Map.filter ((\case UUniform{} -> False; _ -> True) . fst) pUniforms 127 , IR.programInTextures = snd <$> Map.filter ((\case UUniform{} -> False; _ -> True) . fst) pUniforms
119 , IR.programOutput = pure $ IR.Parameter "f0" IR.V4F -- TODO 128 , IR.programOutput = pure $ IR.Parameter "f0" outImageType
120 , IR.vertexShader = show vertSrc 129 , IR.vertexShader = show vertSrc
121 , IR.geometryShader = mempty -- TODO 130 , IR.geometryShader = mempty -- TODO
122 , IR.fragmentShader = show fragSrc 131 , IR.fragmentShader = show fragSrc