Path: blob/21.2-virgl/src/gallium/drivers/lima/lima_gpu.h
4565 views
/*1* Copyright (c) 2011-2013 Luc Verhaegen <[email protected]>2* Copyright (c) 2017-2019 Lima Project3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sub license,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the12* next paragraph) shall be included in all copies or substantial portions13* of the Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER21* DEALINGS IN THE SOFTWARE.22*23*/2425#ifndef H_LIMA_GPU26#define H_LIMA_GPU2728#include <stdint.h>29#include <assert.h>3031#include <util/u_dynarray.h>3233struct lima_gp_frame_reg {34uint32_t vs_cmd_start;35uint32_t vs_cmd_end;36uint32_t plbu_cmd_start;37uint32_t plbu_cmd_end;38uint32_t tile_heap_start;39uint32_t tile_heap_end;40};4142struct lima_pp_frame_reg {43uint32_t plbu_array_address;44uint32_t render_address;45uint32_t unused_0;46uint32_t flags;47uint32_t clear_value_depth;48uint32_t clear_value_stencil;49uint32_t clear_value_color;50uint32_t clear_value_color_1;51uint32_t clear_value_color_2;52uint32_t clear_value_color_3;53uint32_t width;54uint32_t height;55uint32_t fragment_stack_address;56uint32_t fragment_stack_size;57uint32_t unused_1;58uint32_t unused_2;59uint32_t one;60uint32_t supersampled_height;61uint32_t dubya;62uint32_t onscreen;63uint32_t blocking;64uint32_t scale;65uint32_t channel_layout;66};6768struct lima_pp_wb_reg {69uint32_t type;70uint32_t address;71uint32_t pixel_format;72uint32_t downsample_factor;73uint32_t pixel_layout;74uint32_t pitch;75uint32_t mrt_bits;76uint32_t mrt_pitch;77uint32_t zero;78uint32_t unused0;79uint32_t unused1;80uint32_t unused2;81};8283struct lima_render_state {84uint32_t blend_color_bg;85uint32_t blend_color_ra;86uint32_t alpha_blend;87uint32_t depth_test;88uint32_t depth_range;89uint32_t stencil_front;90uint32_t stencil_back;91uint32_t stencil_test;92uint32_t multi_sample;93uint32_t shader_address;94uint32_t varying_types;95uint32_t uniforms_address;96uint32_t textures_address;97uint32_t aux0;98uint32_t aux1;99uint32_t varyings_address;100};101102/* plbu commands */103#define PLBU_CMD_BEGIN(array, max) { \104int i = 0, max_n = max; \105struct util_dynarray *plbu_cmd_array = array; \106uint32_t *plbu_cmd = util_dynarray_ensure_cap(plbu_cmd_array, plbu_cmd_array->size + max_n * 4);107108#define PLBU_CMD_END() \109assert(i <= max_n); \110plbu_cmd_array->size += i * 4; \111}112113#define PLBU_CMD_CURRENT_POS() \114(util_dynarray_num_elements(plbu_cmd_array, uint32_t) + i)115116#define PLBU_CMD(v1, v2) \117do { \118plbu_cmd[i++] = v1; \119plbu_cmd[i++] = v2; \120} while (0)121122#define PLBU_CMD_BLOCK_STEP(shift_min, shift_h, shift_w) \123PLBU_CMD(((shift_min) << 28) | ((shift_h) << 16) | (shift_w), 0x1000010C)124#define PLBU_CMD_TILED_DIMENSIONS(tiled_w, tiled_h) \125PLBU_CMD((((tiled_w) - 1) << 24) | (((tiled_h) - 1) << 8), 0x10000109)126#define PLBU_CMD_BLOCK_STRIDE(block_w) PLBU_CMD((block_w) & 0xff, 0x30000000)127#define PLBU_CMD_ARRAY_ADDRESS(gp_stream, block_num) \128PLBU_CMD(gp_stream, 0x28000000 | ((block_num) - 1) | 1)129#define PLBU_CMD_VIEWPORT_LEFT(v) PLBU_CMD(v, 0x10000107)130#define PLBU_CMD_VIEWPORT_RIGHT(v) PLBU_CMD(v, 0x10000108)131#define PLBU_CMD_VIEWPORT_BOTTOM(v) PLBU_CMD(v, 0x10000105)132#define PLBU_CMD_VIEWPORT_TOP(v) PLBU_CMD(v, 0x10000106)133#define PLBU_CMD_ARRAYS_SEMAPHORE_BEGIN() PLBU_CMD(0x00010002, 0x60000000)134#define PLBU_CMD_ARRAYS_SEMAPHORE_END() PLBU_CMD(0x00010001, 0x60000000)135#define PLBU_CMD_PRIMITIVE_SETUP(force_point_size, cull, index_size) \136PLBU_CMD(0x2200 | ((force_point_size) ? 0x1000 : 0) | \137(cull) | ((index_size) << 9), 0x1000010B)138#define PLBU_CMD_RSW_VERTEX_ARRAY(rsw, gl_pos) \139PLBU_CMD(rsw, 0x80000000 | ((gl_pos) >> 4))140#define PLBU_CMD_SCISSORS(minx, maxx, miny, maxy) \141PLBU_CMD(((minx) << 30) | ((maxy) - 1) << 15 | (miny), \1420x70000000 | ((maxx) - 1) << 13 | ((minx) >> 2))143#define PLBU_CMD_UNKNOWN1() PLBU_CMD(0x00000000, 0x1000010A)144#define PLBU_CMD_UNKNOWN2() PLBU_CMD(0x00000200, 0x1000010B)145#define PLBU_CMD_LOW_PRIM_SIZE(v) PLBU_CMD(v, 0x1000010D)146#define PLBU_CMD_DEPTH_RANGE_NEAR(v) PLBU_CMD(v, 0x1000010E)147#define PLBU_CMD_DEPTH_RANGE_FAR(v) PLBU_CMD(v, 0x1000010F)148#define PLBU_CMD_INDEXED_DEST(gl_pos) PLBU_CMD(gl_pos, 0x10000100)149#define PLBU_CMD_INDEXED_PT_SIZE(pt_size) PLBU_CMD(pt_size, 0x10000102)150#define PLBU_CMD_INDICES(va) PLBU_CMD(va, 0x10000101)151#define PLBU_CMD_DRAW_ARRAYS(mode, start, count) \152PLBU_CMD(((count) << 24) | (start), (((mode) & 0x1F) << 16) | ((count) >> 8))153#define PLBU_CMD_DRAW_ELEMENTS(mode, start, count) \154PLBU_CMD(((count) << 24) | (start), \1550x00200000 | (((mode) & 0x1F) << 16) | ((count) >> 8))156157/* vs commands */158#define VS_CMD_BEGIN(array, max) { \159int i = 0, max_n = max; \160struct util_dynarray *vs_cmd_array = array; \161uint32_t *vs_cmd = util_dynarray_ensure_cap(vs_cmd_array, vs_cmd_array->size + max_n * 4);162163#define VS_CMD_END() \164assert(i <= max_n); \165vs_cmd_array->size += i * 4; \166}167168#define VS_CMD(v1, v2) \169do { \170vs_cmd[i++] = v1; \171vs_cmd[i++] = v2; \172} while (0)173174#define VS_CMD_ARRAYS_SEMAPHORE_BEGIN_1() VS_CMD(0x00028000, 0x50000000)175#define VS_CMD_ARRAYS_SEMAPHORE_BEGIN_2() VS_CMD(0x00000001, 0x50000000)176#define VS_CMD_ARRAYS_SEMAPHORE_END(index_draw) \177VS_CMD((index_draw) ? 0x00018000 : 0x00000000, 0x50000000)178#define VS_CMD_UNIFORMS_ADDRESS(addr, size) \179VS_CMD(addr, 0x30000000 | ((size) << 12))180#define VS_CMD_SHADER_ADDRESS(addr, size) \181VS_CMD(addr, 0x40000000 | ((size) << 12))182#define VS_CMD_SHADER_INFO(prefetch, size) \183VS_CMD(((prefetch) << 20) | ((((size) >> 4) - 1) << 10), 0x10000040)184#define VS_CMD_VARYING_ATTRIBUTE_COUNT(nv, na) \185VS_CMD((((nv) - 1) << 8) | (((na) - 1) << 24), 0x10000042)186#define VS_CMD_UNKNOWN1() VS_CMD(0x00000003, 0x10000041)187#define VS_CMD_UNKNOWN2() VS_CMD(0x00000000, 0x60000000)188#define VS_CMD_ATTRIBUTES_ADDRESS(addr, na) \189VS_CMD(addr, 0x20000000 | ((na) << 17))190#define VS_CMD_VARYINGS_ADDRESS(addr, nv) \191VS_CMD(addr, 0x20000008 | ((nv) << 17))192#define VS_CMD_DRAW(num, index_draw) \193VS_CMD(((num) << 24) | ((index_draw) ? 1 : 0), ((num) >> 8))194195#endif196197198