76
79
free(brw->curbe.next_buf);
81
* called from intelDrawBuffer()
83
* Update the hardware state for drawing into a window or framebuffer object.
85
* Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
86
* places within the driver.
88
* Basically, this needs to be called any time the current framebuffer
89
* changes, the renderbuffers change, or we need to draw into different
83
static void brw_set_draw_region( struct intel_context *intel,
84
struct intel_region *color_regions[],
85
struct intel_region *depth_region,
86
GLuint num_color_regions)
93
brw_update_draw_buffer(struct intel_context *intel)
95
struct gl_context *ctx = &intel->ctx;
96
struct gl_framebuffer *fb = ctx->DrawBuffer;
97
struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
98
bool fb_has_hiz = intel_framebuffer_has_hiz(fb);
101
/* this can happen during the initial context initialization */
106
* If intel_context is using separate stencil, but the depth attachment
107
* (gl_framebuffer.Attachment[BUFFER_DEPTH]) has a packed depth/stencil
108
* format, then we must install the real depth buffer at fb->_DepthBuffer
109
* and set fb->_DepthBuffer->Wrapped before calling _mesa_update_framebuffer.
110
* Otherwise, _mesa_update_framebuffer will create and install a swras
111
* depth wrapper instead.
115
irbDepth = intel_get_renderbuffer(fb, BUFFER_DEPTH);
116
if (irbDepth && irbDepth->Base.Format == MESA_FORMAT_X8_Z24) {
117
_mesa_reference_renderbuffer(&fb->_DepthBuffer, &irbDepth->Base);
118
irbDepth->Base.Wrapped = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
121
irbStencil = intel_get_renderbuffer(fb, BUFFER_STENCIL);
122
if (irbStencil && irbStencil->Base.Format == MESA_FORMAT_S8) {
123
_mesa_reference_renderbuffer(&fb->_StencilBuffer, &irbStencil->Base);
124
irbStencil->Base.Wrapped = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
127
/* Do this here, not core Mesa, since this function is called from
128
* many places within the driver.
130
if (ctx->NewState & _NEW_BUFFERS) {
131
/* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
132
_mesa_update_framebuffer(ctx);
133
/* this updates the DrawBuffer's Width/Height if it's a FBO */
134
_mesa_update_draw_buffer_bounds(ctx);
137
if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
138
/* this may occur when we're called by glBindFrameBuffer() during
139
* the process of someone setting up renderbuffers, etc.
141
/*_mesa_debug(ctx, "DrawBuffer: incomplete user FBO\n");*/
145
/* Check some stencil invariants. These should probably be in
146
* emit_depthbuffer().
148
if (irbStencil && irbStencil->region) {
149
if (!intel->has_separate_stencil)
150
assert(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
151
if (fb_has_hiz || intel->must_use_separate_stencil)
152
assert(irbStencil->Base.Format == MESA_FORMAT_S8);
153
if (irbStencil->Base.Format == MESA_FORMAT_S8)
154
assert(intel->has_separate_stencil);
157
/* Mesa's Stencil._Enabled field is updated when
158
* _NEW_BUFFERS | _NEW_STENCIL, but i965 code assumes that the value
159
* only changes with _NEW_STENCIL (which seems sensible). So flag it
160
* here since this is the _NEW_BUFFERS path.
162
intel->NewGLState |= (_NEW_DEPTH | _NEW_STENCIL);
164
/* The driver uses this in places that need to look up
165
* renderbuffers' buffer objects.
167
intel->NewGLState |= _NEW_BUFFERS;
169
/* update viewport/scissor since it depends on window size */
170
intel->NewGLState |= _NEW_VIEWPORT | _NEW_SCISSOR;
172
/* Update culling direction which changes depending on the
173
* orientation of the buffer:
175
intel->NewGLState |= _NEW_POLYGON;
92
179
* called from intel_batchbuffer_flush and children before sending a
93
180
* batchbuffer off.