<p dir="ltr">I believe that clear depth stencil is meant to respect the render condition, while clear texture is not. In nouveau I "solved" this by ignoring the render condition in the clear depth stencil function too, since nothing in Mesa relied on it iirc.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Aug 4, 2016 12:57, "Marek Olšák" <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
<br>
Some ideas copied from Jakob Sinclair's implementation, but the color<br>
clearing is completely different.<br>
---<br>
 docs/GL3.txt                              |  2 +-<br>
 docs/relnotes/12.1.0.html                 |  1 +<br>
 src/gallium/drivers/r600/r600_pipe.c      |  2 +-<br>
 src/gallium/drivers/radeon/r600_texture.c | 69 +++++++++++++++++++++++++++++++<br>
 src/gallium/drivers/radeonsi/si_pipe.c    |  2 +-<br>
 5 files changed, 73 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/docs/GL3.txt b/docs/GL3.txt<br>
index c185c69..5dcfc31 100644<br>
--- a/docs/GL3.txt<br>
+++ b/docs/GL3.txt<br>
@@ -185,21 +185,21 @@ GL 4.3, GLSL 4.30 -- all DONE: nvc0, radeonsi<br>
   GL_ARB_texture_query_levels                           DONE (all drivers that support GLSL 1.30)<br>
   GL_ARB_texture_storage_multisample                    DONE (all drivers that support GL_ARB_texture_multisample)<br>
   GL_ARB_texture_view                                   DONE (i965, nv50, r600, llvmpipe, softpipe, swr)<br>
   GL_ARB_vertex_attrib_binding                          DONE (all drivers)<br>
<br>
<br>
 GL 4.4, GLSL 4.40:<br>
<br>
   GL_MAX_VERTEX_ATTRIB_STRIDE                           DONE (all drivers)<br>
   GL_ARB_buffer_storage                                 DONE (i965, nv50, nvc0, r600, radeonsi)<br>
-  GL_ARB_clear_texture                                  DONE (i965, nv50, nvc0)<br>
+  GL_ARB_clear_texture                                  DONE (i965, nv50, nvc0, r600, radeonsi)<br>
   GL_ARB_enhanced_layouts                               DONE (i965)<br>
   - compile-time constant expressions                   DONE<br>
   - explicit byte offsets for blocks                    DONE<br>
   - forced alignment within blocks                      DONE<br>
   - specified vec4-slot component numbers               DONE (i965)<br>
   - specified transform/feedback layout                 DONE<br>
   - input/output block locations                        DONE<br>
   GL_ARB_multi_bind                                     DONE (all drivers)<br>
   GL_ARB_query_buffer_object                            DONE (i965/hsw+, nvc0)<br>
   GL_ARB_texture_mirror_clamp_to_edge                   DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe, swr)<br>
diff --git a/docs/relnotes/12.1.0.html b/docs/relnotes/12.1.0.html<br>
index 3935bb0..ed98d13 100644<br>
--- a/docs/relnotes/12.1.0.html<br>
+++ b/docs/relnotes/12.1.0.html<br>
@@ -37,20 +37,21 @@ TBD.<br>
 </pre><br>
<br>
<br>
 <h2>New features</h2><br>
<br>
 <p><br>
 Note: some of the new features are only available with certain drivers.<br>
 </p><br>
<br>
 <ul><br>
+<li>GL_ARB_clear_texture on r600, radeonsi</li><br>
 <li>GL_ARB_enhanced_layouts on i965</li><br>
 <li>GL_ARB_shader_group_vote on nvc0</li><br>
 <li>GL_ARB_ES3_1_compatibility on i965</li><br>
 <li>GL_EXT_window_rectangles on nv50, nvc0</li><br>
 <li>GL_KHR_texture_compression_astc_sliced_3d on i965</li><br>
 </ul><br>
<br>
 <h2>Bug fixes</h2><br>
<br>
 TBD.<br>
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c<br>
index 39a310a..5f69a5d 100644<br>
--- a/src/gallium/drivers/r600/r600_pipe.c<br>
+++ b/src/gallium/drivers/r600/r600_pipe.c<br>
@@ -276,20 +276,21 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)<br>
        case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:<br>
        case PIPE_CAP_TEXTURE_FLOAT_LINEAR:<br>
        case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR:<br>
        case PIPE_CAP_TGSI_TXQS:<br>
        case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:<br>
        case PIPE_CAP_INVALIDATE_BUFFER:<br>
        case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:<br>
        case PIPE_CAP_QUERY_MEMORY_INFO:<br>
        case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:<br>
        case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:<br>
+       case PIPE_CAP_CLEAR_TEXTURE:<br>
                return 1;<br>
<br>
        case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:<br>
                return rscreen->b.info.drm_major == 2 && rscreen->b.info.drm_minor >= 43;<br>
<br>
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:<br>
                return !R600_BIG_ENDIAN && rscreen->b.info.has_userptr;<br>
