diff options
author | Dave Airlie <[email protected]> | 2016-04-27 07:55:20 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2016-05-02 07:28:58 +1000 |
commit | 277170eeea00e001635aa0c8ac90012a6f98f299 (patch) | |
tree | 8b999494828ee0b3ff70e0333c983ee315cb6fb9 /src/gallium/drivers/softpipe/sp_image.c | |
parent | 3950aa47df26ad4cbfa9ca02dffa8ebd5a9b432a (diff) |
softpipe: allow r32 xchg on shader images.
This is part of OES_shader_image_atomic.txt.
Reviewed-by: Roland Scheidegger <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_image.c')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_image.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gallium/drivers/softpipe/sp_image.c b/src/gallium/drivers/softpipe/sp_image.c index f72c4e71ce4..0be11cb8640 100644 --- a/src/gallium/drivers/softpipe/sp_image.c +++ b/src/gallium/drivers/softpipe/sp_image.c @@ -607,6 +607,42 @@ handle_op_int(const struct pipe_image_view *iview, s, t, 1, 1); } +/* GLES OES_shader_image_atomic.txt allows XCHG on R32F */ +static void +handle_op_r32f_xchg(const struct pipe_image_view *iview, + const struct tgsi_image_params *params, + bool just_read, + char *data_ptr, + uint qi, + unsigned stride, + unsigned opcode, + int s, + int t, + float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]) +{ + float sdata[4]; + uint c; + int nc = 1; + util_format_read_4f(params->format, + sdata, 0, + data_ptr, stride, + s, t, 1, 1); + if (just_read) { + for (c = 0; c < nc; c++) { + ((int32_t *)rgba[c])[qi] = sdata[c]; + } + return; + } + + for (c = 0; c < nc; c++) { + int temp = sdata[c]; + sdata[c] = ((float *)rgba[c])[qi]; + ((float *)rgba[c])[qi] = temp; + } + util_format_write_4f(params->format, sdata, 0, data_ptr, stride, + s, t, 1, 1); +} + /* * Implement atomic image operations. */ @@ -682,6 +718,10 @@ sp_tgsi_op(const struct tgsi_image *image, else if (util_format_is_pure_sint(params->format)) handle_op_int(iview, params, just_read, data_ptr, j, stride, opcode, s_coord, t_coord, rgba, rgba2); + else if (params->format == PIPE_FORMAT_R32_FLOAT && + opcode == TGSI_OPCODE_ATOMXCHG) + handle_op_r32f_xchg(iview, params, just_read, data_ptr, j, stride, + opcode, s_coord, t_coord, rgba); else assert(0); } |