static void *
fd_sampler_state_create(struct pipe_context *pctx,
		const struct pipe_sampler_state *cso)
{
	struct fd_sampler_stateobj *so = CALLOC_STRUCT(fd_sampler_stateobj);

	if (!so)
		return NULL;

	so->base = *cso;

	/* SQ_TEX0_PITCH() must be OR'd in later when we know the bound texture: */
	so->tex0 =
		SQ_TEX0_CLAMP_X(tex_clamp(cso->wrap_s)) |
		SQ_TEX0_CLAMP_Y(tex_clamp(cso->wrap_t)) |
		SQ_TEX0_CLAMP_Z(tex_clamp(cso->wrap_r));

	so->tex3 =
		SQ_TEX3_XY_MAG_FILTER(tex_filter(cso->mag_img_filter)) |
		SQ_TEX3_XY_MIN_FILTER(tex_filter(cso->min_img_filter));

	so->tex4 = 0x00000000; /* ??? */
	so->tex5 = 0x00000200; /* ??? */

	return so;
}
Exemple #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);
	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;
}
Exemple #3
0
static void *
fd5_sampler_state_create(struct pipe_context *pctx,
		const struct pipe_sampler_state *cso)
{
	struct fd5_sampler_stateobj *so = CALLOC_STRUCT(fd5_sampler_stateobj);
	unsigned aniso = util_last_bit(MIN2(cso->max_anisotropy >> 1, 8));
	bool miplinear = false;
	bool clamp_to_edge;

	if (!so)
		return NULL;

	so->base = *cso;

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

	/*
	 * 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(miplinear, A5XX_TEX_SAMP_0_MIPFILTER_LINEAR_NEAR) |
		A5XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) |
		A5XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) |
		A5XX_TEX_SAMP_0_ANISO(aniso) |
		A5XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s, clamp_to_edge, &so->needs_border)) |
		A5XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t, clamp_to_edge, &so->needs_border)) |
		A5XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r, clamp_to_edge, &so->needs_border));

	so->texsamp1 =
		COND(!cso->seamless_cube_map, A5XX_TEX_SAMP_1_CUBEMAPSEAMLESSFILTOFF) |
		COND(!cso->normalized_coords, A5XX_TEX_SAMP_1_UNNORM_COORDS);

	if (cso->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
		so->texsamp0 |= A5XX_TEX_SAMP_0_LOD_BIAS(cso->lod_bias);
		so->texsamp1 |=
			A5XX_TEX_SAMP_1_MIN_LOD(cso->min_lod) |
			A5XX_TEX_SAMP_1_MAX_LOD(cso->max_lod);
	}

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

	return so;
}
Exemple #4
0
static void *
fd4_sampler_state_create(struct pipe_context *pctx,
		const struct pipe_sampler_state *cso)
{
	struct fd4_sampler_stateobj *so = CALLOC_STRUCT(fd4_sampler_stateobj);
	unsigned aniso = util_last_bit(MIN2(cso->max_anisotropy >> 1, 8));
	bool miplinear = false;

	if (!so)
		return NULL;

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

	so->base = *cso;

	so->texsamp0 =
		COND(miplinear, A4XX_TEX_SAMP_0_MIPFILTER_LINEAR_NEAR) |
		A4XX_TEX_SAMP_0_XY_MAG(tex_filter(cso->mag_img_filter, aniso)) |
		A4XX_TEX_SAMP_0_XY_MIN(tex_filter(cso->min_img_filter, aniso)) |
		A4XX_TEX_SAMP_0_ANISO(aniso) |
		A4XX_TEX_SAMP_0_WRAP_S(tex_clamp(cso->wrap_s)) |
		A4XX_TEX_SAMP_0_WRAP_T(tex_clamp(cso->wrap_t)) |
		A4XX_TEX_SAMP_0_WRAP_R(tex_clamp(cso->wrap_r));

	so->texsamp1 =
//		COND(miplinear, A4XX_TEX_SAMP_1_MIPFILTER_LINEAR_FAR) |
		COND(!cso->normalized_coords, A4XX_TEX_SAMP_1_UNNORM_COORDS);

	if (cso->min_mip_filter != PIPE_TEX_MIPFILTER_NONE) {
		so->texsamp0 |= A4XX_TEX_SAMP_0_LOD_BIAS(cso->lod_bias);
		so->texsamp1 |=
			A4XX_TEX_SAMP_1_MIN_LOD(cso->min_lod) |
			A4XX_TEX_SAMP_1_MAX_LOD(cso->max_lod);
	}

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

	return so;
}
Exemple #5
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;
}
Exemple #6
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;
}