<br>
        case PIPE_CAP_COMPUTE:<br>
                return rscreen->b.chip_class > R700;<br>
@@ -348,21 +349,20 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)<br>
        case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:<br>
        case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:<br>
        case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:<br>
        case PIPE_CAP_VERTEX_COLOR_CLAMPED:<br>
        case PIPE_CAP_USER_VERTEX_BUFFERS:<br>
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:<br>
        case PIPE_CAP_VERTEXID_NOBASE:<br>
        case PIPE_CAP_DEPTH_BOUNDS_TEST:<br>
        case PIPE_CAP_FORCE_PERSAMPLE_INTERP:<br>
        case PIPE_CAP_SHAREABLE_SHADERS:<br>
-       case PIPE_CAP_CLEAR_TEXTURE:<br>
        case PIPE_CAP_DRAW_PARAMETERS:<br>
        case PIPE_CAP_TGSI_PACK_HALF_FLOAT:<br>
        case PIPE_CAP_MULTI_DRAW_INDIRECT:<br>
        case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:<br>
        case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:<br>
        case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:<br>
        case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:<br>
        case PIPE_CAP_GENERATE_MIPMAP:<br>
        case PIPE_CAP_STRING_MARKER:<br>
        case PIPE_CAP_QUERY_BUFFER_OBJECT:<br>
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c<br>
index f7c2f80..65b40ce 100644<br>
--- a/src/gallium/drivers/radeon/r600_texture.c<br>
+++ b/src/gallium/drivers/radeon/r600_texture.c<br>
@@ -23,20 +23,21 @@<br>
  * Authors:<br>
  *      Jerome Glisse<br>
  *      Corbin Simpson<br>
  */<br>
 #include "r600_pipe_common.h"<br>
 #include "r600_cs.h"<br>
 #include "r600_query.h"<br>
 #include "util/u_format.h"<br>
 #include "util/u_memory.h"<br>
 #include "util/u_pack_color.h"<br>
+#include "util/u_surface.h"<br>
 #include "os/os_time.h"<br>
 #include <errno.h><br>
 #include <inttypes.h><br>
<br>
 static void r600_texture_discard_cmask(struct r600_common_screen *rscreen,<br>
                                       struct r600_texture *rtex);<br>
 static unsigned r600_choose_tiling(struct r600_common_screen *rscreen,<br>
                                   const struct pipe_resource *templ);<br>
