summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2015-10-04 19:37:05 +1000
committerDave Airlie <airlied@redhat.com>2016-01-18 15:33:57 +1000
commit2dbe458bfe20ec5e5aa76a0fe503176e65942e03 (patch)
tree512f6f8a6cca69339e0bca297bab7b11aa323170
parent6487c8cb3a3fdb4881d30828ddf8a2d7b93f24e8 (diff)
WIP
-rw-r--r--src/vrend_shader.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 1934840..b778aa1 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -138,6 +138,7 @@ struct dump_ctx {
bool has_clipvertex_so;
bool has_viewport_idx;
bool uses_gpu_shader5;
+ bool write_mul_temp;
};
static inline const char *tgsi_proc_to_prefix(int shader_type)
@@ -812,6 +813,9 @@ static int prepare_so_movs(struct dump_ctx *ctx)
continue;
ctx->outputs[ctx->so->output[i].register_index].stream = ctx->so->output[i].stream;
+ if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY && ctx->so->output[i].stream)
+ ctx->uses_gpu_shader5 = true;
+
ctx->write_so_outputs[i] = false;
}
return 0;
@@ -1129,7 +1133,7 @@ static int translate_tex(struct dump_ctx *ctx,
sampler_index = 2;
ctx->uses_tg4 = true;
- if (inst->Texture.NumOffsets > 1 || is_shad)
+ if (inst->Texture.NumOffsets > 1 || is_shad || ctx->uses_sampler_rect)
ctx->uses_gpu_shader5 = true;
if (inst->Texture.NumOffsets == 1) {
if (inst->TexOffsets[0].File != TGSI_FILE_IMMEDIATE)
@@ -1985,6 +1989,40 @@ iter_instruction(struct tgsi_iterate_context *iter,
EMIT_BUF_WITH_RET(ctx, buf);
ctx->uses_gpu_shader5 = true;
break;
+ case TGSI_OPCODE_UMUL_HI:
+ snprintf(buf, 255, "umulExtended(%s, %s, %s, mul_temp);\n", srcs[0], srcs[1], dsts[0]);
+ EMIT_BUF_WITH_RET(ctx, buf);
+ ctx->uses_gpu_shader5 = true;
+ ctx->write_mul_temp = true;
+ break;
+ case TGSI_OPCODE_IMUL_HI:
+ snprintf(buf, 255, "imulExtended(%s, %s, %s, mul_temp);\n", srcs[0], srcs[1], dsts[0]);
+ EMIT_BUF_WITH_RET(ctx, buf);
+ ctx->uses_gpu_shader5 = true;
+ ctx->write_mul_temp = true;
+ break;
+
+ case TGSI_OPCODE_IBFE:
+ case TGSI_OPCODE_UBFE:
+ case TGSI_OPCODE_BFI:
+ case TGSI_OPCODE_BREV:
+ break;
+ case TGSI_OPCODE_POPC:
+ snprintf(buf, 255, "%s = bitCount(%s);\n", dsts[0], srcs[0]);
+ EMIT_BUF_WITH_RET(ctx, buf);
+ ctx->uses_gpu_shader5 = true;
+ break;
+ case TGSI_OPCODE_LSB:
+ snprintf(buf, 255, "%s = findLSB(%s);\n", dsts[0], srcs[0]);
+ EMIT_BUF_WITH_RET(ctx, buf);
+ ctx->uses_gpu_shader5 = true;
+ break;
+ case TGSI_OPCODE_IMSB:
+ case TGSI_OPCODE_UMSB:
+ snprintf(buf, 255, "%s = findMSB(%s);\n", dsts[0], srcs[0]);
+ EMIT_BUF_WITH_RET(ctx, buf);
+ ctx->uses_gpu_shader5 = true;
+ break;
default:
fprintf(stderr,"failed to convert opcode %d\n", inst->Instruction.Opcode);
break;
@@ -2262,6 +2300,11 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
STRCAT_WITH_RET(glsl_hdr, buf);
}
+ if (ctx->write_mul_temp) {
+ snprintf(buf, 255, "vec4 mul_temp;\n");
+ STRCAT_WITH_RET(glsl_hdr, buf);
+ }
+
for (i = 0; i < ctx->num_address; i++) {
snprintf(buf, 255, "int addr%d;\n", i);
STRCAT_WITH_RET(glsl_hdr, buf);