From b00e114facc43d94aebefa103caa7df61b39d246 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Sat, 18 May 2019 22:43:06 -0400 Subject: Some notes. --- MaskableStream.hs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/MaskableStream.hs b/MaskableStream.hs index c023998..e6628e6 100644 --- a/MaskableStream.hs +++ b/MaskableStream.hs @@ -57,6 +57,12 @@ bindTextureCommand tlookup ulookup n = GLBindTexture (inputTypeToTextureTarget $ uniInputType (GLTypedUniform ty _) = unwitnessType ty uniInputType (GLUniform r) = objectType r +-- One of these: +-- VertexAttribPointer -- Array +-- VertexAttribIPointer -- streams. +-- VertexAttribI{1,2,3,4}[u]iv -- constant integer attribute. +-- Or some number of these in sequence: +-- VertexAttrib{1,2,3,4}fv -- constant vector or matrix of floats. setVertexAttribCommmand :: (t -> Stream Buffer) -> (GLuint, t) -> GLObjectCommand setVertexAttribCommmand alookup (i,name) = case alookup name of Stream ty (Buffer arrs bo) arrIdx start len -> mkAttrCmd i bo n (arrayTypeToGLType arrType) (intPtrToPtr $! offset) @@ -107,6 +113,10 @@ drawElementsCommand prim (IndexStream (Buffer arrs bo) arrIdx start idxCount) idxType = arrayTypeToGLType arrType ptr = intPtrToPtr $! fromIntegral (arrOffs + start * sizeOfArrayType arrType) +-- Note: all enabled attribute arrays should have the same count. +-- So an object should select similarly sized streams from 'dStreams' of GPUData. +-- So the 'mAttributes' map of a Mesh should contain equally sized arrays. +-- uploadMeshToGPU uses a single Buffer for all of a Mesh's attributes. objectDrawStyle :: (GLsizei -> [(GLint,GLsizei)]) -- ^ mask, normally \x -> [(0,x)] -> Object -> Either [(GLint,GLsizei)] (IndexStream Buffer) @@ -121,11 +131,12 @@ createObjectCommands texUnitMap topUnis obj prg = createObjectCommands_ (objectEnvironment texUnitMap topUnis obj (pure . ((,) 0))) prg data ObjectEnvironment = ObjectEnvironment - { envPrim :: GLenum - , envDrawStyle :: Either [(GLint,GLsizei)] (IndexStream Buffer) - , tlookup :: String -> IORef GLint - , ulookup :: String -> GLUniform - , alookup :: String -> Stream Buffer + { envPrim :: GLenum -- GL version of LambdaCube.GL.Primitive + , envDrawStyle :: Either [(GLint,GLsizei)] -- Mask of array attributes (one draw command for pair). + (IndexStream Buffer) -- Indirect P_TriangleStripI or P_TrianglesI indices. + , tlookup :: String -> IORef GLint -- lookup texture unit + , ulookup :: String -> GLUniform -- lookup uniform + , alookup :: String -> Stream Buffer -- lookup vertex attribute } objectEnvironment :: Map.Map String (IORef GLint) -- cgit v1.2.3