Remove unnecessary uniforms

This commit is contained in:
jgk
2021-06-10 18:07:26 +02:00
parent 95f8e57e45
commit 02511afa80
10 changed files with 69 additions and 93 deletions
+4 -6
View File
@@ -37,7 +37,7 @@ import Linear.Matrix
import Linear.V4
extractProgAndUnis :: FullShader a -> (Program,UniformLocation)
extractProgAndUnis s = (_shaderProgram s, _shaderUniform s)
extractProgAndUnis s = (_shaderProgram s, _shaderMatrixUniform s)
pokeShaders :: [FullShader a] -> F.FoldM IO a [Int]
pokeShaders = traverse pokeShader
@@ -124,7 +124,7 @@ makeShader s shaderlist alocs pm renStrat = do
(prog,unis) <- makeSourcedShader s shaderlist
vaob <- setupVAO alocs
return $ FullShader { _shaderProgram = prog
, _shaderUniform = unis
, _shaderMatrixUniform = unis
, _shaderVAO = vaob
, _shaderPokeStrategy = renStrat
, _shaderDrawPrimitive = pm
@@ -184,7 +184,6 @@ addUniforms uniStrings shad = do
uniLocs <- mapM (uniformLocation $ _shaderProgram shad) uniStrings
return $ shad & shaderCustomUnis %~ (++ uniLocs)
shaderTypeExt :: ShaderType -> String
shaderTypeExt VertexShader = ".vert"
shaderTypeExt GeometryShader = ".geom"
@@ -202,7 +201,6 @@ makeShaderProgram str sources = do
unless linkingSuccess $ do
infoLog <- get (programInfoLog theShaderProgram)
putStrLn $ str ++ ": Program Linking" ++ infoLog
return theShaderProgram
compileAndCheckShader :: String -> (ShaderType,BS.ByteString) -> IO Shader
@@ -217,8 +215,8 @@ compileAndCheckShader str (theShaderType,sourceCode) = do
return theShader
resetShaderUniforms :: [(Program, UniformLocation)] -> IO ()
resetShaderUniforms = setShaderUniforms 0 1 (0,0) (2,2)
{-# INLINE resetShaderUniforms #-}
resetShaderUniforms = setShaderUniforms 0 1 (0,0) (2,2)
setShaderUniforms :: Float -> Float -> Point2 -> Point2 -> [(Program,UniformLocation)] -> IO ()
{-# INLINE setShaderUniforms #-}
@@ -257,7 +255,7 @@ setPerpMatUniform
setPerpMatUniform rot czoom trans wins vFrom shad = do
pmat <- (newMatrix RowMajor $ perspectiveMatrix rot czoom trans wins vFrom) :: IO (GLmatrix GLfloat)
currentProgram $= Just (_shaderProgram shad)
uniform (_shaderUniform shad) $= pmat
uniform (_shaderMatrixUniform shad) $= pmat
return ()
freeShaderPointers :: FullShader a -> IO ()