aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2017-11-18 10:44:38 +0100
committerChristian Gmeiner <[email protected]>2017-11-30 07:33:11 +0100
commit260a5e2a1a2490a7f147ed3e04021924cd0fe7cf (patch)
tree817cb4540413008593a7a1a7860aa26c64ea402c /src
parent9d1f8805b02bd15bc596de77f56837d83144689f (diff)
etnaviv: GC7000: Factor out incompatible texture handling logic
This will be shared with the texture descriptor path. Signed-off-by: Wladimir J. van der Laan <[email protected]> Reviewed-by: Christian Gmeiner <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_texture.c42
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_texture.h5
2 files changed, 31 insertions, 16 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c b/src/gallium/drivers/etnaviv/etnaviv_texture.c
index 295f7eb676c..ad0ea162054 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c
@@ -226,23 +226,10 @@ etna_resource_sampler_compatible(struct etna_resource *res)
return true;
}
-static struct pipe_sampler_view *
-etna_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
- const struct pipe_sampler_view *so)
+struct etna_resource *
+etna_texture_handle_incompatible(struct pipe_context *pctx, struct pipe_resource *prsc)
{
- struct etna_sampler_view *sv = CALLOC_STRUCT(etna_sampler_view);
struct etna_resource *res = etna_resource(prsc);
- struct etna_context *ctx = etna_context(pctx);
- const uint32_t format = translate_texture_format(so->format);
- const bool ext = !!(format & EXT_FORMAT);
- const bool astc = !!(format & ASTC_FORMAT);
- const uint32_t swiz = get_texture_swiz(so->format, so->swizzle_r,
- so->swizzle_g, so->swizzle_b,
- so->swizzle_a);
-
- if (!sv)
- return NULL;
-
if (!etna_resource_sampler_compatible(res)) {
/* The original resource is not compatible with the sampler.
* Allocate an appropriately tiled texture. */
@@ -257,11 +244,34 @@ etna_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
}
if (!res->texture) {
- free(sv);
return NULL;
}
res = etna_resource(res->texture);
}
+ return res;
+}
+
+static struct pipe_sampler_view *
+etna_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
+ const struct pipe_sampler_view *so)
+{
+ struct etna_sampler_view *sv = CALLOC_STRUCT(etna_sampler_view);
+ struct etna_context *ctx = etna_context(pctx);
+ const uint32_t format = translate_texture_format(so->format);
+ const bool ext = !!(format & EXT_FORMAT);
+ const bool astc = !!(format & ASTC_FORMAT);
+ const uint32_t swiz = get_texture_swiz(so->format, so->swizzle_r,
+ so->swizzle_g, so->swizzle_b,
+ so->swizzle_a);
+
+ if (!sv)
+ return NULL;
+
+ struct etna_resource *res = etna_texture_handle_incompatible(pctx, prsc);
+ if (!res) {
+ free(sv);
+ return NULL;
+ }
sv->base = *so;
pipe_reference_init(&sv->base.reference, 1);
diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.h b/src/gallium/drivers/etnaviv/etnaviv_texture.h
index 304373303cd..ec50bca3210 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_texture.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_texture.h
@@ -78,4 +78,9 @@ etna_sampler_view(struct pipe_sampler_view *view)
void
etna_texture_init(struct pipe_context *pctx);
+/* If the original resource is not compatible with the sampler. Allocate
+ * an appropriately tiled texture. */
+struct etna_resource *
+etna_texture_handle_incompatible(struct pipe_context *pctx, struct pipe_resource *prsc);
+
#endif