tgsi_exec.c revision 80a718a63bf2fa817e346f0f5731ee9ef2e0e68b
1b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/************************************************************************** 2b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 3b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Copyright 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas. 4b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * All Rights Reserved. 5b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 6b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Permission is hereby granted, free of charge, to any person obtaining a 7b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * copy of this software and associated documentation files (the 8b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * "Software"), to deal in the Software without restriction, including 9b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * without limitation the rights to use, copy, modify, merge, publish, 10b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * distribute, sub license, and/or sell copies of the Software, and to 11b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * permit persons to whom the Software is furnished to do so, subject to 12b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * the following conditions: 13b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 14b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * The above copyright notice and this permission notice (including the 15b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * next paragraph) shall be included in all copies or substantial portions 16b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * of the Software. 17b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 18b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 26b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow **************************************************************************/ 27b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 28b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** 29b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * TGSI interpreter/executor. 30b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 31b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Flow control information: 32b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 33b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Since we operate on 'quads' (4 pixels or 4 vertices in parallel) 34b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * flow control statements (IF/ELSE/ENDIF, LOOP/ENDLOOP) require special 35b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * care since a condition may be true for some quad components but false 36b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * for other components. 37b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 38b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * We basically execute all statements (even if they're in the part of 39b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * an IF/ELSE clause that's "not taken") and use a special mask to 40b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * control writing to destination registers. This is the ExecMask. 41b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * See store_dest(). 42b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 43339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow * The ExecMask is computed from three other masks (CondMask, LoopMask and 44b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * ContMask) which are controlled by the flow control instructions (namely: 45b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * (IF/ELSE/ENDIF, LOOP/ENDLOOP and CONT). 46b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * 47339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow * 48b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Authors: 49b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Michal Krol 50b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Brian Paul 51b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 52b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 53b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "pipe/p_compiler.h" 54b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "pipe/p_state.h" 55b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "pipe/p_shader_tokens.h" 56b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "tgsi/tgsi_parse.h" 57b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "tgsi/tgsi_util.h" 58b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "tgsi_exec.h" 59b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "util/u_memory.h" 60b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#include "util/u_math.h" 61b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 62b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define FAST_MATH 1 63b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 64b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TILE_TOP_LEFT 0 65b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TILE_TOP_RIGHT 1 66b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TILE_BOTTOM_LEFT 2 67b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TILE_BOTTOM_RIGHT 3 68b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 69b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define CHAN_X 0 70b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define CHAN_Y 1 71b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define CHAN_Z 2 72b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define CHAN_W 3 73b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 74b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/* 75b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Shorthand locations of various utility registers (_I = Index, _C = Channel) 76b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 77b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_0_I TGSI_EXEC_TEMP_00000000_I 78b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_0_C TGSI_EXEC_TEMP_00000000_C 79b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_7F_I TGSI_EXEC_TEMP_7FFFFFFF_I 80b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_7F_C TGSI_EXEC_TEMP_7FFFFFFF_C 81b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_80_I TGSI_EXEC_TEMP_80000000_I 82b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_80_C TGSI_EXEC_TEMP_80000000_C 83b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_FF_I TGSI_EXEC_TEMP_FFFFFFFF_I 84b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_FF_C TGSI_EXEC_TEMP_FFFFFFFF_C 85b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_1_I TGSI_EXEC_TEMP_ONE_I 86b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_1_C TGSI_EXEC_TEMP_ONE_C 87b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_2_I TGSI_EXEC_TEMP_TWO_I 88b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_2_C TGSI_EXEC_TEMP_TWO_C 89b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_128_I TGSI_EXEC_TEMP_128_I 90b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_128_C TGSI_EXEC_TEMP_128_C 91b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_M128_I TGSI_EXEC_TEMP_MINUS_128_I 92b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_M128_C TGSI_EXEC_TEMP_MINUS_128_C 93b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_KILMASK_I TGSI_EXEC_TEMP_KILMASK_I 94b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_KILMASK_C TGSI_EXEC_TEMP_KILMASK_C 95b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_OUTPUT_I TGSI_EXEC_TEMP_OUTPUT_I 96b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_OUTPUT_C TGSI_EXEC_TEMP_OUTPUT_C 97b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_PRIMITIVE_I TGSI_EXEC_TEMP_PRIMITIVE_I 98b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_PRIMITIVE_C TGSI_EXEC_TEMP_PRIMITIVE_C 99b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_CC_I TGSI_EXEC_TEMP_CC_I 100b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_CC_C TGSI_EXEC_TEMP_CC_C 101b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_3_I TGSI_EXEC_TEMP_THREE_I 102b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_3_C TGSI_EXEC_TEMP_THREE_C 103b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_HALF_I TGSI_EXEC_TEMP_HALF_I 104b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_HALF_C TGSI_EXEC_TEMP_HALF_C 105b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define TEMP_R0 TGSI_EXEC_TEMP_R0 106b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 107b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define IS_CHANNEL_ENABLED(INST, CHAN)\ 108b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN))) 109b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 110b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define IS_CHANNEL_ENABLED2(INST, CHAN)\ 111b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow ((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN))) 112b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 113b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\ 114b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\ 115b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( INST, CHAN )) 116b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 117b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define FOR_EACH_ENABLED_CHANNEL2(INST, CHAN)\ 118b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)\ 119b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED2( INST, CHAN )) 120b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 121b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 122b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** The execution mask depends on the conditional mask and the loop mask */ 123b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define UPDATE_EXEC_MASK(MACH) \ 124b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow MACH->ExecMask = MACH->CondMask & MACH->LoopMask & MACH->ContMask & MACH->FuncMask 125b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 126b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** 127b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Initialize machine state by expanding tokens to full instructions, 128b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * allocating temporary storage, setting up constants, etc. 129b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * After this, we can call tgsi_exec_machine_run() many times. 130b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 131b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowvoid 132b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowtgsi_exec_machine_bind_shader( 133b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach, 134b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_token *tokens, 135b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint numSamplers, 136b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_sampler *samplers) 137b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 138b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint k; 139b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_parse_context parse; 140b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_labels *labels = &mach->Labels; 141b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_full_instruction *instructions; 142b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_full_declaration *declarations; 143b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint maxInstructions = 10, numInstructions = 0; 144b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint maxDeclarations = 10, numDeclarations = 0; 145b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint instno = 0; 146b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 147b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#if 0 148b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow tgsi_dump(tokens, 0); 149b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#endif 150b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 151b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow util_init_math(); 152b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 153b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Tokens = tokens; 154b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Samplers = samplers; 155b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 156b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow k = tgsi_parse_init (&parse, mach->Tokens); 157b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (k != TGSI_PARSE_OK) { 158b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow debug_printf( "Problem parsing!\n" ); 159b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return; 160b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 161b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 162b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Processor = parse.FullHeader.Processor.Processor; 163b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ImmLimit = 0; 164b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow labels->count = 0; 165b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 166b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow declarations = (struct tgsi_full_declaration *) 167b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow MALLOC( maxDeclarations * sizeof(struct tgsi_full_declaration) ); 168b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 169b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (!declarations) { 170b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return; 171b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 172b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 173b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow instructions = (struct tgsi_full_instruction *) 174b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow MALLOC( maxInstructions * sizeof(struct tgsi_full_instruction) ); 175b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 176b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (!instructions) { 177b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FREE( declarations ); 178b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return; 179b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 180b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 181b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow while( !tgsi_parse_end_of_tokens( &parse ) ) { 182b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint pointer = parse.Position; 183b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint i; 184b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 185b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow tgsi_parse_token( &parse ); 186b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch( parse.FullToken.Token.Type ) { 187b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TOKEN_TYPE_DECLARATION: 188b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* save expanded declaration */ 189b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (numDeclarations == maxDeclarations) { 190b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow declarations = REALLOC(declarations, 191b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow maxDeclarations 192b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * sizeof(struct tgsi_full_declaration), 193b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow (maxDeclarations + 10) 194b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * sizeof(struct tgsi_full_declaration)); 195b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow maxDeclarations += 10; 196b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 197b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow memcpy(declarations + numDeclarations, 198b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &parse.FullToken.FullDeclaration, 199b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow sizeof(declarations[0])); 200b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow numDeclarations++; 201b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 202b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 203b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TOKEN_TYPE_IMMEDIATE: 204b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow { 205b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint size = parse.FullToken.FullImmediate.Immediate.Size - 1; 206b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( size % 4 == 0 ); 207b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( mach->ImmLimit + size / 4 <= TGSI_EXEC_NUM_IMMEDIATES ); 208b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 209b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for( i = 0; i < size; i++ ) { 210b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Imms[mach->ImmLimit + i / 4][i % 4] = 211b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow parse.FullToken.FullImmediate.u.ImmediateFloat32[i].Float; 212b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 213b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ImmLimit += size / 4; 214b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 215b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 216b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 217b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TOKEN_TYPE_INSTRUCTION: 218b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( labels->count < MAX_LABELS ); 219b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 220b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow labels->labels[labels->count][0] = instno; 221b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow labels->labels[labels->count][1] = pointer; 222b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow labels->count++; 223b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 224b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* save expanded instruction */ 225b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (numInstructions == maxInstructions) { 226b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow instructions = REALLOC(instructions, 227b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow maxInstructions 228b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * sizeof(struct tgsi_full_instruction), 229b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow (maxInstructions + 10) 230b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * sizeof(struct tgsi_full_instruction)); 231b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow maxInstructions += 10; 232b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 233b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow memcpy(instructions + numInstructions, 234b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &parse.FullToken.FullInstruction, 235b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow sizeof(instructions[0])); 236b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow numInstructions++; 237b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 238b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 239b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 240b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 241b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 242b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 243b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow tgsi_parse_free (&parse); 244b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 245b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->Declarations) { 246b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FREE( mach->Declarations ); 247b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 248b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Declarations = declarations; 249b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->NumDeclarations = numDeclarations; 250b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 251b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->Instructions) { 252b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FREE( mach->Instructions ); 253b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 254b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Instructions = instructions; 255b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->NumInstructions = numInstructions; 256b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 257b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 258b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 259b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowvoid 260b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowtgsi_exec_machine_init( 261b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach ) 262b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 263b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint i; 264b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 265b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps = (struct tgsi_exec_vector *) tgsi_align_128bit( mach->_Temps); 266b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Addrs = &mach->Temps[TGSI_EXEC_TEMP_ADDR]; 267b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 268b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Setup constants. */ 269b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for( i = 0; i < 4; i++ ) { 270b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].u[i] = 0x00000000; 271b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_7F_I].xyzw[TEMP_7F_C].u[i] = 0x7FFFFFFF; 272b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_80_I].xyzw[TEMP_80_C].u[i] = 0x80000000; 273b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_FF_I].xyzw[TEMP_FF_C].u[i] = 0xFFFFFFFF; 274b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].f[i] = 1.0f; 275b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_2_I].xyzw[TEMP_2_C].f[i] = 2.0f; 276b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_128_I].xyzw[TEMP_128_C].f[i] = 128.0f; 277b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C].f[i] = -128.0f; 278b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_3_I].xyzw[TEMP_3_C].f[i] = 3.0f; 279b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C].f[i] = 0.5f; 280b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 281b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 282b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 283b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 284b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowvoid 285b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowtgsi_exec_machine_free_data(struct tgsi_exec_machine *mach) 286b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 287b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->Instructions) { 288b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FREE(mach->Instructions); 289b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Instructions = NULL; 290b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->NumInstructions = 0; 291b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 292b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->Declarations) { 293b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FREE(mach->Declarations); 294b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Declarations = NULL; 295b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->NumDeclarations = 0; 296b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 297b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 298b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 299b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 300b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 301b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_abs( 302b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 303b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 304b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 305b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = fabsf( src->f[0] ); 306b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = fabsf( src->f[1] ); 307339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst->f[2] = fabsf( src->f[2] ); 308b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = fabsf( src->f[3] ); 309b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 310b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 311b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 312b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_add( 313b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 314b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 315b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 316b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 317b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] + src1->f[0]; 318b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] + src1->f[1]; 319b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] + src1->f[2]; 320b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] + src1->f[3]; 321b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 322b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 323b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 324b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_iadd( 325b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 326b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 327b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 328b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 329b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] + src1->i[0]; 330b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] + src1->i[1]; 331b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] + src1->i[2]; 332b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] + src1->i[3]; 333b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 334b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 335b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 336b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_and( 337b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 338339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow const union tgsi_exec_channel *src0, 339b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 340b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 341b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] & src1->u[0]; 342b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] & src1->u[1]; 343b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] & src1->u[2]; 344b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] & src1->u[3]; 345b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 346b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 347b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 348b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ceil( 349b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 350b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 351b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 352b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = ceilf( src->f[0] ); 353b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = ceilf( src->f[1] ); 354b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = ceilf( src->f[2] ); 355b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = ceilf( src->f[3] ); 356b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 357b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 358b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 359b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_cos( 360b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 361b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 362b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 363b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = cosf( src->f[0] ); 364b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = cosf( src->f[1] ); 365b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = cosf( src->f[2] ); 366b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = cosf( src->f[3] ); 367b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 368b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 369b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 370b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ddx( 371b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 372b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 373b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 374b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = 375b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = 376b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = 377b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src->f[TILE_BOTTOM_RIGHT] - src->f[TILE_BOTTOM_LEFT]; 378b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 379b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 380b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 381b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ddy( 382b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 383b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 384b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 385b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = 386b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = 387b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = 388b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src->f[TILE_TOP_LEFT] - src->f[TILE_BOTTOM_LEFT]; 389b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 390b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 391b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 392b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_div( 393b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 394b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 395b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 396b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 397b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (src1->f[0] != 0) { 398b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] / src1->f[0]; 399b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 400b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (src1->f[1] != 0) { 401b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] / src1->f[1]; 402b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 403b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (src1->f[2] != 0) { 404b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] / src1->f[2]; 405b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 406b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (src1->f[3] != 0) { 407b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] / src1->f[3]; 408b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 409b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 410b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 411b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 412b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_udiv( 413b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 414b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 415b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 416b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 417b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] / src1->u[0]; 418b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] / src1->u[1]; 419b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] / src1->u[2]; 420b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] / src1->u[3]; 421b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 422b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 423b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 424b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_eq( 425b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 426b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 427b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 428b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2, 429b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src3 ) 430b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 431b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] == src1->f[0] ? src2->f[0] : src3->f[0]; 432b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] == src1->f[1] ? src2->f[1] : src3->f[1]; 433b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] == src1->f[2] ? src2->f[2] : src3->f[2]; 434b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] == src1->f[3] ? src2->f[3] : src3->f[3]; 435b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 436b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 437b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 438b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ieq( 439b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 440b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 441b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 442b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2, 443b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src3 ) 444b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 445b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] == src1->i[0] ? src2->i[0] : src3->i[0]; 446b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] == src1->i[1] ? src2->i[1] : src3->i[1]; 447b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] == src1->i[2] ? src2->i[2] : src3->i[2]; 448b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] == src1->i[3] ? src2->i[3] : src3->i[3]; 449b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 450b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 451b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 452b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_exp2( 453b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 454b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src) 455b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 456b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#if FAST_MATH 457b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = util_fast_exp2( src->f[0] ); 458b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = util_fast_exp2( src->f[1] ); 459b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = util_fast_exp2( src->f[2] ); 460b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = util_fast_exp2( src->f[3] ); 461b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#else 462b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = powf( 2.0f, src->f[0] ); 463b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = powf( 2.0f, src->f[1] ); 464b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = powf( 2.0f, src->f[2] ); 465b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = powf( 2.0f, src->f[3] ); 466b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#endif 467b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 468b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 469b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 470b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_f2it( 471b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 472b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 473b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 474b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = (int) src->f[0]; 475b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = (int) src->f[1]; 476b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = (int) src->f[2]; 477b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = (int) src->f[3]; 478b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 479b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 480b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 481b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_f2ut( 482b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 483b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 484b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 485b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = (uint) src->f[0]; 486b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = (uint) src->f[1]; 487b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = (uint) src->f[2]; 488b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = (uint) src->f[3]; 489b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 490b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 491b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 492b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_flr( 493b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 494b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 495b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 496b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = floorf( src->f[0] ); 497b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = floorf( src->f[1] ); 498b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = floorf( src->f[2] ); 499b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = floorf( src->f[3] ); 500b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 501b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 502b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 503b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_frc( 504b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 505b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 506b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 507b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src->f[0] - floorf( src->f[0] ); 508b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src->f[1] - floorf( src->f[1] ); 509b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src->f[2] - floorf( src->f[2] ); 510b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src->f[3] - floorf( src->f[3] ); 511b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 512b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 513b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 514b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ge( 515b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 516b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 517b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 518b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2, 519b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src3 ) 520b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 521b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] >= src1->f[0] ? src2->f[0] : src3->f[0]; 522b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] >= src1->f[1] ? src2->f[1] : src3->f[1]; 523b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] >= src1->f[2] ? src2->f[2] : src3->f[2]; 524b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] >= src1->f[3] ? src2->f[3] : src3->f[3]; 525b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 526b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 527b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 528b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_i2f( 529b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 530b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 531b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 532b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = (float) src->i[0]; 533b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = (float) src->i[1]; 534b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = (float) src->i[2]; 535b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = (float) src->i[3]; 536b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 537b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 538b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 539b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_lg2( 540b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 541b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 542b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 543b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#if FAST_MATH 544b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = util_fast_log2( src->f[0] ); 545b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = util_fast_log2( src->f[1] ); 546b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = util_fast_log2( src->f[2] ); 547b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = util_fast_log2( src->f[3] ); 548b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#else 549b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = logf( src->f[0] ) * 1.442695f; 550b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = logf( src->f[1] ) * 1.442695f; 551b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = logf( src->f[2] ) * 1.442695f; 552b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = logf( src->f[3] ) * 1.442695f; 553b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#endif 554b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 555b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 556b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 557b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_le( 558b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 559b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 560b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 561b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2, 562b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src3 ) 563b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 564b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] <= src1->f[0] ? src2->f[0] : src3->f[0]; 565b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] <= src1->f[1] ? src2->f[1] : src3->f[1]; 566b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] <= src1->f[2] ? src2->f[2] : src3->f[2]; 567b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] <= src1->f[3] ? src2->f[3] : src3->f[3]; 568b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 569b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 570b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 571b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_lt( 572b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 573b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 574b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 575b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2, 576b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src3 ) 577b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 578b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] < src1->f[0] ? src2->f[0] : src3->f[0]; 579b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] < src1->f[1] ? src2->f[1] : src3->f[1]; 580b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] < src1->f[2] ? src2->f[2] : src3->f[2]; 581b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] < src1->f[3] ? src2->f[3] : src3->f[3]; 582b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 583b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 584b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 585b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ilt( 586b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 587b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 588b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 589b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2, 590b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src3 ) 591b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 592b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] < src1->i[0] ? src2->i[0] : src3->i[0]; 593b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] < src1->i[1] ? src2->i[1] : src3->i[1]; 594b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] < src1->i[2] ? src2->i[2] : src3->i[2]; 595b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] < src1->i[3] ? src2->i[3] : src3->i[3]; 596b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 597b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 598b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 599b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ult( 600b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 601b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 602b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 603b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2, 604b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src3 ) 605b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 606b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] < src1->u[0] ? src2->u[0] : src3->u[0]; 607b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] < src1->u[1] ? src2->u[1] : src3->u[1]; 608b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] < src1->u[2] ? src2->u[2] : src3->u[2]; 609b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] < src1->u[3] ? src2->u[3] : src3->u[3]; 610b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 611b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 612b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 613b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_max( 614b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 615b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 616b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 617b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 618b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] > src1->f[0] ? src0->f[0] : src1->f[0]; 619b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] > src1->f[1] ? src0->f[1] : src1->f[1]; 620b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] > src1->f[2] ? src0->f[2] : src1->f[2]; 621b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] > src1->f[3] ? src0->f[3] : src1->f[3]; 622b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 623b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 624b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 625b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_imax( 626b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 627b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 628b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 629b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 630b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] > src1->i[0] ? src0->i[0] : src1->i[0]; 631b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] > src1->i[1] ? src0->i[1] : src1->i[1]; 632b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] > src1->i[2] ? src0->i[2] : src1->i[2]; 633b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] > src1->i[3] ? src0->i[3] : src1->i[3]; 634b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 635b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 636b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 637b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_umax( 638b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 639b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 640b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 641b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 642b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] > src1->u[0] ? src0->u[0] : src1->u[0]; 643b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] > src1->u[1] ? src0->u[1] : src1->u[1]; 644b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] > src1->u[2] ? src0->u[2] : src1->u[2]; 645b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] > src1->u[3] ? src0->u[3] : src1->u[3]; 646b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 647b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 648b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 649b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_min( 650b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 651b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 652b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 653b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 654b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] < src1->f[0] ? src0->f[0] : src1->f[0]; 655b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] < src1->f[1] ? src0->f[1] : src1->f[1]; 656b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] < src1->f[2] ? src0->f[2] : src1->f[2]; 657b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] < src1->f[3] ? src0->f[3] : src1->f[3]; 658b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 659b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 660b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 661b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_imin( 662b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 663b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 664b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 665b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 666b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] < src1->i[0] ? src0->i[0] : src1->i[0]; 667b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] < src1->i[1] ? src0->i[1] : src1->i[1]; 668b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] < src1->i[2] ? src0->i[2] : src1->i[2]; 669b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] < src1->i[3] ? src0->i[3] : src1->i[3]; 670b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 671b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 672b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 673b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_umin( 674b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 675b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 676b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 677b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 678b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] < src1->u[0] ? src0->u[0] : src1->u[0]; 679b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] < src1->u[1] ? src0->u[1] : src1->u[1]; 680b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] < src1->u[2] ? src0->u[2] : src1->u[2]; 681b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] < src1->u[3] ? src0->u[3] : src1->u[3]; 682b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 683b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 684b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 685b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_umod( 686b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 687b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 688b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 689b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 690b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] % src1->u[0]; 691b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] % src1->u[1]; 692b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] % src1->u[2]; 693b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] % src1->u[3]; 694b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 695b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 696b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 697b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_mul( 698b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 699b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 700b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 701b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 702b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] * src1->f[0]; 703b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] * src1->f[1]; 704b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] * src1->f[2]; 705b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] * src1->f[3]; 706b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 707b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 708b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 709b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_imul( 710b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 711b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 712b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 713b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 714b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] * src1->i[0]; 715b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] * src1->i[1]; 716b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] * src1->i[2]; 717b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] * src1->i[3]; 718b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 719b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 720b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 721b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_imul64( 722b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst0, 723b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst1, 724b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 725b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 726b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 727b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->i[0] = src0->i[0] * src1->i[0]; 728b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->i[1] = src0->i[1] * src1->i[1]; 729b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->i[2] = src0->i[2] * src1->i[2]; 730b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->i[3] = src0->i[3] * src1->i[3]; 731b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->i[0] = 0; 732b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->i[1] = 0; 733b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->i[2] = 0; 734b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->i[3] = 0; 735b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 736b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 737b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 738b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_umul64( 739b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst0, 740b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst1, 741b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 742b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 743b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 744b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->u[0] = src0->u[0] * src1->u[0]; 745b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->u[1] = src0->u[1] * src1->u[1]; 746b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->u[2] = src0->u[2] * src1->u[2]; 747b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst1->u[3] = src0->u[3] * src1->u[3]; 748b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->u[0] = 0; 749b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->u[1] = 0; 750b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->u[2] = 0; 751b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst0->u[3] = 0; 752b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 753b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 754b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 755b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_movc( 756b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 757b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 758b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1, 759b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src2 ) 760b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 761b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] ? src1->u[0] : src2->u[0]; 762b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] ? src1->u[1] : src2->u[1]; 763b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] ? src1->u[2] : src2->u[2]; 764b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] ? src1->u[3] : src2->u[3]; 765b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 766b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 767b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 768b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_neg( 769b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 770b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 771b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 772b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = -src->f[0]; 773b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = -src->f[1]; 774b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = -src->f[2]; 775b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = -src->f[3]; 776b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 777b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 778b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 779b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ineg( 780b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 781b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 782b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 783b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = -src->i[0]; 784b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = -src->i[1]; 785b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = -src->i[2]; 786b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = -src->i[3]; 787b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 788b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 789b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 790b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_not( 791b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 792b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 793b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 794b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = ~src->u[0]; 795b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = ~src->u[1]; 796b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = ~src->u[2]; 797b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = ~src->u[3]; 798b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 799b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 800b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 801b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_or( 802b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 803b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 804b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 805b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 806b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] | src1->u[0]; 807b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] | src1->u[1]; 808b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] | src1->u[2]; 809b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] | src1->u[3]; 810b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 811b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 812b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 813b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_pow( 814b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 815b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 816b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 817b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 818b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#if FAST_MATH 819b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = util_fast_pow( src0->f[0], src1->f[0] ); 820b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = util_fast_pow( src0->f[1], src1->f[1] ); 821b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = util_fast_pow( src0->f[2], src1->f[2] ); 822b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = util_fast_pow( src0->f[3], src1->f[3] ); 823b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#else 824b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = powf( src0->f[0], src1->f[0] ); 825b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = powf( src0->f[1], src1->f[1] ); 826b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = powf( src0->f[2], src1->f[2] ); 827b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = powf( src0->f[3], src1->f[3] ); 828b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#endif 829b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 830b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 831b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 832b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_rnd( 833b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 834b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 835b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 836b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = floorf( src->f[0] + 0.5f ); 837b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = floorf( src->f[1] + 0.5f ); 838b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = floorf( src->f[2] + 0.5f ); 839b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = floorf( src->f[3] + 0.5f ); 840b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 841b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 842b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 843b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_shl( 844b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 845b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 846b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 847b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 848b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] << src1->i[0]; 849b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] << src1->i[1]; 850b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] << src1->i[2]; 851b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] << src1->i[3]; 852b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 853b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 854b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 855b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ishr( 856b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 857b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 858b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 859b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 860b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[0] = src0->i[0] >> src1->i[0]; 861b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[1] = src0->i[1] >> src1->i[1]; 862b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[2] = src0->i[2] >> src1->i[2]; 863b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[3] = src0->i[3] >> src1->i[3]; 864b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 865b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 866b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 867b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_trunc( 868b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 869b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0 ) 870b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 871b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = (float) (int) src0->f[0]; 872b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = (float) (int) src0->f[1]; 873b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = (float) (int) src0->f[2]; 874b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = (float) (int) src0->f[3]; 875b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 876b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 877b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 878b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_ushr( 879b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 880b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 881b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 882b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 883b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[0] = src0->u[0] >> src1->u[0]; 884b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[1] = src0->u[1] >> src1->u[1]; 885b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[2] = src0->u[2] >> src1->u[2]; 886b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->u[3] = src0->u[3] >> src1->u[3]; 887b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 888b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 889b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 890b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_sin( 891b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 892b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 893b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 894b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = sinf( src->f[0] ); 895b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = sinf( src->f[1] ); 896b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = sinf( src->f[2] ); 897b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = sinf( src->f[3] ); 898b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 899b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 900b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 901b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_sqrt( union tgsi_exec_channel *dst, 902b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 903b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 904b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = sqrtf( src->f[0] ); 905b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = sqrtf( src->f[1] ); 906b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = sqrtf( src->f[2] ); 907b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = sqrtf( src->f[3] ); 908b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 909b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 910b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 911b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_sub( 912b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 913b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src0, 914b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src1 ) 915b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 916b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = src0->f[0] - src1->f[0]; 917b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = src0->f[1] - src1->f[1]; 918b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = src0->f[2] - src1->f[2]; 919b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = src0->f[3] - src1->f[3]; 920b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 921b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 922b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 923b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowmicro_u2f( 924b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst, 925b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *src ) 926b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 927b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[0] = (float) src->u[0]; 928b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[1] = (float) src->u[1]; 929b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[2] = (float) src->u[2]; 930b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[3] = (float) src->u[3]; 931b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 932b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 933b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 934339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komowmicro_xor( 935339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow union tgsi_exec_channel *dst, 936339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow const union tgsi_exec_channel *src0, 937339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow const union tgsi_exec_channel *src1 ) 938339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow{ 939339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst->u[0] = src0->u[0] ^ src1->u[0]; 940339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst->u[1] = src0->u[1] ^ src1->u[1]; 941339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst->u[2] = src0->u[2] ^ src1->u[2]; 942339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst->u[3] = src0->u[3] ^ src1->u[3]; 943339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow} 944339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 945339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komowstatic void 946339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komowfetch_src_file_channel( 947339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow const struct tgsi_exec_machine *mach, 948339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow const uint file, 949b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const uint swizzle, 950b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *index, 951b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *chan ) 952b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 953b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch( swizzle ) { 954b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_EXTSWIZZLE_X: 955b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_EXTSWIZZLE_Y: 956b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_EXTSWIZZLE_Z: 957b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_EXTSWIZZLE_W: 958b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch( file ) { 959b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_FILE_CONSTANT: 960b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->Consts); 961b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(index->i[0] >= 0); 962b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(index->i[1] >= 0); 963b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(index->i[2] >= 0); 964b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(index->i[3] >= 0); 965b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->f[0] = mach->Consts[index->i[0]][swizzle]; 966b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->f[1] = mach->Consts[index->i[1]][swizzle]; 967b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->f[2] = mach->Consts[index->i[2]][swizzle]; 968b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->f[3] = mach->Consts[index->i[3]][swizzle]; 969b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 970b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 971b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_FILE_INPUT: 972b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[0] = mach->Inputs[index->i[0]].xyzw[swizzle].u[0]; 973b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[1] = mach->Inputs[index->i[1]].xyzw[swizzle].u[1]; 974b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[2] = mach->Inputs[index->i[2]].xyzw[swizzle].u[2]; 975b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[3] = mach->Inputs[index->i[3]].xyzw[swizzle].u[3]; 976b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 977b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 978b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_FILE_TEMPORARY: 979b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(index->i[0] < TGSI_EXEC_NUM_TEMPS); 980b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[0] = mach->Temps[index->i[0]].xyzw[swizzle].u[0]; 981b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[1] = mach->Temps[index->i[1]].xyzw[swizzle].u[1]; 982b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[2] = mach->Temps[index->i[2]].xyzw[swizzle].u[2]; 983b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[3] = mach->Temps[index->i[3]].xyzw[swizzle].u[3]; 984b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 985b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 986b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_FILE_IMMEDIATE: 987b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( index->i[0] < (int) mach->ImmLimit ); 988b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->f[0] = mach->Imms[index->i[0]][swizzle]; 989b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( index->i[1] < (int) mach->ImmLimit ); 990b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->f[1] = mach->Imms[index->i[1]][swizzle]; 991339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert( index->i[2] < (int) mach->ImmLimit ); 992339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow chan->f[2] = mach->Imms[index->i[2]][swizzle]; 993339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert( index->i[3] < (int) mach->ImmLimit ); 994339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow chan->f[3] = mach->Imms[index->i[3]][swizzle]; 995339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 996339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 997339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_FILE_ADDRESS: 998339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow chan->u[0] = mach->Addrs[index->i[0]].xyzw[swizzle].u[0]; 999339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow chan->u[1] = mach->Addrs[index->i[1]].xyzw[swizzle].u[1]; 1000339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow chan->u[2] = mach->Addrs[index->i[2]].xyzw[swizzle].u[2]; 1001339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow chan->u[3] = mach->Addrs[index->i[3]].xyzw[swizzle].u[3]; 1002339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1003339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1004339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_FILE_OUTPUT: 1005339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* vertex/fragment output vars can be read too */ 1006b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[0] = mach->Outputs[index->i[0]].xyzw[swizzle].u[0]; 1007b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[1] = mach->Outputs[index->i[1]].xyzw[swizzle].u[1]; 1008b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[2] = mach->Outputs[index->i[2]].xyzw[swizzle].u[2]; 1009b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan->u[3] = mach->Outputs[index->i[3]].xyzw[swizzle].u[3]; 1010b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1011b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1012b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1013b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 1014b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1015b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1016b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1017b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_EXTSWIZZLE_ZERO: 1018b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow *chan = mach->Temps[TEMP_0_I].xyzw[TEMP_0_C]; 1019b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1020b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1021b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_EXTSWIZZLE_ONE: 1022b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow *chan = mach->Temps[TEMP_1_I].xyzw[TEMP_1_C]; 1023b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1024b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1025b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1026b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 1027b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1028b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1029b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1030b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1031b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowfetch_source( 1032b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_exec_machine *mach, 1033b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *chan, 1034b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_src_register *reg, 1035b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const uint chan_index ) 1036b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1037b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel index; 1038b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint swizzle; 1039b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1040b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[0] = 1041b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[1] = 1042b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[2] = 1043b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[3] = reg->SrcRegister.Index; 1044b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1045b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (reg->SrcRegister.Indirect) { 1046b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel index2; 1047b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel indir_index; 1048339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1049339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index2.i[0] = 1050339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index2.i[1] = 1051339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index2.i[2] = 1052339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index2.i[3] = reg->SrcRegisterInd.Index; 1053339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1054339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow swizzle = tgsi_util_get_src_register_swizzle( ®->SrcRegisterInd, CHAN_X ); 1055339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow fetch_src_file_channel( 1056339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mach, 1057339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow reg->SrcRegisterInd.File, 1058339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow swizzle, 1059339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow &index2, 1060339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow &indir_index ); 1061339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1062339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index.i[0] += indir_index.i[0]; 1063b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[1] += indir_index.i[1]; 1064b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[2] += indir_index.i[2]; 1065b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[3] += indir_index.i[3]; 1066b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1067b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1068b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( reg->SrcRegister.Dimension ) { 1069b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch( reg->SrcRegister.File ) { 1070b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_FILE_INPUT: 1071b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[0] *= 17; 1072b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[1] *= 17; 1073b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[2] *= 17; 1074b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[3] *= 17; 1075b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1076b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_FILE_CONSTANT: 1077b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[0] *= 4096; 1078b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[1] *= 4096; 1079b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[2] *= 4096; 1080b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[3] *= 4096; 1081b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1082b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1083b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 1084b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1085b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1086b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[0] += reg->SrcRegisterDim.Index; 1087b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[1] += reg->SrcRegisterDim.Index; 1088b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[2] += reg->SrcRegisterDim.Index; 1089b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index.i[3] += reg->SrcRegisterDim.Index; 1090b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1091b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (reg->SrcRegisterDim.Indirect) { 1092b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel index2; 1093b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel indir_index; 1094b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1095b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index2.i[0] = 1096b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index2.i[1] = 1097b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index2.i[2] = 1098b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow index2.i[3] = reg->SrcRegisterDimInd.Index; 1099b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1100b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle = tgsi_util_get_src_register_swizzle( ®->SrcRegisterDimInd, CHAN_X ); 1101b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow fetch_src_file_channel( 1102b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach, 1103b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow reg->SrcRegisterDimInd.File, 1104b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle, 1105339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow &index2, 1106339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow &indir_index ); 1107339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1108339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index.i[0] += indir_index.i[0]; 1109339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index.i[1] += indir_index.i[1]; 1110339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index.i[2] += indir_index.i[2]; 1111339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow index.i[3] += indir_index.i[3]; 1112339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1113339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1114339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1115339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index ); 1116339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow fetch_src_file_channel( 1117339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mach, 1118339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow reg->SrcRegister.File, 1119339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow swizzle, 1120b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &index, 1121b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan ); 1122b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1123b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (tgsi_util_get_full_src_register_sign_mode( reg, chan_index )) { 1124b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_UTIL_SIGN_CLEAR: 1125b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_abs( chan, chan ); 1126b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1127b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1128b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_UTIL_SIGN_SET: 1129b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_abs( chan, chan ); 1130b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_neg( chan, chan ); 1131b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1132b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1133b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_UTIL_SIGN_TOGGLE: 1134b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_neg( chan, chan ); 1135b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1136b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1137b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_UTIL_SIGN_KEEP: 1138b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1139b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1140b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1141b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (reg->SrcRegisterExtMod.Complement) { 1142b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sub( chan, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], chan ); 1143b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1144b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1145b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1146b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1147b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstore_dest( 1148b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach, 1149b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *chan, 1150b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_dst_register *reg, 1151b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_instruction *inst, 1152b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint chan_index ) 1153b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1154b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint i; 1155b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel null; 1156b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *dst; 1157b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint execmask = mach->ExecMask; 1158b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1159b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (reg->DstRegister.File) { 1160b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_FILE_NULL: 1161b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst = &null; 1162339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1163339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1164339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_FILE_OUTPUT: 1165339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst = &mach->Outputs[mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] 1166339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow + reg->DstRegister.Index].xyzw[chan_index]; 1167339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1168339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1169339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_FILE_TEMPORARY: 1170339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert( reg->DstRegister.Index < TGSI_EXEC_NUM_TEMPS ); 1171339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst = &mach->Temps[reg->DstRegister.Index].xyzw[chan_index]; 1172339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1173339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1174339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_FILE_ADDRESS: 1175339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow dst = &mach->Addrs[reg->DstRegister.Index].xyzw[chan_index]; 1176339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1177b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1178b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1179b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 1180b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return; 1181b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1182b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1183b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (inst->InstructionExtNv.CondFlowEnable) { 1184b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C]; 1185b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint swizzle; 1186b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint shift; 1187b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint mask; 1188b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint test; 1189b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1190b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Only CC0 supported. 1191b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 1192b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( inst->InstructionExtNv.CondFlowIndex < 1 ); 1193b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1194b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (chan_index) { 1195b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case CHAN_X: 1196b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle = inst->InstructionExtNv.CondSwizzleX; 1197b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1198b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case CHAN_Y: 1199b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle = inst->InstructionExtNv.CondSwizzleY; 1200b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1201b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case CHAN_Z: 1202b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle = inst->InstructionExtNv.CondSwizzleZ; 1203b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1204b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case CHAN_W: 1205b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle = inst->InstructionExtNv.CondSwizzleW; 1206b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1207b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1208b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 1209b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return; 1210b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1211b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1212b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (swizzle) { 1213b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_SWIZZLE_X: 1214b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow shift = TGSI_EXEC_CC_X_SHIFT; 1215b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mask = TGSI_EXEC_CC_X_MASK; 1216b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1217b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_SWIZZLE_Y: 1218b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow shift = TGSI_EXEC_CC_Y_SHIFT; 1219339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mask = TGSI_EXEC_CC_Y_MASK; 1220339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1221339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_SWIZZLE_Z: 1222339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow shift = TGSI_EXEC_CC_Z_SHIFT; 1223339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mask = TGSI_EXEC_CC_Z_MASK; 1224339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1225339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_SWIZZLE_W: 1226339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow shift = TGSI_EXEC_CC_W_SHIFT; 1227339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mask = TGSI_EXEC_CC_W_MASK; 1228339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1229339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow default: 1230339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert( 0 ); 1231339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow return; 1232339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1233339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1234b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (inst->InstructionExtNv.CondMask) { 1235b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_CC_GT: 1236b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow test = ~(TGSI_EXEC_CC_GT << shift) & mask; 1237b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1238b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (cc->u[i] & test) 1239b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow execmask &= ~(1 << i); 1240b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1241b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1242b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_CC_EQ: 1243b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow test = ~(TGSI_EXEC_CC_EQ << shift) & mask; 1244b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1245b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (cc->u[i] & test) 1246b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow execmask &= ~(1 << i); 1247b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1248b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1249b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_CC_LT: 1250b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow test = ~(TGSI_EXEC_CC_LT << shift) & mask; 1251b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1252b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (cc->u[i] & test) 1253b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow execmask &= ~(1 << i); 1254b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1255b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1256b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_CC_GE: 1257b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_EQ) << shift) & mask; 1258b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1259b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (cc->u[i] & test) 1260b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow execmask &= ~(1 << i); 1261b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1262b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1263b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_CC_LE: 1264b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow test = ~((TGSI_EXEC_CC_LT | TGSI_EXEC_CC_EQ) << shift) & mask; 1265b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1266b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (cc->u[i] & test) 1267b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow execmask &= ~(1 << i); 1268b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1269b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1270b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_CC_NE: 1271b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow test = ~((TGSI_EXEC_CC_GT | TGSI_EXEC_CC_LT | TGSI_EXEC_CC_UN) << shift) & mask; 1272b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1273b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (cc->u[i] & test) 1274b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow execmask &= ~(1 << i); 1275b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1276339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1277339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_CC_TR: 1278339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1279339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1280339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_CC_FL: 1281339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1282339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow execmask &= ~(1 << i); 1283339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1284339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1285339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow default: 1286339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert( 0 ); 1287339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow return; 1288339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1289339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1290339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1291b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (inst->Instruction.Saturate) { 1292b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_SAT_NONE: 1293b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1294b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (execmask & (1 << i)) 1295b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[i] = chan->i[i]; 1296b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1297b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1298b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_SAT_ZERO_ONE: 1299b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1300b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (execmask & (1 << i)) { 1301b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (chan->f[i] < 0.0f) 1302b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[i] = 0.0f; 1303b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else if (chan->f[i] > 1.0f) 1304b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[i] = 1.0f; 1305b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else 1306b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[i] = chan->i[i]; 1307b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1308b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1309b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1310b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_SAT_MINUS_PLUS_ONE: 1311b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1312b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (execmask & (1 << i)) { 1313b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (chan->f[i] < -1.0f) 1314b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[i] = -1.0f; 1315b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else if (chan->f[i] > 1.0f) 1316b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->f[i] = 1.0f; 1317b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else 1318b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow dst->i[i] = chan->i[i]; 1319b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1320b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1321b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1322b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1323b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 1324b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1325b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1326b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (inst->InstructionExtNv.CondDstUpdate) { 1327b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *cc = &mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C]; 1328b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint shift; 1329b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint mask; 1330b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1331b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Only CC0 supported. 1332b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 1333339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert( inst->InstructionExtNv.CondDstIndex < 1 ); 1334339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1335339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow switch (chan_index) { 1336339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case CHAN_X: 1337339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow shift = TGSI_EXEC_CC_X_SHIFT; 1338339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mask = ~TGSI_EXEC_CC_X_MASK; 1339339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1340339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case CHAN_Y: 1341339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow shift = TGSI_EXEC_CC_Y_SHIFT; 1342339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mask = ~TGSI_EXEC_CC_Y_MASK; 1343339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1344339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case CHAN_Z: 1345339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow shift = TGSI_EXEC_CC_Z_SHIFT; 1346339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mask = ~TGSI_EXEC_CC_Z_MASK; 1347339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1348b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case CHAN_W: 1349b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow shift = TGSI_EXEC_CC_W_SHIFT; 1350b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mask = ~TGSI_EXEC_CC_W_MASK; 1351b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1352b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1353b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 1354b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return; 1355b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1356b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1357b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) 1358b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (execmask & (1 << i)) { 1359b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow cc->u[i] &= mask; 1360b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (dst->f[i] < 0.0f) 1361b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow cc->u[i] |= TGSI_EXEC_CC_LT << shift; 1362b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else if (dst->f[i] > 0.0f) 1363b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow cc->u[i] |= TGSI_EXEC_CC_GT << shift; 1364b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else if (dst->f[i] == 0.0f) 1365b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow cc->u[i] |= TGSI_EXEC_CC_EQ << shift; 1366b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else 1367b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow cc->u[i] |= TGSI_EXEC_CC_UN << shift; 1368b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1369b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1370b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1371b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1372b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define FETCH(VAL,INDEX,CHAN)\ 1373b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow fetch_source (mach, VAL, &inst->FullSrcRegisters[INDEX], CHAN) 1374b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1375b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#define STORE(VAL,INDEX,CHAN)\ 1376b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow store_dest (mach, VAL, &inst->FullDstRegisters[INDEX], inst, CHAN ) 1377b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1378b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1379b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** 1380b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Execute ARB-style KIL which is predicated by a src register. 1381b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Kill fragment if any of the four values is less than zero. 1382b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 1383b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1384b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowexec_kil(struct tgsi_exec_machine *mach, 1385b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_instruction *inst) 1386b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1387b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint uniquemask; 1388b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint chan_index; 1389b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint kilmask = 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */ 1390339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow union tgsi_exec_channel r[1]; 1391339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1392339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* This mask stores component bits that were already tested. Note that 1393339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow * we test if the value is less than zero, so 1.0 and 0.0 need not to be 1394339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow * tested. */ 1395339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE); 1396339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1397339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow for (chan_index = 0; chan_index < 4; chan_index++) 1398339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow { 1399339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow uint swizzle; 1400339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow uint i; 1401339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1402339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* unswizzle channel */ 1403339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow swizzle = tgsi_util_get_full_src_register_extswizzle ( 1404339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow &inst->FullSrcRegisters[0], 1405b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow chan_index); 1406b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1407b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* check if the component has not been already tested */ 1408b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (uniquemask & (1 << swizzle)) 1409b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow continue; 1410b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uniquemask |= 1 << swizzle; 1411b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1412b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, chan_index); 1413b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < 4; i++) 1414b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (r[0].f[i] < 0.0f) 1415b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow kilmask |= 1 << i; 1416b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1417b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1418b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask; 1419b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1420b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1421b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** 1422b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Execute NVIDIA-style KIL which is predicated by a condition code. 1423b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Kill fragment if the condition code is TRUE. 1424b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 1425b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1426b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowexec_kilp(struct tgsi_exec_machine *mach, 1427b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_instruction *inst) 1428b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1429b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint kilmask; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */ 1430b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1431b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (inst->InstructionExtNv.CondFlowEnable) { 1432b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint swizzle[4]; 1433b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint chan_index; 1434b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1435b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow kilmask = 0x0; 1436b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1437b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle[0] = inst->InstructionExtNv.CondSwizzleX; 1438b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle[1] = inst->InstructionExtNv.CondSwizzleY; 1439b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle[2] = inst->InstructionExtNv.CondSwizzleZ; 1440b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow swizzle[3] = inst->InstructionExtNv.CondSwizzleW; 1441b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1442b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (chan_index = 0; chan_index < 4; chan_index++) 1443b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow { 1444b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint i; 1445b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1446b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < 4; i++) { 1447339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* TODO: evaluate the condition code */ 1448339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (0) 1449339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow kilmask |= 1 << i; 1450339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1451339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1452339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1453339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow else { 1454339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* "unconditional" kil */ 1455339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow kilmask = mach->ExecMask; 1456339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1457339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask; 1458339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow} 1459339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1460339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1461339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow/* 1462b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Fetch a texel using STR texture coordinates. 1463b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 1464b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1465b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowfetch_texel( struct tgsi_sampler *sampler, 1466b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *s, 1467b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *t, 1468b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const union tgsi_exec_channel *p, 1469b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow float lodbias, /* XXX should be float[4] */ 1470b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *r, 1471b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *g, 1472b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *b, 1473b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel *a ) 1474b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1475b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint j; 1476b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow float rgba[NUM_CHANNELS][QUAD_SIZE]; 1477b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1478b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow sampler->get_samples(sampler, s->f, t->f, p->f, lodbias, rgba); 1479b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1480b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (j = 0; j < 4; j++) { 1481b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow r->f[j] = rgba[0][j]; 1482b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow g->f[j] = rgba[1][j]; 1483b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow b->f[j] = rgba[2][j]; 1484b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow a->f[j] = rgba[3][j]; 1485b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1486b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1487b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1488b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1489b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1490b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowexec_tex(struct tgsi_exec_machine *mach, 1491b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_instruction *inst, 1492b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow boolean biasLod, 1493b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow boolean projected) 1494b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1495b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index; 1496b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel r[8]; 1497b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint chan_index; 1498b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow float lodBias; 1499b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1500b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* debug_printf("Sampler %u unit %u\n", sampler, unit); */ 1501b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1502b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (inst->InstructionExtTexture.Texture) { 1503b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TEXTURE_1D: 1504339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1505339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH(&r[0], 0, CHAN_X); 1506339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1507339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (projected) { 1508339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH(&r[1], 0, CHAN_W); 1509339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_div( &r[0], &r[0], &r[1] ); 1510339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1511339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1512339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (biasLod) { 1513339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH(&r[1], 0, CHAN_W); 1514339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow lodBias = r[2].f[0]; 1515339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1516339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow else 1517339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow lodBias = 0.0; 1518339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1519b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow fetch_texel(&mach->Samplers[unit], 1520b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &r[0], NULL, NULL, lodBias, /* S, T, P, BIAS */ 1521b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */ 1522b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1523b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1524b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TEXTURE_2D: 1525b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TEXTURE_RECT: 1526b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1527b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, CHAN_X); 1528b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 0, CHAN_Y); 1529b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 0, CHAN_Z); 1530b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1531b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (projected) { 1532b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[3], 0, CHAN_W); 1533b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[0], &r[0], &r[3] ); 1534b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[1], &r[1], &r[3] ); 1535b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[2], &r[2], &r[3] ); 1536b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1537b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1538b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (biasLod) { 1539b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[3], 0, CHAN_W); 1540b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow lodBias = r[3].f[0]; 1541b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1542b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else 1543b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow lodBias = 0.0; 1544b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1545b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow fetch_texel(&mach->Samplers[unit], 1546b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &r[0], &r[1], &r[2], lodBias, /* inputs */ 1547b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &r[0], &r[1], &r[2], &r[3]); /* outputs */ 1548b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1549b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1550b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TEXTURE_3D: 1551b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_TEXTURE_CUBE: 1552b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1553b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, CHAN_X); 1554b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 0, CHAN_Y); 1555b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 0, CHAN_Z); 1556b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1557b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (projected) { 1558b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[3], 0, CHAN_W); 1559b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[0], &r[0], &r[3] ); 1560b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[1], &r[1], &r[3] ); 1561339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_div( &r[2], &r[2], &r[3] ); 1562339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1563339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1564339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (biasLod) { 1565339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH(&r[3], 0, CHAN_W); 1566339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow lodBias = r[3].f[0]; 1567339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1568339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow else 1569339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow lodBias = 0.0; 1570339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1571339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow fetch_texel(&mach->Samplers[unit], 1572339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow &r[0], &r[1], &r[2], lodBias, 1573339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow &r[0], &r[1], &r[2], &r[3]); 1574339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1575339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1576b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 1577b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 1578b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1579b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1580b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1581b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[chan_index], 0, chan_index ); 1582b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1583b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1584b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1585b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1586b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** 1587b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Evaluate a constant-valued coefficient at the position of the 1588b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * current quad. 1589b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 1590b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1591b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komoweval_constant_coef( 1592b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach, 1593b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned attrib, 1594b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned chan ) 1595b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1596b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned i; 1597b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1598b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for( i = 0; i < QUAD_SIZE; i++ ) { 1599b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Inputs[attrib].xyzw[chan].f[i] = mach->InterpCoefs[attrib].a0[chan]; 1600b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1601b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1602b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1603b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** 1604b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Evaluate a linear-valued coefficient at the position of the 1605b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * current quad. 1606b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 1607b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1608b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komoweval_linear_coef( 1609b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach, 1610b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned attrib, 1611b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned chan ) 1612b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1613b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float x = mach->QuadPos.xyzw[0].f[0]; 1614b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float y = mach->QuadPos.xyzw[1].f[0]; 1615b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float dadx = mach->InterpCoefs[attrib].dadx[chan]; 1616b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float dady = mach->InterpCoefs[attrib].dady[chan]; 1617b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y; 1618339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mach->Inputs[attrib].xyzw[chan].f[0] = a0; 1619339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mach->Inputs[attrib].xyzw[chan].f[1] = a0 + dadx; 1620339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mach->Inputs[attrib].xyzw[chan].f[2] = a0 + dady; 1621339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow mach->Inputs[attrib].xyzw[chan].f[3] = a0 + dadx + dady; 1622339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow} 1623339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1624339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow/** 1625339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow * Evaluate a perspective-valued coefficient at the position of the 1626339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow * current quad. 1627339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow */ 1628339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komowstatic void 1629339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komoweval_perspective_coef( 1630339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow struct tgsi_exec_machine *mach, 1631339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow unsigned attrib, 1632339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow unsigned chan ) 1633b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1634b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float x = mach->QuadPos.xyzw[0].f[0]; 1635b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float y = mach->QuadPos.xyzw[1].f[0]; 1636b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float dadx = mach->InterpCoefs[attrib].dadx[chan]; 1637b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float dady = mach->InterpCoefs[attrib].dady[chan]; 1638b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y; 1639b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const float *w = mach->QuadPos.xyzw[3].f; 1640b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* divide by W here */ 1641b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Inputs[attrib].xyzw[chan].f[0] = a0 / w[0]; 1642b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Inputs[attrib].xyzw[chan].f[1] = (a0 + dadx) / w[1]; 1643b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Inputs[attrib].xyzw[chan].f[2] = (a0 + dady) / w[2]; 1644b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Inputs[attrib].xyzw[chan].f[3] = (a0 + dadx + dady) / w[3]; 1645b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1646b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1647b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1648b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowtypedef void (* eval_coef_func)( 1649b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach, 1650b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned attrib, 1651b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned chan ); 1652b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1653b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1654b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowexec_declaration( 1655b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach, 1656b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_declaration *decl ) 1657b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1658b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) { 1659b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( decl->Declaration.File == TGSI_FILE_INPUT ) { 1660b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned first, last, mask; 1661b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow eval_coef_func eval; 1662b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1663b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow first = decl->DeclarationRange.First; 1664b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow last = decl->DeclarationRange.Last; 1665b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mask = decl->Declaration.UsageMask; 1666b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1667b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch( decl->Declaration.Interpolate ) { 1668b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_INTERPOLATE_CONSTANT: 1669b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow eval = eval_constant_coef; 1670b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1671b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1672b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_INTERPOLATE_LINEAR: 1673b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow eval = eval_linear_coef; 1674b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1675339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1676339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_INTERPOLATE_PERSPECTIVE: 1677339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow eval = eval_perspective_coef; 1678339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1679339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1680339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow default: 1681339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow eval = NULL; 1682339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert( 0 ); 1683339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1684339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1685339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if( mask == TGSI_WRITEMASK_XYZW ) { 1686339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow unsigned i, j; 1687339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1688339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow for( i = first; i <= last; i++ ) { 1689339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow for( j = 0; j < NUM_CHANNELS; j++ ) { 1690b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow eval( mach, i, j ); 1691b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1692b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1693b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1694b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else { 1695b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow unsigned i, j; 1696b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1697b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for( j = 0; j < NUM_CHANNELS; j++ ) { 1698b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( mask & (1 << j) ) { 1699b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for( i = first; i <= last; i++ ) { 1700b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow eval( mach, i, j ); 1701b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1702b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1703b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1704b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1705b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1706b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1707b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 1708b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1709b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowstatic void 1710b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowexec_instruction( 1711b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow struct tgsi_exec_machine *mach, 1712b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow const struct tgsi_full_instruction *inst, 1713b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow int *pc ) 1714b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 1715b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint chan_index; 1716b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow union tgsi_exec_channel r[8]; 1717b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1718b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow (*pc)++; 1719b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1720b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow switch (inst->Instruction.Opcode) { 1721b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ARL: 1722b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1723b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 1724b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_f2it( &r[0], &r[0] ); 1725b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 1726b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1727b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1728b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1729b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_MOV: 1730b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SWZ: 1731b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1732339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, chan_index ); 1733339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 1734339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1735339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1736339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1737339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_LIT: 1738339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { 1739339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X ); 1740339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1741339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1742339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { 1743339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, CHAN_X ); 1744339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { 1745339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_max( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); 1746339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, CHAN_Y ); 1747b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1748b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1749b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { 1750b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 0, CHAN_Y ); 1751b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_max( &r[1], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); 1752b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1753b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[2], 0, CHAN_W ); 1754b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] ); 1755b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] ); 1756b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_pow( &r[1], &r[1], &r[2] ); 1757b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_lt( &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); 1758b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, CHAN_Z ); 1759b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1760b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1761b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1762b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { 1763b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); 1764b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1765b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1766b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1767b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_RCP: 1768b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_RECIP */ 1769b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 1770b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] ); 1771b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1772b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 1773b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1774b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1775b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1776b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_RSQ: 1777b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_RECIPSQRT */ 1778b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 1779b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sqrt( &r[0], &r[0] ); 1780b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] ); 1781b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1782b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 1783b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1784b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1785b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1786b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_EXP: 1787b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 1788b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_flr( &r[1], &r[0] ); /* r1 = floor(r0) */ 1789339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { 1790339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_exp2( &r[2], &r[1] ); /* r2 = 2 ^ r1 */ 1791339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[2], 0, CHAN_X ); /* store r2 */ 1792339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1793339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { 1794339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_sub( &r[2], &r[0], &r[1] ); /* r2 = r0 - r1 */ 1795339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[2], 0, CHAN_Y ); /* store r2 */ 1796339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1797339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { 1798339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_exp2( &r[2], &r[0] ); /* r2 = 2 ^ r0 */ 1799339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[2], 0, CHAN_Z ); /* store r2 */ 1800339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1801339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { 1802339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); 1803339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1804b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1805b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1806b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_LOG: 1807b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 1808b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_abs( &r[2], &r[0] ); /* r2 = abs(r0) */ 1809b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_lg2( &r[1], &r[2] ); /* r1 = lg2(r2) */ 1810b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_flr( &r[0], &r[1] ); /* r0 = floor(r1) */ 1811b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { 1812b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, CHAN_X ); 1813b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1814b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { 1815b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_exp2( &r[0], &r[0] ); /* r0 = 2 ^ r0 */ 1816b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_div( &r[0], &r[2], &r[0] ); /* r0 = r2 / r0 */ 1817b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, CHAN_Y ); 1818b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1819b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { 1820b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[1], 0, CHAN_Z ); 1821b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1822b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { 1823b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); 1824b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1825b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1826b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1827b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_MUL: 1828b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) 1829b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow { 1830b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, chan_index); 1831b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, chan_index); 1832b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1833b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 1834b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1835b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE(&r[0], 0, chan_index); 1836b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1837b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1838b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1839b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ADD: 1840b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1841b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 1842b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 1843b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 1844b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 1845b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1846339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1847339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1848339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_DP3: 1849339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* TGSI_OPCODE_DOT3 */ 1850339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, CHAN_X ); 1851339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 1, CHAN_X ); 1852339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 1853339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1854339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 0, CHAN_Y ); 1855339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[2], 1, CHAN_Y ); 1856339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 1857339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_add( &r[0], &r[0], &r[1] ); 1858339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1859339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 0, CHAN_Z ); 1860339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[2], 1, CHAN_Z ); 1861b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 1862b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 1863b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1864b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1865b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 1866b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1867b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1868b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1869b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_DP4: 1870b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_DOT4 */ 1871b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, CHAN_X); 1872b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, CHAN_X); 1873b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1874b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 1875b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1876b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 0, CHAN_Y); 1877b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 1, CHAN_Y); 1878b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1879b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 1880b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 1881b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1882b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 0, CHAN_Z); 1883b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 1, CHAN_Z); 1884b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1885b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 1886b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 1887b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1888b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 0, CHAN_W); 1889b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 1, CHAN_W); 1890b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1891b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 1892b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 1893b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1894b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1895b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 1896b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1897b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1898b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1899b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_DST: 1900b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { 1901b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X ); 1902b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1903339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1904339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { 1905339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, CHAN_Y ); 1906339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 1, CHAN_Y); 1907339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 1908339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, CHAN_Y ); 1909339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1910339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1911339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { 1912339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, CHAN_Z ); 1913339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, CHAN_Z ); 1914339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1915339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1916339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { 1917339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 1, CHAN_W ); 1918b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, CHAN_W ); 1919b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1920b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1921b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1922b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_MIN: 1923b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1924b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, chan_index); 1925b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, chan_index); 1926b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1927b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* XXX use micro_min()?? */ 1928b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_lt( &r[0], &r[0], &r[1], &r[0], &r[1] ); 1929b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1930b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE(&r[0], 0, chan_index); 1931b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1932b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1933b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1934b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_MAX: 1935b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1936b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, chan_index); 1937b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, chan_index); 1938b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1939b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* XXX use micro_max()?? */ 1940b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_lt( &r[0], &r[0], &r[1], &r[1], &r[0] ); 1941b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1942b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE(&r[0], 0, chan_index ); 1943b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1944b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1945b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1946b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SLT: 1947b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_SETLT */ 1948b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1949b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 1950b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 1951b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_lt( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); 1952b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 1953b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1954b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1955b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1956b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SGE: 1957b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_SETGE */ 1958b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1959b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 1960339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 1, chan_index ); 1961339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_ge( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); 1962339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 1963339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 1964339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 1965339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 1966339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_MAD: 1967339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* TGSI_OPCODE_MADD */ 1968339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1969339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, chan_index ); 1970339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 1, chan_index ); 1971339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 1972339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 2, chan_index ); 1973339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_add( &r[0], &r[0], &r[1] ); 1974339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 1975b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1976b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1977b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1978b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SUB: 1979b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1980b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, chan_index); 1981b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, chan_index); 1982b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1983b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sub( &r[0], &r[0], &r[1] ); 1984b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1985b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE(&r[0], 0, chan_index); 1986b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 1987b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 1988b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1989b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_LERP: 1990b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_LRP */ 1991b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 1992b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, chan_index); 1993b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, chan_index); 1994b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 2, chan_index); 1995b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 1996b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sub( &r[1], &r[1], &r[2] ); 1997b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 1998b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[2] ); 1999b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2000b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE(&r[0], 0, chan_index); 2001b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2002b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2003b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2004b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CND: 2005b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2006b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2007b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2008b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CND0: 2009b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2010b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2011b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2012b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_DOT2ADD: 2013b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_DP2A */ 2014b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2015b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2016b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2017339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_INDEX: 2018339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert (0); 2019339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2020339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2021339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_NEGATE: 2022339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert (0); 2023339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2024339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2025339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_FRAC: 2026339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* TGSI_OPCODE_FRC */ 2027339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2028339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, chan_index ); 2029339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_frc( &r[0], &r[0] ); 2030339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 2031339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2032b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2033b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2034b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CLAMP: 2035b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2036b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2037b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2038b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_FLOOR: 2039b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_FLR */ 2040b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2041b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2042b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_flr( &r[0], &r[0] ); 2043b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2044b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2045b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2046b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2047b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ROUND: 2048b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2049b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2050b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_rnd( &r[0], &r[0] ); 2051b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2052b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2053b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2054b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2055b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_EXPBASE2: 2056b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_EX2 */ 2057b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, CHAN_X); 2058b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2059b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#if FAST_MATH 2060b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_exp2( &r[0], &r[0] ); 2061b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#else 2062b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_pow( &r[0], &mach->Temps[TEMP_2_I].xyzw[TEMP_2_C], &r[0] ); 2063b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#endif 2064b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2065b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2066b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2067b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2068b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2069b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2070b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_LOGBASE2: 2071b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_LG2 */ 2072b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 2073b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_lg2( &r[0], &r[0] ); 2074339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2075339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 2076339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2077339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2078339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2079339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_POWER: 2080339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* TGSI_OPCODE_POW */ 2081339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH(&r[0], 0, CHAN_X); 2082339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH(&r[1], 1, CHAN_X); 2083339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2084339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_pow( &r[0], &r[0], &r[1] ); 2085339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2086339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2087339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 2088339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2089b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2090b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2091b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CROSSPRODUCT: 2092b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* TGSI_OPCODE_XPD */ 2093b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, CHAN_Y); 2094b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, CHAN_Z); 2095b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2096b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[2], &r[0], &r[1] ); 2097b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2098b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[3], 0, CHAN_Z); 2099b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[4], 1, CHAN_Y); 2100b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2101b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[5], &r[3], &r[4] ); 2102b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sub( &r[2], &r[2], &r[5] ); 2103b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2104b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) { 2105b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[2], 0, CHAN_X ); 2106b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2107b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2108b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 1, CHAN_X); 2109b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2110b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[3], &r[3], &r[2] ); 2111b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2112b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[5], 0, CHAN_X); 2113b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2114b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[5] ); 2115b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sub( &r[3], &r[3], &r[1] ); 2116b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2117b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) { 2118b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[3], 0, CHAN_Y ); 2119b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2120b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2121b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[5], &r[5], &r[4] ); 2122b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[0], &r[0], &r[2] ); 2123b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sub( &r[5], &r[5], &r[0] ); 2124b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2125b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) { 2126b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[5], 0, CHAN_Z ); 2127b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2128b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2129b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) { 2130b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); 2131339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2132339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2133339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2134339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_MULTIPLYMATRIX: 2135339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert (0); 2136339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2137339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2138339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_ABS: 2139339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2140339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH(&r[0], 0, chan_index); 2141339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2142339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_abs( &r[0], &r[0] ); 2143339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2144339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE(&r[0], 0, chan_index); 2145339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2146b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2147b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2148b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_RCC: 2149b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2150b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2151b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2152b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_DPH: 2153b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, CHAN_X); 2154b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, CHAN_X); 2155b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2156b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 2157b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2158b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 0, CHAN_Y); 2159b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 1, CHAN_Y); 2160b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2161b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 2162b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 2163b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2164b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 0, CHAN_Z); 2165b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 1, CHAN_Z); 2166b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2167b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 2168b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 2169b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2170b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, CHAN_W); 2171b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2172b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 2173b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2174b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2175b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2176b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2177b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2178b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2179b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_COS: 2180b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, CHAN_X); 2181b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2182b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_cos( &r[0], &r[0] ); 2183b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2184b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2185b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2186b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2187b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2188339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2189339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_DDX: 2190339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2191339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, chan_index ); 2192339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_ddx( &r[0], &r[0] ); 2193339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 2194339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2195339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2196339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2197339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_DDY: 2198339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2199339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, chan_index ); 2200339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_ddy( &r[0], &r[0] ); 2201339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 2202339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2203b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2204b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2205b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_KILP: 2206b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow exec_kilp (mach, inst); 2207b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2208b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2209b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_KIL: 2210b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow exec_kil (mach, inst); 2211b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2212b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2213b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_PK2H: 2214b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2215b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2216b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2217b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_PK2US: 2218b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2219b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2220b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2221b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_PK4B: 2222b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2223b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2224b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2225b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_PK4UB: 2226b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2227b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2228b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2229b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_RFL: 2230b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2231b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2232b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2233b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SEQ: 2234b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2235b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2236b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2237b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_eq( &r[0], &r[0], &r[1], 2238b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 2239b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); 2240b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2241b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2242b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2243b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2244b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SFL: 2245339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert (0); 2246339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2247339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2248339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_SGT: 2249339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2250339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, chan_index ); 2251339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[1], 1, chan_index ); 2252339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_le( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] ); 2253339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow STORE( &r[0], 0, chan_index ); 2254339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow } 2255339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2256339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2257339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_SIN: 2258339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow FETCH( &r[0], 0, CHAN_X ); 2259339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow micro_sin( &r[0], &r[0] ); 2260b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2261b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2262b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2263b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2264b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2265b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SLE: 2266b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2267b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2268b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2269b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_le( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] ); 2270b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2271b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2272b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2273b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2274b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SNE: 2275b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2276b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2277b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2278b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_eq( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] ); 2279b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2280b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2281b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2282b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2283b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_STR: 2284b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2285b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2286b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2287b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_TEX: 2288b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* simple texture lookup */ 2289b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* src[0] = texcoord */ 2290b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* src[1] = sampler unit */ 2291b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow exec_tex(mach, inst, FALSE, FALSE); 2292b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2293b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2294b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_TXB: 2295b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Texture lookup with lod bias */ 2296b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* src[0] = texcoord (src[0].w = LOD bias) */ 2297b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* src[1] = sampler unit */ 2298b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow exec_tex(mach, inst, TRUE, FALSE); 2299b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2300b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2301b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_TXD: 2302339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* Texture lookup with explict partial derivatives */ 2303339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* src[0] = texcoord */ 2304339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* src[1] = d[strq]/dx */ 2305339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* src[2] = d[strq]/dy */ 2306339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* src[3] = sampler unit */ 2307339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow assert (0); 2308339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2309339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2310339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow case TGSI_OPCODE_TXL: 2311339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* Texture lookup with explit LOD */ 2312339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* src[0] = texcoord (src[0].w = LOD) */ 2313339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow /* src[1] = sampler unit */ 2314339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow exec_tex(mach, inst, TRUE, FALSE); 2315339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow break; 2316339ffcd8c81b8df33a98bd674789fe588761ec4aLenny Komow 2317b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_TXP: 2318b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Texture lookup with projection */ 2319b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* src[0] = texcoord (src[0].w = projection) */ 2320b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* src[1] = sampler unit */ 2321b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow exec_tex(mach, inst, FALSE, TRUE); 2322b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2323b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2324b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_UP2H: 2325b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2326b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2327b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2328b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_UP2US: 2329b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2330b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2331b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2332b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_UP4B: 2333b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2334b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2335b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2336b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_UP4UB: 2337b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2338b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2339b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2340b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_X2D: 2341b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2342b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2343b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2344b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ARA: 2345b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2346b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2347b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2348b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ARR: 2349b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2350b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2351b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2352b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_BRA: 2353b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2354b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2355b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2356b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CAL: 2357b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* skip the call if no execution channels are enabled */ 2358b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->ExecMask) { 2359b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* do the call */ 2360b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2361b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* push the Cond, Loop, Cont stacks */ 2362b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING); 2363b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondStack[mach->CondStackTop++] = mach->CondMask; 2364b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING); 2365b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask; 2366b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING); 2367b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ContStack[mach->ContStackTop++] = mach->ContMask; 2368b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2369b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING); 2370b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->FuncStack[mach->FuncStackTop++] = mach->FuncMask; 2371b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2372b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* note that PC was already incremented above */ 2373b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CallStack[mach->CallStackTop++] = *pc; 2374b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow *pc = inst->InstructionExtLabel.Label; 2375b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2376b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2377b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2378b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_RET: 2379b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->FuncMask &= ~mach->ExecMask; 2380b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2381b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2382b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->FuncMask == 0x0) { 2383b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* really return now (otherwise, keep executing */ 2384b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2385b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->CallStackTop == 0) { 2386b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* returning from main() */ 2387b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow *pc = -1; 2388b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return; 2389b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2390b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow *pc = mach->CallStack[--mach->CallStackTop]; 2391b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2392b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* pop the Cond, Loop, Cont stacks */ 2393b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->CondStackTop > 0); 2394b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask = mach->CondStack[--mach->CondStackTop]; 2395b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->LoopStackTop > 0); 2396b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->LoopMask = mach->LoopStack[--mach->LoopStackTop]; 2397b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->ContStackTop > 0); 2398b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ContMask = mach->ContStack[--mach->ContStackTop]; 2399b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->FuncStackTop > 0); 2400b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->FuncMask = mach->FuncStack[--mach->FuncStackTop]; 2401b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2402b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2403b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2404b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2405b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2406b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SSG: 2407b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2408b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2409b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2410b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CMP: 2411b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2412b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[0], 0, chan_index); 2413b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[1], 1, chan_index); 2414b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH(&r[2], 2, chan_index); 2415b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2416b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_lt( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[1], &r[2] ); 2417b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2418b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE(&r[0], 0, chan_index); 2419b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2420b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2421b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2422b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SCS: 2423b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) || IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) { 2424b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 2425b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2426b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) ) { 2427b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_cos( &r[1], &r[0] ); 2428b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[1], 0, CHAN_X ); 2429b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2430b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) { 2431b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_sin( &r[1], &r[0] ); 2432b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[1], 0, CHAN_Y ); 2433b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2434b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( IS_CHANNEL_ENABLED( *inst, CHAN_Z ) ) { 2435b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], 0, CHAN_Z ); 2436b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2437b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( IS_CHANNEL_ENABLED( *inst, CHAN_W ) ) { 2438b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W ); 2439b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2440b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2441b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2442b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_NRM: 2443b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2444b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2445b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2446b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_DIV: 2447b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 2448b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2449b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2450b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_DP2: 2451b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 2452b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, CHAN_X ); 2453b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[0], &r[0], &r[1] ); 2454b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2455b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 0, CHAN_Y ); 2456b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[2], 1, CHAN_Y ); 2457b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_mul( &r[1], &r[1], &r[2] ); 2458b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_add( &r[0], &r[0], &r[1] ); 2459b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2460b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2461b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2462b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2463b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2464b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2465b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_IF: 2466b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* push CondMask */ 2467b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING); 2468b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondStack[mach->CondStackTop++] = mach->CondMask; 2469b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, CHAN_X ); 2470b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* update CondMask */ 2471b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( ! r[0].u[0] ) { 2472b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask &= ~0x1; 2473b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2474b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( ! r[0].u[1] ) { 2475b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask &= ~0x2; 2476b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2477b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( ! r[0].u[2] ) { 2478b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask &= ~0x4; 2479b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2480b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( ! r[0].u[3] ) { 2481b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask &= ~0x8; 2482b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2483b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2484b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Todo: If CondMask==0, jump to ELSE */ 2485b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2486b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2487b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ELSE: 2488b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* invert CondMask wrt previous mask */ 2489b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow { 2490b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint prevMask; 2491b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->CondStackTop > 0); 2492b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow prevMask = mach->CondStack[mach->CondStackTop - 1]; 2493b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask = ~mach->CondMask & prevMask; 2494b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2495b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Todo: If CondMask==0, jump to ENDIF */ 2496b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2497b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2498b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2499b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ENDIF: 2500b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* pop CondMask */ 2501b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->CondStackTop > 0); 2502b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask = mach->CondStack[--mach->CondStackTop]; 2503b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2504b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2505b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2506b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_END: 2507b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* halt execution */ 2508b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow *pc = -1; 2509b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2510b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2511b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_REP: 2512b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2513b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2514b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2515b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ENDREP: 2516b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2517b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2518b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2519b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_PUSHA: 2520b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2521b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2522b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2523b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_POPA: 2524b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2525b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2526b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2527b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CEIL: 2528b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2529b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2530b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_ceil( &r[0], &r[0] ); 2531b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2532b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2533b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2534b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2535b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_I2F: 2536b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2537b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2538b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_i2f( &r[0], &r[0] ); 2539b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2540b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2541b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2542b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2543b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_NOT: 2544b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2545b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2546b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_not( &r[0], &r[0] ); 2547b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2548b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2549b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2550b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2551b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_TRUNC: 2552b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2553b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2554b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_trunc( &r[0], &r[0] ); 2555b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2556b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2557b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2558b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2559b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SHL: 2560b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2561b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2562b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2563b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_shl( &r[0], &r[0], &r[1] ); 2564b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2565b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2566b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2567b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2568b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SHR: 2569b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2570b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2571b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2572b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_ishr( &r[0], &r[0], &r[1] ); 2573b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2574b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2575b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2576b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2577b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_AND: 2578b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2579b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2580b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2581b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_and( &r[0], &r[0], &r[1] ); 2582b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2583b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2584b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2585b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2586b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_OR: 2587b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2588b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2589b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2590b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_or( &r[0], &r[0], &r[1] ); 2591b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2592b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2593b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2594b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2595b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_MOD: 2596b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2597b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2598b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2599b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_XOR: 2600b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { 2601b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[0], 0, chan_index ); 2602b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow FETCH( &r[1], 1, chan_index ); 2603b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow micro_xor( &r[0], &r[0], &r[1] ); 2604b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow STORE( &r[0], 0, chan_index ); 2605b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2606b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2607b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2608b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_SAD: 2609b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2610b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2611b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2612b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_TXF: 2613b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2614b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2615b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2616b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_TXQ: 2617b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert (0); 2618b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2619b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2620b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_EMIT: 2621b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += 16; 2622b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++; 2623b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2624b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2625b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ENDPRIM: 2626b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]++; 2627b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]] = 0; 2628b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2629b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2630b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_LOOP: 2631b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* fall-through (for now) */ 2632b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_BGNLOOP2: 2633b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* push LoopMask and ContMasks */ 2634b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING); 2635b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask; 2636b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING); 2637b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ContStack[mach->ContStackTop++] = mach->ContMask; 2638b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2639b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2640b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ENDLOOP: 2641b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* fall-through (for now at least) */ 2642b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ENDLOOP2: 2643b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Restore ContMask, but don't pop */ 2644b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->ContStackTop > 0); 2645b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ContMask = mach->ContStack[mach->ContStackTop - 1]; 2646b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2647b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->ExecMask) { 2648b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* repeat loop: jump to instruction just past BGNLOOP */ 2649b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow *pc = inst->InstructionExtLabel.Label + 1; 2650b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2651b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow else { 2652b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* exit loop: pop LoopMask */ 2653b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->LoopStackTop > 0); 2654b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->LoopMask = mach->LoopStack[--mach->LoopStackTop]; 2655b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* pop ContMask */ 2656b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->ContStackTop > 0); 2657b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ContMask = mach->ContStack[--mach->ContStackTop]; 2658b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2659b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2660b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2661b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2662b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_BRK: 2663b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* turn off loop channels for each enabled exec channel */ 2664b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->LoopMask &= ~mach->ExecMask; 2665b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Todo: if mach->LoopMask == 0, jump to end of loop */ 2666b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2667b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2668b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2669b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_CONT: 2670b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* turn off cont channels for each enabled exec channel */ 2671b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ContMask &= ~mach->ExecMask; 2672b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* Todo: if mach->LoopMask == 0, jump to end of loop */ 2673b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow UPDATE_EXEC_MASK(mach); 2674b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2675b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2676b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_BGNSUB: 2677b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* no-op */ 2678b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2679b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2680b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_ENDSUB: 2681b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* no-op */ 2682b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2683b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2684b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_NOISE1: 2685b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 2686b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2687b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2688b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_NOISE2: 2689b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 2690b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2691b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2692b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_NOISE3: 2693b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 2694b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2695b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2696b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_NOISE4: 2697b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 2698b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2699b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2700b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow case TGSI_OPCODE_NOP: 2701b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow break; 2702b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2703b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow default: 2704b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert( 0 ); 2705b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2706b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 2707b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2708b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2709b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow/** 2710b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Run TGSI interpreter. 2711b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * \return bitmask of "alive" quad components 2712b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 2713b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowuint 2714b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komowtgsi_exec_machine_run( struct tgsi_exec_machine *mach ) 2715b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow{ 2716b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow uint i; 2717b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow int pc = 0; 2718b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2719b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondMask = 0xf; 2720b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->LoopMask = 0xf; 2721b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ContMask = 0xf; 2722b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->FuncMask = 0xf; 2723b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->ExecMask = 0xf; 2724b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2725b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->CondStackTop = 0; /* temporarily subvert this assertion */ 2726b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->CondStackTop == 0); 2727b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->LoopStackTop == 0); 2728b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->ContStackTop == 0); 2729b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(mach->CallStackTop == 0); 2730b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2731b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0; 2732b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0; 2733b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2734b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if( mach->Processor == TGSI_PROCESSOR_GEOMETRY ) { 2735b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0] = 0; 2736b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Primitives[0] = 0; 2737b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2738b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2739b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < QUAD_SIZE; i++) { 2740b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Temps[TEMP_CC_I].xyzw[TEMP_CC_C].u[i] = 2741b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_X_SHIFT) | 2742b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_Y_SHIFT) | 2743b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_Z_SHIFT) | 2744b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow (TGSI_EXEC_CC_EQ << TGSI_EXEC_CC_W_SHIFT); 2745b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2746b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2747b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* execute declarations (interpolants) */ 2748b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < mach->NumDeclarations; i++) { 2749b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow exec_declaration( mach, mach->Declarations+i ); 2750b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2751b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2752b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* execute instructions, until pc is set to -1 */ 2753b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow while (pc != -1) { 2754b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow assert(pc < (int) mach->NumInstructions); 2755b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow exec_instruction( mach, mach->Instructions + pc, &pc ); 2756b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2757b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2758b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#if 0 2759b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* we scale from floats in [0,1] to Zbuffer ints in sp_quad_depth_test.c */ 2760b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) { 2761b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow /* 2762b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow * Scale back depth component. 2763b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow */ 2764b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow for (i = 0; i < 4; i++) 2765b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow mach->Outputs[0].xyzw[2].f[i] *= ctx->DrawBuffer->_DepthMaxF; 2766b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow } 2767b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow#endif 2768b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2769b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow return ~mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0]; 2770b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow} 2771b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2772b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow 2773b0a17f2ff9e0f5466fa7f9142db8128144175cafLenny Komow