llvmpipe: handle serialized nir as a shader type.
authorDave Airlie <airlied@redhat.com>
Tue, 10 Dec 2019 04:55:17 +0000 (14:55 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 27 Dec 2019 03:26:33 +0000 (13:26 +1000)
Acked-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_state_cs.c

index b238cce808f621d1ef38da1d866b5066b34b90e2..d0a1b351c4910ab93798c09184b694a97a97df9d 100644 (file)
@@ -733,6 +733,8 @@ llvmpipe_destroy_screen( struct pipe_screen *_screen )
    if(winsys->destroy)
       winsys->destroy(winsys);
 
+   glsl_type_singleton_decref();
+
    mtx_destroy(&screen->rast_mutex);
    mtx_destroy(&screen->cs_mutex);
    FREE(screen);
@@ -796,6 +798,8 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
 
    util_cpu_detect();
 
+   glsl_type_singleton_init_or_ref();
+
 #ifdef DEBUG
    LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 );
 #endif
index 83affd7d429d0bf9472f862990254fbbbbd3fdb9..92e156b411123c1d6251465c67a63b39bd9126d1 100644 (file)
@@ -46,7 +46,7 @@
 #include "lp_cs_tpool.h"
 #include "state_tracker/sw_winsys.h"
 #include "nir/nir_to_tgsi_info.h"
-
+#include "nir_serialize.h"
 struct lp_cs_job_info {
    unsigned grid_size[3];
    unsigned block_size[3];
@@ -426,15 +426,26 @@ llvmpipe_create_compute_state(struct pipe_context *pipe,
       return NULL;
 
    shader->base.type = templ->ir_type;
-   if (templ->ir_type == PIPE_SHADER_IR_TGSI) {
+   if (templ->ir_type == PIPE_SHADER_IR_NIR_SERIALIZED) {
+      struct blob_reader reader;
+      const struct pipe_binary_program_header *hdr = templ->prog;
+
+      blob_reader_init(&reader, hdr->blob, hdr->num_bytes);
+      shader->base.ir.nir = nir_deserialize(NULL, pipe->screen->get_compiler_options(pipe->screen, PIPE_SHADER_IR_NIR, PIPE_SHADER_COMPUTE), &reader);
+      shader->base.type = PIPE_SHADER_IR_NIR;
+
+      pipe->screen->finalize_nir(pipe->screen, shader->base.ir.nir, false);
+   } else if (templ->ir_type == PIPE_SHADER_IR_NIR)
+      shader->base.ir.nir = (struct nir_shader *)templ->prog;
+
+   if (shader->base.type == PIPE_SHADER_IR_TGSI) {
       /* get/save the summary info for this shader */
       lp_build_tgsi_info(templ->prog, &shader->info);
 
       /* we need to keep a local copy of the tokens */
       shader->base.tokens = tgsi_dup_tokens(templ->prog);
    } else {
-      shader->base.ir.nir = (struct nir_shader *)templ->prog;
-      nir_tgsi_scan_shader(templ->prog, &shader->info.base, false);
+      nir_tgsi_scan_shader(shader->base.ir.nir, &shader->info.base, false);
    }
 
    shader->req_local_mem = templ->req_local_mem;