diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_span.c | 91 |
1 files changed, 27 insertions, 64 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index aa83b3c128a..9343f40eef0 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -185,10 +185,16 @@ intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb) rb->Data = irb->region->buffer->virtual; rb->RowStride = irb->region->pitch; - /* Flip orientation if it's the window system buffer */ if (!rb->Name) { + /* Flip orientation of the window system buffer */ rb->Data += rb->RowStride * (irb->region->height - 1) * irb->region->cpp; rb->RowStride = -rb->RowStride; + } else { + /* Adjust the base pointer of a texture image drawbuffer to the image + * within the miptree region (all else has draw_x/y = 0). + */ + rb->Data += irb->draw_x * irb->region->cpp; + rb->Data += irb->draw_y * rb->RowStride * irb->region->cpp; } intel_set_span_functions(intel, rb); @@ -211,71 +217,26 @@ intel_renderbuffer_unmap(struct intel_context *intel, rb->RowStride = 0; } -/** - * Map or unmap all the renderbuffers which we may need during - * software rendering. - * XXX in the future, we could probably convey extra information to - * reduce the number of mappings needed. I.e. if doing a glReadPixels - * from the depth buffer, we really only need one mapping. - * - * XXX Rewrite this function someday. - * We can probably just loop over all the renderbuffer attachments, - * map/unmap all of them, and not worry about the _ColorDrawBuffers - * _ColorReadBuffer, _DepthBuffer or _StencilBuffer fields. - */ static void -intel_map_unmap_framebuffer(struct intel_context *intel, - struct gl_framebuffer *fb, - GLboolean map) +intel_framebuffer_map(struct intel_context *intel, struct gl_framebuffer *fb) { - GLuint i; - - /* color draw buffers */ - for (i = 0; i < fb->_NumColorDrawBuffers; i++) { - if (map) - intel_renderbuffer_map(intel, fb->_ColorDrawBuffers[i]); - else - intel_renderbuffer_unmap(intel, fb->_ColorDrawBuffers[i]); - } - - /* color read buffer */ - if (map) - intel_renderbuffer_map(intel, fb->_ColorReadBuffer); - else - intel_renderbuffer_unmap(intel, fb->_ColorReadBuffer); + int i; - /* check for render to textures */ for (i = 0; i < BUFFER_COUNT; i++) { - struct gl_renderbuffer_attachment *att = - fb->Attachment + i; - struct gl_texture_object *tex = att->Texture; - if (tex) { - /* render to texture */ - ASSERT(att->Renderbuffer); - if (map) - intel_tex_map_images(intel, intel_texture_object(tex)); - else - intel_tex_unmap_images(intel, intel_texture_object(tex)); - } + intel_renderbuffer_map(intel, fb->Attachment[i].Renderbuffer); } - /* depth buffer (Note wrapper!) */ - if (fb->_DepthBuffer) { - if (map) - intel_renderbuffer_map(intel, fb->_DepthBuffer->Wrapped); - else - intel_renderbuffer_unmap(intel, fb->_DepthBuffer->Wrapped); - } + intel_check_front_buffer_rendering(intel); +} - /* stencil buffer (Note wrapper!) */ - if (fb->_StencilBuffer) { - if (map) - intel_renderbuffer_map(intel, fb->_StencilBuffer->Wrapped); - else - intel_renderbuffer_unmap(intel, fb->_StencilBuffer->Wrapped); - } +static void +intel_framebuffer_unmap(struct intel_context *intel, struct gl_framebuffer *fb) +{ + int i; - intel_check_front_buffer_rendering(intel); + for (i = 0; i < BUFFER_COUNT; i++) { + intel_renderbuffer_unmap(intel, fb->Attachment[i].Renderbuffer); + } } /** @@ -302,9 +263,10 @@ intelSpanRenderStart(struct gl_context * ctx) } } - intel_map_unmap_framebuffer(intel, ctx->DrawBuffer, GL_TRUE); - if (ctx->ReadBuffer != ctx->DrawBuffer) - intel_map_unmap_framebuffer(intel, ctx->ReadBuffer, GL_TRUE); + intel_framebuffer_map(intel, ctx->DrawBuffer); + if (ctx->ReadBuffer != ctx->DrawBuffer) { + intel_framebuffer_map(intel, ctx->ReadBuffer); + } } /** @@ -326,9 +288,10 @@ intelSpanRenderFinish(struct gl_context * ctx) } } - intel_map_unmap_framebuffer(intel, ctx->DrawBuffer, GL_FALSE); - if (ctx->ReadBuffer != ctx->DrawBuffer) - intel_map_unmap_framebuffer(intel, ctx->ReadBuffer, GL_FALSE); + intel_framebuffer_unmap(intel, ctx->DrawBuffer); + if (ctx->ReadBuffer != ctx->DrawBuffer) { + intel_framebuffer_unmap(intel, ctx->ReadBuffer); + } } |