Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / intel / dev / gen_debug.c
index b0d0d1a574a9dd2cc6f30d9fa9acf24df75498e1..3671ba10a321aad7526eb3e3bd282342ad8b69b9 100644 (file)
  * miscellaneous debugging code.
  */
 
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "dev/gen_debug.h"
+#include "git_sha1.h"
 #include "util/macros.h"
 #include "util/debug.h"
 #include "c11/threads.h"
@@ -86,6 +89,13 @@ static const struct debug_control debug_control[] = {
    { "color",       DEBUG_COLOR },
    { "reemit",      DEBUG_REEMIT },
    { "soft64",      DEBUG_SOFT64 },
+   { "tcs8",        DEBUG_TCS_EIGHT_PATCH },
+   { "bt",          DEBUG_BT },
+   { "pc",          DEBUG_PIPE_CONTROL },
+   { "nofc",        DEBUG_NO_FAST_CLEAR },
+   { "no32",        DEBUG_NO32 },
+   { "shaders",     DEBUG_WM | DEBUG_VS | DEBUG_TCS |
+                    DEBUG_TES | DEBUG_GS | DEBUG_CS },
    { NULL,    0 }
 };
 
@@ -118,3 +128,108 @@ brw_process_intel_debug_variable(void)
    call_once(&process_intel_debug_variable_flag,
              brw_process_intel_debug_variable_once);
 }
+
+static uint64_t debug_identifier[4] = {
+   0xffeeddccbbaa9988,
+   0x7766554433221100,
+   0xffeeddccbbaa9988,
+   0x7766554433221100,
+};
+
+void *
+intel_debug_identifier(void)
+{
+   return debug_identifier;
+}
+
+uint32_t
+intel_debug_identifier_size(void)
+{
+   return sizeof(debug_identifier);
+}
+
+uint32_t
+intel_debug_write_identifiers(void *_output,
+                              uint32_t output_size,
+                              const char *driver_name)
+{
+   void *output = _output, *output_end = _output + output_size;
+
+   assert(output_size > intel_debug_identifier_size());
+
+   memcpy(output, intel_debug_identifier(), intel_debug_identifier_size());
+   output += intel_debug_identifier_size();
+
+   for (uint32_t id = GEN_DEBUG_BLOCK_TYPE_DRIVER; id < GEN_DEBUG_BLOCK_TYPE_MAX; id++) {
+      switch (id) {
+      case GEN_DEBUG_BLOCK_TYPE_DRIVER: {
+         struct gen_debug_block_driver driver_desc = {
+            .base = {
+               .type = id,
+            },
+         };
+         int len = snprintf(output + sizeof(driver_desc),
+                            output_end - (output + sizeof(driver_desc)),
+                            "%s " PACKAGE_VERSION " build " MESA_GIT_SHA1,
+                            driver_name);
+         driver_desc.base.length = sizeof(driver_desc) + len + 1;
+         memcpy(output, &driver_desc, sizeof(driver_desc));
+         output += driver_desc.base.length;
+         break;
+      }
+
+      case GEN_DEBUG_BLOCK_TYPE_FRAME: {
+         struct gen_debug_block_frame frame_desc = {
+            .base = {
+               .type = GEN_DEBUG_BLOCK_TYPE_FRAME,
+               .length = sizeof(frame_desc),
+            },
+         };
+         memcpy(output, &frame_desc, sizeof(frame_desc));
+         output += sizeof(frame_desc);
+         break;
+      }
+
+      default:
+         unreachable("Missing identifier write");
+      }
+
+      assert(output < output_end);
+   }
+
+   struct gen_debug_block_base end = {
+      .type = GEN_DEBUG_BLOCK_TYPE_END,
+      .length = sizeof(end),
+   };
+   memcpy(output, &end, sizeof(end));
+   output += sizeof(end);
+
+   assert(output < output_end);
+
+   /* Return the how many bytes where written, so that the rest of the buffer
+    * can be used for other things.
+    */
+   return output - _output;
+}
+
+void *
+intel_debug_get_identifier_block(void *_buffer,
+                                 uint32_t buffer_size,
+                                 enum gen_debug_block_type type)
+{
+   void *buffer = _buffer + intel_debug_identifier_size(),
+      *end_buffer = _buffer + buffer_size;
+
+   while (buffer < end_buffer) {
+      struct gen_debug_block_base *item = buffer;
+
+      if (item->type == type)
+         return item;
+      if (item->type == GEN_DEBUG_BLOCK_TYPE_END)
+         return NULL;
+
+      buffer += item->length;
+   }
+
+   return NULL;
+}