From a6a4790155d919707965a897fe35823edc62efe7 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 | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/gapis/api/gles/dependency_graph_behaviour_provider.go b/gapis/api/gles/dependency_graph_behaviour_provider.go index 331986a16d..bc625f5cef 100644 --- a/gapis/api/gles/dependency_graph_behaviour_provider.go +++ b/gapis/api/gles/dependency_graph_behaviour_provider.go @@ -198,24 +198,44 @@ 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) - b.Read(g, data) - b.Read(g, size) + for layer := GLsizei(0); layer < cmd.SrcDepth(); layer++ { + data, size := c.Objects().Textures().Get(TextureId(cmd.SrcName())).dataAndSize(cmd.SrcLevel(), GLint(layer)+cmd.SrcZ()) + b.Read(g, data) + b.Read(g, size) + } } if cmd.DstTarget() == GLenum_GL_RENDERBUFFER { 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) - b.Write(g, data) - b.Write(g, size) + for layer := GLsizei(0); layer < cmd.SrcDepth(); layer++ { + data, size := c.Objects().Textures().Get(TextureId(cmd.DstName())).dataAndSize(cmd.DstLevel(), GLint(layer)+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())