summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>2020-02-19 10:47:20 -0600
committerMarge Bot <eric+marge@anholt.net>2020-08-12 10:11:06 +0000
commite2b6ccbdadd9438eab60ba7dbf8c0d870079c839 (patch)
tree186346f4da1268e84cff6f3f044c47f6128fa824
parent8e1de8e5ac90a9dd0a2fb9310cb36371a9d12dce (diff)
intel/compiler: Use C99 array initializers for prog_data/key sizes
This is way better than a pile of STATIC_ASSERTs. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6280>
-rw-r--r--src/intel/compiler/brw_compiler.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/intel/compiler/brw_compiler.c b/src/intel/compiler/brw_compiler.c
index a75e86346bf..e58ed67900b 100644
--- a/src/intel/compiler/brw_compiler.c
+++ b/src/intel/compiler/brw_compiler.c
@@ -240,19 +240,13 @@ brw_get_compiler_config_value(const struct brw_compiler *compiler)
unsigned
brw_prog_data_size(gl_shader_stage stage)
{
- STATIC_ASSERT(MESA_SHADER_VERTEX == 0);
- STATIC_ASSERT(MESA_SHADER_TESS_CTRL == 1);
- STATIC_ASSERT(MESA_SHADER_TESS_EVAL == 2);
- STATIC_ASSERT(MESA_SHADER_GEOMETRY == 3);
- STATIC_ASSERT(MESA_SHADER_FRAGMENT == 4);
- STATIC_ASSERT(MESA_SHADER_COMPUTE == 5);
static const size_t stage_sizes[] = {
- sizeof(struct brw_vs_prog_data),
- sizeof(struct brw_tcs_prog_data),
- sizeof(struct brw_tes_prog_data),
- sizeof(struct brw_gs_prog_data),
- sizeof(struct brw_wm_prog_data),
- sizeof(struct brw_cs_prog_data),
+ [MESA_SHADER_VERTEX] = sizeof(struct brw_vs_prog_data),
+ [MESA_SHADER_TESS_CTRL] = sizeof(struct brw_tcs_prog_data),
+ [MESA_SHADER_TESS_EVAL] = sizeof(struct brw_tes_prog_data),
+ [MESA_SHADER_GEOMETRY] = sizeof(struct brw_gs_prog_data),
+ [MESA_SHADER_FRAGMENT] = sizeof(struct brw_wm_prog_data),
+ [MESA_SHADER_COMPUTE] = sizeof(struct brw_cs_prog_data),
};
assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes));
return stage_sizes[stage];
@@ -262,12 +256,12 @@ unsigned
brw_prog_key_size(gl_shader_stage stage)
{
static const size_t stage_sizes[] = {
- sizeof(struct brw_vs_prog_key),
- sizeof(struct brw_tcs_prog_key),
- sizeof(struct brw_tes_prog_key),
- sizeof(struct brw_gs_prog_key),
- sizeof(struct brw_wm_prog_key),
- sizeof(struct brw_cs_prog_key),
+ [MESA_SHADER_VERTEX] = sizeof(struct brw_vs_prog_key),
+ [MESA_SHADER_TESS_CTRL] = sizeof(struct brw_tcs_prog_key),
+ [MESA_SHADER_TESS_EVAL] = sizeof(struct brw_tes_prog_key),
+ [MESA_SHADER_GEOMETRY] = sizeof(struct brw_gs_prog_key),
+ [MESA_SHADER_FRAGMENT] = sizeof(struct brw_wm_prog_key),
+ [MESA_SHADER_COMPUTE] = sizeof(struct brw_cs_prog_key),
};
assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes));
return stage_sizes[stage];