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

New: storage buffer in frag shader when using GraphicsPipelineConfigurator #256

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

theodoregoetz
Copy link
Contributor

Alert: This PR is meant to provoke discussion on a specific aspect of VSG design. For changes to VSG, please continue the discussion in the issue linked below. Once VSG has moved forward, this PR can be adjusted to accomodate the design decisions made and provide a working example.

See this issue on VSG: vsg-dev/VulkanSceneGraph#954

This example attempts to use GraphicsPipelineConfigurator and ShaderSet along side a storage buffer (descriptor type VK_DESCRIPTOR_TYPE_STORAGE_BUFFER). Since storage buffers are bound exactly like uniform buffers, there exists a very small potential change we could make in VSG to add storage buffer support to methods that look like addUniformBinding() and assignUniform(), however this makes the interface misleading (uniform and storage buffers are quite different in size limitations and purpose).

The example included here uses a storage buffer in the fragment shader to color individual triangles using the gl_PrimitiveID to index into the buffer. This minimizes the data transfered to the card when the triangle list is large and also minimizes the number of draw commands with a large number of colors when used with an index-draw command.

@robertosfield
Copy link
Collaborator

I have merged this draft example as theodoregoetz-storage-buffer branch:

https://github.com/vsg-dev/vsgExamples/tree/theodoregoetz-storage-buffer

I have also checked a fix to VSG master to fixed the bug in DescriptorConfig::applyUniform(..) not assigning the uniformBinding.descriptorType with the commit:

vsg-dev/VulkanSceneGraph@62b2e8e

I have also amended the vsgstoragebuffer example to make it possible to use -d and -a command line args to print out Vulkan debug errors, as well as placing the local uniform assignment functions with the original GraphicsPipelineConfiguration::applyUniform(..). Before the commit to VSG master this produced a Vulkan debug error, but after applying the error is fixed.

This doesn't address the naming sloppiness, but at least should provide a functional path for now.

@robertosfield robertosfield merged commit ad37910 into vsg-dev:master Sep 4, 2023
@robertosfield
Copy link
Collaborator

I have merged the vsgstoragebuffer example with vsgExamples master. We can tackle the naming issues at a later date with separate submissions.

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