diff options
author | Kenneth Graunke <[email protected]> | 2013-10-31 15:42:09 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2013-11-21 15:01:13 -0800 |
commit | 379a246fc190c1bc1664a4ecf24aabca13314c7f (patch) | |
tree | cb061fd0a143b113d294175de8c7b7e23b926404 /src | |
parent | b64eb100b0c74d1d601f646bb2fe6175fa722450 (diff) |
i965: Add basic driver hooks and plumbing for AMD_performance_monitor.
These stub functions will be filled out in later patches.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/Makefile.sources | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_performance_monitor.c | 219 |
4 files changed, 228 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index ac1363c776b..193f2db3bc7 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -73,6 +73,7 @@ i965_FILES = \ brw_lower_unnormalized_offset.cpp \ brw_misc_state.c \ brw_object_purgeable.c \ + brw_performance_monitor.c \ brw_program.c \ brw_primitive_restart.c \ brw_queryobj.c \ diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index d1f3ce12c3c..4e09038477c 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -801,6 +801,10 @@ brwCreateContext(gl_api api, _mesa_initialize_dispatch_tables(ctx); _mesa_initialize_vbo_vtxfmt(ctx); + if (ctx->Extensions.AMD_performance_monitor) { + brw_init_performance_monitors(brw); + } + return true; } diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index fe9e3a8fa08..8d373ff780b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1613,6 +1613,10 @@ bool brw_is_hiz_depth_format(struct brw_context *ctx, gl_format format); bool brw_render_target_supported(struct brw_context *brw, struct gl_renderbuffer *rb); +/* brw_performance_monitor.c */ +void brw_init_performance_monitors(struct brw_context *brw); +void brw_dump_perf_monitors(struct brw_context *brw); + /* intel_extensions.c */ extern void intelInitExtensions(struct gl_context *ctx); diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c b/src/mesa/drivers/dri/i965/brw_performance_monitor.c new file mode 100644 index 00000000000..c9673c55565 --- /dev/null +++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c @@ -0,0 +1,219 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file brw_performance_monitor.c + * + * Implementation of the GL_AMD_performance_monitor extension. + */ + +#include <limits.h> + +#include "main/bitset.h" +#include "main/hash.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "main/performance_monitor.h" + +#include "glsl/ralloc.h" + +#include "brw_context.h" +#include "brw_defines.h" +#include "intel_batchbuffer.h" + +#define FILE_DEBUG_FLAG DEBUG_PERFMON + +/** + * i965 representation of a performance monitor object. + */ +struct brw_perf_monitor_object +{ + /** The base class. */ + struct gl_perf_monitor_object base; +}; + +/** Downcasting convenience macro. */ +static inline struct brw_perf_monitor_object * +brw_perf_monitor(struct gl_perf_monitor_object *m) +{ + return (struct brw_perf_monitor_object *) m; +} + +/******************************************************************************/ + +static GLboolean brw_is_perf_monitor_result_available(struct gl_context *, struct gl_perf_monitor_object *); + +static void +dump_perf_monitor_callback(GLuint name, void *monitor_void, void *brw_void) +{ + struct gl_context *ctx = brw_void; + struct gl_perf_monitor_object *m = monitor_void; + + DBG("%4d %-7s %-6s %-11s\n", + name, + m->Active ? "Active" : "", + m->Ended ? "Ended" : "", + brw_is_perf_monitor_result_available(ctx, m) ? "Available" : ""); +} + +void +brw_dump_perf_monitors(struct brw_context *brw) +{ + struct gl_context *ctx = &brw->ctx; + DBG("Monitors:\n"); + _mesa_HashWalk(ctx->PerfMonitor.Monitors, dump_perf_monitor_callback, brw); +} + +/******************************************************************************/ + +/** + * Initialize a monitor to sane starting state; throw away old buffers. + */ +static void +reinitialize_perf_monitor(struct brw_context *brw, + struct brw_perf_monitor_object *monitor) +{ +} + +/** + * Driver hook for glBeginPerformanceMonitorAMD(). + */ +static GLboolean +brw_begin_perf_monitor(struct gl_context *ctx, + struct gl_perf_monitor_object *m) +{ + struct brw_context *brw = brw_context(ctx); + struct brw_perf_monitor_object *monitor = brw_perf_monitor(m); + + DBG("Begin(%d)\n", m->Name); + + reinitialize_perf_monitor(brw, monitor); + + return true; +} + +/** + * Driver hook for glEndPerformanceMonitorAMD(). + */ +static void +brw_end_perf_monitor(struct gl_context *ctx, + struct gl_perf_monitor_object *m) +{ + DBG("End(%d)\n", m->Name); +} + +/** + * Reset a performance monitor, throwing away any results. + */ +static void +brw_reset_perf_monitor(struct gl_context *ctx, + struct gl_perf_monitor_object *m) +{ + struct brw_context *brw = brw_context(ctx); + struct brw_perf_monitor_object *monitor = brw_perf_monitor(m); + + reinitialize_perf_monitor(brw, monitor); + + if (m->Active) { + brw_begin_perf_monitor(ctx, m); + } +} + +/** + * Is a performance monitor result available? + */ +static GLboolean +brw_is_perf_monitor_result_available(struct gl_context *ctx, + struct gl_perf_monitor_object *m) +{ + /* ...need to actually check if counters are available, once we have some. */ + + return true; +} + +/** + * Get the performance monitor result. + */ +static void +brw_get_perf_monitor_result(struct gl_context *ctx, + struct gl_perf_monitor_object *m, + GLsizei data_size, + GLuint *data, + GLint *bytes_written) +{ + DBG("GetResult(%d)\n", m->Name); + + /* This hook should only be called when results are available. */ + assert(m->Ended); + + /* Copy data to the supplied array (data). + * + * The output data format is: <group ID, counter ID, value> for each + * active counter. The API allows counters to appear in any order. + */ + GLsizei offset = 0; + + /* ...but, we don't actually expose anything yet, so nothing to do here */ + + if (bytes_written) + *bytes_written = offset * sizeof(uint32_t); +} + +/** + * Create a new performance monitor object. + */ +static struct gl_perf_monitor_object * +brw_new_perf_monitor(struct gl_context *ctx) +{ + return calloc(1, sizeof(struct brw_perf_monitor_object)); +} + +/** + * Delete a performance monitor object. + */ +static void +brw_delete_perf_monitor(struct gl_context *ctx, struct gl_perf_monitor_object *m) +{ + struct brw_perf_monitor_object *monitor = brw_perf_monitor(m); + DBG("Delete(%d)\n", m->Name); + reinitialize_perf_monitor(brw_context(ctx), monitor); + free(monitor); +} + +/******************************************************************************/ + +void +brw_init_performance_monitors(struct brw_context *brw) +{ + struct gl_context *ctx = &brw->ctx; + + ctx->Driver.NewPerfMonitor = brw_new_perf_monitor; + ctx->Driver.DeletePerfMonitor = brw_delete_perf_monitor; + ctx->Driver.BeginPerfMonitor = brw_begin_perf_monitor; + ctx->Driver.EndPerfMonitor = brw_end_perf_monitor; + ctx->Driver.ResetPerfMonitor = brw_reset_perf_monitor; + ctx->Driver.IsPerfMonitorResultAvailable = brw_is_perf_monitor_result_available; + ctx->Driver.GetPerfMonitorResult = brw_get_perf_monitor_result; + + /* ...need to set ctx->PerfMonitor.Groups and ctx->PerfMonitor.NumGroups */ +} |