diff options
author | Jordan Justen <[email protected]> | 2015-09-24 01:45:40 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2015-09-29 08:23:47 -0700 |
commit | 681b4badaedec5c9503887c4afb32485ce22c30e (patch) | |
tree | 9c5f88859e3147521ce5e63c0331cc822331ed8b /src/mesa/drivers/dri/i965/brw_fs_nir.cpp | |
parent | 4c6ddd3397f9ec363342831eab710003996e77a8 (diff) |
i965/cs: Generate code to load gl_NumWorkGroups
This code also sets cs_prog_data->uses_num_work_groups which is later
used by state setup to indicate that the gl_NumWorkGroups surface
needs to be setup.
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_fs_nir.cpp')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index cf7e74256fc..7a965cd5b73 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1922,6 +1922,34 @@ fs_visitor::nir_emit_intrinsic(const fs_builder &bld, nir_intrinsic_instr *instr break; } + case nir_intrinsic_load_num_work_groups: { + assert(devinfo->gen >= 7); + assert(stage == MESA_SHADER_COMPUTE); + + struct brw_cs_prog_data *cs_prog_data = + (struct brw_cs_prog_data *) prog_data; + const unsigned surface = + cs_prog_data->binding_table.work_groups_start; + + cs_prog_data->uses_num_work_groups = true; + + fs_reg surf_index = fs_reg(surface); + brw_mark_surface_used(prog_data, surface); + + /* Read the 3 GLuint components of gl_NumWorkGroups */ + for (unsigned i = 0; i < 3; i++) { + fs_reg read_result = + emit_untyped_read(bld, surf_index, + fs_reg(i << 2), + 1 /* dims */, 1 /* size */, + BRW_PREDICATE_NONE); + read_result.type = dest.type; + bld.MOV(dest, read_result); + dest = offset(dest, bld, 1); + } + break; + } + default: unreachable("unknown intrinsic"); } |