Commit 4a979dc3 by Chris Forbes

Formatting-only change: conform better with swiftshader style

Change-Id: I5241cb398aa294a702c0f70980b80d399dfbc5b0 Reviewed-on: https://swiftshader-review.googlesource.com/c/23689Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent a1cd1190
...@@ -29,49 +29,53 @@ namespace sw ...@@ -29,49 +29,53 @@ namespace sw
// - Input / Output interface blocks, builtin or otherwise, have been split. // - Input / Output interface blocks, builtin or otherwise, have been split.
// - The only input/output OpVariables present are those used by the entrypoint // - The only input/output OpVariables present are those used by the entrypoint
for (auto insn : *this) { for (auto insn : *this)
switch (insn.opcode()) { {
case spv::OpExecutionMode: switch (insn.opcode())
ProcessExecutionMode(insn); {
break; case spv::OpExecutionMode:
ProcessExecutionMode(insn);
break;
case spv::OpTypeVoid: case spv::OpTypeVoid:
case spv::OpTypeBool: case spv::OpTypeBool:
case spv::OpTypeInt: case spv::OpTypeInt:
case spv::OpTypeFloat: case spv::OpTypeFloat:
case spv::OpTypeVector: case spv::OpTypeVector:
case spv::OpTypeMatrix: case spv::OpTypeMatrix:
case spv::OpTypeImage: case spv::OpTypeImage:
case spv::OpTypeSampler: case spv::OpTypeSampler:
case spv::OpTypeSampledImage: case spv::OpTypeSampledImage:
case spv::OpTypeArray: case spv::OpTypeArray:
case spv::OpTypeRuntimeArray: case spv::OpTypeRuntimeArray:
case spv::OpTypeStruct: case spv::OpTypeStruct:
case spv::OpTypePointer: case spv::OpTypePointer:
case spv::OpTypeFunction: { case spv::OpTypeFunction:
auto resultId = insn.word(1); {
auto &object = defs[resultId]; auto resultId = insn.word(1);
object.kind = Object::Kind::Type; auto &object = defs[resultId];
object.definition = insn; object.kind = Object::Kind::Type;
break; object.definition = insn;
} break;
}
case spv::OpVariable: { case spv::OpVariable:
auto typeId = insn.word(1); {
auto resultId = insn.word(2); auto typeId = insn.word(1);
auto storageClass = static_cast<spv::StorageClass>(insn.word(3)); auto resultId = insn.word(2);
if (insn.wordCount() > 4) auto storageClass = static_cast<spv::StorageClass>(insn.word(3));
UNIMPLEMENTED("Variable initializers not yet supported"); if (insn.wordCount() > 4)
UNIMPLEMENTED("Variable initializers not yet supported");
auto &object = defs[resultId]; auto &object = defs[resultId];
object.kind = Object::Kind::Variable; object.kind = Object::Kind::Variable;
object.definition = insn; object.definition = insn;
object.storageClass = storageClass; object.storageClass = storageClass;
break; break;
} }
default: default:
break; // This is OK, these passes are intentionally partial break; // This is OK, these passes are intentionally partial
} }
} }
} }
...@@ -79,32 +83,33 @@ namespace sw ...@@ -79,32 +83,33 @@ namespace sw
void SpirvShader::ProcessExecutionMode(InsnIterator insn) void SpirvShader::ProcessExecutionMode(InsnIterator insn)
{ {
auto mode = static_cast<spv::ExecutionMode>(insn.word(2)); auto mode = static_cast<spv::ExecutionMode>(insn.word(2));
switch (mode) { switch (mode)
case spv::ExecutionModeEarlyFragmentTests: {
modes.EarlyFragmentTests = true; case spv::ExecutionModeEarlyFragmentTests:
break; modes.EarlyFragmentTests = true;
case spv::ExecutionModeDepthReplacing: break;
modes.DepthReplacing = true; case spv::ExecutionModeDepthReplacing:
break; modes.DepthReplacing = true;
case spv::ExecutionModeDepthGreater: break;
modes.DepthGreater = true; case spv::ExecutionModeDepthGreater:
break; modes.DepthGreater = true;
case spv::ExecutionModeDepthLess: break;
modes.DepthLess = true; case spv::ExecutionModeDepthLess:
break; modes.DepthLess = true;
case spv::ExecutionModeDepthUnchanged: break;
modes.DepthUnchanged = true; case spv::ExecutionModeDepthUnchanged:
break; modes.DepthUnchanged = true;
case spv::ExecutionModeLocalSize: break;
modes.LocalSizeX = insn.word(3); case spv::ExecutionModeLocalSize:
modes.LocalSizeZ = insn.word(5); modes.LocalSizeX = insn.word(3);
modes.LocalSizeY = insn.word(4); modes.LocalSizeZ = insn.word(5);
break; modes.LocalSizeY = insn.word(4);
case spv::ExecutionModeOriginUpperLeft: break;
// This is always the case for a Vulkan shader. Do nothing. case spv::ExecutionModeOriginUpperLeft:
break; // This is always the case for a Vulkan shader. Do nothing.
default: break;
UNIMPLEMENTED("No other execution modes are permitted"); default:
UNIMPLEMENTED("No other execution modes are permitted");
} }
} }
} }
\ No newline at end of file
...@@ -44,7 +44,9 @@ namespace sw ...@@ -44,7 +44,9 @@ namespace sw
} }
uint32_t wordCount() const uint32_t wordCount() const
{ return *iter >> spv::WordCountShift; } {
return *iter >> spv::WordCountShift;
}
uint32_t word(uint32_t n) const uint32_t word(uint32_t n) const
{ {
...@@ -58,7 +60,9 @@ namespace sw ...@@ -58,7 +60,9 @@ namespace sw
} }
InsnIterator operator*() const InsnIterator operator*() const
{ return *this; } {
return *this;
}
InsnIterator &operator++() InsnIterator &operator++()
{ {
...@@ -78,15 +82,20 @@ namespace sw ...@@ -78,15 +82,20 @@ namespace sw
InsnIterator() = default; InsnIterator() = default;
explicit InsnIterator(InsnStore::const_iterator iter) : iter{iter} explicit InsnIterator(InsnStore::const_iterator iter) : iter{iter}
{} {
}
}; };
/* range-based-for interface */ /* range-based-for interface */
InsnIterator begin() const InsnIterator begin() const
{ return InsnIterator{insns.cbegin() + 5}; } {
return InsnIterator{insns.cbegin() + 5};
}
InsnIterator end() const InsnIterator end() const
{ return InsnIterator{insns.cend()}; } {
return InsnIterator{insns.cend()};
}
class Object class Object
{ {
...@@ -104,7 +113,9 @@ namespace sw ...@@ -104,7 +113,9 @@ namespace sw
}; };
int getSerialID() const int getSerialID() const
{ return serialID; } {
return serialID;
}
explicit SpirvShader(InsnStore const &insns); explicit SpirvShader(InsnStore const &insns);
...@@ -121,7 +132,9 @@ namespace sw ...@@ -121,7 +132,9 @@ namespace sw
}; };
Modes const &getModes() const Modes const &getModes() const
{ return modes; } {
return modes;
}
private: private:
const int serialID; const int serialID;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment