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: Fix crash at VkDestroyDebugReportCallbackEXT #1998

Merged
merged 1 commit into from Jun 20, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions gapis/api/vulkan/find_issues.go
Expand Up @@ -72,8 +72,9 @@ type findIssues struct {

func newFindIssues(ctx context.Context, c *capture.Capture, numInitialCmds int) *findIssues {
t := &findIssues{
state: c.NewState(ctx),
numInitialCmds: numInitialCmds,
state: c.NewState(ctx),
numInitialCmds: numInitialCmds,
reportCallbacks: map[VkInstance]VkDebugReportCallbackEXT{},
}
t.state.OnError = func(err interface{}) {
if issue, ok := err.(replay.Issue); ok {
Expand Down Expand Up @@ -116,6 +117,7 @@ func (t *findIssues) Transform(ctx context.Context, id api.CmdID, cmd api.Cmd, o
inst := di.Instance()
if ch, ok := t.reportCallbacks[inst]; ok {
out.MutateAndWrite(ctx, api.CmdNoID, cb.ReplayDestroyVkDebugReportCallback(inst, ch))
delete(t.reportCallbacks, inst)
}
}

Expand Down Expand Up @@ -262,11 +264,17 @@ func (t *findIssues) Transform(ctx context.Context, id api.CmdID, cmd api.Cmd, o
).AddWrite(
callbackHandleData.Data(),
))
t.reportCallbacks[inst] = callbackHandle
}
}

func (t *findIssues) Flush(ctx context.Context, out transform.Writer) {
cb := CommandBuilder{Thread: 0, Arena: t.state.Arena}
for inst, ch := range t.reportCallbacks {
out.MutateAndWrite(ctx, api.CmdNoID, cb.ReplayDestroyVkDebugReportCallback(inst, ch))
// It is safe to delete keys in loop in Go
delete(t.reportCallbacks, inst)
}
out.MutateAndWrite(ctx, api.CmdNoID, cb.Custom(func(ctx context.Context, s *api.GlobalState, b *builder.Builder) error {
b.RegisterNotificationReader(func(n gapir.Notification) {
vkApi := API{}
Expand Down
2 changes: 1 addition & 1 deletion gapis/api/vulkan/replay.go
Expand Up @@ -431,7 +431,7 @@ func (t *destroyResourcesAtEOS) Flush(ctx context.Context, out transform.Writer)

// Debug report callbacks
for handle, object := range so.DebugReportCallbacks().All() {
out.MutateAndWrite(ctx, id, cb.ReplayDestroyVkDebugReportCallback(object.Instance(), handle))
out.MutateAndWrite(ctx, id, cb.VkDestroyDebugReportCallbackEXT(object.Instance(), handle, p))
}

// Instances.
Expand Down
11 changes: 1 addition & 10 deletions gapis/api/vulkan/synthetic.api
Expand Up @@ -209,16 +209,10 @@ cmd bool ReplayCreateVkDebugReportCallback(
VkDebugReportCallbackEXT* pCallback) {
if !(instance in Instances) { vkErrorInvalidInstance(instance) }
if pCreateInfo == null { vkErrorNullPointer("VkDebugReportCallbackCreateInfoEXT") }
info := pCreateInfo[0]
read(pCreateInfo[0:1])
handle := ?
if pCallback == null { vkErrorNullPointer("VkDebugReportCallbackEXT") }
pCallback[0] = handle
object := new!DebugReportCallbackObject(
Instance: instance,
Flags: info.flags,
VulkanHandle: handle,
)
DebugReportCallbacks[handle] = object
return ?
}

Expand All @@ -227,7 +221,4 @@ cmd void ReplayDestroyVkDebugReportCallback(
VkInstance instance,
VkDebugReportCallbackEXT callback) {
if !(instance in Instances) { vkErrorInvalidInstance(instance) }
if (callback != as!VkDebugReportCallbackEXT(0)) {
delete(DebugReportCallbacks, callback)
}
}