<br>
<br>
@@ -1689,20 +1690,87 @@ static struct pipe_surface *r600_create_surface(struct pipe_context *pipe,<br>
 static void r600_surface_destroy(struct pipe_context *pipe,<br>
                                 struct pipe_surface *surface)<br>
 {<br>
        struct r600_surface *surf = (struct r600_surface*)surface;<br>
        r600_resource_reference(&surf->cb_buffer_fmask, NULL);<br>
        r600_resource_reference(&surf->cb_buffer_cmask, NULL);<br>
        pipe_resource_reference(&surface->texture, NULL);<br>
        FREE(surface);<br>
 }<br>
<br>
+static void r600_clear_texture(struct pipe_context *pipe,<br>
+                              struct pipe_resource *tex,<br>
+                              unsigned level,<br>
+                              const struct pipe_box *box,<br>
+                              const void *data)<br>
+{<br>
+       struct pipe_screen *screen = pipe->screen;<br>
+       struct r600_texture *rtex = (struct r600_texture*)tex;<br>
+       struct pipe_surface tmpl = {{0}}, *sf;<br>
+       const struct util_format_description *desc =<br>
+               util_format_description(tex->format);<br>
+<br>
+       tmpl.format = tex->format;<br>
+       tmpl.u.tex.first_layer = box->z;<br>
+       tmpl.u.tex.last_layer = box->z + box->depth - 1;<br>
+       tmpl.u.tex.level = level;<br>
+       sf = pipe->create_surface(pipe, tex, &tmpl);<br>
+       if (!sf)<br>
+               return;<br>
+<br>
+       if (rtex->is_depth) {<br>
+               unsigned clear;<br>
+               float depth;<br>
+               uint8_t stencil = 0;<br>
+<br>
+               /* Depth is always present. */<br>
+               clear = PIPE_CLEAR_DEPTH;<br>
+               desc->unpack_z_float(&depth, 0, data, 0, 1, 1);<br>
+<br>
+               if (rtex->surface.flags & RADEON_SURF_SBUFFER) {<br>
+                       clear |= PIPE_CLEAR_STENCIL;<br>
+                       desc->unpack_s_8uint(&stencil, 0, data, 0, 1, 1);<br>
+               }<br>
+<br>
+               pipe->clear_depth_stencil(pipe, sf, clear, depth, stencil,<br>
+                                         box->x, box->y,<br>
+                                         box->width, box->height);<br>
+       } else {<br>
+               union pipe_color_union color;<br>
+<br>
+               assert(rtex->surface.bpe <= sizeof(color));<br>
+               memcpy(&color, data, rtex->surface.bpe);<br>
+<br>
+               /* pipe_color_union requires the full vec4 representation. */<br>
+               if (util_format_is_pure_uint(tex->format))<br>
+                       desc->unpack_rgba_uint(color.ui, 0, data, 0, 1, 1);<br>
+               else if (util_format_is_pure_sint(tex->format))<br>
+                       desc->unpack_rgba_sint(color.i, 0, data, 0, 1, 1);<br>
+               else<br>
+                       desc->unpack_rgba_float(color.f, 0, data, 0, 1, 1);<br>
+<br>
+               if (screen->is_format_supported(screen, tex->format,<br>
+                                               tex->target, 0,<br>
+                                               PIPE_BIND_RENDER_TARGET)) {<br>
+                       pipe->clear_render_target(pipe, sf, &color,<br>
+                                                 box->x, box->y,<br>
+                                                 box->width, box->height);<br>
+               } else {<br>
+                       /* Software fallback - just for R9G9B9E5_FLOAT */<br>
+                       util_clear_render_target(pipe, sf, &color,<br>
+                                                box->x, box->y,<br>
+                                                box->width, box->height);<br>
+               }<br>
+       }<br>
+       pipe_surface_reference(&sf, NULL);<br>
+}<br>
+<br>
 unsigned r600_translate_colorswap(enum pipe_format format, bool do_endian_swap)<br>
 {<br>
        const struct util_format_description *desc = util_format_description(format);<br>
<br>
 #define HAS_SWIZZLE(chan,swz) (desc->swizzle[chan] == PIPE_SWIZZLE_##swz)<br>
<br>
        if (format == PIPE_FORMAT_R11G11B10_FLOAT) /* isn't plain */<br>
                return V_0280A0_SWAP_STD;<br>
<br>
        if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)<br>
@@ -2325,11 +2393,12 @@ void evergreen_do_fast_color_clear(struct r600_common_context *rctx,<br>
 void r600_init_screen_texture_functions(struct r600_common_screen *rscreen)<br>
 {<br>
        rscreen->b.resource_from_handle = r600_texture_from_handle;<br>
        rscreen->b.resource_get_handle = r600_texture_get_handle;<br>
 }<br>
<br>
 void r600_init_context_texture_functions(struct r600_common_context *rctx)<br>
 {<br>
        rctx->b.create_surface = r600_create_surface;<br>
        rctx->b.surface_destroy = r600_surface_destroy;<br>
+       rctx->b.clear_texture = r600_clear_texture;<br>
 }<br>
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c<br>
index e33823d..c1c2a9a 100644<br>
--- a/src/gallium/drivers/radeonsi/si_pipe.c<br>
+++ b/src/gallium/drivers/radeonsi/si_pipe.c<br>
@@ -379,20 +379,21 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)<br>
        case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:<br>
        case PIPE_CAP_INVALIDATE_BUFFER:<br>
        case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:<br>
        case PIPE_CAP_QUERY_MEMORY_INFO:<br>
        case PIPE_CAP_TGSI_PACK_HALF_FLOAT:<br>
        case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:<br>
        case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:<br>
        case PIPE_CAP_GENERATE_MIPMAP:<br>
        case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:<br>
        case PIPE_CAP_STRING_MARKER:<br>
+       case PIPE_CAP_CLEAR_TEXTURE:<br>
                return 1;<br>
<br>
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:<br>
                return !SI_BIG_ENDIAN && sscreen->b.info.has_userptr;<br>
<br>
        case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:<br>
                return (sscreen->b.info.drm_major == 2 &&<br>
                        sscreen->b.info.drm_minor >= 43) ||<br>
                       sscreen->b.info.drm_major == 3;<br>
<br>
@@ -427,21 +428,20 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)<br>
        case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:<br>
                return 0;<br>
<br>
        /* Unsupported features. */<br>
        case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:<br>
        case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:<br>
        case PIPE_CAP_USER_VERTEX_BUFFERS:<br>
        case PIPE_CAP_FAKE_SW_MSAA:<br>
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:<br>
        case PIPE_CAP_VERTEXID_NOBASE:<br>
-       case PIPE_CAP_CLEAR_TEXTURE:<br>
        case PIPE_CAP_DRAW_PARAMETERS:<br>
        case PIPE_CAP_MULTI_DRAW_INDIRECT:<br>
        case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:<br>
        case PIPE_CAP_QUERY_BUFFER_OBJECT:<br>
        case PIPE_CAP_CULL_DISTANCE:<br>
        case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:<br>
        case PIPE_CAP_TGSI_VOTE:<br>
        case PIPE_CAP_MAX_WINDOW_RECTANGLES:<br>
                return 0;<br>
<br>
--<br>
2.7.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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></div>