Skip to content

Commit a888ede

Browse files
chellmuthChris Hellmuth
authored andcommitted
clang-format
1 parent 12f1d4a commit a888ede

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

source/MaterialXGenOsl/LibsToOso.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
namespace mx = MaterialX;
2323

24-
2524
const std::string setCiOslNetworkSource = R"(
2625
2726
#include "mx_funcs.h"
@@ -93,8 +92,6 @@ shader setCi (
9392
}
9493
)";
9594

96-
97-
9895
const std::string options =
9996
" Options: \n"
10097
" --outputOsoPath [DIRPATH] TODO\n"
@@ -313,7 +310,8 @@ int main(int argc, char* const argv[])
313310
catch (mx::ExceptionRenderError& exc)
314311
{
315312
std::cout << "Encountered a codegen/compilation related exception for the "
316-
"following node: " << std::endl;
313+
"following node: "
314+
<< std::endl;
317315
std::cout << exc.what() << std::endl;
318316

319317
// Dump details about the exception in the log file.
@@ -327,13 +325,12 @@ int main(int argc, char* const argv[])
327325
// Catch any other exceptions
328326
catch (mx::Exception& exc)
329327
{
330-
std::cout << "Failed to codegen/compile the following node to OSL: " << std::endl;
328+
std::cout << "Failed to codegen/compile the following node to OSL: " << std::endl;
331329
std::cout << exc.what() << std::endl;
332330

333331
hasFailed = true;
334332
}
335333

336-
337334
// We create and use a dedicated `NodeGraph` to avoid `NodeDef` names collision.
338335
mx::NodeGraphPtr librariesDocGraph = librariesDoc->addNodeGraph("librariesDocGraph");
339336

@@ -434,7 +431,7 @@ int main(int argc, char* const argv[])
434431
}
435432
}
436433

437-
mx::writeToXmlFile(implMtlxDoc, implMtlxDocFilePath);
434+
mx::writeToXmlFile(implMtlxDoc, implMtlxDocFilePath);
438435

439436
// If something went wrong, return an appropriate error code.
440437
if (hasFailed)

source/MaterialXGenOsl/OslNetworkShaderGenerator.cpp

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <MaterialXGenShader/TypeDesc.h>
1313
#include <MaterialXGenShader/ShaderStage.h>
1414

15-
1615
MATERIALX_NAMESPACE_BEGIN
1716

