Skip to content

Commit

Permalink
ShaderSourceFactoryUtils: fixed missing const
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 6, 2023
1 parent 17ebb85 commit ca3908f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Graphics/GraphicsTools/interface/ShaderSourceFactoryUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct CompoundShaderSourceFactoryCreateInfo
Uint32 NumFactories DEFAULT_INITIALIZER(0);

/// An array of shader source file substitutes.
ShaderSourceFileSubstitueInfo* pFileSubstitutes DEFAULT_INITIALIZER(nullptr);
const ShaderSourceFileSubstitueInfo* pFileSubstitutes DEFAULT_INITIALIZER(nullptr);

/// The number of file substitutes in pFileSubstitutes array.
Uint32 NumFileSubstitutes DEFAULT_INITIALIZER(0);
Expand All @@ -76,10 +76,10 @@ struct CompoundShaderSourceFactoryCreateInfo
constexpr CompoundShaderSourceFactoryCreateInfo() noexcept
{}

constexpr CompoundShaderSourceFactoryCreateInfo(IShaderSourceInputStreamFactory** _ppFactories,
Uint32 _NumFactories,
ShaderSourceFileSubstitueInfo* _pFileSubstitutes = nullptr,
Uint32 _NumFileSubstitutes = 0) noexcept :
constexpr CompoundShaderSourceFactoryCreateInfo(IShaderSourceInputStreamFactory** _ppFactories,
Uint32 _NumFactories,
const ShaderSourceFileSubstitueInfo* _pFileSubstitutes = nullptr,
Uint32 _NumFileSubstitutes = 0) noexcept :
ppFactories{_ppFactories},
NumFactories{_NumFactories},
pFileSubstitutes{_pFileSubstitutes},
Expand Down Expand Up @@ -139,7 +139,7 @@ typedef struct MemoryShaderSourceFileInfo MemoryShaderSourceFileInfo;
struct MemoryShaderSourceFactoryCreateInfo
{
/// An array of shader source files.
MemoryShaderSourceFileInfo* pSources DEFAULT_INITIALIZER(nullptr);
const MemoryShaderSourceFileInfo* pSources DEFAULT_INITIALIZER(nullptr);

/// The number of files in pSources array.
Uint32 NumSources DEFAULT_INITIALIZER(0);
Expand All @@ -152,10 +152,12 @@ struct MemoryShaderSourceFactoryCreateInfo
constexpr MemoryShaderSourceFactoryCreateInfo() noexcept
{}

constexpr MemoryShaderSourceFactoryCreateInfo(MemoryShaderSourceFileInfo* _pSources,
Uint32 _NumSources) noexcept :
constexpr MemoryShaderSourceFactoryCreateInfo(const MemoryShaderSourceFileInfo* _pSources,
Uint32 _NumSources,
bool _CopySources = false) noexcept :
pSources{_pSources},
NumSources{_NumSources}
NumSources{_NumSources},
CopySources{_CopySources}
{}
#endif
};
Expand Down
2 changes: 2 additions & 0 deletions Graphics/GraphicsTools/src/ShaderSourceFactoryUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ class MemoryShaderSourceFactory final : public ObjectBase<IShaderSourceInputStre
for (Uint32 i = 0; i < CI.NumSources; ++i)
{
const auto& Source = CI.pSources[i];
DEV_CHECK_ERR(Source.Name != nullptr && Source.Name[0] != '\0', "Source name must not be null or empty");
DEV_CHECK_ERR(Source.pData != nullptr, "Source data must not be null");
m_NameToSourceMap.emplace(HashMapStringKey{Source.Name, true}, CI.CopySources ? m_Sources[i].c_str() : Source.pData);
}
}
Expand Down

0 comments on commit ca3908f

Please sign in to comment.