MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / Texture

Method Texture

tests/loadtests/vkloadtests/Texture.cpp:59–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59Texture::Texture(VulkanContext& vkctx,
60 uint32_t width, uint32_t height,
61 const char* const szArgs,
62 const std::string sBasePath)
63 : VulkanLoadTestSample(vkctx, width, height, sBasePath)
64{
65 zoom = -2.5f;
66 rotation = { 0.0f, 15.0f, 0.0f };
67 tiling = vk::ImageTiling::eOptimal;
68 useSubAlloc = UseSuballocator::No;
69 rgbcolor upperLeftColor{ 0.7f, 0.1f, 0.2f };
70 rgbcolor lowerLeftColor{ 0.8f, 0.9f, 0.3f };
71 rgbcolor upperRightColor{ 0.4f, 1.0f, 0.5f };
72 rgbcolor lowerRightColor{ 0.0f, 0.6f, 0.1f };
73
74 transcoded = false;
75
76 quadColor = { upperLeftColor, lowerLeftColor,
77 upperRightColor, lowerRightColor };
78
79 ktxVulkanDeviceInfo vdi;
80 ktxVulkanDeviceInfo_Construct(&vdi, vkctx.gpu, vkctx.device,
81 vkctx.queue, vkctx.commandPool, nullptr);
82
83 processArgs(szArgs);
84
85 KTX_error_code ktxresult;
86 ktxTexture* kTexture;
87 std::string ktxfilepath = externalFile ? ktxfilename
88 : getAssetPath() + ktxfilename;
89 ktxresult = ktxTexture_CreateFromNamedFile(ktxfilepath.c_str(),
90 KTX_TEXTURE_CREATE_NO_FLAGS,
91 &kTexture);
92 if (KTX_SUCCESS != ktxresult) {
93 std::stringstream message;
94
95 message << "Creation of ktxTexture from \"" << ktxfilepath
96 << "\" failed: " << ktxErrorString(ktxresult);
97 throw std::runtime_error(message.str());
98 }
99
100 if (ktxTexture_NeedsTranscoding(kTexture)) {
101 TextureTranscoder tc(vkctx);
102 tc.transcode((ktxTexture2*)kTexture);
103 transcoded = true;
104 }
105
106 vk::Format vkFormat
107 = static_cast<vk::Format>(ktxTexture_GetVkFormat(kTexture));
108 transcodedFormat = vkFormat;
109 vk::FormatProperties properties;
110 vkctx.gpu.getFormatProperties(vkFormat, &properties);
111 vk::FormatFeatureFlags& features = tiling == vk::ImageTiling::eLinear ?
112 properties.linearTilingFeatures :
113 properties.optimalTilingFeatures;
114 vk::FormatFeatureFlags wantedFeatures =
115 vk::FormatFeatureFlagBits::eSampledImage
116 | vk::FormatFeatureFlagBits::eSampledImageFilterLinear;

Callers

nothing calls this directly

Calls 14

ktxErrorStringFunction · 0.85
ktxTexture_GetVkFormatFunction · 0.85
unsupported_ttypeClass · 0.85
InitVMAFunction · 0.85
ktxTexture_VkUploadExFunction · 0.85
ktxHashList_FindValueFunction · 0.85
cleanupFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected