MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / CreateTexture

Method CreateTexture

deps/LLGL/sources/Renderer/Vulkan/VKRenderSystem.cpp:261–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259/* ----- Textures ----- */
260
261Texture* VKRenderSystem::CreateTexture(const TextureDescriptor& textureDesc, const SrcImageDescriptor* imageDesc)
262{
263 const auto& cfg = GetConfiguration();
264
265 /* Determine size of image for staging buffer */
266 const auto imageSize = NumMipTexels(textureDesc, 0);
267 const auto initialDataSize = static_cast<VkDeviceSize>(GetMemoryFootprint(textureDesc.format, imageSize));
268
269 /* Set up initial image data */
270 const void* initialData = nullptr;
271 ByteBuffer intermediateData;
272
273 if (imageDesc)
274 {
275 /* Check if image data must be converted */
276 const auto& formatAttribs = GetFormatAttribs(textureDesc.format);
277 if (formatAttribs.bitSize > 0 && (formatAttribs.flags & FormatFlags::IsCompressed) == 0)
278 {
279 /* Convert image format (will be null if no conversion is necessary) */
280 intermediateData = ConvertImageBuffer(*imageDesc, formatAttribs.format, formatAttribs.dataType, cfg.threadCount);
281 }
282
283 if (intermediateData)
284 {
285 /*
286 Validate that source image data was large enough so conversion is valid,
287 then use temporary image buffer as source for initial data
288 */
289 const auto srcImageDataSize = imageSize * ImageFormatSize(imageDesc->format) * DataTypeSize(imageDesc->dataType);
290 AssertImageDataSize(imageDesc->dataSize, static_cast<std::size_t>(srcImageDataSize));
291 initialData = intermediateData.get();
292 }
293 else
294 {
295 /*
296 Validate that image data is large enough,
297 then use input data as source for initial data
298 */
299 AssertImageDataSize(imageDesc->dataSize, static_cast<std::size_t>(initialDataSize));
300 initialData = imageDesc->data;
301 }
302 }
303 else if ((textureDesc.miscFlags & MiscFlags::NoInitialData) == 0)
304 {
305 /* Allocate default image data */
306 const auto& formatAttribs = GetFormatAttribs(textureDesc.format);
307 if (formatAttribs.bitSize > 0 && (formatAttribs.flags & FormatFlags::IsCompressed) == 0)
308 {
309 const ColorRGBAd fillColor{ textureDesc.clearValue.color.Cast<double>() };
310 intermediateData = GenerateImageBuffer(formatAttribs.format, formatAttribs.dataType, imageSize, fillColor);
311 }
312 else
313 intermediateData = GenerateEmptyByteBuffer(static_cast<std::size_t>(initialDataSize));
314
315 initialData = intermediateData.get();
316 }
317
318 /* Create staging buffer */

Callers 8

onDeviceResetMethod · 0.45
SDL_CreateTextureFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
CreateTexturesMethod · 0.45
mainFunction · 0.45
CsRenderSystem.cppFile · 0.45

Calls 15

ConvertImageBufferFunction · 0.85
BuildVkBufferCreateInfoFunction · 0.85
MustGenerateMipsOnCreateFunction · 0.85
TakeOwnershipFunction · 0.85
AllocCommandBufferMethod · 0.80
TransitionImageLayoutMethod · 0.80
CopyBufferToImageMethod · 0.80
GetVkExtentMethod · 0.80
FlushCommandBufferMethod · 0.80
GetMemoryFootprintFunction · 0.50
getMethod · 0.45

Tested by 5

mainFunction · 0.36
mainFunction · 0.36
mainFunction · 0.36
CreateTexturesMethod · 0.36
mainFunction · 0.36