diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-09-27 15:52:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 12:03:11 +0100 |
commit | 52f96abd8ba4323ff358f34683f9502ec24b9961 (patch) | |
tree | a199c439124bbda41edc585cc5e81463e190becb | |
parent | d5cf1a872bc71e638dabe38926f2ef1bfbea667e (diff) | |
parent | 3695c087829843b108bf55296d7dca39a08f135b (diff) |
Merge pull request #32389 from akien-mga/vulkan
Better format generated shader headers
-rw-r--r-- | gles_builders.py | 28 | ||||
-rw-r--r-- | modules/basis_universal/SCsub | 10 | ||||
-rw-r--r-- | modules/basis_universal/register_types.cpp | 11 | ||||
-rw-r--r-- | modules/basis_universal/texture_basisu.cpp (renamed from modules/basis_universal/texture_bu.cpp) | 40 | ||||
-rw-r--r-- | modules/basis_universal/texture_basisu.h (renamed from modules/basis_universal/texture_bu.h) | 16 |
5 files changed, 50 insertions, 55 deletions
diff --git a/gles_builders.py b/gles_builders.py index 7b2d1ba7d5..b7a9b2b419 100644 --- a/gles_builders.py +++ b/gles_builders.py @@ -586,6 +586,7 @@ def include_file_in_rd_header(filename, header_data, depth): return header_data + def build_rd_header(filename): header_data = RDHeaderStruct() include_file_in_rd_header(filename, header_data, 0) @@ -605,52 +606,47 @@ def build_rd_header(filename): fd.write("#define " + out_file_ifdef + "_RD\n") out_file_class = out_file_base.replace(".glsl.gen.h", "").title().replace("_", "").replace(".", "") + "ShaderRD" - fd.write("\n\n") - fd.write("#include \"servers/visual/rasterizer_rd/shader_rd.h\"\n\n\n") + fd.write("\n") + fd.write("#include \"servers/visual/rasterizer_rd/shader_rd.h\"\n\n") fd.write("class " + out_file_class + " : public ShaderRD {\n\n") fd.write("public:\n\n") - - fd.write("\t"+out_file_class+"() {\n\n") + fd.write("\t" + out_file_class + "() {\n\n") if (len(header_data.compute_lines)): - fd.write("\t\tstatic const char _compute_code[]={\n") + fd.write("\t\tstatic const char _compute_code[] = {\n") for x in header_data.compute_lines: for c in x: fd.write(str(ord(c)) + ",") - fd.write(str(ord('\n')) + ",") - fd.write("\t\t0};\n\n") - fd.write("\t\tsetup(nullptr,nullptr,_compute_code,\""+out_file_class+"\");\n") + + fd.write("\t\tsetup(nullptr, nullptr, _compute_code, \"" + out_file_class + "\");\n") fd.write("\t}\n") else: - fd.write("\t\tstatic const char _vertex_code[]={\n") + fd.write("\t\tstatic const char _vertex_code[] = {\n") for x in header_data.vertex_lines: for c in x: fd.write(str(ord(c)) + ",") - fd.write(str(ord('\n')) + ",") fd.write("\t\t0};\n\n") fd.write("\t\tstatic const char _fragment_code[]={\n") for x in header_data.fragment_lines: for c in x: - fd.write(str(ord(c)) + ",") - + fd.write(str(ord(c)) + ",") fd.write(str(ord('\n')) + ",") - fd.write("\t\t0};\n\n") - fd.write("\t\tsetup(_vertex_code,_fragment_code,nullptr,\""+out_file_class+"\");\n") - fd.write("\t}\n") + fd.write("\t\tsetup(_vertex_code, _fragment_code, nullptr, \"" + out_file_class + "\");\n") + fd.write("\t}\n") fd.write("};\n\n") - fd.write("#endif\n\n") + fd.write("#endif\n") fd.close() diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub index b933e78de8..3e179762a5 100644 --- a/modules/basis_universal/SCsub +++ b/modules/basis_universal/SCsub @@ -3,7 +3,7 @@ Import('env') Import('env_modules') -env_bu = env_modules.Clone() +env_basisu = env_modules.Clone() # Thirdparty source files # Not unbundled so far since not widespread as shared library @@ -28,16 +28,16 @@ tool_sources = [ tool_sources = [thirdparty_dir + file for file in tool_sources] transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"] -env_bu.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"]) +env_basisu.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "transcoder"]) if env['target'] == "debug": - env_bu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) + env_basisu.Append(CPPFLAGS=["-DBASISU_DEVEL_MESSAGES=1", "-DBASISD_ENABLE_DEBUG_FLAGS=1"]) -env_thirdparty = env_bu.Clone() +env_thirdparty = env_basisu.Clone() env_thirdparty.disable_warnings() if env['tools']: env_thirdparty.add_source_files(env.modules_sources, tool_sources) env_thirdparty.add_source_files(env.modules_sources, transcoder_sources) # Godot source files -env_bu.add_source_files(env.modules_sources, "*.cpp") +env_basisu.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/basis_universal/register_types.cpp b/modules/basis_universal/register_types.cpp index 780630c857..04f488de96 100644 --- a/modules/basis_universal/register_types.cpp +++ b/modules/basis_universal/register_types.cpp @@ -1,15 +1,14 @@ #include "register_types.h" #include "core/os/os.h" -#include "texture_bu.h" +#include "servers/visual_server.h" +#include "texture_basisu.h" #ifdef TOOLS_ENABLED -#include "thirdparty/basis_universal/basisu_comp.h" +#include <basisu_comp.h> #endif -#include "thirdparty/basis_universal/transcoder/basisu.h" - -#include "servers/visual_server.h" +#include <transcoder/basisu_transcoder.h> enum BasisDecompressFormat { BASIS_DECOMPRESS_RG, @@ -250,7 +249,7 @@ void register_basis_universal_types() { Image::basis_universal_packer = basis_universal_packer; #endif Image::basis_universal_unpacker = basis_universal_unpacker; - // ClassDB::register_class<TextureBU>(); + //ClassDB::register_class<TextureBasisU>(); } void unregister_basis_universal_types() { diff --git a/modules/basis_universal/texture_bu.cpp b/modules/basis_universal/texture_basisu.cpp index 73a945b33d..20c4974da5 100644 --- a/modules/basis_universal/texture_bu.cpp +++ b/modules/basis_universal/texture_basisu.cpp @@ -1,57 +1,57 @@ -#include "texture_bu.h" +#include "texture_basisu.h" #if 0 #include "core/os/os.h" #ifdef TOOLS_ENABLED -#include "basisu_comp.h" +#include <basisu_comp.h> #endif -#include "transcoder/basisu.h" +#include <transcoder/basisu_transcoder.h> -void TextureBU::_bind_methods() { +void TextureBasisU::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_bu_data", "data"), &TextureBU::set_bu_data); - ClassDB::bind_method(D_METHOD("get_bu_data"), &TextureBU::get_data); - ClassDB::bind_method(D_METHOD("import"), &TextureBU::import); + ClassDB::bind_method(D_METHOD("set_basisu_data", "data"), &TextureBasisU::set_basisu_data); + ClassDB::bind_method(D_METHOD("get_basisu_data"), &TextureBasisU::get_data); + ClassDB::bind_method(D_METHOD("import"), &TextureBasisU::import); - ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "bu_data"), "set_bu_data", "get_bu_data"); + ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "basisu_data"), "set_basisu_data", "get_basisu_data"); }; -int TextureBU::get_width() const { +int TextureBasisU::get_width() const { return tex_size.x; }; -int TextureBU::get_height() const { +int TextureBasisU::get_height() const { return tex_size.y; }; -RID TextureBU::get_rid() const { +RID TextureBasisU::get_rid() const { return texture; }; -bool TextureBU::has_alpha() const { +bool TextureBasisU::has_alpha() const { return false; }; -void TextureBU::set_flags(uint32_t p_flags) { +void TextureBasisU::set_flags(uint32_t p_flags) { flags = p_flags; VisualServer::get_singleton()->texture_set_flags(texture, p_flags); }; -uint32_t TextureBU::get_flags() const { +uint32_t TextureBasisU::get_flags() const { return flags; }; -void TextureBU::set_bu_data(const PoolVector<uint8_t>& p_data) { +void TextureBasisU::set_basisu_data(const PoolVector<uint8_t>& p_data) { #ifdef TOOLS_ENABLED data = p_data; @@ -118,7 +118,7 @@ void TextureBU::set_bu_data(const PoolVector<uint8_t>& p_data) { VisualServer::get_singleton()->texture_set_data(texture, img); }; -Error TextureBU::import(const Ref<Image>& p_img) { +Error TextureBasisU::import(const Ref<Image>& p_img) { #ifdef TOOLS_ENABLED @@ -173,7 +173,7 @@ Error TextureBU::import(const Ref<Image>& p_img) { }; }; - set_bu_data(budata); + set_basisu_data(budata); return OK; #else @@ -183,19 +183,19 @@ Error TextureBU::import(const Ref<Image>& p_img) { }; -PoolVector<uint8_t> TextureBU::get_bu_data() const { +PoolVector<uint8_t> TextureBasisU::get_basisu_data() const { return data; }; -TextureBU::TextureBU() { +TextureBasisU::TextureBasisU() { flags = FLAGS_DEFAULT; texture = VisualServer::get_singleton()->texture_create(); }; -TextureBU::~TextureBU() { +TextureBasisU::~TextureBasisU() { VisualServer::get_singleton()->free(texture); }; diff --git a/modules/basis_universal/texture_bu.h b/modules/basis_universal/texture_basisu.h index 9ec9194a96..20cfd65e3a 100644 --- a/modules/basis_universal/texture_bu.h +++ b/modules/basis_universal/texture_basisu.h @@ -1,15 +1,15 @@ #include "scene/resources/texture.h" #ifdef TOOLS_ENABLED -#include "thirdparty/basis_universal/basisu_comp.h" +#include <basisu_comp.h> #endif -#include "thirdparty/basis_universal/transcoder/basisu.h" +#include <transcoder/basisu_transcoder.h> #if 0 -class TextureBU : public Texture { +class TextureBasisU : public Texture { - GDCLASS(TextureBU, Texture); + GDCLASS(TextureBasisU, Texture); RES_BASE_EXTENSION("butex"); RID texture; @@ -34,13 +34,13 @@ public: Error import(const Ref<Image> &p_img); - void set_bu_data(const PoolVector<uint8_t>& p_data); + void set_basisu_data(const PoolVector<uint8_t>& p_data); - PoolVector<uint8_t> get_bu_data() const; + PoolVector<uint8_t> get_basisu_data() const; String get_img_path() const; - TextureBU(); - ~TextureBU(); + TextureBasisU(); + ~TextureBasisU(); }; |