Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pseudo-commands for mid-execution capture. #1527

Merged
merged 30 commits into from
Feb 5, 2018

Conversation

AWoloszyn
Copy link
Contributor

@AWoloszyn AWoloszyn commented Jan 2, 2018

Instead of serializing pseudo-commands for mid-execution capture "eg: RecreateInstance", serialize the state block as-is.

Only re-create the state block when we need to on the server side.

TODO in a future MR:

  • Remove the cases where we generate the commands when not necessary
    1. Generating the dependency graph
    1. Resolving resources

# See the License for the specific language governing permissions and
# limitations under the License.

go_install()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be go_installl(DESTINATION ${TARGET_INSTALL_PATH})?

}

initialCmds := capt.GetInitialCommands(ctx)
_ = initialCmds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant?

if err != nil {
return err
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer f.Close() ?

@@ -69,7 +69,9 @@ bool ChunkWriterImpl::write(std::string& s) {
}

void ChunkWriterImpl::flush() {
mStreamGood = mWriter->write(mBuffer.data(), mBuffer.size());
size_t bufferSize = mBuffer.size();
// If we flush en empty buffer, this will return false, which is incorrect.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this comment is describing the stale code? Probably not necessary or should be changed for the new code here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - Andrew?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct, removed the comment.

@@ -48,6 +48,7 @@
#include <unordered_map>

namespace gapii {
const uint8_t kAllAPIs = 0xFF;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we can change the getEncoder to make is accept a bit mask, instead the shift value, so we can avoid using this 'mask' like thing with the 'shift value' like thing in should_trace()? Hmm, probably not in this CL anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would prefer to leave this for a future CL.

@@ -927,13 +1069,12 @@ func rebuildVkCmdDebugMarkerInsertEXT(
markerNameData.Free()
markerInfoData.Free()
}, cb.VkCmdDebugMarkerInsertEXT(commandBuffer, markerInfoData.Ptr()).AddRead(
markerNameData.Data()).AddRead(markerInfoData.Data())
markerNameData.Data()).AddRead(markerInfoData.Data()), nil
}

func GetCommandArgs(ctx context.Context,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should add comment for it?

@@ -79,6 +80,10 @@ func (e externs) callSub(ctx context.Context, cmd api.Cmd, id api.CmdID, s *api.
})
}

func (e externs) callSub(ctx context.Context, cmd api.Cmd, id api.CmdID, s *api.GlobalState, b *rb.Builder, sub, data interface{}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop it? It is only used once.

@@ -1035,6 +1176,108 @@ func GetCommandArgs(ctx context.Context,
}
}

func GetCommandFunction(cr CommandReference) interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blurbs?


