Path: blob/21.2-virgl/src/gallium/drivers/etnaviv/etnaviv_internal.h
4570 views
/*1* Copyright (c) 2012-2015 Etnaviv Project2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sub license,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the11* next paragraph) shall be included in all copies or substantial portions12* of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*/2223#ifndef H_ETNA_INTERNAL24#define H_ETNA_INTERNAL2526#include <assert.h>27#include <stdbool.h>28#include <stdint.h>2930#include "hw/state.xml.h"31#include "hw/state_3d.xml.h"3233#include "drm/etnaviv_drmif.h"3435#define ETNA_NUM_INPUTS (16)36#define ETNA_NUM_VARYINGS 1637#define ETNA_NUM_LOD (14)38#define ETNA_NUM_LAYERS (6)39#define ETNA_MAX_UNIFORMS (256)40#define ETNA_MAX_CONST_BUF 1641#define ETNA_MAX_PIXELPIPES 24243/* All RS operations must have width%16 = 0 */44#define ETNA_RS_WIDTH_MASK (16 - 1)45/* RS tiled operations must have height%4 = 0 */46#define ETNA_RS_HEIGHT_MASK (3)47/* PE render targets must be aligned to 64 bytes */48#define ETNA_PE_ALIGNMENT (64)4950/* These demarcate the margin (fixp16) between the computed sizes and the51value sent to the chip. These have been set to the numbers used by the52Vivante driver on gc2000. They used to be -1 for scissor right and bottom. I53am not sure whether older hardware was relying on these or they were just a54guess. But if so, these need to be moved to the _specs structure.55*/56#define ETNA_SE_SCISSOR_MARGIN_RIGHT (0x1119)57#define ETNA_SE_SCISSOR_MARGIN_BOTTOM (0x1111)58#define ETNA_SE_CLIP_MARGIN_RIGHT (0xffff)59#define ETNA_SE_CLIP_MARGIN_BOTTOM (0xffff)6061/* GPU chip 3D specs */62struct etna_specs {63/* HALTI (gross architecture) level. -1 for pre-HALTI. */64int halti : 8;65/* supports SUPERTILE (64x64) tiling? */66unsigned can_supertile : 1;67/* needs z=(z+w)/2, for older GCxxx */68unsigned vs_need_z_div : 1;69/* supports trigonometric instructions */70unsigned has_sin_cos_sqrt : 1;71/* has SIGN/FLOOR/CEIL instructions */72unsigned has_sign_floor_ceil : 1;73/* can use VS_RANGE, PS_RANGE registers*/74unsigned has_shader_range_registers : 1;75/* has the new sin/cos/log functions */76unsigned has_new_transcendentals : 1;77/* has the new dp2/dpX_norm instructions, among others */78unsigned has_halti2_instructions : 1;79/* has V4_COMPRESSION */80unsigned v4_compression : 1;81/* supports single-buffer rendering with multiple pixel pipes */82unsigned single_buffer : 1;83/* has unified uniforms memory */84unsigned has_unified_uniforms : 1;85/* can load shader instructions from memory */86unsigned has_icache : 1;87/* ASTC texture support (and has associated states) */88unsigned tex_astc : 1;89/* has BLT engine instead of RS */90unsigned use_blt : 1;91/* can use any kind of wrapping mode on npot textures */92unsigned npot_tex_any_wrap : 1;93/* supports seamless cube map */94unsigned seamless_cube_map : 1;95/* number of bits per TS tile */96unsigned bits_per_tile;97/* clear value for TS (dependent on bits_per_tile) */98uint32_t ts_clear_value;99/* base of vertex texture units */100unsigned vertex_sampler_offset;101/* number of fragment sampler units */102unsigned fragment_sampler_count;103/* number of vertex sampler units */104unsigned vertex_sampler_count;105/* size of vertex shader output buffer */106unsigned vertex_output_buffer_size;107/* maximum number of vertex element configurations */108unsigned vertex_max_elements;109/* size of a cached vertex (?) */110unsigned vertex_cache_size;111/* number of shader cores */112unsigned shader_core_count;113/* number of vertex streams */114unsigned stream_count;115/* vertex shader memory address*/116uint32_t vs_offset;117/* pixel shader memory address*/118uint32_t ps_offset;119/* vertex shader uniforms address*/120uint32_t vs_uniforms_offset;121/* pixel shader uniforms address*/122uint32_t ps_uniforms_offset;123/* vertex/fragment shader max instructions */124uint32_t max_instructions;125/* maximum number of varyings */126unsigned max_varyings;127/* maximum number of registers */128unsigned max_registers;129/* maximum vertex uniforms */130unsigned max_vs_uniforms;131/* maximum pixel uniforms */132unsigned max_ps_uniforms;133/* maximum texture size */134unsigned max_texture_size;135/* maximum texture size */136unsigned max_rendertarget_size;137/* available pixel pipes */138unsigned pixel_pipes;139/* number of constants */140unsigned num_constants;141};142143/* Compiled Gallium state. All the different compiled state atoms are woven144* together and uploaded only when it is necessary to synchronize the state,145* for example before rendering. */146147/* Compiled pipe_blend_color */148struct compiled_blend_color {149float color[4];150uint32_t PE_ALPHA_BLEND_COLOR;151uint32_t PE_ALPHA_COLOR_EXT0;152uint32_t PE_ALPHA_COLOR_EXT1;153};154155/* Compiled pipe_stencil_ref */156struct compiled_stencil_ref {157uint32_t PE_STENCIL_CONFIG[2];158uint32_t PE_STENCIL_CONFIG_EXT[2];159};160161/* Compiled pipe_viewport_state */162struct compiled_viewport_state {163uint32_t PA_VIEWPORT_SCALE_X;164uint32_t PA_VIEWPORT_SCALE_Y;165uint32_t PA_VIEWPORT_SCALE_Z;166uint32_t PA_VIEWPORT_OFFSET_X;167uint32_t PA_VIEWPORT_OFFSET_Y;168uint32_t PA_VIEWPORT_OFFSET_Z;169uint32_t SE_SCISSOR_LEFT;170uint32_t SE_SCISSOR_TOP;171uint32_t SE_SCISSOR_RIGHT;172uint32_t SE_SCISSOR_BOTTOM;173uint32_t PE_DEPTH_NEAR;174uint32_t PE_DEPTH_FAR;175};176177/* Compiled pipe_framebuffer_state */178struct compiled_framebuffer_state {179uint32_t GL_MULTI_SAMPLE_CONFIG;180uint32_t PE_COLOR_FORMAT;181uint32_t PE_DEPTH_CONFIG;182struct etna_reloc PE_DEPTH_ADDR;183struct etna_reloc PE_PIPE_DEPTH_ADDR[ETNA_MAX_PIXELPIPES];184uint32_t PE_DEPTH_STRIDE;185uint32_t PE_HDEPTH_CONTROL;186uint32_t PE_DEPTH_NORMALIZE;187struct etna_reloc PE_COLOR_ADDR;188struct etna_reloc PE_PIPE_COLOR_ADDR[ETNA_MAX_PIXELPIPES];189uint32_t PE_COLOR_STRIDE;190uint32_t PE_MEM_CONFIG;191uint32_t RA_MULTISAMPLE_UNK00E04;192uint32_t RA_MULTISAMPLE_UNK00E10[VIVS_RA_MULTISAMPLE_UNK00E10__LEN];193uint32_t RA_CENTROID_TABLE[VIVS_RA_CENTROID_TABLE__LEN];194uint32_t TS_MEM_CONFIG;195uint32_t TS_DEPTH_CLEAR_VALUE;196struct etna_reloc TS_DEPTH_STATUS_BASE;197struct etna_reloc TS_DEPTH_SURFACE_BASE;198uint32_t TS_COLOR_CLEAR_VALUE;199uint32_t TS_COLOR_CLEAR_VALUE_EXT;200struct etna_reloc TS_COLOR_STATUS_BASE;201struct etna_reloc TS_COLOR_SURFACE_BASE;202uint32_t PE_LOGIC_OP;203uint32_t PS_CONTROL;204uint32_t PS_CONTROL_EXT;205bool msaa_mode; /* adds input (and possible temp) to PS */206};207208/* Compiled context->create_vertex_elements_state */209struct compiled_vertex_elements_state {210unsigned num_elements;211uint32_t FE_VERTEX_ELEMENT_CONFIG[VIVS_FE_VERTEX_ELEMENT_CONFIG__LEN];212uint32_t NFE_GENERIC_ATTRIB_CONFIG0[VIVS_NFE_GENERIC_ATTRIB__LEN];213uint32_t NFE_GENERIC_ATTRIB_SCALE[VIVS_NFE_GENERIC_ATTRIB__LEN];214uint32_t NFE_GENERIC_ATTRIB_CONFIG1[VIVS_NFE_GENERIC_ATTRIB__LEN];215unsigned num_buffers;216uint32_t NFE_VERTEX_STREAMS_VERTEX_DIVISOR[VIVS_NFE_VERTEX_STREAMS__LEN];217};218219/* Compiled context->set_vertex_buffer result */220struct compiled_set_vertex_buffer {221uint32_t FE_VERTEX_STREAM_CONTROL;222struct etna_reloc FE_VERTEX_STREAM_BASE_ADDR;223};224225/* Compiled linked VS+PS shader state */226struct compiled_shader_state {227uint32_t RA_CONTROL;228uint32_t PA_ATTRIBUTE_ELEMENT_COUNT;229uint32_t PA_CONFIG;230uint32_t PA_SHADER_ATTRIBUTES[VIVS_PA_SHADER_ATTRIBUTES__LEN];231uint32_t VS_END_PC;232uint32_t VS_OUTPUT_COUNT; /* number of outputs if point size per vertex disabled */233uint32_t VS_OUTPUT_COUNT_PSIZE; /* number of outputs of point size per vertex enabled */234uint32_t VS_INPUT_COUNT;235uint32_t VS_TEMP_REGISTER_CONTROL;236uint32_t VS_OUTPUT[4];237uint32_t VS_INPUT[4];238uint32_t VS_LOAD_BALANCING;239uint32_t VS_START_PC;240uint32_t PS_END_PC;241uint32_t PS_OUTPUT_REG;242uint32_t PS_INPUT_COUNT;243uint32_t PS_INPUT_COUNT_MSAA; /* Adds an input */244uint32_t PS_TEMP_REGISTER_CONTROL;245uint32_t PS_TEMP_REGISTER_CONTROL_MSAA; /* Adds a temporary if needed to make space for extra input */246uint32_t PS_START_PC;247uint32_t GL_VARYING_TOTAL_COMPONENTS;248uint32_t GL_VARYING_NUM_COMPONENTS[2];249uint32_t GL_VARYING_COMPONENT_USE[2];250uint32_t GL_HALTI5_SH_SPECIALS;251uint32_t FE_HALTI5_ID_CONFIG;252unsigned vs_inst_mem_size;253unsigned ps_inst_mem_size;254uint32_t *VS_INST_MEM;255uint32_t *PS_INST_MEM;256struct etna_reloc PS_INST_ADDR;257struct etna_reloc VS_INST_ADDR;258unsigned writes_z:1;259unsigned uses_discard:1;260};261262/* Helpers to assist creating and setting bitarrays (eg, for varyings).263* field_size must be a power of two, and <= 32. */264#define DEFINE_ETNA_BITARRAY(name, num, field_size) \265uint32_t name[(num) * (field_size) / 32]266267static inline void268etna_bitarray_set(uint32_t *array, size_t array_size, size_t field_size,269size_t index, uint32_t value)270{271size_t shift = (index * field_size) % 32;272size_t offset = (index * field_size) / 32;273274assert(index < array_size * 32 / field_size);275assert(value < 1 << field_size);276277array[offset] |= value << shift;278}279280#define etna_bitarray_set(array, field_size, index, value) \281etna_bitarray_set((array), ARRAY_SIZE(array), field_size, index, value)282283#endif284285286