[Mesa-dev] [PATCH 4/5] llvmpipe: improve setup shader names (for debugging)
Jose Fonseca
jfonseca at vmware.com
Tue May 13 05:59:53 PDT 2014
----- Original Message -----
> From: Roland Scheidegger <sroland at vmware.com>
>
> The setup shaders were composed of both a fs shader number and a variant
> number. But since they aren't tied to a particular fragment shader, the
> former was a fixed zero while the latter was also always zero because
> it was never assigned. So, similar to what the fs code does, use a ever
> increasing number to give it a more catchy name (unlike fragment shaders
> though where this number is for each explicitly created shader, we just use
> it for the implicitly created variants).
> And while here, fix whitespace a bit.
> ---
> src/gallium/drivers/llvmpipe/lp_state_setup.c | 78
> ++++++++++++++-------------
> 1 file changed, 40 insertions(+), 38 deletions(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c
> b/src/gallium/drivers/llvmpipe/lp_state_setup.c
> index edd1923..baf77c1 100644
> --- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
> +++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
> @@ -50,6 +50,10 @@
> #include "lp_state_setup.h"
>
>
> +/** Setup shader number (for debugging) */
> +static unsigned setup_no = 0;
> +
> +
> /* currently organized to interpolate full float[4] attributes even
> * when some elements are unused. Later, can pack vertex data more
> * closely.
> @@ -82,26 +86,26 @@ struct lp_setup_args
>
> static void
> store_coef(struct gallivm_state *gallivm,
> - struct lp_setup_args *args,
> - unsigned slot,
> - LLVMValueRef a0,
> - LLVMValueRef dadx,
> - LLVMValueRef dady)
> + struct lp_setup_args *args,
> + unsigned slot,
> + LLVMValueRef a0,
> + LLVMValueRef dadx,
> + LLVMValueRef dady)
> {
> LLVMBuilderRef builder = gallivm->builder;
> LLVMValueRef idx = lp_build_const_int32(gallivm, slot);
>
> LLVMBuildStore(builder,
> - a0,
> - LLVMBuildGEP(builder, args->a0, &idx, 1, ""));
> + a0,
> + LLVMBuildGEP(builder, args->a0, &idx, 1, ""));
>
> LLVMBuildStore(builder,
> - dadx,
> - LLVMBuildGEP(builder, args->dadx, &idx, 1, ""));
> + dadx,
> + LLVMBuildGEP(builder, args->dadx, &idx, 1, ""));
>
> LLVMBuildStore(builder,
> - dady,
> - LLVMBuildGEP(builder, args->dady, &idx, 1, ""));
> + dady,
> + LLVMBuildGEP(builder, args->dady, &idx, 1, ""));
> }
>
>
> @@ -728,6 +732,7 @@ generate_setup_variant(struct lp_setup_variant_key *key,
> }
>
> builder = gallivm->builder;
> + variant->no = setup_no++;
>
> if (LP_DEBUG & DEBUG_COUNTERS) {
> t0 = os_time_get();
> @@ -736,8 +741,8 @@ generate_setup_variant(struct lp_setup_variant_key *key,
> memcpy(&variant->key, key, key->size);
> variant->list_item_global.base = variant;
>
> - util_snprintf(func_name, sizeof(func_name), "fs%u_setup%u",
> - 0, variant->no);
> + util_snprintf(func_name, sizeof(func_name), "setup_variant_%u",
> + variant->no);
>
> /* Currently always deal with full 4-wide vertex attributes from
> * the vertices.
> @@ -808,7 +813,7 @@ generate_setup_variant(struct lp_setup_variant_key *key,
> LP_COUNT_ADD(llvm_compile_time, t1 - t0);
> LP_COUNT_ADD(nr_llvm_compiles, 1);
> }
> -
> +
> return variant;
>
> fail:
> @@ -823,7 +828,7 @@ fail:
> }
> FREE(variant);
> }
> -
> +
> return NULL;
> }
>
> @@ -831,13 +836,13 @@ fail:
>
> static void
> lp_make_setup_variant_key(struct llvmpipe_context *lp,
> - struct lp_setup_variant_key *key)
> + struct lp_setup_variant_key *key)
> {
> struct lp_fragment_shader *fs = lp->fs;
> unsigned i;
>
> assert(sizeof key->inputs[0] == sizeof(uint));
> -
> +
> key->num_inputs = fs->info.base.num_inputs;
> key->flatshade_first = lp->rasterizer->flatshade_first;
> key->pixel_center_half = lp->rasterizer->half_pixel_center;
> @@ -875,9 +880,9 @@ lp_make_setup_variant_key(struct llvmpipe_context *lp,
> for (i = 0; i < key->num_inputs; i++) {
> if (key->inputs[i].interp == LP_INTERP_COLOR) {
> if (lp->rasterizer->flatshade)
> - key->inputs[i].interp = LP_INTERP_CONSTANT;
> - else
> - key->inputs[i].interp = LP_INTERP_PERSPECTIVE;
> + key->inputs[i].interp = LP_INTERP_CONSTANT;
> + else
> + key->inputs[i].interp = LP_INTERP_PERSPECTIVE;
> }
> }
>
> @@ -886,11 +891,11 @@ lp_make_setup_variant_key(struct llvmpipe_context *lp,
>
> static void
> remove_setup_variant(struct llvmpipe_context *lp,
> - struct lp_setup_variant *variant)
> + struct lp_setup_variant *variant)
> {
> if (gallivm_debug & GALLIVM_DEBUG_IR) {
> debug_printf("llvmpipe: del setup_variant #%u total %u\n",
> - variant->no, lp->nr_setup_variants);
> + variant->no, lp->nr_setup_variants);
> }
>
> if (variant->function) {
> @@ -992,10 +997,10 @@ lp_delete_setup_variants(struct llvmpipe_context *lp)
> }
>
> void
> -lp_dump_setup_coef( const struct lp_setup_variant_key *key,
> - const float (*sa0)[4],
> - const float (*sdadx)[4],
> - const float (*sdady)[4])
> +lp_dump_setup_coef(const struct lp_setup_variant_key *key,
> + const float (*sa0)[4],
> + const float (*sdadx)[4],
> + const float (*sdady)[4])
> {
> int i, slot;
>
> @@ -1005,23 +1010,20 @@ lp_dump_setup_coef( const struct lp_setup_variant_key
> *key,
> float dady = sdady[0][i];
>
> debug_printf("POS.%c: a0 = %f, dadx = %f, dady = %f\n",
> - "xyzw"[i],
> - a0, dadx, dady);
> + "xyzw"[i], a0, dadx, dady);
> }
>
> for (slot = 0; slot < key->num_inputs; slot++) {
> unsigned usage_mask = key->inputs[slot].usage_mask;
> for (i = 0; i < TGSI_NUM_CHANNELS; i++) {
> - if (usage_mask & (1 << i)) {
> - float a0 = sa0 [1 + slot][i];
> - float dadx = sdadx[1 + slot][i];
> - float dady = sdady[1 + slot][i];
> -
> - debug_printf("IN[%u].%c: a0 = %f, dadx = %f, dady = %f\n",
> - slot,
> - "xyzw"[i],
> - a0, dadx, dady);
> - }
> + if (usage_mask & (1 << i)) {
> + float a0 = sa0 [1 + slot][i];
> + float dadx = sdadx[1 + slot][i];
> + float dady = sdady[1 + slot][i];
> +
> + debug_printf("IN[%u].%c: a0 = %f, dadx = %f, dady = %f\n",
> + slot, "xyzw"[i], a0, dadx, dady);
> + }
> }
> }
> }
> --
> 1.9.1
>
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
More information about the mesa-dev
mailing list