Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a
  5.  * copy of this software and associated documentation files (the "Software"),
  6.  * to deal in the Software without restriction, including without limitation
  7.  * on the rights to use, copy, modify, merge, publish, distribute, sub
  8.  * license, and/or sell copies of the Software, and to permit persons to whom
  9.  * the Software is furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice (including the next
  12.  * paragraph) shall be included in all copies or substantial portions of the
  13.  * Software.
  14.  *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17.  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  18.  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  19.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  20.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  21.  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  22.  */
  23. #ifndef R600_ASM_H
  24. #define R600_ASM_H
  25.  
  26. #include "r600_pipe.h"
  27. #include "r600_isa.h"
  28.  
  29. struct r600_bytecode_alu_src {
  30.         unsigned                        sel;
  31.         unsigned                        chan;
  32.         unsigned                        neg;
  33.         unsigned                        abs;
  34.         unsigned                        rel;
  35.         unsigned                        kc_bank;
  36.         uint32_t                        value;
  37. };
  38.  
  39. struct r600_bytecode_alu_dst {
  40.         unsigned                        sel;
  41.         unsigned                        chan;
  42.         unsigned                        clamp;
  43.         unsigned                        write;
  44.         unsigned                        rel;
  45. };
  46.  
  47. struct r600_bytecode_alu {
  48.         struct list_head                list;
  49.         struct r600_bytecode_alu_src            src[3];
  50.         struct r600_bytecode_alu_dst            dst;
  51.         unsigned                        op;
  52.         unsigned                        last;
  53.         unsigned                        is_op3;
  54.         unsigned                        execute_mask;
  55.         unsigned                        update_pred;
  56.         unsigned                        pred_sel;
  57.         unsigned                        bank_swizzle;
  58.         unsigned                        bank_swizzle_force;
  59.         unsigned                        omod;
  60.         unsigned                        index_mode;
  61. };
  62.  
  63. struct r600_bytecode_tex {
  64.         struct list_head                list;
  65.         unsigned                        op;
  66.         unsigned                        inst_mod;
  67.         unsigned                        resource_id;
  68.         unsigned                        src_gpr;
  69.         unsigned                        src_rel;
  70.         unsigned                        dst_gpr;
  71.         unsigned                        dst_rel;
  72.         unsigned                        dst_sel_x;
  73.         unsigned                        dst_sel_y;
  74.         unsigned                        dst_sel_z;
  75.         unsigned                        dst_sel_w;
  76.         unsigned                        lod_bias;
  77.         unsigned                        coord_type_x;
  78.         unsigned                        coord_type_y;
  79.         unsigned                        coord_type_z;
  80.         unsigned                        coord_type_w;
  81.         int                             offset_x;
  82.         int                             offset_y;
  83.         int                             offset_z;
  84.         unsigned                        sampler_id;
  85.         unsigned                        src_sel_x;
  86.         unsigned                        src_sel_y;
  87.         unsigned                        src_sel_z;
  88.         unsigned                        src_sel_w;
  89. };
  90.  
  91. struct r600_bytecode_vtx {
  92.         struct list_head                list;
  93.         unsigned                        op;
  94.         unsigned                        fetch_type;
  95.         unsigned                        buffer_id;
  96.         unsigned                        src_gpr;
  97.         unsigned                        src_sel_x;
  98.         unsigned                        mega_fetch_count;
  99.         unsigned                        dst_gpr;
  100.         unsigned                        dst_sel_x;
  101.         unsigned                        dst_sel_y;
  102.         unsigned                        dst_sel_z;
  103.         unsigned                        dst_sel_w;
  104.         unsigned                        use_const_fields;
  105.         unsigned                        data_format;
  106.         unsigned                        num_format_all;
  107.         unsigned                        format_comp_all;
  108.         unsigned                        srf_mode_all;
  109.         unsigned                        offset;
  110.         unsigned                        endian;
  111. };
  112.  
  113. struct r600_bytecode_output {
  114.         unsigned                        array_base;
  115.         unsigned                        array_size;
  116.         unsigned                        comp_mask;
  117.         unsigned                        type;
  118.         unsigned                        end_of_program;
  119.  
  120.         unsigned                        op;
  121.  
  122.         unsigned                        elem_size;
  123.         unsigned                        gpr;
  124.         unsigned                        swizzle_x;
  125.         unsigned                        swizzle_y;
  126.         unsigned                        swizzle_z;
  127.         unsigned                        swizzle_w;
  128.         unsigned                        burst_count;
  129.         unsigned                        barrier;
  130. };
  131.  
  132. struct r600_bytecode_kcache {
  133.         unsigned                        bank;
  134.         unsigned                        mode;
  135.         unsigned                        addr;
  136. };
  137.  
  138. struct r600_bytecode_cf {
  139.         struct list_head                list;
  140.  
  141.         unsigned                        op;
  142.         unsigned                        addr;
  143.         unsigned                        ndw;
  144.         unsigned                        id;
  145.         unsigned                        cond;
  146.         unsigned                        pop_count;
  147.         unsigned                        cf_addr; /* control flow addr */
  148.         struct r600_bytecode_kcache             kcache[4];
  149.         unsigned                        r6xx_uses_waterfall;
  150.         unsigned                        eg_alu_extended;
  151.         struct list_head                alu;
  152.         struct list_head                tex;
  153.         struct list_head                vtx;
  154.         struct r600_bytecode_output             output;
  155.         struct r600_bytecode_alu                *curr_bs_head;
  156.         struct r600_bytecode_alu                *prev_bs_head;
  157.         struct r600_bytecode_alu                *prev2_bs_head;
  158.         unsigned isa[2];
  159. };
  160.  
  161. #define FC_NONE                         0
  162. #define FC_IF                           1
  163. #define FC_LOOP                         2
  164. #define FC_REP                          3
  165. #define FC_PUSH_VPM                     4
  166. #define FC_PUSH_WQM                     5
  167.  
  168. struct r600_cf_stack_entry {
  169.         int                             type;
  170.         struct r600_bytecode_cf         *start;
  171.         struct r600_bytecode_cf         **mid; /* used to store the else point */
  172.         int                             num_mid;
  173. };
  174.  
  175. #define SQ_MAX_CALL_DEPTH 0x00000020
  176.  
  177. #define AR_HANDLE_NORMAL 0
  178. #define AR_HANDLE_RV6XX 1 /* except RV670 */
  179.  
  180. struct r600_stack_info {
  181.         /* current level of non-WQM PUSH operations
  182.          * (PUSH, PUSH_ELSE, ALU_PUSH_BEFORE) */
  183.         int push;
  184.         /* current level of WQM PUSH operations
  185.          * (PUSH, PUSH_ELSE, PUSH_WQM) */
  186.         int push_wqm;
  187.         /* current loop level */
  188.         int loop;
  189.  
  190.         /* required depth */
  191.         int max_entries;
  192.         /* subentries per entry */
  193.         int entry_size;
  194. };
  195.  
  196. struct r600_bytecode {
  197.         enum chip_class                 chip_class;
  198.         bool                            has_compressed_msaa_texturing;
  199.         int                             type;
  200.         struct list_head                cf;
  201.         struct r600_bytecode_cf         *cf_last;
  202.         unsigned                        ndw;
  203.         unsigned                        ncf;
  204.         unsigned                        ngpr;
  205.         unsigned                        nstack;
  206.         unsigned                        nlds_dw;
  207.         unsigned                        nresource;
  208.         unsigned                        force_add_cf;
  209.         uint32_t                        *bytecode;
  210.         uint32_t                        fc_sp;
  211.         struct r600_cf_stack_entry      fc_stack[32];
  212.         struct r600_stack_info          stack;
  213.         unsigned        ar_loaded;
  214.         unsigned        ar_reg;
  215.         unsigned        ar_chan;
  216.         unsigned        ar_handling;
  217.         unsigned        r6xx_nop_after_rel_dst;
  218.         unsigned        debug_id;
  219.         struct r600_isa* isa;
  220. };
  221.  
  222. /* eg_asm.c */
  223. int eg_bytecode_cf_build(struct r600_bytecode *bc, struct r600_bytecode_cf *cf);
  224.  
  225. /* r600_asm.c */
  226. void r600_bytecode_init(struct r600_bytecode *bc,
  227.                         enum chip_class chip_class,
  228.                         enum radeon_family family,
  229.                         bool has_compressed_msaa_texturing);
  230. void r600_bytecode_clear(struct r600_bytecode *bc);
  231. int r600_bytecode_add_alu(struct r600_bytecode *bc,
  232.                 const struct r600_bytecode_alu *alu);
  233. int r600_bytecode_add_vtx(struct r600_bytecode *bc,
  234.                 const struct r600_bytecode_vtx *vtx);
  235. int r600_bytecode_add_tex(struct r600_bytecode *bc,
  236.                 const struct r600_bytecode_tex *tex);
  237. int r600_bytecode_add_output(struct r600_bytecode *bc,
  238.                 const struct r600_bytecode_output *output);
  239. int r600_bytecode_build(struct r600_bytecode *bc);
  240. int r600_bytecode_add_cf(struct r600_bytecode *bc);
  241. int r600_bytecode_add_cfinst(struct r600_bytecode *bc,
  242.                 unsigned op);
  243. int r600_bytecode_add_alu_type(struct r600_bytecode *bc,
  244.                 const struct r600_bytecode_alu *alu, unsigned type);
  245. void r600_bytecode_special_constants(uint32_t value,
  246.                 unsigned *sel, unsigned *neg);
  247. void r600_bytecode_disasm(struct r600_bytecode *bc);
  248. void r600_bytecode_alu_read(struct r600_bytecode *bc,
  249.                 struct r600_bytecode_alu *alu, uint32_t word0, uint32_t word1);
  250.  
  251. int cm_bytecode_add_cf_end(struct r600_bytecode *bc);
  252.  
  253. void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
  254.                                       unsigned count,
  255.                                       const struct pipe_vertex_element *elements);
  256.  
  257. /* r700_asm.c */
  258. void r700_bytecode_cf_vtx_build(uint32_t *bytecode,
  259.                 const struct r600_bytecode_cf *cf);
  260. int r700_bytecode_alu_build(struct r600_bytecode *bc,
  261.                 struct r600_bytecode_alu *alu, unsigned id);
  262. void r700_bytecode_alu_read(struct r600_bytecode *bc,
  263.                 struct r600_bytecode_alu *alu, uint32_t word0, uint32_t word1);
  264. void r600_bytecode_export_read(struct r600_bytecode *bc,
  265.                 struct r600_bytecode_output *output, uint32_t word0, uint32_t word1);
  266. void eg_bytecode_export_read(struct r600_bytecode *bc,
  267.                 struct r600_bytecode_output *output, uint32_t word0, uint32_t word1);
  268.  
  269. void r600_vertex_data_type(enum pipe_format pformat, unsigned *format,
  270.                            unsigned *num_format, unsigned *format_comp, unsigned *endian);
  271. #endif
  272.