MCPcopy Create free account
hub / github.com/InoriRus/Kyty / create2_func

Function create2_func

source/emulator/src/Graphics/Objects/Texture.cpp:527–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527static void* create2_func(GraphicContext* ctx, CommandBuffer* buffer, const uint64_t* params, GpuMemoryScenario scenario,
528 const Vector<GpuMemoryObject>& objects, VulkanMemory* mem)
529{
530 KYTY_PROFILER_BLOCK("TextureObject::CreateFromObjects");
531
532 EXIT_IF(objects.IsEmpty());
533 EXIT_IF(mem == nullptr);
534 EXIT_IF(ctx == nullptr);
535 EXIT_IF(params == nullptr);
536
537 auto fmt = (params[TextureObject::PARAM_FORMAT] >> 16u) & 0xffffu;
538 auto dfmt = (params[TextureObject::PARAM_FORMAT] >> 8u) & 0xffu;
539 auto nfmt = (params[TextureObject::PARAM_FORMAT]) & 0xffu;
540 auto width = params[TextureObject::PARAM_WIDTH_HEIGHT] >> 32u;
541 auto height = params[TextureObject::PARAM_WIDTH_HEIGHT] & 0xffffffffu;
542 auto base_level = params[TextureObject::PARAM_LEVELS] >> 32u;
543 auto levels = params[TextureObject::PARAM_LEVELS] & 0xffffffffu;
544 auto swizzle = params[TextureObject::PARAM_SWIZZLE];
545
546 VkImageUsageFlags vk_usage = get_usage();
547
548 VkComponentMapping components {};
549
550 components.r = get_swizzle(GetDstSel(swizzle, 0));
551 components.g = get_swizzle(GetDstSel(swizzle, 1));
552 components.b = get_swizzle(GetDstSel(swizzle, 2));
553 components.a = get_swizzle(GetDstSel(swizzle, 3));
554
555 auto pixel_format = get_texture_format(dfmt, nfmt, fmt);
556
557 EXIT_NOT_IMPLEMENTED(pixel_format == VK_FORMAT_UNDEFINED);
558 EXIT_NOT_IMPLEMENTED(width == 0);
559 EXIT_NOT_IMPLEMENTED(height == 0);
560
561 auto* vk_obj = new TextureVulkanImage;
562
563 VkImageCreateInfo image_info {};
564 image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
565 image_info.pNext = nullptr;
566 image_info.flags = 0;
567 image_info.imageType = VK_IMAGE_TYPE_2D;
568 image_info.extent.width = width;
569 image_info.extent.height = height;
570 image_info.extent.depth = 1;
571 image_info.mipLevels = levels;
572 image_info.arrayLayers = 1;
573 image_info.format = pixel_format;
574 image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
575 image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
576 image_info.usage = vk_usage;
577 image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
578 image_info.samples = VK_SAMPLE_COUNT_1_BIT;
579
580 if (!CheckSwizzle(ctx, &image_info, &components))
581 {
582 EXIT("swizzle is not supported");
583 }
584

Callers

nothing calls this directly

Calls 10

GetDstSelFunction · 0.85
VulkanAllocateFunction · 0.85
VulkanBindImageMemoryFunction · 0.85
get_usageFunction · 0.70
get_swizzleFunction · 0.70
get_texture_formatFunction · 0.70
CheckSwizzleFunction · 0.70
CheckFormatFunction · 0.70
update2_funcFunction · 0.70
IsEmptyMethod · 0.45

Tested by

no test coverage detected