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

Improve support for SubpassInputs #90

Merged
merged 1 commit into from
Aug 29, 2024
Merged

Conversation

akioCL
Copy link
Contributor

@akioCL akioCL commented Aug 17, 2024

Improve support for subpass inputs in order to emit shaders that work when subpass inputs are enabled or disabled. In the case they are disabled, SubpassInputs are transformed to a Texture2D type. This way we can use the same shader on platforms where SubpassInputs are not supported without having to modify the code.

SubpassInputs need to pass the arguments used when doing the Load operation on the Texture2D. Example:

[[input_attachment_index(0)]]
SubpassInput m_frameBuffer;

float4 color = m_frameBuffer.SubpassLoad(int3(1, 2, 0));

When subpass inputs are supported we get the following result:

[[vk::input_attachment_index(0)]]
[[vk::binding(0, 0)]]
SubpassInput m_frameBuffer;

float4 color = m_frameBuffer.SubpassLoad();

When subpass inputs are not supported we get the following result:

Texture2D m_frameBuffer;

float4 color = m_frameBuffer.Load(int3(1, 2, 0));

Details:

  • Add --no-subpass-input argument to emit a shader without subpass input support
  • Add SubpassInputToTexture2DCodeMutator to:
    • Replace SubpassInput type --> Texture2D type if subpass input are not supported
    • Replace SubpassLoad function --> Load function if subpass input are not supported
    • Remove arguments from SubpassLoad function when subpass inputs are supported

- Add --no-subpass-input argument to emit a shader without subpass input support
- Add SubpassInputToTexture2DCodeMutator to:
  - Replace SubpassInput type --> Texture2D type if subpass input are not supported
  - Replace SubpassLoad function --> Load function if subpass input are not supported
  - Remove arguments from SubpassLoad function when subpass inputs are supported

Signed-off-by: Akio Gaule <[email protected]>
@akioCL akioCL requested review from moudgils and galibzon August 17, 2024 01:35
@akioCL akioCL merged commit 23d786b into development Aug 29, 2024
2 checks passed
@akioCL akioCL deleted the improve_input_attachments branch August 29, 2024 12:47
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.

3 participants