Added ETC2 and ASTC texture variants (Refs #174)
This commit is contained in:
parent
40753f9dbb
commit
0b6fb9b64d
10 changed files with 72 additions and 30 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
android:label="Instancing"
|
android:label="Instancing"
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
|
android:screenOrientation="landscape"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden">
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
<meta-data android:name="android.app.lib_name" android:value="vulkanInstancing" />
|
<meta-data android:name="android.app.lib_name" android:value="vulkanInstancing" />
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
|
||||||
|
|
@ -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..
|
|
||||||
)
|
|
||||||
47
android/instancing/build.py
Normal file
47
android/instancing/build.py
Normal 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!")
|
||||||
BIN
data/textures/lavaplanet_astc_8x8_unorm.ktx
Normal file
BIN
data/textures/lavaplanet_astc_8x8_unorm.ktx
Normal file
Binary file not shown.
BIN
data/textures/lavaplanet_etc2_unorm.ktx
Normal file
BIN
data/textures/lavaplanet_etc2_unorm.ktx
Normal file
Binary file not shown.
BIN
data/textures/texturearray_rocks_astc_8x8_unorm.ktx
Normal file
BIN
data/textures/texturearray_rocks_astc_8x8_unorm.ktx
Normal file
Binary file not shown.
BIN
data/textures/texturearray_rocks_etc2_unorm.ktx
Normal file
BIN
data/textures/texturearray_rocks_etc2_unorm.ktx
Normal file
Binary file not shown.
|
|
@ -123,7 +123,7 @@ public:
|
||||||
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
|
||||||
|
|
||||||
VkClearValue clearValues[2];
|
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 };
|
clearValues[1].depthStencil = { 1.0f, 0 };
|
||||||
|
|
||||||
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
|
VkRenderPassBeginInfo renderPassBeginInfo = vks::initializers::renderPassBeginInfo();
|
||||||
|
|
@ -185,8 +185,29 @@ public:
|
||||||
{
|
{
|
||||||
models.rock.loadFromFile(getAssetPath() + "models/rock01.dae", vertexLayout, 0.1f, vulkanDevice, queue);
|
models.rock.loadFromFile(getAssetPath() + "models/rock01.dae", vertexLayout, 0.1f, vulkanDevice, queue);
|
||||||
models.planet.loadFromFile(getAssetPath() + "models/sphere.obj", vertexLayout, 0.2f, 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()
|
void setupDescriptorPool()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue