2 * Copyright © 2011 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
27 #include "compiler/brw_compiler.h"
36 enum brw_param_domain
{
37 BRW_PARAM_DOMAIN_BUILTIN
= 0,
38 BRW_PARAM_DOMAIN_PARAMETER
,
39 BRW_PARAM_DOMAIN_UNIFORM
,
40 BRW_PARAM_DOMAIN_IMAGE
,
43 #define BRW_PARAM(domain, val) (BRW_PARAM_DOMAIN_##domain << 24 | (val))
44 #define BRW_PARAM_DOMAIN(param) ((uint32_t)(param) >> 24)
45 #define BRW_PARAM_VALUE(param) ((uint32_t)(param) & 0x00ffffff)
47 #define BRW_PARAM_PARAMETER(idx, comp) \
48 BRW_PARAM(PARAMETER, ((idx) << 2) | (comp))
49 #define BRW_PARAM_PARAMETER_IDX(param) (BRW_PARAM_VALUE(param) >> 2)
50 #define BRW_PARAM_PARAMETER_COMP(param) (BRW_PARAM_VALUE(param) & 0x3)
52 #define BRW_PARAM_UNIFORM(idx) BRW_PARAM(UNIFORM, (idx))
53 #define BRW_PARAM_UNIFORM_IDX(param) BRW_PARAM_VALUE(param)
55 #define BRW_PARAM_IMAGE(idx, offset) BRW_PARAM(IMAGE, ((idx) << 8) | (offset))
56 #define BRW_PARAM_IMAGE_IDX(value) (BRW_PARAM_VALUE(value) >> 8)
57 #define BRW_PARAM_IMAGE_OFFSET(value) (BRW_PARAM_VALUE(value) & 0xf)
59 struct nir_shader
*brw_create_nir(struct brw_context
*brw
,
60 const struct gl_shader_program
*shader_prog
,
61 struct gl_program
*prog
,
62 gl_shader_stage stage
,
65 void brw_shader_gather_info(nir_shader
*nir
, struct gl_program
*prog
);
67 void brw_setup_tex_for_precompile(struct brw_context
*brw
,
68 struct brw_sampler_prog_key_data
*tex
,
69 struct gl_program
*prog
);
71 void brw_populate_sampler_prog_key_data(struct gl_context
*ctx
,
72 const struct gl_program
*prog
,
73 struct brw_sampler_prog_key_data
*key
);
74 bool brw_debug_recompile_sampler_key(struct brw_context
*brw
,
75 const struct brw_sampler_prog_key_data
*old_key
,
76 const struct brw_sampler_prog_key_data
*key
);
79 brw_assign_common_binding_table_offsets(const struct gen_device_info
*devinfo
,
80 const struct gl_program
*prog
,
81 struct brw_stage_prog_data
*stage_prog_data
,
82 uint32_t next_binding_table_offset
);
85 brw_program_deserialize_nir(struct gl_context
*ctx
, struct gl_program
*prog
,
86 gl_shader_stage stage
);
89 brw_stage_prog_data_free(const void *prog_data
);
92 brw_dump_arb_asm(const char *stage
, struct gl_program
*prog
);
94 bool brw_vs_precompile(struct gl_context
*ctx
, struct gl_program
*prog
);
95 bool brw_tcs_precompile(struct gl_context
*ctx
,
96 struct gl_shader_program
*shader_prog
,
97 struct gl_program
*prog
);
98 bool brw_tes_precompile(struct gl_context
*ctx
,
99 struct gl_shader_program
*shader_prog
,
100 struct gl_program
*prog
);
101 bool brw_gs_precompile(struct gl_context
*ctx
, struct gl_program
*prog
);
102 bool brw_fs_precompile(struct gl_context
*ctx
, struct gl_program
*prog
);
103 bool brw_cs_precompile(struct gl_context
*ctx
, struct gl_program
*prog
);
105 GLboolean
brw_link_shader(struct gl_context
*ctx
, struct gl_shader_program
*prog
);
107 void brw_upload_tcs_prog(struct brw_context
*brw
);
108 void brw_tcs_populate_key(struct brw_context
*brw
,
109 struct brw_tcs_prog_key
*key
);
110 void brw_upload_tes_prog(struct brw_context
*brw
);
111 void brw_tes_populate_key(struct brw_context
*brw
,
112 struct brw_tes_prog_key
*key
);