diff options
author | Chia-I Wu <[email protected]> | 2014-10-29 09:57:23 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-11-06 10:43:53 +0800 |
commit | ce40fa3a4ad58e3dfe50e7733f3e2b43d36e9136 (patch) | |
tree | 9e50e93fc87544d02b674fa26c66a21e8ba80956 /src/gallium/drivers/ilo/ilo_gpgpu.c | |
parent | a1a701877a3160f7e076c3d62565c08cbf32e920 (diff) |
ilo: hook up launch_grid()
All we need to do is to upload the input data and call
ilo_render_emit_launch_grid() with space checking.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_gpgpu.c')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpgpu.c | 76 |
1 files changed, 73 insertions, 3 deletions
diff --git a/src/gallium/drivers/ilo/ilo_gpgpu.c b/src/gallium/drivers/ilo/ilo_gpgpu.c index fd756a02fcb..9a2ca007f80 100644 --- a/src/gallium/drivers/ilo/ilo_gpgpu.c +++ b/src/gallium/drivers/ilo/ilo_gpgpu.c @@ -25,18 +25,88 @@ * Chia-I Wu <[email protected]> */ +#include "util/u_upload_mgr.h" #include "ilo_context.h" +#include "ilo_render.h" +#include "ilo_shader.h" #include "ilo_gpgpu.h" -/* - * This is a placeholder. We will need something similar to ilo_render. - */ +static void +launch_grid(struct ilo_context *ilo, + const uint *block_layout, const uint *grid_layout, + const struct pipe_constant_buffer *input, uint32_t pc) +{ + const unsigned grid_offset[3] = { 0, 0, 0 }; + const unsigned thread_group_size = + block_layout[0] * block_layout[1] * block_layout[2]; + int max_len, before_space; + + ilo_cp_set_owner(ilo->cp, INTEL_RING_RENDER, NULL); + + max_len = ilo_render_get_launch_grid_len(ilo->render, &ilo->state_vector); + max_len += ilo_render_get_flush_len(ilo->render) * 2; + + if (max_len > ilo_cp_space(ilo->cp)) { + ilo_cp_submit(ilo->cp, "out of space"); + assert(max_len <= ilo_cp_space(ilo->cp)); + } + + before_space = ilo_cp_space(ilo->cp); + + while (true) { + struct ilo_builder_snapshot snapshot; + + ilo_builder_batch_snapshot(&ilo->cp->builder, &snapshot); + + ilo_render_emit_launch_grid(ilo->render, &ilo->state_vector, + grid_offset, grid_layout, thread_group_size, input, pc); + + if (!ilo_builder_validate(&ilo->cp->builder, 0, NULL)) { + ilo_builder_batch_restore(&ilo->cp->builder, &snapshot); + + /* flush and try again */ + if (ilo_builder_batch_used(&ilo->cp->builder)) { + ilo_cp_submit(ilo->cp, "out of aperture"); + continue; + } + } + + break; + } + + /* sanity check size estimation */ + assert(before_space - ilo_cp_space(ilo->cp) <= max_len); +} static void ilo_launch_grid(struct pipe_context *pipe, const uint *block_layout, const uint *grid_layout, uint32_t pc, const void *input) { + struct ilo_context *ilo = ilo_context(pipe); + struct ilo_shader_state *cs = ilo->state_vector.cs; + struct pipe_constant_buffer input_buf; + + memset(&input_buf, 0, sizeof(input_buf)); + + input_buf.buffer_size = + ilo_shader_get_kernel_param(cs, ILO_KERNEL_CS_INPUT_SIZE); + if (input_buf.buffer_size) { + u_upload_data(ilo->uploader, 0, input_buf.buffer_size, input, + &input_buf.buffer_offset, &input_buf.buffer); + } + + ilo_shader_cache_upload(ilo->shader_cache, &ilo->cp->builder); + + launch_grid(ilo, block_layout, grid_layout, &input_buf, pc); + + ilo_render_invalidate_hw(ilo->render); + + if (ilo_debug & ILO_DEBUG_NOCACHE) + ilo_render_emit_flush(ilo->render); + + if (input_buf.buffer_size) + pipe_resource_reference(&input_buf.buffer, NULL); } /** |