<p dir="ltr"></p>
<p dir="ltr">On Aug 5, 2016 10:54 AM, "Nicolai Hähnle" <<a href="mailto:nhaehnle@gmail.com">nhaehnle@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On 04.08.2016 21:42, Marek Olšák wrote:<br>
>><br>
>> 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>
>> v2: remove leftover code, disable conditional rendering<br>
>> ---<br>
>> docs/GL3.txt | 2 +-<br>
>> docs/relnotes/12.1.0.html | 1 +<br>
>> src/gallium/drivers/r600/r600_blit.c | 6 ++-<br>
>> src/gallium/drivers/r600/r600_pipe.c | 2 +-<br>
>> src/gallium/drivers/radeon/r600_texture.c | 66 +++++++++++++++++++++++++++++++<br>
>> src/gallium/drivers/radeonsi/si_blit.c | 6 ++-<br>
>> src/gallium/drivers/radeonsi/si_pipe.c | 2 +-<br>
>> 7 files changed, 80 insertions(+), 5 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_blit.c b/src/gallium/drivers/r600/r600_blit.c<br>
>> index a6c5b44..8f2e2a6 100644<br>
>> --- a/src/gallium/drivers/r600/r600_blit.c<br>
>> +++ b/src/gallium/drivers/r600/r600_blit.c<br>
>> @@ -29,21 +29,25 @@<br>
>><br>
>> enum r600_blitter_op /* bitmask */<br>
>> {<br>
>> R600_SAVE_FRAGMENT_STATE = 1,<br>
>> R600_SAVE_TEXTURES = 2,<br>
>> R600_SAVE_FRAMEBUFFER = 4,<br>
>> R600_DISABLE_RENDER_COND = 8,<br>
>><br>
>> R600_CLEAR = R600_SAVE_FRAGMENT_STATE,<br>
>><br>
>> - R600_CLEAR_SURFACE = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER,<br>
>> + /* GL_ARB_clear_texture should ignore the render condition, but<br>
>> + * Gallium shouldn't. Follow OpenGL.<br>
>> + */<br>
>> + R600_CLEAR_SURFACE = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER |<br>
>> + R600_DISABLE_RENDER_COND,<br>
><br>
><br>
> It's annoying, but doesn't this break conditional rendering of glClear?</p>
<p dir="ltr">glClear doesn't use these clear functions.</p>
<p dir="ltr">Marek</p>
<p dir="ltr">><br>
> Nicolai<br>
><br>
><br>
>><br>
>> R600_COPY_BUFFER = R600_DISABLE_RENDER_COND,<br>
>><br>
>> R600_COPY_TEXTURE = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_SAVE_TEXTURES |<br>
>> R600_DISABLE_RENDER_COND,<br>
>><br>
>> R600_BLIT = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_SAVE_TEXTURES,<br>
>><br>
>> R600_DECOMPRESS = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_DISABLE_RENDER_COND,<br>
>><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..0b13f36 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,84 @@ 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>
>> + /* 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 +2390,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_blit.c b/src/gallium/drivers/radeonsi/si_blit.c<br>
>> index 38a19d5..6fcf0f0 100644<br>
>> --- a/src/gallium/drivers/radeonsi/si_blit.c<br>
>> +++ b/src/gallium/drivers/radeonsi/si_blit.c<br>
>> @@ -28,21 +28,25 @@<br>
>><br>
>> enum si_blitter_op /* bitmask */<br>
>> {<br>
>> SI_SAVE_TEXTURES = 1,<br>
>> SI_SAVE_FRAMEBUFFER = 2,<br>
>> SI_SAVE_FRAGMENT_STATE = 4,<br>
>> SI_DISABLE_RENDER_COND = 8,<br>
>><br>
>> SI_CLEAR = SI_SAVE_FRAGMENT_STATE,<br>
>><br>
>> - SI_CLEAR_SURFACE = SI_SAVE_FRAMEBUFFER | SI_SAVE_FRAGMENT_STATE,<br>
>> + /* GL_ARB_clear_texture should ignore the render condition, but<br>
>> + * Gallium shouldn't. Follow OpenGL.<br>
>> + */<br>
>> + SI_CLEAR_SURFACE = SI_SAVE_FRAMEBUFFER | SI_SAVE_FRAGMENT_STATE |<br>
>> + SI_DISABLE_RENDER_COND,<br>
>><br>
>> SI_COPY = SI_SAVE_FRAMEBUFFER | SI_SAVE_TEXTURES |<br>
>> SI_SAVE_FRAGMENT_STATE | SI_DISABLE_RENDER_COND,<br>
>><br>
>> SI_BLIT = SI_SAVE_FRAMEBUFFER | SI_SAVE_TEXTURES |<br>
>> SI_SAVE_FRAGMENT_STATE,<br>
>><br>
>> SI_DECOMPRESS = SI_SAVE_FRAMEBUFFER | SI_SAVE_FRAGMENT_STATE |<br>
>> SI_DISABLE_RENDER_COND,<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>
>></p>