llvmpipe_prepare_geometry_sampling(lp,
lp->num_sampler_views[PIPE_SHADER_GEOMETRY],
lp->sampler_views[PIPE_SHADER_GEOMETRY]);
+
+ llvmpipe_prepare_vertex_images(lp,
+ lp->num_images[PIPE_SHADER_VERTEX],
+ lp->images[PIPE_SHADER_VERTEX]);
+ llvmpipe_prepare_geometry_images(lp,
+ lp->num_images[PIPE_SHADER_GEOMETRY],
+ lp->images[PIPE_SHADER_GEOMETRY]);
if (lp->gs && lp->gs->no_tokens) {
/* we have an empty geometry shader with stream output, so
attach the stream output info to the current vertex shader */
prepare_shader_sampling(lp, num, views, PIPE_SHADER_GEOMETRY);
}
+static void
+prepare_shader_images(
+ struct llvmpipe_context *lp,
+ unsigned num,
+ struct pipe_image_view *views,
+ enum pipe_shader_type shader_type)
+{
+
+ unsigned i;
+ uint32_t row_stride;
+ uint32_t img_stride;
+ const void *addr;
+
+ assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
+ if (!num)
+ return;
+
+ for (i = 0; i < num; i++) {
+ struct pipe_image_view *view = i < num ? &views[i] : NULL;
+
+ if (view) {
+ struct pipe_resource *img = view->resource;
+ struct llvmpipe_resource *lp_img = llvmpipe_resource(img);
+ if (!img)
+ continue;
+
+ unsigned width0 = img->width0;
+ unsigned num_layers = img->depth0;
+
+ if (!lp_img->dt) {
+ /* regular texture - setup array of mipmap level offsets */
+ struct pipe_resource *res = view->resource;
+
+ if (llvmpipe_resource_is_texture(res)) {
+ uint32_t mip_offset = lp_img->mip_offsets[view->u.tex.level];
+ addr = lp_img->tex_data;
+
+ if (img->target == PIPE_TEXTURE_1D_ARRAY ||
+ img->target == PIPE_TEXTURE_2D_ARRAY ||
+ img->target == PIPE_TEXTURE_3D ||
+ img->target == PIPE_TEXTURE_CUBE ||
+ img->target == PIPE_TEXTURE_CUBE_ARRAY) {
+ num_layers = view->u.tex.last_layer - view->u.tex.first_layer + 1;
+ assert(view->u.tex.first_layer <= view->u.tex.last_layer);
+ mip_offset += view->u.tex.first_layer * lp_img->img_stride[view->u.tex.level];
+ }
+
+ row_stride = lp_img->row_stride[view->u.tex.level];
+ img_stride = lp_img->img_stride[view->u.tex.level];
+ addr = (uint8_t *)addr + mip_offset;
+ }
+ else {
+ unsigned view_blocksize = util_format_get_blocksize(view->format);
+ addr = lp_img->data;
+ /* probably don't really need to fill that out */
+ row_stride = 0;
+ img_stride = 0;
+
+ /* everything specified in number of elements here. */
+ width0 = view->u.buf.size / view_blocksize;
+ addr = (uint8_t *)addr + view->u.buf.offset;
+ assert(view->u.buf.offset + view->u.buf.size <= res->width0);
+ }
+ }
+ else {
+ /* display target texture/surface */
+ /*
+ * XXX: Where should this be unmapped?
+ */
+ struct llvmpipe_screen *screen = llvmpipe_screen(img->screen);
+ struct sw_winsys *winsys = screen->winsys;
+ addr = winsys->displaytarget_map(winsys, lp_img->dt,
+ PIPE_TRANSFER_READ);
+ row_stride = lp_img->row_stride[0];
+ img_stride = lp_img->img_stride[0];
+ assert(addr);
+ }
+ draw_set_mapped_image(lp->draw,
+ shader_type,
+ i,
+ width0, img->height0, num_layers,
+ addr,
+ row_stride, img_stride);
+ }
+ }
+}
+
+
+/**
+ * Called whenever we're about to draw (no dirty flag, FIXME?).
+ */
+void
+llvmpipe_prepare_vertex_images(struct llvmpipe_context *lp,
+ unsigned num,
+ struct pipe_image_view *views)
+{
+ prepare_shader_images(lp, num, views, PIPE_SHADER_VERTEX);
+}
+
+
+/**
+ * Called whenever we're about to draw (no dirty flag, FIXME?).
+ */
+void
+llvmpipe_prepare_geometry_images(struct llvmpipe_context *lp,
+ unsigned num,
+ struct pipe_image_view *views)
+{
+ prepare_shader_images(lp, num, views, PIPE_SHADER_GEOMETRY);
+}
void
llvmpipe_init_sampler_funcs(struct llvmpipe_context *llvmpipe)