Remove unused shader code

This commit is contained in:
2025-11-14 11:27:16 +00:00
parent 836fefb9a5
commit 91917dbddd
9 changed files with 20 additions and 120 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ data RenderData = RenderData
, _wallVBO :: VBO
, _cloudVBO :: VBO
, _cloudShader :: GLuint
, _dummyVAO :: VAO
, _dummyVAO :: GLuint
}
makeLenses ''RenderData
+5 -1
View File
@@ -1,5 +1,9 @@
{-# OPTIONS -fno-warn-missing-signatures #-}
module Dodge.Menu.OptionType where
module Dodge.Menu.OptionType (
boolOption,
enumOption,
makeSubmenuOption,
) where
import Control.Lens
import Dodge.Data.Universe
+2 -2
View File
@@ -121,7 +121,7 @@ doDrawing' win pdata u = do
glEnable GL_CULL_FACE
unless (debugOn Remove_LOS cfig) $ do
glUseProgram (pdata ^. ceilingStencilShader)
glBindVertexArray $ pdata ^. dummyVAO . vaoName
glBindVertexArray $ pdata ^. dummyVAO
glEnable GL_DEPTH_CLAMP
glDrawArrays GL_TRIANGLES 0 (fromIntegral (trueNWalls * 6))
glDisable GL_DEPTH_CLAMP
@@ -311,7 +311,7 @@ doDrawing' win pdata u = do
glEnable GL_BLEND
glBlendFunc GL_SRC_ALPHA GL_ONE
glUseProgram $ pdata ^. windowPullShader
glBindVertexArray $ pdata ^. dummyVAO . vaoName
glBindVertexArray $ pdata ^. dummyVAO
glDrawArrays GL_TRIANGLES 0 (fromIntegral nWins * 6)
glDisable GL_DEPTH_CLAMP
glDisable GL_CULL_FACE
+1 -1
View File
@@ -206,7 +206,7 @@ preloadRender = do
, _cloudVBO = cloudvbo
, _cloudShader = cloudshader
-- , _screenTextureVAO = screentexturevao
, _dummyVAO = VAO dummyvao
, _dummyVAO = dummyvao
}
--------------------end preloadRender
+1 -1
View File
@@ -174,7 +174,7 @@ renderShadows cam cfig shadrendertype nWalls nSils nCaps positiontexture normalt
glDisable GL_CULL_FACE
-- the first bit has been used to stencil out "ceilings" under which we never draw
glStencilFunc GL_NOTEQUAL 128 255
glBindVertexArray $ pdata ^. dummyVAO . vaoName
glBindVertexArray $ pdata ^. dummyVAO
--draw wall shadows
glUseProgram shadwall
glDrawArrays GL_TRIANGLES 0 (nWalls * 18)
+2 -6
View File
@@ -1,5 +1,4 @@
module Shader (
freeShaderPointers',
drawShaderLay,
shadVBOptr,
drawShader,
@@ -18,7 +17,7 @@ drawShaderLay :: Int -> UMV.MVector (PrimState IO) Int -> Int -> (Shader, VBO) -
drawShaderLay l countsVector shadIn fs = do
i <- UMV.read countsVector shadIn
glUseProgram (_shaderUINT $ fst fs)
glBindVertexArray $ fs ^. _1 . shaderVAO . vaoName
glBindVertexArray $ fs ^. _1 . shaderVAO . unVAO
glDrawArrays
(_unPrimitiveMode $ _shaderPrimitive $ fst fs)
(fromIntegral $ l * numSubElements)
@@ -28,15 +27,12 @@ drawShader :: Shader -> Int -> IO ()
{-# INLINE drawShader #-}
drawShader fs i = do
glUseProgram (_shaderUINT fs)
glBindVertexArray $ fs ^. shaderVAO . vaoName
glBindVertexArray $ fs ^. shaderVAO . unVAO
glDrawArrays
(_unPrimitiveMode $ _shaderPrimitive fs)
0
(fromIntegral i)
freeShaderPointers' :: (Shader, VBO) -> IO ()
freeShaderPointers' = free . _vboPtr . snd
shadVBOptr :: (Shader, VBO) -> Ptr Float
{-# INLINE shadVBOptr #-}
shadVBOptr = _vboPtr . snd
+7 -106
View File
@@ -1,16 +1,13 @@
module Shader.Compile (
setupVBO,
setupVBOStatic,
makeShaderEBO,
-- makeShaderEBO,
makeShaderVBO,
makeShaderUsingVBO,
-- makeShaderUsingVBO,
makeShaderProgram,
-- makeByteStringShaderUsingVAO,
makeShaderUsingVAO,
setupVAOUsingVBO,
setupEBO,
-- makeShaderUsingVAO,
-- setupVAOUsingVBO,
-- setupEBO,
toFloatVAs,
setupStaticVBOVAO,
-- setupStaticVBOVAO,
makeSourcedShader,
) where
@@ -20,7 +17,6 @@ import qualified Data.ByteString as BS
import qualified Data.ByteString.Unsafe as BU
import Foreign
import Foreign.C.String
import Foreign.C.Types
import GLHelp
import Graphics.GL.Core45
import Graphics.GL.Types
@@ -52,36 +48,6 @@ makeShaderVBO s shaderlist sizes pm = do
, vbo
)
makeShaderEBO ::
-- | First part of the name of the shader
String ->
-- | shader types
[GLenum] ->
-- | The input vertex sizes
[VertexAttribute] ->
PrimitiveMode ->
VBO ->
IO (Shader, UintBO)
makeShaderEBO s shaderlist sizes pm vbo = do
shad <- makeShaderUsingVBO s shaderlist sizes pm vbo
ebo <- setupEBO (shad ^. shaderVAO)
glVertexArrayElementBuffer (shad ^. shaderVAO . vaoName) (ebo ^. uiboName)
return (shad, ebo)
makeShaderUsingVBO ::
-- | First part of the name of the shader
String ->
-- | shader types
[GLenum] ->
-- | The input vertex sizes
[VertexAttribute] ->
PrimitiveMode ->
VBO ->
IO Shader
makeShaderUsingVBO s shaderlist sizes pm vbo = do
vao <- setupVAOUsingVBO sizes vbo
makeShaderUsingVAO s shaderlist pm vao
setupVBO :: Int -> IO VBO
setupVBO vertexsize = do
vboname <- mglCreate glCreateBuffers
@@ -98,58 +64,6 @@ setupVBO vertexsize = do
GL_DYNAMIC_STORAGE_BIT
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
-- the input ptr is assumed to contain the correct amount of data according to
-- the specified number and type of vertices
-- note the VBO here does not have a sensible ptr value
setupStaticVBOVAO :: Storable a => [VertexAttribute] -> [a] -> IO (VBO, VAO)
setupStaticVBOVAO vas vdata = withArrayLen vdata $ \i ptr -> do
vboname <- mglCreate glCreateBuffers
glNamedBufferStorage
vboname
(CPtrdiff (fromIntegral (i * sizeOf (head vdata))))
ptr
0
let vbo =
VBO
{ _vboName = vboname
, _vboPtr = nullPtr
, _vboVertexBytes = vasTightStride vas
}
vao <- setupVAOUsingVBO vas vbo
return (vbo, vao)
setupVBOStatic :: Int -> IO VBO
setupVBOStatic vertexsize = do
vboname <- mglCreate glCreateBuffers
thePtr <- mallocBytes (vertexsize * numDrawableVertices)
-- Allocate space
--glNamedBufferData
glNamedBufferStorage
vboname
(fromIntegral $ numDrawableVertices * vertexsize)
nullPtr
GL_DYNAMIC_STORAGE_BIT
--GL_STATIC_DRAW
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
-- | Takes the VAO from elsewhere
makeShaderUsingVAO ::
-- | First part of the name of the shader
String ->
-- | shader types
[GLenum] ->
PrimitiveMode ->
VAO ->
IO Shader
makeShaderUsingVAO s shaderlist pm theVAO = do
prog <- makeSourcedShader s shaderlist
return
Shader
{ _shaderUINT = prog
, _shaderVAO = theVAO
, _shaderPrimitive = pm
}
{- | Compile shader and get its uniform locations.
supposes the shader code is in the shader folder, with the string names
followed by .vert/.geom/.frag.
@@ -176,26 +90,13 @@ setupVAOUsingVBO vas vbo = do
vaoname
vas
(fromIntegral strd)
return VAO{_vaoName = vaoname}
setupEBO :: VAO -> IO UintBO
setupEBO vao = do
eboptr <- mallocArray 65536 -- so we can go back to glushort...
eboname <- mglCreate glCreateBuffers
glNamedBufferStorage
eboname
(fromIntegral $ gluintSize * 65536)
nullPtr
GL_DYNAMIC_STORAGE_BIT
glVertexArrayElementBuffer (vao ^. vaoName) eboname
return $ UintBO eboname eboptr
return $ VAO vaoname
setupVBOVAO :: [VertexAttribute] -> IO (VAO, VBO)
setupVBOVAO vas = do
vaoname <- mglCreate glCreateVertexArrays
glBindVertexArray vaoname
vbo <- setupVBO strd
--vao <- setupVAOvbo (toFloatVAs sizes) (sum sizes) (vbo ^. vboName)
vao <- setupVAOUsingVBO vas vbo
return (vao, vbo)
where
+1 -1
View File
@@ -61,7 +61,7 @@ newtype TO = TO {_unTO :: GLuint}
{- | Vertex array object: contains the reference to the object,
and its buffer targets.
-}
newtype VAO = VAO { _vaoName :: GLuint }
newtype VAO = VAO { _unVAO :: GLuint }
data VertexAttribute = VertexAttribute
{ _vaCount :: GLint
-1
View File
@@ -5,7 +5,6 @@ module Shader.Poke.Cloud (pokeCloud, pokeDust) where
import Shader.Parameters
import Color
import Control.Lens
--import qualified Data.Vector.Unboxed as UV
import Dodge.Data.Cloud
import Dodge.Material.Color
import Foreign