turnip: Reuse tu6_stage2opcode() more.
authorEric Anholt <eric@anholt.net>
Tue, 3 Dec 2019 00:44:52 +0000 (16:44 -0800)
committerEric Anholt <eric@anholt.net>
Thu, 5 Dec 2019 04:32:15 +0000 (20:32 -0800)
A bit of cleanup for adding more stages later.

Reviewed-by: Jonathan Marek <jonathan@marek.ca>
src/freedreno/vulkan/tu_cmd_buffer.c

index b5da64627ef672d4b5fdea8632bd6c4f3c6f2a96..516bbc19e5b5618a0e62c24aaed79519cabc5660 100644 (file)
@@ -2413,27 +2413,24 @@ tu6_emit_textures(struct tu_device *device, struct tu_cs *draw_state,
    if (!size)
       return (struct tu_cs_entry) {};
 
-   unsigned opcode, tex_samp_reg, tex_const_reg, tex_count_reg;
+   unsigned tex_samp_reg, tex_const_reg, tex_count_reg;
    enum a6xx_state_block sb;
 
    switch (type) {
    case MESA_SHADER_VERTEX:
       sb = SB6_VS_TEX;
-      opcode = CP_LOAD_STATE6_GEOM;
       tex_samp_reg = REG_A6XX_SP_VS_TEX_SAMP_LO;
       tex_const_reg = REG_A6XX_SP_VS_TEX_CONST_LO;
       tex_count_reg = REG_A6XX_SP_VS_TEX_COUNT;
       break;
    case MESA_SHADER_FRAGMENT:
       sb = SB6_FS_TEX;
-      opcode = CP_LOAD_STATE6_FRAG;
       tex_samp_reg = REG_A6XX_SP_FS_TEX_SAMP_LO;
       tex_const_reg = REG_A6XX_SP_FS_TEX_CONST_LO;
       tex_count_reg = REG_A6XX_SP_FS_TEX_COUNT;
       break;
    case MESA_SHADER_COMPUTE:
       sb = SB6_CS_TEX;
-      opcode = CP_LOAD_STATE6_FRAG;
       tex_samp_reg = REG_A6XX_SP_CS_TEX_SAMP_LO;
       tex_const_reg = REG_A6XX_SP_CS_TEX_CONST_LO;
       tex_count_reg = REG_A6XX_SP_CS_TEX_COUNT;
@@ -2469,7 +2466,7 @@ tu6_emit_textures(struct tu_device *device, struct tu_cs *draw_state,
    tu_cs_begin_sub_stream(device, draw_state, 64, &cs);
 
    /* output sampler state: */
-   tu_cs_emit_pkt7(&cs, opcode, 3);
+   tu_cs_emit_pkt7(&cs, tu6_stage2opcode(type), 3);
    tu_cs_emit(&cs, CP_LOAD_STATE6_0_DST_OFF(0) |
       CP_LOAD_STATE6_0_STATE_TYPE(ST6_SHADER) |
       CP_LOAD_STATE6_0_STATE_SRC(SS6_INDIRECT) |
@@ -2481,7 +2478,7 @@ tu6_emit_textures(struct tu_device *device, struct tu_cs *draw_state,
    tu_cs_emit_qw(&cs, samp_addr); /* SRC_ADDR_LO/HI */
 
    /* emit texture state: */
-   tu_cs_emit_pkt7(&cs, opcode, 3);
+   tu_cs_emit_pkt7(&cs, tu6_stage2opcode(type), 3);
    tu_cs_emit(&cs, CP_LOAD_STATE6_0_DST_OFF(0) |
       CP_LOAD_STATE6_0_STATE_TYPE(ST6_CONSTANTS) |
       CP_LOAD_STATE6_0_STATE_SRC(SS6_INDIRECT) |