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:
authorChip Davis <cdavis@codeweavers.com>2020-02-21 06:38:28 +0300
committerChip Davis <cdavis@codeweavers.com>2020-07-24 01:59:54 +0300
commit688c5fcbda2abe98889fd5de70fd58e0b36c8a26 (patch)
treea5086179e4f453f914066c84b153918a7a8c39d4 /spirv_cross_c.cpp
parent3dcc23a5b3e667b5d30dc64653c73cb7a39b6ee5 (diff)
MSL: Add support for processing more than one patch per workgroup.
This should hopefully reduce underutilization of the GPU, especially on GPUs where the thread execution width is greater than the number of control points. This also simplifies initialization by reading the buffer directly instead of using Metal's vertex-attribute-in-compute support. It turns out the only way in which shader stages are allowed to differ in their interfaces is in the number of components per vector; the base type must be the same. Since we are using the raw buffer instead of attributes, we can now also emit arrays and matrices directly into the buffer, instead of flattening them and then unpacking them. Structs are still flattened, however; this is due to the need to handle vectors with fewer components than were output, and I think handling this while also directly emitting structs could get ugly. Another advantage of this scheme is that the extra invocations needed to read the attributes when there were more input than output points are now no more. The number of threads per workgroup is now lcm(SIMD-size, output control points). This should ensure we always process a whole number of patches per workgroup. To avoid complexity handling indices in the tessellation control shader, I've also changed the way vertex shaders for tessellation are handled. They are now compute kernels using Metal's support for vertex-style stage input. This lets us always emit vertices into the buffer in order of vertex shader execution. Now we no longer have to deal with indexing in the tessellation control shader. This also fixes a long-standing issue where if an index were greater than the number of vertices to draw, the vertex shader would wind up writing outside the buffer, and the vertex would be lost. This is a breaking change, and I know SPIRV-Cross has other clients, so I've hidden this behind an option for now. In the future, I want to remove this option and make it the default.
Diffstat (limited to 'spirv_cross_c.cpp')
-rw-r--r--spirv_cross_c.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/spirv_cross_c.cpp b/spirv_cross_c.cpp
index ec1edd99..c7d1361b 100644
--- a/spirv_cross_c.cpp
+++ b/spirv_cross_c.cpp
@@ -635,6 +635,26 @@ spvc_result spvc_compiler_options_set_uint(spvc_compiler_options options, spvc_c
case SPVC_COMPILER_OPTION_MSL_ENABLE_CLIP_DISTANCE_USER_VARYING:
options->msl.enable_clip_distance_user_varying = value != 0;
break;
+
+ case SPVC_COMPILER_OPTION_MSL_MULTI_PATCH_WORKGROUP:
+ options->msl.multi_patch_workgroup = value != 0;
+ break;
+
+ case SPVC_COMPILER_OPTION_MSL_SHADER_INPUT_BUFFER_INDEX:
+ options->msl.shader_input_buffer_index = value;
+ break;
+
+ case SPVC_COMPILER_OPTION_MSL_SHADER_INDEX_BUFFER_INDEX:
+ options->msl.shader_index_buffer_index = value;
+ break;
+
+ case SPVC_COMPILER_OPTION_MSL_VERTEX_FOR_TESSELLATION:
+ options->msl.vertex_for_tessellation = value != 0;
+ break;
+
+ case SPVC_COMPILER_OPTION_MSL_VERTEX_INDEX_TYPE:
+ options->msl.vertex_index_type = static_cast<CompilerMSL::Options::IndexType>(value);
+ break;
#endif
default: