"GGTT PT");
dword_out(aub, 1);
dword_out(aub, 0);
+
+ aub->next_context_handle = 1;
}
void
aub->has_default_setup = true;
}
+static struct aub_context *
+aub_context_new(struct aub_file *aub, uint32_t new_id)
+{
+ assert(aub->num_contexts < MAX_CONTEXT_COUNT);
+
+ struct aub_context *ctx = &aub->contexts[aub->num_contexts++];
+
+ ctx->id = new_id;
+ memset(ctx, 0, sizeof(*ctx));
+
+ return ctx;
+}
+
+uint32_t
+aub_write_context_create(struct aub_file *aub, uint32_t *ctx_id)
+{
+ uint32_t new_id = ctx_id ? *ctx_id : aub->next_context_handle;
+
+ aub_context_new(aub, new_id);
+
+ if (!ctx_id)
+ aub->next_context_handle++;
+
+ return new_id;
+}
+
+static struct aub_context *
+aub_context_find(struct aub_file *aub, uint32_t id)
+{
+ for (int i = 0; i < aub->num_contexts; i++) {
+ if (aub->contexts[i].id == id)
+ return &aub->contexts[i];
+ }
+
+ return NULL;
+}
+
+static struct aub_hw_context *
+aub_write_ensure_context(struct aub_file *aub, uint32_t ctx_id,
+ enum drm_i915_gem_engine_class engine_class)
+{
+ struct aub_context *ctx = aub_context_find(aub, ctx_id);
+ assert(ctx != NULL);
+
+ struct aub_hw_context *hw_ctx = &ctx->hw_contexts[engine_class];
+ if (!hw_ctx->initialized) {
+ /* TODO: initialize context here */
+ }
+
+ return hw_ctx;
+}
+
+static uint64_t
+get_context_descriptor(struct aub_file *aub,
+ const struct engine *cs,
+ struct aub_hw_context *hw_ctx)
+{
+ return cs->hw_class | hw_ctx->pphwsp_addr | CONTEXT_FLAGS;
+}
+
/**
* Break up large objects into multiple writes. Otherwise a 128kb VBO
* would overflow the 16 bits of size field in the packet header and
extern "C" {
#endif
+#define MAX_CONTEXT_COUNT 64
+
struct aub_ppgtt_table {
uint64_t phys_addr;
struct aub_ppgtt_table *subtables[512];
};
+struct aub_hw_context {
+ bool initialized;
+ uint64_t ring_addr;
+ uint64_t pphwsp_addr;
+};
+
+/* GEM context, as seen from userspace */
+struct aub_context {
+ uint32_t id;
+ struct aub_hw_context hw_contexts[I915_ENGINE_CLASS_VIDEO + 1];
+};
+
struct aub_file {
FILE *file;
uint64_t pphwsp_addr;
uint64_t descriptor;
} engine_setup[I915_ENGINE_CLASS_VIDEO_ENHANCE + 1];
+
+ struct aub_context contexts[MAX_CONTEXT_COUNT];
+ int num_contexts;
+
+ uint32_t next_context_handle;
};
void aub_file_init(struct aub_file *aub, FILE *file, FILE *debug, uint16_t pci_id, const char *app_name);
void aub_write_context_execlists(struct aub_file *aub, uint64_t context_addr,
enum drm_i915_gem_engine_class engine_class);
+uint32_t aub_write_context_create(struct aub_file *aub, uint32_t *ctx_id);
+
#ifdef __cplusplus
}
#endif
bo->map = NULL;
}
+static uint32_t
+dump_create_context(int fd, uint32_t *ctx_id)
+{
+ if (!aub_file.file) {
+ aub_file_init(&aub_file, output_file,
+ verbose == 2 ? stdout : NULL,
+ device, program_invocation_short_name);
+ aub_write_default_setup(&aub_file);
+
+ if (verbose)
+ printf("[running, output file %s, chipset id 0x%04x, gen %d]\n",
+ output_filename, device, devinfo.gen);
+ }
+
+ return aub_write_context_create(&aub_file, ctx_id);
+}
+
__attribute__ ((visibility ("default"))) int
close(int fd)
{
return libc_ioctl(fd, request, argp);
}
+ case DRM_IOCTL_I915_GEM_CONTEXT_CREATE: {
+ uint32_t *ctx_id = NULL;
+ struct drm_i915_gem_context_create *create = argp;
+ ret = 0;
+ if (!device_override) {
+ ret = libc_ioctl(fd, request, argp);
+ ctx_id = &create->ctx_id;
+ }
+
+ if (ret == 0)
+ create->ctx_id = dump_create_context(fd, ctx_id);
+
+ return ret;
+ }
+
case DRM_IOCTL_I915_GEM_CREATE: {
struct drm_i915_gem_create *create = argp;