* Chia-I Wu <olv@lunarg.com>
*/
-#include "intel_chipset.h"
+#include "util/u_upload_mgr.h"
-#include "ilo_3d.h"
#include "ilo_blit.h"
+#include "ilo_blitter.h"
#include "ilo_cp.h"
+#include "ilo_draw.h"
#include "ilo_gpgpu.h"
#include "ilo_query.h"
+#include "ilo_render.h"
#include "ilo_resource.h"
#include "ilo_screen.h"
#include "ilo_shader.h"
#include "ilo_state.h"
+#include "ilo_transfer.h"
#include "ilo_video.h"
#include "ilo_context.h"
static void
-ilo_context_new_cp_batch(struct ilo_cp *cp, void *data)
-{
-}
-
-static void
-ilo_context_pre_cp_flush(struct ilo_cp *cp, void *data)
-{
-}
-
-static void
-ilo_context_post_cp_flush(struct ilo_cp *cp, void *data)
+ilo_context_cp_submitted(struct ilo_cp *cp, void *data)
{
struct ilo_context *ilo = ilo_context(data);
- if (ilo->last_cp_bo)
- ilo->last_cp_bo->unreference(ilo->last_cp_bo);
-
- /* remember the just flushed bo, on which fences could wait */
- ilo->last_cp_bo = cp->bo;
- ilo->last_cp_bo->reference(ilo->last_cp_bo);
+ /* builder buffers are reallocated */
+ ilo_render_invalidate_builder(ilo->render);
}
static void
ilo_flush(struct pipe_context *pipe,
struct pipe_fence_handle **f,
- enum pipe_flush_flags flags)
+ unsigned flags)
{
struct ilo_context *ilo = ilo_context(pipe);
- if (f) {
- struct ilo_fence *fence;
+ ilo_cp_submit(ilo->cp,
+ (flags & PIPE_FLUSH_END_OF_FRAME) ? "frame end" : "user request");
- fence = CALLOC_STRUCT(ilo_fence);
- if (fence) {
- pipe_reference_init(&fence->reference, 1);
+ if (f) {
+ struct pipe_screen *screen = pipe->screen;
+ screen->fence_reference(screen, f, NULL);
+ *f = ilo_screen_fence_create(pipe->screen, ilo->cp->last_submitted_bo);
+ }
+}
- /* reference the batch bo that we want to wait on */
- if (ilo_cp_empty(ilo->cp))
- fence->bo = ilo->last_cp_bo;
- else
- fence->bo = ilo->cp->bo;
+static void
+ilo_render_condition(struct pipe_context *pipe,
+ struct pipe_query *query,
+ boolean condition,
+ uint mode)
+{
+ struct ilo_context *ilo = ilo_context(pipe);
- if (fence->bo)
- fence->bo->reference(fence->bo);
- }
+ /* reference count? */
+ ilo->render_condition.query = query;
+ ilo->render_condition.condition = condition;
+ ilo->render_condition.mode = mode;
+}
- *f = (struct pipe_fence_handle *) fence;
+bool
+ilo_skip_rendering(struct ilo_context *ilo)
+{
+ uint64_t result;
+ bool wait;
+
+ if (!ilo->render_condition.query)
+ return false;
+
+ switch (ilo->render_condition.mode) {
+ case PIPE_RENDER_COND_WAIT:
+ case PIPE_RENDER_COND_BY_REGION_WAIT:
+ wait = true;
+ break;
+ case PIPE_RENDER_COND_NO_WAIT:
+ case PIPE_RENDER_COND_BY_REGION_NO_WAIT:
+ default:
+ wait = false;
+ break;
}
- ilo_cp_flush(ilo->cp);
+ if (ilo->base.get_query_result(&ilo->base, ilo->render_condition.query,
+ wait, (union pipe_query_result *) &result))
+ return ((bool) result == ilo->render_condition.condition);
+ else
+ return false;
}
static void
{
struct ilo_context *ilo = ilo_context(pipe);
- if (ilo->last_cp_bo)
- ilo->last_cp_bo->unreference(ilo->last_cp_bo);
+ ilo_state_vector_cleanup(&ilo->state_vector);
+
+ if (ilo->uploader)
+ u_upload_destroy(ilo->uploader);
+ if (ilo->blitter)
+ ilo_blitter_destroy(ilo->blitter);
+ if (ilo->render)
+ ilo_render_destroy(ilo->render);
if (ilo->shader_cache)
ilo_shader_cache_destroy(ilo->shader_cache);
if (ilo->cp)
ilo_cp_destroy(ilo->cp);
+ util_slab_destroy(&ilo->transfer_mempool);
+
FREE(ilo);
}
static struct pipe_context *
-ilo_context_create(struct pipe_screen *screen, void *priv)
+ilo_context_create(struct pipe_screen *screen, void *priv, unsigned flags)
{
struct ilo_screen *is = ilo_screen(screen);
struct ilo_context *ilo;
if (!ilo)
return NULL;
- ilo->winsys = is->winsys;
- ilo->devid = is->devid;
- ilo->gen = is->gen;
-
- if (IS_SNB_GT1(ilo->devid) ||
- IS_IVB_GT1(ilo->devid) ||
- IS_HSW_GT1(ilo->devid) ||
- IS_BAYTRAIL(ilo->devid))
- ilo->gt = 1;
- else if (IS_SNB_GT2(ilo->devid) ||
- IS_IVB_GT2(ilo->devid) ||
- IS_HSW_GT2(ilo->devid))
- ilo->gt = 2;
- else
- ilo->gt = 0;
-
- /* stolen from classic i965 */
- /* WM maximum threads is number of EUs times number of threads per EU. */
- if (ilo->gen >= ILO_GEN(7)) {
- if (ilo->gt == 1) {
- ilo->max_wm_threads = 48;
- ilo->max_vs_threads = 36;
- ilo->max_gs_threads = 36;
- ilo->urb.size = 128;
- ilo->urb.max_vs_entries = 512;
- ilo->urb.max_gs_entries = 192;
- } else if (ilo->gt == 2) {
- ilo->max_wm_threads = 172;
- ilo->max_vs_threads = 128;
- ilo->max_gs_threads = 128;
- ilo->urb.size = 256;
- ilo->urb.max_vs_entries = 704;
- ilo->urb.max_gs_entries = 320;
- } else {
- assert(!"Unknown gen7 device.");
- }
- } else if (ilo->gen == ILO_GEN(6)) {
- if (ilo->gt == 2) {
- ilo->max_wm_threads = 80;
- ilo->max_vs_threads = 60;
- ilo->max_gs_threads = 60;
- ilo->urb.size = 64; /* volume 5c.5 section 5.1 */
- ilo->urb.max_vs_entries = 256; /* volume 2a (see 3DSTATE_URB) */
- ilo->urb.max_gs_entries = 256;
- } else {
- ilo->max_wm_threads = 40;
- ilo->max_vs_threads = 24;
- ilo->max_gs_threads = 21; /* conservative; 24 if rendering disabled */
- ilo->urb.size = 32; /* volume 5c.5 section 5.1 */
- ilo->urb.max_vs_entries = 256; /* volume 2a (see 3DSTATE_URB) */
- ilo->urb.max_gs_entries = 256;
- }
- }
+ ilo->winsys = is->dev.winsys;
+ ilo->dev = &is->dev;
- ilo->cp = ilo_cp_create(ilo->winsys, is->has_llc);
- ilo->shader_cache = ilo_shader_cache_create(ilo->winsys);
+ /*
+ * initialize first, otherwise it may not be safe to call
+ * ilo_context_destroy() on errors
+ */
+ util_slab_create(&ilo->transfer_mempool,
+ sizeof(struct ilo_transfer), 64, UTIL_SLAB_SINGLETHREADED);
- if (!ilo->cp || !ilo->shader_cache) {
+ ilo->shader_cache = ilo_shader_cache_create();
+ ilo->cp = ilo_cp_create(ilo->dev, ilo->winsys, ilo->shader_cache);
+ if (ilo->cp)
+ ilo->render = ilo_render_create(&ilo->cp->builder);
+
+ if (!ilo->cp || !ilo->shader_cache || !ilo->render) {
ilo_context_destroy(&ilo->base);
return NULL;
}
- ilo_cp_set_hook(ilo->cp, ILO_CP_HOOK_NEW_BATCH,
- ilo_context_new_cp_batch, (void *) ilo);
- ilo_cp_set_hook(ilo->cp, ILO_CP_HOOK_PRE_FLUSH,
- ilo_context_pre_cp_flush, (void *) ilo);
- ilo_cp_set_hook(ilo->cp, ILO_CP_HOOK_POST_FLUSH,
- ilo_context_post_cp_flush, (void *) ilo);
-
- ilo->dirty = ILO_DIRTY_ALL;
+ ilo_cp_set_submit_callback(ilo->cp,
+ ilo_context_cp_submitted, (void *) ilo);
ilo->base.screen = screen;
ilo->base.priv = priv;
ilo->base.destroy = ilo_context_destroy;
ilo->base.flush = ilo_flush;
+ ilo->base.render_condition = ilo_render_condition;
- ilo_init_3d_functions(ilo);
+ ilo_init_draw_functions(ilo);
ilo_init_query_functions(ilo);
ilo_init_state_functions(ilo);
ilo_init_blit_functions(ilo);
ilo_init_video_functions(ilo);
ilo_init_gpgpu_functions(ilo);
+ ilo_init_draw(ilo);
+ ilo_state_vector_init(ilo->dev, &ilo->state_vector);
+
+ /*
+ * These must be called last as u_upload/u_blitter are clients of the pipe
+ * context.
+ */
+ ilo->uploader = u_upload_create(&ilo->base, 1024 * 1024, 16,
+ PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_INDEX_BUFFER);
+ if (!ilo->uploader) {
+ ilo_context_destroy(&ilo->base);
+ return NULL;
+ }
+
+ ilo->blitter = ilo_blitter_create(ilo);
+ if (!ilo->blitter) {
+ ilo_context_destroy(&ilo->base);
+ return NULL;
+ }
+
return &ilo->base;
}