Skip to content

Commit

Permalink
Updates to match API253011
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailGorobets committed Jul 24, 2023
1 parent e1661f6 commit 062a178
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion RenderStateNotation/scripts/cxx_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

"ShaderDesc",
"ShaderMacro",
"ShaderMacroArray",
"ShaderResourceDesc",
"ShaderCreateInfo",

Expand Down
15 changes: 7 additions & 8 deletions RenderStateNotation/scripts/cxx_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,27 @@
Str = Allocator.CopyString(Json.get<std::string>());
}
template <>
inline void WriteRSN(nlohmann::json& Json, const ShaderMacro* const pMacros, DynamicLinearAllocator& Allocator)
inline void WriteRSN(nlohmann::json& Json, const ShaderMacroArray& Macros, DynamicLinearAllocator& Allocator)
{
for (size_t i = 0; pMacros[i].Name != nullptr || pMacros[i].Definition != nullptr; i++)
for (size_t i = 0; Macros.Count; i++)
{
auto Object = nlohmann::json::object();
WriteRSN(Object, pMacros[i], Allocator);
WriteRSN(Object, Macros.Elements[i], Allocator);
Json.push_back(Object);
}
}
template <>
inline void ParseRSN(const nlohmann::json& Json, const ShaderMacro*& pMacros, DynamicLinearAllocator& Allocator)
inline void ParseRSN(const nlohmann::json& Json, ShaderMacroArray& Macros, DynamicLinearAllocator& Allocator)
{
if (!Json.is_array())
throw nlohmann::json::type_error::create(JsonTypeError, std::string("type must be array, but is ") + Json.type_name(), Json);
auto* pData = Allocator.ConstructArray<ShaderMacro>(Json.size() + 1);
auto* pData = Allocator.ConstructArray<ShaderMacro>(Json.size());
for (size_t i = 0; i < Json.size(); i++)
ParseRSN(Json[i], pData[i], Allocator);
pMacros = pData;
Macros.Elements = pData;
Macros.Count = static_cast<Uint32>(Json.size());
}
inline void ParseRSN(const nlohmann::json& Json, const Char**& pObjects, Uint32& NumElements, DynamicLinearAllocator& Allocator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ TEST(Tools_RenderStateNotationParser, ParseShaderCreateInfo)
EXPECT_STREQ(DescReference.Desc.Name, Desc.Desc.Name);
EXPECT_EQ(DescReference.Desc, Desc.Desc);
EXPECT_EQ(DescReference.SourceLanguage, Desc.SourceLanguage);
EXPECT_EQ(DescReference.Macros.Count, Desc.Macros.Count);
EXPECT_EQ(DescReference.Macros[0], Desc.Macros[0]);
EXPECT_EQ(DescReference.Macros[1], Desc.Macros[1]);
EXPECT_EQ(DescReference.Macros[2], Desc.Macros[2]);

EXPECT_TRUE(SafeStrEqual(DescReference.FilePath, Desc.FilePath));
EXPECT_TRUE(SafeStrEqual(DescReference.EntryPoint, Desc.EntryPoint));
Expand Down

0 comments on commit 062a178

Please sign in to comment.