1/* 2 * Copyright 2012, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Artur Wyszynski, harakash@gmail.com 7 * Alexander von Gluck IV, kallisti5@unixzen.com 8 */ 9 10 11#include "GalliumFramebuffer.h" 12 13extern "C" { 14#include "main/context.h" 15#include "main/framebuffer.h" 16#include "main/renderbuffer.h" 17#include "pipe/p_format.h" 18} 19 20 21#define TRACE_FRAMEBUFFER 22#ifdef TRACE_FRAEMBUFFER 23# define TRACE(x...) printf("GalliumFramebuffer: " x) 24# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__) 25#else 26# define TRACE(x...) 27# define CALLED() 28#endif 29#define ERROR(x...) printf("GalliumFramebuffer: " x) 30 31 32static boolean 33hgl_framebuffer_flush_front(struct st_framebuffer_iface* stfb, 34 enum st_attachment_type statt) 35{ 36 CALLED(); 37 // TODO: I have *NO* idea how we are going to access this data... 38 39 #if 0 40 struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); 41 pipe_mutex_lock(stwfb->fb->mutex); 42 43 struct pipe_resource* resource = textures[statt]; 44 if (resource) 45 stw_framebuffer_present_locked(...); 46 #endif 47 48 return TRUE; 49} 50 51 52static boolean 53hgl_framebuffer_validate(struct st_framebuffer_iface* stfb, 54 const enum st_attachment_type* statts, unsigned count, 55 struct pipe_resource** out) 56{ 57 CALLED(); 58 59 return TRUE; 60} 61 62 63GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual) 64 : 65 fBuffer(NULL) 66{ 67 CALLED(); 68 fBuffer = CALLOC_STRUCT(st_framebuffer_iface); 69 if (!fBuffer) { 70 ERROR("%s: Couldn't calloc framebuffer!\n", __func__); 71 return; 72 } 73 fBuffer->visual = visual; 74 fBuffer->flush_front = hgl_framebuffer_flush_front; 75 fBuffer->validate = hgl_framebuffer_validate; 76 77 pipe_mutex_init(fMutex); 78} 79 80 81GalliumFramebuffer::~GalliumFramebuffer() 82{ 83 CALLED(); 84 // We lock and unlock to try and make sure we wait for anything 85 // using the framebuffer to finish 86 Lock(); 87 if (!fBuffer) { 88 ERROR("%s: Strange, no Gallium Framebuffer to free?\n", __func__); 89 return; 90 } 91 FREE(fBuffer); 92 Unlock(); 93 94 pipe_mutex_destroy(fMutex); 95} 96 97 98status_t 99GalliumFramebuffer::Lock() 100{ 101 CALLED(); 102 pipe_mutex_lock(fMutex); 103 return B_OK; 104} 105 106 107status_t 108GalliumFramebuffer::Unlock() 109{ 110 CALLED(); 111 pipe_mutex_unlock(fMutex); 112 return B_OK; 113} 114