intel/compiler: Add functions to get prog_data and prog_key sizes for a stage
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 21 Oct 2017 08:30:13 +0000 (01:30 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Wed, 1 Nov 2017 06:36:54 +0000 (23:36 -0700)
v2:
 * Return unsigned instead of size_t. (Ken)

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/compiler/brw_compiler.c
src/intel/compiler/brw_compiler.h

index 2f6af7d2c3f46c17582835f00b78cb1e2cc59ea4..f6120cbf0aca7957fc4a6ff06217e164ed1b2f38 100644 (file)
@@ -168,3 +168,39 @@ brw_compiler_create(void *mem_ctx, const struct gen_device_info *devinfo)
 
    return 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),
+   };
+   assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes));
+   return stage_sizes[stage];
+}
+
+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),
+   };
+   assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes));
+   return stage_sizes[stage];
+}
index 2bb7111ad538b75c26fdf20c76d809993be913b8..ede3d1508a1868f15f94f4095c779dbc1d6cac6f 100644 (file)
@@ -1109,6 +1109,12 @@ DEFINE_PROG_DATA_DOWNCAST(sf)
 struct brw_compiler *
 brw_compiler_create(void *mem_ctx, const struct gen_device_info *devinfo);
 
+unsigned
+brw_prog_data_size(gl_shader_stage stage);
+
+unsigned
+brw_prog_key_size(gl_shader_stage stage);
+
 /**
  * Compile a vertex shader.
  *