<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 12, 2019 at 1:33 PM Lucas Stach <<a href="mailto:l.stach@pengutronix.de">l.stach@pengutronix.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If the driver provides native support for YUV textures we can skip<br>
adding additional samplers and re-writing the shaders.<br>
<br>
Signed-off-by: Lucas Stach <<a href="mailto:l.stach@pengutronix.de" target="_blank">l.stach@pengutronix.de</a>><br>
---<br>
src/mesa/state_tracker/st_atom_sampler.c | 6 ++++++<br>
src/mesa/state_tracker/st_atom_texture.c | 6 ++++++<br>
src/mesa/state_tracker/st_program.h | 6 ++++++<br>
src/mesa/state_tracker/st_sampler_view.c | 21 +++++++++++++--------<br>
4 files changed, 31 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c<br>
index 27e4da315817..9def70c9432a 100644<br>
--- a/src/mesa/state_tracker/st_atom_sampler.c<br>
+++ b/src/mesa/state_tracker/st_atom_sampler.c<br>
@@ -303,10 +303,16 @@ update_shader_samplers(struct st_context *st,<br>
struct st_texture_object *stObj =<br>
st_get_texture_object(st->ctx, prog, unit);<br>
struct pipe_sampler_state *sampler = samplers + unit;<br>
+ struct pipe_screen *pscreen = st->pipe->screen;<br>
<br>
if (!stObj)<br>
continue;<br>
<br>
+ if (pscreen->is_format_supported(pscreen, st_get_view_format(stObj),<br>
+ PIPE_TEXTURE_2D, 0, 0,<br>
+ PIPE_BIND_SAMPLER_VIEW))<br>
+ continue;<br></blockquote><div><br></div><div>Can you call is_format_supported at texture initialization? is_format_supported can be expensive.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
switch (st_get_view_format(stObj)) {<br>
case PIPE_FORMAT_NV12:<br>
/* we need one additional sampler: */<br>
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c<br>
index ce7755f0c588..df84a472e722 100644<br>
--- a/src/mesa/state_tracker/st_atom_texture.c<br>
+++ b/src/mesa/state_tracker/st_atom_texture.c<br>
@@ -174,11 +174,17 @@ update_textures(struct st_context *st,<br>
GLuint extra = 0;<br>
struct st_texture_object *stObj =<br>
st_get_texture_object(st->ctx, prog, unit);<br>
+ struct pipe_screen *pscreen = st->pipe->screen;<br>
struct pipe_sampler_view tmpl;<br>
<br>
if (!stObj)<br>
continue;<br>
<br>
+ if (pscreen->is_format_supported(pscreen, st_get_view_format(stObj),<br>
+ sampler_views[unit]->target, 0, 0,<br>
+ PIPE_BIND_SAMPLER_VIEW))<br></blockquote><div><br></div><div>Same here.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ continue;<br>
+<br>
/* use original view as template: */<br>
tmpl = *sampler_views[unit];<br>
<br>
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h<br>
index f67ea5eb2087..bc5f3e3d9642 100644<br>
--- a/src/mesa/state_tracker/st_program.h<br>
+++ b/src/mesa/state_tracker/st_program.h<br>
@@ -67,6 +67,12 @@ st_get_external_sampler_key(struct st_context *st, struct gl_program *prog)<br>
unsigned unit = u_bit_scan(&mask);<br>
struct st_texture_object *stObj =<br>
st_get_texture_object(st->ctx, prog, unit);<br>
+ struct pipe_screen *pscreen = st->pipe->screen;<br>
+<br>
+ if (pscreen->is_format_supported(pscreen, st_get_view_format(stObj),<br>
+ PIPE_TEXTURE_2D, 0, 0,<br>
+ PIPE_BIND_SAMPLER_VIEW))<br></blockquote><div><br></div><div>Same here.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ continue;<br>
<br>
switch (st_get_view_format(stObj)) {<br>
case PIPE_FORMAT_NV12:<br>
diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c<br>
index eb97f2bb6b7d..30dfa20af6b5 100644<br>
--- a/src/mesa/state_tracker/st_sampler_view.c<br>
+++ b/src/mesa/state_tracker/st_sampler_view.c<br>
@@ -471,6 +471,7 @@ get_sampler_view_format(struct st_context *st,<br>
const struct st_texture_object *stObj,<br>
bool srgb_skip_decode)<br>
{<br>
+ struct pipe_screen *pscreen = st->pipe->screen;<br>
enum pipe_format format;<br>
<br>
GLenum baseFormat = _mesa_base_tex_image(&stObj->base)->_BaseFormat;<br>
@@ -489,15 +490,19 @@ get_sampler_view_format(struct st_context *st,<br>
if (srgb_skip_decode)<br>
format = util_format_linear(format);<br>
<br>
- /* Use R8_UNORM for video formats */<br>
- switch (format) {<br>
- case PIPE_FORMAT_NV12:<br>
- case PIPE_FORMAT_IYUV:<br>
- format = PIPE_FORMAT_R8_UNORM;<br>
- break;<br>
- default:<br>
- break;<br>
+ if (!pscreen->is_format_supported(pscreen, format, PIPE_TEXTURE_2D, 0, 0,<br>
+ PIPE_BIND_SAMPLER_VIEW)) {<br></blockquote><div><br></div><div>Same here.<br></div><div> </div><div>Marek</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ /* Use R8_UNORM for video formats */<br>
+ switch (format) {<br>
+ case PIPE_FORMAT_NV12:<br>
+ case PIPE_FORMAT_IYUV:<br>
+ format = PIPE_FORMAT_R8_UNORM;<br>
+ break;<br>
+ default:<br>
+ break;<br>
+ }<br>
}<br>
+<br>
return format;<br>
}<br>
<br>
-- <br>
2.20.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div></div>