diff options
author | Marek Olšák <[email protected]> | 2016-01-07 19:48:56 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-01-08 20:07:16 +0100 |
commit | 69f43c2cc903d5973bab2515be51465c9e8f9f9e (patch) | |
tree | 85a9ae0393dc6546a8695590f9da8b7ddf0e23c8 /src/gallium/auxiliary/util | |
parent | 8a13ce14fd4e29e4e74322c1a3d548960f7f9bc6 (diff) |
util/pstipple: allow fragment shader POSITION to be a system value
Reviewed-by: Edward O'Callaghan <[email protected]
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_pstipple.c | 30 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_pstipple.h | 3 |
2 files changed, 26 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/util/u_pstipple.c b/src/gallium/auxiliary/util/u_pstipple.c index 0bb46ff8dd1..08dec13846d 100644 --- a/src/gallium/auxiliary/util/u_pstipple.c +++ b/src/gallium/auxiliary/util/u_pstipple.c @@ -177,6 +177,7 @@ struct pstip_transform_context { struct tgsi_shader_info info; uint tempsUsed; /**< bitmask */ int wincoordInput; + unsigned wincoordFile; int maxInput; uint samplersUsed; /**< bitfield of samplers used */ int freeSampler; /** an available sampler for the pstipple */ @@ -206,7 +207,7 @@ pstip_transform_decl(struct tgsi_transform_context *ctx, pctx->samplersUsed |= 1 << i; } } - else if (decl->Declaration.File == TGSI_FILE_INPUT) { + else if (decl->Declaration.File == pctx->wincoordFile) { pctx->maxInput = MAX2(pctx->maxInput, (int) decl->Range.Last); if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION) pctx->wincoordInput = (int) decl->Range.First; @@ -275,10 +276,22 @@ pstip_transform_prolog(struct tgsi_transform_context *ctx) wincoordInput = pctx->wincoordInput; if (pctx->wincoordInput < 0) { + struct tgsi_full_declaration decl; + + decl = tgsi_default_full_declaration(); /* declare new position input reg */ - tgsi_transform_input_decl(ctx, wincoordInput, - TGSI_SEMANTIC_POSITION, 1, - TGSI_INTERPOLATE_LINEAR); + decl.Declaration.File = pctx->wincoordFile; + decl.Declaration.Semantic = 1; + decl.Semantic.Name = TGSI_SEMANTIC_POSITION; + decl.Range.First = + decl.Range.Last = wincoordInput; + + if (pctx->wincoordFile == TGSI_FILE_INPUT) { + decl.Declaration.Interpolate = 1; + decl.Interp.Interpolate = TGSI_INTERPOLATE_LINEAR; + } + + ctx->emit_declaration(ctx, &decl); } sampIdx = pctx->hasFixedUnit ? pctx->fixedUnit : pctx->freeSampler; @@ -327,7 +340,7 @@ pstip_transform_prolog(struct tgsi_transform_context *ctx) tgsi_transform_op2_inst(ctx, TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, texTemp, TGSI_WRITEMASK_XYZW, - TGSI_FILE_INPUT, wincoordInput, + pctx->wincoordFile, wincoordInput, TGSI_FILE_IMMEDIATE, pctx->numImmed); /* TEX texTemp, texTemp, sampler; */ @@ -351,11 +364,15 @@ pstip_transform_prolog(struct tgsi_transform_context *ctx) * will be used to sample the stipple texture; * if NULL, the fixed unit is used * \param fixedUnit fixed texture unit used for the stipple texture + * \param wincoordFile TGSI_FILE_INPUT or TGSI_FILE_SYSTEM_VALUE, + * depending on which one is supported by the driver + * for TGSI_SEMANTIC_POSITION in the fragment shader */ struct tgsi_token * util_pstipple_create_fragment_shader(const struct tgsi_token *tokens, unsigned *samplerUnitOut, - unsigned fixedUnit) + unsigned fixedUnit, + unsigned wincoordFile) { struct pstip_transform_context transform; const uint newLen = tgsi_num_tokens(tokens) + NUM_NEW_TOKENS; @@ -370,6 +387,7 @@ util_pstipple_create_fragment_shader(const struct tgsi_token *tokens, */ memset(&transform, 0, sizeof(transform)); transform.wincoordInput = -1; + transform.wincoordFile = wincoordFile; transform.maxInput = -1; transform.coordOrigin = TGSI_FS_COORD_ORIGIN_UPPER_LEFT; transform.hasFixedUnit = !samplerUnitOut; diff --git a/src/gallium/auxiliary/util/u_pstipple.h b/src/gallium/auxiliary/util/u_pstipple.h index 249c58be95f..ef8396f4318 100644 --- a/src/gallium/auxiliary/util/u_pstipple.h +++ b/src/gallium/auxiliary/util/u_pstipple.h @@ -50,7 +50,8 @@ util_pstipple_create_sampler(struct pipe_context *pipe); struct tgsi_token * util_pstipple_create_fragment_shader(const struct tgsi_token *tokens, unsigned *samplerUnitOut, - unsigned fixed_unit); + unsigned fixed_unit, + unsigned wincoordFile); #endif |