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