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 fe52c04
Show file tree
Hide file tree
Showing 4 changed files with 71 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
63 changes: 63 additions & 0 deletions tatic_castUint32(Json.size());
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
diff --git a/RenderStateNotation/scripts/cxx_config.py b/RenderStateNotation/scripts/cxx_config.py
index bf11ff1..662d183 100644
--- a/RenderStateNotation/scripts/cxx_config.py
+++ b/RenderStateNotation/scripts/cxx_config.py
@@ -60,7 +60,6 @@ CXX_REGISTERED_STRUCT = {

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

diff --git a/RenderStateNotation/scripts/cxx_template.py b/RenderStateNotation/scripts/cxx_template.py
index 6e02f02..fccb40b 100644
--- a/RenderStateNotation/scripts/cxx_template.py
+++ b/RenderStateNotation/scripts/cxx_template.py
@@ -65,9 +65,9 @@ constexpr Uint32 JsonUnexpectedKey = 501;
} \
} while (false)

-void WriteRSN(nlohmann::json& Json, const ShaderMacro& Type, DynamicLinearAllocator& Allocator);
+void WriteRSN(nlohmann::json& Json, const ShaderMacroArray& Type, DynamicLinearAllocator& Allocator);

-void ParseRSN(const nlohmann::json& Json, ShaderMacro& Type, DynamicLinearAllocator& Allocator);
+void ParseRSN(const nlohmann::json& Json, ShaderMacroArray& Type, DynamicLinearAllocator& Allocator);

template <typename Type, std::enable_if_t<!std::is_pointer<Type>::value, bool> = true>
inline void WriteRSN(nlohmann::json& Json, const Type& Object, DynamicLinearAllocator& Allocator)
@@ -158,27 +158,28 @@ inline void ParseRSN(const nlohmann::json& Json, const char*& Str, DynamicLinear
}

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)

0 comments on commit fe52c04

Please sign in to comment.