Implement some easy to support extensions

This commit is contained in:
baldurk
2020-04-15 20:33:57 +01:00
parent def5476cf2
commit c91414782a
3 changed files with 51 additions and 4 deletions
+43 -2
View File
@@ -24,6 +24,7 @@
#include "spirv_debug.h"
#include <math.h>
#include <time.h>
#include "common/formatting.h"
#include "spirv_op_helpers.h"
@@ -63,7 +64,7 @@ ThreadState::ThreadState(uint32_t workgroupIdx, Debugger &debug, const GlobalSta
{
workgroupIndex = workgroupIdx;
nextInstruction = 0;
done = false;
helperInvocation = false;
}
ThreadState::~ThreadState()
@@ -75,7 +76,7 @@ ThreadState::~ThreadState()
bool ThreadState::Finished() const
{
return done || callstack.empty();
return helperInvocation || callstack.empty();
}
void ThreadState::FillCallstack(ShaderDebugState &state)
@@ -1809,6 +1810,46 @@ void ThreadState::StepNext(ShaderDebugState *state, const rdcarray<ThreadState>
break;
}
//////////////////////////////////////////////////////////////////////////////
//
// Misc opcodes
//
//////////////////////////////////////////////////////////////////////////////
case Op::ReadClockKHR:
{
const DataType &resultType = debugger.GetType(opdata.resultType);
ShaderVariable result;
result.type = resultType.scalar().Type();
result.rows = 1;
result.columns = RDCMAX(1U, resultType.vector().count);
result.value.u64v[0] = global.clock;
SetDst(state, opdata.result, result);
break;
}
case Op::IsHelperInvocationEXT:
{
ShaderVariable result;
result.type = VarType::UInt;
result.rows = 1;
result.columns = 1;
result.value.u.x = helperInvocation;
SetDst(state, opdata.result, result);
break;
}
case Op::DemoteToHelperInvocationEXT:
{
helperInvocation = true;
break;
}
//////////////////////////////////////////////////////////////////////////////
//
// Function flow control opcodes
+3 -1
View File
@@ -115,6 +115,8 @@ public:
rdcarray<ShaderVariable> samplers;
SparseIdMap<ExtInstDispatcher> extInsts;
uint64_t clock;
};
struct StackFrame
@@ -195,7 +197,7 @@ struct ThreadState
// index in the pixel quad
uint32_t workgroupIndex;
bool done;
bool helperInvocation;
const ShaderVariable &GetSrc(Id id) const;
@@ -339,6 +339,8 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const Shader
}
}
global.clock = uint64_t(time(NULL)) << 32;
for(auto it = extSets.begin(); it != extSets.end(); it++)
{
Id id = it->first;
@@ -638,7 +640,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *apiWrapper, const Shader
lane.outputs = active.outputs;
lane.ids = active.ids;
// mark as inactive/helper lane
lane.done = true;
lane.helperInvocation = true;
}
// now that the globals are allocated and their storage won't move, we can take pointers to them
@@ -774,6 +776,8 @@ rdcarray<ShaderDebugState> Debugger::ContinueDebug()
// do 100 in a chunk
for(int cycleCounter = 0; cycleCounter < 100; cycleCounter++)
{
global.clock++;
if(active.Finished())
break;