diff --git a/libs/filamat/CMakeLists.txt b/libs/filamat/CMakeLists.txt index 07673b17c6..1c4c0a5d38 100644 --- a/libs/filamat/CMakeLists.txt +++ b/libs/filamat/CMakeLists.txt @@ -19,12 +19,12 @@ set(PRIVATE_HDRS src/eiff/BlobDictionary.h src/eiff/Chunk.h src/eiff/ChunkContainer.h - src/eiff/DictionaryGlslChunk.h + src/eiff/DictionaryTextChunk.h src/eiff/DictionarySpirvChunk.h src/eiff/Flattener.h - src/eiff/GlslChunk.h + src/eiff/TextChunk.h src/eiff/LineDictionary.h - src/eiff/MaterialGlslChunk.h + src/eiff/MaterialTextChunk.h src/eiff/MaterialInterfaceBlockChunk.h src/eiff/MaterialSpirvChunk.h src/eiff/ShaderEntry.h @@ -37,10 +37,10 @@ set(SRCS src/eiff/BlobDictionary.cpp src/eiff/Chunk.cpp src/eiff/ChunkContainer.cpp - src/eiff/DictionaryGlslChunk.cpp + src/eiff/DictionaryTextChunk.cpp src/eiff/DictionarySpirvChunk.cpp src/eiff/LineDictionary.cpp - src/eiff/MaterialGlslChunk.cpp + src/eiff/MaterialTextChunk.cpp src/eiff/MaterialSpirvChunk.cpp src/eiff/MaterialInterfaceBlockChunk.cpp src/eiff/SimpleFieldChunk.cpp diff --git a/libs/filamat/src/MaterialBuilder.cpp b/libs/filamat/src/MaterialBuilder.cpp index 2b4db93e15..0dd3c0835a 100644 --- a/libs/filamat/src/MaterialBuilder.cpp +++ b/libs/filamat/src/MaterialBuilder.cpp @@ -34,11 +34,11 @@ #include "eiff/BlobDictionary.h" #include "eiff/LineDictionary.h" #include "eiff/MaterialInterfaceBlockChunk.h" -#include "eiff/MaterialGlslChunk.h" +#include "eiff/MaterialTextChunk.h" #include "eiff/MaterialSpirvChunk.h" #include "eiff/ChunkContainer.h" #include "eiff/SimpleFieldChunk.h" -#include "eiff/DictionaryGlslChunk.h" +#include "eiff/DictionaryTextChunk.h" #include "eiff/DictionarySpirvChunk.h" #include "filamat/sca/GLSLTools.h" @@ -428,7 +428,7 @@ Package MaterialBuilder::build() noexcept { container.addChild(&matShaderModels); // Generate all shaders. - std::vector glslEntries; + std::vector glslEntries; std::vector spirvEntries; LineDictionary glslDictionary; BlobDictionary spirvDictionary; @@ -450,7 +450,7 @@ Package MaterialBuilder::build() noexcept { const TargetApi codeGenTargetApi = params.codeGenTargetApi; std::vector* pSpirv = (targetApi == TargetApi::VULKAN) ? &spirv : nullptr; - GlslEntry glslEntry; + TextEntry glslEntry; SpirvEntry spirvEntry; glslEntry.shaderModel = static_cast(params.shaderModel); @@ -536,9 +536,9 @@ Package MaterialBuilder::build() noexcept { } } - // Emit GLSL chunks (TextDictionaryReader and MaterialGlslChunk). - filamat::DictionaryGlslChunk dicGlslChunk(glslDictionary); - MaterialGlslChunk glslChunk(glslEntries, glslDictionary); + // Emit GLSL chunks (TextDictionaryReader and MaterialTextChunk). + filamat::DictionaryTextChunk dicGlslChunk(glslDictionary, ChunkType::DictionaryGlsl); + MaterialTextChunk glslChunk(glslEntries, glslDictionary, ChunkType::MaterialGlsl); if (!glslEntries.empty()) { container.addChild(&dicGlslChunk); container.addChild(&glslChunk); @@ -560,7 +560,7 @@ Package MaterialBuilder::build() noexcept { package.setValid(!errorOccured); // Free all shaders that were created earlier. - for (GlslEntry entry : glslEntries) { + for (TextEntry entry : glslEntries) { free(entry.shader); } return package; diff --git a/libs/filamat/src/PostprocessMaterialBuilder.cpp b/libs/filamat/src/PostprocessMaterialBuilder.cpp index c7d586965b..13532e3623 100644 --- a/libs/filamat/src/PostprocessMaterialBuilder.cpp +++ b/libs/filamat/src/PostprocessMaterialBuilder.cpp @@ -23,9 +23,9 @@ #include "GLSLPostProcessor.h" #include "eiff/ChunkContainer.h" -#include "eiff/DictionaryGlslChunk.h" +#include "eiff/DictionaryTextChunk.h" #include "eiff/DictionarySpirvChunk.h" -#include "eiff/MaterialGlslChunk.h" +#include "eiff/MaterialTextChunk.h" #include "eiff/MaterialSpirvChunk.h" #include "eiff/SimpleFieldChunk.h" @@ -54,7 +54,7 @@ Package PostprocessMaterialBuilder::build() { SimpleFieldChunk version(ChunkType::PostProcessVersion,1); container.addChild(&version); - std::vector glslEntries; + std::vector glslEntries; std::vector spirvEntries; LineDictionary glslDictionary; BlobDictionary spirvDictionary; @@ -73,7 +73,7 @@ Package PostprocessMaterialBuilder::build() { const TargetApi codeGenTargetApi = params.codeGenTargetApi; std::vector* pSpirv = (targetApi == TargetApi::VULKAN) ? &spirv : nullptr; - GlslEntry glslEntry; + TextEntry glslEntry; SpirvEntry spirvEntry; glslEntry.shaderModel = static_cast(params.shaderModel); @@ -144,8 +144,8 @@ Package PostprocessMaterialBuilder::build() { } // Emit GLSL chunks - DictionaryGlslChunk dicGlslChunk(glslDictionary); - MaterialGlslChunk glslChunk(glslEntries, glslDictionary); + DictionaryTextChunk dicGlslChunk(glslDictionary, ChunkType::DictionaryGlsl); + MaterialTextChunk glslChunk(glslEntries, glslDictionary, ChunkType::MaterialGlsl); if (!glslEntries.empty()) { container.addChild(&dicGlslChunk); container.addChild(&glslChunk); @@ -167,7 +167,7 @@ Package PostprocessMaterialBuilder::build() { package.setValid(!errorOccured); // Free all shaders that were created earlier. - for (GlslEntry entry : glslEntries) { + for (TextEntry entry : glslEntries) { free(entry.shader); } return package; diff --git a/libs/filamat/src/eiff/DictionaryGlslChunk.cpp b/libs/filamat/src/eiff/DictionaryTextChunk.cpp similarity index 79% rename from libs/filamat/src/eiff/DictionaryGlslChunk.cpp rename to libs/filamat/src/eiff/DictionaryTextChunk.cpp index 8cbf648e9b..6ea6a73d1f 100644 --- a/libs/filamat/src/eiff/DictionaryGlslChunk.cpp +++ b/libs/filamat/src/eiff/DictionaryTextChunk.cpp @@ -14,15 +14,15 @@ * limitations under the License. */ -#include "DictionaryGlslChunk.h" +#include "DictionaryTextChunk.h" namespace filamat { -DictionaryGlslChunk::DictionaryGlslChunk(LineDictionary& dictionary) : - Chunk(ChunkType::DictionaryGlsl), mDictionary(dictionary){ +DictionaryTextChunk::DictionaryTextChunk(LineDictionary& dictionary, ChunkType chunkType) : + Chunk(chunkType), mDictionary(dictionary) { } -void DictionaryGlslChunk::flatten(Flattener& f) { +void DictionaryTextChunk::flatten(Flattener& f) { // NumStrings f.writeUint32(mDictionary.getLineCount()); diff --git a/libs/filamat/src/eiff/DictionaryGlslChunk.h b/libs/filamat/src/eiff/DictionaryTextChunk.h similarity index 76% rename from libs/filamat/src/eiff/DictionaryGlslChunk.h rename to libs/filamat/src/eiff/DictionaryTextChunk.h index aa59e67a16..e929edb6dd 100644 --- a/libs/filamat/src/eiff/DictionaryGlslChunk.h +++ b/libs/filamat/src/eiff/DictionaryTextChunk.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef TNT_FILAMAT_DIC_GLSL_CHUNK_H -#define TNT_FILAMAT_DIC_GLSL_CHUNK_H +#ifndef TNT_FILAMAT_DIC_TEXT_CHUNK_H +#define TNT_FILAMAT_DIC_TEXT_CHUNK_H #include #include @@ -26,10 +26,10 @@ namespace filamat { -class DictionaryGlslChunk : public Chunk { +class DictionaryTextChunk : public Chunk { public: - DictionaryGlslChunk(LineDictionary& dictionary); - ~DictionaryGlslChunk() = default; + DictionaryTextChunk(LineDictionary& dictionary, ChunkType chunkType); + ~DictionaryTextChunk() = default; virtual void flatten(Flattener& f); private: LineDictionary& mDictionary; @@ -37,4 +37,4 @@ private: } // namespace filamat -#endif // TNT_FILAMAT_DIC_GLSL_CHUNK_H +#endif // TNT_FILAMAT_DIC_TEXT_CHUNK_H diff --git a/libs/filamat/src/eiff/MaterialGlslChunk.cpp b/libs/filamat/src/eiff/MaterialTextChunk.cpp similarity index 67% rename from libs/filamat/src/eiff/MaterialGlslChunk.cpp rename to libs/filamat/src/eiff/MaterialTextChunk.cpp index ffbfbb5376..505f2d28f4 100644 --- a/libs/filamat/src/eiff/MaterialGlslChunk.cpp +++ b/libs/filamat/src/eiff/MaterialTextChunk.cpp @@ -14,23 +14,23 @@ * limitations under the License. */ -#include "MaterialGlslChunk.h" +#include "MaterialTextChunk.h" namespace filamat { -MaterialGlslChunk::MaterialGlslChunk(const std::vector &entries, - LineDictionary &dictionary) : - GlslChunk(ChunkType::MaterialGlsl, entries, dictionary) { +MaterialTextChunk::MaterialTextChunk(const std::vector &entries, + LineDictionary &dictionary, ChunkType chunkType) : + TextChunk(chunkType, entries, dictionary) { } -void MaterialGlslChunk::writeEntryAttributes(size_t entryIndex, Flattener& f) { - const GlslEntry& entry = mEntries[entryIndex]; +void MaterialTextChunk::writeEntryAttributes(size_t entryIndex, Flattener& f) { + const TextEntry& entry = mEntries[entryIndex]; f.writeUint8(entry.shaderModel); f.writeUint8(entry.variant); f.writeUint8(entry.stage); } -const char* MaterialGlslChunk::getShaderText(size_t entryIndex) const { +const char* MaterialTextChunk::getShaderText(size_t entryIndex) const { return mEntries[entryIndex].shader; } diff --git a/libs/filamat/src/eiff/MaterialGlslChunk.h b/libs/filamat/src/eiff/MaterialTextChunk.h similarity index 72% rename from libs/filamat/src/eiff/MaterialGlslChunk.h rename to libs/filamat/src/eiff/MaterialTextChunk.h index 0c39e77536..c845368ab3 100644 --- a/libs/filamat/src/eiff/MaterialGlslChunk.h +++ b/libs/filamat/src/eiff/MaterialTextChunk.h @@ -14,26 +14,27 @@ * limitations under the License. */ -#ifndef TNT_FILAMAT_MATERIAL_GLSL_CHUNK_H -#define TNT_FILAMAT_MATERIAL_GLSL_CHUNK_H +#ifndef TNT_FILAMAT_MATERIAL_TEXT_CHUNK_H +#define TNT_FILAMAT_MATERIAL_TEXT_CHUNK_H #include #include "Chunk.h" -#include "GlslChunk.h" +#include "TextChunk.h" #include "LineDictionary.h" #include "ShaderEntry.h" namespace filamat { -class MaterialGlslChunk final : public GlslChunk { +class MaterialTextChunk final : public TextChunk { public: - MaterialGlslChunk(const std::vector &entries, LineDictionary &dictionary); - ~MaterialGlslChunk() = default; + MaterialTextChunk(const std::vector &entries, LineDictionary &dictionary, + ChunkType chunkType); + ~MaterialTextChunk() = default; protected: virtual const char* getShaderText(size_t entryIndex) const override; virtual void writeEntryAttributes(size_t entryIndex, Flattener& f) override; }; } // namespace filamat -#endif // TNT_FILAMAT_GLSL_CHUNK_H +#endif // TNT_FILAMAT_TEXT_CHUNK_H diff --git a/libs/filamat/src/eiff/ShaderEntry.h b/libs/filamat/src/eiff/ShaderEntry.h index 2a3243cbd1..9fe4bb1fe5 100644 --- a/libs/filamat/src/eiff/ShaderEntry.h +++ b/libs/filamat/src/eiff/ShaderEntry.h @@ -19,7 +19,8 @@ namespace filamat { -struct GlslEntry { +// TextEntry stores a shader in ASCII text format, like GLSL. +struct TextEntry { uint8_t shaderModel; uint8_t variant; uint8_t stage; diff --git a/libs/filamat/src/eiff/GlslChunk.h b/libs/filamat/src/eiff/TextChunk.h similarity index 94% rename from libs/filamat/src/eiff/GlslChunk.h rename to libs/filamat/src/eiff/TextChunk.h index ac4c79125f..482b84c791 100644 --- a/libs/filamat/src/eiff/GlslChunk.h +++ b/libs/filamat/src/eiff/TextChunk.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef TNT_FILAMAT_GLSL_CHUNK_H -#define TNT_FILAMAT_GLSL_CHUNK_H +#ifndef TNT_FILAMAT_TEXT_CHUNK_H +#define TNT_FILAMAT_TEXT_CHUNK_H #include @@ -30,11 +30,11 @@ using namespace utils; namespace filamat { template -class GlslChunk : public Chunk { +class TextChunk : public Chunk { public: - virtual ~GlslChunk() = default; + virtual ~TextChunk() = default; protected: - GlslChunk(ChunkType type, const std::vector& entries, const LineDictionary& dictionary) : + TextChunk(ChunkType type, const std::vector& entries, const LineDictionary& dictionary) : Chunk(type), mDictionary(dictionary), mEntries(entries) { } @@ -132,4 +132,4 @@ protected: } // namespace filamat -#endif // TNT_FILAMAT_GLSL_CHUNK_H +#endif // TNT_FILAMAT_TEXT_CHUNK_H