Permalink
Browse files

Added 8-bit OpenGL-based video mode to try to speed up palette changes.

Unfortunately, although this offers significant performance improvements in
debug mode, it is roughly equivalent in release mode.
To use it, set SDL_VIDEODRIVER=pb-8bit as an environment variable when you
run your executable.
  • Loading branch information...
1 parent a360c74 commit a78036fb1681079649eac19bb96cabf4d413c78b @jnicholl jnicholl committed Nov 30, 2011
View
Oops, something went wrong.
View
@@ -1,73 +1,73 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SDL12</name>
- <comment></comment>
- <projects>
- <project>TouchControlOverlay</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
- <triggers>full,incremental,</triggers>
- <arguments>
- <dictionary>
- <key>?name?</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.append_environment</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildArguments</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildCommand</key>
- <value>make</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.buildLocation</key>
- <value>${workspace_loc:/SDL12/Simulator}</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.contents</key>
- <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
- <value>false</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
- <value>false</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableFullBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.stopOnError</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
- <value>true</value>
- </dictionary>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
- <triggers>full,incremental,</triggers>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.cdt.core.cnature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
- <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
- <nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
- <nature>org.eclipse.cdt.core.ccnature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>SDL12</name>
+ <comment></comment>
+ <projects>
+ <project>TouchControlOverlay</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildLocation</key>
+ <value>${workspace_loc:/SDL12/Device-Release}</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ </natures>
+</projectDescription>
@@ -411,6 +411,7 @@ extern VideoBootStrap AALIB_bootstrap;
extern VideoBootStrap CACA_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_PLAYBOOK
+extern VideoBootStrap PLAYBOOK_8Bit_bootstrap;
extern VideoBootStrap PLAYBOOK_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_DUMMY
@@ -127,6 +127,7 @@ static VideoBootStrap *bootstrap[] = {
&CACA_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_PLAYBOOK
+ &PLAYBOOK_8Bit_bootstrap,
&PLAYBOOK_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_DUMMY
@@ -0,0 +1,129 @@
+/*
+ * SDL_playbookhw.c
+ *
+ * Created on: Nov 23, 2011
+ * Author: jnicholl
+ */
+
+#include "SDL_config.h"
+
+#include "SDL_playbookhw_c.h"
+#include <errno.h>
+
+int PLAYBOOK_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+ fprintf(stderr, "Allocate HW surface %08x\n", surface);
+ if (surface->hwdata != NULL) {
+ fprintf(stderr, "Surface already has hwdata\n");
+ return -1;
+ }
+
+ surface->hwdata = SDL_malloc(sizeof(struct private_hwdata));
+ if (surface->hwdata == NULL) {
+ SDL_OutOfMemory();
+ return -1;
+ }
+
+ int rc = screen_create_pixmap( &surface->hwdata->pixmap, _priv->screenContext);
+ if (rc) {
+ fprintf(stderr, "Failed to create HW surface: screen_create_pixmap returned %s\n", strerror(errno));
+ goto fail1;
+ }
+
+ int size[2] = {surface->w, surface->h};
+ rc = screen_set_pixmap_property_iv(surface->hwdata->pixmap, SCREEN_PROPERTY_BUFFER_SIZE, size);
+ if (rc) {
+ fprintf(stderr, "Failed to set SCREEN_PROPERTY_BUFFER_SIZE: screen_set_pixmap_property_iv returned %s\n", strerror(errno));
+ goto fail1;
+ }
+
+ int format = SCREEN_FORMAT_RGBA8888;
+ rc = screen_set_pixmap_property_iv(surface->hwdata->pixmap, SCREEN_PROPERTY_FORMAT, &format);
+ if (rc) {
+ fprintf(stderr, "Failed to set SCREEN_PROPERTY_FORMAT: screen_set_pixmap_property_iv returned %s\n", strerror(errno));
+ goto fail1;
+ }
+
+ rc = screen_create_pixmap_buffer(surface->hwdata->pixmap);
+ if (rc) {
+ fprintf(stderr, "Failed to allocate HW surface: screen_create_pixmap_buffer returned %s\n", strerror(errno));
+ goto fail2;
+ }
+
+ surface->flags |= SDL_HWSURFACE;
+ surface->flags |= SDL_PREALLOC;
+
+ return 0;
+
+fail2:
+ screen_destroy_pixmap(surface->hwdata->pixmap);
+fail1:
+ SDL_free(surface->hwdata);
+ surface->hwdata = 0;
+
+ return -1;
+}
+
+void PLAYBOOK_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+ fprintf(stderr, "Free HW surface %08x\n", surface);
+ if (surface->hwdata) {
+ screen_destroy_pixmap_buffer(surface->hwdata->pixmap);
+ screen_destroy_pixmap(surface->hwdata->pixmap);
+ }
+ return;
+}
+
+int PLAYBOOK_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+ /* Currently does nothing */
+ return(0);
+}
+
+void PLAYBOOK_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+ /* Currently does nothing */
+ return;
+}
+
+int PLAYBOOK_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+ fprintf(stderr, "Flip HW surface %08x\n", surface);
+ // FIXME: This doesn't work properly yet. It flashes black, I think the new render buffers are wrong.
+ static int fullRect[] = {0, 0, 1024, 600};
+ //screen_flush_blits(_priv->screenContext, 0);
+ int result = screen_post_window(_priv->screenWindow, surface->hwdata->front, 1, fullRect, 0);
+
+ screen_buffer_t windowBuffer[2];
+ int rc = screen_get_window_property_pv(_priv->screenWindow,
+ SCREEN_PROPERTY_RENDER_BUFFERS, (void**)&windowBuffer);
+ if (rc) {
+ SDL_SetError("Cannot get window render buffers: %s", strerror(errno));
+ return NULL;
+ }
+
+ rc = screen_get_buffer_property_pv(windowBuffer[0], SCREEN_PROPERTY_POINTER, &_priv->pixels);
+ if (rc) {
+ SDL_SetError("Cannot get buffer pointer: %s", strerror(errno));
+ return NULL;
+ }
+ surface->hwdata->front = windowBuffer[0];
+ surface->pixels = _priv->pixels;
+ return 0;
+}
+
+int PLAYBOOK_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
+{
+ fprintf(stderr, "Fill HW rect\n");
+ if (dst->flags & SDL_HWSURFACE) {
+ int attribs[] = {SCREEN_BLIT_DESTINATION_X, rect->x,
+ SCREEN_BLIT_DESTINATION_Y, rect->y,
+ SCREEN_BLIT_DESTINATION_WIDTH, rect->w,
+ SCREEN_BLIT_DESTINATION_HEIGHT, rect->h,
+ SCREEN_BLIT_COLOR, color,
+ SCREEN_BLIT_END};
+ screen_fill(_priv->screenContext, _priv->frontBuffer, attribs);
+ }
+ return 0;
+}
+
@@ -0,0 +1,30 @@
+/*
+ * SDL_playbookhw_c.h
+ *
+ * Created on: Nov 23, 2011
+ * Author: jnicholl
+ */
+
+#ifndef SDL_PLAYBOOKHW_C_H_
+#define SDL_PLAYBOOKHW_C_H_
+
+#include "SDL_config.h"
+
+#include "SDL_video.h"
+#include "SDL_playbookvideo.h"
+
+struct private_hwdata {
+ screen_pixmap_t pixmap;
+ screen_window_t window;
+ screen_buffer_t front;
+ screen_buffer_t back;
+};
+
+int PLAYBOOK_AllocHWSurface(_THIS, SDL_Surface *surface);
+void PLAYBOOK_FreeHWSurface(_THIS, SDL_Surface *surface);
+int PLAYBOOK_LockHWSurface(_THIS, SDL_Surface *surface);
+void PLAYBOOK_UnlockHWSurface(_THIS, SDL_Surface *surface);
+int PLAYBOOK_FlipHWSurface(_THIS, SDL_Surface *surface);
+int PLAYBOOK_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
+
+#endif /* SDL_PLAYBOOKHW_C_H_ */
Oops, something went wrong.

0 comments on commit a78036f

Please sign in to comment.