Commit c61271e5 by Chris Forbes

Add epilog pass to copy outputs out to pipeline

Bug: b/124177079 Change-Id: I1779ed78ccfdb6c77bcf55ba109ae93fc75171ff Reviewed-on: https://swiftshader-review.googlesource.com/c/24989Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 58bee563
......@@ -42,6 +42,7 @@ namespace sw
}
spirvShader->emit(&routine);
spirvShader->emitEpilog(&routine);
for(int i = 0; i < RENDERTARGETS; i++)
{
......
......@@ -32,7 +32,7 @@ namespace sw
PixelRoutine::PixelRoutine(const PixelProcessor::State &state, SpirvShader const *spirvShader)
: QuadRasterizer(state, spirvShader) /* addressing */
{
spirvShader->emitEarly(&routine);
spirvShader->emitProlog(&routine);
if (forceClearRegisters)
{
......
......@@ -643,7 +643,7 @@ namespace sw
// emit-time
void SpirvShader::emitEarly(SpirvRoutine *routine) const
void SpirvShader::emitProlog(SpirvRoutine *routine) const
{
for (auto insn : *this)
{
......@@ -795,4 +795,32 @@ namespace sw
}
}
}
void SpirvShader::emitEpilog(SpirvRoutine *routine) const
{
for (auto insn : *this)
{
switch (insn.opcode())
{
case spv::OpVariable:
{
auto resultId = insn.word(2);
auto &object = getObject(resultId);
if (object.kind == Object::Kind::InterfaceVariable && object.storageClass == spv::StorageClassOutput)
{
auto &dst = routine->getValue(resultId);
int offset = 0;
VisitInterface(resultId,
[&](Decorations const &d, AttribType type) {
auto scalarSlot = d.Location << 2 | d.Component;
routine->outputs[scalarSlot] = dst[offset++];
});
}
break;
}
default:
break;
}
}
}
}
......@@ -313,9 +313,9 @@ namespace sw
std::vector<InterfaceComponent> inputs;
std::vector<InterfaceComponent> outputs;
void emitEarly(SpirvRoutine *routine) const;
void emitProlog(SpirvRoutine *routine) const;
void emit(SpirvRoutine *routine) const;
void emitEpilog(SpirvRoutine *routine) const;
using BuiltInHash = std::hash<std::underlying_type<spv::BuiltIn>::type>;
std::unordered_map<spv::BuiltIn, BuiltinMapping, BuiltInHash> inputBuiltins;
......
......@@ -66,6 +66,8 @@ namespace sw
{
Nucleus::setInsertBlock(returnBlock);
}
spirvShader->emitEpilog(&routine);
}
RValue<Pointer<Byte>> VertexProgram::uniformAddress(int bufferIndex, unsigned int index)
......
......@@ -28,7 +28,7 @@ namespace sw
: state(state),
spirvShader(spirvShader)
{
spirvShader->emitEarly(&routine);
spirvShader->emitProlog(&routine);
}
VertexRoutine::~VertexRoutine()
......
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