Commits

Jason McKesson committed 258bbff

glscene: `style` uniform and storage buffer parsing.

  • Participants
  • Parent commits 9c73180

Comments (0)

Files changed (3)

File glscene/Test/test.glscene

 		rotation_scale 0.36
 	end
 	
-	uniform_buffer_res <ident> 64 [stream_draw]
-	storage_buffer_res <ident> 128 placeholder
+	uniform_buffer_res <ubuff> 64 [stream_draw]
+	storage_buffer_res <sbuff> 128 placeholder
 
 	program_res <ident>
 		vert "filename.vert"
 				
 				mesh <ident>
 				texture 0 <tex> <spl>
+				uniform_buffer 0 <ubuff>
+				uniform_buffer 1 <ubuff> 32
+				storage_buffer 0 <ubuff>
 			end
 		end
 		

File glscene/source/Parse.cpp

 	{
 		TOK_MESH,
 		TOK_TEXTURE,
+		TOK_UNIFORM_BUFFER,
+		TOK_STORAGE_BUFFER,
 	};
 
 	//////////////////////////////////////////////////////////////////////////
 						data.textures.back().texUnit = texUnit;
 					}
 					break;
+				case TOK_UNIFORM_BUFFER:
+					{
+						EatOneToken();
+						unsigned int binding = ParseSingleUInt();
+						IdString bufferId = ParseIdentifier(m_resources.uniformBuffers, true, tok.id());
+						data.uniformBuffers.push_back(ParsedBufferRefDef(bufferId));
+						ParsedBufferRefDef &bufferDef = data.uniformBuffers.back();
+						bufferDef.pos = pos;
+						bufferDef.buffBinding = binding;
+						if(IsCurrTokenOneOf(g_unsignedIntStartTokens))
+							bufferDef.offset = ParseSingleUInt();
+					}
+					break;
+				case TOK_STORAGE_BUFFER:
+					{
+						EatOneToken();
+						unsigned int binding = ParseSingleUInt();
+						IdString bufferId = ParseIdentifier(m_resources.storageBuffers, true, tok.id());
+						data.storageBuffers.push_back(ParsedBufferRefDef(bufferId));
+						ParsedBufferRefDef &bufferDef = data.storageBuffers.back();
+						bufferDef.pos = pos;
+						bufferDef.buffBinding = binding;
+						if(IsCurrTokenOneOf(g_unsignedIntStartTokens))
+							bufferDef.offset = ParseSingleUInt();
+					}
+					break;
 				}
 			}
 		}

File glscene/source/ParsedData.h

 		{}
 	};
 
+	struct ParsedBufferRefDef
+	{
+		FilePosition pos;
+		unsigned int buffBinding;
+		IdString bufferId;
+		unsigned int offset;
+
+		ParsedBufferRefDef(const IdString &_bufferId) : bufferId(_bufferId), offset(0) {}
+	};
+
 	struct ParsedStyleData
 	{
 		boost::optional<ParsedMeshRefDef> mesh;
 		std::vector<ParsedTextureRefDef> textures;
+		std::vector<ParsedBufferRefDef> uniformBuffers;
+		std::vector<ParsedBufferRefDef> storageBuffers;
 	};
 
 	struct ParsedLocalDef