nir = brw_nir_create_passthrough_tcs(mem_ctx, compiler, options, key);
/* Reserve space for passing the default tess levels as constants. */
- prog_data->param = rzalloc_array(mem_ctx, uint32_t, 8);
- prog_data->nr_params = 8;
+ num_system_values = 8;
+ system_values =
+ rzalloc_array(mem_ctx, enum brw_param_builtin, num_system_values);
+ prog_data->param = rzalloc_array(mem_ctx, uint32_t, num_system_values);
+ prog_data->nr_params = num_system_values;
+
+ if (key->tes_primitive_mode == GL_QUADS) {
+ for (int i = 0; i < 4; i++)
+ system_values[7 - i] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X + i;
+
+ system_values[3] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X;
+ system_values[2] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_Y;
+ } else if (key->tes_primitive_mode == GL_TRIANGLES) {
+ for (int i = 0; i < 3; i++)
+ system_values[7 - i] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X + i;
+
+ system_values[4] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X;
+ } else {
+ assert(key->tes_primitive_mode == GL_ISOLINES);
+ system_values[7] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_Y;
+ system_values[6] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X;
+ }
+
prog_data->ubo_ranges[0].length = 1;
}
const float default_inner_level[2])
{
struct iris_context *ice = (struct iris_context *) ctx;
+ struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_TESS_CTRL];
memcpy(&ice->state.default_outer_level[0], &default_outer_level[0], 4 * sizeof(float));
memcpy(&ice->state.default_inner_level[0], &default_inner_level[0], 2 * sizeof(float));
ice->state.dirty |= IRIS_DIRTY_CONSTANTS_TCS;
+ shs->cbuf0_needs_upload = true;
}
static void
value = tcs_info->tess.tcs_vertices_out;
}
+ } else if (sysval >= BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X &&
+ sysval <= BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_W) {
+ unsigned i = sysval - BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X;
+ value = fui(ice->state.default_outer_level[i]);
+ } else if (sysval == BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X) {
+ value = fui(ice->state.default_inner_level[0]);
+ } else if (sysval == BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_Y) {
+ value = fui(ice->state.default_inner_level[1]);
} else {
assert(!"unhandled system value");
}
}
}
- /* Upload constants for TCS passthrough. */
- if ((dirty & IRIS_DIRTY_CONSTANTS_TCS) &&
- ice->shaders.prog[MESA_SHADER_TESS_CTRL] &&
- !ice->shaders.uncompiled[MESA_SHADER_TESS_CTRL]) {
- struct iris_compiled_shader *tes_shader = ice->shaders.prog[MESA_SHADER_TESS_EVAL];
- assert(tes_shader);
-
- /* Passthrough always copies 2 vec4s, so when uploading data we ensure
- * it is in the right layout for TES.
- */
- float hdr[8] = {};
- struct brw_tes_prog_data *tes_prog_data = (void *) tes_shader->prog_data;
- switch (tes_prog_data->domain) {
- case BRW_TESS_DOMAIN_QUAD:
- for (int i = 0; i < 4; i++)
- hdr[7 - i] = ice->state.default_outer_level[i];
- hdr[3] = ice->state.default_inner_level[0];
- hdr[2] = ice->state.default_inner_level[1];
- break;
- case BRW_TESS_DOMAIN_TRI:
- for (int i = 0; i < 3; i++)
- hdr[7 - i] = ice->state.default_outer_level[i];
- hdr[4] = ice->state.default_inner_level[0];
- break;
- case BRW_TESS_DOMAIN_ISOLINE:
- hdr[7] = ice->state.default_outer_level[1];
- hdr[6] = ice->state.default_outer_level[0];
- break;
- }
-
- struct iris_shader_state *shs = &ice->state.shaders[MESA_SHADER_TESS_CTRL];
- struct iris_const_buffer *cbuf = &shs->constbuf[0];
- u_upload_data(ice->ctx.const_uploader, 0, sizeof(hdr), 32,
- &hdr[0], &cbuf->data.offset,
- &cbuf->data.res);
- }
-
for (int stage = 0; stage <= MESA_SHADER_FRAGMENT; stage++) {
if (!(dirty & (IRIS_DIRTY_CONSTANTS_VS << stage)))
continue;