Skip to content

Commit 02ed0ee

Browse files
committed
Add missing asset to host image copy sample
Minor code cleanup
1 parent d68ec09 commit 02ed0ee

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

android/examples/hostimagecopy/build.gradle

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ task copyTask {
6060
include 'metalplate01_rgba.ktx'
6161
}
6262

63+
copy {
64+
from rootProject.ext.assetPath + 'models'
65+
into 'assets/models'
66+
include 'plane_z.gltf'
67+
}
6368

6469
}
6570

examples/hostimagecopy/hostimagecopy.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class VulkanExample : public VulkanExampleBase
7070
deviceCreatepNextChain = &enabledPhysicalDeviceHostImageCopyFeaturesEXT;
7171
}
7272

73-
~VulkanExample()
73+
~VulkanExample() override
7474
{
7575
if (device) {
7676
destroyTextureImage(texture);
@@ -82,7 +82,7 @@ class VulkanExample : public VulkanExampleBase
8282
}
8383

8484
// Enable physical device features required for this example
85-
virtual void getEnabledFeatures()
85+
void getEnabledFeatures() override
8686
{
8787
// Enable anisotropic filtering if supported
8888
if (deviceFeatures.samplerAnisotropy) {
@@ -134,7 +134,6 @@ class VulkanExample : public VulkanExampleBase
134134
texture.height = ktxTexture->baseHeight;
135135
texture.mipLevels = ktxTexture->numLevels;
136136
ktx_uint8_t *ktxTextureData = ktxTexture_GetData(ktxTexture);
137-
ktx_size_t ktxTextureSize = ktxTexture_GetSize(ktxTexture);
138137

139138
const VkFormat imageFormat = VK_FORMAT_R8G8B8A8_UNORM;
140139

@@ -271,7 +270,7 @@ class VulkanExample : public VulkanExampleBase
271270
vkFreeMemory(device, texture.deviceMemory, nullptr);
272271
}
273272

274-
void buildCommandBuffers()
273+
void buildCommandBuffers() override
275274
{
276275
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();
277276

@@ -371,11 +370,11 @@ class VulkanExample : public VulkanExampleBase
371370
VkPipelineMultisampleStateCreateInfo multisampleState = vks::initializers::pipelineMultisampleStateCreateInfo(VK_SAMPLE_COUNT_1_BIT, 0);
372371
std::vector<VkDynamicState> dynamicStateEnables = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
373372
VkPipelineDynamicStateCreateInfo dynamicState = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
374-
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;
375-
376-
// Shaders
377-
shaderStages[0] = loadShader(getShadersPath() + "texture/texture.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
378-
shaderStages[1] = loadShader(getShadersPath() + "texture/texture.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
373+
// Shaders
374+
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages = {
375+
loadShader(getShadersPath() + "texture/texture.vert.spv", VK_SHADER_STAGE_VERTEX_BIT),
376+
loadShader(getShadersPath() + "texture/texture.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT)
377+
};
379378

380379
VkGraphicsPipelineCreateInfo pipelineCreateInfo = vks::initializers::pipelineCreateInfo(pipelineLayout, renderPass, 0);
381380
pipelineCreateInfo.pInputAssemblyState = &inputAssemblyState;
@@ -413,7 +412,7 @@ class VulkanExample : public VulkanExampleBase
413412
plane.loadFromFile(getAssetPath() + "models/plane_z.gltf", vulkanDevice, queue, glTFLoadingFlags);
414413
}
415414

416-
void prepare()
415+
void prepare() override
417416
{
418417
VulkanExampleBase::prepare();
419418

@@ -440,15 +439,15 @@ class VulkanExample : public VulkanExampleBase
440439
VulkanExampleBase::submitFrame();
441440
}
442441

443-
virtual void render()
442+
void render() override
444443
{
445444
if (!prepared)
446445
return;
447446
updateUniformBuffers();
448447
draw();
449448
}
450449

451-
virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
450+
void OnUpdateUIOverlay(vks::UIOverlay *overlay) override
452451
{
453452
if (overlay->header("Settings")) {
454453
if (overlay->sliderFloat("LOD bias", &uniformData.lodBias, 0.0f, (float)texture.mipLevels)) {

0 commit comments

Comments
 (0)