summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi/si_state.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2015-02-01 14:38:48 +0100
committerMarek Olšák <[email protected]>2015-02-04 14:34:13 +0100
commit9af943c32e93ae7fd86f0c00dfd5b0e4c4e2430f (patch)
tree4b1511ff0fddaa119f0046c06700c120b7c1347d /src/gallium/drivers/radeonsi/si_state.c
parent70e4243f073ec20d5f6d895cf17f6e49bf2867b1 (diff)
radeonsi: add support for sampler views where resource = NULL
The hardware obeys swizzles even if the resource is NULL. This will be used by set_polygon_stipple. Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_state.c')
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c15
1 files changed, 13 insertions, 2 deletions
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);