1817
const string OslNetworkShaderGenerator::TARGET = "genoslnetwork";
@@ -56,20 +55,22 @@ ShaderPtr OslNetworkShaderGenerator::generate(const string& name, ElementPtr ele
5655
std::set<std::string> osoPaths;
5756

5857
// Walk the node graph, emitting shaders and param declarations.
59-
for (auto&& node : graph.getNodes()) {
58+
for (auto&& node : graph.getNodes())
59+
{
6060
const string& nodeName = node->getName();
6161

62-
for (auto&& input : node->getInputs()) {
62+
for (auto&& input : node->getInputs())
63+
{
6364
string inputName = input->getName();
6465
_syntax->makeValidName(inputName);
6566

6667
const ShaderOutput* connection = input->getConnection();
67-
if (!connection || connection->getNode() == &graph) {
68+
if (!connection || connection->getNode() == &graph)
69+
{
6870
if (!input->hasAuthoredValue())
6971
continue;
7072

71-
if (input->getName() == "backsurfaceshader"
72-
|| input->getName() == "displacementshader")
73+
if (input->getName() == "backsurfaceshader" || input->getName() == "displacementshader")
7374
continue; // FIXME: these aren't getting pruned by hasAuthoredValue
7475

7576
string value = _syntax->getValue(input);
@@ -78,30 +79,37 @@ ShaderPtr OslNetworkShaderGenerator::generate(const string& name, ElementPtr ele
7879

7980
// TODO: Figure out how to avoid special-casing struct-types in the generator, perhaps in the syntax?
8081
auto inputType = input->getType();
81-
if (inputType == Type::VECTOR2) {
82+
if (inputType == Type::VECTOR2)
83+
{
8284
auto parts = splitString(value, " ");
8385
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".x", parts[0]), stage, false);
8486
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".y", parts[1]), stage, false);
8587
}
86-
else if (inputType == Type::VECTOR4) {
88+
else if (inputType == Type::VECTOR4)
89+
{
8790
auto parts = splitString(value, " ");
8891
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".x", parts[0]), stage, false);
8992
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".y", parts[1]), stage, false);
9093
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".z", parts[2]), stage, false);
91-
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".w", parts[3]), stage, false);}
92-
else if (inputType == Type::COLOR4) {
94+
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".w", parts[3]), stage, false);
95+
}
96+
else if (inputType == Type::COLOR4)
97+
{
9398
auto parts = splitString(value, " ");
9499
emitLine(paramString(_syntax->getTypeName(Type::COLOR3), inputName + ".rgb", parts[0] + " " + parts[1] + " " + parts[2]), stage, false);
95100
emitLine(paramString(_syntax->getTypeName(Type::FLOAT), inputName + ".a", parts[3]), stage, false);
96101
}
97-
else {
102+
else
103+
{
98104
emitLine(paramString(_syntax->getTypeName(input->getType()), inputName, value), stage, false);
99105
}
100-
} else {
106+
}
107+
else
108+
{
101109
string connName = connection->getName();
102110
_syntax->makeValidName(connName);
103111

104-
string connect = connectString(connection->getNode()->getName(), connName, nodeName, inputName);
112+
string connect = connectString(connection->getNode()->getName(), connName, nodeName, inputName);
105113
// Save connect emits for the end, because they can't come
106114
// before both connected shaders have been declared.
107115
connections.push_back(connect);
@@ -121,24 +129,26 @@ ShaderPtr OslNetworkShaderGenerator::generate(const string& name, ElementPtr ele
121129
lastNodeName = nodeName;
122130
}
123131

124-
if (!lastOutput) {
132+
if (!lastOutput)
133+
{
125134
printf("Invalid shader\n");
126135
return nullptr;
127136
}
128137

129-
for (auto&& connect : connections) {
138+
for (auto&& connect : connections)
139+
{
130140
emitLine(connect, stage, false);
131141
}
132142

133143
// During unit tests, wrap a special node that will add the output to Ci.
134-
if (context.getOptions().oslNetworkConnectCiWrapper) {
144+
if (context.getOptions().oslNetworkConnectCiWrapper)
145+
{
135146
emitLine("shader setCi root ;", stage, false);
136147
string connect = connectString(
137148
lastNodeName,
138149
lastOutput->getName(),
139150
"root",
140-
lastOutput->getType().getName() + "_input"
141-
);
151+
lastOutput->getType().getName() + "_input");
142152
emitLine(connect, stage, false);
143153
}
144154

@@ -159,7 +169,6 @@ ShaderPtr OslNetworkShaderGenerator::generate(const string& name, ElementPtr ele
159169
return shader;
160170
}
161171

162-
163172
ShaderPtr OslNetworkShaderGenerator::createShader(const string& name, ElementPtr element, GenContext& context) const
164173
{
165174
// Create the root shader graph
@@ -197,7 +206,6 @@ ShaderPtr OslNetworkShaderGenerator::createShader(const string& name, ElementPtr
197206
return shader;
198207
}
199208

200-
201209
namespace OSLNetwork
202210
{
203211

@@ -206,6 +214,6 @@ const string UNIFORMS = "u";
206214
const string INPUTS = "i";
207215
const string OUTPUTS = "o";
208216

209-
} // namespace OSL
217+
} // namespace OSLNetwork
210218

211219
MATERIALX_NAMESPACE_END

source/MaterialXGenOsl/OslNetworkShaderGenerator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class MX_GENOSL_API OslNetworkShaderGenerator : public ShaderGenerator
5151
protected:
5252
/// Create and initialize a new OSL shader for shader generation.
5353
virtual ShaderPtr createShader(const string& name, ElementPtr element, GenContext& context) const;
54-
5554
};
5655

5756
namespace OSLNetwork
@@ -62,7 +61,7 @@ extern MX_GENOSL_API const string UNIFORMS;
6261
extern MX_GENOSL_API const string INPUTS;
6362
extern MX_GENOSL_API const string OUTPUTS;
6463

65-
} // namespace OSL
64+
} // namespace OSLNetwork
6665

6766
MATERIALX_NAMESPACE_END
6867

source/MaterialXTest/MaterialXRenderOsl/RenderOsl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ bool OslShaderRenderTester::runRenderer(const std::string& shaderName,
311311

312312
const std::string& outputName = output->getVariable();
313313
const std::string& outputType = typeSyntax.getTypeAlias().empty() ? typeSyntax.getName() : typeSyntax.getTypeAlias();
314-
const std::string& sceneTemplateFile = (_useOslCmdStr ? "scene_template_oslcmd.xml": "scene_template.xml");
314+
const std::string& sceneTemplateFile = (_useOslCmdStr ? "scene_template_oslcmd.xml" : "scene_template.xml");
315315

316316
// Set shader output name and type to use
317317
_renderer->setOslShaderOutput(outputName, outputType);
@@ -323,7 +323,7 @@ bool OslShaderRenderTester::runRenderer(const std::string& shaderName,
323323
auto osoPathAttr = shader->getAttribute("osoPath");
324324
if (osoPathAttr)
325325
{
326-
_renderer->setDataLibraryOSOPath( osoPathAttr->getValueString() );
326+
_renderer->setDataLibraryOSOPath(osoPathAttr->getValueString());
327327
}
328328

329329
// Set scene template file. For now we only have the constant color scene file

0 commit comments

Comments
 (0)