radeonsi: add si_shader::prolog2
authorMarek Olšák <marek.olsak@amd.com>
Fri, 7 Apr 2017 19:38:09 +0000 (21:38 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 28 Apr 2017 19:47:35 +0000 (21:47 +0200)
For a GS prolog in merged ES-GS.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_debug.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h

index 038c8b479311216e118beaf8b800ac0d5cef7ea1..9634901e709814abe5dabfd17858d2061dd5ca8f 100644 (file)
@@ -643,6 +643,10 @@ static void si_print_annotated_shader(struct si_shader *shader,
                si_add_split_disasm(shader->previous_stage->binary.disasm_string,
                                    start_addr, &num_inst, instructions);
        }
+       if (shader->prolog2) {
+               si_add_split_disasm(shader->prolog2->binary.disasm_string,
+                                   start_addr, &num_inst, instructions);
+       }
        si_add_split_disasm(shader->binary.disasm_string,
                            start_addr, &num_inst, instructions);
        if (shader->epilog) {
index ed2e06696946847ea606b157bfc6d3c920e476c3..c4e659be24ea13fa4ee0c3b7b6f2ef04611ba25a 100644 (file)
@@ -6349,6 +6349,8 @@ static unsigned si_get_shader_binary_size(struct si_shader *shader)
                size += shader->prolog->binary.code_size;
        if (shader->previous_stage)
                size += shader->previous_stage->binary.code_size;
+       if (shader->prolog2)
+               size += shader->prolog2->binary.code_size;
        if (shader->epilog)
                size += shader->epilog->binary.code_size;
        return size;
@@ -6360,6 +6362,8 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
                shader->prolog ? &shader->prolog->binary : NULL;
        const struct ac_shader_binary *previous_stage =
                shader->previous_stage ? &shader->previous_stage->binary : NULL;
+       const struct ac_shader_binary *prolog2 =
+               shader->prolog2 ? &shader->prolog2->binary : NULL;
        const struct ac_shader_binary *epilog =
                shader->epilog ? &shader->epilog->binary : NULL;
        const struct ac_shader_binary *mainb = &shader->binary;
@@ -6369,7 +6373,9 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
 
        assert(!prolog || !prolog->rodata_size);
        assert(!previous_stage || !previous_stage->rodata_size);
-       assert((!prolog && !previous_stage && !epilog) || !mainb->rodata_size);
+       assert(!prolog2 || !prolog2->rodata_size);
+       assert((!prolog && !previous_stage && !prolog2 && !epilog) ||
+              !mainb->rodata_size);
        assert(!epilog || !epilog->rodata_size);
 
        /* GFX9 can fetch at most 128 bytes past the end of the shader.
@@ -6400,6 +6406,10 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
                                        previous_stage->code_size);
                ptr += previous_stage->code_size;
        }
+       if (prolog2) {
+               util_memcpy_cpu_to_le32(ptr, prolog2->code, prolog2->code_size);
+               ptr += prolog2->code_size;
+       }
 
        util_memcpy_cpu_to_le32(ptr, mainb->code, mainb->code_size);
        ptr += mainb->code_size;
@@ -6610,6 +6620,9 @@ void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
                if (shader->previous_stage)
                        si_shader_dump_disassembly(&shader->previous_stage->binary,
                                                   debug, "previous stage", file);
+               if (shader->prolog2)
+                       si_shader_dump_disassembly(&shader->prolog2->binary,
+                                                  debug, "prolog2", file);
 
                si_shader_dump_disassembly(&shader->binary, debug, "main", file);
 
@@ -9009,6 +9022,12 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
                        shader->info.uses_instanceid |=
                                shader->previous_stage->info.uses_instanceid;
                }
+               if (shader->prolog2) {
+                       shader->config.num_sgprs = MAX2(shader->config.num_sgprs,
+                                                       shader->prolog2->config.num_sgprs);
+                       shader->config.num_vgprs = MAX2(shader->config.num_vgprs,
+                                                       shader->prolog2->config.num_vgprs);
+               }
                if (shader->epilog) {
                        shader->config.num_sgprs = MAX2(shader->config.num_sgprs,
                                                        shader->epilog->config.num_sgprs);
index ad72a3d389967770a82cb017f49194e5ac7ac4ec..8d60ed967c53da46115b66ae7aa0a28bb3f11388 100644 (file)
@@ -473,6 +473,7 @@ struct si_shader {
 
        struct si_shader_part           *prolog;
        struct si_shader                *previous_stage; /* for GFX9 */
+       struct si_shader_part           *prolog2;
        struct si_shader_part           *epilog;
 
        struct si_pm4_state             *pm4;