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

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/i965/brw_vs_surface_state.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:
30
30
  */
31
31
 
32
32
#include "main/mtypes.h"
33
 
#include "main/texstore.h"
34
33
#include "program/prog_parameter.h"
35
34
 
36
35
#include "brw_context.h"
43
42
 * state atom.
44
43
 */
45
44
static void
46
 
prepare_vs_constants(struct brw_context *brw)
 
45
brw_upload_vs_pull_constants(struct brw_context *brw)
47
46
{
48
47
   struct gl_context *ctx = &brw->intel.ctx;
49
48
   struct intel_context *intel = &brw->intel;
 
49
   /* BRW_NEW_VERTEX_PROGRAM */
50
50
   struct brw_vertex_program *vp =
51
51
      (struct brw_vertex_program *) brw->vertex_program;
52
52
   const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
53
 
   const int size = params->NumParameters * 4 * sizeof(GLfloat);
54
53
   int i;
55
54
 
56
55
   if (vp->program.IsNVProgram)
61
60
    */
62
61
   _mesa_load_state_parameters(&brw->intel.ctx, vp->program.Base.Parameters);
63
62
 
64
 
   /* BRW_NEW_VERTEX_PROGRAM */
65
 
   if (!vp->use_const_buffer) {
 
63
   /* CACHE_NEW_VS_PROG */
 
64
   if (!brw->vs.prog_data->nr_pull_params) {
66
65
      if (brw->vs.const_bo) {
67
66
         drm_intel_bo_unreference(brw->vs.const_bo);
68
67
         brw->vs.const_bo = NULL;
 
68
         brw->bind.surf_offset[SURF_INDEX_VERT_CONST_BUFFER] = 0;
69
69
         brw->state.dirty.brw |= BRW_NEW_VS_CONSTBUF;
70
70
      }
71
71
      return;
74
74
   /* _NEW_PROGRAM_CONSTANTS */
75
75
   drm_intel_bo_unreference(brw->vs.const_bo);
76
76
   brw->vs.const_bo = drm_intel_bo_alloc(intel->bufmgr, "vp_const_buffer",
77
 
                                         size, 64);
 
77
                                         brw->vs.prog_data->nr_pull_params * 4,
 
78
                                         64);
78
79
 
79
80
   drm_intel_gem_bo_map_gtt(brw->vs.const_bo);
80
 
   for (i = 0; i < params->NumParameters; i++) {
81
 
      memcpy(brw->vs.const_bo->virtual + i * 4 * sizeof(float),
82
 
             params->ParameterValues[i],
83
 
             4 * sizeof(float));
 
81
   for (i = 0; i < brw->vs.prog_data->nr_pull_params; i++) {
 
82
      memcpy(brw->vs.const_bo->virtual + i * 4,
 
83
             brw->vs.prog_data->pull_param[i],
 
84
             4);
84
85
   }
85
86
 
86
87
   if (0) {
92
93
   }
93
94
 
94
95
   drm_intel_gem_bo_unmap_gtt(brw->vs.const_bo);
 
96
 
 
97
   const int surf = SURF_INDEX_VERT_CONST_BUFFER;
 
98
   intel->vtbl.create_constant_surface(brw, brw->vs.const_bo,
 
99
                                       params->NumParameters,
 
100
                                       &brw->bind.surf_offset[surf]);
 
101
 
95
102
   brw->state.dirty.brw |= BRW_NEW_VS_CONSTBUF;
96
103
}
97
104
 
98
 
const struct brw_tracked_state brw_vs_constants = {
 
105
const struct brw_tracked_state brw_vs_pull_constants = {
99
106
   .dirty = {
100
107
      .mesa = (_NEW_PROGRAM_CONSTANTS),
101
 
      .brw = (BRW_NEW_VERTEX_PROGRAM),
102
 
      .cache = 0
103
 
   },
104
 
   .prepare = prepare_vs_constants,
105
 
};
106
 
 
107
 
/**
108
 
 * Update the surface state for a VS constant buffer.
109
 
 *
110
 
 * Sets brw->vs.surf_bo[surf] and brw->vp->const_buffer.
111
 
 */
112
 
static void
113
 
brw_update_vs_constant_surface( struct gl_context *ctx,
114
 
                                GLuint surf)
115
 
{
116
 
   struct brw_context *brw = brw_context(ctx);
117
 
   struct intel_context *intel = &brw->intel;
118
 
   struct brw_vertex_program *vp =
119
 
      (struct brw_vertex_program *) brw->vertex_program;
120
 
   const struct gl_program_parameter_list *params = vp->program.Base.Parameters;
121
 
 
122
 
   assert(surf == 0);
123
 
 
124
 
   /* If there's no constant buffer, then no surface BO is needed to point at
125
 
    * it.
126
 
    */
127
 
   if (brw->vs.const_bo == NULL) {
128
 
      brw->vs.surf_offset[surf] = 0;
129
 
      return;
130
 
   }
131
 
 
132
 
   if (intel->gen >= 7) {
133
 
      gen7_create_constant_surface(brw, brw->vs.const_bo, params->NumParameters,
134
 
                                  &brw->vs.surf_offset[surf]);
135
 
   } else {
136
 
      brw_create_constant_surface(brw, brw->vs.const_bo, params->NumParameters,
137
 
                                  &brw->vs.surf_offset[surf]);
138
 
   }
139
 
}
140
 
 
141
 
 
142
 
static void
143
 
prepare_vs_surfaces(struct brw_context *brw)
144
 
{
145
 
   int nr_surfaces = 0;
146
 
 
147
 
   if (brw->vs.const_bo) {
148
 
      brw_add_validated_bo(brw, brw->vs.const_bo);
149
 
      nr_surfaces = 1;
150
 
   }
151
 
 
152
 
   if (brw->vs.nr_surfaces != nr_surfaces) {
153
 
      brw->state.dirty.brw |= BRW_NEW_NR_VS_SURFACES;
154
 
      brw->vs.nr_surfaces = nr_surfaces;
155
 
   }
156
 
}
157
 
 
158
 
/**
159
 
 * Vertex shader surfaces (constant buffer).
160
 
 *
161
 
 * This consumes the state updates for the constant buffer needing
162
 
 * to be updated, and produces BRW_NEW_NR_VS_SURFACES for the VS unit and
163
 
 * CACHE_NEW_SURF_BIND for the binding table upload.
164
 
 */
165
 
static void upload_vs_surfaces(struct brw_context *brw)
166
 
{
167
 
   struct gl_context *ctx = &brw->intel.ctx;
168
 
   uint32_t *bind;
169
 
   int i;
170
 
 
171
 
   /* BRW_NEW_NR_VS_SURFACES */
172
 
   if (brw->vs.nr_surfaces == 0) {
173
 
      if (brw->vs.bind_bo_offset) {
174
 
         brw->state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE;
175
 
      }
176
 
      brw->vs.bind_bo_offset = 0;
177
 
      return;
178
 
   }
179
 
 
180
 
   brw_update_vs_constant_surface(ctx, SURF_INDEX_VERT_CONST_BUFFER);
181
 
 
182
 
   /* Might want to calculate nr_surfaces first, to avoid taking up so much
183
 
    * space for the binding table. (once we have vs samplers)
184
 
    */
185
 
   bind = brw_state_batch(brw, sizeof(uint32_t) * BRW_VS_MAX_SURF,
186
 
                          32, &brw->vs.bind_bo_offset);
187
 
 
188
 
   for (i = 0; i < BRW_VS_MAX_SURF; i++) {
189
 
      /* BRW_NEW_VS_CONSTBUF */
190
 
      bind[i] = brw->vs.surf_offset[i];
191
 
   }
192
 
 
193
 
   brw->state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE;
194
 
}
195
 
 
196
 
const struct brw_tracked_state brw_vs_surfaces = {
197
 
   .dirty = {
198
 
      .mesa = 0,
199
 
      .brw = (BRW_NEW_VS_CONSTBUF |
200
 
              BRW_NEW_NR_VS_SURFACES |
201
 
              BRW_NEW_BATCH),
202
 
      .cache = 0
203
 
   },
204
 
   .prepare = prepare_vs_surfaces,
205
 
   .emit = upload_vs_surfaces,
 
108
      .brw = (BRW_NEW_BATCH | BRW_NEW_VERTEX_PROGRAM),
 
109
      .cache = CACHE_NEW_VS_PROG,
 
110
   },
 
111
   .emit = brw_upload_vs_pull_constants,
206
112
};