}
}
+static void si_set_sampler_state_desc(struct si_sampler_state *sstate,
+ struct si_sampler_view *sview,
+ struct r600_texture *tex,
+ uint32_t *desc)
+{
+ if (sview && sview->is_integer)
+ memcpy(desc, sstate->integer_val, 4*4);
+ else if (tex && tex->upgraded_depth &&
+ (!sview || !sview->is_stencil_sampler))
+ memcpy(desc, sstate->upgraded_depth_val, 4*4);
+ else
+ memcpy(desc, sstate->val, 4*4);
+}
+
static void si_set_sampler_view_desc(struct si_context *sctx,
struct si_sampler_view *sview,
struct si_sampler_state *sstate,
/* Disable FMASK and bind sampler state in [12:15]. */
memcpy(desc + 8, null_texture_descriptor, 4*4);
- if (sstate) {
- if (!is_buffer && rtex->upgraded_depth &&
- !sview->is_stencil_sampler)
- memcpy(desc + 12, sstate->upgraded_depth_val, 4*4);
- else
- memcpy(desc + 12, sstate->val, 4*4);
- }
+ if (sstate)
+ si_set_sampler_state_desc(sstate, sview,
+ is_buffer ? NULL : rtex,
+ desc + 12);
}
}
memcpy(desc + 8, null_texture_descriptor, 4*4);
/* Re-set the sampler state if we are transitioning from FMASK. */
if (views->sampler_states[slot])
- memcpy(desc + 12,
- views->sampler_states[slot]->val, 4*4);
+ si_set_sampler_state_desc(views->sampler_states[slot], NULL, NULL,
+ desc + 12);
views->enabled_mask &= ~(1u << slot);
}
if (tex && tex->fmask.size)
continue;
- if (tex && tex->upgraded_depth && !sview->is_stencil_sampler)
- memcpy(desc->list + desc_slot * 16 + 12,
- sstates[i]->upgraded_depth_val, 4*4);
- else
- memcpy(desc->list + desc_slot * 16 + 12,
- sstates[i]->val, 4*4);
+ si_set_sampler_state_desc(sstates[i], sview, tex,
+ desc->list + desc_slot * 16 + 12);
sctx->descriptors_dirty |= 1u << si_sampler_and_image_descriptors_idx(shader);
}
width, height, depth,
view->state, view->fmask_state);
+ unsigned num_format = G_008F14_NUM_FORMAT_GFX6(view->state[1]);
+ view->is_integer =
+ num_format == V_008F14_IMG_NUM_FORMAT_USCALED ||
+ num_format == V_008F14_IMG_NUM_FORMAT_SSCALED ||
+ num_format == V_008F14_IMG_NUM_FORMAT_UINT ||
+ num_format == V_008F14_IMG_NUM_FORMAT_SINT;
view->base_level_info = &surflevel[base_level];
view->base_level = base_level;
view->block_width = util_format_get_blockwidth(pipe_format);
static uint32_t si_translate_border_color(struct si_context *sctx,
const struct pipe_sampler_state *state,
- const union pipe_color_union *color)
+ const union pipe_color_union *color,
+ bool is_integer)
{
bool linear_filter = state->min_img_filter != PIPE_TEX_FILTER_NEAREST ||
state->mag_img_filter != PIPE_TEX_FILTER_NEAREST;
- if ((color->f[0] == 0 && color->f[1] == 0 &&
- color->f[2] == 0 && color->f[3] == 0) ||
- (!wrap_mode_uses_border_color(state->wrap_s, linear_filter) &&
- !wrap_mode_uses_border_color(state->wrap_t, linear_filter) &&
- !wrap_mode_uses_border_color(state->wrap_r, linear_filter)))
+ if (!wrap_mode_uses_border_color(state->wrap_s, linear_filter) &&
+ !wrap_mode_uses_border_color(state->wrap_t, linear_filter) &&
+ !wrap_mode_uses_border_color(state->wrap_r, linear_filter))
return S_008F3C_BORDER_COLOR_TYPE(V_008F3C_SQ_TEX_BORDER_COLOR_TRANS_BLACK);
- if (color->f[0] == 0 && color->f[1] == 0 &&
- color->f[2] == 0 && color->f[3] == 1)
- return S_008F3C_BORDER_COLOR_TYPE(V_008F3C_SQ_TEX_BORDER_COLOR_OPAQUE_BLACK);
- if (color->f[0] == 1 && color->f[1] == 1 &&
- color->f[2] == 1 && color->f[3] == 1)
- return S_008F3C_BORDER_COLOR_TYPE(V_008F3C_SQ_TEX_BORDER_COLOR_OPAQUE_WHITE);
+#define simple_border_types(elt) \
+do { \
+ if (color->elt[0] == 0 && color->elt[1] == 0 && \
+ color->elt[2] == 0 && color->elt[3] == 0) \
+ return S_008F3C_BORDER_COLOR_TYPE(V_008F3C_SQ_TEX_BORDER_COLOR_TRANS_BLACK); \
+ if (color->elt[0] == 0 && color->elt[1] == 0 && \
+ color->elt[2] == 0 && color->elt[3] == 1) \
+ return S_008F3C_BORDER_COLOR_TYPE(V_008F3C_SQ_TEX_BORDER_COLOR_OPAQUE_BLACK); \
+ if (color->elt[0] == 1 && color->elt[1] == 1 && \
+ color->elt[2] == 1 && color->elt[3] == 1) \
+ return S_008F3C_BORDER_COLOR_TYPE(V_008F3C_SQ_TEX_BORDER_COLOR_OPAQUE_WHITE); \
+} while (false)
+
+ if (is_integer)
+ simple_border_types(ui);
+ else
+ simple_border_types(f);
+
+#undef simple_border_types
int i;
S_008F38_DISABLE_LSB_CEIL(sctx->b.chip_class <= VI) |
S_008F38_FILTER_PREC_FIX(1) |
S_008F38_ANISO_OVERRIDE(sctx->b.chip_class >= VI));
- rstate->val[3] = si_translate_border_color(sctx, state, &state->border_color);
+ rstate->val[3] = si_translate_border_color(sctx, state, &state->border_color, false);
+
+ /* Create sampler resource for integer textures. */
+ memcpy(rstate->integer_val, rstate->val, sizeof(rstate->val));
+ rstate->integer_val[3] = si_translate_border_color(sctx, state, &state->border_color, true);
/* Create sampler resource for upgraded depth textures. */
memcpy(rstate->upgraded_depth_val, rstate->val, sizeof(rstate->val));
rstate->upgraded_depth_val[3] |= S_008F3C_UPGRADED_DEPTH(1);
else
rstate->upgraded_depth_val[3] =
- si_translate_border_color(sctx, state, &clamped_border_color) |
+ si_translate_border_color(sctx, state, &clamped_border_color, false) |
S_008F3C_UPGRADED_DEPTH(1);
return rstate;