* screen
*/
+static void
+dd_screen_finalize_nir(struct pipe_screen *_screen, void *nir, bool optimize)
+{
+ struct pipe_screen *screen = dd_screen(_screen)->screen;
+
+ screen->finalize_nir(screen, nir, optimize);
+}
+
static void
dd_screen_destroy(struct pipe_screen *_screen)
{
SCR_INIT(get_compiler_options);
SCR_INIT(get_driver_uuid);
SCR_INIT(get_device_uuid);
+ SCR_INIT(finalize_nir);
#undef SCR_INIT
return screen->get_compiler_options(screen, ir, shader);
}
+static void noop_finalize_nir(struct pipe_screen *pscreen, void *nir, bool optimize)
+{
+}
+
struct pipe_screen *noop_screen_create(struct pipe_screen *oscreen)
{
struct noop_pipe_screen *noop_screen;
screen->query_memory_info = noop_query_memory_info;
screen->get_disk_shader_cache = noop_get_disk_shader_cache;
screen->get_compiler_options = noop_get_compiler_options;
+ screen->finalize_nir = noop_finalize_nir;
return screen;
}
return screen->fence_get_fd(screen, fence);
}
+static void
+rbug_screen_finalize_nir(struct pipe_screen *_screen, void *nir, bool optimize)
+{
+ struct pipe_screen *screen = rbug_screen(_screen)->screen;
+
+ return screen->finalize_nir(screen, nir, optimize);
+}
+
bool
rbug_enabled()
{
rb_screen->base.fence_reference = rbug_screen_fence_reference;
rb_screen->base.fence_finish = rbug_screen_fence_finish;
rb_screen->base.fence_get_fd = rbug_screen_fence_get_fd;
+ SCR_INIT(finalize_nir);
rb_screen->screen = screen;
return result;
}
+static void
+trace_screen_finalize_nir(struct pipe_screen *_screen, void *nir, bool optimize)
+{
+ struct pipe_screen *screen = trace_screen(_screen)->screen;
+
+ screen->finalize_nir(screen, nir, optimize);
+}
+
static void
trace_screen_destroy(struct pipe_screen *_screen)
{
tr_scr->base.get_timestamp = trace_screen_get_timestamp;
SCR_INIT(get_driver_uuid);
SCR_INIT(get_device_uuid);
+ SCR_INIT(finalize_nir);
tr_scr->screen = screen;
struct pipe_resource *resource,
unsigned int nrects,
const struct pipe_box *rects);
+
+ /**
+ * Run driver-specific NIR lowering and optimization passes.
+ *
+ * State trackers should call this before passing shaders to drivers,
+ * and ideally also before shader caching.
+ *
+ * \param optimize Whether the input shader hasn't been optimized and
+ * should be.
+ */
+ void (*finalize_nir)(struct pipe_screen *screen, void *nir, bool optimize);
};