Skip to content

Commit

Permalink
Fixed replay on machines with dual-gpus.
Browse files Browse the repository at this point in the history
Our device remapping code was completely broken.
Fixed this bug, now we can replay on machines where the
gpu index changes.
  • Loading branch information
AWoloszyn committed Mar 28, 2018
1 parent d911080 commit 144d2ec
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions gapis/api/vulkan/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ func (a API) GetReplayPriority(ctx context.Context, i *device.Instance, h *captu
type makeAttachementReadable struct {
Instance VkInstance
EnumeratedPhysicalDevices []VkPhysicalDevice
Properties map[VkPhysicalDevice]VkPhysicalDeviceProperties
Properties []VkPhysicalDeviceProperties
InPhysicalDeviceEnumerate bool
NumPhysicalDevicesLeft uint32
}

// drawConfig is a replay.Config used by colorBufferRequest and
Expand Down Expand Up @@ -154,13 +156,6 @@ func (t *makeAttachementReadable) Transform(ctx context.Context, id api.CmdID, c
cb := CommandBuilder{Thread: cmd.Thread()}
cmd.Extras().Observations().ApplyReads(s.Memory.ApplicationPool())

// Info for physical device enumeration
inPhyDevEnumeration := false
numPhyDevLeft := uint32(0)
vkInst := VkInstance(0)
phyDevs := []VkPhysicalDevice{}
phyDevProps := []VkPhysicalDeviceProperties{}

if image, ok := cmd.(*VkCreateImage); ok {
pinfo := image.PCreateInfo
info := pinfo.MustRead(ctx, image, s, nil)
Expand Down Expand Up @@ -278,24 +273,26 @@ func (t *makeAttachementReadable) Transform(ctx context.Context, id api.CmdID, c
// Second call to vkEnumeratePhysicalDevices
l := s.MemoryLayout
cmd.Extras().Observations().ApplyWrites(s.Memory.ApplicationPool())
numPhyDevLeft = uint32(e.PPhysicalDeviceCount.Slice(uint64(0), uint64(1), l).Index(uint64(0), l).MustRead(ctx, cmd, s, nil))
t.NumPhysicalDevicesLeft = uint32(e.PPhysicalDeviceCount.Slice(uint64(0), uint64(1), l).Index(uint64(0), l).MustRead(ctx, cmd, s, nil))
// Do not mutate the second call to vkEnumeratePhysicalDevices, all the following vkGetPhysicalDeviceProperties belong to this
// physical device enumeration.
inPhyDevEnumeration = true

t.InPhysicalDeviceEnumerate = true
t.Properties = make([]VkPhysicalDeviceProperties, 0)
t.EnumeratedPhysicalDevices = make([]VkPhysicalDevice, 0)
t.Instance = e.Instance
} else if g, ok := cmd.(*VkGetPhysicalDeviceProperties); ok {
if inPhyDevEnumeration {
if t.InPhysicalDeviceEnumerate {
cmd.Extras().Observations().ApplyWrites(s.Memory.ApplicationPool())
prop := g.PProperties.MustRead(ctx, cmd, s, nil)
phyDevProps = append(phyDevProps, prop)
phyDevs = append(phyDevs, g.PhysicalDevice)
if numPhyDevLeft > 0 {
numPhyDevLeft--
t.Properties = append(t.Properties, prop)
t.EnumeratedPhysicalDevices = append(t.EnumeratedPhysicalDevices, g.PhysicalDevice)
if t.NumPhysicalDevicesLeft > 0 {
t.NumPhysicalDevicesLeft--
}
if numPhyDevLeft == 0 {
newEnumerate := buildReplayEnumeratePhysicalDevices(ctx, s, cb, vkInst, uint32(len(phyDevs)), phyDevs, phyDevProps)
if t.NumPhysicalDevicesLeft == 0 {
newEnumerate := buildReplayEnumeratePhysicalDevices(ctx, s, cb, t.Instance, uint32(len(t.EnumeratedPhysicalDevices)), t.EnumeratedPhysicalDevices, t.Properties)
out.MutateAndWrite(ctx, id, newEnumerate)
inPhyDevEnumeration = false
t.InPhysicalDeviceEnumerate = false
}
return
} else {
Expand Down Expand Up @@ -482,7 +479,9 @@ func (a API) Replay(
transforms.Add(&makeAttachementReadable{
VkInstance(0),
make([]VkPhysicalDevice, 0),
make(map[VkPhysicalDevice]VkPhysicalDeviceProperties),
make([]VkPhysicalDeviceProperties, 0),
false,
0,
})

readFramebuffer := newReadFramebuffer(ctx)
Expand Down

0 comments on commit 144d2ec

Please sign in to comment.