<div dir="ltr"><div>I think the name PIPE_CAP_MULTISAMPLED_RENDER_TO_TEXTURE is slightly misleading, because it doesn't imply anything about the OpenGL ES behavior, which is that a texture is multisampled in the cache, but single-sampled in memory. This should be mentioned somewhere.<br></div><div><br></div><div>Marek</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 6, 2018 at 5:19 PM Kristian H. Kristensen <<a href="mailto:hoegsberg@gmail.com">hoegsberg@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This new pipe cap and the new nr_samples field in pipe_surface lets a<br>
state tracker bind a render target with a different sample count than<br>
the resource. This allows for implementing<br>
EXT_multisampled_render_to_texture and<br>
EXT_multisampled_render_to_texture2.<br>
<br>
Signed-off-by: Kristian H. Kristensen <<a href="mailto:hoegsberg@chromium.org" target="_blank">hoegsberg@chromium.org</a>><br>
---<br>
src/gallium/auxiliary/util/u_framebuffer.c | 10 ++++++++--<br>
src/gallium/docs/source/screen.rst | 3 +++<br>
src/gallium/include/pipe/p_defines.h | 1 +<br>
src/gallium/include/pipe/p_state.h | 6 ++++++<br>
4 files changed, 18 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c<br>
index 5bafddc726f..127623a7677 100644<br>
--- a/src/gallium/auxiliary/util/u_framebuffer.c<br>
+++ b/src/gallium/auxiliary/util/u_framebuffer.c<br>
@@ -229,13 +229,19 @@ util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb)<br>
if (!(fb->nr_cbufs || fb->zsbuf))<br>
return MAX2(fb->samples, 1);<br>
<br>
+ /**<br>
+ * If a driver doesn't advertise PIPE_CAP_MULTISAMPLED_RENDER_TO_TEXTURE,<br>
+ * pipe_surface::nr_samples will always be 0.<br>
+ */<br>
for (i = 0; i < fb->nr_cbufs; i++) {<br>
if (fb->cbufs[i]) {<br>
- return MAX2(1, fb->cbufs[i]->texture->nr_samples);<br>
+ return MAX3(1, fb->cbufs[i]->texture->nr_samples,<br>
+ fb->cbufs[i]->nr_samples);<br>
}<br>
}<br>
if (fb->zsbuf) {<br>
- return MAX2(1, fb->zsbuf->texture->nr_samples);<br>
+ return MAX3(1, fb->zsbuf->texture->nr_samples,<br>
+ fb->zsbuf->nr_samples);<br>
}<br>
<br>
return 1;<br>
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst<br>
index 0abd164494c..2a062a7027c 100644<br>
--- a/src/gallium/docs/source/screen.rst<br>
+++ b/src/gallium/docs/source/screen.rst<br>
@@ -477,6 +477,9 @@ subpixel precision bias in bits during conservative rasterization.<br>
0 means no limit.<br>
* ``PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET``: The maximum supported value for<br>
of pipe_vertex_element::src_offset.<br>
+* ``PIPE_CAP_MULTISAMPLED_RENDER_TO_TEXTURE``: Whether the driver<br>
+ supports pipe_surface overrides of resource nr_samples. If set, will<br>
+ enable EXT_multisampled_render_to_texture.<br>
<br>
.. _pipe_capf:<br>
<br>
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h<br>
index dacedf5b936..0ecfaf3ba5e 100644<br>
--- a/src/gallium/include/pipe/p_defines.h<br>
+++ b/src/gallium/include/pipe/p_defines.h<br>
@@ -823,6 +823,7 @@ enum pipe_cap<br>
PIPE_CAP_MAX_COMBINED_HW_ATOMIC_COUNTER_BUFFERS,<br>
PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET,<br>
PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET,<br>
+ PIPE_CAP_MULTISAMPLED_RENDER_TO_TEXTURE,<br>
};<br>
<br>
/**<br>
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h<br>
index fd670345aad..89cffb15bd8 100644<br>
--- a/src/gallium/include/pipe/p_state.h<br>
+++ b/src/gallium/include/pipe/p_state.h<br>
@@ -443,6 +443,12 @@ struct pipe_surface<br>
uint16_t width; /**< logical width in pixels */<br>
uint16_t height; /**< logical height in pixels */<br>
<br>
+ /** Number of samples for the surface. This can be different from the<br>
+ * resource nr_samples when the resource is bound using<br>
+ * FramebufferTexture2DMultisampleEXT.<br>
+ */<br>
+ unsigned nr_samples:8;<br>
+<br>
union pipe_surface_desc u;<br>
};<br>
<br>
-- <br>
2.19.1.930.g4563a0d9d0-goog<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><br>
</blockquote></div>