[Mesa-dev] [RFC 1/4] gallium: add compute shader IR type
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Fri Mar 25 01:43:47 UTC 2016
Needed to distinguish NATIVE and TGSI compute shaders on
compute state creation.
Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
---
src/gallium/drivers/trace/tr_dump_state.c | 2 ++
src/gallium/include/pipe/p_state.h | 1 +
src/gallium/state_trackers/clover/core/kernel.cpp | 1 +
src/gallium/tests/trivial/compute.c | 1 +
src/mesa/state_tracker/st_program.c | 1 +
5 files changed, 6 insertions(+)
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index 0627e5a..394cdaa 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -317,6 +317,8 @@ void trace_dump_compute_state(const struct pipe_compute_state *state)
trace_dump_struct_begin("pipe_compute_state");
+ trace_dump_member(uint, state, ir_type);
+
trace_dump_member_begin("prog");
if (state->prog) {
static char str[64 * 1024];
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 2e720ce..8e7a10b 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -727,6 +727,7 @@ struct pipe_llvm_program_header
struct pipe_compute_state
{
+ unsigned ir_type; /**< IR type contained in prog. */
const void *prog; /**< Compute program to be executed. */
unsigned req_local_mem; /**< Required size of the LOCAL resource. */
unsigned req_private_mem; /**< Required size of the PRIVATE resource. */
diff --git a/src/gallium/state_trackers/clover/core/kernel.cpp b/src/gallium/state_trackers/clover/core/kernel.cpp
index c12755b..bce3b52 100644
--- a/src/gallium/state_trackers/clover/core/kernel.cpp
+++ b/src/gallium/state_trackers/clover/core/kernel.cpp
@@ -223,6 +223,7 @@ kernel::exec_context::bind(intrusive_ptr<command_queue> _q,
if (st)
_q->pipe->delete_compute_state(_q->pipe, st);
+ cs.ir_type = q->device().ir_format();
cs.prog = &(msec.data[0]);
cs.req_local_mem = mem_local;
cs.req_input_mem = input.size();
diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c
index 5d5e0b0..2ddfc42 100644
--- a/src/gallium/tests/trivial/compute.c
+++ b/src/gallium/tests/trivial/compute.c
@@ -144,6 +144,7 @@ static void init_prog(struct context *ctx, unsigned local_sz,
struct pipe_context *pipe = ctx->pipe;
struct tgsi_token prog[1024];
struct pipe_compute_state cs = {
+ .ir_type = PIPE_SHADER_IR_TGSI,
.prog = prog,
.req_local_mem = local_sz,
.req_private_mem = private_sz,
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 80dcfd8..5e282d9 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1435,6 +1435,7 @@ st_translate_compute_program(struct st_context *st,
st_translate_program_common(st, &stcp->Base.Base, stcp->glsl_to_tgsi, ureg,
TGSI_PROCESSOR_COMPUTE, &prog);
+ stcp->tgsi.ir_type = PIPE_SHADER_IR_TGSI;
stcp->tgsi.prog = prog.tokens;
stcp->tgsi.req_local_mem = stcp->Base.SharedSize;
stcp->tgsi.req_private_mem = 0;
--
2.7.4
More information about the mesa-dev
mailing list