Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docs/debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ Within this `RUN` block, you may declare any number of `THREAD` command blocks t

Defines a sequence of debugger commands to run when the shader invocation for the fragment with the given window space position is executed.

TODO(bclayton): This has not yet been implemented.

Each of the `THREAD` commands begins a block that must be terminated with an `END`.

Within each `THREAD` command block, you may use any of the following commands to control execution of the shader, and to verify the debugger's behaviour:
Expand Down
18 changes: 18 additions & 0 deletions src/amberscript/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,24 @@ Result Parser::ParseDebugThread(debug::Events* dbg) {
}

dbg->BreakOnVertexIndex(vertex_index, thread);
} else if (token->AsString() == "FRAGMENT_WINDOW_SPACE_POSITION") {
token = tokenizer_->NextToken();
if (!token->IsInteger())
return Result("expected x unsigned integer coordinate");
auto x = token->AsUint32();

token = tokenizer_->NextToken();
if (!token->IsInteger())
return Result("expected y unsigned integer coordinate");
auto y = token->AsUint32();

auto thread = debug::ThreadScript::Create();
auto result = ParseDebugThreadBody(thread.get());
if (!result.IsSuccess()) {
return result;
}

dbg->BreakOnFragmentWindowSpacePosition(x, y, thread);
} else {
return Result("expected GLOBAL_INVOCATION_ID or VERTEX_INDEX");
}
Expand Down
9 changes: 9 additions & 0 deletions src/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ class ScriptImpl : public Script {
[=](Events* events) { events->BreakOnVertexIndex(index, thread); });
}

void BreakOnFragmentWindowSpacePosition(
uint32_t x,
uint32_t y,
const std::shared_ptr<const ThreadScript>& thread) override {
sequence_.emplace_back([=](Events* events) {
events->BreakOnFragmentWindowSpacePosition(x, y, thread);
});
}

private:
using Event = std::function<void(Events*)>;
std::vector<Event> sequence_;
Expand Down
11 changes: 10 additions & 1 deletion src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,19 @@ class Events {

/// BreakOnVertexIndex instructs the debugger to set a breakpoint at the start
/// of the vertex shader program for the invocation with the vertex index
/// [index], and run the |ThreadScript| once the breakpoint is hit.
/// |index|, and run the |ThreadScript| once the breakpoint is hit.
virtual void BreakOnVertexIndex(
uint32_t index,
const std::shared_ptr<const ThreadScript>&) = 0;

/// BreakOnFragmentWindowSpacePosition instructs the debugger to set a
/// breakpoint at the start of the fragment shader program for the invocation
/// with the window space coordinate [x, y], and run the |ThreadScript| once
/// the breakpoint is hit.
virtual void BreakOnFragmentWindowSpacePosition(
uint32_t x,
uint32_t y,
const std::shared_ptr<const ThreadScript>&) = 0;
};

/// ThreadScript is a specialization of the |amber::debug::Thread| interface,
Expand Down
Loading