Beispiel #1
0
static void *
fd3_sampler_state_create(struct pipe_context *pctx,
		const struct pipe_sampler_state *cso)
{
	struct fd3_sampler_stateobj *so = CALLOC_STRUCT(fd3_sampler_stateobj);
	bool miplinear = false;

	if (!so)
		return NULL;

	if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR)
		miplinear = true;

	so->base = *cso;

	so->texsamp0 =
			COND(!cso->normalized_coords, A3XX_TEX_SAMP_0_UNNORM_COORDS) |
			COND(miplinear, A3XX_TEX_SAMP_0_MIPFILTER_LINEAR) |
			A3XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter)) |
			A3XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter)) |
			A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s)) |
			A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t)) |
			A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r));

	if (cso->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
		so->texsamp1 =
				A3XX_TEX_SAMP_1_MIN_LOD(cso->min_lod) |
				A3XX_TEX_SAMP_1_MAX_LOD(cso->max_lod);
	} else {
		so->texsamp1 = 0x00000000;
	}

	return so;
}
Beispiel #2
0
static void *
fd3_sampler_state_create(struct pipe_context *pctx,
		const struct pipe_sampler_state *cso)
{
	struct fd3_sampler_stateobj *so = CALLOC_STRUCT(fd3_sampler_stateobj);
	unsigned aniso = util_last_bit(MIN2(cso->max_anisotropy >> 1, 8));
	bool miplinear = false;
	bool clamp_to_edge;

	if (!so)
		return NULL;

	if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR)
		miplinear = true;

	so->base = *cso;

	/*
	 * For nearest filtering, _CLAMP means _CLAMP_TO_EDGE;  for linear
	 * filtering, _CLAMP means _CLAMP_TO_BORDER while additionally
	 * clamping the texture coordinates to [0.0, 1.0].
	 *
	 * The clamping will be taken care of in the shaders.  There are two
	 * filters here, but let the minification one has a say.
	 */
	clamp_to_edge = (cso->min_img_filter == PIPE_TEX_FILTER_NEAREST);
	if (!clamp_to_edge) {
		so->saturate_s = (cso->wrap_s == PIPE_TEX_WRAP_CLAMP);
		so->saturate_t = (cso->wrap_t == PIPE_TEX_WRAP_CLAMP);
		so->saturate_r = (cso->wrap_r == PIPE_TEX_WRAP_CLAMP);
	}

	so->needs_border = false;
	so->texsamp0 =
			COND(!cso->normalized_coords, A3XX_TEX_SAMP_0_UNNORM_COORDS) |
			COND(!cso->seamless_cube_map, A3XX_TEX_SAMP_0_CUBEMAPSEAMLESSFILTOFF) |
			COND(miplinear, A3XX_TEX_SAMP_0_MIPFILTER_LINEAR) |
			A3XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) |
			A3XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) |
			A3XX_TEX_SAMP_0_ANISO(aniso) |
			A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) |
			A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge, &so->needs_border)) |
			A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge, &so->needs_border));

	if (cso->compare_mode)
		so->texsamp0 |= A3XX_TEX_SAMP_0_COMPARE_FUNC(cso->compare_func); /* maps 1:1 */

	if (cso->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
		so->texsamp1 =
				A3XX_TEX_SAMP_1_LOD_BIAS(cso->lod_bias) |
				A3XX_TEX_SAMP_1_MIN_LOD(cso->min_lod) |
				A3XX_TEX_SAMP_1_MAX_LOD(cso->max_lod);
	} else {
		so->texsamp1 = 0x00000000;
	}

	return so;
}
Beispiel #3
0
static void *
fd3_sampler_state_create(struct pipe_context *pctx,
		const struct pipe_sampler_state *cso)
{
	struct fd3_sampler_stateobj *so = CALLOC_STRUCT(fd3_sampler_stateobj);

	if (!so)
		return NULL;

	so->base = *cso;

	so->texsamp0 =
			A3XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter)) |
			A3XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter)) |
			A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s)) |
			A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t)) |
			A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r));
	so->texsamp1 = 0x00000000;  /* ??? */

	return so;
}
Beispiel #4
0
static void *
fd3_sampler_state_create(struct pipe_context *pctx,
		const struct pipe_sampler_state *cso)
{
	struct fd3_sampler_stateobj *so = CALLOC_STRUCT(fd3_sampler_stateobj);
	bool miplinear = false;

	if (!so)
		return NULL;

	if (cso->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR)
		miplinear = true;

	so->base = *cso;

	so->texsamp0 =
			COND(!cso->normalized_coords, A3XX_TEX_SAMP_0_UNNORM_COORDS) |
			COND(miplinear, A3XX_TEX_SAMP_0_MIPFILTER_LINEAR) |
			A3XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter)) |
			A3XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter)) |
			A3XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s)) |
			A3XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t)) |
			A3XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r));

	/* when mip-map is not disabled, this gets set.. I guess possibly
	 * it is the LOD related params, but I think I need GLES3 blob driver
	 * to be able to tell..
	 */
	if (cso->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
		so->texsamp1 = 0x003ff000;
	} else {
		so->texsamp1 = 0x00000000;
	}

	return so;
}