فهرست منبع

Add a flag to deactivate FP16 at compiletime.

Joachim Meyer 9 سال پیش
والد
کامیت
8abb424e28

+ 1 - 5
build/android/Polycode2DPhysics/AndroidManifest.xml

@@ -1,11 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- BEGIN_INCLUDE(manifest) -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.example.native_activity"
-        android:versionCode="1"
-        android:versionName="1.0">
-
-    <uses-sdk android:minSdkVersion="21" />
+        package="com.example.native_activity">
 
     <!-- This .apk has no Java code itself, so set hasCode to false. -->
     <application android:label="Polycore" android:hasCode="false">

+ 1 - 1
build/android/Polycode2DPhysics/build.gradle

@@ -8,7 +8,7 @@ android {
 
     defaultConfig {
     applicationId "org.polycode.polycode2dphysics"
-        minSdkVersion 21
+        minSdkVersion 14
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"

+ 1 - 1
build/android/Polycode3DPhysics/build.gradle

@@ -8,7 +8,7 @@ android {
 
     defaultConfig {
     applicationId "org.polycode.polycode3dphysics"
-        minSdkVersion 21
+        minSdkVersion 14
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"

+ 1 - 1
build/android/PolycodeUI/build.gradle

@@ -8,7 +8,7 @@ android {
 
     defaultConfig {
     applicationId "org.polycode.polycodeui"
-        minSdkVersion 21
+        minSdkVersion 14
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"

+ 1 - 1
build/android/Polycore/build.gradle

@@ -6,7 +6,7 @@ android {
     buildToolsVersion "23.0.2"
     defaultConfig {
         applicationId "org.polycode.polycore"
-        minSdkVersion 21
+        minSdkVersion 14
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
build/android/Polycore/jni/Android.mk


+ 1 - 1
build/android/TemplateApp/build.gradle

@@ -7,7 +7,7 @@ android {
     buildToolsVersion '23.0.2'
     defaultConfig {
         applicationId "org.polycode.templateapp"
-        minSdkVersion 21
+        minSdkVersion 14
         targetSdkVersion 23
         versionCode 1
         versionName "1.0"

+ 1 - 1
build/android/TemplateApp/jni/Android.mk

@@ -77,6 +77,6 @@ LOCAL_MODULE := TemplateApp
 LOCAL_LDLIBS := -landroid -lEGL -lGLESv2 -lOpenSLES -lz -llog
 LOCAL_STATIC_LIBRARIES := Polycore PolycodeUI Polycode3DPhysics freetype lua physfs box2d BulletDynamics BulletCollision BulletSoftBody LinearMath
 LOCAL_SHARED_LIBRARIES := ogg vorbis
-LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../include -DUSE_EGL -DSTRICT_OPENGLES2
+LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../include -DUSE_EGL -DSTRICT_OPENGLES2 -DNO_FP16
 LOCAL_SRC_FILES := PolycodeTemplate.cpp PolycodeTemplateApp.cpp
 include $(BUILD_SHARED_LIBRARY)

+ 3 - 1
include/polycode/core/PolyImage.h

@@ -275,8 +275,10 @@ namespace Polycode {
 		
 			static const int IMAGE_RGB = 0;
 			static const int IMAGE_RGBA = 1;
+#ifndef NO_FP16
 			static const int IMAGE_FP16 = 2;
-		
+#endif
+			
 		protected:
 		
 			bool loadHDR(const String &fileName);

+ 1 - 1
lib

@@ -1 +1 @@
-Subproject commit ca969d5709d7280c3b16b98c4fc4f584e3e5a157
+Subproject commit cbd0b400c695ee6626d562365990846bc74cfc99

+ 7 - 1
src/core/PolyImage.cpp

@@ -61,9 +61,11 @@ void Image::setPixelType(int type) {
 		case IMAGE_RGBA:
 			pixelSize = 4;						
 		break;
+#ifndef NO_FP16
 		case IMAGE_FP16:		
 			pixelSize = 6;
 		break;
+#endif
 		default:
 			pixelSize = 4;								
 			break;
@@ -624,7 +626,7 @@ bool Image::loadSTB(const String &fileName) {
 }
 
 bool Image::loadHDR(const String &fileName) {
-	
+#ifndef NO_FP16
 	imageType = Image::IMAGE_FP16;
 	
 	CoreFile *infile = Services()->getCore()->openFile(fileName.c_str(), "rb");
@@ -660,6 +662,10 @@ bool Image::loadHDR(const String &fileName) {
 	
 	
 	return true;
+#else
+	Logger::log("HDR not supported!");
+	return false;
+#endif
 }
 
 void Image::transformCoordinates(int *x, int *y) {

+ 10 - 4
src/core/PolyOpenGLGraphicsInterface.cpp

@@ -485,13 +485,15 @@ void OpenGLGraphicsInterface::createRenderBuffer(RenderBuffer *renderBuffer) {
 		renderBuffer->depthTexture->type = renderBuffer->colorTexture->type;
 		renderBuffer->depthTexture->filteringMode = Texture::FILTERING_LINEAR;
 		createTexture(&*renderBuffer->depthTexture);
-		
+#ifndef NO_FP16
 		if(renderBuffer->colorTexture->type == Image::IMAGE_FP16) {
 			glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, renderBuffer->getWidth(), renderBuffer->getHeight());
-			
 		} else {
+#endif
 			glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, renderBuffer->getWidth(), renderBuffer->getHeight());
+#ifndef NO_FP16
 		}
+#endif
 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, *((GLuint*)renderBuffer->depthTexture->platformData), 0);
 	}
 	
@@ -553,6 +555,7 @@ void OpenGLGraphicsInterface::createTexture(Texture *texture) {
 			glTextureFormat = GL_RGB;
 			pixelType = GL_UNSIGNED_BYTE;
 			break;
+#ifndef NO_FP16
 		case Image::IMAGE_FP16:
 #ifdef BGRA_TEXTURE_FORMAT
 			glTextureType = GL_BGR;
@@ -568,6 +571,7 @@ void OpenGLGraphicsInterface::createTexture(Texture *texture) {
 #endif
 			pixelType = GL_FLOAT;
 			break;
+#endif
 		default:
 #ifdef BGRA_TEXTURE_FORMAT
 			glTextureType = GL_BGRA;
@@ -581,15 +585,17 @@ void OpenGLGraphicsInterface::createTexture(Texture *texture) {
 	
 	if(texture->depthTexture) {
 		glTextureType = GL_DEPTH_COMPONENT;
-		
+#ifndef NO_FP16
 		if(texture->type == Image::IMAGE_FP16) {
 			pixelType = GL_FLOAT;
 			glTextureFormat = GL_DEPTH_COMPONENT16;
 		} else {
+#endif
 			pixelType = GL_UNSIGNED_BYTE;
 			glTextureFormat = GL_DEPTH_COMPONENT;
+#ifndef NO_FP16
 		}
-		
+#endif		
 	  //  glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
 	}
 	

+ 14 - 8
src/core/PolyTexture.cpp

@@ -43,16 +43,18 @@ Texture::Texture(unsigned int width, unsigned int height, char *textureData,bool
 	
 	switch(type) {
 		case Image::IMAGE_RGB:
-			pixelSize = 3;			
+			pixelSize = 3;
 			break;
 		case Image::IMAGE_RGBA:
-			pixelSize = 4;						
+			pixelSize = 4;
 		break;
-		case Image::IMAGE_FP16:		
+#ifndef NO_FP16
+		case Image::IMAGE_FP16:
 			pixelSize = 6;
 		break;
+#endif
 		default:
-			pixelSize = 4;								
+			pixelSize = 4;
 		break;
 	}
 	
@@ -94,16 +96,18 @@ void Texture::setImageData(Image *data) {
 
 	switch (data->getType()) {
 		case Image::IMAGE_RGB:
-			pixelSize = 3;			
+			pixelSize = 3;
 		break;
 		case Image::IMAGE_RGBA:
-			pixelSize = 4;						
+			pixelSize = 4;
 		break;
-		case Image::IMAGE_FP16:		
+#ifndef NO_FP16
+		case Image::IMAGE_FP16:
 			pixelSize = 6;
 		break;
+#endif
 		default:
-			pixelSize = 4;								
+			pixelSize = 4;
 		break;
 	}
 
@@ -159,9 +163,11 @@ Texture::Texture(Image *image, bool clamp, bool createMipmaps) : Resource(Resour
 RenderBuffer::RenderBuffer(unsigned int width, unsigned int height, bool attachDepthBuffer, bool floatingPoint) : platformData(NULL), width(width), height(height), depthBufferPlatformData(NULL), floatingPoint(floatingPoint) {
 	
 	int imageType = Image::IMAGE_RGBA;
+#ifndef NO_FP16
 	if(floatingPoint) {
 		imageType = Image::IMAGE_FP16;
 	}
+#endif
 	colorTexture = std::make_shared<Texture>(width, height, nullptr, false, false, imageType, true);
 	if(attachDepthBuffer) {
 		depthTexture = std::make_shared<Texture>(width, height, nullptr, false, false, 1, true);

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است