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

renamed "Uniform" to "DescriptorBuffer" #956

Closed
wants to merge 3 commits into from

Conversation

theodoregoetz
Copy link
Contributor

@theodoregoetz theodoregoetz commented Sep 4, 2023

Using the name "DescriptorBuffer" instead of "Uniform" with ShaderSet and GraphicsPipelineConfigurator better conveys that these methods work with both uniform and storage (and sometimes even image/texture) bindings.

Part of #954

This is a rename only and no functionality was changed. The public member variable ShaderSet::uniformBindings was renamed to ShaderSet::bufferBindings and a reference was created to keep the the API from breaking. Also, updated names in the read/write methods are set to be used when the version hits 1.0.10.

  • This change requires a documentation update

Testing

See the associated storage buffer example: https://github.com/vsg-dev/vsgExamples/tree/master/examples/utils/vsgstoragebuffer

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@theodoregoetz
Copy link
Contributor Author

Looking at the documentation (vsg-dev/vsgTutorial), I don't think anything there needs to change.

@robertosfield
Copy link
Collaborator

Thanks for the changes. I have done a first pass review and it all looks consistent with what I had in mind with a renaming.

One thing that has just struct me is the changes introduce a new naming conflict. In Vulkan and the VSG we have the vk/vsg::Buffer which is used for a far wider usage than just DescriptorBuffer, so we are solving one naming issue but introducing a new one that could cause further confusion.

I will need to reflect on this overlap and doing further passes over the changes, happy to take suggestions.

@robertosfield
Copy link
Collaborator

After a second read through I'm wondering if DescriptorBinding would be better than UniformBinding/BufferBinding. This would also fit with the DescriptorConfigurator naming, and the DescriptorBuffer/DescrptorImage naming.

Thoughts?

@theodoregoetz
Copy link
Contributor Author

Agreed. I'll rework this for "Uniform" -> "Descriptor".

@robertosfield
Copy link
Collaborator

Thanks.. I am sorry that using Descriptor as the base name didn't occur to me in discussions, alas sometimes only when you see something implemented does how coherent it is come to fore.

the buffer terminology was kept in GraphicsPipelineConfigurator to differentiate between image/texture and uniform/storage buffers, but BufferBindings was renamed to DescriptorBindings in ShaderSet because these can hold images, uniforms etc
@theodoregoetz
Copy link
Contributor Author

After a closer look, I figured that the Buffer term was good to have in GraphicsPipelineConfigurator because it differentiates the descriptor from the images (textures) and vertex attributes (arrays). But for sure the ShaderSet's methods were better using the term "descriptor" because it holds onto textures, uniforms and storage buffers. I also fixed up the read/write to be backwards compatible and triggered on version 1.0.10 which doesn't exist yet - I'm not really sure how to want to handle that.

Additionally, I started to use the [[deprecated]] C++ attribute and found that the errors I get from gcc are quite nice. Let me know if this causes any problems.

@@ -58,11 +58,13 @@ namespace vsg
/// call after all the textures and buffers have been explictly assigned to add in texture/buffer descriptors that are enabled by default (define == "").
bool assignDefaults();

