uint32_t prog_key_size,
cache_key cache_key)
{
- gl_shader_stage stage = ish->nir->info.stage;
-
/* Create a copy of the program key with program_string_id zeroed out.
* It's essentially random data which we don't want to include in our
* hashing and comparisons. We'll set a proper value on a cache hit.
*/
union brw_any_prog_key prog_key;
memcpy(&prog_key, orig_prog_key, prog_key_size);
- brw_prog_key_set_id(&prog_key, stage, 0);
+ prog_key.base.program_string_id = 0;
uint8_t data[sizeof(prog_key) + sizeof(ish->nir_sha1)];
uint32_t data_size = prog_key_size + sizeof(ish->nir_sha1);
#include "iris_context.h"
#include "nir/tgsi_to_nir.h"
-#define KEY_INIT_NO_ID(gen) \
- .tex.swizzles[0 ... MAX_SAMPLERS - 1] = 0x688, \
- .tex.compressed_multisample_layout_mask = ~0, \
- .tex.msaa_16 = (gen >= 9 ? ~0 : 0)
-#define KEY_INIT(gen) .program_string_id = ish->program_id, KEY_INIT_NO_ID(gen)
+#define KEY_INIT_NO_ID(gen) \
+ .base.tex.swizzles[0 ... MAX_SAMPLERS - 1] = 0x688, \
+ .base.tex.compressed_multisample_layout_mask = ~0, \
+ .base.tex.msaa_16 = (gen >= 9 ? ~0 : 0)
+#define KEY_INIT(gen) .base.program_string_id = ish->program_id, KEY_INIT_NO_ID(gen)
static unsigned
get_new_program_id(struct iris_screen *screen)
static void
iris_debug_recompile(struct iris_context *ice,
struct shader_info *info,
- unsigned program_string_id,
- const void *key)
+ const struct brw_base_prog_key *key)
{
struct iris_screen *screen = (struct iris_screen *) ice->ctx.screen;
const struct brw_compiler *c = screen->compiler;
info->label ? info->label : "");
const void *old_key =
- iris_find_previous_compile(ice, info->stage, program_string_id);
+ iris_find_previous_compile(ice, info->stage, key->program_string_id);
brw_debug_key_recompile(c, &ice->dbg, info->stage, old_key, key);
}
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, key->program_string_id, key);
+ iris_debug_recompile(ice, &nir->info, &key->base);
} else {
ish->compiled_once = true;
}
if (ish) {
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, key->program_string_id, key);
+ iris_debug_recompile(ice, &nir->info, &key->base);
} else {
ish->compiled_once = true;
}
iris_get_shader_info(ice, MESA_SHADER_TESS_EVAL);
struct brw_tcs_prog_key key = {
KEY_INIT_NO_ID(devinfo->gen),
- .program_string_id = tcs ? tcs->program_id : 0,
+ .base.program_string_id = tcs ? tcs->program_id : 0,
.tes_primitive_mode = tes_info->tess.primitive_mode,
.input_vertices = ice->state.vertices_per_patch,
};
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, key->program_string_id, key);
+ iris_debug_recompile(ice, &nir->info, &key->base);
} else {
ish->compiled_once = true;
}
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, key->program_string_id, key);
+ iris_debug_recompile(ice, &nir->info, &key->base);
} else {
ish->compiled_once = true;
}
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, key->program_string_id, key);
+ iris_debug_recompile(ice, &nir->info, &key->base);
} else {
ish->compiled_once = true;
}
}
if (ish->compiled_once) {
- iris_debug_recompile(ice, &nir->info, key->program_string_id, key);
+ iris_debug_recompile(ice, &nir->info, &key->base);
} else {
ish->compiled_once = true;
}
return memcmp(a->data, b->data, a->size) == 0;
}
-static unsigned
-get_program_string_id(enum iris_program_cache_id cache_id, const void *key)
-{
- switch (cache_id) {
- case IRIS_CACHE_VS:
- return ((struct brw_vs_prog_key *) key)->program_string_id;
- case IRIS_CACHE_TCS:
- return ((struct brw_tcs_prog_key *) key)->program_string_id;
- case IRIS_CACHE_TES:
- return ((struct brw_tes_prog_key *) key)->program_string_id;
- case IRIS_CACHE_GS:
- return ((struct brw_gs_prog_key *) key)->program_string_id;
- case IRIS_CACHE_CS:
- return ((struct brw_cs_prog_key *) key)->program_string_id;
- case IRIS_CACHE_FS:
- return ((struct brw_wm_prog_key *) key)->program_string_id;
- default:
- unreachable("no program string id for this kind of program");
- }
-}
-
struct iris_compiled_shader *
iris_find_cached_shader(struct iris_context *ice,
enum iris_program_cache_id cache_id,
{
hash_table_foreach(ice->shaders.cache, entry) {
const struct keybox *keybox = entry->key;
+ const struct brw_base_prog_key *key = (const void *)keybox->data;
if (keybox->cache_id == cache_id &&
- get_program_string_id(cache_id, keybox->data) == program_string_id) {
+ key->program_string_id == program_string_id) {
return keybox->data;
}
}
memset(wm_key, 0, sizeof(*wm_key));
wm_key->nr_color_regions = 1;
for (int i = 0; i < MAX_SAMPLERS; i++)
- wm_key->tex.swizzles[i] = SWIZZLE_XYZW;
+ wm_key->base.tex.swizzles[i] = SWIZZLE_XYZW;
}
const unsigned *
struct brw_wm_prog_key wm_key;
brw_blorp_init_wm_prog_key(&wm_key);
- wm_key.tex.compressed_multisample_layout_mask =
+ wm_key.base.tex.compressed_multisample_layout_mask =
prog_key->tex_aux_usage == ISL_AUX_USAGE_MCS;
- wm_key.tex.msaa_16 = prog_key->tex_samples == 16;
+ wm_key.base.tex.msaa_16 = prog_key->tex_samples == 16;
wm_key.multisample_fbo = prog_key->rt_samples > 1;
program = blorp_compile_fs(blorp, mem_ctx, nir, &wm_key, false,
struct brw_wm_prog_key wm_key;
brw_blorp_init_wm_prog_key(&wm_key);
- wm_key.tex.compressed_multisample_layout_mask = 1;
- wm_key.tex.msaa_16 = blorp_key.num_samples == 16;
+ wm_key.base.tex.compressed_multisample_layout_mask = 1;
+ wm_key.base.tex.msaa_16 = blorp_key.num_samples == 16;
wm_key.multisample_fbo = true;
struct brw_wm_prog_data prog_data;
assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes));
return stage_sizes[stage];
}
-
-void
-brw_prog_key_set_id(union brw_any_prog_key *key,
- gl_shader_stage stage,
- unsigned id)
-{
- static const unsigned stage_offsets[] = {
- offsetof(struct brw_vs_prog_key, program_string_id),
- offsetof(struct brw_tcs_prog_key, program_string_id),
- offsetof(struct brw_tes_prog_key, program_string_id),
- offsetof(struct brw_gs_prog_key, program_string_id),
- offsetof(struct brw_wm_prog_key, program_string_id),
- offsetof(struct brw_cs_prog_key, program_string_id),
- };
- assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_offsets));
- *(unsigned*)((uint8_t*)key + stage_offsets[stage]) = id;
-}
float scale_factors[32];
};
+struct brw_base_prog_key {
+ unsigned program_string_id;
+
+ struct brw_sampler_prog_key_data tex;
+};
+
/**
* The VF can't natively handle certain types of attributes, such as GL_FIXED
* or most 10_10_10_2 types. These flags enable various VS workarounds to
/** The program key for Vertex Shaders. */
struct brw_vs_prog_key {
- unsigned program_string_id;
+ struct brw_base_prog_key base;
/**
* Per-attribute workaround flags
* the VUE, even if they aren't written by the vertex shader.
*/
uint8_t point_coord_replace;
-
- struct brw_sampler_prog_key_data tex;
};
/** The program key for Tessellation Control Shaders. */
struct brw_tcs_prog_key
{
- unsigned program_string_id;
+ struct brw_base_prog_key base;
GLenum tes_primitive_mode;
uint64_t outputs_written;
bool quads_workaround;
-
- struct brw_sampler_prog_key_data tex;
};
/** The program key for Tessellation Evaluation Shaders. */
struct brw_tes_prog_key
{
- unsigned program_string_id;
+ struct brw_base_prog_key base;
/** A bitfield of per-patch inputs read. */
uint32_t patch_inputs_read;
/** A bitfield of per-vertex inputs read. */
uint64_t inputs_read;
-
- struct brw_sampler_prog_key_data tex;
};
/** The program key for Geometry Shaders. */
struct brw_gs_prog_key
{
- unsigned program_string_id;
-
- struct brw_sampler_prog_key_data tex;
+ struct brw_base_prog_key base;
};
enum brw_sf_primitive {
/** The program key for Fragment/Pixel Shaders. */
struct brw_wm_prog_key {
+ struct brw_base_prog_key base;
+
/* Some collection of BRW_WM_IZ_* */
uint8_t iz_lookup;
bool stats_wm:1;
uint8_t color_outputs_valid;
uint64_t input_slots_valid;
- unsigned program_string_id;
GLenum alpha_test_func; /* < For Gen4/5 MRT alpha test */
float alpha_test_ref;
-
- struct brw_sampler_prog_key_data tex;
};
struct brw_cs_prog_key {
- uint32_t program_string_id;
- struct brw_sampler_prog_key_data tex;
+ struct brw_base_prog_key base;
};
/* brw_any_prog_key is any of the keys that map to an API stage */
union brw_any_prog_key {
+ struct brw_base_prog_key base;
struct brw_vs_prog_key vs;
struct brw_tcs_prog_key tcs;
struct brw_tes_prog_key tes;
void brw_debug_key_recompile(const struct brw_compiler *c, void *log,
gl_shader_stage stage,
- const void *old_key, const void *key);
+ const struct brw_base_prog_key *old_key,
+ const struct brw_base_prog_key *key);
static inline uint32_t
encode_slm_size(unsigned gen, uint32_t bytes)
return found;
}
+static bool
+debug_base_recompile(const struct brw_compiler *c, void *log,
+ const struct brw_base_prog_key *old_key,
+ const struct brw_base_prog_key *key)
+{
+ return debug_sampler_recompile(c, log, &old_key->tex, &key->tex);
+}
+
static void
debug_vs_recompile(const struct brw_compiler *c, void *log,
const struct brw_vs_prog_key *old_key,
const struct brw_vs_prog_key *key)
{
- bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex);
+ bool found = debug_base_recompile(c, log, &old_key->base, &key->base);
for (unsigned i = 0; i < VERT_ATTRIB_MAX; i++) {
found |= check("vertex attrib w/a flags", gl_attrib_wa_flags[i]);
const struct brw_tcs_prog_key *old_key,
const struct brw_tcs_prog_key *key)
{
- bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex);
+ bool found = debug_base_recompile(c, log, &old_key->base, &key->base);
found |= check("input vertices", input_vertices);
found |= check("outputs written", outputs_written);
const struct brw_tes_prog_key *old_key,
const struct brw_tes_prog_key *key)
{
- bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex);
+ bool found = debug_base_recompile(c, log, &old_key->base, &key->base);
found |= check("inputs read", inputs_read);
found |= check("patch inputs read", patch_inputs_read);
const struct brw_gs_prog_key *old_key,
const struct brw_gs_prog_key *key)
{
- bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex);
+ bool found = debug_base_recompile(c, log, &old_key->base, &key->base);
if (!found) {
c->shader_perf_log(log, " something else\n");
found |= check("mrt alpha test function", alpha_test_func);
found |= check("mrt alpha test reference value", alpha_test_ref);
- found |= debug_sampler_recompile(c, log, &old_key->tex, &key->tex);
+ found |= debug_base_recompile(c, log, &old_key->base, &key->base);
if (!found) {
c->shader_perf_log(log, " something else\n");
const struct brw_cs_prog_key *old_key,
const struct brw_cs_prog_key *key)
{
- bool found = debug_sampler_recompile(c, log, &old_key->tex, &key->tex);
+ bool found = debug_base_recompile(c, log, &old_key->base, &key->base);
if (!found) {
c->shader_perf_log(log, " something else\n");
void
brw_debug_key_recompile(const struct brw_compiler *c, void *log,
gl_shader_stage stage,
- const void *old_key, const void *key)
+ const struct brw_base_prog_key *old_key,
+ const struct brw_base_prog_key *key)
{
if (!old_key) {
c->shader_perf_log(log, " No previous compile found...\n");
switch (stage) {
case MESA_SHADER_VERTEX:
- debug_vs_recompile(c, log, old_key, key);
+ debug_vs_recompile(c, log, (const struct brw_vs_prog_key *)old_key,
+ (const struct brw_vs_prog_key *)key);
break;
case MESA_SHADER_TESS_CTRL:
- debug_tcs_recompile(c, log, old_key, key);
+ debug_tcs_recompile(c, log, (const struct brw_tcs_prog_key *)old_key,
+ (const struct brw_tcs_prog_key *)key);
break;
case MESA_SHADER_TESS_EVAL:
- debug_tes_recompile(c, log, old_key, key);
+ debug_tes_recompile(c, log, (const struct brw_tes_prog_key *)old_key,
+ (const struct brw_tes_prog_key *)key);
break;
case MESA_SHADER_GEOMETRY:
- debug_gs_recompile(c, log, old_key, key);
+ debug_gs_recompile(c, log, (const struct brw_gs_prog_key *)old_key,
+ (const struct brw_gs_prog_key *)key);
break;
case MESA_SHADER_FRAGMENT:
- debug_fs_recompile(c, log, old_key, key);
+ debug_fs_recompile(c, log, (const struct brw_wm_prog_key *)old_key,
+ (const struct brw_wm_prog_key *)key);
break;
case MESA_SHADER_COMPUTE:
- debug_cs_recompile(c, log, old_key, key);
+ debug_cs_recompile(c, log, (const struct brw_cs_prog_key *)old_key,
+ (const struct brw_cs_prog_key *)key);
break;
default:
break;
{
const struct gen_device_info *devinfo = compiler->devinfo;
- brw_nir_apply_sampler_key(shader, compiler, &key->tex, true);
+ brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, true);
brw_nir_lower_fs_inputs(shader, devinfo, key);
brw_nir_lower_fs_outputs(shader);
cfg_t *simd8_cfg = NULL, *simd16_cfg = NULL, *simd32_cfg = NULL;
- fs_visitor v8(compiler, log_data, mem_ctx, key,
+ fs_visitor v8(compiler, log_data, mem_ctx, &key->base,
&prog_data->base, prog, shader, 8,
shader_time_index8);
if (!v8.run_fs(allow_spilling, false /* do_rep_send */)) {
if (v8.max_dispatch_width >= 16 &&
likely(!(INTEL_DEBUG & DEBUG_NO16) || use_rep_send)) {
/* Try a SIMD16 compile */
- fs_visitor v16(compiler, log_data, mem_ctx, key,
+ fs_visitor v16(compiler, log_data, mem_ctx, &key->base,
&prog_data->base, prog, shader, 16,
shader_time_index16);
v16.import_uniforms(&v8);
compiler->devinfo->gen >= 6 &&
unlikely(INTEL_DEBUG & DEBUG_DO32)) {
/* Try a SIMD32 compile */
- fs_visitor v32(compiler, log_data, mem_ctx, key,
+ fs_visitor v32(compiler, log_data, mem_ctx, &key->base,
&prog_data->base, prog, shader, 32,
shader_time_index32);
v32.import_uniforms(&v8);
unsigned dispatch_width)
{
nir_shader *shader = nir_shader_clone(mem_ctx, src_shader);
- brw_nir_apply_sampler_key(shader, compiler, &key->tex, true);
+ brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, true);
NIR_PASS_V(shader, brw_nir_lower_cs_intrinsics, dispatch_width);
if (min_dispatch_width <= 8) {
nir_shader *nir8 = compile_cs_to_nir(compiler, mem_ctx, key,
src_shader, 8);
- v8 = new fs_visitor(compiler, log_data, mem_ctx, key, &prog_data->base,
+ v8 = new fs_visitor(compiler, log_data, mem_ctx, &key->base,
+ &prog_data->base,
NULL, /* Never used in core profile */
nir8, 8, shader_time_index);
if (!v8->run_cs(min_dispatch_width)) {
/* Try a SIMD16 compile */
nir_shader *nir16 = compile_cs_to_nir(compiler, mem_ctx, key,
src_shader, 16);
- v16 = new fs_visitor(compiler, log_data, mem_ctx, key, &prog_data->base,
+ v16 = new fs_visitor(compiler, log_data, mem_ctx, &key->base,
+ &prog_data->base,
NULL, /* Never used in core profile */
nir16, 16, shader_time_index);
if (v8)
/* Try a SIMD32 compile */
nir_shader *nir32 = compile_cs_to_nir(compiler, mem_ctx, key,
src_shader, 32);
- v32 = new fs_visitor(compiler, log_data, mem_ctx, key, &prog_data->base,
+ v32 = new fs_visitor(compiler, log_data, mem_ctx, &key->base,
+ &prog_data->base,
NULL, /* Never used in core profile */
nir32, 32, shader_time_index);
if (v8)
public:
fs_visitor(const struct brw_compiler *compiler, void *log_data,
void *mem_ctx,
- const void *key,
+ const brw_base_prog_key *key,
struct brw_stage_prog_data *prog_data,
struct gl_program *prog,
const nir_shader *shader,
void dump_instruction(backend_instruction *inst);
void dump_instruction(backend_instruction *inst, FILE *file);
- const void *const key;
+ const brw_base_prog_key *const key;
const struct brw_sampler_prog_key_data *key_tex;
struct brw_gs_compile *gs_compile;
fs_visitor::fs_visitor(const struct brw_compiler *compiler, void *log_data,
void *mem_ctx,
- const void *key,
+ const brw_base_prog_key *key,
struct brw_stage_prog_data *prog_data,
struct gl_program *prog,
const nir_shader *shader,
int shader_time_index)
: backend_shader(compiler, log_data, mem_ctx, shader,
&prog_data->base.base),
- key(&c->key), gs_compile(c),
+ key(&c->key.base), gs_compile(c),
prog_data(&prog_data->base.base), prog(NULL),
dispatch_width(8),
shader_time_index(shader_time_index),
void
fs_visitor::init()
{
- switch (stage) {
- case MESA_SHADER_FRAGMENT:
- key_tex = &((const brw_wm_prog_key *) key)->tex;
- break;
- case MESA_SHADER_VERTEX:
- key_tex = &((const brw_vs_prog_key *) key)->tex;
- break;
- case MESA_SHADER_TESS_CTRL:
- key_tex = &((const brw_tcs_prog_key *) key)->tex;
- break;
- case MESA_SHADER_TESS_EVAL:
- key_tex = &((const brw_tes_prog_key *) key)->tex;
- break;
- case MESA_SHADER_GEOMETRY:
- key_tex = &((const brw_gs_prog_key *) key)->tex;
- break;
- case MESA_SHADER_COMPUTE:
- key_tex = &((const brw_cs_prog_key*) key)->tex;
- break;
- default:
- unreachable("unhandled shader stage");
- }
+ this->key_tex = &key->tex;
this->max_dispatch_width = 32;
this->prog_data = this->stage_prog_data;
nir->info.inputs_read = key->inputs_read;
nir->info.patch_inputs_read = key->patch_inputs_read;
- brw_nir_apply_sampler_key(nir, compiler, &key->tex, is_scalar);
+ brw_nir_apply_sampler_key(nir, compiler, &key->base.tex, is_scalar);
brw_nir_lower_tes_inputs(nir, input_vue_map);
brw_nir_lower_vue_outputs(nir);
brw_postprocess_nir(nir, compiler, is_scalar);
}
if (is_scalar) {
- fs_visitor v(compiler, log_data, mem_ctx, (void *) key,
+ fs_visitor v(compiler, log_data, mem_ctx, &key->base,
&prog_data->base.base, NULL, nir, 8,
shader_time_index, input_vue_map);
if (!v.run_tes()) {
char **error_str)
{
const bool is_scalar = compiler->scalar_stage[MESA_SHADER_VERTEX];
- brw_nir_apply_sampler_key(shader, compiler, &key->tex, is_scalar);
+ brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, is_scalar);
const unsigned *assembly = NULL;
if (is_scalar) {
prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8;
- fs_visitor v(compiler, log_data, mem_ctx, key, &prog_data->base.base,
+ fs_visitor v(compiler, log_data, mem_ctx, &key->base,
+ &prog_data->base.base,
NULL, /* prog; Only used for TEXTURE_RECTANGLE on gen < 8 */
shader, 8, shader_time_index);
if (!v.run_vs()) {
void *mem_ctx,
bool no_spills,
int shader_time_index)
- : vec4_visitor(compiler, log_data, &c->key.tex,
+ : vec4_visitor(compiler, log_data, &c->key.base.tex,
&prog_data->base, shader, mem_ctx,
no_spills, shader_time_index),
c(c),
&c.input_vue_map, inputs_read,
shader->info.separate_shader);
- brw_nir_apply_sampler_key(shader, compiler, &key->tex, is_scalar);
+ brw_nir_apply_sampler_key(shader, compiler, &key->base.tex, is_scalar);
brw_nir_lower_vue_inputs(shader, &c.input_vue_map);
brw_nir_lower_vue_outputs(shader);
brw_postprocess_nir(shader, compiler, is_scalar);
void *mem_ctx,
int shader_time_index,
const struct brw_vue_map *input_vue_map)
- : vec4_visitor(compiler, log_data, &key->tex, &prog_data->base,
+ : vec4_visitor(compiler, log_data, &key->base.tex, &prog_data->base,
nir, mem_ctx, false, shader_time_index),
input_vue_map(input_vue_map), key(key)
{
nir->info.outputs_written,
nir->info.patch_outputs_written);
- brw_nir_apply_sampler_key(nir, compiler, &key->tex, is_scalar);
+ brw_nir_apply_sampler_key(nir, compiler, &key->base.tex, is_scalar);
brw_nir_lower_vue_inputs(nir, &input_vue_map);
brw_nir_lower_tcs_outputs(nir, &vue_prog_data->vue_map,
key->tes_primitive_mode);
}
if (is_scalar) {
- fs_visitor v(compiler, log_data, mem_ctx, (void *) key,
+ fs_visitor v(compiler, log_data, mem_ctx, &key->base,
&prog_data->base.base, NULL, nir, 8,
shader_time_index, &input_vue_map);
if (!v.run_tcs()) {
const nir_shader *shader,
void *mem_ctx,
int shader_time_index)
- : vec4_visitor(compiler, log_data, &key->tex, &prog_data->base,
+ : vec4_visitor(compiler, log_data, &key->base.tex, &prog_data->base,
shader, mem_ctx, false, shader_time_index)
{
}
const nir_shader *shader,
void *mem_ctx,
int shader_time_index)
- : vec4_visitor(compiler, log_data, &key->tex, &vs_prog_data->base, shader,
- mem_ctx, false /* no_spills */, shader_time_index),
+ : vec4_visitor(compiler, log_data, &key->base.tex, &vs_prog_data->base,
+ shader, mem_ctx, false /* no_spills */, shader_time_index),
key(key),
vs_prog_data(vs_prog_data)
{
}
}
+static void
+populate_base_prog_key(const struct gen_device_info *devinfo,
+ struct brw_base_prog_key *key)
+{
+ populate_sampler_prog_key(devinfo, &key->tex);
+}
+
static void
populate_vs_prog_key(const struct gen_device_info *devinfo,
struct brw_vs_prog_key *key)
{
memset(key, 0, sizeof(*key));
- populate_sampler_prog_key(devinfo, &key->tex);
+ populate_base_prog_key(devinfo, &key->base);
/* XXX: Handle vertex input work-arounds */
{
memset(key, 0, sizeof(*key));
- populate_sampler_prog_key(devinfo, &key->tex);
+ populate_base_prog_key(devinfo, &key->base);
key->input_vertices = input_vertices;
}
{
memset(key, 0, sizeof(*key));
- populate_sampler_prog_key(devinfo, &key->tex);
+ populate_base_prog_key(devinfo, &key->base);
}
static void
{
memset(key, 0, sizeof(*key));
- populate_sampler_prog_key(devinfo, &key->tex);
+ populate_base_prog_key(devinfo, &key->base);
}
static void
{
memset(key, 0, sizeof(*key));
- populate_sampler_prog_key(devinfo, &key->tex);
+ populate_base_prog_key(devinfo, &key->base);
/* We set this to 0 here and set to the actual value before we call
* brw_compile_fs.
{
memset(key, 0, sizeof(*key));
- populate_sampler_prog_key(devinfo, &key->tex);
+ populate_base_prog_key(devinfo, &key->base);
}
struct anv_pipeline_stage {
if (unlikely(brw->perf_debug)) {
if (cp->compiled_once) {
brw_debug_recompile(brw, MESA_SHADER_COMPUTE, cp->program.Id,
- key->program_string_id, key);
+ &key->base);
}
cp->compiled_once = true;
/* BRW_NEW_COMPUTE_PROGRAM */
const struct brw_program *cp =
(struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
- const struct gl_program *prog = (struct gl_program *) cp;
memset(key, 0, sizeof(*key));
/* _NEW_TEXTURE */
- brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
-
- /* The unique compute program ID */
- key->program_string_id = cp->id;
+ brw_populate_base_prog_key(ctx, cp, &key->base);
}
return;
cp = (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
- cp->id = key.program_string_id;
+ cp->id = key.base.program_string_id;
MAYBE_UNUSED bool success = brw_codegen_cs_prog(brw, cp, &key);
assert(success);
{
const struct gen_device_info *devinfo = compiler->devinfo;
memset(key, 0, sizeof(*key));
- key->program_string_id = brw_program(prog)->id;
-
- brw_setup_tex_for_precompile(devinfo, &key->tex, prog);
+ brw_populate_default_base_prog_key(devinfo, brw_program(prog), &key->base);
}
bool
* lookup, so set the id to 0 for the sha1 hashing. program_string_id will
* be set below.
*/
- brw_prog_key_set_id(&prog_key, stage, 0);
+ prog_key.base.program_string_id = 0;
gen_shader_sha1(prog, stage, &prog_key, binary_sha1);
unreachable("Unsupported stage!");
}
- brw_prog_key_set_id(&prog_key, stage, brw_program(prog)->id);
+ prog_key.base.program_string_id = brw_program(prog)->id;
brw_alloc_stage_scratch(brw, stage_state, prog_data->total_scratch);
if (prog && !prog->program_written_to_cache) {
struct brw_vs_prog_key vs_key;
brw_vs_populate_key(brw, &vs_key);
- vs_key.program_string_id = 0;
+ vs_key.base.program_string_id = 0;
write_program_data(brw, prog, &vs_key, brw->vs.base.prog_data,
brw->vs.base.prog_offset, cache,
if (prog && !prog->program_written_to_cache) {
struct brw_tcs_prog_key tcs_key;
brw_tcs_populate_key(brw, &tcs_key);
- tcs_key.program_string_id = 0;
+ tcs_key.base.program_string_id = 0;
write_program_data(brw, prog, &tcs_key, brw->tcs.base.prog_data,
brw->tcs.base.prog_offset, cache,
if (prog && !prog->program_written_to_cache) {
struct brw_tes_prog_key tes_key;
brw_tes_populate_key(brw, &tes_key);
- tes_key.program_string_id = 0;
+ tes_key.base.program_string_id = 0;
write_program_data(brw, prog, &tes_key, brw->tes.base.prog_data,
brw->tes.base.prog_offset, cache,
if (prog && !prog->program_written_to_cache) {
struct brw_gs_prog_key gs_key;
brw_gs_populate_key(brw, &gs_key);
- gs_key.program_string_id = 0;
+ gs_key.base.program_string_id = 0;
write_program_data(brw, prog, &gs_key, brw->gs.base.prog_data,
brw->gs.base.prog_offset, cache,
if (prog && !prog->program_written_to_cache) {
struct brw_wm_prog_key wm_key;
brw_wm_populate_key(brw, &wm_key);
- wm_key.program_string_id = 0;
+ wm_key.base.program_string_id = 0;
write_program_data(brw, prog, &wm_key, brw->wm.base.prog_data,
brw->wm.base.prog_offset, cache,
if (prog && !prog->program_written_to_cache) {
struct brw_cs_prog_key cs_key;
brw_cs_populate_key(brw, &cs_key);
- cs_key.program_string_id = 0;
+ cs_key.base.program_string_id = 0;
write_program_data(brw, prog, &cs_key, brw->cs.base.prog_data,
brw->cs.base.prog_offset, cache,
if (unlikely(brw->perf_debug)) {
if (gp->compiled_once) {
brw_debug_recompile(brw, MESA_SHADER_GEOMETRY, gp->program.Id,
- key->program_string_id, key);
+ &key->base);
}
if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
perf_debug("GS compile took %.03f ms and stalled the GPU\n",
memset(key, 0, sizeof(*key));
- key->program_string_id = gp->id;
-
- /* _NEW_TEXTURE */
- brw_populate_sampler_prog_key_data(ctx, &gp->program, &key->tex);
+ brw_populate_base_prog_key(ctx, gp, &key->base);
}
void
return;
gp = (struct brw_program *) brw->programs[MESA_SHADER_GEOMETRY];
- gp->id = key.program_string_id;
+ gp->id = key.base.program_string_id;
MAYBE_UNUSED bool success = brw_codegen_gs_prog(brw, gp, &key);
assert(success);
memset(key, 0, sizeof(*key));
- brw_setup_tex_for_precompile(devinfo, &key->tex, prog);
- key->program_string_id = brw_program(prog)->id;
+ brw_populate_default_base_prog_key(devinfo, brw_program(prog),
+ &key->base);
}
bool
void
brw_setup_tex_for_precompile(const struct gen_device_info *devinfo,
struct brw_sampler_prog_key_data *tex,
- struct gl_program *prog)
+ const struct gl_program *prog)
{
const bool has_shader_channel_select = devinfo->is_haswell || devinfo->gen >= 8;
unsigned sampler_count = util_last_bit(prog->SamplersUsed);
brw_debug_recompile(struct brw_context *brw,
gl_shader_stage stage,
unsigned api_id,
- unsigned key_program_string_id,
- void *key)
+ struct brw_base_prog_key *key)
{
const struct brw_compiler *compiler = brw->screen->compiler;
enum brw_cache_id cache_id = brw_stage_cache_id(stage);
_mesa_shader_stage_to_string(stage), api_id);
const void *old_key =
- brw_find_previous_compile(&brw->cache, cache_id, key_program_string_id);
+ brw_find_previous_compile(&brw->cache, cache_id, key->program_string_id);
brw_debug_key_recompile(compiler, brw, stage, old_key, key);
}
void brw_setup_tex_for_precompile(const struct gen_device_info *devinfo,
struct brw_sampler_prog_key_data *tex,
- struct gl_program *prog);
-
-void brw_populate_sampler_prog_key_data(struct gl_context *ctx,
- const struct gl_program *prog,
- struct brw_sampler_prog_key_data *key);
+ const struct gl_program *prog);
+
+void brw_populate_base_prog_key(struct gl_context *ctx,
+ const struct brw_program *prog,
+ struct brw_base_prog_key *key);
+void brw_populate_default_base_prog_key(const struct gen_device_info *devinfo,
+ const struct brw_program *prog,
+ struct brw_base_prog_key *key);
void brw_debug_recompile(struct brw_context *brw, gl_shader_stage stage,
- unsigned api_id, unsigned prog_string_id, void *key);
+ unsigned api_id, struct brw_base_prog_key *key);
+
uint32_t
brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
const struct gl_program *prog,
union brw_any_prog_key prog_key;
blob_copy_bytes(reader, &prog_key, brw_prog_key_size(stage));
- brw_prog_key_set_id(&prog_key, stage, brw_program(prog)->id);
+ prog_key.base.program_string_id = brw_program(prog)->id;
enum brw_cache_id cache_id = brw_stage_cache_id(stage);
/** for variable-sized keys */
GLuint key_size;
GLuint prog_data_size;
- const void *key;
+ const struct brw_base_prog_key *key;
uint32_t offset;
uint32_t size;
return stage_ids[stage];
}
-static unsigned
-get_program_string_id(enum brw_cache_id cache_id, const void *key)
-{
- switch (cache_id) {
- case BRW_CACHE_VS_PROG:
- return ((struct brw_vs_prog_key *) key)->program_string_id;
- case BRW_CACHE_TCS_PROG:
- return ((struct brw_tcs_prog_key *) key)->program_string_id;
- case BRW_CACHE_TES_PROG:
- return ((struct brw_tes_prog_key *) key)->program_string_id;
- case BRW_CACHE_GS_PROG:
- return ((struct brw_gs_prog_key *) key)->program_string_id;
- case BRW_CACHE_CS_PROG:
- return ((struct brw_cs_prog_key *) key)->program_string_id;
- case BRW_CACHE_FS_PROG:
- return ((struct brw_wm_prog_key *) key)->program_string_id;
- default:
- unreachable("no program string id for this kind of program");
- }
-}
-
static GLuint
hash_key(struct brw_cache_item *item)
{
for (unsigned i = 0; i < cache->size; i++) {
for (struct brw_cache_item *c = cache->items[i]; c; c = c->next) {
if (c->cache_id == cache_id &&
- get_program_string_id(cache_id, c->key) == program_string_id) {
+ c->key->program_string_id == program_string_id) {
return c->key;
}
}
if (tcp) {
if (tcp->compiled_once) {
brw_debug_recompile(brw, MESA_SHADER_TESS_CTRL, tcp->program.Id,
- key->program_string_id, key);
+ &key->base);
}
tcp->compiled_once = true;
}
tep->program.info.tess.spacing == TESS_SPACING_EQUAL;
if (tcp) {
- key->program_string_id = tcp->id;
-
/* _NEW_TEXTURE */
- brw_populate_sampler_prog_key_data(&brw->ctx, &tcp->program, &key->tex);
+ brw_populate_base_prog_key(&brw->ctx, tcp, &key->base);
}
}
tcp = (struct brw_program *) brw->programs[MESA_SHADER_TESS_CTRL];
if (tcp)
- tcp->id = key.program_string_id;
+ tcp->id = key.base.program_string_id;
MAYBE_UNUSED bool success = brw_codegen_tcs_prog(brw, tcp, tep, &key);
assert(success);
memset(key, 0, sizeof(*key));
- key->program_string_id = btcp->id;
- brw_setup_tex_for_precompile(devinfo, &key->tex, prog);
+ brw_populate_default_base_prog_key(devinfo, btcp, &key->base);
/* Guess that the input and output patches have the same dimensionality. */
if (devinfo->gen < 8 || compiler->use_tcs_8_patch)
if (unlikely(brw->perf_debug)) {
if (tep->compiled_once) {
brw_debug_recompile(brw, MESA_SHADER_TESS_EVAL, tep->program.Id,
- key->program_string_id, key);
+ &key->base);
}
if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
perf_debug("TES compile took %.03f ms and stalled the GPU\n",
memset(key, 0, sizeof(*key));
- key->program_string_id = tep->id;
+ /* _NEW_TEXTURE */
+ brw_populate_base_prog_key(&brw->ctx, tep, &key->base);
/* The TCS may have additional outputs which aren't read by the
* TES (possibly for cross-thread communication). These need to
key->inputs_read = per_vertex_slots;
key->patch_inputs_read = per_patch_slots;
-
- /* _NEW_TEXTURE */
- brw_populate_sampler_prog_key_data(&brw->ctx, prog, &key->tex);
}
void
return;
tep = (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL];
- tep->id = key.program_string_id;
+ tep->id = key.base.program_string_id;
MAYBE_UNUSED bool success = brw_codegen_tes_prog(brw, tep, &key);
assert(success);
memset(key, 0, sizeof(*key));
- key->program_string_id = btep->id;
+ brw_populate_default_base_prog_key(devinfo, btep, &key->base);
+
key->inputs_read = prog->nir->info.inputs_read;
key->patch_inputs_read = prog->nir->info.patch_inputs_read;
~(VARYING_BIT_TESS_LEVEL_INNER | VARYING_BIT_TESS_LEVEL_OUTER);
key->patch_inputs_read |= tcp->nir->info.patch_outputs_written;
}
-
- brw_setup_tex_for_precompile(devinfo, &key->tex, prog);
}
bool
if (unlikely(brw->perf_debug)) {
if (vp->compiled_once) {
brw_debug_recompile(brw, MESA_SHADER_VERTEX, vp->program.Id,
- key->program_string_id, key);
+ &key->base);
}
if (start_busy && !brw_bo_busy(brw->batch.last_bo)) {
perf_debug("VS compile took %.03f ms and stalled the GPU\n",
/* Just upload the program verbatim for now. Always send it all
* the inputs it asks for, whether they are varying or not.
*/
- key->program_string_id = vp->id;
+
+ /* _NEW_TEXTURE */
+ brw_populate_base_prog_key(ctx, vp, &key->base);
if (ctx->Transform.ClipPlanesEnabled != 0 &&
(ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) &&
key->clamp_vertex_color = ctx->Light._ClampVertexColor;
}
- /* _NEW_TEXTURE */
- brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
-
/* BRW_NEW_VS_ATTRIB_WORKAROUNDS */
if (devinfo->gen < 8 && !devinfo->is_haswell) {
memcpy(key->gl_attrib_wa_flags, brw->vb.attrib_wa_flags,
return;
vp = (struct brw_program *) brw->programs[MESA_SHADER_VERTEX];
- vp->id = key.program_string_id;
+ vp->id = key.base.program_string_id;
MAYBE_UNUSED bool success = brw_codegen_vs_prog(brw, vp, &key);
assert(success);
memset(key, 0, sizeof(*key));
- brw_setup_tex_for_precompile(devinfo, &key->tex, prog);
- key->program_string_id = bvp->id;
+ brw_populate_default_base_prog_key(devinfo, bvp, &key->base);
+
key->clamp_vertex_color =
(prog->info.outputs_written &
(VARYING_BIT_COL0 | VARYING_BIT_COL1 | VARYING_BIT_BFC0 |
if (unlikely(brw->perf_debug)) {
if (fp->compiled_once) {
brw_debug_recompile(brw, MESA_SHADER_FRAGMENT, fp->program.Id,
- key->program_string_id, key);
+ &key->base);
}
fp->compiled_once = true;
}
}
-void
+static void
brw_populate_sampler_prog_key_data(struct gl_context *ctx,
const struct gl_program *prog,
struct brw_sampler_prog_key_data *key)
}
}
+void
+brw_populate_base_prog_key(struct gl_context *ctx,
+ const struct brw_program *prog,
+ struct brw_base_prog_key *key)
+{
+ key->program_string_id = prog->id;
+ brw_populate_sampler_prog_key_data(ctx, &prog->program, &key->tex);
+}
+
+void
+brw_populate_default_base_prog_key(const struct gen_device_info *devinfo,
+ const struct brw_program *prog,
+ struct brw_base_prog_key *key)
+{
+ key->program_string_id = prog->id;
+ brw_setup_tex_for_precompile(devinfo, &key->tex, &prog->program);
+}
+
static bool
brw_wm_state_dirty(const struct brw_context *brw)
{
key->clamp_fragment_color = ctx->Color._ClampFragmentColor;
/* _NEW_TEXTURE */
- brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
+ brw_populate_base_prog_key(ctx, fp, &key->base);
/* _NEW_BUFFERS */
key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;
key->alpha_test_ref = ctx->Color.AlphaRef;
}
- /* The unique fragment program ID */
- key->program_string_id = fp->id;
-
/* Whether reads from the framebuffer should behave coherently. */
key->coherent_fb_fetch = ctx->Extensions.EXT_shader_framebuffer_fetch;
}
return;
fp = (struct brw_program *) brw->programs[MESA_SHADER_FRAGMENT];
- fp->id = key.program_string_id;
+ fp->id = key.base.program_string_id;
MAYBE_UNUSED bool success = brw_codegen_wm_prog(brw, fp, &key,
&brw->vue_map_geom_out);
memset(key, 0, sizeof(*key));
+ brw_populate_default_base_prog_key(devinfo, brw_program(prog),
+ &key->base);
+
uint64_t outputs_written = prog->info.outputs_written;
if (devinfo->gen < 6) {
key->input_slots_valid = prog->info.inputs_read | VARYING_BIT_POS;
}
- brw_setup_tex_for_precompile(devinfo, &key->tex, prog);
-
key->nr_color_regions = util_bitcount64(outputs_written &
~(BITFIELD64_BIT(FRAG_RESULT_DEPTH) |
BITFIELD64_BIT(FRAG_RESULT_STENCIL) |
BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)));
- key->program_string_id = brw_program(prog)->id;
-
/* Whether reads from the framebuffer should behave coherently. */
key->coherent_fb_fetch = devinfo->gen >= 9;
}