From d15e800d66d74a5ec819f291cc7cfb5ddcb28d81 Mon Sep 17 00:00:00 2001 From: Csaba Hruska Date: Sat, 24 Dec 2016 21:20:02 +0100 Subject: some render optimization --- src/LambdaCube/GL/Type.hs | 50 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'src/LambdaCube/GL/Type.hs') diff --git a/src/LambdaCube/GL/Type.hs b/src/LambdaCube/GL/Type.hs index 5a9117d..776a425 100644 --- a/src/LambdaCube/GL/Type.hs +++ b/src/LambdaCube/GL/Type.hs @@ -128,7 +128,7 @@ data GLTexture = GLTexture { glTextureObject :: GLuint , glTextureTarget :: GLenum - } + } deriving Eq data InputConnection = InputConnection @@ -159,34 +159,50 @@ data GLRenderer , glVAO :: GLuint , glTexUnitMapping :: Map String (IORef GLint) -- maps texture uniforms to texture units , glStreams :: Vector GLStream + , glDrawContextRef :: IORef GLDrawContext + , glForceSetup :: IORef Bool + , glVertexBufferRef :: IORef GLuint + , glIndexBufferRef :: IORef GLuint } data GLSampler = GLSampler { glSamplerObject :: GLuint - } + } deriving Eq data GLRenderTarget = GLRenderTarget { framebufferObject :: GLuint , framebufferDrawbuffers :: Maybe [GLenum] - } + } deriving Eq + +type GLTextureUnit = Int +type GLUniformBinding = GLint + +data GLSamplerUniform + = GLSamplerUniform + { glUniformBinding :: GLUniformBinding + , glUniformBindingRef :: IORef GLUniformBinding + } + +instance Eq GLSamplerUniform where + a == b = glUniformBinding a == glUniformBinding b + +data GLDrawContext + = GLDrawContext + { glRasterContext :: RasterContext + , glAccumulationContext :: AccumulationContext + , glRenderTarget :: GLRenderTarget + , glProgram :: GLuint + , glTextureMapping :: [(GLTextureUnit,GLTexture)] + , glSamplerMapping :: [(GLTextureUnit,GLSampler)] + , glSamplerUniformMapping :: [(GLTextureUnit,GLSamplerUniform)] + } data GLCommand - = GLSetRasterContext !RasterContext - | GLSetAccumulationContext !AccumulationContext - | GLSetRenderTarget !GLuint !(Maybe [GLenum]) - | GLSetProgram !GLuint - | GLSetSamplerUniform !GLint !GLint (IORef GLint) -- sampler index, texture unit, IORef stores the actual texture unit mapping - | GLSetTexture !GLenum !GLuint !GLuint - | GLSetSampler !GLuint !GLuint - | GLRenderSlot !SlotName !ProgramName - | GLRenderStream !StreamName !ProgramName - | GLClearRenderTarget [ClearImage] - | GLGenerateMipMap !GLenum !GLenum - | GLSaveImage FrameBufferComponent ImageRef -- from framebuffer component to texture (image) - | GLLoadImage ImageRef FrameBufferComponent -- from texture (image) to framebuffer component - deriving Show + = GLRenderSlot GLDrawContext SlotName ProgramName + | GLRenderStream GLDrawContext StreamName ProgramName + | GLClearRenderTarget GLRenderTarget [ClearImage] instance Show (IORef GLint) where show _ = "(IORef GLint)" -- cgit v1.2.3