}
-/* Run our configurable linear shader pipeline:
+/*
+ * Run our configurable linear shader pipeline:
+ * x,y is the surface position of the linear region, width, height is the size.
+ * Return TRUE for success, FALSE otherwise.
*/
static boolean
lp_fs_linear_run(const struct lp_rast_state *state,
const struct lp_fragment_shader_variant *variant = state->variant;
const struct lp_tgsi_info *info = &variant->shader->info;
struct lp_jit_linear_context jit;
- lp_jit_linear_llvm_func jit_func = variant->jit_linear_llvm;
-
- struct lp_linear_sampler samp[LP_MAX_LINEAR_TEXTURES];
- struct lp_linear_interp interp[LP_MAX_LINEAR_INPUTS];
-
- const float w0 = a0[0][3];
- float oow = 1.0f/w0;
-
- unsigned input_mask = variant->linear_input_mask;
int nr_consts = info->base.file_max[TGSI_FILE_CONSTANT]+1;
- int nr_tex = info->num_texs;
- int i, j;
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
if (variant->shader->base.type == PIPE_SHADER_IR_TGSI) {
uint8_t constants[LP_MAX_LINEAR_CONSTANTS][4];
- for (i = 0; i < nr_consts; i++) {
- for (j = 0; j < 4; j++) {
+ for (int i = 0; i < nr_consts; i++) {
+ for (int j = 0; j < 4; j++) {
float val = state->jit_context.constants[0][i*4+j];
if (val < 0.0f || val > 1.0f) {
if (LP_DEBUG & DEBUG_LINEAR2)
} else {
uint8_t nir_constants[LP_MAX_LINEAR_CONSTANTS * 4];
- for (i = 0; i < state->jit_context.num_constants[0]; i++){
+ for (int i = 0; i < state->jit_context.num_constants[0]; i++){
float val = state->jit_context.constants[0][i];
if (val < 0.0f || val > 1.0f) {
if (LP_DEBUG & DEBUG_LINEAR2)
/* XXX: Per primitive:
*/
+ struct lp_linear_interp interp[LP_MAX_LINEAR_INPUTS];
+ const float oow = 1.0f / a0[0][3];
+ unsigned input_mask = variant->linear_input_mask;
while (input_mask) {
int i = u_bit_scan(&input_mask);
unsigned usage_mask = info->base.input_usage_mask[i];
info->base.input_interpolate[i] == TGSI_INTERPOLATE_PERSPECTIVE ||
(info->base.input_interpolate[i] == TGSI_INTERPOLATE_COLOR &&
!variant->key.flatshade);
-
if (!lp_linear_init_interp(&interp[i],
x, y, width, height,
usage_mask,
jit.inputs[i] = &interp[i].base;
}
-
/* XXX: Per primitive: Initialize linear or nearest samplers:
*/
- for (i = 0; i < nr_tex; i++) {
+ struct lp_linear_sampler samp[LP_MAX_LINEAR_TEXTURES];
+ const int nr_tex = info->num_texs;
+ for (int i = 0; i < nr_tex; i++) {
const struct lp_tgsi_texture_info *tex_info = &info->tex[i];
- unsigned unit = tex_info->sampler_unit;
+ const unsigned tex_unit = tex_info->texture_unit;
+ const unsigned samp_unit = tex_info->sampler_unit;
+ //const unsigned fs_s_input = tex_info->coord[0].u.index;
+ //const unsigned fs_t_input = tex_info->coord[1].u.index;
+
+ // xxx investigate why these fail in deqp-vk
+ //assert(variant->linear_input_mask & (1 << fs_s_input));
+ //assert(variant->linear_input_mask & (1 << fs_t_input));
/* XXX: some texture coordinates are linear!
*/
//boolean perspective = (info->base.input_interpolate[i] ==
// TGSI_INTERPOLATE_PERSPECTIVE);
- if (!lp_linear_init_sampler(&samp[i],
- tex_info,
- lp_fs_variant_key_sampler_idx(&variant->key, unit),
- &state->jit_context.textures[unit],
- x, y, width, height,
- a0, dadx, dady)) {
+ if (!lp_linear_init_sampler(&samp[i], tex_info,
+ lp_fs_variant_key_sampler_idx(&variant->key, samp_unit),
+ &state->jit_context.textures[tex_unit],
+ x, y, width, height, a0, dadx, dady)) {
if (LP_DEBUG & DEBUG_LINEAR2)
debug_printf(" -- init_sampler(%d) failed\n", i);
goto fail;
/* JIT function already does blending */
jit.color0 = color + x * 4 + y * stride;
- for (y = 0; y < height; y++) {
- jit_func(&jit, 0, 0, width);
+ lp_jit_linear_llvm_func jit_func = variant->jit_linear_llvm;
+
+ for (unsigned iy = 0; iy < height; iy++) {
+ jit_func(&jit, 0, 0, width); // x=0, y=0
jit.color0 += stride;
}
uint8_t constants[LP_MAX_LINEAR_CONSTANTS][4];
alignas(16) uint8_t color0[TILE_SIZE*4];
- int nr_inputs = info->base.file_max[TGSI_FILE_INPUT]+1;
- int nr_tex = info->num_texs;
- int i;
+ const int nr_inputs = info->base.file_max[TGSI_FILE_INPUT]+1;
+ const int nr_tex = info->num_texs;
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
jit.constants = (const uint8_t (*)[4])constants;
- for (i = 0; i < nr_tex; i++) {
+ for (int i = 0; i < nr_tex; i++) {
lp_linear_init_noop_sampler(&samp[i]);
jit.tex[i] = &samp[i].base;
}
- for (i = 0; i < nr_inputs; i++) {
+ for (int i = 0; i < nr_inputs; i++) {
lp_linear_init_noop_interp(&interp[i]);
jit.inputs[i] = &interp[i].base;
}
/* Find out which interpolators were called, and store this as a
* mask:
*/
- for (i = 0; i < nr_inputs; i++)
+ for (int i = 0; i < nr_inputs; i++) {
variant->linear_input_mask |= (interp[i].row[0] << i);
+ }
}
const struct lp_fragment_shader_variant_key *key = &variant->key;
const struct lp_fragment_shader *shader = variant->shader;
const struct lp_tgsi_info *info = &shader->info;
- int i;
if (info->base.file_max[TGSI_FILE_CONSTANT] >= LP_MAX_LINEAR_CONSTANTS ||
info->base.file_max[TGSI_FILE_INPUT] >= LP_MAX_LINEAR_INPUTS) {
goto fail;
}
- /* If we have a fastpath which implements the entire varient, use
+ /* If we have a fastpath which implements the entire variant, use
* that.
*/
if (lp_linear_check_fastpath(variant)) {
/* Check static sampler state.
*/
- for (i = 0; i < info->num_texs; i++) {
+ for (unsigned i = 0; i < info->num_texs; i++) {
const struct lp_tgsi_texture_info *tex_info = &info->tex[i];
- unsigned unit = tex_info->sampler_unit;
+ const unsigned unit = tex_info->sampler_unit;
/* XXX: Relax this once setup premultiplies by oow:
*/
goto fail;
}
- struct lp_sampler_static_state *samp = lp_fs_variant_key_sampler_idx(key, unit);
+ struct lp_sampler_static_state *samp =
+ lp_fs_variant_key_sampler_idx(key, unit);
if (!lp_linear_check_sampler(samp, tex_info)) {
if (LP_DEBUG & DEBUG_LINEAR)
debug_printf(" -- samp[%d]: check_sampler failed\n", i);