1 /************************************************************************** 2 * 3 * Copyright 2009 VMware, Inc. All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portions 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 * 25 **************************************************************************/ 26 27 #ifndef ASM_FILTERS_H 28 #define ASM_FILTERS_H 29 30 static const char color_matrix_asm[] = 31 "FRAG\n" 32 "DCL IN[0], GENERIC[0], PERSPECTIVE\n" 33 "DCL OUT[0], COLOR, CONSTANT\n" 34 "DCL CONST[0..4], CONSTANT\n" 35 "DCL TEMP[0..4], CONSTANT\n" 36 "DCL SAMP[0], CONSTANT\n" 37 "TEX TEMP[0], IN[0], SAMP[0], 2D\n" 38 "MOV TEMP[1], TEMP[0].xxxx\n" 39 "MOV TEMP[2], TEMP[0].yyyy\n" 40 "MOV TEMP[3], TEMP[0].zzzz\n" 41 "MOV TEMP[4], TEMP[0].wwww\n" 42 "MUL TEMP[1], TEMP[1], CONST[0]\n" 43 "MUL TEMP[2], TEMP[2], CONST[1]\n" 44 "MUL TEMP[3], TEMP[3], CONST[2]\n" 45 "MUL TEMP[4], TEMP[4], CONST[3]\n" 46 "ADD TEMP[0], TEMP[1], CONST[4]\n" 47 "ADD TEMP[0], TEMP[0], TEMP[2]\n" 48 "ADD TEMP[0], TEMP[0], TEMP[3]\n" 49 "ADD TEMP[0], TEMP[0], TEMP[4]\n" 50 "MOV OUT[0], TEMP[0]\n" 51 "END\n"; 52 53 static const char convolution_asm[] = 54 "FRAG\n" 55 "DCL IN[0], GENERIC[0], PERSPECTIVE\n" 56 "DCL OUT[0], COLOR, CONSTANT\n" 57 "DCL TEMP[0..4], CONSTANT\n" 58 "DCL ADDR[0], CONSTANT\n" 59 "DCL CONST[0..%d], CONSTANT\n" 60 "DCL SAMP[0], CONSTANT\n" 61 "0: MOV TEMP[0], CONST[0].xxxx\n" 62 "1: MOV TEMP[1], CONST[0].xxxx\n" 63 "2: BGNLOOP :14\n" 64 "3: SGE TEMP[0].z, TEMP[0].yyyy, CONST[1].xxxx\n" 65 "4: IF TEMP[0].zzzz :7\n" 66 "5: BRK\n" 67 "6: ENDIF\n" 68 "7: ARL ADDR[0].x, TEMP[0].yyyy\n" 69 "8: MOV TEMP[3], CONST[ADDR[0]+2]\n" 70 "9: ADD TEMP[4].xy, IN[0], TEMP[3]\n" 71 "10: TEX TEMP[2], TEMP[4], SAMP[0], 2D\n" 72 "11: MOV TEMP[3], CONST[ADDR[0]+%d]\n" 73 "12: MAD TEMP[1], TEMP[2], TEMP[3], TEMP[1]\n" 74 "13: ADD TEMP[0].y, TEMP[0].yyyy, CONST[0].yyyy\n" 75 "14: ENDLOOP :2\n" 76 "15: MAD OUT[0], TEMP[1], CONST[1].yyyy, CONST[1].zzzz\n" 77 "16: END\n"; 78 79 80 static const char lookup_asm[] = 81 "FRAG\n" 82 "DCL IN[0], GENERIC[0], PERSPECTIVE\n" 83 "DCL OUT[0], COLOR, CONSTANT\n" 84 "DCL TEMP[0..2], CONSTANT\n" 85 "DCL CONST[0], CONSTANT\n" 86 "DCL SAMP[0..1], CONSTANT\n" 87 "TEX TEMP[0], IN[0], SAMP[0], 2D\n" 88 "MOV TEMP[1], TEMP[0]\n" 89 /* do red */ 90 "TEX TEMP[2], TEMP[1].xxxx, SAMP[1], 1D\n" 91 "MOV TEMP[0].x, TEMP[2].xxxx\n" 92 /* do blue */ 93 "TEX TEMP[2], TEMP[1].yyyy, SAMP[1], 1D\n" 94 "MOV TEMP[0].y, TEMP[2].yyyy\n" 95 /* do green */ 96 "TEX TEMP[2], TEMP[1].zzzz, SAMP[1], 1D\n" 97 "MOV TEMP[0].z, TEMP[2].zzzz\n" 98 /* do alpha */ 99 "TEX TEMP[2], TEMP[1].wwww, SAMP[1], 1D\n" 100 "MOV TEMP[0].w, TEMP[2].wwww\n" 101 "MOV OUT[0], TEMP[0]\n" 102 "END\n"; 103 104 105 static const char lookup_single_asm[] = 106 "FRAG\n" 107 "DCL IN[0], GENERIC[0], PERSPECTIVE\n" 108 "DCL OUT[0], COLOR, CONSTANT\n" 109 "DCL TEMP[0..2], CONSTANT\n" 110 "DCL CONST[0], CONSTANT\n" 111 "DCL SAMP[0..1], CONSTANT\n" 112 "TEX TEMP[0], IN[0], SAMP[0], 2D\n" 113 "TEX TEMP[1], TEMP[0].%s, SAMP[1], 1D\n" 114 "MOV OUT[0], TEMP[1]\n" 115 "END\n"; 116 117 #endif 118