#endif /* V3D_VERSION >= 40 */
}
+void
+v3dX(create_texture_shader_state_bo)(struct v3d_context *v3d,
+ struct v3d_sampler_view *so)
+{
+ struct pipe_resource *prsc = so->texture;
+ const struct pipe_sampler_view *cso = &so->base;
+ struct v3d_screen *screen = v3d->screen;
+
+ void *map;
+
+#if V3D_VERSION >= 40
+ v3d_bo_unreference(&so->bo);
+ so->bo = v3d_bo_alloc(v3d->screen,
+ cl_packet_length(TEXTURE_SHADER_STATE), "sampler");
+ map = v3d_bo_map(so->bo);
+#else /* V3D_VERSION < 40 */
+ STATIC_ASSERT(sizeof(so->texture_shader_state) >=
+ cl_packet_length(TEXTURE_SHADER_STATE));
+ map = &so->texture_shader_state;
+#endif
+
+ v3dx_pack(map, TEXTURE_SHADER_STATE, tex) {
+ v3d_setup_texture_shader_state(&tex, prsc,
+ cso->u.tex.first_level,
+ cso->u.tex.last_level,
+ cso->u.tex.first_layer,
+ cso->u.tex.last_layer);
+
+ tex.srgb = util_format_is_srgb(cso->format);
+
+#if V3D_VERSION >= 40
+ tex.swizzle_r = translate_swizzle(so->swizzle[0]);
+ tex.swizzle_g = translate_swizzle(so->swizzle[1]);
+ tex.swizzle_b = translate_swizzle(so->swizzle[2]);
+ tex.swizzle_a = translate_swizzle(so->swizzle[3]);
+#endif
+
+ if (prsc->nr_samples > 1 && V3D_VERSION < 40) {
+ /* Using texture views to reinterpret formats on our
+ * MSAA textures won't work, because we don't lay out
+ * the bits in memory as it's expected -- for example,
+ * RGBA8 and RGB10_A2 are compatible in the
+ * ARB_texture_view spec, but in HW we lay them out as
+ * 32bpp RGBA8 and 64bpp RGBA16F. Just assert for now
+ * to catch failures.
+ *
+ * We explicitly allow remapping S8Z24 to RGBA8888 for
+ * v3d_blit.c's stencil blits.
+ */
+ assert((util_format_linear(cso->format) ==
+ util_format_linear(prsc->format)) ||
+ (prsc->format == PIPE_FORMAT_S8_UINT_Z24_UNORM &&
+ cso->format == PIPE_FORMAT_R8G8B8A8_UNORM));
+ uint32_t output_image_format =
+ v3d_get_rt_format(&screen->devinfo, cso->format);
+ uint32_t internal_type;
+ uint32_t internal_bpp;
+ v3d_get_internal_type_bpp_for_output_format(&screen->devinfo,
+ output_image_format,
+ &internal_type,
+ &internal_bpp);
+
+ switch (internal_type) {
+ case V3D_INTERNAL_TYPE_8:
+ tex.texture_type = TEXTURE_DATA_FORMAT_RGBA8;
+ break;
+ case V3D_INTERNAL_TYPE_16F:
+ tex.texture_type = TEXTURE_DATA_FORMAT_RGBA16F;
+ break;
+ default:
+ unreachable("Bad MSAA texture type");
+ }
+
+ /* sRGB was stored in the tile buffer as linear and
+ * would have been encoded to sRGB on resolved tile
+ * buffer store. Note that this means we would need
+ * shader code if we wanted to read an MSAA sRGB
+ * texture without sRGB decode.
+ */
+ tex.srgb = false;
+ } else {
+ tex.texture_type = v3d_get_tex_format(&screen->devinfo,
+ cso->format);
+ }
+ };
+}
+
static struct pipe_sampler_view *
v3d_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
const struct pipe_sampler_view *cso)
pipe_resource_reference(&so->texture, prsc);
}
- void *map;
-#if V3D_VERSION >= 40
- so->bo = v3d_bo_alloc(v3d->screen,
- cl_packet_length(TEXTURE_SHADER_STATE), "sampler");
- map = v3d_bo_map(so->bo);
-#else /* V3D_VERSION < 40 */
- STATIC_ASSERT(sizeof(so->texture_shader_state) >=
- cl_packet_length(TEXTURE_SHADER_STATE));
- map = &so->texture_shader_state;
-#endif
-
- v3dx_pack(map, TEXTURE_SHADER_STATE, tex) {
- v3d_setup_texture_shader_state(&tex, prsc,
- cso->u.tex.first_level,
- cso->u.tex.last_level,
- cso->u.tex.first_layer,
- cso->u.tex.last_layer);
-
- tex.srgb = util_format_is_srgb(cso->format);
-
-#if V3D_VERSION >= 40
- tex.swizzle_r = translate_swizzle(so->swizzle[0]);
- tex.swizzle_g = translate_swizzle(so->swizzle[1]);
- tex.swizzle_b = translate_swizzle(so->swizzle[2]);
- tex.swizzle_a = translate_swizzle(so->swizzle[3]);
-#endif
-
- if (prsc->nr_samples > 1 && V3D_VERSION < 40) {
- /* Using texture views to reinterpret formats on our
- * MSAA textures won't work, because we don't lay out
- * the bits in memory as it's expected -- for example,
- * RGBA8 and RGB10_A2 are compatible in the
- * ARB_texture_view spec, but in HW we lay them out as
- * 32bpp RGBA8 and 64bpp RGBA16F. Just assert for now
- * to catch failures.
- *
- * We explicitly allow remapping S8Z24 to RGBA8888 for
- * v3d_blit.c's stencil blits.
- */
- assert((util_format_linear(cso->format) ==
- util_format_linear(prsc->format)) ||
- (prsc->format == PIPE_FORMAT_S8_UINT_Z24_UNORM &&
- cso->format == PIPE_FORMAT_R8G8B8A8_UNORM));
- uint32_t output_image_format =
- v3d_get_rt_format(&screen->devinfo, cso->format);
- uint32_t internal_type;
- uint32_t internal_bpp;
- v3d_get_internal_type_bpp_for_output_format(&screen->devinfo,
- output_image_format,
- &internal_type,
- &internal_bpp);
-
- switch (internal_type) {
- case V3D_INTERNAL_TYPE_8:
- tex.texture_type = TEXTURE_DATA_FORMAT_RGBA8;
- break;
- case V3D_INTERNAL_TYPE_16F:
- tex.texture_type = TEXTURE_DATA_FORMAT_RGBA16F;
- break;
- default:
- unreachable("Bad MSAA texture type");
- }
-
- /* sRGB was stored in the tile buffer as linear and
- * would have been encoded to sRGB on resolved tile
- * buffer store. Note that this means we would need
- * shader code if we wanted to read an MSAA sRGB
- * texture without sRGB decode.
- */
- tex.srgb = false;
- } else {
- tex.texture_type = v3d_get_tex_format(&screen->devinfo,
- cso->format);
- }
- };
+ v3d_create_texture_shader_state_bo(v3d, so);
return &so->base;
}