Skip to content

Commit 56aacf1

Browse files
committed
Address co-pilot comment about shadername generation
1 parent 1904ded commit 56aacf1

6 files changed

Lines changed: 14 additions & 22 deletions

File tree

source/MaterialXTest/MaterialXRender/RenderUtil.h

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,30 +190,22 @@ struct RenderItem
190190
: element(std::move(elem)),
191191
imageSearchPath(std::move(searchPath)),
192192
outputPath(std::move(outPath)),
193-
imageVec(images) {}
193+
imageVec(images)
194+
{
195+
mx::StringMap pathMap;
196+
pathMap["/"] = "_";
197+
pathMap[":"] = "_";
198+
shaderName = mx::createValidName(
199+
mx::replaceSubstrings(element->getNamePath(), pathMap));
200+
}
194201

195202
mx::TypedElementPtr element;
196203
mx::FileSearchPath imageSearchPath;
197204
mx::FilePath outputPath;
198205
mx::ImageVec* imageVec = nullptr;
199-
200-
const std::string& shaderName() const
201-
{
202-
if (_cachedShaderName.empty())
203-
{
204-
mx::StringMap pathMap;
205-
pathMap["/"] = "_";
206-
pathMap[":"] = "_";
207-
_cachedShaderName = mx::createValidName(
208-
mx::replaceSubstrings(element->getNamePath(), pathMap));
209-
}
210-
return _cachedShaderName;
211-
}
206+
std::string shaderName;
212207

213208
mx::DocumentPtr doc() const { return element->getDocument(); }
214-
215-
private:
216-
mutable std::string _cachedShaderName;
217209
};
218210

219211
// Returned by runRenderer — each call produces its own isolated profiling data.

source/MaterialXTest/MaterialXRenderGlsl/RenderGlsl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ RenderUtil::RenderProfileResult GlslShaderRenderTester::runRenderer(
151151
mx::GenContext& context)
152152
{
153153
RenderUtil::RenderProfileResult result;
154-
const std::string& shaderName = item.shaderName();
154+
const std::string& shaderName = item.shaderName;
155155
mx::DocumentPtr doc = item.doc();
156156
mx::TypedElementPtr element = item.element;
157157
const GenShaderUtil::TestSuiteOptions& testOptions = session.testOptions;

source/MaterialXTest/MaterialXRenderMdl/RenderMdl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ RenderUtil::RenderProfileResult MdlShaderRenderTester::runRenderer(
4646
mx::GenContext& context)
4747
{
4848
RenderUtil::RenderProfileResult result;
49-
const std::string& shaderName = item.shaderName();
49+
const std::string& shaderName = item.shaderName;
5050
mx::DocumentPtr doc = item.doc();
5151
mx::TypedElementPtr element = item.element;
5252
const GenShaderUtil::TestSuiteOptions& testOptions = session.testOptions;

source/MaterialXTest/MaterialXRenderMsl/RenderMsl.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void registerLights(mx::DocumentPtr document, const GenShaderUtil::TestSuiteOpti
158158
mx::GenContext& context)
159159
{
160160
RenderUtil::RenderProfileResult result;
161-
const std::string& shaderName = item.shaderName();
161+
const std::string& shaderName = item.shaderName;
162162
mx::DocumentPtr doc = item.doc();
163163
mx::TypedElementPtr element = item.element;
164164
const GenShaderUtil::TestSuiteOptions& testOptions = session.testOptions;

source/MaterialXTest/MaterialXRenderOsl/RenderOsl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ RenderUtil::RenderProfileResult OslShaderRenderTester::runRenderer(
194194
mx::GenContext& context)
195195
{
196196
RenderUtil::RenderProfileResult result;
197-
const std::string& shaderName = item.shaderName();
197+
const std::string& shaderName = item.shaderName;
198198
mx::DocumentPtr doc = item.doc();
199199
mx::TypedElementPtr element = item.element;
200200
const GenShaderUtil::TestSuiteOptions& testOptions = session.testOptions;

source/MaterialXTest/MaterialXRenderSlang/RenderSlang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ RenderUtil::RenderProfileResult SlangShaderRenderTester::runRenderer(
150150
mx::GenContext& context)
151151
{
152152
RenderUtil::RenderProfileResult result;
153-
const std::string& shaderName = item.shaderName();
153+
const std::string& shaderName = item.shaderName;
154154
mx::DocumentPtr doc = item.doc();
155155
mx::TypedElementPtr element = item.element;
156156
const GenShaderUtil::TestSuiteOptions& testOptions = session.testOptions;

0 commit comments

Comments
 (0)