diff options
author | Rob Clark <[email protected]> | 2014-11-05 12:08:04 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2014-11-14 13:59:54 -0500 |
commit | 82103206feb10b3cfc581fe5ea88673e4d53b744 (patch) | |
tree | 0d60fa72f114c1465542ce9dcac01868cfe3679f /src/gallium/drivers/freedreno/ir3/ir3_shader.h | |
parent | e091c08089f43e0a4f4edf8e5e24f2617364f044 (diff) |
freedreno/ir3: move some helpers
Split out a few helpers from fd3_program so we don't have to duplicate
for fd4_program.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/ir3/ir3_shader.h')
-rw-r--r-- | src/gallium/drivers/freedreno/ir3/ir3_shader.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h index a26dab2e8e1..3d51603fcfb 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h @@ -214,4 +214,62 @@ void ir3_shader_destroy(struct ir3_shader *shader); struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key); +/* + * Helper/util: + */ + +static inline int +ir3_find_output(const struct ir3_shader_variant *so, ir3_semantic semantic) +{ + int j; + + for (j = 0; j < so->outputs_count; j++) + if (so->outputs[j].semantic == semantic) + return j; + + /* it seems optional to have a OUT.BCOLOR[n] for each OUT.COLOR[n] + * in the vertex shader.. but the fragment shader doesn't know this + * so it will always have both IN.COLOR[n] and IN.BCOLOR[n]. So + * at link time if there is no matching OUT.BCOLOR[n], we must map + * OUT.COLOR[n] to IN.BCOLOR[n]. And visa versa if there is only + * a OUT.BCOLOR[n] but no matching OUT.COLOR[n] + */ + if (sem2name(semantic) == TGSI_SEMANTIC_BCOLOR) { + unsigned idx = sem2idx(semantic); + semantic = ir3_semantic_name(TGSI_SEMANTIC_COLOR, idx); + } else if (sem2name(semantic) == TGSI_SEMANTIC_COLOR) { + unsigned idx = sem2idx(semantic); + semantic = ir3_semantic_name(TGSI_SEMANTIC_BCOLOR, idx); + } else { + return 0; + } + + for (j = 0; j < so->outputs_count; j++) + if (so->outputs[j].semantic == semantic) + return j; + + debug_assert(0); + + return 0; +} + +static inline int +ir3_next_varying(const struct ir3_shader_variant *so, int i) +{ + while (++i < so->inputs_count) + if (so->inputs[i].compmask && so->inputs[i].bary) + break; + return i; +} + +static inline uint32_t +ir3_find_output_regid(const struct ir3_shader_variant *so, ir3_semantic semantic) +{ + int j; + for (j = 0; j < so->outputs_count; j++) + if (so->outputs[j].semantic == semantic) + return so->outputs[j].regid; + return regid(63, 0); +} + #endif /* IR3_SHADER_H_ */ |