From 187751ec26b36c04de62e512cfdf2c83a4ea1a6c Mon Sep 17 00:00:00 2001 From: justin Date: Sun, 9 Nov 2025 21:11:55 +0000 Subject: [PATCH] Move from glNamedBufferData to glNamedBufferStorage --- src/Dodge/Render.hs | 1 - src/Shader/Bind.hs | 6 +++--- src/Shader/Compile.hs | 18 ++++++++++++------ src/Shader/Data.hs | 4 +--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 062f00f93..d2415a8d5 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -50,7 +50,6 @@ doDrawing' win pdata u = do cfig = _uvConfig u (windowPoints, wallSPics, wallsToPoke) = wallsToDraw w lightPoints = lightsToRender cfig (w ^. wCam) (w ^. cWorld . lWorld) - --(V2 vfx vfy) = w ^. wCam . camViewFrom shadV = _pictureShaders pdata nFls = w ^. cWorld . numberFloorVerxs nchs = w ^. cWorld . numberChasmVerxs diff --git a/src/Shader/Bind.hs b/src/Shader/Bind.hs index 1c530e7fa..44297f082 100644 --- a/src/Shader/Bind.hs +++ b/src/Shader/Bind.hs @@ -44,11 +44,11 @@ bufferShaderLayers shads counts = MV.imapM_ f shads where g stride theVBO lay = do numVs <- UMV.unsafeRead counts $ lay * numLayers + i - glNamedBufferSubDataH + glNamedBufferSubData (_vboName theVBO) (fromIntegral $ floatSize * stride * numSubElements * lay) (fromIntegral $ floatSize * numVs * stride) (_vboPtr theVBO `plusPtr` (floatSize * stride * numSubElements * lay)) -glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO () -glNamedBufferSubDataH = glNamedBufferSubData +--glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO () +--glNamedBufferSubDataH = glNamedBufferSubData diff --git a/src/Shader/Compile.hs b/src/Shader/Compile.hs index 83e9c22ff..54c29c6e7 100644 --- a/src/Shader/Compile.hs +++ b/src/Shader/Compile.hs @@ -86,12 +86,14 @@ setupVBO vertexsize = do -- unclear whether this should also be multiplied by floatSize thePtr <- mallocBytes (vertexsize * numDrawableVertices) -- Allocate space - glNamedBufferData + --glNamedBufferData + glNamedBufferStorage vboname (fromIntegral $ floatSize * numDrawableVertices * vertexsize) -- (fromIntegral $ numDrawableVertices * vertexsize) nullPtr - GL_STREAM_DRAW + --GL_STREAM_DRAW + 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 @@ -118,11 +120,13 @@ setupVBOStatic vertexsize = do vboname <- mglCreate glCreateBuffers thePtr <- mallocBytes (vertexsize * numDrawableVertices) -- Allocate space - glNamedBufferData + --glNamedBufferData + glNamedBufferStorage vboname (fromIntegral $ numDrawableVertices * vertexsize) nullPtr - GL_STATIC_DRAW + GL_DYNAMIC_STORAGE_BIT + --GL_STATIC_DRAW return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize} makeByteStringShaderUsingVAO :: @@ -189,11 +193,13 @@ setupEBO :: VAO -> IO EBO setupEBO vao = do eboptr <- mallocArray numGLushort eboname <- mglCreate glCreateBuffers - glNamedBufferData + --glNamedBufferData + glNamedBufferStorage eboname (fromIntegral $ glushortSize * numGLushort) nullPtr - GL_STREAM_DRAW + GL_DYNAMIC_STORAGE_BIT + --GL_STREAM_DRAW glVertexArrayElementBuffer (vao ^. vaoName) eboname return $ EBO eboname eboptr diff --git a/src/Shader/Data.hs b/src/Shader/Data.hs index 27366698d..c4447c915 100644 --- a/src/Shader/Data.hs +++ b/src/Shader/Data.hs @@ -61,9 +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 { _vaoName :: GLuint } data VertexAttribute = VertexAttribute { _vaCount :: GLint