[Scummvm-git-logs] scummvm branch-2-7 -> b1b2e3418438076ca6fccf95c1ebb368818c1f32
lotharsm
noreply at scummvm.org
Sun Feb 12 08:35:52 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
624d9782a5 CREATE_PROJECT: Add Accelerate framework to iOS and tvOS
b1b2e34184 IOS7: Add support for 32 bit pixel formats
Commit: 624d9782a538e4d15ab4777405f6d44cb526bf90
https://github.com/scummvm/scummvm/commit/624d9782a538e4d15ab4777405f6d44cb526bf90
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-02-12T09:35:48+01:00
Commit Message:
CREATE_PROJECT: Add Accelerate framework to iOS and tvOS
Add Apple Accelerate framework to iOS and tvOS targets. The framework
utilizes NEON extensions on the ARM chip to accelerate calculations.
This will come to use when processing texture data.
Changed paths:
configure
devtools/create_project/xcode.cpp
ports.mk
diff --git a/configure b/configure
index 31590db87fe..6f44008abdb 100755
--- a/configure
+++ b/configure
@@ -3866,7 +3866,7 @@ case $_backend in
append_var LIBS "-lobjc -framework UIKit -framework CoreGraphics -framework OpenGLES"
append_var LIBS "-framework QuartzCore -framework CoreFoundation -framework Foundation"
append_var LIBS "-framework AudioToolbox -framework CoreAudio -framework SystemConfiguration "
- append_var LIBS "-framework GameController"
+ append_var LIBS "-framework GameController -framework Accelerate"
if test "$_host_cpu" = 'aarch64' ; then
append_var LDFLAGS "-miphoneos-version-min=7.1 -arch arm64"
append_var CFLAGS "-miphoneos-version-min=7.1 -arch arm64"
diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp
index ea355e64588..2c82aa74869 100644
--- a/devtools/create_project/xcode.cpp
+++ b/devtools/create_project/xcode.cpp
@@ -434,6 +434,7 @@ void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) {
std::map<std::string, FileProperty> properties;
int fwOrder = 0;
// Frameworks
+ DEF_SYSFRAMEWORK("Accelerate");
DEF_SYSFRAMEWORK("ApplicationServices");
DEF_SYSFRAMEWORK("AudioToolbox");
DEF_SYSFRAMEWORK("AudioUnit");
@@ -562,6 +563,7 @@ void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) {
frameworks_iOS.push_back("AudioToolbox.framework");
frameworks_iOS.push_back("QuartzCore.framework");
frameworks_iOS.push_back("OpenGLES.framework");
+ frameworks_iOS.push_back("Accelerate.framework");
if (CONTAINS_DEFINE(setup.defines, "USE_FAAD")) {
frameworks_iOS.push_back("libfaad.a");
diff --git a/ports.mk b/ports.mk
index 03cfc299a6b..dd46fcbeb90 100644
--- a/ports.mk
+++ b/ports.mk
@@ -504,7 +504,7 @@ iphone: $(DETECT_OBJS) $(OBJS)
+$(LD) $(LDFLAGS) -o scummvm $(DETECT_OBJS) $(OBJS) \
$(OSX_STATIC_LIBS) \
-framework UIKit -framework CoreGraphics -framework OpenGLES -framework GameController \
- -framework CoreFoundation -framework QuartzCore -framework Foundation \
+ -framework CoreFoundation -framework QuartzCore -framework Foundation -framework Accelerate \
-framework AudioToolbox -framework CoreAudio -framework SystemConfiguration -lobjc -lz
# Special target to create a snapshot disk image for macOS
Commit: b1b2e3418438076ca6fccf95c1ebb368818c1f32
https://github.com/scummvm/scummvm/commit/b1b2e3418438076ca6fccf95c1ebb368818c1f32
Author: Lars Sundström (l.sundstrom at gmail.com)
Date: 2023-02-12T09:35:48+01:00
Commit Message:
IOS7: Add support for 32 bit pixel formats
This enables some game engines only supporting 32 bit color formats,
e.g. 11th hour and Broken Sword 2.5.
Add support for the pixel formats RGBA8888 and ABGR8888. The pixel
formats are defined in big endian while iOS utilizes little endian,
thus requiring converting some formats to get correct color
representation.
Use the Apple Accelerate framework converting the format requiring
to minimize the CPU load since this is done every frame.
Changed paths:
backends/platform/ios7/ios7_osys_video.mm
backends/platform/ios7/ios7_video.h
backends/platform/ios7/ios7_video.mm
diff --git a/backends/platform/ios7/ios7_osys_video.mm b/backends/platform/ios7/ios7_osys_video.mm
index 3b010161bcf..7c321839e12 100644
--- a/backends/platform/ios7/ios7_osys_video.mm
+++ b/backends/platform/ios7/ios7_osys_video.mm
@@ -101,6 +101,10 @@ void OSystem_iOS7::initVideoContext() {
#ifdef USE_RGB_COLOR
Common::List<Graphics::PixelFormat> OSystem_iOS7::getSupportedFormats() const {
Common::List<Graphics::PixelFormat> list;
+ // ABGR8888 (big endian)
+ list.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
+ // RGBA8888 (big endian)
+ list.push_back(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
// RGB565
list.push_back(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
// CLUT8
@@ -138,9 +142,19 @@ void OSystem_iOS7::initSize(uint width, uint height, const Graphics::PixelFormat
// Create the screen texture right here. We need to do this here, since
// when a game requests hi-color mode, we actually set the framebuffer
// to the texture buffer to avoid an additional copy step.
- execute_on_main_thread(^ {
- [[iOS7AppDelegate iPhoneView] createScreenTexture];
- });
+ // Free any previous screen texture and create new to handle format changes
+ _videoContext->screenTexture.free();
+
+ if (format && *format == Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) {
+ // ABGR8888 (big endian)
+ _videoContext->screenTexture.create((uint16) getSizeNextPOT(_videoContext->screenWidth), (uint16) getSizeNextPOT(_videoContext->screenHeight), Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24));
+ } else if (format && *format == Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) {
+ // RGBA8888 (big endian)
+ _videoContext->screenTexture.create((uint16) getSizeNextPOT(_videoContext->screenWidth), (uint16) getSizeNextPOT(_videoContext->screenHeight), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ } else {
+ // Assume RGB565
+ _videoContext->screenTexture.create((uint16) getSizeNextPOT(_videoContext->screenWidth), (uint16) getSizeNextPOT(_videoContext->screenHeight), Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+ }
// In case the client code tries to set up a non supported mode, we will
// fall back to CLUT8 and set the transaction error accordingly.
@@ -149,6 +163,10 @@ void OSystem_iOS7::initSize(uint width, uint height, const Graphics::PixelFormat
_gfxTransactionError = kTransactionFormatNotSupported;
}
+ execute_on_main_thread(^{
+ [[iOS7AppDelegate iPhoneView] setGameScreenCoords];
+ });
+
if (!format || format->bytesPerPixel == 1) {
_framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
} else {
diff --git a/backends/platform/ios7/ios7_video.h b/backends/platform/ios7/ios7_video.h
index 2ff3f843588..2bd6accaece 100644
--- a/backends/platform/ios7/ios7_video.h
+++ b/backends/platform/ios7/ios7_video.h
@@ -25,6 +25,7 @@
#include <UIKit/UIKit.h>
#include <Foundation/Foundation.h>
#include <QuartzCore/QuartzCore.h>
+#include <Accelerate/Accelerate.h>
#include <OpenGLES/EAGL.h>
#include <OpenGLES/ES2/gl.h>
@@ -41,6 +42,8 @@ typedef struct {
GLfloat u,v;
} GLVertex;
+uint getSizeNextPOT(uint size);
+
@interface iPhoneView : UIView {
VideoContext _videoContext;
@@ -97,7 +100,7 @@ typedef struct {
- (VideoContext *)getVideoContext;
-- (void)createScreenTexture;
+- (void)setGameScreenCoords;
- (void)initSurface;
- (void)setViewTransformation;
diff --git a/backends/platform/ios7/ios7_video.mm b/backends/platform/ios7/ios7_video.mm
index 81517656699..da29d0376c3 100644
--- a/backends/platform/ios7/ios7_video.mm
+++ b/backends/platform/ios7/ios7_video.mm
@@ -115,7 +115,7 @@ uint getSizeNextPOT(uint size) {
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = @{
kEAGLDrawablePropertyRetainedBacking: @NO,
- kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGB565
+ kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8,
};
_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
@@ -569,6 +569,30 @@ uint getSizeNextPOT(uint size) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.getPixels()); printOpenGLError();
}
+- (void *)getTextureInRGBA8888BE_AsRGBA8888LE {
+ // Allocate a pixel buffer with 32 bits per pixel
+ void *pixelBuffer = malloc(_videoContext.screenTexture.h * _videoContext.screenTexture.w * sizeof(uint32_t));
+ // Copy the texture pixels as we don't want to operate on the
+ memcpy(pixelBuffer, _videoContext.screenTexture.getPixels(), _videoContext.screenTexture.h * _videoContext.screenTexture.w * sizeof(uint32_t));
+
+ // Utilize the Accelerator Framwork to do some byte swapping
+ vImage_Buffer src;
+ src.height = _videoContext.screenTexture.h;
+ src.width = _videoContext.screenTexture.w;
+ src.rowBytes = _videoContext.screenTexture.pitch;
+ src.data = _videoContext.screenTexture.getPixels();
+
+ // Initialise dst with src, change data pointer to pixelBuffer
+ vImage_Buffer dst = src;
+ dst.data = pixelBuffer;
+
+ // Swap pixel channels from RGBA BE to RGBA LE (ABGR)
+ const uint8_t map[4] = { 3, 2, 1, 0 };
+ vImagePermuteChannels_ARGB8888(&src, &dst, map, kvImageNoFlags);
+
+ return pixelBuffer;
+}
+
- (void)updateMainSurface {
glBufferData(GL_ARRAY_BUFFER, sizeof(GLVertex) * 4, _gameScreenCoords, GL_STATIC_DRAW);
glVertexAttribPointer(_positionSlot, 2, GL_FLOAT, GL_FALSE, sizeof(GLVertex), 0);
@@ -579,8 +603,18 @@ uint getSizeNextPOT(uint size) {
// Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases
// due to the iPhone internals having to convert the whole texture back from its internal format when used.
// In the future we could use several tiled textures instead.
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.getPixels()); printOpenGLError();
-
+ if (_videoContext.screenTexture.format == Graphics::PixelFormat(4, 8, 8, 8, 8, 0, 8, 16, 24)) {
+ // ABGR8888 in big endian which in little endian is RBGA8888 -> no convertion needed
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, _videoContext.screenTexture.getPixels()); printOpenGLError();
+ } else if (_videoContext.screenTexture.format == Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)) {
+ // RGBA8888 (big endian) = ABGR8888 (little endian) -> needs convertion
+ void* pixelBuffer = [self getTextureInRGBA8888BE_AsRGBA8888LE];
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelBuffer); printOpenGLError();
+ free(pixelBuffer);
+ } else {
+ // Assuming RGB565
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.getPixels()); printOpenGLError();
+ }
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
@@ -605,14 +639,12 @@ uint getSizeNextPOT(uint size) {
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError();
}
-- (void)createScreenTexture {
+- (void)setGameScreenCoords{
const uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth);
const uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight);
_gameScreenCoords[1].u = _gameScreenCoords[3].u = _videoContext.screenWidth / (GLfloat)screenTexWidth;
_gameScreenCoords[2].v = _gameScreenCoords[3].v = _videoContext.screenHeight / (GLfloat)screenTexHeight;
-
- _videoContext.screenTexture.create((uint16) screenTexWidth, (uint16) screenTexHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
}
- (void)initSurface {
More information about the Scummvm-git-logs
mailing list