Skip to content

Commit

Permalink
Add missing asset to host image copy sample
Browse files Browse the repository at this point in the history
Minor code cleanup
  • Loading branch information
SaschaWillems committed Mar 1, 2025
1 parent d68ec09 commit 02ed0ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
5 changes: 5 additions & 0 deletions android/examples/hostimagecopy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ task copyTask {
include 'metalplate01_rgba.ktx'
}

copy {
from rootProject.ext.assetPath + 'models'
into 'assets/models'
include 'plane_z.gltf'
}

}

Expand Down
23 changes: 11 additions & 12 deletions examples/hostimagecopy/hostimagecopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class VulkanExample : public VulkanExampleBase
deviceCreatepNextChain = &enabledPhysicalDeviceHostImageCopyFeaturesEXT;
}

~VulkanExample()
~VulkanExample() override
{
if (device) {
destroyTextureImage(texture);
Expand All @@ -82,7 +82,7 @@ class VulkanExample : public VulkanExampleBase
}

// Enable physical device features required for this example
virtual void getEnabledFeatures()
void getEnabledFeatures() override
{
// Enable anisotropic filtering if supported
if (deviceFeatures.samplerAnisotropy) {
Expand Down Expand Up @@ -134,7 +134,6 @@ class VulkanExample : public VulkanExampleBase
texture.height = ktxTexture->baseHeight;
texture.mipLevels = ktxTexture->numLevels;
ktx_uint8_t *ktxTextureData = ktxTexture_GetData(ktxTexture);
ktx_size_t ktxTextureSize = ktxTexture_GetSize(ktxTexture);

const VkFormat imageFormat = VK_FORMAT_R8G8B8A8_UNORM;

Expand Down Expand Up @@ -271,7 +270,7 @@ class VulkanExample : public VulkanExampleBase
vkFreeMemory(device, texture.deviceMemory, nullptr);
}

void buildCommandBuffers()
void buildCommandBuffers() override
{
VkCommandBufferBeginInfo cmdBufInfo = vks::initializers::commandBufferBeginInfo();

Expand Down Expand Up @@ -371,11 +370,11 @@ class VulkanExample : public VulkanExampleBase
VkPipelineMultisampleStateCreateInfo multisampleState = vks::initializers::pipelineMultisampleStateCreateInfo(VK_SAMPLE_COUNT_1_BIT, 0);
std::vector<VkDynamicState> dynamicStateEnables = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR };
VkPipelineDynamicStateCreateInfo dynamicState = vks::initializers::pipelineDynamicStateCreateInfo(dynamicStateEnables);
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages;

// Shaders
shaderStages[0] = loadShader(getShadersPath() + "texture/texture.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
shaderStages[1] = loadShader(getShadersPath() + "texture/texture.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
// Shaders
std::array<VkPipelineShaderStageCreateInfo,2> shaderStages = {
loadShader(getShadersPath() + "texture/texture.vert.spv", VK_SHADER_STAGE_VERTEX_BIT),
loadShader(getShadersPath() + "texture/texture.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT)
};

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

void prepare()
void prepare() override
{
VulkanExampleBase::prepare();

Expand All @@ -440,15 +439,15 @@ class VulkanExample : public VulkanExampleBase
VulkanExampleBase::submitFrame();
}

virtual void render()
void render() override
{
if (!prepared)
return;
updateUniformBuffers();
draw();
}

virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)
void OnUpdateUIOverlay(vks::UIOverlay *overlay) override
{
if (overlay->header("Settings")) {
if (overlay->sliderFloat("LOD bias", &uniformData.lodBias, 0.0f, (float)texture.mipLevels)) {
Expand Down

0 comments on commit 02ed0ee

Please sign in to comment.