/** * Helper function to set the fragment shaders. */ static inline void set_fragment_shader(struct blit_state *ctx, uint writemask, enum pipe_format format, enum pipe_texture_target pipe_tex) { enum tgsi_return_type stype; unsigned idx; if (util_format_is_pure_uint(format)) { stype = TGSI_RETURN_TYPE_UINT; idx = 0; } else if (util_format_is_pure_sint(format)) { stype = TGSI_RETURN_TYPE_SINT; idx = 1; } else { stype = TGSI_RETURN_TYPE_FLOAT; idx = 2; } if (!ctx->fs[pipe_tex][writemask][idx]) { unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex, 0); /* OpenGL does not allow blits from signed to unsigned integer * or vice versa. */ ctx->fs[pipe_tex][writemask][idx] = util_make_fragment_tex_shader_writemask(ctx->pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR, writemask, stype, stype); } cso_set_fragment_shader_handle(ctx->cso, ctx->fs[pipe_tex][writemask][idx]); }
/** * Make a simple fragment shader that sets the output color to a color * taken from a texture. * \param tex_target one of PIPE_TEXTURE_x */ void * 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 ); }
/** * Helper function to set the fragment shaders. */ static INLINE void set_fragment_shader(struct blit_state *ctx, uint writemask, enum pipe_texture_target pipe_tex) { if (!ctx->fs[pipe_tex][writemask]) { unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex, 0); ctx->fs[pipe_tex][writemask] = util_make_fragment_tex_shader_writemask(ctx->pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR, writemask); } cso_set_fragment_shader_handle(ctx->cso, ctx->fs[pipe_tex][writemask]); }
/** * Make a simple fragment shader that sets the output color to a color * taken from a texture. * \param tex_target one of PIPE_TEXTURE_x */ void * util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target, unsigned interp_mode, enum tgsi_return_type stype, enum tgsi_return_type dtype, bool load_level_zero, bool use_txf) { return util_make_fragment_tex_shader_writemask( pipe, tex_target, interp_mode, TGSI_WRITEMASK_XYZW, stype, dtype, load_level_zero, use_txf); }