/// deprecated. use enableBuffer() instead
[[deprecated("use enableBuffer()")]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be enableDescriptor()?

W.r.t [[deprecated]], do you know whether doxygen can handle it in a sensible way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. GraphicsPipelineConfigurator::enableBuffer() is still good in my opinion. see my previous comment posted at the same time as yours just now.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think enableBuffer() is more confusing that the original enableUniform(). Buffer has a distinct mean in VSG and Vulkan, it refers to a whole buffer not a subset that is can be as a uniform and storage.

enableDescriptor() is more generic than enableTexture()/enableUniform() but it does at least still map to DescriptorBuffer/DescriptorImage. If we want to replace enableUniform()/enableTexture() then it would probably be best as enableDescriptorBuffer()/enableDescriptorImage().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I came to nearly the same conclusion but decided at the time that shorter method names would be better. Note that the word "descriptor" shows up twice in DescriptorConfigurator::enableDescriptorBuffer() so why not just make it DescriptorConfigurator::enableBuffer()?

But really I could have gone either way. DescriptorConfigurator::enableDescriptorBuffer() is not too bad in length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I want to keep this PR to the uniform/storage issue and follow-up with a rename for the texture/image methods right after.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just DescriptorConfigurator::enable(..) then?

Though, as we'll need to keep it consistent with the GraphicsPipelineConfigurator API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can stand the slight inconsistency for this PR, I'd like to make this change first, keeping it as is at the moment (enableDescriptorBuffer(), etc) and come back with another PR to rename enableTexture() to enableDescriptorImage(). This is because the down-stream changes are many and separating this out keeps it all straight in my head.

@@ -471,8 +471,8 @@ bool GraphicsPipelineConfigurator::assignBuffer(const std::string& name, ref_ptr
/// deprecated. use GraphicsPipelineConfigurator::assignBuffer() instead
bool GraphicsPipelineConfigurator::assignUniform(const std::string& name, ref_ptr<Data> data)
{
warn("GraphicsPipelineConfigurator::enableUniform() has been deprecated."
" use GraphicsPipelineConfigurator::enableBuffer() instead.");
warn("GraphicsPipelineConfigurator::assignUniform() has been deprecated."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the warning redundant if we are using the [[deprecated]] compiler hint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. I don't know how this attribute and how VSG's logging plays with release and debug. I figured you might have some opinion on which is best. I can take this out if you think it best.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this PR is settled a bit further I'll merge this PR as a branch and then do testing with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for deprecations, I believe it best to be obnoxious about it. Otherwise it's easier to ignore.

…ineConfigurator. added deprecated comments for doxygen output
@theodoregoetz
Copy link
Contributor Author

The last commit renames the configurator methods to ...DescriptorBuffer(). I also added /// deprecated: comments to account for doxygen which seems to ignore the [[deprecated]] attribute in my (lmited) tests.

@theodoregoetz theodoregoetz changed the title renamed "UniformBinding" to "BufferBinding" renamed "Uniform" to "DescriptorBuffer" Sep 6, 2023
@robertosfield
Copy link
Collaborator

FYI, I've checked in some work that includes a bump of the VSG master version to 1.0.10-rc1 so the IO checks in this PR should now work with VSG master.

@theodoregoetz
Copy link
Contributor Author

I believe this PR is complete now, unless @robertosfield you really want to have the rename from Texture to DescriptorImage done at the exact same time (keep in mind that this would more than double the down-stream updates)

@robertosfield
Copy link
Collaborator

robertosfield commented Sep 7, 2023

I have done another review and want to make a few changes so will merge this PR as a theodoregoetz-buffer-binding branch. I need to decide upon the naming and want to simplify the deprecated entries - I think one is enough, we certainly don't need [[deprecated]], doxygen comment and console message all saying the same thing.

The branch is:
https://github.com/vsg-dev/VulkanSceneGraph/tree/theodoregoetz-buffer-binding

@robertosfield
Copy link
Collaborator

I have decided to create a parallel DescriptorBinding branch so I can incrementally cherry-pick changes from the theodoregoetz-buffer-binding branch:

https://github.com/vsg-dev/VulkanSceneGraph/tree/DescriptorBinding

So far I have just copied across the changes to alignment and DescriptorBuffer doxygen comment as these don't affect the API and fix a bug. I'll merge these changes with VSG master right away as they uncontroversial. I'll then copy across the changes that change the API.

@robertosfield
Copy link
Collaborator

I now think I have got to the new DescriptorBinding branch parity with this PR and the theodoregoetz-buffer-binding branch, these are the changes so far:

https://github.com/vsg-dev/VulkanSceneGraph/compare/DescriptorBinding

I have updated vsgXchange, vsgPoints and vsgExamples to not use the deprecated methods:

https://github.com/vsg-dev/vsgXchange/compare/DescriporBinding
https://github.com/vsg-dev/vsgPoints/compare/DescriptorBindings
https://github.com/vsg-dev/vsgPoints/compare/DescriptorBindings

The main differences to this PR is that I have only used the [[deprecated]] compile hint and have not assign any doxygen comments or vsg::warn(..) messages, and the enable/assignUniform(..) methods have been replaced by enable/assignDescriptor(..) methods rather than enable/assignDescriptorBuffer(..).

I decided just using enable/assignDescriptor rather than enable/assignDescriptorBuffer as I feel that it fits better with the enable/assignArray(..) naming, and offers the path of just overloading the assignDescriptor(..) methods to have an optional ref_ptr which can then replace the enable/assignTexture(..) method with a standard enableDescriptor/assignDescriptor() naming.

I think the DescriptorBinding branch is ready to merge with master, but will reflect on the possible change of enable/assignTexture(..) before I do anything further. Happy to take suggestions.

@theodoregoetz
Copy link
Contributor Author

Sounds good to me except I don't quite understand how you will handle textures with just assignDescriptor - uniform/storage takes a BufferInfoList and the texture takes an ImageInfoList.

@robertosfield
Copy link
Collaborator

I have had a look at unifying the enableTexture/assignTexture to use the enableDescriptor/assignDescriptor() usage but to make it work well we'll need to check the vkDescriptorType and use that to choose with a DescriptorImage, DescriptorBuffer or DescriptorTexelBufferView should be used.

The vsg::DescriptorTexelBufferView isn't yet supported by ShaderSet/DescriptorConfigurator/GraphicsPipelineConfigurator so this would be best tackled as separate lock of work. I am lots of other work to get on with so I won't go pursue another avenue of unplanned work. Resolving the enableTexture/assignTexture() is a coherent way will also take more time so I'll now merged the respective DescriptorBinding branches with VSG etc. master and leave these matters to future work.

@robertosfield
Copy link
Collaborator

Sounds good to me except I don't quite understand how you will handle textures with just assignDescriptor - uniform/storage takes a BufferInfoList and the texture takes an ImageInfoList.

Oh, that's simple - you just have overload assignDescriptor(..) methods. That's the easy part, the harder part is implementing a generate enableDescirptor() that handles all the different Descriptor types.

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

Successfully merging this pull request may close these issues.

2 participants