From: Mark Menzynski Date: Tue, 28 Jan 2020 12:11:31 +0000 (+0100) Subject: nv50/ir: Add nv50_ir_prog_info serialize X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=82dd683a3ce83461c374aa2332d2db2ff589b741;p=mesa.git nv50/ir: Add nv50_ir_prog_info serialize Adds a function for serializing a nv50_ir_prog_info structure, which is needed for shader caching. v2 (Karol): strip nir when serializing Signed-off-by: Mark Menzynski Reviewed-by: Karol Herbst Part-of: --- diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h index 2b8ffb5cd0b..c36e990735d 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h @@ -270,6 +270,10 @@ namespace nv50_ir extern void nv50_ir_prog_info_out_print(struct nv50_ir_prog_info_out *); +/* Serialize a nv50_ir_prog_info structure and save it into blob */ +extern bool +nv50_ir_prog_info_serialize(struct blob *, struct nv50_ir_prog_info *); + /* Serialize a nv50_ir_prog_info_out structure and save it into blob */ extern bool MUST_CHECK nv50_ir_prog_info_out_serialize(struct blob *, struct nv50_ir_prog_info_out *); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_serialize.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_serialize.cpp index 41f151ac283..682a2014a74 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_serialize.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_serialize.cpp @@ -18,6 +18,45 @@ enum FixupApplyFunc { FLIP_GV100, }; +extern bool +nv50_ir_prog_info_serialize(struct blob *blob, struct nv50_ir_prog_info *info) +{ + blob_write_uint32(blob, info->bin.smemSize); + blob_write_uint16(blob, info->target); + blob_write_uint8(blob, info->type); + blob_write_uint8(blob, info->optLevel); + blob_write_uint8(blob, info->dbgFlags); + blob_write_uint8(blob, info->omitLineNum); + blob_write_uint8(blob, info->bin.sourceRep); + + switch(info->bin.sourceRep) { + case PIPE_SHADER_IR_TGSI: { + struct tgsi_token *tokens = (struct tgsi_token *)info->bin.source; + unsigned int num_tokens = tgsi_num_tokens(tokens); + + blob_write_uint32(blob, num_tokens); + blob_write_bytes(blob, tokens, num_tokens * sizeof(struct tgsi_token)); + break; + } + case PIPE_SHADER_IR_NIR: { + struct nir_shader *nir = (struct nir_shader *)info->bin.source; + nir_serialize(blob, nir, true); + break; + } + default: + ERROR("unhandled info->bin.sourceRep switch case\n"); + assert(false); + return false; + } + + if (info->type == PIPE_SHADER_COMPUTE) + blob_write_bytes(blob, &info->prop.cp, sizeof(info->prop.cp)); + + blob_write_bytes(blob, &info->io, sizeof(info->io)); + + return true; +} + extern bool nv50_ir_prog_info_out_serialize(struct blob *blob, struct nv50_ir_prog_info_out *info_out)