/* fragment shader */
ctx->fs[TGSI_WRITEMASK_XYZW] =
- util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
+ util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D,
+ TGSI_INTERPOLATE_LINEAR);
ctx->vbuf = NULL;
/* init vertex data that doesn't change */
if (ctx->fs[writemask] == NULL)
ctx->fs[writemask] =
util_make_fragment_tex_shader_writemask(pipe, TGSI_TEXTURE_2D,
+ TGSI_INTERPOLATE_LINEAR,
writemask);
/* shaders */
return ctx->fs_col[num_cbufs];
}
+/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */
+static unsigned
+pipe_tex_to_tgsi_tex(unsigned pipe_tex_target)
+{
+ switch (pipe_tex_target) {
+ case PIPE_TEXTURE_1D:
+ return TGSI_TEXTURE_1D;
+ case PIPE_TEXTURE_2D:
+ return TGSI_TEXTURE_2D;
+ case PIPE_TEXTURE_3D:
+ return TGSI_TEXTURE_3D;
+ case PIPE_TEXTURE_CUBE:
+ return TGSI_TEXTURE_CUBE;
+ default:
+ assert(0 && "unexpected texture target");
+ return TGSI_TEXTURE_UNKNOWN;
+ }
+}
+
+
static INLINE
void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx,
unsigned tex_target)
/* Create the fragment shader on-demand. */
if (!ctx->fs_texfetch_col[tex_target]) {
- switch (tex_target) {
- case PIPE_TEXTURE_2D:
- ctx->fs_texfetch_col[PIPE_TEXTURE_2D] =
- util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
- break;
- case PIPE_TEXTURE_3D:
- ctx->fs_texfetch_col[PIPE_TEXTURE_3D] =
- util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_3D);
- break;
- case PIPE_TEXTURE_CUBE:
- ctx->fs_texfetch_col[PIPE_TEXTURE_CUBE] =
- util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE);
- break;
- case PIPE_TEXTURE_1D:
- default:
- ctx->fs_texfetch_col[PIPE_TEXTURE_1D] =
- util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_1D);
- tex_target = PIPE_TEXTURE_1D; /* for the default case */
- }
+ unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+
+ ctx->fs_texfetch_col[tex_target] =
+ util_make_fragment_tex_shader(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR);
}
return ctx->fs_texfetch_col[tex_target];
/* Create the fragment shader on-demand. */
if (!ctx->fs_texfetch_depth[tex_target]) {
- switch (tex_target) {
- case PIPE_TEXTURE_2D:
- ctx->fs_texfetch_depth[PIPE_TEXTURE_2D] =
- util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_2D);
- break;
- case PIPE_TEXTURE_3D:
- ctx->fs_texfetch_depth[PIPE_TEXTURE_3D] =
- util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_3D);
- break;
- case PIPE_TEXTURE_CUBE:
- ctx->fs_texfetch_depth[PIPE_TEXTURE_CUBE] =
- util_make_fragment_tex_shader_writedepth(pipe,TGSI_TEXTURE_CUBE);
- break;
- case PIPE_TEXTURE_1D:
- default:
- ctx->fs_texfetch_depth[PIPE_TEXTURE_1D] =
- util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_1D);
- tex_target = PIPE_TEXTURE_1D; /* for the default case */
- }
+ unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target);
+
+ ctx->fs_texfetch_depth[tex_target] =
+ util_make_fragment_tex_shader_writedepth(pipe, tgsi_tex,
+ TGSI_INTERPOLATE_LINEAR);
}
return ctx->fs_texfetch_depth[tex_target];
}
/* fragment shader */
- ctx->fs2d = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
- ctx->fsCube = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE);
+ ctx->fs2d = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D,
+ TGSI_INTERPOLATE_LINEAR);
+ ctx->fsCube = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE,
+ TGSI_INTERPOLATE_LINEAR);
/* vertex data that doesn't change */
for (i = 0; i < 4; i++) {
* MOV OUT[0], IMM[0] // (if writemask != 0xf)
* TEX OUT[0].writemask, IN[0], SAMP[0], 2D;
* END;
+ *
+ * \param tex_target one of PIPE_TEXTURE_x
+ * \parma interp_mode either TGSI_INTERPOLATE_LINEAR or PERSPECTIVE
+ * \param writemask mask of TGSI_WRITEMASK_x
*/
void *
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
unsigned tex_target,
+ unsigned interp_mode,
unsigned writemask )
{
struct ureg_program *ureg;
struct ureg_src tex;
struct ureg_dst out;
+ assert(interp_mode == TGSI_INTERPOLATE_LINEAR ||
+ interp_mode == TGSI_INTERPOLATE_PERSPECTIVE);
+
ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
if (ureg == NULL)
return NULL;
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
- TGSI_INTERPOLATE_PERSPECTIVE );
+ interp_mode );
out = ureg_DECL_output( ureg,
TGSI_SEMANTIC_COLOR,
* \param tex_target one of PIPE_TEXTURE_x
*/
void *
-util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target )
+util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
+ unsigned interp_mode)
{
return util_make_fragment_tex_shader_writemask( pipe,
tex_target,
+ interp_mode,
TGSI_WRITEMASK_XYZW );
}
*/
void *
util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
- unsigned tex_target)
+ unsigned tex_target,
+ unsigned interp_mode)
{
struct ureg_program *ureg;
struct ureg_src sampler;
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
- TGSI_INTERPOLATE_PERSPECTIVE );
+ interp_mode );
out = ureg_DECL_output( ureg,
TGSI_SEMANTIC_COLOR,
extern void *
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
unsigned tex_target,
+ unsigned interp_mode,
unsigned writemask);
extern void *
-util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target);
+util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
+ unsigned interp_mode);
extern void *
util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
- unsigned tex_target);
+ unsigned tex_target,
+ unsigned interp_mode);
extern void *
{
struct pipe_context *pipe = ctx->pipe;
/* fragment shader */
- ctx->fs = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
+ ctx->fs = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D,
+ TGSI_INTERPOLATE_LINEAR);
}
static struct pipe_resource *