Path: blob/master/drivers/gpu/drm/radeon/r600_blit_shaders.c
15113 views
/*1* Copyright 2009 Advanced Micro Devices, Inc.2*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, sublicense,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 the next11* paragraph) shall be included in all copies or substantial portions of the12* 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 NONINFRINGEMENT. IN NO EVENT SHALL17* THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR18* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,19* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*22* Authors:23* Alex Deucher <[email protected]>24*/2526#include <linux/types.h>27#include <linux/kernel.h>2829/*30* R6xx+ cards need to use the 3D engine to blit data which requires31* quite a bit of hw state setup. Rather than pull the whole 3D driver32* (which normally generates the 3D state) into the DRM, we opt to use33* statically generated state tables. The regsiter state and shaders34* were hand generated to support blitting functionality. See the 3D35* driver or documentation for descriptions of the registers and36* shader instructions.37*/3839const u32 r6xx_default_state[] =40{410xc0002400, /* START_3D_CMDBUF */420x00000000,43440xc0012800, /* CONTEXT_CONTROL */450x80000000,460x80000000,47480xc0016800,490x00000010,500x00008000, /* WAIT_UNTIL */51520xc0016800,530x00000542,540x07000003, /* TA_CNTL_AUX */55560xc0016800,570x000005c5,580x00000000, /* VC_ENHANCE */59600xc0016800,610x00000363,620x00000000, /* SQ_DYN_GPR_CNTL_PS_FLUSH_REQ */63640xc0016800,650x0000060c,660x82000000, /* DB_DEBUG */67680xc0016800,690x0000060e,700x01020204, /* DB_WATERMARKS */71720xc0026f00,730x00000000,740x00000000, /* SQ_VTX_BASE_VTX_LOC */750x00000000, /* SQ_VTX_START_INST_LOC */76770xc0096900,780x0000022a,790x00000000, /* SQ_ESGS_RING_ITEMSIZE */800x00000000,810x00000000,820x00000000,830x00000000,840x00000000,850x00000000,860x00000000,870x00000000,88890xc0016900,900x00000004,910x00000000, /* DB_DEPTH_INFO */92930xc0026900,940x0000000a,950x00000000, /* DB_STENCIL_CLEAR */960x00000000, /* DB_DEPTH_CLEAR */97980xc0016900,990x00000200,1000x00000000, /* DB_DEPTH_CONTROL */1011020xc0026900,1030x00000343,1040x00000060, /* DB_RENDER_CONTROL */1050x00000040, /* DB_RENDER_OVERRIDE */1061070xc0016900,1080x00000351,1090x0000aa00, /* DB_ALPHA_TO_MASK */1101110xc00f6900,1120x00000100,1130x00000800, /* VGT_MAX_VTX_INDX */1140x00000000, /* VGT_MIN_VTX_INDX */1150x00000000, /* VGT_INDX_OFFSET */1160x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */1170x00000000, /* SX_ALPHA_TEST_CONTROL */1180x00000000, /* CB_BLEND_RED */1190x00000000,1200x00000000,1210x00000000,1220x00000000, /* CB_FOG_RED */1230x00000000,1240x00000000,1250x00000000, /* DB_STENCILREFMASK */1260x00000000, /* DB_STENCILREFMASK_BF */1270x00000000, /* SX_ALPHA_REF */1281290xc0046900,1300x0000030c,1310x01000000, /* CB_CLRCMP_CNTL */1320x00000000,1330x00000000,1340x00000000,1351360xc0046900,1370x00000048,1380x3f800000, /* CB_CLEAR_RED */1390x00000000,1400x3f800000,1410x3f800000,1421430xc0016900,1440x00000080,1450x00000000, /* PA_SC_WINDOW_OFFSET */1461470xc00a6900,1480x00000083,1490x0000ffff, /* PA_SC_CLIP_RECT_RULE */1500x00000000, /* PA_SC_CLIPRECT_0_TL */1510x20002000,1520x00000000,1530x20002000,1540x00000000,1550x20002000,1560x00000000,1570x20002000,1580x00000000, /* PA_SC_EDGERULE */1591600xc0406900,1610x00000094,1620x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */1630x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */1640x80000000, /* PA_SC_VPORT_SCISSOR_1_TL */1650x20002000,1660x80000000,1670x20002000,1680x80000000,1690x20002000,1700x80000000,1710x20002000,1720x80000000,1730x20002000,1740x80000000,1750x20002000,1760x80000000,1770x20002000,1780x80000000,1790x20002000,1800x80000000,1810x20002000,1820x80000000,1830x20002000,1840x80000000,1850x20002000,1860x80000000,1870x20002000,1880x80000000,1890x20002000,1900x80000000,1910x20002000,1920x80000000,1930x20002000,1940x00000000, /* PA_SC_VPORT_ZMIN_0 */1950x3f800000,1960x00000000,1970x3f800000,1980x00000000,1990x3f800000,2000x00000000,2010x3f800000,2020x00000000,2030x3f800000,2040x00000000,2050x3f800000,2060x00000000,2070x3f800000,2080x00000000,2090x3f800000,2100x00000000,2110x3f800000,2120x00000000,2130x3f800000,2140x00000000,2150x3f800000,2160x00000000,2170x3f800000,2180x00000000,2190x3f800000,2200x00000000,2210x3f800000,2220x00000000,2230x3f800000,2240x00000000,2250x3f800000,2262270xc0026900,2280x00000292,2290x00000000, /* PA_SC_MPASS_PS_CNTL */2300x00004010, /* PA_SC_MODE_CNTL */2312320xc0096900,2330x00000300,2340x00000000, /* PA_SC_LINE_CNTL */2350x00000000, /* PA_SC_AA_CONFIG */2360x0000002d, /* PA_SU_VTX_CNTL */2370x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */2380x3f800000,2390x3f800000,2400x3f800000,2410x00000000, /* PA_SC_SAMPLE_LOCS_MCTX */2420x00000000,2432440xc0016900,2450x00000312,2460xffffffff, /* PA_SC_AA_MASK */2472480xc0066900,2490x0000037e,2500x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */2510x00000000, /* PA_SU_POLY_OFFSET_CLAMP */2520x00000000, /* PA_SU_POLY_OFFSET_FRONT_SCALE */2530x00000000, /* PA_SU_POLY_OFFSET_FRONT_OFFSET */2540x00000000, /* PA_SU_POLY_OFFSET_BACK_SCALE */2550x00000000, /* PA_SU_POLY_OFFSET_BACK_OFFSET */2562570xc0046900,2580x000001b6,2590x00000000, /* SPI_INPUT_Z */2600x00000000, /* SPI_FOG_CNTL */2610x00000000, /* SPI_FOG_FUNC_SCALE */2620x00000000, /* SPI_FOG_FUNC_BIAS */2632640xc0016900,2650x00000225,2660x00000000, /* SQ_PGM_START_FS */2672680xc0016900,2690x00000229,2700x00000000, /* SQ_PGM_RESOURCES_FS */2712720xc0016900,2730x00000237,2740x00000000, /* SQ_PGM_CF_OFFSET_FS */2752760xc0026900,2770x000002a8,2780x00000000, /* VGT_INSTANCE_STEP_RATE_0 */2790x00000000, /* VGT_INSTANCE_STEP_RATE_1 */2802810xc0116900,2820x00000280,2830x00000000, /* PA_SU_POINT_SIZE */2840x00000000, /* PA_SU_POINT_MINMAX */2850x00000008, /* PA_SU_LINE_CNTL */2860x00000000, /* PA_SC_LINE_STIPPLE */2870x00000000, /* VGT_OUTPUT_PATH_CNTL */2880x00000000, /* VGT_HOS_CNTL */2890x00000000, /* VGT_HOS_MAX_TESS_LEVEL */2900x00000000, /* VGT_HOS_MIN_TESS_LEVEL */2910x00000000, /* VGT_HOS_REUSE_DEPTH */2920x00000000, /* VGT_GROUP_PRIM_TYPE */2930x00000000, /* VGT_GROUP_FIRST_DECR */2940x00000000, /* VGT_GROUP_DECR */2950x00000000, /* VGT_GROUP_VECT_0_CNTL */2960x00000000, /* VGT_GROUP_VECT_1_CNTL */2970x00000000, /* VGT_GROUP_VECT_0_FMT_CNTL */2980x00000000, /* VGT_GROUP_VECT_1_FMT_CNTL */2990x00000000, /* VGT_GS_MODE */3003010xc0016900,3020x000002a1,3030x00000000, /* VGT_PRIMITIVEID_EN */3043050xc0016900,3060x000002a5,3070x00000000, /* VGT_MULTI_PRIM_ID_RESET_EN */3083090xc0036900,3100x000002ac,3110x00000000, /* VGT_STRMOUT_EN */3120x00000000, /* VGT_REUSE_OFF */3130x00000000, /* VGT_VTX_CNT_EN */3143150xc0016900,3160x000002c8,3170x00000000, /* VGT_STRMOUT_BUFFER_EN */3183190xc0076900,3200x00000202,3210x00cc0000, /* CB_COLOR_CONTROL */3220x00000210, /* DB_SHADER_CNTL */3230x00010000, /* PA_CL_CLIP_CNTL */3240x00000244, /* PA_SU_SC_MODE_CNTL */3250x00000100, /* PA_CL_VTE_CNTL */3260x00000000, /* PA_CL_VS_OUT_CNTL */3270x00000000, /* PA_CL_NANINF_CNTL */3283290xc0026900,3300x0000008e,3310x0000000f, /* CB_TARGET_MASK */3320x0000000f, /* CB_SHADER_MASK */3333340xc0016900,3350x000001e8,3360x00000001, /* CB_SHADER_CONTROL */3373380xc0016900,3390x00000185,3400x00000000, /* SPI_VS_OUT_ID_0 */3413420xc0016900,3430x00000191,3440x00000b00, /* SPI_PS_INPUT_CNTL_0 */3453460xc0056900,3470x000001b1,3480x00000000, /* SPI_VS_OUT_CONFIG */3490x00000000, /* SPI_THREAD_GROUPING */3500x00000001, /* SPI_PS_IN_CONTROL_0 */3510x00000000, /* SPI_PS_IN_CONTROL_1 */3520x00000000, /* SPI_INTERP_CONTROL_0 */3533540xc0036e00, /* SET_SAMPLER */3550x00000000,3560x00000012,3570x00000000,3580x00000000,359};360361const u32 r7xx_default_state[] =362{3630xc0012800, /* CONTEXT_CONTROL */3640x80000000,3650x80000000,3663670xc0016800,3680x00000010,3690x00008000, /* WAIT_UNTIL */3703710xc0016800,3720x00000542,3730x07000002, /* TA_CNTL_AUX */3743750xc0016800,3760x000005c5,3770x00000000, /* VC_ENHANCE */3783790xc0016800,3800x00000363,3810x00004000, /* SQ_DYN_GPR_CNTL_PS_FLUSH_REQ */3823830xc0016800,3840x0000060c,3850x00000000, /* DB_DEBUG */3863870xc0016800,3880x0000060e,3890x00420204, /* DB_WATERMARKS */3903910xc0026f00,3920x00000000,3930x00000000, /* SQ_VTX_BASE_VTX_LOC */3940x00000000, /* SQ_VTX_START_INST_LOC */3953960xc0096900,3970x0000022a,3980x00000000, /* SQ_ESGS_RING_ITEMSIZE */3990x00000000,4000x00000000,4010x00000000,4020x00000000,4030x00000000,4040x00000000,4050x00000000,4060x00000000,4074080xc0016900,4090x00000004,4100x00000000, /* DB_DEPTH_INFO */4114120xc0026900,4130x0000000a,4140x00000000, /* DB_STENCIL_CLEAR */4150x00000000, /* DB_DEPTH_CLEAR */4164170xc0016900,4180x00000200,4190x00000000, /* DB_DEPTH_CONTROL */4204210xc0026900,4220x00000343,4230x00000060, /* DB_RENDER_CONTROL */4240x00000000, /* DB_RENDER_OVERRIDE */4254260xc0016900,4270x00000351,4280x0000aa00, /* DB_ALPHA_TO_MASK */4294300xc0096900,4310x00000100,4320x00000800, /* VGT_MAX_VTX_INDX */4330x00000000, /* VGT_MIN_VTX_INDX */4340x00000000, /* VGT_INDX_OFFSET */4350x00000000, /* VGT_MULTI_PRIM_IB_RESET_INDX */4360x00000000, /* SX_ALPHA_TEST_CONTROL */4370x00000000, /* CB_BLEND_RED */4380x00000000,4390x00000000,4400x00000000,4414420xc0036900,4430x0000010c,4440x00000000, /* DB_STENCILREFMASK */4450x00000000, /* DB_STENCILREFMASK_BF */4460x00000000, /* SX_ALPHA_REF */4474480xc0046900,4490x0000030c, /* CB_CLRCMP_CNTL */4500x01000000,4510x00000000,4520x00000000,4530x00000000,4544550xc0016900,4560x00000080,4570x00000000, /* PA_SC_WINDOW_OFFSET */4584590xc00a6900,4600x00000083,4610x0000ffff, /* PA_SC_CLIP_RECT_RULE */4620x00000000, /* PA_SC_CLIPRECT_0_TL */4630x20002000,4640x00000000,4650x20002000,4660x00000000,4670x20002000,4680x00000000,4690x20002000,4700xaaaaaaaa, /* PA_SC_EDGERULE */4714720xc0406900,4730x00000094,4740x80000000, /* PA_SC_VPORT_SCISSOR_0_TL */4750x20002000, /* PA_SC_VPORT_SCISSOR_0_BR */4760x80000000, /* PA_SC_VPORT_SCISSOR_1_TL */4770x20002000,4780x80000000,4790x20002000,4800x80000000,4810x20002000,4820x80000000,4830x20002000,4840x80000000,4850x20002000,4860x80000000,4870x20002000,4880x80000000,4890x20002000,4900x80000000,4910x20002000,4920x80000000,4930x20002000,4940x80000000,4950x20002000,4960x80000000,4970x20002000,4980x80000000,4990x20002000,5000x80000000,5010x20002000,5020x80000000,5030x20002000,5040x80000000,5050x20002000,5060x00000000, /* PA_SC_VPORT_ZMIN_0 */5070x3f800000,5080x00000000,5090x3f800000,5100x00000000,5110x3f800000,5120x00000000,5130x3f800000,5140x00000000,5150x3f800000,5160x00000000,5170x3f800000,5180x00000000,5190x3f800000,5200x00000000,5210x3f800000,5220x00000000,5230x3f800000,5240x00000000,5250x3f800000,5260x00000000,5270x3f800000,5280x00000000,5290x3f800000,5300x00000000,5310x3f800000,5320x00000000,5330x3f800000,5340x00000000,5350x3f800000,5360x00000000,5370x3f800000,5385390xc0026900,5400x00000292,5410x00000000, /* PA_SC_MPASS_PS_CNTL */5420x00514000, /* PA_SC_MODE_CNTL */5435440xc0096900,5450x00000300,5460x00000000, /* PA_SC_LINE_CNTL */5470x00000000, /* PA_SC_AA_CONFIG */5480x0000002d, /* PA_SU_VTX_CNTL */5490x3f800000, /* PA_CL_GB_VERT_CLIP_ADJ */5500x3f800000,5510x3f800000,5520x3f800000,5530x00000000, /* PA_SC_SAMPLE_LOCS_MCTX */5540x00000000,5555560xc0016900,5570x00000312,5580xffffffff, /* PA_SC_AA_MASK */5595600xc0066900,5610x0000037e,5620x00000000, /* PA_SU_POLY_OFFSET_DB_FMT_CNTL */5630x00000000, /* PA_SU_POLY_OFFSET_CLAMP */5640x00000000, /* PA_SU_POLY_OFFSET_FRONT_SCALE */5650x00000000, /* PA_SU_POLY_OFFSET_FRONT_OFFSET */5660x00000000, /* PA_SU_POLY_OFFSET_BACK_SCALE */5670x00000000, /* PA_SU_POLY_OFFSET_BACK_OFFSET */5685690xc0046900,5700x000001b6,5710x00000000, /* SPI_INPUT_Z */5720x00000000, /* SPI_FOG_CNTL */5730x00000000, /* SPI_FOG_FUNC_SCALE */5740x00000000, /* SPI_FOG_FUNC_BIAS */5755760xc0016900,5770x00000225,5780x00000000, /* SQ_PGM_START_FS */5795800xc0016900,5810x00000229,5820x00000000, /* SQ_PGM_RESOURCES_FS */5835840xc0016900,5850x00000237,5860x00000000, /* SQ_PGM_CF_OFFSET_FS */5875880xc0026900,5890x000002a8,5900x00000000, /* VGT_INSTANCE_STEP_RATE_0 */5910x00000000, /* VGT_INSTANCE_STEP_RATE_1 */5925930xc0116900,5940x00000280,5950x00000000, /* PA_SU_POINT_SIZE */5960x00000000, /* PA_SU_POINT_MINMAX */5970x00000008, /* PA_SU_LINE_CNTL */5980x00000000, /* PA_SC_LINE_STIPPLE */5990x00000000, /* VGT_OUTPUT_PATH_CNTL */6000x00000000, /* VGT_HOS_CNTL */6010x00000000, /* VGT_HOS_MAX_TESS_LEVEL */6020x00000000, /* VGT_HOS_MIN_TESS_LEVEL */6030x00000000, /* VGT_HOS_REUSE_DEPTH */6040x00000000, /* VGT_GROUP_PRIM_TYPE */6050x00000000, /* VGT_GROUP_FIRST_DECR */6060x00000000, /* VGT_GROUP_DECR */6070x00000000, /* VGT_GROUP_VECT_0_CNTL */6080x00000000, /* VGT_GROUP_VECT_1_CNTL */6090x00000000, /* VGT_GROUP_VECT_0_FMT_CNTL */6100x00000000, /* VGT_GROUP_VECT_1_FMT_CNTL */6110x00000000, /* VGT_GS_MODE */6126130xc0016900,6140x000002a1,6150x00000000, /* VGT_PRIMITIVEID_EN */6166170xc0016900,6180x000002a5,6190x00000000, /* VGT_MULTI_PRIM_ID_RESET_EN */6206210xc0036900,6220x000002ac,6230x00000000, /* VGT_STRMOUT_EN */6240x00000000, /* VGT_REUSE_OFF */6250x00000000, /* VGT_VTX_CNT_EN */6266270xc0016900,6280x000002c8,6290x00000000, /* VGT_STRMOUT_BUFFER_EN */6306310xc0076900,6320x00000202,6330x00cc0000, /* CB_COLOR_CONTROL */6340x00000210, /* DB_SHADER_CNTL */6350x00010000, /* PA_CL_CLIP_CNTL */6360x00000244, /* PA_SU_SC_MODE_CNTL */6370x00000100, /* PA_CL_VTE_CNTL */6380x00000000, /* PA_CL_VS_OUT_CNTL */6390x00000000, /* PA_CL_NANINF_CNTL */6406410xc0026900,6420x0000008e,6430x0000000f, /* CB_TARGET_MASK */6440x0000000f, /* CB_SHADER_MASK */6456460xc0016900,6470x000001e8,6480x00000001, /* CB_SHADER_CONTROL */6496500xc0016900,6510x00000185,6520x00000000, /* SPI_VS_OUT_ID_0 */6536540xc0016900,6550x00000191,6560x00000b00, /* SPI_PS_INPUT_CNTL_0 */6576580xc0056900,6590x000001b1,6600x00000000, /* SPI_VS_OUT_CONFIG */6610x00000001, /* SPI_THREAD_GROUPING */6620x00000001, /* SPI_PS_IN_CONTROL_0 */6630x00000000, /* SPI_PS_IN_CONTROL_1 */6640x00000000, /* SPI_INTERP_CONTROL_0 */6656660xc0036e00, /* SET_SAMPLER */6670x00000000,6680x00000012,6690x00000000,6700x00000000,671};672673/* same for r6xx/r7xx */674const u32 r6xx_vs[] =675{6760x00000004,6770x81000000,6780x0000203c,6790x94000b08,6800x00004000,6810x14200b1a,6820x00000000,6830x00000000,6840x3c000000,6850x68cd1000,686#ifdef __BIG_ENDIAN6870x000a0000,688#else6890x00080000,690#endif6910x00000000,692};693694const u32 r6xx_ps[] =695{6960x00000002,6970x80800000,6980x00000000,6990x94200688,7000x00000010,7010x000d1000,7020xb0800000,7030x00000000,704};705706const u32 r6xx_ps_size = ARRAY_SIZE(r6xx_ps);707const u32 r6xx_vs_size = ARRAY_SIZE(r6xx_vs);708const u32 r6xx_default_size = ARRAY_SIZE(r6xx_default_state);709const u32 r7xx_default_size = ARRAY_SIZE(r7xx_default_state);710711712