if env['platform'] == 'haiku':
SConscript([
+ 'state_trackers/hgl/SConscript',
'targets/haiku-softpipe/SConscript',
])
--- /dev/null
+#######################################################################
+# SConscript for Haiku state_tracker
+
+Import('*')
+
+env = env.Clone()
+
+env.Append(CPPPATH = [
+ '#/src',
+ '#/src/mapi',
+ '#/src/mesa',
+])
+
+sources = [
+ 'hgl.c',
+ 'bitmap_wrapper.cpp',
+]
+
+st_haiku = env.ConvenienceLibrary(
+ target = 'st_haiku',
+ source = sources
+)
+Export('st_haiku')
*/
-#include "GalliumFramebuffer.h"
-
-extern "C" {
#include "main/context.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "pipe/p_format.h"
-#include "state_tracker/st_manager.h"
+#include "util/u_atomic.h"
#include "util/u_memory.h"
-}
-#include "GalliumContext.h"
+#include "hgl_context.h"
#ifdef DEBUG
-# define TRACE(x...) printf("GalliumFramebuffer: " x)
+# define TRACE(x...) printf("hgl:state_tracker: " x)
# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
#else
# define TRACE(x...)
# define CALLED()
#endif
-#define ERROR(x...) printf("GalliumFramebuffer: " x)
+#define ERROR(x...) printf("hgl:state_tracker: " x)
static boolean
-hgl_framebuffer_flush_front(struct st_context_iface *stctx,
+hgl_st_framebuffer_flush_front(struct st_context_iface *stctx,
struct st_framebuffer_iface* stfb, enum st_attachment_type statt)
{
CALLED();
- hgl_context* context = (hgl_context*)stfb->st_manager_private;
+ struct hgl_context* context = (struct hgl_context*)stfb->st_manager_private;
if (!context) {
ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
}
+/**
+ * Called by the st manager to validate the framebuffer (allocate
+ * its resources).
+ */
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)
+hgl_st_framebuffer_validate(struct st_context_iface *stctx,
+ struct st_framebuffer_iface *stfbi, const enum st_attachment_type *statts,
+ unsigned count, struct pipe_resource **out)
{
CALLED();
- if (!stfb) {
+ if (!stfbi) {
ERROR("%s: Invalid st framebuffer interface!\n", __func__);
return FALSE;
}
- hgl_context* context = (hgl_context*)stfb->st_manager_private;
+ struct hgl_context* context = (struct hgl_context*)stfbi->st_manager_private;
if (!context) {
ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
if (context->stVisual && context->manager && context->manager->screen) {
TRACE("%s: Updating resources\n", __func__);
- unsigned i;
- for (i = 0; i < count; i++) {
+ for (unsigned i = 0; i < count; i++) {
enum pipe_format format = PIPE_FORMAT_NONE;
unsigned bind = 0;
}
-GalliumFramebuffer::GalliumFramebuffer(struct st_visual* visual,
- void* privateContext)
- :
- fBuffer(NULL)
+/**
+ * Create new framebuffer
+ */
+struct hgl_buffer *
+hgl_create_st_framebuffer(struct hgl_context* context)
{
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);
-}
+ struct hgl_buffer *buffer = CALLOC_STRUCT(hgl_buffer);
-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();
+ assert(context);
+ assert(context->stVisual);
- pipe_mutex_destroy(fMutex);
-}
+ if (buffer) {
+ // Copy context visual into framebuffer
+ memcpy(&buffer->visual, context->stVisual, sizeof(struct st_visual));
+ // calloc our st_framebuffer interface
+ buffer->stfbi = CALLOC_STRUCT(st_framebuffer_iface);
+ if (!buffer->stfbi) {
+ ERROR("%s: Couldn't calloc framebuffer!\n", __func__);
+ return NULL;
+ }
-status_t
-GalliumFramebuffer::Lock()
-{
- CALLED();
- pipe_mutex_lock(fMutex);
- return B_OK;
-}
+ struct st_framebuffer_iface* stfbi = buffer->stfbi;
+ p_atomic_set(&stfbi->stamp, 1);
+ stfbi->flush_front = hgl_st_framebuffer_flush_front;
+ stfbi->validate = hgl_st_framebuffer_validate;
+ stfbi->st_manager_private = (void*)context;
+ stfbi->visual = &buffer->visual;
+ // TODO: Do we need linked list?
+ }
-status_t
-GalliumFramebuffer::Unlock()
-{
- CALLED();
- pipe_mutex_unlock(fMutex);
- return B_OK;
+ return buffer;
}
--- /dev/null
+/*
+ * Copyright 2009-2014, Haiku, Inc. All Rights Reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ * Alexander von Gluck IV, kallisti5@unixzen.com
+ */
+#ifndef HGL_CONTEXT_H
+#define HGL_CONTEXT_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "state_tracker/st_api.h"
+#include "state_tracker/st_manager.h"
+#include "pipe/p_compiler.h"
+#include "pipe/p_screen.h"
+#include "postprocess/filters.h"
+#include "os/os_thread.h"
+
+#include "bitmap_wrapper.h"
+#ifdef __cplusplus
+}
+#endif
+
+
+#define CONTEXT_MAX 32
+
+typedef int64 context_id;
+
+
+struct hgl_buffer
+{
+ struct st_framebuffer_iface *stfbi;
+ struct st_visual* visual;
+
+ unsigned width;
+ unsigned height;
+
+ struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
+
+ void *map;
+
+ //struct hgl_buffer *next; /**< next in linked list */
+};
+
+
+struct hgl_context
+{
+ struct st_api* api;
+ // State Tracker API
+ struct st_manager* manager;
+ // State Tracker Manager
+ struct st_context_iface* st;
+ // State Tracker Interface Object
+ struct st_visual* stVisual;
+ // State Tracker Visual
+
+ struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
+
+ // Post processing
+ struct pp_queue_t* postProcess;
+ unsigned int postProcessEnable[PP_FILTERS];
+
+ Bitmap* bitmap;
+ color_space colorSpace;
+
+ pipe_mutex fbMutex;
+
+ struct hgl_buffer* draw;
+ struct hgl_buffer* read;
+};
+
+
+struct hgl_buffer* hgl_create_st_framebuffer(struct hgl_context* context);
+
+
+#endif /* HGL_CONTEXT_H */
return -1;
}
- context->draw = new GalliumFramebuffer(context->stVisual, (void*)this);
- context->read = new GalliumFramebuffer(context->stVisual, (void*)this);
+ context->draw = hgl_create_st_framebuffer(context);
+ context->read = hgl_create_st_framebuffer(context);
if (!context->draw || !context->read) {
ERROR("%s: Problem allocating framebuffer!\n", __func__);
}
// We need to lock and unlock framebuffers before accessing them
- context->draw->Lock();
- context->read->Lock();
- api->make_current(context->api, context->st, context->draw->fBuffer,
- context->read->fBuffer);
- context->draw->Unlock();
- context->read->Unlock();
+ api->make_current(context->api, context->st, context->draw->stfbi,
+ context->read->stfbi);
if (context->textures[ST_ATTACHMENT_BACK_LEFT]
&& context->textures[ST_ATTACHMENT_DEPTH_STENCIL]
}
// TODO: Where did st_notify_swapbuffers go?
- //st_notify_swapbuffers(context->draw->stfb);
+ //st_notify_swapbuffers(context->draw->stfbi);
context->st->flush(context->st, ST_FLUSH_FRONT, NULL);
#include <kernel/image.h>
extern "C" {
-#include "state_tracker/st_api.h"
+//#include "state_tracker/st_api.h"
#include "pipe/p_compiler.h"
#include "pipe/p_screen.h"
#include "postprocess/filters.h"
#include "os/os_thread.h"
+#include "hgl_context.h"
}
-#include "bitmap_wrapper.h"
-#include "GalliumFramebuffer.h"
-
-
-#define CONTEXT_MAX 32
-
-
-typedef int64 context_id;
-struct hgl_context
-{
- struct st_api* api;
- // State Tracker API
- struct st_manager* manager;
- // State Tracker Manager
- struct st_context_iface* st;
- // State Tracker Interface Object
- struct st_visual* stVisual;
- // State Tracker Visual
-
- struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
-
- // Post processing
- struct pp_queue_t* postProcess;
- unsigned int postProcessEnable[PP_FILTERS];
-
- Bitmap* bitmap;
- color_space colorSpace;
+#include "bitmap_wrapper.h"
- GalliumFramebuffer* draw;
- GalliumFramebuffer* read;
-};
class GalliumContext {
+++ /dev/null
-/*
- * Copyright 2012, Haiku, Inc. All Rights Reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- * Alexander von Gluck IV, kallisti5@unixzen.com
- */
-#ifndef GALLIUMFRAMEBUFFER_H
-#define GALLIUMFRAMEBUFFER_H
-
-
-extern "C" {
-#include "os/os_thread.h"
-#include "pipe/p_screen.h"
-#include "state_tracker/st_api.h"
-}
-
-
-class GalliumFramebuffer {
-public:
- GalliumFramebuffer(struct st_visual* visual,
- void* privateContext);
- ~GalliumFramebuffer();
- status_t Lock();
- status_t Unlock();
-
- struct st_framebuffer_iface* fBuffer;
-
-private:
- pipe_mutex fMutex;
-};
-
-
-#endif /* GALLIUMFRAMEBUFFER_H */
env.Prepend(LIBS = [
ws_haiku,
+ st_haiku,
trace,
rbug,
mesautil,
'#/src/mesa/main',
'#/include/HaikuGL',
'#/src/gallium/winsys/sw/hgl',
+ '#/src/gallium/state_trackers/hgl',
'/boot/system/develop/headers/private',
])
softpipe_sources = [
'GalliumContext.cpp',
- 'GalliumFramebuffer.cpp',
'SoftwareRenderer.cpp'
]
'#/src/gallium/include',
'#/src/gallium/auxiliary',
'#/src/gallium/drivers',
+ '#/src/gallium/state_trackers/hgl',
])
ws_haiku = env.ConvenienceLibrary(
target = 'ws_haiku',
source = [
'hgl_sw_winsys.c',
- 'bitmap_wrapper.cpp',
]
)
Export('ws_haiku')
#include <Directory.h>
#include <FindDirectory.h>
#include <Path.h>
-#include <String.h>
+#include <strings.h>
#include "GLDispatcher.h"
#include "GLRendererRoster.h"