Просмотр исходного кода

Merge branch 'master' of github.com:taylor001/crown

Daniele Bartolini 10 лет назад
Родитель
Сommit
5465f1259a
2 измененных файлов с 27 добавлено и 5 удалено
  1. 13 1
      src/console_server.cpp
  2. 14 4
      src/renderers/shader.cpp

+ 13 - 1
src/console_server.cpp

@@ -12,6 +12,7 @@
 #include "dynamic_string.h"
 #include "json.h"
 #include "map.h"
+#include "bundle_compiler.h"
 
 namespace crown
 {
@@ -158,7 +159,18 @@ void ConsoleServer::process_command(TCPSocket /*client*/, const char* json)
 	DynamicString cmd(ta);
 	json::parse_string(root["command"], cmd);
 
-	if (cmd == "reload")
+	if (cmd == "compile")
+	{
+		DynamicString type(ta);
+		DynamicString name(ta);
+		DynamicString platform(ta);
+		json::parse_string(root["resource_type"], type);
+		json::parse_string(root["resource_name"], name);
+		json::parse_string(root["platform"], platform);
+
+		bundle_compiler_globals::compiler()->compile(type.c_str(), name.c_str(), platform.c_str());
+	}
+	else if (cmd == "reload")
 	{
 		DynamicString type(ta);
 		DynamicString name(ta);

+ 14 - 4
src/renderers/shader.cpp

@@ -40,7 +40,7 @@ namespace shader_resource
 	{
 		using namespace string_stream;
 
-		TempAllocator256 ta;
+		TempAllocator512 ta;
 		StringStream args(ta);
 		args << " -f " << infile;
 		args << " -o " << outfile;
@@ -103,8 +103,9 @@ namespace shader_resource
 		varying_file->write(varying_def.c_str(), varying_def.length());
 		opts._fs.close(varying_file);
 
-		TempAllocator1024 ta;
+		TempAllocator4096 ta;
 		StringStream output(ta);
+		using namespace string_stream;
 
 		int exitcode = run_external_compiler(vs_code_path.c_str()
 			, tmpvs_path.c_str()
@@ -113,8 +114,13 @@ namespace shader_resource
 			, opts.platform()
 			, output
 			);
-		CE_ASSERT(exitcode == 0, "Failed to compile vertex shader");
+		RESOURCE_COMPILER_ASSERT(exitcode == 0
+			, opts
+			, "Failed to compile vertex shader:\n%s"
+			, c_str(output)
+			);
 
+		array::clear(output);
 		exitcode = run_external_compiler(fs_code_path.c_str()
 			, tmpfs_path.c_str()
 			, varying_def_path.c_str()
@@ -125,7 +131,11 @@ namespace shader_resource
 		if (exitcode)
 		{
 			opts.delete_file(tmpvs_path.c_str());
-			CE_ASSERT(exitcode == 0, "Failed to compile fragment shader");
+			RESOURCE_COMPILER_ASSERT(false
+				, opts
+				, "Failed to compile fragment shader:\n%s"
+				, c_str(output)
+				);
 		}
 
 		Buffer tmpvs = opts.read(tmpvs_path.c_str());