#include "sp_buffer.h"
#include "sp_texture.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
static bool
get_dimensions(const struct pipe_shader_buffer *bview,
struct softpipe_resource *spr;
unsigned width;
int c, j;
- unsigned char *data_ptr;
- const struct util_format_description *format_desc = util_format_description(PIPE_FORMAT_R32_UINT);
if (params->unit >= PIPE_MAX_SHADER_BUFFERS)
goto fail_write_all_zero;
for (j = 0; j < TGSI_QUAD_SIZE; j++) {
int s_coord;
bool fill_zero = false;
- uint32_t sdata[4];
if (!(params->execmask & (1 << j)))
fill_zero = true;
rgba[c][j] = 0;
continue;
}
- data_ptr = (unsigned char *)spr->data + bview->buffer_offset + s_coord;
+ uint32_t *src = (uint32_t *)((unsigned char *)spr->data +
+ bview->buffer_offset + s_coord);
for (c = 0; c < 4; c++) {
- format_desc->fetch_rgba_uint(sdata, data_ptr, 0, 0);
- ((uint32_t *)rgba[c])[j] = sdata[0];
- data_ptr += 4;
+ memcpy(&rgba[c][j], &src[c], 4);
}
}
return;
struct pipe_shader_buffer *bview;
struct softpipe_resource *spr;
unsigned width;
- unsigned char *data_ptr;
int j, c;
- const struct util_format_description *format_desc = util_format_description(PIPE_FORMAT_R32_UINT);
if (params->unit >= PIPE_MAX_SHADER_BUFFERS)
return;
if (s_coord >= width)
continue;
- data_ptr = (unsigned char *)spr->data + bview->buffer_offset + s_coord;
+ uint32_t *dst = (uint32_t *)((unsigned char *)spr->data +
+ bview->buffer_offset + s_coord);
for (c = 0; c < 4; c++) {
- if (params->writemask & (1 << c)) {
- unsigned temp[4];
- unsigned char *dptr = data_ptr + (c * 4);
- temp[0] = ((uint32_t *)rgba[c])[j];
- format_desc->pack_rgba_uint(dptr, 0, temp, 0, 1, 1);
- }
+ if (params->writemask & (1 << c))
+ memcpy(&dst[c], &rgba[c][j], 4);
}
}
}
* Implement atomic operations on unsigned integers.
*/
static void
-handle_op_uint(const struct pipe_shader_buffer *bview,
- bool just_read,
- unsigned char *data_ptr,
- uint qi,
- unsigned opcode,
- unsigned writemask,
- float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE],
- float rgba2[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE])
+handle_op_atomic(const struct pipe_shader_buffer *bview,
+ bool just_read,
+ unsigned char *data_ptr,
+ uint qi,
+ enum tgsi_opcode opcode,
+ unsigned writemask,
+ float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE],
+ float rgba2[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE])
{
uint c;
- const struct util_format_description *format_desc = util_format_description(PIPE_FORMAT_R32_UINT);
unsigned sdata[4];
for (c = 0; c < 4; c++) {
- unsigned temp[4];
- unsigned char *dptr = data_ptr + (c * 4);
- format_desc->fetch_rgba_uint(temp, dptr, 0, 0);
- sdata[c] = temp[0];
+ memcpy(&sdata[c], data_ptr + (c * 4), 4);
}
if (just_read) {
((uint32_t *)rgba[c])[qi] = dst_x;
}
break;
+ case TGSI_OPCODE_ATOMFADD:
+ for (c = 0; c < 4; c++) {
+ float temp = uif(sdata[c]);
+ sdata[c] = fui(temp + rgba[c][qi]);
+ rgba[c][qi] = temp;
+ }
+ break;
default:
assert(!"Unexpected TGSI opcode in sp_tgsi_op");
break;
for (c = 0; c < 4; c++) {
if (writemask & (1 << c)) {
- unsigned temp[4];
- unsigned char *dptr = data_ptr + (c * 4);
- temp[0] = sdata[c];
- format_desc->pack_rgba_uint(dptr, 0, temp, 0, 1, 1);
+ memcpy(data_ptr + (c * 4), &sdata[c], 4);
}
}
}
static void
sp_tgsi_op(const struct tgsi_buffer *buffer,
const struct tgsi_buffer_params *params,
- unsigned opcode,
+ enum tgsi_opcode opcode,
const int s[TGSI_QUAD_SIZE],
float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE],
float rgba2[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE])
data_ptr = (unsigned char *)spr->data + bview->buffer_offset + s_coord;
/* we should see atomic operations on r32 formats */
- handle_op_uint(bview, just_read, data_ptr, j,
- opcode, params->writemask, rgba, rgba2);
+ handle_op_atomic(bview, just_read, data_ptr, j,
+ opcode, params->writemask, rgba, rgba2);
}
return;
fail_write_all_zero: