Browse Source

Added new uniform block type.

Mark Sibly 8 years ago
parent
commit
0d1a6d4148
2 changed files with 14 additions and 17 deletions
  1. 1 1
      modules/mojo/graphics/graphicsdevice.monkey2
  2. 13 16
      modules/mojo/graphics/shader.monkey2

+ 1 - 1
modules/mojo/graphics/graphicsdevice.monkey2

@@ -408,7 +408,7 @@ Class GraphicsDevice
 	Field _retroMode:Bool
 	Field _vertexBuffer:VertexBuffer
 	Field _indexBuffer:IndexBuffer
-	Field _ublocks:=New UniformBlock[4]
+	Field _ublocks:=New UniformBlock[8]
 	Field _shader:Shader
 	Field _rpass:Int
 	

+ 13 - 16
modules/mojo/graphics/shader.monkey2

@@ -38,6 +38,9 @@ Class GLUniform
 		Else If name.StartsWith( "m_" )
 			name=name.Slice( 2 )
 			block=3
+		Else If name.StartsWith( "x_" )
+			name=name.Slice( 2 )
+			block=4
 		Endif
 		
 		uniformId=UniformBlock.GetUniformId( name,block )
@@ -48,18 +51,18 @@ End
 Class GLProgram
 
 	Field _glprogram:GLuint
-	Field _uniforms:=New GLUniform[4][]
-	Field _textures:=New GLUniform[4][]
-	Field _ublockSeqs:=New Int[4]
+	Field _uniforms:=New GLUniform[8][]
+	Field _textures:=New GLUniform[8][]
+	Field _ublockSeqs:=New Int[8]
 	Field _glRetroSeq:Int
 
 	Method New( glprogram:GLuint )
 
 		_glprogram=glprogram
 		
-		Local uniforms:=New Stack<GLUniform>[4]
-		Local textures:=New Stack<GLUniform>[4]
-		For Local i:=0 Until 4
+		Local uniforms:=New Stack<GLUniform>[8]
+		Local textures:=New Stack<GLUniform>[8]
+		For Local i:=0 Until 8
 			uniforms[i]=New Stack<GLUniform>
 			textures[i]=New Stack<GLUniform>
 		Next
@@ -95,7 +98,7 @@ Class GLProgram
 			
 		Next
 		
-		For Local i:=0 Until 4
+		For Local i:=0 until 8
 			_uniforms[i]=uniforms[i].ToArray()
 			_textures[i]=textures[i].ToArray()
 			_ublockSeqs[i]=-1
@@ -109,15 +112,11 @@ Class GLProgram
 
 	Method ValidateUniforms( ublocks:UniformBlock[] )
 		
-		For Local i:=0 Until 4
+		For Local i:=0 Until 8
 
 			Local ublock:=ublocks[ i ]
 			
-			If Not ublock Continue
-			
-			If ublock.Name<>i Print "OOOPS!"
-			
-			If ublock.Seq=_ublockSeqs[i] Continue
+			If Not ublock Or ublock.Seq=_ublockSeqs[i] Continue
 			
 			_ublockSeqs[i]=ublock.Seq
 			
@@ -161,10 +160,8 @@ Class GLProgram
 		
 		Next
 		
-		For Local i:=0 Until 4
+		For Local i:=0 Until 8
 			
-'			If Not ublocks[i] continue
-		
 			If Not _textures[i] Continue
 			
 			For Local u:=Eachin _textures[i]