setup_locals(&ctx, func);
- if (nir->info.stage == MESA_SHADER_COMPUTE)
+ if (gl_shader_stage_is_compute(nir->info.stage))
setup_shared(&ctx, nir);
visit_cf_list(&ctx, &func->impl->body);
phi_post_pass(&ctx);
- if (nir->info.stage != MESA_SHADER_COMPUTE)
+ if (!gl_shader_stage_is_compute(nir->info.stage))
ctx.abi->emit_outputs(ctx.abi, AC_LLVM_MAX_OUTPUTS,
ctx.abi->outputs);
break;
case nir_var_mem_shared:
- assert(shader->info.stage == MESA_SHADER_COMPUTE);
+ assert(gl_shader_stage_is_compute(shader->info.stage));
exec_list_push_tail(&shader->shared, &var->node);
break;
case MESA_SHADER_TESS_CTRL:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_KERNEL:
default:
/* TODO */
break;
if (shader->info.label)
fprintf(fp, "label: %s\n", shader->info.label);
- switch (shader->info.stage) {
- case MESA_SHADER_COMPUTE:
+ if (gl_shader_stage_is_compute(shader->info.stage)) {
fprintf(fp, "local-size: %u, %u, %u%s\n",
shader->info.cs.local_size[0],
shader->info.cs.local_size[1],
shader->info.cs.local_size[2],
shader->info.cs.local_size_variable ? " (variable)" : "");
fprintf(fp, "shared-size: %u\n", shader->info.cs.shared_size);
- break;
- default:
- break;
}
fprintf(fp, "inputs: %u\n", shader->num_inputs);
ENUM(MESA_SHADER_GEOMETRY),
ENUM(MESA_SHADER_FRAGMENT),
ENUM(MESA_SHADER_COMPUTE),
+ ENUM(MESA_SHADER_KERNEL),
};
- STATIC_ASSERT(ARRAY_SIZE(names) == MESA_SHADER_STAGES);
+ STATIC_ASSERT(ARRAY_SIZE(names) == MESA_ALL_SHADER_STAGES);
return NAME(stage);
}
case MESA_SHADER_FRAGMENT: return "fragment";
case MESA_SHADER_GEOMETRY: return "geometry";
case MESA_SHADER_COMPUTE: return "compute";
+ case MESA_SHADER_KERNEL: return "kernel";
case MESA_SHADER_TESS_CTRL: return "tessellation control";
case MESA_SHADER_TESS_EVAL: return "tessellation evaluation";
}
case MESA_SHADER_FRAGMENT: return "FS";
case MESA_SHADER_GEOMETRY: return "GS";
case MESA_SHADER_COMPUTE: return "CS";
+ case MESA_SHADER_KERNEL: return "CL";
case MESA_SHADER_TESS_CTRL: return "TCS";
case MESA_SHADER_TESS_EVAL: return "TES";
}
#ifndef SHADER_ENUMS_H
#define SHADER_ENUMS_H
+#include <stdbool.h>
+
#ifdef __cplusplus
extern "C" {
#endif
MESA_SHADER_GEOMETRY = 3,
MESA_SHADER_FRAGMENT = 4,
MESA_SHADER_COMPUTE = 5,
+ /* must be last so it doesn't affect the GL pipeline */
+ MESA_SHADER_KERNEL = 6,
} gl_shader_stage;
+static inline bool
+gl_shader_stage_is_compute(gl_shader_stage stage)
+{
+ return stage == MESA_SHADER_COMPUTE || stage == MESA_SHADER_KERNEL;
+}
+
/**
* Number of STATE_* values we need to address any GL state.
* Used to dimension arrays.
*/
const char *_mesa_shader_stage_to_abbrev(unsigned stage);
+/**
+ * GL related stages (not including CL)
+ */
#define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
+/**
+ * All stages
+ */
+#define MESA_ALL_SHADER_STAGES (MESA_SHADER_KERNEL + 1)
+
/**
* Indexes for vertex program attributes.
break;
case SpvExecutionModeLocalSize:
- vtn_assert(b->shader->info.stage == MESA_SHADER_COMPUTE);
+ vtn_assert(gl_shader_stage_is_compute(b->shader->info.stage));
b->shader->info.cs.local_size[0] = mode->literals[0];
b->shader->info.cs.local_size[1] = mode->literals[1];
b->shader->info.cs.local_size[2] = mode->literals[2];
[MESA_SHADER_FRAGMENT] = 24, // TODO
[MESA_SHADER_VERTEX] = 16,
[MESA_SHADER_COMPUTE] = 16, // TODO how many do we actually need?
+ [MESA_SHADER_KERNEL] = 16, // TODO how many do we actually need?
};
static void
return CP_LOAD_STATE6_GEOM;
case MESA_SHADER_FRAGMENT:
case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_KERNEL:
return CP_LOAD_STATE6_FRAG;
default:
unreachable("bad shader type");
case MESA_SHADER_FRAGMENT:
return SB6_FS_SHADER;
case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_KERNEL:
return SB6_CS_SHADER;
default:
unreachable("bad shader type");
break;
case MESA_SHADER_FRAGMENT:
case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_KERNEL:
opcode = CP_LOAD_STATE6_FRAG;
break;
default:
case MESA_SHADER_FRAGMENT:
return SB4_FS_SHADER;
case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_KERNEL:
return SB4_CS_SHADER;
default:
unreachable("bad shader type");
ir3_glsl_type_size);
break;
case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_KERNEL:
break;
default:
errx(1, "unhandled shader stage: %d", stage);
ir3_emit_cs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring,
struct fd_context *ctx, const struct pipe_grid_info *info)
{
- debug_assert(v->type == MESA_SHADER_COMPUTE);
+ debug_assert(gl_shader_stage_is_compute(v->type));
emit_common_consts(v, ring, ctx, PIPE_SHADER_COMPUTE);
}
}
- if (nir->info.stage == MESA_SHADER_COMPUTE) {
+ if (gl_shader_stage_is_compute(nir->info.stage)) {
info->properties[TGSI_PROPERTY_CS_FIXED_BLOCK_WIDTH] = nir->info.cs.local_size[0];
info->properties[TGSI_PROPERTY_CS_FIXED_BLOCK_HEIGHT] = nir->info.cs.local_size[1];
info->properties[TGSI_PROPERTY_CS_FIXED_BLOCK_DEPTH] = nir->info.cs.local_size[2];
ctx->num_images = util_last_bit(info->images_declared);
if (ctx->shader->selector->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE]) {
- assert(nir->info.stage == MESA_SHADER_COMPUTE);
+ assert(gl_shader_stage_is_compute(nir->info.stage));
si_declare_compute_memory(ctx);
}
ac_nir_translate(&ctx->ac, &ctx->abi, nir);
return GL_TESS_EVALUATION_SUBROUTINE;
case MESA_SHADER_NONE:
break;
+ case MESA_SHADER_KERNEL:
+ unreachable("not reached");
+ break;
}
unreachable("not reached");
}
case MESA_SHADER_TESS_EVAL:
return GL_TESS_EVALUATION_SUBROUTINE_UNIFORM;
case MESA_SHADER_NONE:
+ case MESA_SHADER_KERNEL:
break;
}
unreachable("not reached");