Added ETC2 and ASTC texture variants (Refs #174), only enable wireframe if non solid fillmode is supported by the device
This commit is contained in:
parent
83806a43c2
commit
4cc7b204df
7 changed files with 86 additions and 37 deletions
|
|
@ -15,6 +15,7 @@
|
|||
android:label="Mesh"
|
||||
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="vulkanMesh" />
|
||||
<intent-filter>
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
cd jni
|
||||
call ndk-build
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo ndk-build has failed, build cancelled
|
||||
cd..
|
||||
|
||||
mkdir "assets\shaders\base"
|
||||
xcopy "..\..\data\shaders\base\*.spv" "assets\shaders\base" /Y
|
||||
|
||||
|
||||
mkdir "assets\shaders\mesh"
|
||||
xcopy "..\..\data\shaders\mesh\mesh.vert.spv" "assets\shaders\mesh" /Y
|
||||
xcopy "..\..\data\shaders\mesh\mesh.frag.spv" "assets\shaders\mesh" /Y
|
||||
|
||||
mkdir "assets\models\voyager"
|
||||
xcopy "..\..\data\models\voyager\voyager.ktx" "assets\models\voyager" /Y
|
||||
xcopy "..\..\data\models\voyager\voyager.dae" "assets\models\voyager" /Y
|
||||
|
||||
mkdir "res\drawable"
|
||||
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||
|
||||
call ant debug -Dout.final.file=vulkanMesh.apk
|
||||
) ELSE (
|
||||
echo error : ndk-build failed with errors!
|
||||
cd..
|
||||
)
|
||||
52
android/mesh/build.py
Normal file
52
android/mesh/build.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import glob
|
||||
|
||||
APK_NAME = "vulkanMesh"
|
||||
SHADER_DIR = "mesh"
|
||||
ASSETS_MODELS = ["voyager.dae"]
|
||||
ASSETS_TEXTURES = ["voyager_astc_8x8_unorm.ktx", "voyager_bc3_unorm.ktx", "voyager_etc2_unorm.ktx"]
|
||||
|
||||
if subprocess.call("ndk-build", shell=True) == 0:
|
||||
print("Build successful")
|
||||
|
||||
# Assets
|
||||
if not os.path.exists("./assets"):
|
||||
os.makedirs("./assets")
|
||||
|
||||
# Shaders
|
||||
# Base
|
||||
if not os.path.exists("./assets/shaders/base"):
|
||||
os.makedirs("./assets/shaders/base")
|
||||
for file in glob.glob("../../data/shaders/base/*.spv"):
|
||||
shutil.copy(file, "./assets/shaders/base")
|
||||
# Sample
|
||||
if not os.path.exists("./assets/shaders/%s" % SHADER_DIR):
|
||||
os.makedirs("./assets/shaders/%s" % SHADER_DIR)
|
||||
for file in glob.glob("../../data/shaders/%s/*.spv" %SHADER_DIR):
|
||||
shutil.copy(file, "./assets/shaders/%s" % SHADER_DIR)
|
||||
# Textures
|
||||
if not os.path.exists("./assets/models/voyager"):
|
||||
os.makedirs("./assets/models/voyager")
|
||||
for file in ASSETS_TEXTURES:
|
||||
shutil.copy("../../data/models/voyager/%s" % file, "./assets/models/voyager")
|
||||
# Models
|
||||
for file in ASSETS_MODELS:
|
||||
shutil.copy("../../data/models/voyager/%s" % file, "./assets/models/voyager")
|
||||
|
||||
# Icon
|
||||
if not os.path.exists("./res/drawable"):
|
||||
os.makedirs("./res/drawable")
|
||||
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/models/voyager/voyager_astc_8x8_unorm.ktx
Normal file
BIN
data/models/voyager/voyager_astc_8x8_unorm.ktx
Normal file
Binary file not shown.
BIN
data/models/voyager/voyager_etc2_unorm.ktx
Normal file
BIN
data/models/voyager/voyager_etc2_unorm.ktx
Normal file
Binary file not shown.
|
|
@ -104,8 +104,6 @@ public:
|
|||
cameraPos = { 0.1f, 1.1f, 0.0f };
|
||||
enableTextOverlay = true;
|
||||
title = "Vulkan Example - Model rendering";
|
||||
// Enable physical device features required for this example
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
@ -124,6 +122,14 @@ public:
|
|||
uniformBuffers.scene.destroy();
|
||||
}
|
||||
|
||||
virtual void getEnabledFeatures()
|
||||
{
|
||||
// Fill mode non solid is required for wireframe display
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
};
|
||||
}
|
||||
|
||||
void reBuildCommandBuffers()
|
||||
{
|
||||
if (!checkCommandBuffers())
|
||||
|
|
@ -356,7 +362,18 @@ public:
|
|||
void loadAssets()
|
||||
{
|
||||
loadModel(getAssetPath() + "models/voyager/voyager.dae");
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
|
||||
if (deviceFeatures.textureCompressionBC) {
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_bc3_unorm.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
|
||||
}
|
||||
else if (deviceFeatures.textureCompressionASTC_LDR) {
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue);
|
||||
}
|
||||
else if (deviceFeatures.textureCompressionETC2) {
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_etc2_unorm.ktx", VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, vulkanDevice, queue);
|
||||
}
|
||||
else {
|
||||
vks::tools::exitFatal("Device does not support any compressed texture format!", "Error");
|
||||
}
|
||||
}
|
||||
|
||||
void setupVertexDescriptions()
|
||||
|
|
@ -568,11 +585,12 @@ public:
|
|||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.solid));
|
||||
|
||||
// Wire frame rendering pipeline
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
|
||||
rasterizationState.lineWidth = 1.0f;
|
||||
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wireframe));
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare and initialize uniform buffer containing shader uniforms
|
||||
void prepareUniformBuffers()
|
||||
|
|
@ -649,20 +667,24 @@ public:
|
|||
{
|
||||
case KEY_W:
|
||||
case GAMEPAD_BUTTON_A:
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
wireframe = !wireframe;
|
||||
reBuildCommandBuffers();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void getOverlayText(VulkanTextOverlay *textOverlay)
|
||||
{
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
#if defined(__ANDROID__)
|
||||
textOverlay->addText("Press \"Button A\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
#else
|
||||
textOverlay->addText("Press \"w\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VULKAN_EXAMPLE_MAIN()
|
||||
Loading…
Add table
Add a link
Reference in a new issue