xref: /aosp_15_r20/external/mesa3d/src/mesa/main/spirv_capabilities.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright 2017 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
24 /**
25  * \file
26  * \brief SPIRV-V capability handling.
27  */
28 
29 #include "spirv_capabilities.h"
30 #include "compiler/spirv/spirv_info.h"
31 
32 void
_mesa_fill_supported_spirv_capabilities(struct spirv_capabilities * caps,struct gl_constants * consts,const struct gl_extensions * gl_exts)33 _mesa_fill_supported_spirv_capabilities(struct spirv_capabilities *caps,
34                                         struct gl_constants *consts,
35                                         const struct gl_extensions *gl_exts)
36 {
37    const struct spirv_supported_extensions *spirv_exts = consts->SpirVExtensions;
38 
39    *caps = (struct spirv_capabilities) {
40       /* These come from the table in GL_ARB_gl_spirv */
41       .Matrix                             = true,
42       .Shader                             = true,
43       .Geometry                           = true,
44       .Tessellation                       = gl_exts->ARB_tessellation_shader,
45       .Float64                            = gl_exts->ARB_gpu_shader_fp64,
46       .AtomicStorage                      = gl_exts->ARB_shader_atomic_counters,
47       .TessellationPointSize              = gl_exts->ARB_tessellation_shader,
48       .GeometryPointSize                  = true,
49       .ImageGatherExtended                = gl_exts->ARB_gpu_shader5,
50       .StorageImageMultisample            = gl_exts->ARB_shader_image_load_store &&
51                                             consts->MaxImageSamples > 1,
52       .UniformBufferArrayDynamicIndexing  = gl_exts->ARB_gpu_shader5,
53       .SampledImageArrayDynamicIndexing   = gl_exts->ARB_gpu_shader5,
54       .StorageBufferArrayDynamicIndexing  = gl_exts->ARB_shader_storage_buffer_object,
55       .StorageImageArrayDynamicIndexing   = gl_exts->ARB_shader_image_load_store,
56       .ClipDistance                       = true,
57       .CullDistance                       = gl_exts->ARB_cull_distance,
58       .ImageCubeArray                     = gl_exts->ARB_texture_cube_map_array,
59       .SampleRateShading                  = gl_exts->ARB_sample_shading,
60       .ImageRect                          = true,
61       .SampledRect                        = true,
62       .Sampled1D                          = true,
63       .Image1D                            = true,
64       .SampledCubeArray                   = gl_exts->ARB_texture_cube_map_array,
65       .SampledBuffer                      = true,
66       .ImageBuffer                        = true,
67       .ImageMSArray                       = true,
68       .StorageImageExtendedFormats        = gl_exts->ARB_shader_image_load_store,
69       .ImageQuery                         = true,
70       .DerivativeControl                  = gl_exts->ARB_derivative_control,
71       .InterpolationFunction              = gl_exts->ARB_gpu_shader5,
72       .GeometryStreams                    = gl_exts->ARB_gpu_shader5,
73       .StorageImageWriteWithoutFormat     = gl_exts->ARB_shader_image_load_store,
74       .MultiViewport                      = gl_exts->ARB_viewport_array,
75 
76       /* These aren't in the main table for some reason */
77       .Int64                              = gl_exts->ARB_gpu_shader_int64,
78       .SparseResidency                    = gl_exts->ARB_sparse_texture2,
79       .MinLod                             = gl_exts->ARB_sparse_texture_clamp,
80       .StorageImageReadWithoutFormat      = gl_exts->EXT_shader_image_load_formatted,
81       .Int64Atomics                       = gl_exts->NV_shader_atomic_int64,
82 
83       /* These come from their individual extension specs */
84       .DemoteToHelperInvocation           = gl_exts->EXT_demote_to_helper_invocation,
85       .DrawParameters                     = gl_exts->ARB_shader_draw_parameters &&
86                                             spirv_exts->supported[SPV_KHR_shader_draw_parameters],
87       .ComputeDerivativeGroupQuadsNV      = gl_exts->NV_compute_shader_derivatives,
88       .ComputeDerivativeGroupLinearNV     = gl_exts->NV_compute_shader_derivatives,
89       .SampleMaskPostDepthCoverage        = gl_exts->ARB_post_depth_coverage,
90       .ShaderClockKHR                     = gl_exts->ARB_shader_clock,
91       .ShaderViewportIndexLayerEXT        = gl_exts->ARB_shader_viewport_layer_array,
92       .StencilExportEXT                   = gl_exts->ARB_shader_stencil_export,
93       .SubgroupBallotKHR                  = gl_exts->ARB_shader_ballot &&
94                                             spirv_exts->supported[SPV_KHR_shader_ballot],
95       .SubgroupVoteKHR                    = gl_exts->ARB_shader_group_vote &&
96                                             spirv_exts->supported[SPV_KHR_subgroup_vote],
97       .TransformFeedback                  = gl_exts->ARB_transform_feedback3,
98       .VariablePointers                   = spirv_exts->supported[SPV_KHR_variable_pointers],
99       .IntegerFunctions2INTEL             = gl_exts->INTEL_shader_integer_functions2,
100 
101       .GroupNonUniform                    = consts->ShaderSubgroupSupportedFeatures &
102                                             GL_SUBGROUP_FEATURE_BASIC_BIT_KHR,
103       .GroupNonUniformArithmetic          = consts->ShaderSubgroupSupportedFeatures &
104                                             GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR,
105       .GroupNonUniformBallot              = consts->ShaderSubgroupSupportedFeatures &
106                                             GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR,
107       .GroupNonUniformClustered           = consts->ShaderSubgroupSupportedFeatures &
108                                             GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR,
109       .GroupNonUniformQuad                = consts->ShaderSubgroupSupportedFeatures &
110                                             GL_SUBGROUP_FEATURE_QUAD_BIT_KHR,
111       .GroupNonUniformShuffle             = consts->ShaderSubgroupSupportedFeatures &
112                                             GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR,
113       .GroupNonUniformShuffleRelative     = consts->ShaderSubgroupSupportedFeatures &
114                                             GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR,
115       .GroupNonUniformVote                = consts->ShaderSubgroupSupportedFeatures &
116                                             GL_SUBGROUP_FEATURE_VOTE_BIT_KHR,
117    };
118 }
119