<div dir="ltr">Can the Vulkan driver take advantage of this too?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 29, 2016 at 3:38 PM, Jordan Justen <span dir="ltr"><<a href="mailto:jordan.l.justen@intel.com" target="_blank">jordan.l.justen@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br>
---<br>
src/mesa/drivers/dri/i965/brw_compiler.h | 1 +<br>
src/mesa/drivers/dri/i965/brw_fs.cpp | 15 ++++++++++++---<br>
src/mesa/drivers/dri/i965/gen7_cs_state.c | 32 ++++++++++---------------------<br>
3 files changed, 23 insertions(+), 25 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h b/src/mesa/drivers/dri/i965/brw_compiler.h<br>
index bed969c..f1f9e56 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_compiler.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_compiler.h<br>
@@ -430,6 +430,7 @@ struct brw_cs_prog_data {<br>
GLuint dispatch_grf_start_reg_16;<br>
unsigned local_size[3];<br>
unsigned simd_size;<br>
+ unsigned threads;<br>
bool uses_barrier;<br>
bool uses_num_work_groups;<br>
unsigned local_invocation_id_regs;<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
index cbcde68..836ade0 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
@@ -6478,6 +6478,15 @@ fs_visitor::emit_cs_work_group_id_setup()<br>
return reg;<br>
}<br>
<br>
+static void<br>
+cs_set_simd_size(struct brw_cs_prog_data *cs_prog_data, unsigned size)<br>
+{<br>
+ cs_prog_data->simd_size = size;<br>
+ unsigned group_size = cs_prog_data->local_size[0] *<br>
+ cs_prog_data->local_size[1] * cs_prog_data->local_size[2];<br>
+ cs_prog_data->threads = (group_size + size - 1) / size;<br>
+}<br>
+<br>
const unsigned *<br>
brw_compile_cs(const struct brw_compiler *compiler, void *log_data,<br>
void *mem_ctx,<br>
@@ -6526,7 +6535,7 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,<br>
fail_msg = v8.fail_msg;<br>
} else {<br>
cfg = v8.cfg;<br>
- prog_data->simd_size = 8;<br>
+ cs_set_simd_size(prog_data, 8);<br>
prog_data->base.dispatch_grf_start_reg = v8.payload.num_regs;<br>
}<br>
}<br>
@@ -6551,7 +6560,7 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,<br>
}<br>
} else {<br>
cfg = v16.cfg;<br>
- prog_data->simd_size = 16;<br>
+ cs_set_simd_size(prog_data, 16);<br>
prog_data->dispatch_grf_start_reg_16 = v16.payload.num_regs;<br>
}<br>
}<br>
@@ -6578,7 +6587,7 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,<br>
}<br>
} else {<br>
cfg = v32.cfg;<br>
- prog_data->simd_size = 32;<br>
+ cs_set_simd_size(prog_data, 32);<br>
}<br>
}<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/gen7_cs_state.c b/src/mesa/drivers/dri/i965/gen7_cs_state.c<br>
index 7f484dd..619edfb 100644<br>
--- a/src/mesa/drivers/dri/i965/gen7_cs_state.c<br>
+++ b/src/mesa/drivers/dri/i965/gen7_cs_state.c<br>
@@ -33,17 +33,6 @@<br>
#include "program/prog_statevars.h"<br>
#include "compiler/glsl/ir_uniform.h"<br>
<br>
-static unsigned<br>
-get_cs_thread_count(const struct brw_cs_prog_data *cs_prog_data)<br>
-{<br>
- const unsigned simd_size = cs_prog_data->simd_size;<br>
- unsigned group_size = cs_prog_data->local_size[0] *<br>
- cs_prog_data->local_size[1] * cs_prog_data->local_size[2];<br>
-<br>
- return (group_size + simd_size - 1) / simd_size;<br>
-}<br>
-<br>
-<br>
static void<br>
brw_upload_cs_state(struct brw_context *brw)<br>
{<br>
@@ -79,7 +68,6 @@ brw_upload_cs_state(struct brw_context *brw)<br>
(prog_data->nr_params + local_id_dwords) * sizeof(gl_constant_value);<br>
unsigned reg_aligned_constant_size = ALIGN(push_constant_data_size, 32);<br>
unsigned push_constant_regs = reg_aligned_constant_size / 32;<br>
- unsigned threads = get_cs_thread_count(cs_prog_data);<br>
<br>
uint32_t dwords = brw->gen < 8 ? 8 : 9;<br>
BEGIN_BATCH(dwords);<br>
@@ -129,7 +117,8 @@ brw_upload_cs_state(struct brw_context *brw)<br>
*<br>
* Note: The constant data is built in brw_upload_cs_push_constants below.<br>
*/<br>
- const uint32_t vfe_curbe_allocation = push_constant_regs * threads;<br>
+ const uint32_t vfe_curbe_allocation =<br>
+ push_constant_regs * cs_prog_data->threads;<br>
OUT_BATCH(SET_FIELD(vfe_urb_allocation, MEDIA_VFE_STATE_URB_ALLOC) |<br>
SET_FIELD(vfe_curbe_allocation, MEDIA_VFE_STATE_CURBE_ALLOC));<br>
OUT_BATCH(0);<br>
@@ -141,7 +130,7 @@ brw_upload_cs_state(struct brw_context *brw)<br>
BEGIN_BATCH(4);<br>
OUT_BATCH(MEDIA_CURBE_LOAD << 16 | (4 - 2));<br>
OUT_BATCH(0);<br>
- OUT_BATCH(ALIGN(reg_aligned_constant_size * threads, 64));<br>
+ OUT_BATCH(ALIGN(reg_aligned_constant_size * cs_prog_data->threads, 64));<br>
OUT_BATCH(stage_state->push_const_offset);<br>
ADVANCE_BATCH();<br>
}<br>
@@ -163,9 +152,9 @@ brw_upload_cs_state(struct brw_context *brw)<br>
desc[dw++] = SET_FIELD(push_constant_regs, MEDIA_CURBE_READ_LENGTH);<br>
const uint32_t media_threads =<br>
brw->gen >= 8 ?<br>
- SET_FIELD(threads, GEN8_MEDIA_GPGPU_THREAD_COUNT) :<br>
- SET_FIELD(threads, MEDIA_GPGPU_THREAD_COUNT);<br>
- assert(threads <= brw->max_cs_threads);<br>
+ SET_FIELD(cs_prog_data->threads, GEN8_MEDIA_GPGPU_THREAD_COUNT) :<br>
+ SET_FIELD(cs_prog_data->threads, MEDIA_GPGPU_THREAD_COUNT);<br>
+ assert(cs_prog_data->threads <= brw->max_cs_threads);<br>
<br>
assert(prog_data->total_shared <= 64 * 1024);<br>
uint32_t slm_size = 0;<br>
@@ -247,21 +236,20 @@ brw_upload_cs_push_constants(struct brw_context *brw,<br>
const unsigned param_aligned_count =<br>
reg_aligned_constant_size / sizeof(*param);<br>
<br>
- unsigned threads = get_cs_thread_count(cs_prog_data);<br>
-<br>
param = (gl_constant_value*)<br>
brw_state_batch(brw, type,<br>
- ALIGN(reg_aligned_constant_size * threads, 64),<br>
+ ALIGN(reg_aligned_constant_size *<br>
+ cs_prog_data->threads, 64),<br>
64, &stage_state->push_const_offset);<br>
assert(param);<br>
<br>
STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));<br>
<br>
- brw_cs_fill_local_id_payload(cs_prog_data, param, threads,<br>
+ brw_cs_fill_local_id_payload(cs_prog_data, param, cs_prog_data->threads,<br>
reg_aligned_constant_size);<br>
<br>
/* _NEW_PROGRAM_CONSTANTS */<br>
- for (t = 0; t < threads; t++) {<br>
+ for (t = 0; t < cs_prog_data->threads; t++) {<br>
gl_constant_value *next_param =<br>
¶m[t * param_aligned_count + local_id_dwords];<br>
for (i = 0; i < prog_data->nr_params; i++) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.8.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>