2da9757854862608833aa7b8a017967e92ec66c9
[mesa.git] / src / compiler / shader_info.c
1 /*
2 * Copyright © 2016 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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24
25 #include "mesa/main/mtypes.h"
26
27 void
28 copy_shader_info(const struct gl_shader_program *shader_prog,
29 struct gl_linked_shader *sh)
30 {
31 shader_info *info = &sh->Program->info;
32
33 info->inputs_read = sh->Program->InputsRead;
34 info->double_inputs_read = sh->Program->DoubleInputsRead;
35 info->outputs_written = sh->Program->OutputsWritten;
36 info->outputs_read = sh->Program->OutputsRead;
37 info->patch_inputs_read = sh->Program->PatchInputsRead;
38 info->patch_outputs_written = sh->Program->PatchOutputsWritten;
39 info->system_values_read = sh->Program->SystemValuesRead;
40 info->uses_texture_gather = sh->Program->UsesGather;
41
42 switch (sh->Stage) {
43 case MESA_SHADER_GEOMETRY:
44 info->gs.vertices_in = shader_prog->Geom.VerticesIn;
45 info->gs.output_primitive = sh->info.Geom.OutputType;
46 info->gs.vertices_out = sh->info.Geom.VerticesOut;
47 info->gs.invocations = sh->info.Geom.Invocations;
48 info->gs.uses_end_primitive = shader_prog->Geom.UsesEndPrimitive;
49 info->gs.uses_streams = shader_prog->Geom.UsesStreams;
50 break;
51
52 case MESA_SHADER_FRAGMENT: {
53 struct gl_fragment_program *fp =
54 (struct gl_fragment_program *)sh->Program;
55
56 info->fs.uses_discard = fp->UsesKill;
57 info->fs.uses_sample_qualifier = fp->IsSample != 0;
58 info->fs.early_fragment_tests = sh->info.EarlyFragmentTests;
59 info->fs.depth_layout = fp->FragDepthLayout;
60 break;
61 }
62
63 case MESA_SHADER_COMPUTE: {
64 struct gl_compute_program *cp = (struct gl_compute_program *)sh->Program;
65 info->cs.local_size[0] = cp->LocalSize[0];
66 info->cs.local_size[1] = cp->LocalSize[1];
67 info->cs.local_size[2] = cp->LocalSize[2];
68 break;
69 }
70
71 default:
72 break; /* No stage-specific info */
73 }
74 }