Lines Matching refs:fb
57 compute_depth_max(struct gl_framebuffer *fb) in compute_depth_max() argument
59 if (fb->Visual.depthBits == 0) { in compute_depth_max()
64 fb->_DepthMax = (1 << 16) - 1; in compute_depth_max()
66 else if (fb->Visual.depthBits < 32) { in compute_depth_max()
67 fb->_DepthMax = (1 << fb->Visual.depthBits) - 1; in compute_depth_max()
73 fb->_DepthMax = 0xffffffff; in compute_depth_max()
75 fb->_DepthMaxF = (GLfloat) fb->_DepthMax; in compute_depth_max()
78 fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF; in compute_depth_max()
91 struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); in _mesa_create_framebuffer() local
93 if (fb) { in _mesa_create_framebuffer()
94 _mesa_initialize_window_framebuffer(fb, visual); in _mesa_create_framebuffer()
96 return fb; in _mesa_create_framebuffer()
110 struct gl_framebuffer *fb; in _mesa_new_framebuffer() local
113 fb = CALLOC_STRUCT(gl_framebuffer); in _mesa_new_framebuffer()
114 if (fb) { in _mesa_new_framebuffer()
115 _mesa_initialize_user_framebuffer(fb, name); in _mesa_new_framebuffer()
117 return fb; in _mesa_new_framebuffer()
127 _mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, in _mesa_initialize_window_framebuffer() argument
130 assert(fb); in _mesa_initialize_window_framebuffer()
133 memset(fb, 0, sizeof(struct gl_framebuffer)); in _mesa_initialize_window_framebuffer()
135 simple_mtx_init(&fb->Mutex, mtx_plain); in _mesa_initialize_window_framebuffer()
137 fb->RefCount = 1; in _mesa_initialize_window_framebuffer()
140 fb->Visual = *visual; in _mesa_initialize_window_framebuffer()
144 fb->_NumColorDrawBuffers = 1; in _mesa_initialize_window_framebuffer()
145 fb->ColorDrawBuffer[0] = GL_BACK; in _mesa_initialize_window_framebuffer()
146 fb->_ColorDrawBufferIndexes[0] = BUFFER_BACK_LEFT; in _mesa_initialize_window_framebuffer()
147 fb->ColorReadBuffer = GL_BACK; in _mesa_initialize_window_framebuffer()
148 fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT; in _mesa_initialize_window_framebuffer()
151 fb->_NumColorDrawBuffers = 1; in _mesa_initialize_window_framebuffer()
152 fb->ColorDrawBuffer[0] = GL_FRONT; in _mesa_initialize_window_framebuffer()
153 fb->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT; in _mesa_initialize_window_framebuffer()
154 fb->ColorReadBuffer = GL_FRONT; in _mesa_initialize_window_framebuffer()
155 fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT; in _mesa_initialize_window_framebuffer()
158 fb->Delete = _mesa_destroy_framebuffer; in _mesa_initialize_window_framebuffer()
159 fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; in _mesa_initialize_window_framebuffer()
160 fb->_AllColorBuffersFixedPoint = !visual->floatMode; in _mesa_initialize_window_framebuffer()
161 fb->_HasSNormOrFloatColorBuffer = visual->floatMode; in _mesa_initialize_window_framebuffer()
162 fb->_HasAttachments = true; in _mesa_initialize_window_framebuffer()
163 fb->FlipY = true; in _mesa_initialize_window_framebuffer()
165 fb->SampleLocationTable = NULL; in _mesa_initialize_window_framebuffer()
166 fb->ProgrammableSampleLocations = 0; in _mesa_initialize_window_framebuffer()
167 fb->SampleLocationPixelGrid = 0; in _mesa_initialize_window_framebuffer()
169 compute_depth_max(fb); in _mesa_initialize_window_framebuffer()
178 _mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name) in _mesa_initialize_user_framebuffer() argument
180 assert(fb); in _mesa_initialize_user_framebuffer()
183 memset(fb, 0, sizeof(struct gl_framebuffer)); in _mesa_initialize_user_framebuffer()
185 fb->Name = name; in _mesa_initialize_user_framebuffer()
186 fb->RefCount = 1; in _mesa_initialize_user_framebuffer()
187 fb->_NumColorDrawBuffers = 1; in _mesa_initialize_user_framebuffer()
188 fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT; in _mesa_initialize_user_framebuffer()
189 fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0; in _mesa_initialize_user_framebuffer()
190 fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT; in _mesa_initialize_user_framebuffer()
191 fb->_ColorReadBufferIndex = BUFFER_COLOR0; in _mesa_initialize_user_framebuffer()
192 fb->SampleLocationTable = NULL; in _mesa_initialize_user_framebuffer()
193 fb->ProgrammableSampleLocations = 0; in _mesa_initialize_user_framebuffer()
194 fb->SampleLocationPixelGrid = 0; in _mesa_initialize_user_framebuffer()
195 fb->Delete = _mesa_destroy_framebuffer; in _mesa_initialize_user_framebuffer()
196 simple_mtx_init(&fb->Mutex, mtx_plain); in _mesa_initialize_user_framebuffer()
205 _mesa_destroy_framebuffer(struct gl_framebuffer *fb) in _mesa_destroy_framebuffer() argument
207 if (fb) { in _mesa_destroy_framebuffer()
208 _mesa_free_framebuffer_data(fb); in _mesa_destroy_framebuffer()
209 free(fb->Label); in _mesa_destroy_framebuffer()
210 free(fb); in _mesa_destroy_framebuffer()
220 _mesa_free_framebuffer_data(struct gl_framebuffer *fb) in _mesa_free_framebuffer_data() argument
222 assert(fb); in _mesa_free_framebuffer_data()
223 assert(fb->RefCount == 0); in _mesa_free_framebuffer_data()
225 simple_mtx_destroy(&fb->Mutex); in _mesa_free_framebuffer_data()
228 struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; in _mesa_free_framebuffer_data()
240 free(fb->SampleLocationTable); in _mesa_free_framebuffer_data()
241 fb->SampleLocationTable = NULL; in _mesa_free_framebuffer_data()
252 struct gl_framebuffer *fb) in _mesa_reference_framebuffer_() argument
271 if (fb) { in _mesa_reference_framebuffer_()
272 simple_mtx_lock(&fb->Mutex); in _mesa_reference_framebuffer_()
273 fb->RefCount++; in _mesa_reference_framebuffer_()
274 simple_mtx_unlock(&fb->Mutex); in _mesa_reference_framebuffer_()
275 *ptr = fb; in _mesa_reference_framebuffer_()
290 _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb, in _mesa_resize_framebuffer() argument
298 assert(_mesa_is_winsys_fbo(fb)); in _mesa_resize_framebuffer()
301 struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; in _mesa_resize_framebuffer()
318 fb->Width = width; in _mesa_resize_framebuffer()
319 fb->Height = height; in _mesa_resize_framebuffer()
436 struct gl_framebuffer *fb) in _mesa_update_framebuffer_visual() argument
438 memset(&fb->Visual, 0, sizeof(fb->Visual)); in _mesa_update_framebuffer_visual()
442 if (fb->Attachment[i].Renderbuffer) { in _mesa_update_framebuffer_visual()
443 const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; in _mesa_update_framebuffer_visual()
451 fb->Visual.samples = rb->NumSamples; in _mesa_update_framebuffer_visual()
452 fb->Visual.sampleBuffers = rb->NumSamples > 0 ? 1 : 0; in _mesa_update_framebuffer_visual()
455 fb->Visual.redBits = _mesa_get_format_bits(fmt, GL_RED_BITS); in _mesa_update_framebuffer_visual()
456 fb->Visual.greenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); in _mesa_update_framebuffer_visual()
457 fb->Visual.blueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); in _mesa_update_framebuffer_visual()
458 fb->Visual.alphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); in _mesa_update_framebuffer_visual()
459 fb->Visual.rgbBits = fb->Visual.redBits in _mesa_update_framebuffer_visual()
460 + fb->Visual.greenBits + fb->Visual.blueBits; in _mesa_update_framebuffer_visual()
462 fb->Visual.sRGBCapable = ctx->Extensions.EXT_sRGB; in _mesa_update_framebuffer_visual()
468 fb->Visual.floatMode = GL_FALSE; in _mesa_update_framebuffer_visual()
470 if (fb->Attachment[i].Renderbuffer) { in _mesa_update_framebuffer_visual()
471 const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer; in _mesa_update_framebuffer_visual()
475 fb->Visual.floatMode = GL_TRUE; in _mesa_update_framebuffer_visual()
481 if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) { in _mesa_update_framebuffer_visual()
483 fb->Attachment[BUFFER_DEPTH].Renderbuffer; in _mesa_update_framebuffer_visual()
485 fb->Visual.depthBits = _mesa_get_format_bits(fmt, GL_DEPTH_BITS); in _mesa_update_framebuffer_visual()
488 if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) { in _mesa_update_framebuffer_visual()
490 fb->Attachment[BUFFER_STENCIL].Renderbuffer; in _mesa_update_framebuffer_visual()
492 fb->Visual.stencilBits = _mesa_get_format_bits(fmt, GL_STENCIL_BITS); in _mesa_update_framebuffer_visual()
495 if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) { in _mesa_update_framebuffer_visual()
497 fb->Attachment[BUFFER_ACCUM].Renderbuffer; in _mesa_update_framebuffer_visual()
499 fb->Visual.accumRedBits = _mesa_get_format_bits(fmt, GL_RED_BITS); in _mesa_update_framebuffer_visual()
500 fb->Visual.accumGreenBits = _mesa_get_format_bits(fmt, GL_GREEN_BITS); in _mesa_update_framebuffer_visual()
501 fb->Visual.accumBlueBits = _mesa_get_format_bits(fmt, GL_BLUE_BITS); in _mesa_update_framebuffer_visual()
502 fb->Visual.accumAlphaBits = _mesa_get_format_bits(fmt, GL_ALPHA_BITS); in _mesa_update_framebuffer_visual()
505 compute_depth_max(fb); in _mesa_update_framebuffer_visual()
561 update_color_draw_buffers(struct gl_framebuffer *fb) in update_color_draw_buffers() argument
566 fb->_ColorDrawBuffers[0] = NULL; in update_color_draw_buffers()
568 for (output = 0; output < fb->_NumColorDrawBuffers; output++) { in update_color_draw_buffers()
569 gl_buffer_index buf = fb->_ColorDrawBufferIndexes[output]; in update_color_draw_buffers()
571 fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer; in update_color_draw_buffers()
574 fb->_ColorDrawBuffers[output] = NULL; in update_color_draw_buffers()
585 update_color_read_buffer(struct gl_framebuffer *fb) in update_color_read_buffer() argument
587 if (fb->_ColorReadBufferIndex == BUFFER_NONE || in update_color_read_buffer()
588 fb->DeletePending || in update_color_read_buffer()
589 fb->Width == 0 || in update_color_read_buffer()
590 fb->Height == 0) { in update_color_read_buffer()
591 fb->_ColorReadBuffer = NULL; /* legal! */ in update_color_read_buffer()
594 assert(fb->_ColorReadBufferIndex >= 0); in update_color_read_buffer()
595 assert(fb->_ColorReadBufferIndex < BUFFER_COUNT); in update_color_read_buffer()
596 fb->_ColorReadBuffer in update_color_read_buffer()
597 = fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer; in update_color_read_buffer()
617 update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) in update_framebuffer() argument
619 if (_mesa_is_winsys_fbo(fb)) { in update_framebuffer()
624 if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) { in update_framebuffer()
625 _mesa_drawbuffers(ctx, fb, ctx->Const.MaxDrawBuffers, in update_framebuffer()
630 if (fb == ctx->DrawBuffer) { in update_framebuffer()
639 if (fb->_Status != GL_FRAMEBUFFER_COMPLETE) { in update_framebuffer()
640 _mesa_test_framebuffer_completeness(ctx, fb); in update_framebuffer()
649 update_color_draw_buffers(fb); in update_framebuffer()
650 update_color_read_buffer(fb); in update_framebuffer()
652 compute_depth_max(fb); in update_framebuffer()
685 struct gl_framebuffer *fb, in renderbuffer_exists() argument
689 const struct gl_renderbuffer_attachment *att = fb->Attachment; in renderbuffer_exists()
692 if (fb->_Status == 0) { in renderbuffer_exists()
693 _mesa_test_framebuffer_completeness(ctx, fb); in renderbuffer_exists()
696 if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) { in renderbuffer_exists()
728 const struct gl_renderbuffer *readBuf = fb->_ColorReadBuffer; in renderbuffer_exists()
813 struct gl_framebuffer *fb, in _mesa_get_color_read_format() argument
819 if (fb == NULL) in _mesa_get_color_read_format()
820 fb = ctx->ReadBuffer; in _mesa_get_color_read_format()
822 if (!fb || !fb->_ColorReadBuffer) { in _mesa_get_color_read_format()
852 const mesa_format format = fb->_ColorReadBuffer->Format; in _mesa_get_color_read_format()
908 struct gl_framebuffer *fb, in _mesa_get_color_read_type() argument
914 if (fb == NULL) in _mesa_get_color_read_type()
915 fb = ctx->ReadBuffer; in _mesa_get_color_read_type()
917 if (!fb || !fb->_ColorReadBuffer) { in _mesa_get_color_read_type()
927 const mesa_format format = fb->_ColorReadBuffer->Format; in _mesa_get_color_read_type()
962 _mesa_print_framebuffer(const struct gl_framebuffer *fb) in _mesa_print_framebuffer() argument
964 fprintf(stderr, "Mesa Framebuffer %u at %p\n", fb->Name, (void *) fb); in _mesa_print_framebuffer()
965 fprintf(stderr, " Size: %u x %u Status: %s\n", fb->Width, fb->Height, in _mesa_print_framebuffer()
966 _mesa_enum_to_string(fb->_Status)); in _mesa_print_framebuffer()
970 const struct gl_renderbuffer_attachment *att = &fb->Attachment[i]; in _mesa_print_framebuffer()
995 _mesa_is_front_buffer_reading(const struct gl_framebuffer *fb) in _mesa_is_front_buffer_reading() argument
997 if (!fb || _mesa_is_user_fbo(fb)) in _mesa_is_front_buffer_reading()
1000 return fb->_ColorReadBufferIndex == BUFFER_FRONT_LEFT; in _mesa_is_front_buffer_reading()
1004 _mesa_is_front_buffer_drawing(const struct gl_framebuffer *fb) in _mesa_is_front_buffer_drawing() argument
1006 if (!fb || _mesa_is_user_fbo(fb)) in _mesa_is_front_buffer_drawing()
1009 return (fb->_NumColorDrawBuffers >= 1 && in _mesa_is_front_buffer_drawing()
1010 fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT); in _mesa_is_front_buffer_drawing()