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

Vulkan Overdraw Tracking #1994

Merged
merged 15 commits into from
Jul 6, 2018
Merged

Conversation

sean-purcell
Copy link
Contributor

@sean-purcell sean-purcell commented Jun 18, 2018

Vulkan overdraw tracking using the stencil buffer (currently includes some commits that are necessary and haven't been merged to master yet).

gapit screenshot --overdraw produces images that look like:
screenshot

@sean-purcell sean-purcell changed the title (WIP) Vulkan Overdraw Tracking Vulkan Overdraw Tracking Jun 19, 2018
}
}

func (s *stencilOverdraw) add(ctx context.Context, after []uint64, capt *path.Capture, res replay.Result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can capt here be different from s.capture? Do you need to pass it in both places? Here and in newStencilOverdraw

lastRenderPassArgs, lastRenderPassIdx, id,
mustAllocData, addCleanup, out)
if err != nil {

Copy link
Contributor

Choose a reason for hiding this comment

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

was the new line here intentional?

rewrite map[api.CmdID]replay.Result
}

func newStencilOverdraw(ctx context.Context, capt *path.Capture) *stencilOverdraw {
Copy link
Contributor

Choose a reason for hiding this comment

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

unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used here

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry I meant "capt"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, unused, oops

@@ -174,3 +182,25 @@ func (verb *screenshotVerb) frameCommand(ctx context.Context, capture *path.Capt
fmt.Printf("Frame Command: %v\n", eofEvents[verb.Frame].Command.GetIndices())
return eofEvents[verb.Frame].Command, nil
}

func rescaleBytes(ctx context.Context, data []byte, max int) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you thought about just rescaling dynamically?
(0->Max) -> (0->1)

Copy link
Contributor

Choose a reason for hiding this comment

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

Could be done as a follow-up but it would save some having to type.
That being said, someone may want to avoid rescaling as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind! I misread this, you are already doing what I had said.
Ignore me

// unpackMapCustom takes a dense map of u32 -> structure, flattens the map into
// a slice, allocates the appropriate data using a custom provided allocation
// function and returns it as well as the length of the map.
func unpackMapCustom(alloc func(v ...interface{}) api.AllocResult, m interface{}) (api.AllocResult, uint32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe unpackMapWithAllocator it describes what's custom about it a bit more clearly.

)).Ptr()
}

// TODO: determine if basePipelineHandle is an issue
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to just pass in -1 / VK_NULL_HANDLE for base_pipeline_handle / base_pipeline_index.

Actually if you are passing in 0 for flags you MUST have -1 / VK_NULL_HANDLE for base_pipeline_*.

Alternatively, for a slight optimization, IF the original pipeline was created with VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT you could actaully set VK_PIPELINE_CREATE_DERIVATIVE_BIT, and point base_pipeline_handle to the original pipeline. That would improve pipeline compilation speed.

addCleanup func(func()),
out transform.Writer,
) (stencilImage, error) {
// TODO: check if we're allowed to modify the command directly, since
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't modify the commands. This can cause problems later on, since these are shared data-structures. (If golang has a CONST keyword we would be using it here).

// TODO: Ideally this would be smarter, but without duplicating the
// state and mutating it, it's hard to tell what the right
// vkQueueSubmit to modify is.
lastSubmit := int64(after)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic should be improved to allow selecting a specific renderpass without counting on the early terminator. #2010 needs to be resolved first though.

VkImageLayout_VK_IMAGE_LAYOUT_GENERAL)
}
} else {
stencilDesc = MakeVkAttachmentDescription(a)
Copy link
Contributor

Choose a reason for hiding this comment

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

So we can store off some extra data on the side of VkCreatePhysicalDevice, and grab the supported depth formats. Then you will be able to look up what the valid/legal depth formats are.

This can be done as a follow-up.

func (s *stencilOverdraw) add(ctx context.Context, extraCommands uint64, after []uint64, capt *path.Capture, res replay.Result) {
c, err := capture.ResolveFromPath(ctx, capt)
if err != nil {
res(nil, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

and return?

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, thanks

if err != nil {
res(nil, err)
}
lastSubmit := int64(after[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this could be refactored into something more readable:

for lastSubmit := int64(after[0]); lastSubmit >= 0; lastSubmit-- {
	switch (c.Commands[lastSubmit]).(type) {
	case *VkQueueSubmit:
		id := api.CmdID(uint64(lastSubmit) + extraCommands)
		s.rewrite[id] = res
		s.lastSubIdx[id] = api.SubCmdIdx(after[1:])
		return
	}
}
res(nil, &service.ErrDataUnavailable{
	Reason: messages.ErrMessage("No last queue submission"),
})

@AWoloszyn
Copy link
Contributor

Checking this on Windows now

@AWoloszyn
Copy link
Contributor

This was failing for me on Windows, (empty output).

I ran with the validation layers attached, and saw a few issues. Can we resolve those before submitting.

I sent them to you separately, because they are quite large for a github comment

@AWoloszyn AWoloszyn merged commit 944d5c9 into google:master Jul 6, 2018
@sean-purcell sean-purcell deleted the overdraw-stencil branch July 6, 2018 15:00
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.

4 participants