mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 06:50:11 +01:00
intel: add identifier for debug purposes
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3203>
This commit is contained in:
parent
e81de67d85
commit
805b32cab9
3 changed files with 138 additions and 1 deletions
|
|
@ -29,7 +29,12 @@ LOCAL_MODULE := libmesa_intel_dev
|
||||||
|
|
||||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := $(MESA_TOP)/include
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
|
libmesa_git_sha1
|
||||||
|
|
||||||
|
LOCAL_C_INCLUDES := \
|
||||||
|
$(MESA_TOP)/include \
|
||||||
|
$(MESA_TOP)/src
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(DEV_FILES)
|
LOCAL_SRC_FILES := $(DEV_FILES)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,12 @@
|
||||||
* miscellaneous debugging code.
|
* miscellaneous debugging code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "dev/gen_debug.h"
|
#include "dev/gen_debug.h"
|
||||||
|
#include "git_sha1.h"
|
||||||
#include "util/macros.h"
|
#include "util/macros.h"
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
#include "c11/threads.h"
|
#include "c11/threads.h"
|
||||||
|
|
@ -123,3 +126,96 @@ brw_process_intel_debug_variable(void)
|
||||||
call_once(&process_intel_debug_variable_flag,
|
call_once(&process_intel_debug_variable_flag,
|
||||||
brw_process_intel_debug_variable_once);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,42 @@ extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
|
||||||
|
|
||||||
extern void brw_process_intel_debug_variable(void);
|
extern void brw_process_intel_debug_variable(void);
|
||||||
|
|
||||||
|
/* Below is a list of structure located in the identifier buffer. The driver
|
||||||
|
* can fill those in for debug purposes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum gen_debug_block_type {
|
||||||
|
/* End of the debug blocks */
|
||||||
|
GEN_DEBUG_BLOCK_TYPE_END = 1,
|
||||||
|
|
||||||
|
/* Driver identifier (struct gen_debug_block_driver) */
|
||||||
|
GEN_DEBUG_BLOCK_TYPE_DRIVER,
|
||||||
|
|
||||||
|
/* Internal, never to be written out */
|
||||||
|
GEN_DEBUG_BLOCK_TYPE_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gen_debug_block_base {
|
||||||
|
uint32_t type; /* enum gen_debug_block_type */
|
||||||
|
uint32_t length; /* inclusive of this structure size */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gen_debug_block_driver {
|
||||||
|
struct gen_debug_block_base base;
|
||||||
|
uint8_t description[];
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void *intel_debug_identifier(void);
|
||||||
|
extern uint32_t intel_debug_identifier_size(void);
|
||||||
|
|
||||||
|
extern uint32_t intel_debug_write_identifiers(void *output,
|
||||||
|
uint32_t output_size,
|
||||||
|
const char *driver_name);
|
||||||
|
|
||||||
|
extern void *intel_debug_get_identifier_block(void *buffer,
|
||||||
|
uint32_t buffer_size,
|
||||||
|
enum gen_debug_block_type type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue