o3de / o3de-azslc

Amazon Shader Language (AZSL) Compiler
Other
23 stars 14 forks source link

Improve support for SubpassInputs #90

Closed akioCL closed 2 weeks ago

akioCL commented 3 weeks ago

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: