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

Make sure shader param exists before setting its value #558

Merged
merged 2 commits into from
Feb 9, 2022

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Feb 8, 2022

Signed-off-by: Ian Chen [email protected]

🦟 Bug fix

Summary

Fixes crash when setting a shader parameter that does not exist. Now it prints out a warning msg to let users know what param will not be set.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #558 (358b325) into ign-rendering6 (b5d5557) will decrease coverage by 0.02%.
The diff coverage is 25.97%.

❗ Current head 358b325 differs from pull request most recent head fcb8392. Consider uploading reports for the commit fcb8392 to get more accurate results

Impacted file tree graph

@@                Coverage Diff                 @@
##           ign-rendering6     #558      +/-   ##
==================================================
- Coverage           54.40%   54.37%   -0.03%     
==================================================
  Files                 198      198              
  Lines               20084    20151      +67     
==================================================
+ Hits                10926    10957      +31     
- Misses               9158     9194      +36     
Impacted Files Coverage Δ
ogre2/src/Ogre2Material.cc 65.24% <0.00%> (-6.36%) ⬇️
ogre2/src/Ogre2RenderEngine.cc 78.58% <ø> (-0.05%) ⬇️
ogre2/src/Ogre2MaterialSwitcher.cc 84.41% <53.84%> (-5.59%) ⬇️
ogre2/src/Ogre2GpuRays.cc 95.51% <100.00%> (+0.03%) ⬆️
src/ShaderParam.cc 100.00% <100.00%> (ø)
...a/src/Hlms/PbsListener/OgreHlmsPbsTerraShadows.cpp 58.00% <0.00%> (+34.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50e8e1e...fcb8392. Read the comment docs.

@iche033 iche033 merged commit 112d5d4 into ign-rendering6 Feb 9, 2022
@iche033 iche033 deleted the find_param branch February 9, 2022 19:57
@osrf-triage
Copy link

This pull request has been mentioned on Gazebo Community. There might be relevant details there:

https://community.gazebosim.org/t/new-ignition-releases-2022-03-01-citadel-edifice-fortress/1313/1

@srmainwaring
Copy link
Contributor

srmainwaring commented Mar 2, 2022

@iche033 I've realised that this breaks the custom shaders for Metal, which can be seen on the waves example

waves-textures-issue

The issue is that the Metal shaders do not declare the textures as parameters and they are not found as named constants. As a result a warning is issued and registration of the texture unit state is skipped. For textures the named constant is only set for OpenGL:

https://github.com/ignitionrobotics/ign-rendering/blob/5e67f4159761151b09560d447c73d3123e954963/ogre2/src/Ogre2Material.cc#L786-L791

A possible fix would be to skip this check if the shader param type is a texture and not OpenGL?

    if (!_ogreParams->_findNamedConstantDefinition(name_param.first) &&
        !(Ogre2RenderEngine::Instance()->GraphicsAPI() !=
            GraphicsAPI::OPENGL &&
            (ShaderParam::PARAM_TEXTURE == name_param.second.Type() ||
             ShaderParam::PARAM_TEXTURE_CUBE == name_param.second.Type()))
    )
    {
      ignwarn << "Unable to find GPU program parameter: "
              << name_param.first << std::endl;
      continue;
    } 

@iche033
Copy link
Contributor Author

iche033 commented Mar 2, 2022

Thanks for the patch! yeah that looks good to me. I don't know if vulkan will have the same issue or not (being added in #553). I guess we'll find out. I created a PR for the patch: #574

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

Successfully merging this pull request may close these issues.

4 participants