static struct pipe_sampler_view * fd2_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, const struct pipe_sampler_view *cso) { struct fd2_pipe_sampler_view *so = CALLOC_STRUCT(fd2_pipe_sampler_view); struct fd_resource *rsc = fd_resource(prsc); if (!so) return NULL; so->base = *cso; pipe_reference(NULL, &prsc->reference); so->base.texture = prsc; so->base.reference.count = 1; so->base.context = pctx; so->tex_resource = rsc; so->fmt = fd2_pipe2surface(cso->format); so->tex0 = A2XX_SQ_TEX_0_PITCH(rsc->pitch); so->tex2 = A2XX_SQ_TEX_2_HEIGHT(prsc->height0 - 1) | A2XX_SQ_TEX_2_WIDTH(prsc->width0 - 1); so->tex3 = fd2_tex_swiz(cso->format, cso->swizzle_r, cso->swizzle_g, cso->swizzle_b, cso->swizzle_a); return &so->base; }
static void patch_vtx_fetches(struct fd_context *ctx, struct fd2_shader_stateobj *so, struct fd_vertex_stateobj *vtx) { unsigned i; assert(so->num_vfetch_instrs == vtx->num_elements); /* update vtx fetch instructions: */ for (i = 0; i < so->num_vfetch_instrs; i++) { struct ir2_instruction *instr = so->vfetch_instrs[i]; struct pipe_vertex_element *elem = &vtx->pipe[i]; struct pipe_vertex_buffer *vb = &ctx->vertexbuf.vb[elem->vertex_buffer_index]; enum pipe_format format = elem->src_format; const struct util_format_description *desc = util_format_description(format); unsigned j; /* Find the first non-VOID channel. */ for (j = 0; j < 4; j++) if (desc->channel[j].type != UTIL_FORMAT_TYPE_VOID) break; /* CI/CIS can probably be set in compiler instead: */ instr->fetch.const_idx = 20 + (i / 3); instr->fetch.const_idx_sel = i % 3; instr->fetch.fmt = fd2_pipe2surface(format); instr->fetch.is_normalized = desc->channel[j].normalized; instr->fetch.is_signed = desc->channel[j].type == UTIL_FORMAT_TYPE_SIGNED; instr->fetch.stride = vb->stride ? : 1; instr->fetch.offset = elem->src_offset; for (j = 0; j < 4; j++) instr->regs[0]->swizzle[j] = "xyzw01__"[desc->swizzle[j]]; assert(instr->fetch.fmt != ~0); DBG("vtx[%d]: %s (%d), ci=%d, cis=%d, id=%d, swizzle=%s, " "stride=%d, offset=%d", i, util_format_name(format), instr->fetch.fmt, instr->fetch.const_idx, instr->fetch.const_idx_sel, elem->instance_divisor, instr->regs[0]->swizzle, instr->fetch.stride, instr->fetch.offset); } /* trigger re-assemble: */ so->info.sizedwords = 0; }