diff options
-rw-r--r-- | src/gallium/drivers/radeonsi/si_descriptors.c | 13 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.c | 15 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 811c1670f47..3452be3de92 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -374,6 +374,9 @@ static void si_sampler_views_begin_new_cs(struct si_context *sctx, struct si_sampler_view *rview = (struct si_sampler_view*)views->views[i]; + if (!rview->resource) + continue; + r600_context_bo_reloc(&sctx->b, &sctx->b.rings.gfx, rview->resource, RADEON_USAGE_READ, si_get_resource_ro_priority(rview->resource)); @@ -398,9 +401,11 @@ static void si_set_sampler_view(struct si_context *sctx, unsigned shader, struct si_sampler_view *rview = (struct si_sampler_view*)view; - r600_context_bo_reloc(&sctx->b, &sctx->b.rings.gfx, - rview->resource, RADEON_USAGE_READ, - si_get_resource_ro_priority(rview->resource)); + if (rview->resource) + r600_context_bo_reloc(&sctx->b, &sctx->b.rings.gfx, + rview->resource, RADEON_USAGE_READ, + si_get_resource_ro_priority(rview->resource)); + pipe_sampler_view_reference(&views->views[slot], view); views->desc_data[slot] = view_desc; @@ -441,7 +446,7 @@ static void si_set_sampler_views(struct pipe_context *ctx, si_set_sampler_view(sctx, shader, slot, views[i], rviews[i]->state); - if (views[i]->texture->target != PIPE_BUFFER) { + if (views[i]->texture && views[i]->texture->target != PIPE_BUFFER) { struct r600_texture *rtex = (struct r600_texture*)views[i]->texture; diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 85954b74ea1..2deee4516d9 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2246,9 +2246,20 @@ static struct pipe_sampler_view *si_create_sampler_view(struct pipe_context *ctx /* initialize base object */ view->base = *state; view->base.texture = NULL; - pipe_resource_reference(&view->base.texture, texture); view->base.reference.count = 1; view->base.context = ctx; + + /* NULL resource, obey swizzle (only ZERO and ONE make sense). */ + if (!texture) { + view->state[3] = S_008F1C_DST_SEL_X(si_map_swizzle(state->swizzle_r)) | + S_008F1C_DST_SEL_Y(si_map_swizzle(state->swizzle_g)) | + S_008F1C_DST_SEL_Z(si_map_swizzle(state->swizzle_b)) | + S_008F1C_DST_SEL_W(si_map_swizzle(state->swizzle_a)) | + S_008F1C_TYPE(V_008F1C_SQ_RSRC_IMG_1D); + return &view->base; + } + + pipe_resource_reference(&view->base.texture, texture); view->resource = &tmp->resource; /* Buffer resource. */ @@ -2484,7 +2495,7 @@ static void si_sampler_view_destroy(struct pipe_context *ctx, { struct si_sampler_view *view = (struct si_sampler_view *)state; - if (view->resource->b.b.target == PIPE_BUFFER) + if (view->resource && view->resource->b.b.target == PIPE_BUFFER) LIST_DELINIT(&view->list); pipe_resource_reference(&state->texture, NULL); |