2016-01-29 17:16:23 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2016 Red Hat
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ST_NIR_H
|
|
|
|
#define ST_NIR_H
|
|
|
|
|
2015-12-22 02:34:11 +00:00
|
|
|
#include "st_context.h"
|
|
|
|
#include "compiler/shader_enums.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-06-30 04:15:03 +01:00
|
|
|
struct nir_shader;
|
2016-01-29 17:16:23 +00:00
|
|
|
|
2016-06-30 04:15:03 +01:00
|
|
|
void st_nir_lower_builtin(struct nir_shader *shader);
|
2016-09-08 19:57:25 +01:00
|
|
|
void st_nir_lower_tex_src_plane(struct nir_shader *shader, unsigned free_slots,
|
|
|
|
unsigned lower_2plane, unsigned lower_3plane);
|
|
|
|
|
2018-10-25 10:22:33 +01:00
|
|
|
void st_nir_lower_wpos_ytransform(struct nir_shader *nir,
|
|
|
|
struct gl_program *prog,
|
|
|
|
struct pipe_screen *pscreen);
|
|
|
|
|
2021-08-03 18:20:18 +01:00
|
|
|
char *st_finalize_nir(struct st_context *st, struct gl_program *prog,
|
|
|
|
struct gl_shader_program *shader_program,
|
|
|
|
struct nir_shader *nir, bool finalize_by_driver,
|
|
|
|
bool is_before_variants);
|
2015-12-22 02:34:11 +00:00
|
|
|
|
2017-11-09 06:32:08 +00:00
|
|
|
bool
|
|
|
|
st_link_nir(struct gl_context *ctx,
|
|
|
|
struct gl_shader_program *shader_program);
|
2015-12-22 02:34:11 +00:00
|
|
|
|
2019-10-18 18:02:15 +01:00
|
|
|
void st_nir_assign_vs_in_locations(struct nir_shader *nir);
|
2018-10-30 05:41:18 +00:00
|
|
|
void st_nir_assign_varying_locations(struct st_context *st,
|
|
|
|
struct nir_shader *nir);
|
|
|
|
|
2019-02-06 08:03:49 +00:00
|
|
|
void st_nir_lower_samplers(struct pipe_screen *screen, struct nir_shader *nir,
|
nir: Gather texture bitmasks in gl_nir_lower_samplers_as_deref.
Eric and I would like a bitmask of which samplers are used, similar to
prog->SamplersUsed, but available in NIR. The linker uses SamplersUsed
for resource limit checking, but later optimizations may eliminate more
samplers. So instead of propagating it through, we gather a new one.
While there, we also gather the existing textures_used_by_txf bitmask.
Gathering these bitfields in nir_shader_gather_info is awkward at best.
The main reason is that it introduces an ordering dependency between the
two passes. If gathering runs before lower_samplers_as_deref, it can't
look at var->data.binding. If the driver doesn't use the full lowering
to texture_index/texture_array_size (like radeonsi), then the gathering
can't use those fields. Gathering might be run early /and/ late, first
to get varying info, and later to update it after variant lowering. At
this point, should gathering work on pre-lowered or post-lowered code?
Pre-lowered is also harder due to the presence of structure types.
Just doing the gathering when we do the lowering alleviates these
ordering problems. This fixes ordering issues in i965 and makes the
txf info gathering work for radeonsi (though they don't use it).
Reviewed-by: Eric Anholt <eric@anholt.net>
2019-01-13 18:39:41 +00:00
|
|
|
struct gl_shader_program *shader_program,
|
|
|
|
struct gl_program *prog);
|
2020-01-06 19:47:03 +00:00
|
|
|
void st_nir_lower_uniforms(struct st_context *st, struct nir_shader *nir);
|
2019-02-06 08:03:49 +00:00
|
|
|
|
2018-10-30 05:30:06 +00:00
|
|
|
struct pipe_shader_state *
|
|
|
|
st_nir_finish_builtin_shader(struct st_context *st,
|
2020-10-26 18:37:25 +00:00
|
|
|
struct nir_shader *nir);
|
2018-10-30 05:30:06 +00:00
|
|
|
|
|
|
|
struct pipe_shader_state *
|
|
|
|
st_nir_make_passthrough_shader(struct st_context *st,
|
|
|
|
const char *shader_name,
|
|
|
|
gl_shader_stage stage,
|
|
|
|
unsigned num_vars,
|
|
|
|
unsigned *input_locations,
|
|
|
|
unsigned *output_locations,
|
|
|
|
unsigned *interpolation_modes,
|
|
|
|
unsigned sysval_mask);
|
2022-04-04 16:35:21 +01:00
|
|
|
void
|
|
|
|
st_nir_add_point_size(struct nir_shader *nir);
|
2022-05-13 12:33:20 +01:00
|
|
|
|
|
|
|
struct pipe_shader_state *
|
|
|
|
st_nir_make_clearcolor_shader(struct st_context *st);
|
|
|
|
|
2015-12-22 02:34:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2016-01-29 17:16:23 +00:00
|
|
|
|
|
|
|
#endif /* ST_NIR_H */
|