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

[5.2.0] When build tag have dbg, works well, but when have no dbg, it have problems. #15741

Closed
wingdi opened this issue Jun 25, 2022 · 5 comments

Comments

@wingdi
Copy link

wingdi commented Jun 25, 2022

Command: bazelisk build --tool_tag=ijwb:AndroidStudio 
--output_groups=+android_deploy_info 
--curses=no --color=yes --progress_in_terminal_title=no
 -c opt --strip=always --config=android_arm64 -s --fission=no 
--build_event_binary_file=/var/folders/pf/2v4q3ng17ls2wpxh7pjpdlr40000gn/T/intellij-bep-1a5aee30-dc0f-48d1-b7af-ffa092e45a13 
--nobuild_event_binary_file_path_conversion 
-- //mediapipe/examples/android/src/java/com/google/mediapipe/apps/faceeffect_self:glassview
Command: bazelisk build --tool_tag=ijwb:AndroidStudio 
--output_groups=+android_deploy_info 
--curses=no --color=yes --progress_in_terminal_title=no 
-c opt --strip=always --config=android_arm64 -s --fission=no 
-c dbg 
--build_event_binary_file=/var/folders/pf/2v4q3ng17ls2wpxh7pjpdlr40000gn/T/intellij-bep-a467c873-642a-4961-8aef-0a0572ab0d56 
--nobuild_event_binary_file_path_conversion 
-- //mediapipe/examples/android/src/java/com/google/mediapipe/apps/faceeffect_self:glassview

The second command compare with the first one , it added -c dbg, and --build_event_binary_file difference.

This is my project code:

                glGenTextures(1, &brdfLUTMap);
                glActiveTexture(GL_TEXTURE2);
                glBindTexture(GL_TEXTURE_2D, brdfLUTMap);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 512, 512, 0, GL_RGB, GL_FLOAT, 0);
                // be sure to set wrapping mode to GL_CLAMP_TO_EDGE
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

                // then re-configure capture framebuffer object and render screen-space quad with BRDF shader.
                glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
                glBindRenderbuffer(GL_RENDERBUFFER, captureRBO);
                glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 512, 512);
                glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, captureRBO);
                checkGLError("--glFramebufferRenderbuffer ");
                glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, brdfLUTMap, 0);
                glViewport(0, 0, 512, 512);
                brdfShader.use();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                renderQuad();
                glBindFramebuffer(GL_FRAMEBUFFER, 0);

If i use the first command , i can sampling data from brdfLUTMap, if i use the second command, can't sampling data from brdfLUTMap. it's very wired , because other textures have no problem using both two command.

@sgowroji
Copy link
Member

Hello @wingdi, Could you please elaborate your use case and provide complete steps to reproduce the above error. Thanks!

@wingdi
Copy link
Author

wingdi commented Jun 27, 2022

@sgowroji Very thanks for your reply. It's nice to meet you at this project.

First i bind FBO with Texture , and render data to this Texture:

                glGenTextures(1, &brdfLUTMap);
                glActiveTexture(GL_TEXTURE2);
                glBindTexture(GL_TEXTURE_2D, brdfLUTMap);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 512, 512, 0, GL_RGB, GL_FLOAT, 0);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

                glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
                glBindRenderbuffer(GL_RENDERBUFFER, captureRBO);
                glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 512, 512);
                glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, captureRBO);
                glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, brdfLUTMap, 0);
                LOG(ERROR) << "brdfFrameBufferStatus(36053-Normal) "  << glCheckFramebufferStatus(GL_FRAMEBUFFER);
                checkGLError("--brdfLUTMap ");

                glViewport(0, 0, 512, 512);
                brdfShaderProgram.use();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                
                GLuint quadVAO;
                GLuint quadVBO;
                if (quadVAO == 0){
                    float quadVertices[] = {
                            // positions        // texture Coords
                            -1.0f,  1.0f, 0.0f, 0.0f, 1.0f,
                            -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
                            1.0f,  1.0f, 0.0f, 1.0f, 1.0f,
                            1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
                    };
                    // setup plane VAO
                    glGenVertexArrays(1, &quadVAO);
                    glGenBuffers(1, &quadVBO);
                    glBindVertexArray(quadVAO);
                    glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
                    glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, GL_STATIC_DRAW);
                    glEnableVertexAttribArray(0);
                    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
                    glEnableVertexAttribArray(1);
                    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
                }
                glBindVertexArray(quadVAO);
                glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
                glBindBuffer(GL_ARRAY_BUFFER, 0);
                glBindVertexArray(0);

                glBindTexture(GL_TEXTURE_2D, 0);
                glBindRenderbuffer(GL_RENDERBUFFER, 0);
                glBindFramebuffer(GL_FRAMEBUFFER, 0);

                checkGLError("--brdfLUTMap ");

Then sampling data from this Texture:

                glActiveTexture(GL_TEXTURE2);
                glBindTexture(GL_TEXTURE_2D, brdfLUTMap);
                ... 
                glDrawElements(mesh_3d.primitive_type, mesh_3d.index_buffer.size(),
                               GL_UNSIGNED_INT, mesh_3d.index_buffer.data());

When build with dbg , it works well, but if build without dbg, sampling data from brdfLUTMap is zero.
Using bazel-v5.0.0 and bazel-v5.2.0 have same problem.

@ted-xie
Copy link
Contributor

ted-xie commented Jul 7, 2022

Hi @wingdi,

It doesn't seem to me like this is an issue with the Android rules or Android build process in general; it reads more like a build configuration issue.

Have you tried running your test with --subcommands to see what Bazel is doing differently between your two builds? I usually do something like bazel build //my:target --subcommands 2>&1 | tee log.log so I can pipe the stdout + stderr output to a log file.

@ted-xie ted-xie added awaiting-user-response Awaiting a response from the author and removed team-Android Issues for Android team untriaged labels Jul 7, 2022
@sgowroji
Copy link
Member

sgowroji commented Oct 21, 2022

@wingdi , Could you please respond on the above comment. Thanks!

@sgowroji sgowroji removed the awaiting-user-response Awaiting a response from the author label Nov 2, 2022
@sgowroji
Copy link
Member

We are closing this issue now and check details above. Please reach out if you still see problem on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants