1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/************************************************************************** 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved. 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish, 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions: 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software. 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/ 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/glheader.h" 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/macros.h" 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/enums.h" 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "program/prog_instruction.h" 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "program/prog_parameter.h" 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "program/program.h" 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "program/programopt.h" 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "program/prog_print.h" 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "tnl/tnl.h" 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "tnl/t_context.h" 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "intel_batchbuffer.h" 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "i915_reg.h" 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "i915_context.h" 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "i915_program.h" 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic const GLfloat sin_quad_constants[2][4] = { 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 2.0, 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org -1.0, 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org .5, 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org .75 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org }, 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 4.0, 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org -4.0, 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1.0 / (2.0 * M_PI), 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org .2225 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic const GLfloat sin_constants[4] = { 1.0, 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org -1.0 / (3 * 2 * 1), 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1.0 / (5 * 4 * 3 * 2 * 1), 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org -1.0 / (7 * 6 * 5 * 4 * 3 * 2 * 1) 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 1, -1/2!, 1/4!, -1/6! */ 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic const GLfloat cos_constants[4] = { 1.0, 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org -1.0 / (2 * 1), 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1.0 / (4 * 3 * 2 * 1), 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org -1.0 / (6 * 5 * 4 * 3 * 2 * 1) 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Retrieve a ureg for the given source register. Will emit 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * constants, apply swizzling and negation as needed. 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLuint 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsrc_vector(struct i915_fragment_program *p, 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct prog_src_register *source, 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_fragment_program *program) 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint src; 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (source->File) { 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Registers: 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_TEMPORARY: 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (source->Index >= I915_MAX_TEMPORARY) { 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Exceeded max temporary reg: %d/%d", 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org source->Index, I915_MAX_TEMPORARY); 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = UREG(REG_TYPE_R, source->Index); 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_INPUT: 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (source->Index) { 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_WPOS: 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL); 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_COL0: 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL); 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_COL1: 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ); 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = swizzle(src, X, Y, Z, ONE); 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_FOGC: 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W); 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = swizzle(src, W, ZERO, ZERO, ONE); 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX0: 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX1: 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX2: 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX3: 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX4: 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX5: 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX6: 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_TEX7: 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_decl(p, REG_TYPE_T, 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org T_TEX0 + (source->Index - FRAG_ATTRIB_TEX0), 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org D0_CHANNEL_ALL); 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0: 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0 + 1: 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0 + 2: 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0 + 3: 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0 + 4: 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0 + 5: 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0 + 6: 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_ATTRIB_VAR0 + 7: 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_decl(p, REG_TYPE_T, 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org T_TEX0 + (source->Index - FRAG_ATTRIB_VAR0), 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org D0_CHANNEL_ALL); 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Bad source->Index: %d", source->Index); 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_OUTPUT: 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (source->Index) { 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_RESULT_COLOR: 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = UREG(REG_TYPE_OC, 0); 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_RESULT_DEPTH: 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = UREG(REG_TYPE_OD, 0); 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Bad source->Index: %d", source->Index); 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Various paramters and env values. All emitted to 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * hardware as program constants. 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_LOCAL_PARAM: 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_param4fv(p, program->Base.LocalParams[source->Index]); 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_ENV_PARAM: 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_param4fv(p, 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->ctx->FragmentProgram.Parameters[source-> 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Index]); 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_CONSTANT: 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_STATE_VAR: 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_NAMED_PARAM: 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_UNIFORM: 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = i915_emit_param4fv(p, 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org &program->Base.Parameters->ParameterValues[source->Index][0].f); 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Bad source->File: %d", source->File); 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = swizzle(src, 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_SWZ(source->Swizzle, 0), 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_SWZ(source->Swizzle, 1), 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_SWZ(source->Swizzle, 2), GET_SWZ(source->Swizzle, 3)); 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (source->Negate) 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src = negate(src, 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_BIT(source->Negate, 0), 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_BIT(source->Negate, 1), 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_BIT(source->Negate, 2), 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GET_BIT(source->Negate, 3)); 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return src; 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLuint 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgget_result_vector(struct i915_fragment_program *p, 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct prog_instruction *inst) 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (inst->DstReg.File) { 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_OUTPUT: 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (inst->DstReg.Index) { 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_RESULT_COLOR: 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_RESULT_DATA0: 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return UREG(REG_TYPE_OC, 0); 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case FRAG_RESULT_DEPTH: 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->depth_written = 1; 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return UREG(REG_TYPE_OD, 0); 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Bad inst->DstReg.Index: %d", 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org inst->DstReg.Index); 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case PROGRAM_TEMPORARY: 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return UREG(REG_TYPE_R, inst->DstReg.Index); 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Bad inst->DstReg.File: %d", inst->DstReg.File); 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLuint 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgget_result_flags(const struct prog_instruction *inst) 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint flags = 0; 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->SaturateMode == SATURATE_ZERO_ONE) 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags |= A0_DEST_SATURATE; 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.WriteMask & WRITEMASK_X) 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags |= A0_DEST_CHANNEL_X; 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.WriteMask & WRITEMASK_Y) 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags |= A0_DEST_CHANNEL_Y; 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.WriteMask & WRITEMASK_Z) 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags |= A0_DEST_CHANNEL_Z; 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.WriteMask & WRITEMASK_W) 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags |= A0_DEST_CHANNEL_W; 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return flags; 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLuint 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtranslate_tex_src_target(struct i915_fragment_program *p, GLubyte bit) 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (bit) { 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case TEXTURE_1D_INDEX: 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return D0_SAMPLE_TYPE_2D; 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case TEXTURE_2D_INDEX: 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return D0_SAMPLE_TYPE_2D; 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case TEXTURE_RECT_INDEX: 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return D0_SAMPLE_TYPE_2D; 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case TEXTURE_3D_INDEX: 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return D0_SAMPLE_TYPE_VOLUME; 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case TEXTURE_CUBE_INDEX: 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return D0_SAMPLE_TYPE_CUBE; 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "TexSrcBit: %d", bit); 264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return 0; 265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define EMIT_TEX( OP ) \ 269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdo { \ 270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint dim = translate_tex_src_target( p, inst->TexSrcTarget ); \ 271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_fragment_program *program = &p->FragProg; \ 272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint unit = program->Base.SamplerUnits[inst->TexSrcUnit]; \ 273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint sampler = i915_emit_decl(p, REG_TYPE_S, \ 274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unit, dim); \ 275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint coord = src_vector( p, &inst->SrcReg[0], program); \ 276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Texel lookup */ \ 277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org \ 278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_texld( p, get_live_regs(p, inst), \ 279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector( p, inst ), \ 280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags( inst ), \ 281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org sampler, \ 282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org coord, \ 283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org OP); \ 284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} while (0) 285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define EMIT_ARITH( OP, N ) \ 287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdo { \ 288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith( p, \ 289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org OP, \ 290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector( p, inst ), \ 291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags( inst ), 0, \ 292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (N<1)?0:src_vector( p, &inst->SrcReg[0], program), \ 293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (N<2)?0:src_vector( p, &inst->SrcReg[1], program), \ 294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (N<3)?0:src_vector( p, &inst->SrcReg[2], program)); \ 295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} while (0) 296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define EMIT_1ARG_ARITH( OP ) EMIT_ARITH( OP, 1 ) 298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define EMIT_2ARG_ARITH( OP ) EMIT_ARITH( OP, 2 ) 299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define EMIT_3ARG_ARITH( OP ) EMIT_ARITH( OP, 3 ) 300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TODO: consider moving this into core 303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic bool calc_live_regs( struct i915_fragment_program *p ) 305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_fragment_program *program = &p->FragProg; 307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint regsUsed = ~((1 << I915_MAX_TEMPORARY) - 1); 308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint8_t live_components[I915_MAX_TEMPORARY] = { 0, }; 309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = program->Base.NumInstructions - 1; i >= 0; i--) { 312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct prog_instruction *inst = &program->Base.Instructions[i]; 313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int opArgs = _mesa_num_inst_src_regs(inst->Opcode); 314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int a; 315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Register is written to: unmark as live for this and preceeding ops */ 317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.File == PROGRAM_TEMPORARY) { 318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.Index >= I915_MAX_TEMPORARY) 319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return false; 320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org live_components[inst->DstReg.Index] &= ~inst->DstReg.WriteMask; 322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (live_components[inst->DstReg.Index] == 0) 323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org regsUsed &= ~(1 << inst->DstReg.Index); 324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (a = 0; a < opArgs; a++) { 327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Register is read from: mark as live for this and preceeding ops */ 328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->SrcReg[a].File == PROGRAM_TEMPORARY) { 329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned c; 330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->SrcReg[a].Index >= I915_MAX_TEMPORARY) 332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return false; 333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org regsUsed |= 1 << inst->SrcReg[a].Index; 335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (c = 0; c < 4; c++) { 337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const unsigned field = GET_SWZ(inst->SrcReg[a].Swizzle, c); 338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (field <= SWIZZLE_W) 340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org live_components[inst->SrcReg[a].Index] |= (1U << field); 341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->usedRegs[i] = regsUsed; 346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return true; 349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLuint get_live_regs( struct i915_fragment_program *p, 352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct prog_instruction *inst ) 353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_fragment_program *program = &p->FragProg; 355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint nr = inst - program->Base.Instructions; 356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return p->usedRegs[nr]; 358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Possible concerns: 362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SIN, COS -- could use another taylor step? 364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * LIT -- results seem a little different to sw mesa 365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * LOG -- different to mesa on negative numbers, but this is conformant. 366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Parse failures -- Mesa doesn't currently give a good indication 368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * internally whether a particular program string parsed or not. This 369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * can lead to confusion -- hopefully we cope with it ok now. 370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgupload_program(struct i915_fragment_program *p) 374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct gl_fragment_program *program = &p->FragProg; 376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct prog_instruction *inst = program->Base.Instructions; 377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (INTEL_DEBUG & DEBUG_WM) 379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_print_program(&program->Base); 380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Is this a parse-failed program? Ensure a valid program is 382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * loaded, as the flagging of an error isn't sufficient to stop 383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * this being uploaded to hardware. 384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst[0].Opcode == OPCODE_END) { 386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint tmp = i915_get_utemp(p); 387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MOV, 389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org UREG(REG_TYPE_OC, 0), 390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DEST_CHANNEL_ALL, 0, 391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ONE, ZERO, ONE, ONE), 0, 0); 392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (program->Base.NumInstructions > I915_MAX_INSN) { 396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Exceeded max instructions (%d out of %d)", 397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org program->Base.NumInstructions, I915_MAX_INSN); 398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Not always needed: 402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!calc_live_regs(p)) { 404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Could not allocate registers"); 405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org while (1) { 409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint src0, src1, src2, flags; 410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint tmp = 0, dst, consts0 = 0, consts1 = 0; 411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (inst->Opcode) { 413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_ABS: 414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAX, 417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0, negate(src0, 1, 1, 1, 1), 0); 420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_ADD: 423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_2ARG_ARITH(A0_ADD); 424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_CMP: 427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src2 = src_vector(p, &inst->SrcReg[2], program); 430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_CMP, get_result_vector(p, inst), get_result_flags(inst), 0, src0, src2, src1); /* NOTE: order of src2, src1 */ 431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_COS: 434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org consts0 = i915_emit_const4fv(p, sin_quad_constants[0]); 437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org consts1 = i915_emit_const4fv(p, sin_quad_constants[1]); 438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Reduce range from repeating about [-pi,pi] to [-1,1] */ 440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_X, 0, 443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0, 444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts1, Z, ZERO, ZERO, ZERO), /* 1/(2pi) */ 445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts0, W, ZERO, ZERO, ZERO)); /* .75 */ 446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_FRC, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); 448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_X, 0, 452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts0, X, ZERO, ZERO, ZERO), /* 2 */ 454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts0, Y, ZERO, ZERO, ZERO)); /* -1 */ 455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Compute COS with the same calculation used for SIN, but a 457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * different source range has been mapped to [-1,1] this time. 458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.y = abs(tmp.x); {x, abs(x), 0, 0} */ 461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAX, 463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0), 466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.y = tmp.y * tmp.x; {x, x * abs(x), 0, 0} */ 469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.x = tmp.xy DP sin_quad_constants[2].xy */ 477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DP3, 479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_X, 0, 480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts1, X, Y, ZERO, ZERO), 482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.x now contains a first approximation (y). Now, weight it 485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * against tmp.y**2 to get closer. 486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAX, 489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0), 492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.y = tmp.x * tmp.y - tmp.x; {y, y * abs(y) - y, 0, 0} */ 495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, Y, ZERO, ZERO), 500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0)); 501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* result = .2225 * tmp.y + tmp.x =.2225(y * abs(y) - y) + y= */ 503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts1, W, W, W, W), 508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, Y, Y, Y, Y), 509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, X, X, X, X)); 510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_DP2: 513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DP3, 517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, Y, ZERO, ZERO), 520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src1, X, Y, ZERO, ZERO), 521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_DP3: 525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_2ARG_ARITH(A0_DP3); 526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_DP4: 529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_2ARG_ARITH(A0_DP4); 530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_DPH: 533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DP4, 538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, Y, Z, ONE), src1, 0); 541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_DST: 544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* result[0] = 1 * 1; 548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result[1] = a[1] * b[1]; 549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result[2] = a[2] * 1; 550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result[3] = 1 * b[3]; 551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 555f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 556f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, ONE, Y, Z, ONE), 557f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src1, ONE, Y, ONE, W), 0); 558f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 559f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 560f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_EX2: 561f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 562f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 563f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 564f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_EXP, 565f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 566f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 567f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, X, X, X), 0, 0); 568f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 569f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 570f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_FLR: 571f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_1ARG_ARITH(A0_FLR); 572f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 573f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 574f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_TRUNC: 575f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_1ARG_ARITH(A0_TRC); 576f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 577f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 578f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_FRC: 579f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_1ARG_ARITH(A0_FRC); 580f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 581f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 582f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_KIL: 583f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 584f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 585f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 586f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_texld(p, get_live_regs(p, inst), 587f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_ALL, /* use a dummy dest reg */ 588f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0, src0, T0_TEXKILL); 589f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 590f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 591f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_KIL_NV: 592f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.CondMask == COND_TR) { 593f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 594f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 595f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The KIL instruction discards the fragment if any component of 596f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the source is < 0. Emit an immediate operand of {-1}.xywz. 597f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 598f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_texld(p, get_live_regs(p, inst), 599f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_ALL, 600f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0, /* use a dummy dest reg */ 601f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ONE, ONE, ONE, ONE), 602f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 603f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org T0_TEXKILL); 604f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } else { 605f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->error = 1; 606f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Unsupported KIL_NV condition code: %d", 607f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org inst->DstReg.CondMask); 608f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 609f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 610f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 611f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_LG2: 612f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 613f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 614f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 615f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_LOG, 616f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 617f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 618f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, X, X, X), 0, 0); 619f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 620f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 621f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_LIT: 622f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 623f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 624f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 625f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp = max( a.xyzw, a.00zw ) 626f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * XXX: Clamp tmp.w to -128..128 627f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * tmp.y = log(tmp.y) 628f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * tmp.y = tmp.w * tmp.y 629f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * tmp.y = exp(tmp.y) 630f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result = cmp (a.11-x1, a.1x01, a.1xy1 ) 631f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 632f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_MAX, tmp, A0_DEST_CHANNEL_ALL, 0, 633f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0, swizzle(src0, ZERO, ZERO, Z, W), 0); 634f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 635f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_LOG, tmp, A0_DEST_CHANNEL_Y, 0, 636f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, Y, Y, Y, Y), 0, 0); 637f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 638f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_Y, 0, 639f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, Y, ZERO, ZERO), 640f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, W, ZERO, ZERO), 0); 641f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 642f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_EXP, tmp, A0_DEST_CHANNEL_Y, 0, 643f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, Y, Y, Y, Y), 0, 0); 644f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 645f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_CMP, 646f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 647f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 648f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ONE, ONE, X, ONE), 0, 0, 1, 0), 649f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ONE, X, ZERO, ONE), 650f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ONE, X, Y, ONE)); 651f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 652f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 653f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 654f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_LRP: 655f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 656f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 657f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src2 = src_vector(p, &inst->SrcReg[2], program); 658f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags = get_result_flags(inst); 659f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 660f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 661f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* b*a + c*(1-a) 662f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 663f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * b*a + c - ca 664f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 665f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * tmp = b*a + c, 666f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result = (-c)*a + tmp 667f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 668f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_MAD, tmp, 669f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags & A0_DEST_CHANNEL_ALL, 0, src1, src0, src2); 670f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 671f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_MAD, 672f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 673f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, negate(src2, 1, 1, 1, 1), src0, tmp); 674f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 675f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 676f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_MAD: 677f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_3ARG_ARITH(A0_MAD); 678f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 679f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 680f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_MAX: 681f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_2ARG_ARITH(A0_MAX); 682f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 683f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 684f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_MIN: 685f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 686f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 687f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 688f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags = get_result_flags(inst); 689f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 690f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 691f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAX, 692f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, flags & A0_DEST_CHANNEL_ALL, 0, 693f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src0, 1, 1, 1, 1), 694f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src1, 1, 1, 1, 1), 0); 695f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 696f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 697f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MOV, 698f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 699f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, negate(tmp, 1, 1, 1, 1), 0, 0); 700f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 701f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 702f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_MOV: 703f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_1ARG_ARITH(A0_MOV); 704f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 705f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 706f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_MUL: 707f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_2ARG_ARITH(A0_MUL); 708f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 709f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 710f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_POW: 711f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 712f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 713f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 714f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags = get_result_flags(inst); 715f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 716f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* XXX: masking on intermediate values, here and elsewhere. 717f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 718f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 719f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_LOG, 720f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_X, 0, 721f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, X, X, X), 0, 0); 722f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 723f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, tmp, src1, 0); 724f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 725f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 726f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 727f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_EXP, 728f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 729f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, swizzle(tmp, X, X, X, X), 0, 0); 730f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 731f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 732f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 733f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_RCP: 734f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 735f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 736f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 737f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_RCP, 738f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 739f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 740f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, X, X, X), 0, 0); 741f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 742f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 743f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_RSQ: 744f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 745f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 746f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 747f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 748f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_RSQ, 749f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 750f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 751f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, X, X, X), 0, 0); 752f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 753f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 754f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SCS: 755f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 756f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 757f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 758f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 759f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1 760f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x 761f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x 762f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * scs.x = DP4 t1, sin_constants 763f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * t1 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1 764f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * scs.y = DP4 t1, cos_constants 765f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 766f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 767f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 768f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_XY, 0, 769f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, X, ONE, ONE), 770f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, X, ONE, ONE, ONE), 0); 771f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 772f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 773f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 774f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_ALL, 0, 775f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, X, Y, X, Y), 776f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, X, X, ONE, ONE), 0); 777f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 778f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.WriteMask & WRITEMASK_Y) { 779f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint tmp1; 780f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 781f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.WriteMask & WRITEMASK_X) 782f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp1 = i915_get_utemp(p); 783f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else 784f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp1 = tmp; 785f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 786f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 787f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 788f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp1, A0_DEST_CHANNEL_ALL, 0, 789f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, X, Y, Y, W), 790f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, X, Z, ONE, ONE), 0); 791f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 792f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 793f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DP4, 794f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 795f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DEST_CHANNEL_Y, 0, 796f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp1, W, Z, Y, X), 797f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_const4fv(p, sin_constants), 0); 798f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 799f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 800f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inst->DstReg.WriteMask & WRITEMASK_X) { 801f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 802f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 803f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_XYZ, 0, 804f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, X, X, Z, ONE), 805f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, Z, ONE, ONE, ONE), 0); 806f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 807f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 808f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DP4, 809f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 810f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DEST_CHANNEL_X, 0, 811f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ONE, Z, Y, X), 812f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_const4fv(p, cos_constants), 0); 813f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 814f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 815f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 816f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SEQ: 817f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 818f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags = get_result_flags(inst); 819f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst = get_result_vector(p, inst); 820f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 821f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp = src1 >= src2 */ 822f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 823f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SGE, 824f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 825f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 826f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src_vector(p, &inst->SrcReg[0], program), 827f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src_vector(p, &inst->SrcReg[1], program), 828f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 829f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* dst = src1 <= src2 */ 830f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 831f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SGE, 832f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 833f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 834f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector(p, &inst->SrcReg[0], program), 835f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 836f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector(p, &inst->SrcReg[1], program), 837f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 838f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 839f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* dst = tmp && dst */ 840f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 841f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 842f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 843f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 844f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 845f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 846f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 847f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 848f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 849f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SIN: 850f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 851f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 852f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org consts0 = i915_emit_const4fv(p, sin_quad_constants[0]); 853f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org consts1 = i915_emit_const4fv(p, sin_quad_constants[1]); 854f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 855f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Reduce range from repeating about [-pi,pi] to [-1,1] */ 856f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 857f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 858f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_X, 0, 859f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0, 860f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts1, Z, ZERO, ZERO, ZERO), /* 1/(2pi) */ 861f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts0, Z, ZERO, ZERO, ZERO)); /* .5 */ 862f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 863f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, A0_FRC, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); 864f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 865f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 866f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 867f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_X, 0, 868f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 869f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts0, X, ZERO, ZERO, ZERO), /* 2 */ 870f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts0, Y, ZERO, ZERO, ZERO)); /* -1 */ 871f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 872f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Compute sin using a quadratic and quartic. It gives continuity 873f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * that repeating the Taylor series lacks every 2*pi, and has 874f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * reduced error. 875f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 876f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The idea was described at: 877f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * http://www.devmaster.net/forums/showthread.php?t=5784 878f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 879f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 880f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.y = abs(tmp.x); {x, abs(x), 0, 0} */ 881f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 882f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAX, 883f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 884f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 885f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0), 886f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 887f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 888f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.y = tmp.y * tmp.x; {x, x * abs(x), 0, 0} */ 889f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 890f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 891f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 892f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 893f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 894f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 895f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 896f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.x = tmp.xy DP sin_quad_constants[2].xy */ 897f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 898f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_DP3, 899f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_X, 0, 900f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 901f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts1, X, Y, ZERO, ZERO), 902f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 903f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 904f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.x now contains a first approximation (y). Now, weight it 905f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * against tmp.y**2 to get closer. 906f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 907f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 908f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAX, 909f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 910f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 911f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0), 912f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 913f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 914f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp.y = tmp.x * tmp.y - tmp.x; {y, y * abs(y) - y, 0, 0} */ 915f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 916f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 917f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_Y, 0, 918f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, X, ZERO, ZERO), 919f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, ZERO, Y, ZERO, ZERO), 920f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0)); 921f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 922f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* result = .2225 * tmp.y + tmp.x =.2225(y * abs(y) - y) + y= */ 923f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 924f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 925f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 926f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 927f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(consts1, W, W, W, W), 928f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, Y, Y, Y, Y), 929f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(tmp, X, X, X, X)); 930f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 931f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 932f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 933f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SGE: 934f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_2ARG_ARITH(A0_SGE); 935f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 936f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 937f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SGT: 938f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 939f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SLT, 940f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector( p, inst ), 941f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags( inst ), 0, 942f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector( p, &inst->SrcReg[0], program), 943f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 944f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector( p, &inst->SrcReg[1], program), 945f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 946f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 947f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 948f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 949f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SLE: 950f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 951f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SGE, 952f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector( p, inst ), 953f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags( inst ), 0, 954f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector( p, &inst->SrcReg[0], program), 955f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 956f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector( p, &inst->SrcReg[1], program), 957f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 958f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 959f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 960f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 961f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SLT: 962f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_2ARG_ARITH(A0_SLT); 963f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 964f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 965f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SNE: 966f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 967f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags = get_result_flags(inst); 968f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst = get_result_vector(p, inst); 969f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 970f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp = src1 < src2 */ 971f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 972f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SLT, 973f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 974f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 975f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src_vector(p, &inst->SrcReg[0], program), 976f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src_vector(p, &inst->SrcReg[1], program), 977f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 978f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* dst = src1 > src2 */ 979f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 980f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SLT, 981f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 982f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 983f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector(p, &inst->SrcReg[0], program), 984f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 985f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(src_vector(p, &inst->SrcReg[1], program), 986f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1, 1, 1, 1), 987f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 988f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* dst = tmp || dst */ 989f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 990f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_ADD, 991f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 992f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags | A0_DEST_SATURATE, 0, 993f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 994f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 995f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 996f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 997f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 998f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SSG: 999f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst = get_result_vector(p, inst); 1000f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags = get_result_flags(inst); 1001f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 1002f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 1003f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1004f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* tmp = (src < 0.0) */ 1005f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 1006f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SLT, 1007f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, 1008f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 1009f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0, 1010f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, ZERO, ZERO, ZERO, ZERO), 1011f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 1012f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1013f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* dst = (0.0 < src) */ 1014f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 1015f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_SLT, 1016f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 1017f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 1018f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, ZERO, ZERO, ZERO, ZERO), 1019f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0, 1020f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 1021f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1022f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* dst = (src > 0.0) - (src < 0.0) */ 1023f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 1024f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_ADD, 1025f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 1026f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flags, 0, 1027f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org dst, 1028f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(tmp, 1, 1, 1, 1), 1029f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 0); 1030f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1031f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1032f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1033f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SUB: 1034f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 1035f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 1036f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1037f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 1038f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_ADD, 1039f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 1040f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 1041f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0, negate(src1, 1, 1, 1, 1), 0); 1042f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1043f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1044f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_SWZ: 1045f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_1ARG_ARITH(A0_MOV); /* extended swizzle handled natively */ 1046f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1047f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1048f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_TEX: 1049f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_TEX(T0_TEXLD); 1050f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1051f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1052f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_TXB: 1053f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_TEX(T0_TEXLDB); 1054f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1055f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1056f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_TXP: 1057f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_TEX(T0_TEXLDP); 1058f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1059f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1060f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_XPD: 1061f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Cross product: 1062f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result.x = src0.y * src1.z - src0.z * src1.y; 1063f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result.y = src0.z * src1.x - src0.x * src1.z; 1064f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result.z = src0.x * src1.y - src0.y * src1.x; 1065f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * result.w = undef; 1066f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1067f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src0 = src_vector(p, &inst->SrcReg[0], program); 1068f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org src1 = src_vector(p, &inst->SrcReg[1], program); 1069f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp = i915_get_utemp(p); 1070f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1071f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 1072f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MUL, 1073f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tmp, A0_DEST_CHANNEL_ALL, 0, 1074f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, Z, X, Y, ONE), 1075f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src1, Y, Z, X, ONE), 0); 1076f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1077f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 1078f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MAD, 1079f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_vector(p, inst), 1080f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org get_result_flags(inst), 0, 1081f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src0, Y, Z, X, ONE), 1082f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(src1, Z, X, Y, ONE), 1083f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org negate(tmp, 1, 1, 1, 0)); 1084f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org break; 1085f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1086f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_END: 1087f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1088f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1089f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_BGNLOOP: 1090f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_BGNSUB: 1091f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_BRA: 1092f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_BRK: 1093f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_CAL: 1094f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_CONT: 1095f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_DDX: 1096f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_DDY: 1097f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_ELSE: 1098f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_ENDIF: 1099f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_ENDLOOP: 1100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_ENDSUB: 1101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_IF: 1102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_RET: 1103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->error = 1; 1104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "Unsupported opcode: %s", 1105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_opcode_string(inst->Opcode)); 1106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_EXP: 1109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_LOG: 1110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* These opcodes are claimed as GLSL, NV_vp, and ARB_vp in 1111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * prog_instruction.h, but apparently GLSL doesn't ever emit them. 1112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Instead, it translates to EX2 or LG2. 1113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_TXD: 1115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case OPCODE_TXL: 1116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* These opcodes are claimed by GLSL in prog_instruction.h, but 1117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * only NV_vp/fp appears to emit them. 1118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 1120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "bad opcode: %s", 1121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_opcode_string(inst->Opcode)); 1122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org inst++; 1126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_release_utemps(p); 1127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Rather than trying to intercept and jiggle depth writes during 1131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * emit, just move the value into its correct position at the end of 1132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the program: 1133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgfixup_depth_write(struct i915_fragment_program *p) 1136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (p->depth_written) { 1138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint depth = UREG(REG_TYPE_OD, 0); 1139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_emit_arith(p, 1141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org A0_MOV, 1142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org depth, A0_DEST_CHANNEL_W, 0, 1143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org swizzle(depth, X, Y, Z, Z), 0, 0); 1144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgcheck_wpos(struct i915_fragment_program *p) 1150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLbitfield64 inputs = p->FragProg.Base.InputsRead; 1152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 1153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->wpos_tex = -1; 1155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) { 1157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inputs & (FRAG_BIT_TEX(i) | FRAG_BIT_VAR(i))) 1158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org continue; 1159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (inputs & FRAG_BIT_WPOS) { 1160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->wpos_tex = i; 1161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org inputs &= ~FRAG_BIT_WPOS; 1162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inputs & FRAG_BIT_WPOS) { 1166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_program_error(p, "No free texcoord for wpos value"); 1167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtranslate_program(struct i915_fragment_program *p) 1173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_context *i915 = I915_CONTEXT(p->ctx); 1175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (INTEL_DEBUG & DEBUG_WM) { 1177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("fp:\n"); 1178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_print_program(&p->FragProg.Base); 1179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("\n"); 1180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_init_program(i915, p); 1183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org check_wpos(p); 1184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org upload_program(p); 1185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org fixup_depth_write(p); 1186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_fini_program(p); 1187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->translated = 1; 1189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtrack_params(struct i915_fragment_program *p) 1194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint i; 1196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (p->nr_params) 1198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_load_state_parameters(p->ctx, p->FragProg.Base.Parameters); 1199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < p->nr_params; i++) { 1201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint reg = p->param[i].reg; 1202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org COPY_4V(p->constant[reg], p->param[i].values); 1203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->params_uptodate = 1; 1206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->on_hardware = 0; /* overkill */ 1207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915BindProgram(struct gl_context * ctx, GLenum target, struct gl_program *prog) 1212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target == GL_FRAGMENT_PROGRAM_ARB) { 1214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_context *i915 = I915_CONTEXT(ctx); 1215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_fragment_program *p = (struct i915_fragment_program *) prog; 1216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i915->current_program == p) 1218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return; 1219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i915->current_program) { 1221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->current_program->on_hardware = 0; 1222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->current_program->params_uptodate = 0; 1223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->current_program = p; 1226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(p->on_hardware == 0); 1228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(p->params_uptodate == 0); 1229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic struct gl_program * 1234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915NewProgram(struct gl_context * ctx, GLenum target, GLuint id) 1235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org switch (target) { 1237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_VERTEX_PROGRAM_ARB: 1238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program), 1239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org target, id); 1240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org case GL_FRAGMENT_PROGRAM_ARB:{ 1242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_fragment_program *prog = 1243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org CALLOC_STRUCT(i915_fragment_program); 1244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (prog) { 1245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_init_program(I915_CONTEXT(ctx), prog); 1246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_init_fragment_program(ctx, &prog->FragProg, 1248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org target, id); 1249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else 1251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return NULL; 1252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org default: 1255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Just fallback: 1256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return _mesa_new_program(ctx, target, id); 1258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915DeleteProgram(struct gl_context * ctx, struct gl_program *prog) 1263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (prog->Target == GL_FRAGMENT_PROGRAM_ARB) { 1265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_context *i915 = I915_CONTEXT(ctx); 1266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_fragment_program *p = (struct i915_fragment_program *) prog; 1267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i915->current_program == p) 1269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->current_program = 0; 1270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _mesa_delete_program(ctx, prog); 1273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLboolean 1277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915IsProgramNative(struct gl_context * ctx, GLenum target, struct gl_program *prog) 1278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target == GL_FRAGMENT_PROGRAM_ARB) { 1280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_fragment_program *p = (struct i915_fragment_program *) prog; 1281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!p->translated) 1283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org translate_program(p); 1284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return !p->error; 1286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else 1288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return true; 1289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic GLboolean 1292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915ProgramStringNotify(struct gl_context * ctx, 1293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum target, struct gl_program *prog) 1294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (target == GL_FRAGMENT_PROGRAM_ARB) { 1296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_fragment_program *p = (struct i915_fragment_program *) prog; 1297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org p->translated = 0; 1298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (void) _tnl_program_string(ctx, target, prog); 1301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* XXX check if program is legal, within limits */ 1303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return true; 1304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic void 1307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915SamplerUniformChange(struct gl_context *ctx, 1308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLenum target, struct gl_program *prog) 1309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915ProgramStringNotify(ctx, target, prog); 1311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 1314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915_update_program(struct gl_context *ctx) 1315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct intel_context *intel = intel_context(ctx); 1317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_context *i915 = i915_context(&intel->ctx); 1318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_fragment_program *fp = 1319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (struct i915_fragment_program *) ctx->FragmentProgram._Current; 1320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i915->current_program != fp) { 1322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (i915->current_program) { 1323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->current_program->on_hardware = 0; 1324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->current_program->params_uptodate = 0; 1325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->current_program = fp; 1328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!fp->translated) 1331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org translate_program(fp); 1332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org FALLBACK(&i915->intel, I915_FALLBACK_PROGRAM, fp->error); 1334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 1337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915ValidateFragmentProgram(struct i915_context *i915) 1338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_context *ctx = &i915->intel.ctx; 1340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct intel_context *intel = intel_context(ctx); 1341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org TNLcontext *tnl = TNL_CONTEXT(ctx); 1342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct vertex_buffer *VB = &tnl->vb; 1343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct i915_fragment_program *p = 1345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (struct i915_fragment_program *) ctx->FragmentProgram._Current; 1346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLbitfield64 inputsRead = p->FragProg.Base.InputsRead; 1348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK; 1349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint s2 = S2_TEXCOORD_NONE; 1350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int i, offset = 0; 1351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Important: 1353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr; 1355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!p->translated) 1357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org translate_program(p); 1358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->vertex_attr_count = 0; 1360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->wpos_offset = 0; 1361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->coloroffset = 0; 1362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->specoffset = 0; 1363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inputsRead & FRAG_BITS_TEX_ANY || p->wpos_tex != -1) { 1365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16); 1366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else { 1368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, S4_VFMT_XYZ, 12); 1369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Handle gl_PointSize builtin var here */ 1372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) 1373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_POINTSIZE, EMIT_1F, S4_VFMT_POINT_WIDTH, 4); 1374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inputsRead & FRAG_BIT_COL0) { 1376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->coloroffset = offset / 4; 1377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4); 1378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inputsRead & FRAG_BIT_COL1) { 1381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->specoffset = offset / 4; 1382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_4UB_4F_BGRA, S4_VFMT_SPEC_FOG, 4); 1383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if ((inputsRead & FRAG_BIT_FOGC)) { 1386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1F, S4_VFMT_FOG_PARAM, 4); 1387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) { 1390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (inputsRead & FRAG_BIT_TEX(i)) { 1391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int sz = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]->size; 1392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK); 1394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(sz)); 1395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_TEX0 + i, EMIT_SZ(sz), 0, sz * 4); 1397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (inputsRead & FRAG_BIT_VAR(i)) { 1399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int sz = VB->AttribPtr[_TNL_ATTRIB_GENERIC0 + i]->size; 1400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK); 1402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(sz)); 1403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_ATTR(_TNL_ATTRIB_GENERIC0 + i, EMIT_SZ(sz), 0, sz * 4); 1405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org else if (i == p->wpos_tex) { 1407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int wpos_size = 4 * sizeof(float); 1408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* If WPOS is required, duplicate the XYZ position data in an 1409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * unused texture coordinate: 1410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK); 1412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(wpos_size)); 1413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->wpos_offset = offset; 1415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EMIT_PAD(wpos_size); 1416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (s2 != i915->state.Ctx[I915_CTXREG_LIS2] || 1420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org s4 != i915->state.Ctx[I915_CTXREG_LIS4]) { 1421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int k; 1422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org I915_STATECHANGE(i915, I915_UPLOAD_CTX); 1424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Must do this *after* statechange, so as not to affect 1426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * buffered vertices reliant on the old state: 1427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 1428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->vertex_size = _tnl_install_attrs(&intel->ctx, 1429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->vertex_attrs, 1430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->vertex_attr_count, 1431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->ViewportMatrix.m, 0); 1432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(intel->prim.current_offset == intel->prim.start_offset); 1434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->prim.start_offset = (intel->prim.current_offset + intel->vertex_size-1) / intel->vertex_size * intel->vertex_size; 1435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->prim.current_offset = intel->prim.start_offset; 1436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org intel->vertex_size >>= 2; 1438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->state.Ctx[I915_CTXREG_LIS2] = s2; 1440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915->state.Ctx[I915_CTXREG_LIS4] = s4; 1441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org k = intel->vtbl.check_vertex_size(intel, intel->vertex_size); 1443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org assert(k); 1444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!p->params_uptodate) 1447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org track_params(p); 1448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (!p->on_hardware) 1450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_upload_program(i915, p); 1451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (INTEL_DEBUG & DEBUG_WM) { 1453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org printf("i915:\n"); 1454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org i915_disassemble_program(i915->state.Program, i915->state.ProgramSize); 1455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } 1456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 1458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 1459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgi915InitFragProgFuncs(struct dd_function_table *functions) 1460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 1461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org functions->BindProgram = i915BindProgram; 1462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org functions->NewProgram = i915NewProgram; 1463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org functions->DeleteProgram = i915DeleteProgram; 1464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org functions->IsProgramNative = i915IsProgramNative; 1465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org functions->ProgramStringNotify = i915ProgramStringNotify; 1466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org functions->SamplerUniformChange = i915SamplerUniformChange; 1467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 1468