示例#1
0
static void
writer_decode_clip_viewport(const struct ilo_builder *builder,
                            enum ilo_builder_writer_type which,
                            const struct ilo_builder_item *item)
{
   const unsigned state_size = sizeof(uint32_t) * 4;
   const unsigned count = item->size / state_size;
   unsigned offset = item->offset;
   unsigned i;

   for (i = 0; i < count; i++) {
      uint32_t dw;

      dw = writer_dw(builder, which, offset, 0, "CLIP VP%d", i);
      ilo_printf("xmin = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 1, "CLIP VP%d", i);
      ilo_printf("xmax = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 2, "CLIP VP%d", i);
      ilo_printf("ymin = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 3, "CLIP VP%d", i);
      ilo_printf("ymax = %f\n", uif(dw));

      offset += state_size;
   }
}
示例#2
0
static void
writer_decode_color_calc(const struct ilo_builder *builder,
                         enum ilo_builder_writer_type which,
                         const struct ilo_builder_item *item)
{
   uint32_t dw;

   dw = writer_dw(builder, which, item->offset, 0, "CC");
   ilo_printf("alpha test format %s, round disable %d, "
              "stencil ref %d, bf stencil ref %d\n",
	      GEN_EXTRACT(dw, GEN6_CC_DW0_ALPHATEST) ? "FLOAT32" : "UNORM8",
	      (bool) (dw & GEN6_CC_DW0_ROUND_DISABLE_DISABLE),
	      GEN_EXTRACT(dw, GEN6_CC_DW0_STENCIL0_REF),
	      GEN_EXTRACT(dw, GEN6_CC_DW0_STENCIL1_REF));

   writer_dw(builder, which, item->offset, 1, "CC\n");

   dw = writer_dw(builder, which, item->offset, 2, "CC");
   ilo_printf("constant red %f\n", uif(dw));

   dw = writer_dw(builder, which, item->offset, 3, "CC");
   ilo_printf("constant green %f\n", uif(dw));

   dw = writer_dw(builder, which, item->offset, 4, "CC");
   ilo_printf("constant blue %f\n", uif(dw));

   dw = writer_dw(builder, which, item->offset, 5, "CC");
   ilo_printf("constant alpha %f\n", uif(dw));
}
static void
dump_VC4_PACKET_CLIPPER_XY_SCALING(void *cl, uint32_t offset, uint32_t hw_offset)
{
        uint32_t *scale = cl + offset;

        fprintf(stderr, "0x%08x 0x%08x:      %f, %f (%f, %f, 0x%08x, 0x%08x)\n",
                offset, hw_offset,
                uif(scale[0]) / 16.0, uif(scale[1]) / 16.0,
                uif(scale[0]), uif(scale[1]),
                scale[0], scale[1]);
}
static void
dump_VC4_PACKET_CLIPPER_Z_SCALING(void *cl, uint32_t offset, uint32_t hw_offset)
{
        uint32_t *translate = cl + offset;
        uint32_t *scale = cl + offset + 8;

        fprintf(stderr, "0x%08x 0x%08x:      %f, %f (0x%08x, 0x%08x)\n",
                offset, hw_offset,
                uif(translate[0]), uif(translate[1]),
                translate[0], translate[1]);

        fprintf(stderr, "0x%08x 0x%08x:      %f, %f (0x%08x, 0x%08x)\n",
                offset + 8, hw_offset + 8,
                uif(scale[0]), uif(scale[1]),
                scale[0], scale[1]);
}
示例#5
0
static void
writer_decode_sf_clip_viewport_gen7(const struct ilo_builder *builder,
                                    enum ilo_builder_writer_type which,
                                    const struct ilo_builder_item *item)
{
   const unsigned state_size = sizeof(uint32_t) * 16;
   const unsigned count = item->size / state_size;
   unsigned offset = item->offset;
   unsigned i;

   for (i = 0; i < count; i++) {
      uint32_t dw;

      dw = writer_dw(builder, which, offset, 0, "SF_CLIP VP%d", i);
      ilo_printf("m00 = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 1, "SF_CLIP VP%d", i);
      ilo_printf("m11 = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 2, "SF_CLIP VP%d", i);
      ilo_printf("m22 = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 3, "SF_CLIP VP%d", i);
      ilo_printf("m30 = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 4, "SF_CLIP VP%d", i);
      ilo_printf("m31 = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 5, "SF_CLIP VP%d", i);
      ilo_printf("m32 = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 8, "SF_CLIP VP%d", i);
      ilo_printf("guardband xmin = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 9, "SF_CLIP VP%d", i);
      ilo_printf("guardband xmax = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 10, "SF_CLIP VP%d", i);
      ilo_printf("guardband ymin = %f\n", uif(dw));

      dw = writer_dw(builder, which, offset, 11, "SF_CLIP VP%d", i);
      ilo_printf("guardband ymax = %f\n", uif(dw));

      offset += state_size;
   }
}
示例#6
0
文件: vc4_cl_dump.c 项目: xranby/mesa
static void
dump_float(void *cl, uint32_t offset, uint32_t hw_offset)
{
    void *f = cl + offset;

    fprintf(stderr, "0x%08x 0x%08x:      %f (0x%08x)\n",
            offset, hw_offset, uif(*(uint32_t *)f), *(uint32_t *)f);
}
示例#7
0
static void
writer_decode_blob(const struct ilo_builder *builder,
                   enum ilo_builder_writer_type which,
                   const struct ilo_builder_item *item)
{
   const unsigned state_size = sizeof(uint32_t);
   const unsigned count = item->size / state_size;
   unsigned offset = item->offset;
   unsigned i;

   for (i = 0; i < count; i += 4) {
      const uint32_t *dw = writer_pointer(builder, which, offset);

      writer_dw(builder, which, offset, 0, "BLOB%d", i / 4);

      switch (count - i) {
      case 1:
         ilo_printf("(%10.4f, %10c, %10c, %10c) "
                    "(0x%08x, %10c, %10c, %10c)\n",
                    uif(dw[0]), 'X', 'X', 'X',
                        dw[0],  'X', 'X', 'X');
         break;
      case 2:
         ilo_printf("(%10.4f, %10.4f, %10c, %10c) "
                    "(0x%08x, 0x%08x, %10c, %10c)\n",
                    uif(dw[0]), uif(dw[1]), 'X', 'X',
                        dw[0],      dw[1],  'X', 'X');
         break;
      case 3:
         ilo_printf("(%10.4f, %10.4f, %10.4f, %10c) "
                    "(0x%08x, 0x%08x, 0x%08x, %10c)\n",
                    uif(dw[0]), uif(dw[1]), uif(dw[2]), 'X',
                        dw[0],      dw[1],      dw[2],  'X');
         break;
      default:
         ilo_printf("(%10.4f, %10.4f, %10.4f, %10.4f) "
                    "(0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
                    uif(dw[0]), uif(dw[1]), uif(dw[2]), uif(dw[3]),
                        dw[0],      dw[1],      dw[2],      dw[3]);
         break;
      }

      offset += state_size * 4;
   }
}
示例#8
0
static void
writer_decode_blob(const struct ilo_builder *builder,
                   enum ilo_builder_writer_type which,
                   const struct ilo_builder_item *item)
{
   const unsigned state_size = sizeof(uint32_t) * 4;
   const unsigned count = item->size / state_size;
   unsigned offset = item->offset;
   unsigned i;

   for (i = 0; i < count; i++) {
      const uint32_t *dw = writer_pointer(builder, which, offset);

      writer_dw(builder, which, offset, 0, "BLOB%d", i);
      /* output a single line for all four DWords */
      ilo_printf("(% f, % f, % f, % f) (0x%08x, 0x%08x, 0x%08x, 0x%08x)\n",
               uif(dw[0]), uif(dw[1]), uif(dw[2]), uif(dw[3]),
               dw[0], dw[1], dw[2], dw[3]);

      offset += state_size;
   }
}
示例#9
0
文件: si_debug.c 项目: dumbbell/mesa
static void print_value(FILE *file, uint32_t value, int bits)
{
	/* Guess if it's int or float */
	if (value <= (1 << 15))
		fprintf(file, "%u\n", value);
	else {
		float f = uif(value);

		if (fabs(f) < 100000 && f*10 == floor(f*10))
			fprintf(file, "%.1ff\n", f);
		else
			/* Don't print more leading zeros than there are bits. */
			fprintf(file, "0x%0*x\n", bits / 4, value);
	}
}
示例#10
0
static void
print_load_imm(uint64_t inst)
{
        uint32_t imm = inst;
        uint32_t waddr_add = QPU_GET_FIELD(inst, QPU_WADDR_ADD);
        uint32_t waddr_mul = QPU_GET_FIELD(inst, QPU_WADDR_MUL);
        uint32_t cond_add = QPU_GET_FIELD(inst, QPU_COND_ADD);
        uint32_t cond_mul = QPU_GET_FIELD(inst, QPU_COND_MUL);

        fprintf(stderr, "load_imm ");
        print_alu_dst(inst, false);
        fprintf(stderr, "%s, ", (waddr_add != QPU_W_NOP ?
                                 DESC(qpu_condflags, cond_add) : ""));
        print_alu_dst(inst, true);
        fprintf(stderr, "%s, ", (waddr_mul != QPU_W_NOP ?
                                 DESC(qpu_condflags, cond_mul) : ""));
        fprintf(stderr, "0x%08x (%f)", imm, uif(imm));
}
示例#11
0
static void
print_load_imm(uint64_t inst)
{
        uint32_t imm = inst;
        uint32_t waddr_add = QPU_GET_FIELD(inst, QPU_WADDR_ADD);
        uint32_t waddr_mul = QPU_GET_FIELD(inst, QPU_WADDR_MUL);
        uint32_t cond_add = QPU_GET_FIELD(inst, QPU_COND_ADD);
        uint32_t cond_mul = QPU_GET_FIELD(inst, QPU_COND_MUL);

        fprintf(stderr, "load_imm ");

        print_alu_dst(inst, false);
        if (waddr_add != QPU_W_NOP)
                vc4_qpu_disasm_cond(stderr, cond_add);
        fprintf(stderr, ", ");

        print_alu_dst(inst, true);
        if (waddr_mul != QPU_W_NOP)
                vc4_qpu_disasm_cond(stderr, cond_mul);
        fprintf(stderr, ", ");

        fprintf(stderr, "0x%08x (%f)", imm, uif(imm));
}
static void
write_texture_p1(struct vc5_job *job,
                 struct vc5_cl_out **uniforms,
                 struct vc5_texture_stateobj *texstate,
                 uint32_t unit)
{
        struct pipe_sampler_view *psview = texstate->textures[unit];
        struct vc5_sampler_view *sview = vc5_sampler_view(psview);

        struct V3D33_TEXTURE_UNIFORM_PARAMETER_1_CFG_MODE1 unpacked = {
                .texture_state_record_base_address = texstate->texture_state[unit],
        };

        uint32_t packed;
        V3D33_TEXTURE_UNIFORM_PARAMETER_1_CFG_MODE1_pack(&job->indirect,
                                                         (uint8_t *)&packed,
                                                         &unpacked);

        cl_aligned_u32(uniforms, packed | sview->p1);
}

struct vc5_cl_reloc
vc5_write_uniforms(struct vc5_context *vc5, struct vc5_compiled_shader *shader,
                   struct vc5_constbuf_stateobj *cb,
                   struct vc5_texture_stateobj *texstate)
{
        struct v3d_uniform_list *uinfo = &shader->prog_data.base->uniforms;
        struct vc5_job *job = vc5->job;
        const uint32_t *gallium_uniforms = cb->cb[0].user_buffer;
        struct vc5_bo *ubo = vc5_upload_ubo(vc5, shader, gallium_uniforms);

        /* We always need to return some space for uniforms, because the HW
         * will be prefetching, even if we don't read any in the program.
         */
        vc5_cl_ensure_space(&job->indirect, MAX2(uinfo->count, 1) * 4, 4);

        struct vc5_cl_reloc uniform_stream = cl_get_address(&job->indirect);
        vc5_bo_reference(uniform_stream.bo);

        struct vc5_cl_out *uniforms =
                cl_start(&job->indirect);

        for (int i = 0; i < uinfo->count; i++) {

                switch (uinfo->contents[i]) {
                case QUNIFORM_CONSTANT:
                        cl_aligned_u32(&uniforms, uinfo->data[i]);
                        break;
                case QUNIFORM_UNIFORM:
                        cl_aligned_u32(&uniforms,
                                       gallium_uniforms[uinfo->data[i]]);
                        break;
                case QUNIFORM_VIEWPORT_X_SCALE:
                        cl_aligned_f(&uniforms, vc5->viewport.scale[0] * 256.0f);
                        break;
                case QUNIFORM_VIEWPORT_Y_SCALE:
                        cl_aligned_f(&uniforms, vc5->viewport.scale[1] * 256.0f);
                        break;

                case QUNIFORM_VIEWPORT_Z_OFFSET:
                        cl_aligned_f(&uniforms, vc5->viewport.translate[2]);
                        break;
                case QUNIFORM_VIEWPORT_Z_SCALE:
                        cl_aligned_f(&uniforms, vc5->viewport.scale[2]);
                        break;

                case QUNIFORM_USER_CLIP_PLANE:
                        cl_aligned_f(&uniforms,
                                     vc5->clip.ucp[uinfo->data[i] / 4][uinfo->data[i] % 4]);
                        break;

                case QUNIFORM_TEXTURE_CONFIG_P1:
                        write_texture_p1(job, &uniforms, texstate,
                                         uinfo->data[i]);
                        break;

#if 0
                case QUNIFORM_TEXTURE_FIRST_LEVEL:
                        write_texture_first_level(job, &uniforms, texstate,
                                                  uinfo->data[i]);
                        break;
#endif

                case QUNIFORM_TEXRECT_SCALE_X:
                case QUNIFORM_TEXRECT_SCALE_Y:
                        cl_aligned_u32(&uniforms,
                                       get_texrect_scale(texstate,
                                                         uinfo->contents[i],
                                                         uinfo->data[i]));
                        break;

                case QUNIFORM_TEXTURE_WIDTH:
                case QUNIFORM_TEXTURE_HEIGHT:
                case QUNIFORM_TEXTURE_DEPTH:
                case QUNIFORM_TEXTURE_ARRAY_SIZE:
                case QUNIFORM_TEXTURE_LEVELS:
                        cl_aligned_u32(&uniforms,
                                       get_texture_size(texstate,
                                                        uinfo->contents[i],
                                                        uinfo->data[i]));
                        break;

                case QUNIFORM_STENCIL:
                        cl_aligned_u32(&uniforms,
                                       vc5->zsa->stencil_uniforms[uinfo->data[i]] |
                                       (uinfo->data[i] <= 1 ?
                                        (vc5->stencil_ref.ref_value[uinfo->data[i]] << 8) :
                                        0));
                        break;

                case QUNIFORM_ALPHA_REF:
                        cl_aligned_f(&uniforms,
                                     vc5->zsa->base.alpha.ref_value);
                        break;

                case QUNIFORM_SAMPLE_MASK:
                        cl_aligned_u32(&uniforms, vc5->sample_mask);
                        break;

                case QUNIFORM_UBO_ADDR:
                        if (uinfo->data[i] == 0) {
                                cl_aligned_reloc(&job->indirect, &uniforms,
                                                 ubo, 0);
                        } else {
                                int ubo_index = uinfo->data[i];
                                struct vc5_resource *rsc =
                                        vc5_resource(cb->cb[ubo_index].buffer);

                                cl_aligned_reloc(&job->indirect, &uniforms,
                                                 rsc->bo,
                                                 cb->cb[ubo_index].buffer_offset);
                        }
                        break;

                case QUNIFORM_TEXTURE_FIRST_LEVEL:
                case QUNIFORM_TEXTURE_MSAA_ADDR:
                case QUNIFORM_TEXTURE_BORDER_COLOR:
                        /* XXX */
                        break;

                default:
                        assert(quniform_contents_is_texture_p0(uinfo->contents[i]));

                        write_texture_p0(job, &uniforms, texstate,
                                         uinfo->contents[i] -
                                         QUNIFORM_TEXTURE_CONFIG_P0_0,
                                         uinfo->data[i]);
                        break;

                }
#if 0
                uint32_t written_val = *((uint32_t *)uniforms - 1);
                fprintf(stderr, "shader %p[%d]: 0x%08x / 0x%08x (%f)\n",
                        shader, i, __gen_address_offset(&uniform_stream) + i * 4,
                        written_val, uif(written_val));
#endif
        }

        cl_end(&job->indirect, uniforms);

        vc5_bo_unreference(&ubo);

        return uniform_stream;
}

void
vc5_set_shader_uniform_dirty_flags(struct vc5_compiled_shader *shader)
{
        uint32_t dirty = 0;

        for (int i = 0; i < shader->prog_data.base->uniforms.count; i++) {
                switch (shader->prog_data.base->uniforms.contents[i]) {
                case QUNIFORM_CONSTANT:
                        break;
                case QUNIFORM_UNIFORM:
                case QUNIFORM_UBO_ADDR:
                        dirty |= VC5_DIRTY_CONSTBUF;
                        break;

                case QUNIFORM_VIEWPORT_X_SCALE:
                case QUNIFORM_VIEWPORT_Y_SCALE:
                case QUNIFORM_VIEWPORT_Z_OFFSET:
                case QUNIFORM_VIEWPORT_Z_SCALE:
                        dirty |= VC5_DIRTY_VIEWPORT;
                        break;

                case QUNIFORM_USER_CLIP_PLANE:
                        dirty |= VC5_DIRTY_CLIP;
                        break;

                case QUNIFORM_TEXTURE_CONFIG_P1:
                case QUNIFORM_TEXTURE_BORDER_COLOR:
                case QUNIFORM_TEXTURE_FIRST_LEVEL:
                case QUNIFORM_TEXTURE_MSAA_ADDR:
                case QUNIFORM_TEXRECT_SCALE_X:
                case QUNIFORM_TEXRECT_SCALE_Y:
                case QUNIFORM_TEXTURE_WIDTH:
                case QUNIFORM_TEXTURE_HEIGHT:
                case QUNIFORM_TEXTURE_DEPTH:
                case QUNIFORM_TEXTURE_ARRAY_SIZE:
                case QUNIFORM_TEXTURE_LEVELS:
                        /* We could flag this on just the stage we're
                         * compiling for, but it's not passed in.
                         */
                        dirty |= VC5_DIRTY_FRAGTEX | VC5_DIRTY_VERTTEX;
                        break;

                case QUNIFORM_STENCIL:
                case QUNIFORM_ALPHA_REF:
                        dirty |= VC5_DIRTY_ZSA;
                        break;

                case QUNIFORM_SAMPLE_MASK:
                        dirty |= VC5_DIRTY_SAMPLE_MASK;
                        break;

                default:
                        assert(quniform_contents_is_texture_p0(shader->prog_data.base->uniforms.contents[i]));
                        dirty |= VC5_DIRTY_FRAGTEX | VC5_DIRTY_VERTTEX;
                        break;
                }
        }

        shader->uniform_dirty_bits = dirty;
}