From: Zack Rusin Date: Fri, 28 Aug 2009 19:36:05 +0000 (-0400) Subject: st/xorg: normalize coords for the src operands in the vertex shader X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f1c0a4b2f4b0054a3371fcaf5121bf53ef29b756;p=mesa.git st/xorg: normalize coords for the src operands in the vertex shader --- diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 950c6828b09..142d8444e11 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -251,6 +251,14 @@ bind_shaders(struct exa_context *exa, int op, } +static void +bind_samplers(struct exa_context *exa, int op, + PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) +{ + +} + boolean xorg_composite_bind_state(struct exa_context *exa, int op, PicturePtr pSrcPicture, @@ -265,6 +273,7 @@ boolean xorg_composite_bind_state(struct exa_context *exa, bind_blend_state(exa, op, pSrcPicture, pMaskPicture); bind_rasterizer_state(exa); bind_shaders(exa, op, pSrcPicture, pMaskPicture); + bind_samplers(exa, op, pSrcPicture, pMaskPicture, pDstPicture); return FALSE; } diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index d561715fdec..b5288bde4fb 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -17,14 +17,28 @@ #include "cso_cache/cso_context.h" #include "cso_cache/cso_hash.h" +/* Vertex shader: + * IN[0] = src_pos + * IN[1] = mask_pos + * IN[2] = dst_pos + * CONST[0] = (2/dst_width, 2/dst_height, 1, 1) + * CONST[1] = (-1, -1, 0, 0) + * + * OUT[0] = src_pos + * OUT[1] = mask_pos + * OUT[2] = dst_pos + */ + /* Fragment shader: - * SAMP[0] = dst - * SAMP[1] = src - * SAMP[2] = mask - * IN[0] = pos dst - * IN[1] = pos src - * IN[2] = pos mask + * SAMP[0] = src + * SAMP[1] = mask + * SAMP[2] = dst + * IN[0] = pos src + * IN[1] = pos mask + * IN[2] = pos dst * CONST[0] = (0, 0, 0, 1) + * + * OUT[0] = color */ struct xorg_shaders { @@ -57,6 +71,19 @@ src_in_mask(struct ureg_program *ureg, ureg_scalar(mask, TGSI_SWIZZLE_W)); } +static struct ureg_src +vs_normalize_coords(struct ureg_program *ureg, struct ureg_src coords, + struct ureg_src const0, struct ureg_src const1) +{ + struct ureg_dst tmp = ureg_DECL_temporary(ureg); + struct ureg_src ret; + ureg_MUL(ureg, tmp, coords, const0); + ureg_ADD(ureg, tmp, ureg_src(tmp), const1); + ret = ureg_src(tmp); + ureg_release_temporary(ureg, tmp); + return ret; +} + static void * create_vs(struct pipe_context *pipe, unsigned vs_traits) @@ -64,21 +91,27 @@ create_vs(struct pipe_context *pipe, struct ureg_program *ureg; struct ureg_src src; struct ureg_dst dst; + struct ureg_src const0, const1; ureg = ureg_create(TGSI_PROCESSOR_VERTEX); if (ureg == NULL) return 0; + const0 = ureg_DECL_constant(ureg); + const1 = ureg_DECL_constant(ureg); + if ((vs_traits & VS_COMPOSITE)) { src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_POSITION, 1); - dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 1); + TGSI_SEMANTIC_POSITION, 0); + dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0); + src = vs_normalize_coords(ureg, src, + const0, const1); ureg_MOV(ureg, dst, src); } if ((vs_traits & VS_MASK)) { src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_POSITION, 2); - dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 2); + TGSI_SEMANTIC_POSITION, 1); + dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 1); ureg_MOV(ureg, dst, src); } @@ -101,32 +134,32 @@ create_fs(struct pipe_context *pipe, if (ureg == NULL) return 0; -#if 0 /* unused right now */ - dst_sampler = ureg_DECL_sampler(ureg); - dst_pos = ureg_DECL_fs_input(ureg, - TGSI_SEMANTIC_POSITION, - 0, - TGSI_INTERPOLATE_PERSPECTIVE); -#endif + out = ureg_DECL_output(ureg, + TGSI_SEMANTIC_COLOR, + 0); src_sampler = ureg_DECL_sampler(ureg); src_pos = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_POSITION, - 1, + 0, TGSI_INTERPOLATE_PERSPECTIVE); - out = ureg_DECL_output(ureg, - TGSI_SEMANTIC_COLOR, - 0); - if ((fs_traits & FS_MASK)) { mask_sampler = ureg_DECL_sampler(ureg); mask_pos = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_POSITION, - 2, + 1, TGSI_INTERPOLATE_PERSPECTIVE); } +#if 0 /* unused right now */ + dst_sampler = ureg_DECL_sampler(ureg); + dst_pos = ureg_DECL_fs_input(ureg, + TGSI_SEMANTIC_POSITION, + 2, + TGSI_INTERPOLATE_PERSPECTIVE); +#endif + if ((fs_traits & FS_MASK)) { ureg_TEX(ureg, ureg_dst(mask), TGSI_TEXTURE_2D, mask_pos, mask_sampler);