i965: Add a function to translate MESA_SHADER_* into DEBUG_* enums.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 19 Feb 2015 01:31:29 +0000 (17:31 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 19 Feb 2015 23:15:45 +0000 (15:15 -0800)
When compiling, we have a gl_shader_stage (MESA_SHADER_*) enum, and want
to know whether debugging is enabled for that stage.  This allows us to
easily translate it into the corresponding debug flag.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/dri/i965/intel_debug.c
src/mesa/drivers/dri/i965/intel_debug.h

index 013602c4abeb13316e68a6b75657e22db5b0f144..0cb7aef3231330df258616c77b3b4e22b838216a 100644 (file)
@@ -72,6 +72,19 @@ static const struct dri_debug_control debug_control[] = {
    { NULL,    0 }
 };
 
+uint64_t
+intel_debug_flag_for_shader_stage(gl_shader_stage stage)
+{
+   int flags[] = {
+      [MESA_SHADER_VERTEX] = DEBUG_VS,
+      [MESA_SHADER_GEOMETRY] = DEBUG_GS,
+      [MESA_SHADER_FRAGMENT] = DEBUG_WM,
+      [MESA_SHADER_COMPUTE] = 0, /* no debug flag yet */
+   };
+   STATIC_ASSERT(MESA_SHADER_STAGES == 4);
+   return flags[stage];
+}
+
 void
 brw_process_intel_debug_variable(struct brw_context *brw)
 {
index 01b4dcfd3fed721cf0c170dc14ce6c44b83ce649..ed879aba8d36fe132280f36246a8ef2b36e1e592 100644 (file)
@@ -110,6 +110,8 @@ extern uint64_t INTEL_DEBUG;
    }                                                            \
 } while (0)
 
+extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
+
 struct brw_context;
 
 extern void brw_process_intel_debug_variable(struct brw_context *brw);