summaryrefslogtreecommitdiffstats
path: root/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
diff options
context:
space:
mode:
authorAlexander von Gluck IV <[email protected]>2013-10-03 01:22:48 +0000
committerAlexander von Gluck IV <[email protected]>2013-10-04 18:20:09 -0500
commit8730236d1a900c9512a9ef92c08034f0223bcf92 (patch)
tree9d4ec570b0604811cc4431f0e0f5cab292939021 /src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
parentc9f1217e1f2c309cfd8770940773f1f35582a795 (diff)
haiku: Add first Haiku renderer (softpipe)
* This shared library gets parsed by the system as a system "add-on"
Diffstat (limited to 'src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp')
-rw-r--r--src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp b/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
new file mode 100644
index 00000000000..48af2c57495
--- /dev/null
+++ b/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2012-2013, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Artur Wyszynski, [email protected]
+ * Alexander von Gluck IV, [email protected]
+ */
+
+
+#include "GalliumFramebuffer.h"
+
+extern "C" {
+#include "main/context.h"
+#include "main/framebuffer.h"
+#include "main/renderbuffer.h"
+#include "pipe/p_format.h"
+}
+
+
+#define TRACE_FRAMEBUFFER
+#ifdef TRACE_FRAEMBUFFER
+# define TRACE(x...) printf("GalliumFramebuffer: " x)
+# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
+#else
+# define TRACE(x...)
+# define CALLED()
+#endif
+#define ERROR(x...) printf("GalliumFramebuffer: " x)
+
+
+static boolean
+hgl_framebuffer_flush_front(struct st_context_iface *stctx,
+ struct st_framebuffer_iface* stfb, enum st_attachment_type statt)
+{
+ CALLED();
+ // TODO: I have *NO* idea how we are going to access this data...
+
+ #if 0
+ struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
+ pipe_mutex_lock(stwfb->fb->mutex);
+
+ struct pipe_resource* resource = textures[statt];
+ if (resource)
+ stw_framebuffer_present_locked(...);
+ #endif
+
+ return TRUE;
+}
+
+
+static boolean
+hgl_framebuffer_validate(struct st_context_iface* stctx,
+ struct st_framebuffer_iface* stfb,
+ const enum st_attachment_type* statts, unsigned count,
+ struct pipe_resource** out)
+{
+ CALLED();
+
+ return TRUE;
+}
+
+
+GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual,
+ void* privateContext)
+ :
+ fBuffer(NULL)
+{
+ CALLED();
+ fBuffer = CALLOC_STRUCT(st_framebuffer_iface);
+ if (!fBuffer) {
+ ERROR("%s: Couldn't calloc framebuffer!\n", __func__);
+ return;
+ }
+ fBuffer->visual = visual;
+ fBuffer->flush_front = hgl_framebuffer_flush_front;
+ fBuffer->validate = hgl_framebuffer_validate;
+ fBuffer->st_manager_private = privateContext;
+
+ pipe_mutex_init(fMutex);
+}
+
+
+GalliumFramebuffer::~GalliumFramebuffer()
+{
+ CALLED();
+ // We lock and unlock to try and make sure we wait for anything
+ // using the framebuffer to finish
+ Lock();
+ if (!fBuffer) {
+ ERROR("%s: Strange, no Gallium Framebuffer to free?\n", __func__);
+ return;
+ }
+ FREE(fBuffer);
+ Unlock();
+
+ pipe_mutex_destroy(fMutex);
+}
+
+
+status_t
+GalliumFramebuffer::Lock()
+{
+ CALLED();
+ pipe_mutex_lock(fMutex);
+ return B_OK;
+}
+
+
+status_t
+GalliumFramebuffer::Unlock()
+{
+ CALLED();
+ pipe_mutex_unlock(fMutex);
+ return B_OK;
+}