diff options
author | Brian Paul <[email protected]> | 2012-01-16 13:05:49 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-01-24 14:12:35 -0700 |
commit | bde356a1580f52cae0aaca020a33a6437083a450 (patch) | |
tree | a240fcdf0dfab7ddad5e385e2085fe39b89dbfb6 /src | |
parent | 1839a7fc9faae81d32ffc0cdc908b933f4524e28 (diff) |
swrast: move some renderbuffer functions to s_renderbuffer.c
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/swrast/s_renderbuffer.c | 121 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 121 |
2 files changed, 121 insertions, 121 deletions
diff --git a/src/mesa/swrast/s_renderbuffer.c b/src/mesa/swrast/s_renderbuffer.c index 378e3a7e39a..501b4698c8e 100644 --- a/src/mesa/swrast/s_renderbuffer.c +++ b/src/mesa/swrast/s_renderbuffer.c @@ -552,3 +552,124 @@ _swrast_add_soft_renderbuffers(struct gl_framebuffer *fb, } #endif } + + + +static void +map_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + gl_buffer_index buffer) +{ + struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; + struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + + if (texObj) { + const GLuint level = fb->Attachment[buffer].TextureLevel; + const GLuint face = fb->Attachment[buffer].CubeMapFace; + struct gl_texture_image *texImage = texObj->Image[face][level]; + if (texImage) { + struct swrast_texture_image *swImage + = swrast_texture_image(texImage); + + /* XXX we'll eventually call _swrast_map_teximage() here */ + swImage->Map = swImage->Buffer; + if (srb) { + srb->Map = swImage->Buffer; + srb->RowStride = swImage->RowStride * + _mesa_get_format_bytes(swImage->Base.TexFormat); + } + } + } + else if (rb) { + /* Map ordinary renderbuffer */ + ctx->Driver.MapRenderbuffer(ctx, rb, + 0, 0, rb->Width, rb->Height, + GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, + &srb->Map, &srb->RowStride); + assert(srb->Map); + } +} + + +static void +unmap_attachment(struct gl_context *ctx, + struct gl_framebuffer *fb, + gl_buffer_index buffer) +{ + struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; + struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + + if (texObj) { + const GLuint level = fb->Attachment[buffer].TextureLevel; + const GLuint face = fb->Attachment[buffer].CubeMapFace; + struct gl_texture_image *texImage = texObj->Image[face][level]; + if (texImage) { + + /* XXX we'll eventually call _swrast_unmap_teximage() here */ + } + } + else if (rb) { + /* unmap ordinary renderbuffer */ + ctx->Driver.UnmapRenderbuffer(ctx, rb); + } + + srb->Map = NULL; +} + + +/** + * Map the renderbuffers we'll use for tri/line/point rendering. + */ +void +_swrast_map_renderbuffers(struct gl_context *ctx) +{ + struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_renderbuffer *depthRb, *stencilRb; + GLuint buf; + + depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; + if (depthRb) { + /* map depth buffer */ + map_attachment(ctx, fb, BUFFER_DEPTH); + } + + stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; + if (stencilRb && stencilRb != depthRb) { + /* map stencil buffer */ + map_attachment(ctx, fb, BUFFER_STENCIL); + } + + for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) { + map_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]); + } +} + + +/** + * Unmap renderbuffers after rendering. + */ +void +_swrast_unmap_renderbuffers(struct gl_context *ctx) +{ + struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_renderbuffer *depthRb, *stencilRb; + GLuint buf; + + depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; + if (depthRb) { + /* map depth buffer */ + unmap_attachment(ctx, fb, BUFFER_DEPTH); + } + + stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; + if (stencilRb && stencilRb != depthRb) { + /* map stencil buffer */ + unmap_attachment(ctx, fb, BUFFER_STENCIL); + } + + for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) { + unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]); + } +} diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 0a87b7327e0..72d30930001 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -315,127 +315,6 @@ _swrast_unmap_textures(struct gl_context *ctx) } -static void -map_attachment(struct gl_context *ctx, - struct gl_framebuffer *fb, - gl_buffer_index buffer) -{ - struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; - struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - - if (texObj) { - const GLuint level = fb->Attachment[buffer].TextureLevel; - const GLuint face = fb->Attachment[buffer].CubeMapFace; - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - struct swrast_texture_image *swImage - = swrast_texture_image(texImage); - - /* XXX we'll eventually call _swrast_map_teximage() here */ - swImage->Map = swImage->Buffer; - if (srb) { - srb->Map = swImage->Buffer; - srb->RowStride = swImage->RowStride * - _mesa_get_format_bytes(swImage->Base.TexFormat); - } - } - } - else if (rb) { - /* Map ordinary renderbuffer */ - ctx->Driver.MapRenderbuffer(ctx, rb, - 0, 0, rb->Width, rb->Height, - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, - &srb->Map, &srb->RowStride); - assert(srb->Map); - } -} - - -static void -unmap_attachment(struct gl_context *ctx, - struct gl_framebuffer *fb, - gl_buffer_index buffer) -{ - struct gl_texture_object *texObj = fb->Attachment[buffer].Texture; - struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer; - struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); - - if (texObj) { - const GLuint level = fb->Attachment[buffer].TextureLevel; - const GLuint face = fb->Attachment[buffer].CubeMapFace; - struct gl_texture_image *texImage = texObj->Image[face][level]; - if (texImage) { - - /* XXX we'll eventually call _swrast_unmap_teximage() here */ - } - } - else if (rb) { - /* unmap ordinary renderbuffer */ - ctx->Driver.UnmapRenderbuffer(ctx, rb); - } - - srb->Map = NULL; -} - - -/** - * Map the renderbuffers we'll use for tri/line/point rendering. - */ -void -_swrast_map_renderbuffers(struct gl_context *ctx) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *depthRb, *stencilRb; - GLuint buf; - - depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - if (depthRb) { - /* map depth buffer */ - map_attachment(ctx, fb, BUFFER_DEPTH); - } - - stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - if (stencilRb && stencilRb != depthRb) { - /* map stencil buffer */ - map_attachment(ctx, fb, BUFFER_STENCIL); - } - - for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) { - map_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]); - } -} - - -/** - * Unmap renderbuffers after rendering. - */ -void -_swrast_unmap_renderbuffers(struct gl_context *ctx) -{ - struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *depthRb, *stencilRb; - GLuint buf; - - depthRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer; - if (depthRb) { - /* map depth buffer */ - unmap_attachment(ctx, fb, BUFFER_DEPTH); - } - - stencilRb = fb->Attachment[BUFFER_STENCIL].Renderbuffer; - if (stencilRb && stencilRb != depthRb) { - /* map stencil buffer */ - unmap_attachment(ctx, fb, BUFFER_STENCIL); - } - - for (buf = 0; buf < fb->_NumColorDrawBuffers; buf++) { - unmap_attachment(ctx, fb, fb->_ColorDrawBufferIndexes[buf]); - } -} - - - /** * Called via ctx->Driver.AllocTextureStorage() * Just have to allocate memory for the texture images. |