Added ETC2 and ASTC texture variants (Refs #174)

This commit is contained in:
saschawillems 2017-03-12 12:30:17 +01:00
parent 40753f9dbb
commit 0b6fb9b64d
10 changed files with 72 additions and 30 deletions

View file

@ -15,6 +15,7 @@
android:label="Instancing"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboardHidden">
<meta-data android:name="android.app.lib_name" android:value="vulkanInstancing" />
<intent-filter>

View file

@ -1,27 +0,0 @@
cd jni
call ndk-build
if %ERRORLEVEL% EQU 0 (
cd..
mkdir "assets\shaders\base"
xcopy "..\..\data\shaders\base\*.spv" "assets\shaders\base" /Y
mkdir "assets\shaders\instancing"
xcopy "..\..\data\shaders\instancing\*.spv" "assets\shaders\instancing" /Y
mkdir "assets\textures"
xcopy "..\..\data\textures\texturearray_rocks_bc3.ktx" "assets\textures" /Y
xcopy "..\..\data\textures\lavaplanet_bc3.ktx" "assets\textures" /Y
mkdir "assets\models"
xcopy "..\..\data\models\rock01.dae" "assets\models" /Y
xcopy "..\..\data\models\sphere.obj" "assets\models" /Y
mkdir "res\drawable"
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
call ant debug -Dout.final.file=vulkanInstancing.apk
) ELSE (
echo error : ndk-build failed with errors!
cd..
)

View file

@ -0,0 +1,47 @@
import os
import shutil
import subprocess
import sys
import glob
APK_NAME = "vulkanInstancing"
SHADER_DIR = "instancing"
ASSETS_MODELS = ["rock01.dae", "sphere.obj", ]
ASSETS_TEXTURES = ["texturearray_rocks_bc3_unorm.ktx", "texturearray_rocks_astc_8x8_unorm.ktx", "texturearray_rocks_etc2_unorm.ktx", "lavaplanet_bc3_unorm.ktx", "lavaplanet_astc_8x8_unorm.ktx", "lavaplanet_etc2_unorm.ktx"]
if subprocess.call("ndk-build", shell=True) == 0:
print("Build successful")
# Assets
os.makedirs("./assets/shaders/base", exist_ok=True)
os.makedirs("./assets/shaders/%s" % SHADER_DIR, exist_ok=True)
os.makedirs("./assets/textures", exist_ok=True)
os.makedirs("./assets/models", exist_ok=True)
os.makedirs("./res/drawable", exist_ok=True)
# Shaders
# Base
for file in glob.glob("../../data/shaders/base/*.spv"):
shutil.copy(file, "./assets/shaders/base")
# Sample
for file in glob.glob("../../data/shaders/%s/*.spv" %SHADER_DIR):
shutil.copy(file, "./assets/shaders/%s" % SHADER_DIR)
# Textures
for file in ASSETS_TEXTURES:
shutil.copy("../../data/textures/%s" % file, "./assets/textures")
# Models
for file in ASSETS_MODELS:
shutil.copy("../../data/models/%s" % file, "./assets/models")
# Icon
shutil.copy("../../android/images/icon.png", "./res/drawable")
if subprocess.call("ant debug -Dout.final.file=%s.apk" % APK_NAME, shell=True) == 0:
if len(sys.argv) > 1:
if sys.argv[1] == "-deploy":
if subprocess.call("adb install -r %s.apk" % APK_NAME, shell=True) != 0:
print("Could not deploy to device!")
else:
print("Error during build process!")
else:
print("Error building project!")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -123,7 +123,7 @@ public:
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
VkClearValue clearValues[2];
clearValues[0].color = { { 0.0f, 0.0f, 0.0f, 0.0f } };
clearValues[0].color = { { 0.0f, 0.0f, 0.2f, 0.0f } };
clearValues[1].depthStencil = { 1.0f, 0 };
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
@ -185,8 +185,29 @@ public:
{
models.rock.loadFromFile(getAssetPath() + "models/rock01.dae", vertexLayout, 0.1f, vulkanDevice, queue);
models.planet.loadFromFile(getAssetPath() + "models/sphere.obj", vertexLayout, 0.2f, vulkanDevice, queue);
textures.rocks.loadFromFile(getAssetPath() + "textures/texturearray_rocks_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
textures.planet.loadFromFile(getAssetPath() + "textures/lavaplanet_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
// Textures
std::string texFormatSuffix;
VkFormat texFormat;
// Get supported compressed texture format
if (vulkanDevice->features.textureCompressionBC) {
texFormatSuffix = "_bc3_unorm";
texFormat = VK_FORMAT_BC3_UNORM_BLOCK;
}
else if (vulkanDevice->features.textureCompressionASTC_LDR) {
texFormatSuffix = "_astc_8x8_unorm";
texFormat = VK_FORMAT_ASTC_8x8_UNORM_BLOCK;
}
else if (vulkanDevice->features.textureCompressionETC2) {
texFormatSuffix = "_etc2_unorm";
texFormat = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
}
else {
vks::tools::exitFatal("Device does not support any compressed texture format!", "Error");
}
textures.rocks.loadFromFile(getAssetPath() + "textures/texturearray_rocks" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
textures.planet.loadFromFile(getAssetPath() + "textures/lavaplanet" + texFormatSuffix + ".ktx", texFormat, vulkanDevice, queue);
}
void setupDescriptorPool()