From 979eb20eedf3dc5d9764f148eb26a7aaa544ac70 Mon Sep 17 00:00:00 2001 From: Pascal Muetschard Date: Wed, 31 Oct 2018 12:30:43 -0700 Subject: [PATCH] Correctly handle texture layer FB attachemnts in DCE. - in `glCopyImageSubData` the `srcZ` and `dstZ` attribute signal the texture layers read and written. - in the various framebuffer texture attachment calls, which layer is attached to the framebuffer is well defined. --- .../dependency_graph_behaviour_provider.go | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gapis/api/gles/dependency_graph_behaviour_provider.go b/gapis/api/gles/dependency_graph_behaviour_provider.go index 331986a16d..d946ce6164 100644 --- a/gapis/api/gles/dependency_graph_behaviour_provider.go +++ b/gapis/api/gles/dependency_graph_behaviour_provider.go @@ -198,11 +198,10 @@ func (*GlesDependencyGraphBehaviourProvider) GetBehaviourForCommand( switch cmd := cmd.(type) { case *GlCopyImageSubData: // TODO: This assumes whole-image copy. Handle sub-range copies. - // TODO: This does not handle multiple layers well. if cmd.SrcTarget() == GLenum_GL_RENDERBUFFER { b.Read(g, renderbufferDataKey{c.Objects().Renderbuffers().Get(RenderbufferId(cmd.SrcName()))}) } else { - data, size := c.Objects().Textures().Get(TextureId(cmd.SrcName())).dataAndSize(cmd.SrcLevel(), 0) + data, size := c.Objects().Textures().Get(TextureId(cmd.SrcName())).dataAndSize(cmd.SrcLevel(), cmd.SrcZ()) b.Read(g, data) b.Read(g, size) } @@ -210,12 +209,29 @@ func (*GlesDependencyGraphBehaviourProvider) GetBehaviourForCommand( b.Write(g, renderbufferDataKey{c.Objects().Renderbuffers().Get(RenderbufferId(cmd.DstName()))}) } else { - data, size := c.Objects().Textures().Get(TextureId(cmd.DstName())).dataAndSize(cmd.DstLevel(), 0) + data, size := c.Objects().Textures().Get(TextureId(cmd.DstName())).dataAndSize(cmd.DstLevel(), cmd.DstZ()) b.Write(g, data) b.Write(g, size) } case *GlFramebufferTexture2D: - b.Read(g, textureSizeKey{c.Objects().Textures().Get(cmd.Texture()), cmd.Texture(), cmd.Level(), 0}) + var layer GLint + switch target := cmd.TextureTarget(); target { + case GLenum_GL_TEXTURE_CUBE_MAP_POSITIVE_X, GLenum_GL_TEXTURE_CUBE_MAP_NEGATIVE_X, + GLenum_GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GLenum_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + GLenum_GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GLenum_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + layer = GLint(target - GLenum_GL_TEXTURE_CUBE_MAP_POSITIVE_X) + } + b.Read(g, textureSizeKey{c.Objects().Textures().Get(cmd.Texture()), cmd.Texture(), cmd.Level(), layer}) + b.KeepAlive = true // Changes untracked state + case *GlFramebufferTexture: + if t := c.Objects().Textures().Get(cmd.Texture()); !t.IsNil() { + for layer := range t.Levels().Get(cmd.Level()).Layers().All() { + b.Read(g, textureSizeKey{t, cmd.Texture(), cmd.Level(), layer}) + } + } + b.KeepAlive = true // Changes untracked state + case *GlFramebufferTextureLayer: + b.Read(g, textureSizeKey{c.Objects().Textures().Get(cmd.Texture()), cmd.Texture(), cmd.Level(), cmd.Layer()}) b.KeepAlive = true // Changes untracked state case *GlCompressedTexImage2D: texData, texSize := getTextureDataAndSize(ctx, cmd, id, s, c.Bound().TextureUnit(), cmd.Target(), cmd.Level())