spirv_to_dxil: Convert out parameters to a single object

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12707>
This commit is contained in:
Enrico Galli
2021-08-30 14:45:11 -07:00
committed by Marge Bot
parent 268158a758
commit ada05759e1
2 changed files with 22 additions and 15 deletions

View File

@@ -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

View File

@@ -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);