1
/* XXX: Constant buffers disabled
6
* Create the constant buffer surface. Vertex/fragment shader constants will be
7
* read from this buffer with Data Port Read instructions/messages.
10
brw_create_constant_surface( struct brw_context *brw,
11
struct brw_surface_key *key,
12
struct brw_winsys_buffer **bo_out )
14
const GLint w = key->width - 1;
15
struct brw_winsys_buffer *bo;
16
struct brw_winsys_reloc reloc[1];
19
/* Emit relocation to surface contents */
23
offsetof(struct brw_surface_state, ss1),
27
memset(&surf, 0, sizeof(surf));
29
surf.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
30
surf.ss0.surface_type = BRW_SURFACE_BUFFER;
31
surf.ss0.surface_format = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT;
33
surf.ss1.base_addr = 0; /* reloc */
35
surf.ss2.width = w & 0x7f; /* bits 6:0 of size or width */
36
surf.ss2.height = (w >> 7) & 0x1fff; /* bits 19:7 of size or width */
37
surf.ss3.depth = (w >> 20) & 0x7f; /* bits 26:20 of size or width */
38
surf.ss3.pitch = (key->pitch * key->cpp) - 1; /* ignored?? */
39
brw_set_surface_tiling(&surf, key->tiling); /* tiling now allowed */
41
ret = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE,
43
reloc, Elements(reloc),
56
* Update the surface state for a WM constant buffer.
57
* The constant buffer will be (re)allocated here if needed.
59
static enum pipe_error
60
brw_update_wm_constant_surface( struct brw_context *brw,
63
struct brw_surface_key key;
64
struct brw_fragment_shader *fp = brw->curr.fragment_shader;
65
struct pipe_resource *cbuf = brw->curr.fragment_constants;
66
int pitch = cbuf->size / (4 * sizeof(float));
69
/* If we're in this state update atom, we need to update WM constants, so
70
* free the old buffer and create a new one for the new contents.
72
ret = brw_wm_update_constant_buffer(brw, &fp->const_buffer);
76
/* If there's no constant buffer, then no surface BO is needed to point at
80
bo_reference(&brw->wm.surf_bo[surf], NULL);
84
memset(&key, 0, sizeof(key));
86
key.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
87
key.ss0.surface_type = BRW_SURFACE_BUFFER;
88
key.ss0.surface_format = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT;
90
key.bo = brw_buffer(cbuf)->bo;
92
key.ss2.width = (pitch-1) & 0x7f; /* bits 6:0 of size or width */
93
key.ss2.height = ((pitch-1) >> 7) & 0x1fff; /* bits 19:7 of size or width */
94
key.ss3.depth = ((pitch-1) >> 20) & 0x7f; /* bits 26:20 of size or width */
95
key.ss3.pitch = (pitch * 4 * sizeof(float)) - 1; /* ignored?? */
96
brw_set_surface_tiling(&surf, key->tiling); /* tiling now allowed */
100
printf("%s:\n", __FUNCTION__);
101
printf(" width %d height %d depth %d cpp %d pitch %d\n",
102
key.width, key.height, key.depth, key.cpp, key.pitch);
105
if (brw_search_cache(&brw->surface_cache,
110
&brw->wm.surf_bo[surf]))
113
ret = brw_create_constant_surface(brw, &key, &brw->wm.surf_bo[surf]);
117
brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
122
* Updates surface / buffer for fragment shader constant buffer, if
125
* This consumes the state updates for the constant buffer, and produces
126
* BRW_NEW_WM_SURFACES to get picked up by brw_prepare_wm_surfaces for
127
* inclusion in the binding table.
129
static enum pipe_error prepare_wm_constant_surface(struct brw_context *brw )
131
struct brw_fragment_program *fp =
132
(struct brw_fragment_program *) brw->fragment_program;
133
GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
135
ret = brw_wm_update_constant_buffer(brw,
140
/* If there's no constant buffer, then no surface BO is needed to point at
143
if (fp->const_buffer == 0) {
144
if (brw->wm.surf_bo[surf] != NULL) {
145
bo_reference(&brw->wm.surf_bo[surf], NULL);
146
brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
151
ret = brw_update_wm_constant_surface(ctx, surf);
158
const struct brw_tracked_state brw_wm_constant_surface = {
160
.mesa = (_NEW_PROGRAM_CONSTANTS),
161
.brw = (BRW_NEW_FRAGMENT_PROGRAM),
164
.prepare = prepare_wm_constant_surface,