mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-11 07:00:31 +01:00
radeonsi: si_state_shaders.c -> cpp
We'll add some templates here. Why is `extern "C"` not needed for exported functions? Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13285>
This commit is contained in:
parent
8a42ea69a6
commit
385c9e1caf
5 changed files with 21 additions and 22 deletions
|
|
@ -64,7 +64,7 @@ files_libradeonsi = files(
|
|||
'si_state.h',
|
||||
'si_state_binning.c',
|
||||
'si_state_msaa.c',
|
||||
'si_state_shaders.c',
|
||||
'si_state_shaders.cpp',
|
||||
'si_state_streamout.c',
|
||||
'si_state_viewport.c',
|
||||
'si_test_blit.c',
|
||||
|
|
|
|||
|
|
@ -1572,9 +1572,6 @@ bool si_init_thread_trace(struct si_context *sctx);
|
|||
void si_destroy_thread_trace(struct si_context *sctx);
|
||||
void si_handle_thread_trace(struct si_context *sctx, struct radeon_cmdbuf *rcs);
|
||||
|
||||
/* si_state_shaders.c */
|
||||
struct si_pm4_state *si_build_vgt_shader_config(struct si_screen *screen, union si_vgt_stages_key key);
|
||||
|
||||
/*
|
||||
* common helpers
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -918,7 +918,7 @@ void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first);
|
|||
void si_nir_late_opts(nir_shader *nir);
|
||||
char *si_finalize_nir(struct pipe_screen *screen, void *nirptr);
|
||||
|
||||
/* si_state_shaders.c */
|
||||
/* si_state_shaders.cpp */
|
||||
void gfx9_get_gs_info(struct si_shader_selector *es, struct si_shader_selector *gs,
|
||||
struct gfx9_gs_info *out);
|
||||
bool gfx10_is_ngg_passthrough(struct si_shader *shader);
|
||||
|
|
|
|||
|
|
@ -553,7 +553,8 @@ struct si_fast_udiv_info32 si_compute_fast_udiv_info32(uint32_t D, unsigned num_
|
|||
/* si_state_binning.c */
|
||||
void si_emit_dpbb_state(struct si_context *sctx);
|
||||
|
||||
/* si_state_shaders.c */
|
||||
/* si_state_shaders.cpp */
|
||||
struct si_pm4_state *si_build_vgt_shader_config(struct si_screen *screen, union si_vgt_stages_key key);
|
||||
void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es,
|
||||
unsigned char ir_sha1_cache_key[20]);
|
||||
bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20],
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ static void *si_get_shader_binary(struct si_shader *shader)
|
|||
ptr = write_data(ptr, &shader->info, sizeof(shader->info));
|
||||
ptr = write_chunk(ptr, shader->binary.elf_buffer, shader->binary.elf_size);
|
||||
ptr = write_chunk(ptr, shader->binary.llvm_ir_string, llvm_ir_size);
|
||||
assert((char *)ptr - (char *)buffer == size);
|
||||
assert((char *)ptr - (char *)buffer == (ptrdiff_t)size);
|
||||
|
||||
/* Compute CRC32. */
|
||||
ptr = (uint32_t *)buffer;
|
||||
|
|
@ -283,7 +283,7 @@ bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha
|
|||
disk_cache_compute_key(sscreen->disk_shader_cache, ir_sha1_cache_key, 20, sha1);
|
||||
|
||||
size_t binary_size;
|
||||
uint8_t *buffer = disk_cache_get(sscreen->disk_shader_cache, sha1, &binary_size);
|
||||
uint8_t *buffer = (uint8_t*)disk_cache_get(sscreen->disk_shader_cache, sha1, &binary_size);
|
||||
if (buffer) {
|
||||
if (binary_size >= sizeof(uint32_t) && *((uint32_t *)buffer) == binary_size) {
|
||||
if (si_load_shader_binary(shader, buffer)) {
|
||||
|
|
@ -2206,10 +2206,10 @@ static void si_build_shader_variant(struct si_shader *shader, int thread_index,
|
|||
|
||||
if (thread_index >= 0) {
|
||||
if (low_priority) {
|
||||
assert(thread_index < ARRAY_SIZE(sscreen->compiler_lowp));
|
||||
assert(thread_index < (int)ARRAY_SIZE(sscreen->compiler_lowp));
|
||||
compiler = &sscreen->compiler_lowp[thread_index];
|
||||
} else {
|
||||
assert(thread_index < ARRAY_SIZE(sscreen->compiler));
|
||||
assert(thread_index < (int)ARRAY_SIZE(sscreen->compiler));
|
||||
compiler = &sscreen->compiler[thread_index];
|
||||
}
|
||||
if (!debug->async)
|
||||
|
|
@ -2248,7 +2248,8 @@ static void si_build_shader_variant_low_priority(void *job, void *gdata, int thr
|
|||
si_build_shader_variant(shader, thread_index, true);
|
||||
}
|
||||
|
||||
static const struct si_shader_key zeroed;
|
||||
/* This should be const, but C++ doesn't allow implicit zero-initialization with const. */
|
||||
static struct si_shader_key zeroed;
|
||||
|
||||
static bool si_check_missing_main_part(struct si_screen *sscreen, struct si_shader_selector *sel,
|
||||
struct si_compiler_ctx_state *compiler_state,
|
||||
|
|
@ -2357,7 +2358,7 @@ current_not_ready:
|
|||
simple_mtx_lock(&sel->mutex);
|
||||
|
||||
/* Compute the size of the key without the uniform values. */
|
||||
size_t s = (void*)&key->opt.inlined_uniform_values - (void*)key;
|
||||
size_t s = (uint8_t*)&key->opt.inlined_uniform_values - (uint8_t*)key;
|
||||
int variant_count = 0;
|
||||
const int max_inline_uniforms_variants = 5;
|
||||
|
||||
|
|
@ -2614,7 +2615,7 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind
|
|||
|
||||
assert(!debug->debug_message || debug->async);
|
||||
assert(thread_index >= 0);
|
||||
assert(thread_index < ARRAY_SIZE(sscreen->compiler));
|
||||
assert(thread_index < (int)ARRAY_SIZE(sscreen->compiler));
|
||||
compiler = &sscreen->compiler[thread_index];
|
||||
|
||||
if (!compiler->passes)
|
||||
|
|
@ -2828,7 +2829,7 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
|
|||
sel->nir = tgsi_to_nir(state->tokens, ctx->screen, true);
|
||||
} else {
|
||||
assert(state->type == PIPE_SHADER_IR_NIR);
|
||||
sel->nir = state->ir.nir;
|
||||
sel->nir = (nir_shader*)state->ir.nir;
|
||||
}
|
||||
|
||||
si_nir_scan_shader(sel->nir, &sel->info);
|
||||
|
|
@ -2845,7 +2846,7 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
|
|||
&sel->active_samplers_and_images);
|
||||
|
||||
/* Record which streamout buffers are enabled. */
|
||||
for (i = 0; i < sel->so.num_outputs; i++) {
|
||||
for (unsigned i = 0; i < sel->so.num_outputs; i++) {
|
||||
sel->enabled_streamout_buffer_mask |= (1 << sel->so.output[i].output_buffer)
|
||||
<< (sel->so.output[i].stream * 4);
|
||||
}
|
||||
|
|
@ -2896,14 +2897,14 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
|
|||
switch (sel->info.stage) {
|
||||
case MESA_SHADER_GEOMETRY:
|
||||
/* Only possibilities: POINTS, LINE_STRIP, TRIANGLES */
|
||||
sel->rast_prim = sel->info.base.gs.output_primitive;
|
||||
sel->rast_prim = (enum pipe_prim_type)sel->info.base.gs.output_primitive;
|
||||
if (util_rast_prim_is_triangles(sel->rast_prim))
|
||||
sel->rast_prim = PIPE_PRIM_TRIANGLES;
|
||||
|
||||
sel->gsvs_vertex_size = sel->info.num_outputs * 16;
|
||||
sel->max_gsvs_emit_size = sel->gsvs_vertex_size * sel->info.base.gs.vertices_out;
|
||||
sel->gs_input_verts_per_prim =
|
||||
u_vertices_per_prim(sel->info.base.gs.input_primitive);
|
||||
u_vertices_per_prim((enum pipe_prim_type)sel->info.base.gs.input_primitive);
|
||||
|
||||
/* EN_MAX_VERT_OUT_PER_GS_INSTANCE does not work with tesselation so
|
||||
* we can't split workgroups. Disable ngg if any of the following conditions is true:
|
||||
|
|
@ -3176,7 +3177,7 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
|
|||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
struct si_shader_selector *old_hw_vs = si_get_vs(sctx)->cso;
|
||||
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
|
||||
struct si_shader_selector *sel = state;
|
||||
struct si_shader_selector *sel = (struct si_shader_selector*)state;
|
||||
|
||||
if (sctx->shader.vs.cso == sel)
|
||||
return;
|
||||
|
|
@ -3253,7 +3254,7 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
|
|||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
struct si_shader_selector *old_hw_vs = si_get_vs(sctx)->cso;
|
||||
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
|
||||
struct si_shader_selector *sel = state;
|
||||
struct si_shader_selector *sel = (struct si_shader_selector*)state;
|
||||
bool enable_changed = !!sctx->shader.gs.cso != !!sel;
|
||||
bool ngg_changed;
|
||||
|
||||
|
|
@ -3285,7 +3286,7 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
|
|||
static void si_bind_tcs_shader(struct pipe_context *ctx, void *state)
|
||||
{
|
||||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
struct si_shader_selector *sel = state;
|
||||
struct si_shader_selector *sel = (struct si_shader_selector*)state;
|
||||
bool enable_changed = !!sctx->shader.tcs.cso != !!sel;
|
||||
|
||||
if (sctx->shader.tcs.cso == sel)
|
||||
|
|
@ -3308,7 +3309,7 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state)
|
|||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
struct si_shader_selector *old_hw_vs = si_get_vs(sctx)->cso;
|
||||
struct si_shader *old_hw_vs_variant = si_get_vs(sctx)->current;
|
||||
struct si_shader_selector *sel = state;
|
||||
struct si_shader_selector *sel = (struct si_shader_selector*)state;
|
||||
bool enable_changed = !!sctx->shader.tes.cso != !!sel;
|
||||
|
||||
if (sctx->shader.tes.cso == sel)
|
||||
|
|
@ -3382,7 +3383,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
|
|||
{
|
||||
struct si_context *sctx = (struct si_context *)ctx;
|
||||
struct si_shader_selector *old_sel = sctx->shader.ps.cso;
|
||||
struct si_shader_selector *sel = state;
|
||||
struct si_shader_selector *sel = (struct si_shader_selector*)state;
|
||||
|
||||
/* skip if supplied shader is one already in use */
|
||||
if (old_sel == sel)
|
||||
Loading…
Add table
Reference in a new issue