2 * Copyright © 2018 Intel Corporation
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:
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
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
25 #include "gl_nir_linker.h"
26 #include "linker_util.h"
27 #include "main/mtypes.h"
28 #include "ir_uniform.h" /* for gl_uniform_storage */
30 /* This file included general link methods, using NIR, instead of IR as
31 * the counter-part glsl/linker.cpp
33 * Also note that this is tailored for ARB_gl_spirv needs and particularities
37 nir_build_program_resource_list(struct gl_context
*ctx
,
38 struct gl_shader_program
*prog
)
40 /* Rebuild resource list. */
41 if (prog
->data
->ProgramResourceList
) {
42 ralloc_free(prog
->data
->ProgramResourceList
);
43 prog
->data
->ProgramResourceList
= NULL
;
44 prog
->data
->NumProgramResourceList
= 0;
47 struct set
*resource_set
= _mesa_pointer_set_create(NULL
);
51 * Here, it is expected that nir_link_uniforms() has already been
52 * called, so that UniformStorage table is already available.
54 for (unsigned i
= 0; i
< prog
->data
->NumUniformStorage
; i
++) {
55 struct gl_uniform_storage
*uniform
= &prog
->data
->UniformStorage
[i
];
57 /* Do not add uniforms internally used by Mesa. */
61 if (!link_util_add_program_resource(prog
, resource_set
, GL_UNIFORM
, uniform
,
62 uniform
->active_shader_mask
)) {
68 _mesa_set_destroy(resource_set
, NULL
);