From: Kenneth Graunke Date: Tue, 17 Jul 2018 07:17:55 +0000 (-0700) Subject: iris: fix sampler views of TBOs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c41d4cf3f41871203ea68ba519ddf9c321ccf10;p=mesa.git iris: fix sampler views of TBOs we can't read levels/layers, they're invalid for PIPE_BUFFER --- diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 1b7abc9f82e..c4ee638eb24 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -1025,14 +1025,17 @@ iris_create_sampler_view(struct pipe_context *ctx, pipe_reference_init(&isv->pipe.reference, 1); pipe_resource_reference(&isv->pipe.texture, tex); - /* XXX: do we need brw_get_texture_swizzle hacks here? */ + void *map = upload_state(ice->state.surface_uploader, &isv->surface_state, + 4 * GENX(RENDER_SURFACE_STATE_length), 64); + if (!unlikely(map)) + return NULL; + struct iris_bo *state_bo = iris_resource_bo(isv->surface_state.res); + isv->surface_state.offset += iris_bo_offset_from_base_address(state_bo); + + /* XXX: do we need brw_get_texture_swizzle hacks here? */ isv->view = (struct isl_view) { .format = iris_isl_format_for_pipe_format(tmpl->format), - .base_level = tmpl->u.tex.first_level, - .levels = tmpl->u.tex.last_level - tmpl->u.tex.first_level + 1, - .base_array_layer = tmpl->u.tex.first_layer, - .array_len = tmpl->u.tex.last_layer - tmpl->u.tex.first_layer + 1, .swizzle = (struct isl_swizzle) { .r = pipe_swizzle_to_isl_channel(tmpl->swizzle_r), .g = pipe_swizzle_to_isl_channel(tmpl->swizzle_g), @@ -1043,20 +1046,30 @@ iris_create_sampler_view(struct pipe_context *ctx, (itex->surf.usage & ISL_SURF_USAGE_CUBE_BIT), }; - void *map = upload_state(ice->state.surface_uploader, &isv->surface_state, - 4 * GENX(RENDER_SURFACE_STATE_length), 64); - if (!unlikely(map)) - return NULL; - - struct iris_bo *state_bo = iris_resource_bo(isv->surface_state.res); - isv->surface_state.offset += iris_bo_offset_from_base_address(state_bo); - - isl_surf_fill_state(&screen->isl_dev, map, - .surf = &itex->surf, .view = &isv->view, - .mocs = MOCS_WB, - .address = itex->bo->gtt_offset); - // .aux_surf = - // .clear_color = clear_color, + if (tmpl->target != PIPE_BUFFER) { + isv->view.base_level = tmpl->u.tex.first_level; + isv->view.levels = tmpl->u.tex.last_level - tmpl->u.tex.first_level + 1; + isv->view.base_array_layer = tmpl->u.tex.first_layer; + isv->view.array_len = + tmpl->u.tex.last_layer - tmpl->u.tex.first_layer + 1; + + isl_surf_fill_state(&screen->isl_dev, map, + .surf = &itex->surf, .view = &isv->view, + .mocs = MOCS_WB, + .address = itex->bo->gtt_offset); + // .aux_surf = + // .clear_color = clear_color, + } else { + // XXX: what to do about isv->view? other drivers don't use it for bufs + isl_buffer_fill_state(&screen->isl_dev, map, + .address = itex->bo->gtt_offset + + tmpl->u.buf.offset, + // XXX: buffer_texture_range_size from i965? + .size_B = tmpl->u.buf.size, + .format = isv->view.format, + .stride_B = itex->surf.row_pitch_B, + .mocs = MOCS_WB); + } return &isv->pipe; }