-
Notifications
You must be signed in to change notification settings - Fork 327
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
Conversation
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
go_install() |
There was a problem hiding this comment.
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})
?
cmd/linearize_trace/main.go
Outdated
} | ||
|
||
initialCmds := capt.GetInitialCommands(ctx) | ||
_ = initialCmds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant?
cmd/linearize_trace/main.go
Outdated
if err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer f.Close() ?
gapii/cc/chunk_writer.cpp
Outdated
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question - Andrew?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
gapis/api/vulkan/externs.go
Outdated
@@ -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{}) { |
There was a problem hiding this comment.
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{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blurbs?
gapis/api/vulkan/state_rebuilder.go
Outdated
|
||
// 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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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...
gapis/api/vulkan/state_rebuilder.go
Outdated
VkMemoryAllocateInfo{ | ||
VkStructureType_VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, | ||
NewVoidᶜᵖ(memory.Nullptr), | ||
size * 2, // Overallocate by a factor of 2. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline.
There was a problem hiding this comment.
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. 😉
gapis/api/vulkan/state_rebuilder.go
Outdated
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping
gapis/api/vulkan/state_rebuilder.go
Outdated
size, | ||
}).Ptr(), | ||
VkResult_VK_SUCCESS, | ||
).AddWrite(dat.Data())) |
There was a problem hiding this comment.
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())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping
There was a problem hiding this 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.
gapii/cc/chunk_writer.cpp
Outdated
@@ -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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Indent?
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is mPool
null?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
gapis/api/vulkan/state_rebuilder.go
Outdated
VkMemoryAllocateInfo{ | ||
VkStructureType_VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, | ||
NewVoidᶜᵖ(memory.Nullptr), | ||
size * 2, // Overallocate by a factor of 2. |
There was a problem hiding this comment.
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. 😉
gapis/api/vulkan/state_rebuilder.go
Outdated
size, | ||
}).Ptr(), | ||
VkResult_VK_SUCCESS, | ||
).AddWrite(dat.Data())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping
gapis/api/vulkan/state_rebuilder.go
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping
gapis/api/vulkan/vulkan.go
Outdated
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) { |
There was a problem hiding this comment.
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.
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.
vkQueueSubmit more correct.
non-dedicately allocated handle.
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: