From ada05759e1ed732c2a94992f157a2f2ec5c24d51 Mon Sep 17 00:00:00 2001 From: Enrico Galli Date: Mon, 30 Aug 2021 14:45:11 -0700 Subject: [PATCH] spirv_to_dxil: Convert out parameters to a single object Reviewed-by: Jesse Natalie Part-of: --- src/microsoft/spirv_to_dxil/spirv_to_dxil.c | 10 +++++--- src/microsoft/spirv_to_dxil/spirv_to_dxil.h | 27 ++++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c index 4e0973f464e..3b2570e4b9b 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c @@ -45,7 +45,8 @@ bool spirv_to_dxil(const uint32_t *words, size_t word_count, struct dxil_spirv_specialization *specializations, unsigned int num_specializations, dxil_spirv_shader_stage stage, - const char *entry_point_name, void **buffer, size_t *size) + const char *entry_point_name, + struct dxil_spirv_object *out_dxil) { if (stage == MESA_SHADER_NONE || stage == MESA_SHADER_KERNEL) return false; @@ -187,16 +188,17 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, return false; } - blob_finish_get_buffer(&dxil_blob, buffer, size); + blob_finish_get_buffer(&dxil_blob, &out_dxil->binary.buffer, + &out_dxil->binary.size); glsl_type_singleton_decref(); return true; } void -spirv_to_dxil_free(void* buffer) +spirv_to_dxil_free(struct dxil_spirv_object *dxil) { - free(buffer); + free(dxil->binary.buffer); } uint64_t diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h index c0a0b4d40df..27a5f836438 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h @@ -69,31 +69,36 @@ struct dxil_spirv_specialization { bool defined_on_module; }; +struct dxil_spirv_object { + struct { + void *buffer; + size_t size; + } binary; +}; + /** * Compile a SPIR-V module into DXIL. * \param words SPIR-V module to compile * \param word_count number of words in the SPIR-V module * \param specializations specialization constants to compile with the shader * \param num_specializations number of specialization constants - * \param buffer will contain the DXIL bytes on success. Needs to be freed() - * \param size length of returned buffer + * \param stage shader stage + * \param entry_point_name name of shader entrypoint + * \param out_dxil will contain the DXIL bytes on success (call spirv_to_dxil_free after use) * \return true if compilation succeeded */ bool -spirv_to_dxil(const uint32_t* words, - size_t word_count, - struct dxil_spirv_specialization* specializations, - unsigned int num_specializations, - dxil_spirv_shader_stage stage, - const char* entry_point_name, - void** buffer, - size_t* size); +spirv_to_dxil(const uint32_t *words, size_t word_count, + struct dxil_spirv_specialization *specializations, + unsigned int num_specializations, dxil_spirv_shader_stage stage, + const char *entry_point_name, + struct dxil_spirv_object *out_dxil); /** * Free the buffer allocated by spirv_to_dxil. */ void -spirv_to_dxil_free(void* buffer); +spirv_to_dxil_free(struct dxil_spirv_object *dxil); uint64_t spirv_to_dxil_get_version(void);