~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/gallium/drivers/i965/brw_vs.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 Copyright (C) Intel Corp.  2006.  All Rights Reserved.
3
 
 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4
 
 develop this 3D driver.
5
 
 
6
 
 Permission is hereby granted, free of charge, to any person obtaining
7
 
 a copy of this software and associated documentation files (the
8
 
 "Software"), to deal in the Software without restriction, including
9
 
 without limitation the rights to use, copy, modify, merge, publish,
10
 
 distribute, sublicense, and/or sell copies of the Software, and to
11
 
 permit persons to whom the Software is furnished to do so, subject to
12
 
 the following conditions:
13
 
 
14
 
 The above copyright notice and this permission notice (including the
15
 
 next paragraph) shall be included in all copies or substantial
16
 
 portions of the Software.
17
 
 
18
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
 
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
 
 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22
 
 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
 
 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
 
 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 
 
26
 
 **********************************************************************/
27
 
 /*
28
 
  * Authors:
29
 
  *   Keith Whitwell <keith@tungstengraphics.com>
30
 
  */
31
 
 
32
 
#include "tgsi/tgsi_dump.h"           
33
 
 
34
 
#include "brw_context.h"
35
 
#include "brw_vs.h"
36
 
#include "brw_state.h"
37
 
 
38
 
 
39
 
 
40
 
static enum pipe_error do_vs_prog( struct brw_context *brw, 
41
 
                                   struct brw_vertex_shader *vp,
42
 
                                   struct brw_vs_prog_key *key,
43
 
                                   struct brw_winsys_buffer **bo_out)
44
 
{
45
 
   enum pipe_error ret;
46
 
   GLuint program_size;
47
 
   const GLuint *program;
48
 
   struct brw_vs_compile c;
49
 
 
50
 
   memset(&c, 0, sizeof(c));
51
 
   memcpy(&c.key, key, sizeof(*key));
52
 
 
53
 
   brw_init_compile(brw, &c.func);
54
 
   c.vp = vp;
55
 
 
56
 
   c.prog_data.nr_outputs = vp->info.num_outputs;
57
 
   c.prog_data.nr_inputs = vp->info.num_inputs;
58
 
 
59
 
   if (1)
60
 
      tgsi_dump(c.vp->tokens, 0);
61
 
 
62
 
   /* Emit GEN4 code.
63
 
    */
64
 
   brw_vs_emit(&c);
65
 
 
66
 
   /* get the program
67
 
    */
68
 
   ret = brw_get_program(&c.func, &program, &program_size);
69
 
   if (ret)
70
 
      return ret;
71
 
 
72
 
   ret = brw_upload_cache( &brw->cache, BRW_VS_PROG,
73
 
                           &c.key, brw_vs_prog_key_size(&c.key),
74
 
                           NULL, 0,
75
 
                           program, program_size,
76
 
                           &c.prog_data,
77
 
                           &brw->vs.prog_data,
78
 
                           bo_out);
79
 
   if (ret)
80
 
      return ret;
81
 
 
82
 
   return PIPE_OK;
83
 
}
84
 
 
85
 
 
86
 
static enum pipe_error brw_upload_vs_prog(struct brw_context *brw)
87
 
{
88
 
   struct brw_vs_prog_key key;
89
 
   struct brw_vertex_shader *vp = brw->curr.vertex_shader;
90
 
   struct brw_fs_signature *sig = &brw->curr.fragment_shader->signature;
91
 
   enum pipe_error ret;
92
 
 
93
 
   memset(&key, 0, sizeof(key));
94
 
 
95
 
   key.program_string_id = vp->id;
96
 
   key.nr_userclip = brw->curr.ucp.nr;
97
 
 
98
 
   memcpy(&key.fs_signature, sig, brw_fs_signature_size(sig));
99
 
 
100
 
 
101
 
   /* Make an early check for the key.
102
 
    */
103
 
   if (brw_search_cache(&brw->cache, BRW_VS_PROG,
104
 
                        &key, brw_vs_prog_key_size(&key),
105
 
                        NULL, 0,
106
 
                        &brw->vs.prog_data,
107
 
                        &brw->vs.prog_bo))
108
 
      return PIPE_OK;
109
 
 
110
 
   ret = do_vs_prog(brw, vp, &key, &brw->vs.prog_bo);
111
 
   if (ret)
112
 
      return ret;
113
 
 
114
 
   return PIPE_OK;
115
 
}
116
 
 
117
 
 
118
 
/* See brw_vs.c:
119
 
 */
120
 
const struct brw_tracked_state brw_vs_prog = {
121
 
   .dirty = {
122
 
      .mesa  = (PIPE_NEW_CLIP | 
123
 
                PIPE_NEW_RAST |
124
 
                PIPE_NEW_FRAGMENT_SIGNATURE),
125
 
      .brw   = BRW_NEW_VERTEX_PROGRAM,
126
 
      .cache = 0
127
 
   },
128
 
   .prepare = brw_upload_vs_prog
129
 
};