shader: clean up TCS IO emit

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
macos/master
Gert Wollny 6 years ago committed by Dave Airlie
parent 6fb0c9d847
commit 7418567f0c
  1. 41
      src/vrend_shader.c

@ -4672,8 +4672,6 @@ static void emit_ios_geom(struct dump_ctx *ctx)
static void emit_ios_tcs(struct dump_ctx *ctx) static void emit_ios_tcs(struct dump_ctx *ctx)
{ {
uint32_t i; uint32_t i;
char postfix[8];
const char *prefix = "";
if (ctx_indirect_inputs(ctx)) { if (ctx_indirect_inputs(ctx)) {
const char *name_prefix = get_stage_input_name_prefix(ctx, ctx->prog_type); const char *name_prefix = get_stage_input_name_prefix(ctx, ctx->prog_type);
@ -4688,10 +4686,7 @@ static void emit_ios_tcs(struct dump_ctx *ctx)
for (i = 0; i < ctx->num_inputs; i++) { for (i = 0; i < ctx->num_inputs; i++) {
if (!ctx->inputs[i].glsl_predefined_no_emit) { if (!ctx->inputs[i].glsl_predefined_no_emit) {
if (ctx->inputs[i].name != TGSI_SEMANTIC_PATCH) { const char *postfix = (ctx->inputs[i].name != TGSI_SEMANTIC_PATCH) ? "[]" : "";
snprintf(postfix, 8, "[]");
} else
postfix[0] = 0;
emit_hdrf(ctx, "in vec4 %s%s;\n", ctx->inputs[i].glsl_name, postfix); emit_hdrf(ctx, "in vec4 %s%s;\n", ctx->inputs[i].glsl_name, postfix);
} }
} }
@ -4710,14 +4705,11 @@ static void emit_ios_tcs(struct dump_ctx *ctx)
for (i = 0; i < ctx->num_outputs; i++) { for (i = 0; i < ctx->num_outputs; i++) {
if (!ctx->outputs[i].glsl_predefined_no_emit) { if (!ctx->outputs[i].glsl_predefined_no_emit) {
prefix = "";
/* ugly leave spaces to patch interp in later */ /* ugly leave spaces to patch interp in later */
if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL) {
if (ctx->outputs[i].name == TGSI_SEMANTIC_PATCH) if (ctx->outputs[i].name == TGSI_SEMANTIC_PATCH)
emit_hdrf(ctx, "patch out vec4 %s;\n", ctx->outputs[i].glsl_name); emit_hdrf(ctx, "patch out vec4 %s;\n", ctx->outputs[i].glsl_name);
else else
emit_hdrf(ctx, "%sout vec4 %s[];\n", prefix, ctx->outputs[i].glsl_name); emit_hdrf(ctx, "out vec4 %s[];\n", ctx->outputs[i].glsl_name);
}
} else if (ctx->outputs[i].invariant || ctx->outputs[i].precise) { } else if (ctx->outputs[i].invariant || ctx->outputs[i].precise) {
emit_hdrf(ctx, "%s%s;\n", emit_hdrf(ctx, "%s%s;\n",
ctx->outputs[i].precise ? "precise " : ctx->outputs[i].precise ? "precise " :
@ -4726,10 +4718,9 @@ static void emit_ios_tcs(struct dump_ctx *ctx)
} }
} }
if (ctx->prog_type == TGSI_PROCESSOR_TESS_CTRL) {
if (ctx->num_in_clip_dist || ctx->key->prev_stage_pervertex_out) { if (ctx->num_in_clip_dist || ctx->key->prev_stage_pervertex_out) {
int clip_dist, cull_dist; int clip_dist, cull_dist;
char clip_var[64] = {}, cull_var[64] = {}; char clip_var[64] = "", cull_var[64] = "";
clip_dist = ctx->key->prev_stage_num_clip_out ? ctx->key->prev_stage_num_clip_out : ctx->num_in_clip_dist; clip_dist = ctx->key->prev_stage_num_clip_out ? ctx->key->prev_stage_num_clip_out : ctx->num_in_clip_dist;
cull_dist = ctx->key->prev_stage_num_cull_out; cull_dist = ctx->key->prev_stage_num_cull_out;
@ -4745,14 +4736,11 @@ static void emit_ios_tcs(struct dump_ctx *ctx)
emit_hdrf(ctx, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_PointSize;\n float gl_ClipDistance[%d];\n} gl_out[];\n", ctx->num_clip_dist ? ctx->num_clip_dist : 8); emit_hdrf(ctx, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_PointSize;\n float gl_ClipDistance[%d];\n} gl_out[];\n", ctx->num_clip_dist ? ctx->num_clip_dist : 8);
emit_hdr(ctx, "vec4 clip_dist_temp[2];\n"); emit_hdr(ctx, "vec4 clip_dist_temp[2];\n");
} }
}
} }
static void emit_ios_tes(struct dump_ctx *ctx) static void emit_ios_tes(struct dump_ctx *ctx)
{ {
uint32_t i; uint32_t i;
char postfix[8];
const char *prefix = "", *auxprefix = "";
if (ctx_indirect_inputs(ctx)) { if (ctx_indirect_inputs(ctx)) {
const char *name_prefix = get_stage_input_name_prefix(ctx, ctx->prog_type); const char *name_prefix = get_stage_input_name_prefix(ctx, ctx->prog_type);
@ -4763,7 +4751,6 @@ static void emit_ios_tes(struct dump_ctx *ctx)
emit_hdrf(ctx, "patch in vec4 %sp%d[%d];\n", name_prefix, ctx->patch_input_range.first, size); emit_hdrf(ctx, "patch in vec4 %sp%d[%d];\n", name_prefix, ctx->patch_input_range.first, size);
} }
if (ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL) {
if (ctx->generic_input_range.used) { if (ctx->generic_input_range.used) {
int size = ctx->generic_input_range.last - ctx->generic_input_range.first + 1; int size = ctx->generic_input_range.last - ctx->generic_input_range.first + 1;
if (size < ctx->key->num_indirect_generic_inputs) if (size < ctx->key->num_indirect_generic_inputs)
@ -4771,21 +4758,17 @@ static void emit_ios_tes(struct dump_ctx *ctx)
emit_hdrf(ctx, "in block { vec4 %s%d[%d]; } blk[];\n", name_prefix, ctx->generic_input_range.first, size); emit_hdrf(ctx, "in block { vec4 %s%d[%d]; } blk[];\n", name_prefix, ctx->generic_input_range.first, size);
} }
} }
}
for (i = 0; i < ctx->num_inputs; i++) { for (i = 0; i < ctx->num_inputs; i++) {
if (!ctx->inputs[i].glsl_predefined_no_emit) { if (!ctx->inputs[i].glsl_predefined_no_emit) {
prefix = ""; const char *prefix = "";
auxprefix = ""; const char *postfix = "";
if (ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL && ctx->inputs[i].name == TGSI_SEMANTIC_PATCH) if (ctx->inputs[i].name == TGSI_SEMANTIC_PATCH)
prefix = "patch "; prefix = "patch ";
else
if (ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL && ctx->inputs[i].name != TGSI_SEMANTIC_PATCH) { postfix = "[]";
snprintf(postfix, 8, "[]"); emit_hdrf(ctx, "%sin vec4 %s%s;\n", prefix, ctx->inputs[i].glsl_name, postfix);
} else
postfix[0] = 0;
emit_hdrf(ctx, "%s%sin vec4 %s%s;\n", prefix, auxprefix, ctx->inputs[i].glsl_name, postfix);
} }
} }
emit_hdrf(ctx, "layout(%s, %s, %s%s) in;\n", emit_hdrf(ctx, "layout(%s, %s, %s%s) in;\n",
@ -4796,13 +4779,13 @@ static void emit_ios_tes(struct dump_ctx *ctx)
for (i = 0; i < ctx->num_outputs; i++) { for (i = 0; i < ctx->num_outputs; i++) {
if (!ctx->outputs[i].glsl_predefined_no_emit) { if (!ctx->outputs[i].glsl_predefined_no_emit) {
const char *prefix = "";
if (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC || if (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC ||
ctx->outputs[i].name == TGSI_SEMANTIC_COLOR || ctx->outputs[i].name == TGSI_SEMANTIC_COLOR ||
ctx->outputs[i].name == TGSI_SEMANTIC_BCOLOR) { ctx->outputs[i].name == TGSI_SEMANTIC_BCOLOR) {
ctx->num_interps++; ctx->num_interps++;
prefix = INTERP_PREFIX; prefix = INTERP_PREFIX;
} else }
prefix = "";
/* ugly leave spaces to patch interp in later */ /* ugly leave spaces to patch interp in later */
emit_hdrf(ctx, "%s%s%s%s vec4 %s;\n", emit_hdrf(ctx, "%s%s%s%s vec4 %s;\n",

Loading…
Cancel
Save