// TODO: wherever possible, use old resources instead of doing full reads on the old pools.
// This is especially useful for things that are internal pools, (Shader words for example)
func (s *State) RebuildState(ctx context.Context, oldState *api.GlobalState) []api.Cmd {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blurbs?

if numHandled == 0 {
// There is a cycle in the basePipeline indices.
// Or the no base pipelines does exist.
// Create the rest without base pipelines
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it allowed to by cyclical? Probably we should emit an error in the report view for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it is technically allowed, but I want to at least continue to work if it is.
Hopefully the validation layers can catch this.

}

numHandled := 0
for len(unhandledPipelines) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like not optimal? Anyway, we can optimize it later if it matters.

Copy link
Contributor

@Qining Qining left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a fast read, Still reading the details of the code...

VkMemoryAllocateInfo{
VkStructureType_VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
NewVoidᶜᵖ(memory.Nullptr),
size * 2, // Overallocate by a factor of 2.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for the overallocate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to be documented in the code. 😉

func (sb *stateBuilder) getSparseQueueFor(lastBoundQueue *QueueObject, device VkDevice, queueFamilyIndices *map[uint32]uint32) *QueueObject {
hasQueueFamilyIndices := queueFamilyIndices != nil

queueProperties := sb.s.PhysicalDevices.Get(sb.s.Devices.Get(lastBoundQueue.Device).PhysicalDevice).QueueFamilyProperties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw lastBoundQueue != nil in the next line. So if it can be nil here, lastBoundQueue.Device will crash.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

size,
}).Ptr(),
VkResult_VK_SUCCESS,
).AddWrite(dat.Data()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be AddRead(dat.Data())

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

@AWoloszyn AWoloszyn changed the title WIP: Remove pseudo-commands for mid-execution capture. Remove pseudo-commands for mid-execution capture. Jan 30, 2018
Copy link
Contributor

@ben-clayton ben-clayton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address comments in follow up CLs once bazel branch is merged.

@@ -69,7 +69,9 @@ bool ChunkWriterImpl::write(std::string& s) {
}

void ChunkWriterImpl::flush() {
mStreamGood = mWriter->write(mBuffer.data(), mBuffer.size());
size_t bufferSize = mBuffer.size();
// If we flush en empty buffer, this will return false, which is incorrect.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question - Andrew?

gapii/cc/pool.h Outdated
@@ -25,6 +25,9 @@ namespace gapii {
class Pool {
public:
static std::shared_ptr<Pool> create(uint32_t id, uint64_t size);
// This creates a pool that can be serialized, but has no actual
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Indent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -90,7 +90,10 @@ inline Slice<T>::Slice() : mBase(nullptr), mCount(0) {}
template<typename T>
inline Slice<T>::Slice(T* base, uint64_t count, const std::shared_ptr<Pool>& pool)
: mBase(base), mCount(count), mPool(pool) {
GAPID_ASSERT(mBase != nullptr || count == 0 /* Slice: null pointer */);

if (!mPool || !mPool->is_virtual()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is mPool null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC mPool is nullptr, if this is the application pool. I might be wrong, but I think that is the reasoning for this logic.

gapii/cc/spy.cpp Outdated
@@ -483,14 +510,14 @@ void Spy::onPostFrameBoundary(bool isStartOfFrame) {
exit();
set_suspended(false);
saveInitialSate();
set_recording_state(true);
//set_recording_state(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should all be cleaned up and gone now. Not sure why it shows in this CR.

// There is a cycle in the basePipeline indices.
// Or the no base pipelines does exist.
// Create the rest without base pipelines
for k, _ := range unhandledPipelines {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superdooperübernit:

for k := range unhandledPipelines {

Is more idiomatic

VkMemoryAllocateInfo{
VkStructureType_VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
NewVoidᶜᵖ(memory.Nullptr),
size * 2, // Overallocate by a factor of 2.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to be documented in the code. 😉

size,
}).Ptr(),
VkResult_VK_SUCCESS,
).AddWrite(dat.Data()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

func (sb *stateBuilder) getSparseQueueFor(lastBoundQueue *QueueObject, device VkDevice, queueFamilyIndices *map[uint32]uint32) *QueueObject {
hasQueueFamilyIndices := queueFamilyIndices != nil

queueProperties := sb.s.PhysicalDevices.Get(sb.s.Devices.Get(lastBoundQueue.Device).PhysicalDevice).QueueFamilyProperties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping

func (*State) SetupInitialState(ctx context.Context) {}

func (*State) RebuildState(ctx context.Context, s *api.GlobalState) []api.Cmd { return nil }
func (c *State) SetupInitialState(ctx context.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs please

Instead of passing across synthetic commands, pass across the
entire state block. This allows us to more efficiently handle the
state block on the server side.
We were accidentally removing all buffer descriptor sets. This was
causing replays to fail.
This re-writes the capture so that the state block at the start is
replaced with the commands needed to generate the state block.
This will create a virtual command when a subcommand is requested.
Now that we serialize state, we have to let the early-terminator
know that is it running with extra commands. This is so that the
sync data matches the actual command list.
This will instruct the allocator to not allocate over the memory
ranges needed by the initial commands.
AWoloszyn and others added 16 commits February 5, 2018 14:46
This fixes textures in the UI.
Also work around a validation warning in read_framebuffer.go
When we re-create pools we do it through the observations.
Therefore add a single 0-byte observation to each pool.
Also, recover the inheritance info of command buffers and bring back the
missing layout transition for images that have mutiple samples or
not-color aspect.
When the queue submission does not contain any commands, the signaled semaphore
label still should be written.

And for the wait semaphores, the submission will unsignal the semaphore,
so it is a modify to the label, not just a read.
@AWoloszyn AWoloszyn merged commit 8d3d93d into google:master Feb 5, 2018
@AWoloszyn AWoloszyn deleted the move-mec branch February 5, 2018 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants