19f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* 29f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Copyright (C) Intel Corp. 2006. All Rights Reserved. 39f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to 49f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt develop this 3D driver. 59f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 69f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Permission is hereby granted, free of charge, to any person obtaining 79f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt a copy of this software and associated documentation files (the 89f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt "Software"), to deal in the Software without restriction, including 99f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt without limitation the rights to use, copy, modify, merge, publish, 109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt distribute, sublicense, and/or sell copies of the Software, and to 119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt permit persons to whom the Software is furnished to do so, subject to 129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt the following conditions: 139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt The above copyright notice and this permission notice (including the 159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt next paragraph) shall be included in all copies or substantial 169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt portions of the Software. 179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt **********************************************************************/ 279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /* 289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * Authors: 299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * Keith Whitwell <keith@tungstengraphics.com> 309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */ 319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#ifndef BRW_VS_H 349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_VS_H 359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_context.h" 389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_eu.h" 39d45814c925dd6c479cfd383b9b59458fc4359cf7Kenneth Graunke#include "brw_program.h" 40ec2b92f98c2e7f161521b447cc1d9a36bce3707cBrian Paul#include "program/program.h" 419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_vs_prog_key { 449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint program_string_id; 454176025d463e7733dac19788b45b6472b65d62d4Eric Anholt /** 464176025d463e7733dac19788b45b6472b65d62d4Eric Anholt * Number of channels of the vertex attribute that need GL_FIXED rescaling 474176025d463e7733dac19788b45b6472b65d62d4Eric Anholt */ 484176025d463e7733dac19788b45b6472b65d62d4Eric Anholt uint8_t gl_fixed_input_size[VERT_ATTRIB_MAX]; 49a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry 50a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry /** 5118e2e19b07b312c978dfbb6d336f69fa84b3ffe2Paul Berry * True if at least one clip flag is enabled, regardless of whether the 5218e2e19b07b312c978dfbb6d336f69fa84b3ffe2Paul Berry * shader uses clip planes or gl_ClipDistance. 5318e2e19b07b312c978dfbb6d336f69fa84b3ffe2Paul Berry */ 5418e2e19b07b312c978dfbb6d336f69fa84b3ffe2Paul Berry GLuint userclip_active:1; 5518e2e19b07b312c978dfbb6d336f69fa84b3ffe2Paul Berry 5618e2e19b07b312c978dfbb6d336f69fa84b3ffe2Paul Berry /** 57018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry * How many user clipping planes are being uploaded to the vertex shader as 58018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry * push constants. 59a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry */ 60018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry GLuint nr_userclip_plane_consts:4; 61a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry 62a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry /** 63a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry * True if the shader uses gl_ClipDistance, regardless of whether any clip 64a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry * flags are enabled. 65a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry */ 66a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry GLuint uses_clip_distance:1; 67a1b37ebe757f7a74d69612d7c32fbdbbe3405989Paul Berry 688f6920a7b69bd20f04f807e88c22cf1eb78b4e79Paul Berry /** 69018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry * For pre-Gen6 hardware, a bitfield indicating which clipping planes are 70018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry * enabled. This is used to compact clip planes. 71018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry * 72018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry * For Gen6 and later hardware, clip planes are not compacted, so this 73018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry * value is zero to avoid provoking unnecessary shader recompiles. 748f6920a7b69bd20f04f807e88c22cf1eb78b4e79Paul Berry */ 75018ea68d8780ab5baeef0b8122b8410e5e55ae6dPaul Berry GLuint userclip_planes_enabled_gen_4_5:MAX_CLIP_PLANES; 768f6920a7b69bd20f04f807e88c22cf1eb78b4e79Paul Berry 779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint copy_edgeflag:1; 7864f5e9059b975e34885e63bc404b30b1b2c28de8Eric Anholt GLuint point_coord_replace:8; 79d22e2ebe35ef9d33ec5f7a67f903f36bcd9fbc91Eric Anholt GLuint clamp_vertex_color:1; 80d45814c925dd6c479cfd383b9b59458fc4359cf7Kenneth Graunke 81d45814c925dd6c479cfd383b9b59458fc4359cf7Kenneth Graunke struct brw_sampler_prog_key_data tex; 829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}; 839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_vs_compile { 869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_compile func; 879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_vs_prog_key key; 889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_vs_prog_data prog_data; 89fb4901593c9495714d3f54920a28c271852e2112Eric Anholt int8_t constant_map[1024]; 909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_vertex_program *vp; 929f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint nr_inputs; 949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint first_output; 96cb415d4df644a8caffe861626dec5f7aa4cefa49Kenneth Graunke GLuint last_scratch; /**< measured in 32-byte (register size) units */ 979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint first_tmp; 999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt GLuint last_tmp; 1009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_reg r0; 1029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_reg r1; 1039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_reg regs[PROGRAM_ADDRESS+1][128]; 1049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt struct brw_reg tmp; 1059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 106d19d0596daf004b56d80f78fa1a329b43c2ebf94Zou Nan hai struct { 1072e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke bool used_in_src; 108d19d0596daf004b56d80f78fa1a329b43c2ebf94Zou Nan hai struct brw_reg reg; 109d19d0596daf004b56d80f78fa1a329b43c2ebf94Zou Nan hai } output_regs[128]; 1109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1117e2b23ba85a89282565d9375b0a885cc48e66c82Paul Berry struct brw_reg userplane[MAX_CLIP_PLANES]; 1129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 113cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul /** we may need up to 3 constants per instruction (if use_const_buffer) */ 114cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul struct { 115cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul GLint index; 116cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul struct brw_reg reg; 117cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul } current_const[3]; 1189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}; 1199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1207fbe7fe13359d3f349664410ec73d7bd48824ed6Eric Anholtbool brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c); 121af3c9803d818fd33139f1247a387d64b967b8992Eric Anholtvoid brw_old_vs_emit(struct brw_vs_compile *c); 1227fbe7fe13359d3f349664410ec73d7bd48824ed6Eric Anholtbool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog); 123c20cb8d1f6cac0b98950828e69376bb9406761ffKenneth Graunkevoid brw_vs_debug_recompile(struct brw_context *brw, 124c20cb8d1f6cac0b98950828e69376bb9406761ffKenneth Graunke struct gl_shader_program *prog, 125c20cb8d1f6cac0b98950828e69376bb9406761ffKenneth Graunke const struct brw_vs_prog_key *key); 1269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt 1279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#endif 128