diff options
author | Chip Davis <cdavis@codeweavers.com> | 2020-08-28 03:24:20 +0300 |
---|---|---|
committer | Chip Davis <cdavis@codeweavers.com> | 2020-09-02 17:18:25 +0300 |
commit | 4cf840ee7b585eca51bda0baaaecf0aae168fbaa (patch) | |
tree | b657deed1b3f00347cb5f8253b981a6b992bc0af /reference/opt/shaders-msl | |
parent | c7507e39d471241d633f8926de04c6565ad040a0 (diff) |
MSL: Support layered input attachments.
These need to use arrayed texture types, or Metal will complain when
binding the resource. The target layer is addressed relative to the
Layer output by the vertex pipeline, or to the ViewIndex if in a
multiview pipeline. Unlike with the s/t coordinates, Vulkan does not
forbid non-zero layer coordinates here, though this cannot be expressed
in Vulkan GLSL.
Supporting 3D textures will require additional work. Part of the problem
is that Metal does not allow texture views to subset a 3D texture, so we
need some way to pass the base depth to the shader.
Diffstat (limited to 'reference/opt/shaders-msl')
5 files changed, 71 insertions, 1 deletions
diff --git a/reference/opt/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag b/reference/opt/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag new file mode 100644 index 00000000..5f137b04 --- /dev/null +++ b/reference/opt/shaders-msl/frag/input-attachment-ms.arrayed-subpass.msl21.frag @@ -0,0 +1,17 @@ +#include <metal_stdlib> +#include <simd/simd.h> + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_ms_array<float> uSubpass0 [[texture(0)]], texture2d_ms_array<float> uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]], uint gl_Layer [[render_target_array_index]]) +{ + main0_out out = {}; + out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), gl_Layer, 1) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_Layer, 2)) + uSubpass0.read(uint2(gl_FragCoord.xy), gl_Layer, gl_SampleID); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag b/reference/opt/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag new file mode 100644 index 00000000..2e4ca8a7 --- /dev/null +++ b/reference/opt/shaders-msl/frag/input-attachment-ms.multiview.msl21.frag @@ -0,0 +1,18 @@ +#include <metal_stdlib> +#include <simd/simd.h> + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant uint* spvViewMask [[buffer(24)]], texture2d_ms_array<float> uSubpass0 [[texture(0)]], texture2d_ms_array<float> uSubpass1 [[texture(1)]], uint gl_SampleID [[sample_id]], float4 gl_FragCoord [[position]], uint gl_ViewIndex [[render_target_array_index]]) +{ + main0_out out = {}; + gl_ViewIndex += spvViewMask[0]; + out.FragColor = (uSubpass0.read(uint2(gl_FragCoord.xy), gl_ViewIndex, 1) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_ViewIndex, 2)) + uSubpass0.read(uint2(gl_FragCoord.xy), gl_ViewIndex, gl_SampleID); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/input-attachment.arrayed-subpass.frag b/reference/opt/shaders-msl/frag/input-attachment.arrayed-subpass.frag new file mode 100644 index 00000000..5d5ee431 --- /dev/null +++ b/reference/opt/shaders-msl/frag/input-attachment.arrayed-subpass.frag @@ -0,0 +1,17 @@ +#include <metal_stdlib> +#include <simd/simd.h> + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(texture2d_array<float> uSubpass0 [[texture(0)]], texture2d_array<float> uSubpass1 [[texture(1)]], float4 gl_FragCoord [[position]], uint gl_Layer [[render_target_array_index]]) +{ + main0_out out = {}; + out.FragColor = uSubpass0.read(uint2(gl_FragCoord.xy), gl_Layer) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_Layer); + return out; +} + diff --git a/reference/opt/shaders-msl/frag/input-attachment.frag b/reference/opt/shaders-msl/frag/input-attachment.frag index 12219064..790dce3c 100644 --- a/reference/opt/shaders-msl/frag/input-attachment.frag +++ b/reference/opt/shaders-msl/frag/input-attachment.frag @@ -11,7 +11,7 @@ struct main0_out fragment main0_out main0(texture2d<float> uSubpass0 [[texture(0)]], texture2d<float> uSubpass1 [[texture(1)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; - out.FragColor = uSubpass0.read(uint2(gl_FragCoord.xy), 0) + uSubpass1.read(uint2(gl_FragCoord.xy), 0); + out.FragColor = uSubpass0.read(uint2(gl_FragCoord.xy)) + uSubpass1.read(uint2(gl_FragCoord.xy)); return out; } diff --git a/reference/opt/shaders-msl/frag/input-attachment.multiview.frag b/reference/opt/shaders-msl/frag/input-attachment.multiview.frag new file mode 100644 index 00000000..7cf06d2d --- /dev/null +++ b/reference/opt/shaders-msl/frag/input-attachment.multiview.frag @@ -0,0 +1,18 @@ +#include <metal_stdlib> +#include <simd/simd.h> + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(constant uint* spvViewMask [[buffer(24)]], texture2d_array<float> uSubpass0 [[texture(0)]], texture2d_array<float> uSubpass1 [[texture(1)]], float4 gl_FragCoord [[position]], uint gl_ViewIndex [[render_target_array_index]]) +{ + main0_out out = {}; + gl_ViewIndex += spvViewMask[0]; + out.FragColor = uSubpass0.read(uint2(gl_FragCoord.xy), gl_ViewIndex) + uSubpass1.read(uint2(gl_FragCoord.xy), gl_ViewIndex); + return out; +} + |