summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_cs.c
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2015-11-22 22:11:53 -0800
committerMatt Turner <mattst88@gmail.com>2015-11-24 10:05:33 -0800
commit6ba700c3c38f216987ebb9b8a1ce80ac784f2d5a (patch)
treea36fa8e814328e1035547a327cd8d3630a70b603 /src/mesa/drivers/dri/i965/brw_cs.c
parent6b525d9f2babfaf97bb002c06c810874bf152a8c (diff)
downloadexternal_mesa3d-6ba700c3c38f216987ebb9b8a1ce80ac784f2d5a.zip
external_mesa3d-6ba700c3c38f216987ebb9b8a1ce80ac784f2d5a.tar.gz
external_mesa3d-6ba700c3c38f216987ebb9b8a1ce80ac784f2d5a.tar.bz2
i965: Compile brw_cs_fill_local_id_payload() as C.
It's only called from C, it compiles as C, so just compile it as C. Notice the missing extern "C" on the definition of the function, which would screw things up if the prototype wasn't parsed before the definition. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_cs.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_cs.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c
index a34c320..9c92faa 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.c
+++ b/src/mesa/drivers/dri/i965/brw_cs.c
@@ -33,6 +33,42 @@
#include "brw_nir.h"
#include "brw_program.h"
+void
+brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *prog_data,
+ void *buffer, uint32_t threads, uint32_t stride)
+{
+ if (prog_data->local_invocation_id_regs == 0)
+ return;
+
+ /* 'stride' should be an integer number of registers, that is, a multiple
+ * of 32 bytes.
+ */
+ assert(stride % 32 == 0);
+
+ unsigned x = 0, y = 0, z = 0;
+ for (unsigned t = 0; t < threads; t++) {
+ uint32_t *param = (uint32_t *) buffer + stride * t / 4;
+
+ for (unsigned i = 0; i < prog_data->simd_size; i++) {
+ param[0 * prog_data->simd_size + i] = x;
+ param[1 * prog_data->simd_size + i] = y;
+ param[2 * prog_data->simd_size + i] = z;
+
+ x++;
+ if (x == prog_data->local_size[0]) {
+ x = 0;
+ y++;
+ if (y == prog_data->local_size[1]) {
+ y = 0;
+ z++;
+ if (z == prog_data->local_size[2])
+ z = 0;
+ }
+ }
+ }
+ }
+}
+
static void
assign_cs_binding_table_offsets(const struct brw_device_info *devinfo,
const struct gl_shader_program *shader_prog,