android: nv50/ir: Add nv50_ir_prog_info_out serialize and deserialize
[mesa.git] / src / gallium / winsys / sw / hgl / hgl_sw_winsys.c
index b09584c39a4b36b2b4e7711782e8a9ff04a6b5b5..bcbaf9cabe5cf5d35e999001d8e49b4a335ee257 100644 (file)
@@ -1,7 +1,7 @@
 /**************************************************************************
  *
  * Copyright 2009 Artur Wyszynski <harakash@gmail.com>
- * Copyright 2013 Alexander von Gluck IV <kallisti5@unixzen.com>
+ * Copyright 2013-2014 Alexander von Gluck IV <kallisti5@unixzen.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the
  *
  **************************************************************************/
 
+#include <stdio.h>
 
 #include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
 #include "pipe/p_format.h"
 #include "util/u_inlines.h"
-#include "util/u_format.h"
+#include "util/format/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "frontend/api.h"
+#include "frontend/sw_winsys.h"
 
+#include "bitmap_wrapper.h"
 #include "hgl_sw_winsys.h"
 
 
+#ifdef DEBUG
+#   define TRACE(x...) printf("hgl:winsys: " x)
+#   define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
+#else
+#   define TRACE(x...)
+#   define CALLED()
+#endif
+#define ERROR(x...) printf("hgl:winsys: " x)
+
+
+struct haiku_displaytarget
+{
+       enum pipe_format format;
+       color_space colorSpace;
+
+       unsigned width;
+       unsigned height;
+       unsigned stride;
+
+       unsigned size;
+
+       void* data;
+};
+
+
 // Cast
-static INLINE struct haiku_displaytarget*
+static inline struct haiku_displaytarget*
 hgl_sw_displaytarget(struct sw_displaytarget* target)
 {
        return (struct haiku_displaytarget *)target;
@@ -51,7 +81,7 @@ hgl_winsys_destroy(struct sw_winsys* winsys)
 }
 
 
-static boolean
+static bool
 hgl_winsys_is_displaytarget_format_supported(struct sw_winsys* winsys,
        unsigned textureUsage, enum pipe_format format)
 {
@@ -66,8 +96,8 @@ hgl_winsys_convert_cs(enum pipe_format format)
        switch(format) {
                case PIPE_FORMAT_B5G6R5_UNORM:
                        return B_CMAP8;
-               case PIPE_FORMAT_A8R8G8B8_UNORM:
-               case PIPE_FORMAT_X8R8G8B8_UNORM:
+               case PIPE_FORMAT_A8B8G8R8_UNORM:
+               case PIPE_FORMAT_X8B8G8R8_UNORM:
                default:
                        return B_RGB32;
        }
@@ -76,12 +106,15 @@ hgl_winsys_convert_cs(enum pipe_format format)
 static struct sw_displaytarget*
 hgl_winsys_displaytarget_create(struct sw_winsys* winsys,
        unsigned textureUsage, enum pipe_format format, unsigned width,
-       unsigned height, unsigned alignment, unsigned* stride)
+       unsigned height, unsigned alignment, const void *front_private,
+       unsigned* stride)
 {
        struct haiku_displaytarget* haikuDisplayTarget
                = CALLOC_STRUCT(haiku_displaytarget);
        assert(haikuDisplayTarget);
 
+       TRACE("%s: %d x %d\n", __func__, width, height);
+
        haikuDisplayTarget->colorSpace = hgl_winsys_convert_cs(format);
        haikuDisplayTarget->format = format;
        haikuDisplayTarget->width = width;
@@ -131,11 +164,11 @@ hgl_winsys_displaytarget_from_handle(struct sw_winsys* winsys,
 }
 
 
-static boolean
+static bool
 hgl_winsys_displaytarget_get_handle(struct sw_winsys* winsys,
        struct sw_displaytarget* displayTarget, struct winsys_handle* whandle)
 {
-       return FALSE;
+       return false;
 }
 
 
@@ -160,7 +193,8 @@ hgl_winsys_displaytarget_unmap(struct sw_winsys* winsys,
 
 static void
 hgl_winsys_displaytarget_display(struct sw_winsys* winsys,
-       struct sw_displaytarget* displayTarget, void* contextPrivate)
+       struct sw_displaytarget* displayTarget, void* contextPrivate,
+       struct pipe_box *box)
 {
        assert(contextPrivate);
 
@@ -173,6 +207,9 @@ hgl_winsys_displaytarget_display(struct sw_winsys* winsys,
                haikuDisplayTarget->size, haikuDisplayTarget->stride,
                haikuDisplayTarget->colorSpace);
 
+       // Dump the rendered bitmap to disk for debugging
+       //dump_bitmap(bitmap);
+
        return;
 }