agx: move binary_size into info
this simplifies serialization, and will simplify future work. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31908>
This commit is contained in:
@@ -542,7 +542,7 @@ main(int argc, char **argv)
|
||||
agx_compile_shader_nir(b.shader, &key, NULL, &compiled);
|
||||
|
||||
print_u32_data(fp, "libagx_g13", "helper", compiled.binary,
|
||||
compiled.binary_size);
|
||||
compiled.info.binary_size);
|
||||
free(compiled.binary);
|
||||
ralloc_free(b.shader);
|
||||
|
||||
|
||||
@@ -3837,5 +3837,5 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key,
|
||||
}
|
||||
|
||||
out->binary = binary.data;
|
||||
out->binary_size = binary.size;
|
||||
info->binary_size = binary.size;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ static_assert(sizeof(struct agx_interp_info) == 16, "packed");
|
||||
|
||||
struct agx_shader_info {
|
||||
enum pipe_shader_type stage;
|
||||
uint32_t binary_size;
|
||||
|
||||
union agx_varyings varyings;
|
||||
|
||||
@@ -143,7 +144,6 @@ struct agx_shader_info {
|
||||
struct agx_shader_part {
|
||||
struct agx_shader_info info;
|
||||
void *binary;
|
||||
size_t binary_size;
|
||||
};
|
||||
|
||||
#define AGX_MAX_RTS (8)
|
||||
|
||||
@@ -51,8 +51,8 @@ agx_compile_bg_eot_shader(struct agx_bg_eot_cache *cache, nir_shader *shader,
|
||||
agx_compile_shader_nir(shader, key, NULL, &bin);
|
||||
|
||||
res->info = bin.info;
|
||||
res->ptr = agx_pool_upload_aligned_with_bo(&cache->pool, bin.binary,
|
||||
bin.binary_size, 128, &res->bo);
|
||||
res->ptr = agx_pool_upload_aligned_with_bo(
|
||||
&cache->pool, bin.binary, bin.info.binary_size, 128, &res->bo);
|
||||
free(bin.binary);
|
||||
ralloc_free(shader);
|
||||
|
||||
|
||||
@@ -736,9 +736,9 @@ hk_upload_shader(struct hk_device *dev, struct hk_shader *shader)
|
||||
{
|
||||
if (shader->b.info.has_preamble) {
|
||||
unsigned offs = shader->b.info.preamble_offset;
|
||||
assert(offs < shader->b.binary_size);
|
||||
assert(offs < shader->b.info.binary_size);
|
||||
|
||||
size_t size = shader->b.binary_size - offs;
|
||||
size_t size = shader->b.info.binary_size - offs;
|
||||
assert(size > 0);
|
||||
|
||||
shader->bo = agx_bo_create(&dev->dev, size, 0,
|
||||
@@ -896,7 +896,7 @@ hk_compile_nir(struct hk_device *dev, const VkAllocationCallbacks *pAllocator,
|
||||
simple_mtx_unlock(lock);
|
||||
|
||||
shader->code_ptr = shader->b.binary;
|
||||
shader->code_size = shader->b.binary_size;
|
||||
shader->code_size = shader->b.info.binary_size;
|
||||
|
||||
shader->info.stage = sw_stage;
|
||||
shader->info.clip_distance_array_size = nir->info.clip_distance_array_size;
|
||||
@@ -1250,7 +1250,7 @@ hk_deserialize_shader(struct hk_device *dev, struct blob_reader *blob,
|
||||
shader->info = info;
|
||||
shader->code_size = code_size;
|
||||
shader->data_size = data_size;
|
||||
shader->b.binary_size = code_size;
|
||||
shader->b.info.binary_size = code_size;
|
||||
|
||||
shader->code_ptr = malloc(code_size);
|
||||
if (shader->code_ptr == NULL)
|
||||
|
||||
@@ -59,13 +59,12 @@ static void
|
||||
write_shader(struct blob *blob, const struct agx_compiled_shader *binary,
|
||||
bool is_root_gs)
|
||||
{
|
||||
blob_write_uint32(blob, binary->b.binary_size);
|
||||
blob_write_bytes(blob, &binary->b.info, sizeof(binary->b.info));
|
||||
|
||||
if (binary->b.binary_size) {
|
||||
blob_write_bytes(blob, binary->b.binary, binary->b.binary_size);
|
||||
if (binary->b.info.binary_size) {
|
||||
blob_write_bytes(blob, binary->b.binary, binary->b.info.binary_size);
|
||||
}
|
||||
|
||||
blob_write_bytes(blob, &binary->b.info, sizeof(binary->b.info));
|
||||
blob_write_bytes(blob, &binary->uvs, sizeof(binary->uvs));
|
||||
blob_write_bytes(blob, &binary->attrib_components_read,
|
||||
sizeof(binary->attrib_components_read));
|
||||
@@ -97,14 +96,15 @@ read_shader(struct agx_screen *screen, struct blob_reader *blob,
|
||||
binary->stage = uncompiled->type;
|
||||
binary->so = uncompiled;
|
||||
|
||||
size_t size = blob_read_uint32(blob);
|
||||
blob_copy_bytes(blob, &binary->b.info, sizeof(binary->b.info));
|
||||
size_t size = binary->b.info.binary_size;
|
||||
|
||||
if (uncompiled->type == PIPE_SHADER_VERTEX ||
|
||||
uncompiled->type == PIPE_SHADER_TESS_EVAL ||
|
||||
uncompiled->type == PIPE_SHADER_FRAGMENT) {
|
||||
binary->b.binary_size = size;
|
||||
binary->b.binary = malloc(binary->b.binary_size);
|
||||
blob_copy_bytes(blob, binary->b.binary, binary->b.binary_size);
|
||||
|
||||
binary->b.binary = malloc(size);
|
||||
blob_copy_bytes(blob, binary->b.binary, size);
|
||||
|
||||
if (size) {
|
||||
binary->bo = agx_bo_create(&screen->dev, size, 0,
|
||||
@@ -117,7 +117,6 @@ read_shader(struct agx_screen *screen, struct blob_reader *blob,
|
||||
blob_copy_bytes(blob, binary->bo->map, size);
|
||||
}
|
||||
|
||||
blob_copy_bytes(blob, &binary->b.info, sizeof(binary->b.info));
|
||||
blob_copy_bytes(blob, &binary->uvs, sizeof(binary->uvs));
|
||||
blob_copy_bytes(blob, &binary->attrib_components_read,
|
||||
sizeof(binary->attrib_components_read));
|
||||
|
||||
@@ -1572,11 +1572,12 @@ agx_compile_nir(struct agx_device *dev, nir_shader *nir,
|
||||
|
||||
agx_compile_shader_nir(nir, &key, debug, &compiled->b);
|
||||
|
||||
if (compiled->b.binary_size && !secondary) {
|
||||
compiled->bo = agx_bo_create(dev, compiled->b.binary_size, 0,
|
||||
if (compiled->b.info.binary_size && !secondary) {
|
||||
compiled->bo = agx_bo_create(dev, compiled->b.info.binary_size, 0,
|
||||
AGX_BO_EXEC | AGX_BO_LOW_VA, "Executable");
|
||||
|
||||
memcpy(compiled->bo->map, compiled->b.binary, compiled->b.binary_size);
|
||||
memcpy(compiled->bo->map, compiled->b.binary,
|
||||
compiled->b.info.binary_size);
|
||||
}
|
||||
|
||||
return compiled;
|
||||
|
||||
Reference in New Issue
Block a user