llvmpipe: add clear_buffer callback. (v2)

This fixes CL CTS thread dimensions test

v2: optimise for 1 and 4. (ajax)

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7416>
This commit is contained in:
Dave Airlie 2020-11-02 17:13:48 +10:00 committed by Marge Bot
parent 1e3fbee4b0
commit c3d8a69c3a

View file

@ -27,6 +27,7 @@
#include "util/u_rect.h"
#include "util/u_surface.h"
#include "util/u_memset.h"
#include "lp_context.h"
#include "lp_flush.h"
#include "lp_limits.h"
@ -442,6 +443,41 @@ llvmpipe_clear_texture(struct pipe_context *pipe,
}
}
static void
llvmpipe_clear_buffer(struct pipe_context *pipe,
struct pipe_resource *res,
unsigned offset,
unsigned size,
const void *clear_value,
int clear_value_size)
{
struct pipe_transfer *dst_t;
struct pipe_box box;
char *dst;
u_box_1d(offset, size, &box);
dst = pipe->transfer_map(pipe,
res,
0,
PIPE_MAP_WRITE,
&box,
&dst_t);
switch (clear_value_size) {
case 1:
memset(dst, *(uint8_t *)clear_value, size);
break;
case 4:
util_memset32(dst, *(uint32_t *)clear_value, size / 4);
break;
default:
for (unsigned i = 0; i < size; i += clear_value_size)
memcpy(&dst[i], clear_value, clear_value_size);
break;
}
pipe->transfer_unmap(pipe, dst_t);
}
void
llvmpipe_init_surface_functions(struct llvmpipe_context *lp)
{
@ -451,6 +487,7 @@ llvmpipe_init_surface_functions(struct llvmpipe_context *lp)
lp->pipe.surface_destroy = llvmpipe_surface_destroy;
/* These are not actually functions dealing with surfaces */
lp->pipe.clear_texture = llvmpipe_clear_texture;
lp->pipe.clear_buffer = llvmpipe_clear_buffer;
lp->pipe.resource_copy_region = lp_resource_copy;
lp->pipe.blit = lp_blit;
lp->pipe.flush_resource = lp_flush_resource;