gallium/state_tracker: Rewrite Haiku's state tracker
[mesa.git] / src / gallium / winsys / sw / hgl / hgl_sw_winsys.c
index 8e8413bbb972ba22895a27f3442f434bad90c7a0..a71d2a767913d7c98acb39c3628e94ba3139c3e2 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
@@ -25,6 +25,7 @@
  *
  **************************************************************************/
 
+#include <stdio.h>
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_defines.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;
@@ -75,7 +86,7 @@ hgl_winsys_is_displaytarget_format_supported(struct sw_winsys* winsys,
        unsigned textureUsage, enum pipe_format format)
 {
        // TODO STUB
-       return true;
+       return TRUE;
 }
 
 static color_space
@@ -85,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;
        }
@@ -101,6 +112,8 @@ hgl_winsys_displaytarget_create(struct sw_winsys* winsys,
                = 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;
@@ -193,6 +206,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;
 }