1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Copyright (C) Intel Corp. 2006. All Rights Reserved. 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org develop this 3D driver. 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Permission is hereby granted, free of charge, to any person obtaining 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org a 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, sublicense, 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 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org portions of the Software. 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **********************************************************************/ 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Authors: 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Keith Whitwell <keith@tungstengraphics.com> 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef BRW_VS_H 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define BRW_VS_H 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "brw_context.h" 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "brw_eu.h" 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "brw_program.h" 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "program/program.h" 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct brw_vs_prog_key { 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint program_string_id; 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Number of channels of the vertex attribute that need GL_FIXED rescaling 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org uint8_t gl_fixed_input_size[VERT_ATTRIB_MAX]; 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * True if at least one clip flag is enabled, regardless of whether the 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * shader uses clip planes or gl_ClipDistance. 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint userclip_active:1; 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * How many user clipping planes are being uploaded to the vertex shader as 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * push constants. 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint nr_userclip_plane_consts:4; 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * True if the shader uses gl_ClipDistance, regardless of whether any clip 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * flags are enabled. 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint uses_clip_distance:1; 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * For pre-Gen6 hardware, a bitfield indicating which clipping planes are 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * enabled. This is used to compact clip planes. 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * For Gen6 and later hardware, clip planes are not compacted, so this 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * value is zero to avoid provoking unnecessary shader recompiles. 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint userclip_planes_enabled_gen_4_5:MAX_CLIP_PLANES; 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint copy_edgeflag:1; 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint point_coord_replace:8; 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint clamp_vertex_color:1; 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_sampler_prog_key_data tex; 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct brw_vs_compile { 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_compile func; 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_vs_prog_key key; 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_vs_prog_data prog_data; 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int8_t constant_map[1024]; 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_vertex_program *vp; 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint nr_inputs; 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint first_output; 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint last_scratch; /**< measured in 32-byte (register size) units */ 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint first_tmp; 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint last_tmp; 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_reg r0; 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_reg r1; 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_reg regs[PROGRAM_ADDRESS+1][128]; 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_reg tmp; 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct { 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org bool used_in_src; 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_reg reg; 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } output_regs[128]; 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_reg userplane[MAX_CLIP_PLANES]; 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /** we may need up to 3 constants per instruction (if use_const_buffer) */ 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct { 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLint index; 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct brw_reg reg; 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } current_const[3]; 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgbool brw_vs_emit(struct gl_shader_program *prog, struct brw_vs_compile *c); 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid brw_old_vs_emit(struct brw_vs_compile *c); 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgbool brw_vs_precompile(struct gl_context *ctx, struct gl_shader_program *prog); 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid brw_vs_debug_recompile(struct brw_context *brw, 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct gl_shader_program *prog, 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct brw_vs_prog_key *key); 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 128