Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Hollings <bill.hollings@brenwill.com>2021-11-08 23:59:45 +0300
committerBill Hollings <bill.hollings@brenwill.com>2021-11-08 23:59:45 +0300
commitfd252b21ff291f5dee8d74f1702d5755af30a776 (patch)
tree6e7448868f1419d7e68494f2f4bdc6d93f034ec0 /reference/opt/shaders-msl
parent2e0fb3a7784011ebd3c25cd1252beca0819fd1de (diff)
Separate (partially) the tracking of depth images from depth compare ops.
SPIR-V allows an image to be marked as a depth image, but with a non-depth format. Such images should be read or sampled as vectors instead of scalars, except when they are subject to compare operations. Don't mark an OpSampledImage as using a compare operation just because the image contains a depth marker. Instead, require that a compare operation is actually used on that image. Compiler::image_is_comparison() was really testing whether an image is a depth image, since it incorporates the depth marker. Rename that function to is_depth_image(), to clarify what it is really testing. In Compiler::is_depth_image(), do not treat an image as a depth image if it has been explicitly marked with a color format, unless the image is subject to compare operations. In CompilerMSL::to_function_name(), test for compare operations specifically, rather than assuming them from the depth-image marker. CompilerGLSL and CompilerMSL still contain a number of internal tests that use is_depth_image() both for testing for a depth image, and for testing whether compare operations are being used. I've left these as they are for now, but these should be cleaned up at some point. Add unit tests for fetch/sample depth images with color formats and no compare ops.
Diffstat (limited to 'reference/opt/shaders-msl')
-rw-r--r--reference/opt/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag33
-rw-r--r--reference/opt/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag33
2 files changed, 66 insertions, 0 deletions
diff --git a/reference/opt/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag b/reference/opt/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag
new file mode 100644
index 00000000..be9f1331
--- /dev/null
+++ b/reference/opt/shaders-msl/asm/frag/depth-image-color-format-fetch.asm.frag
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+#include <simd/simd.h>
+
+using namespace metal;
+
+struct _7
+{
+ float4 _m0[64];
+};
+
+struct main0_out
+{
+ float4 m_3 [[color(0)]];
+};
+
+struct main0_in
+{
+ float4 m_2 [[user(locn1)]];
+};
+
+fragment main0_out main0(main0_in in [[stage_in]], device _7& _10 [[buffer(0)]], texture2d<float> _8 [[texture(0)]])
+{
+ main0_out out = {};
+ for (int _154 = 0; _154 < 64; )
+ {
+ _10._m0[_154] = _8.read(uint2(int2(_154 - 8 * (_154 / 8), _154 / 8)), 0);
+ _154++;
+ continue;
+ }
+ out.m_3 = in.m_2;
+ return out;
+}
+
diff --git a/reference/opt/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag b/reference/opt/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag
new file mode 100644
index 00000000..bbe0acd7
--- /dev/null
+++ b/reference/opt/shaders-msl/asm/frag/depth-image-color-format-sampled.asm.frag
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+#include <simd/simd.h>
+
+using namespace metal;
+
+struct _7
+{
+ float4 _m0[64];
+};
+
+struct main0_out
+{
+ float4 m_3 [[color(0)]];
+};
+
+struct main0_in
+{
+ float4 m_2 [[user(locn1)]];
+};
+
+fragment main0_out main0(main0_in in [[stage_in]], device _7& _10 [[buffer(0)]], texture2d<float> _8 [[texture(0)]], sampler _9 [[sampler(0)]])
+{
+ main0_out out = {};
+ for (int _158 = 0; _158 < 64; )
+ {
+ _10._m0[_158] = _8.sample(_9, (float2(int2(_158 - 8 * (_158 / 8), _158 / 8)) * float2(0.125)), level(0.0));
+ _158++;
+ continue;
+ }
+ out.m_3 = in.m_2;
+ return out;
+}
+