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

Function update2_func

source/emulator/src/Graphics/Objects/RenderTexture.cpp:70–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70static void update2_func(GraphicContext* ctx, CommandBuffer* buffer, const uint64_t* params, void* obj, GpuMemoryScenario scenario,
71 const Vector<GpuMemoryObject>& objects)
72{
73 KYTY_PROFILER_BLOCK("RenderTextureObject::update_func");
74
75 EXIT_IF(obj == nullptr);
76 EXIT_IF(ctx == nullptr);
77 EXIT_IF(params == nullptr);
78 EXIT_IF(objects.IsEmpty());
79
80 auto* vk_obj = static_cast<RenderTextureVulkanImage*>(obj);
81
82 // bool tiled = (params[RenderTextureObject::PARAM_TILED] != 0);
83 // bool neo = (params[RenderTextureObject::PARAM_NEO] != 0);
84 // auto pitch = params[RenderTextureObject::PARAM_PITCH];
85 auto width = params[RenderTextureObject::PARAM_WIDTH];
86 auto height = params[RenderTextureObject::PARAM_HEIGHT];
87
88 vk_obj->layout = VK_IMAGE_LAYOUT_UNDEFINED;
89
90 // if (objects.Size() == 2 && objects.At(0).type == GpuMemoryObjectType::StorageBuffer &&
91 // objects.At(1).type == GpuMemoryObjectType::StorageTexture && scenario == GpuMemoryScenario::GenerateMips)
92 // {
93 // auto* src_obj = static_cast<StorageTextureVulkanImage*>(objects.At(1).obj);
94 if (objects.Size() == 3 && objects.At(0).type == GpuMemoryObjectType::StorageBuffer &&
95 objects.At(1).type == GpuMemoryObjectType::Texture && objects.At(2).type == GpuMemoryObjectType::StorageTexture &&
96 scenario == GpuMemoryScenario::GenerateMips)
97 {
98 auto* src_obj = static_cast<StorageTextureVulkanImage*>(objects.At(2).obj);
99
100 uint32_t mip_width = src_obj->extent.width;
101 uint32_t mip_height = src_obj->extent.height;
102
103 Vector<ImageImageCopy> regions(1);
104
105 bool updated = false;
106
107 for (uint32_t i = 0; i < 16 && !updated; i++)
108 {
109 if (mip_width == width && mip_height == height)
110 {
111 auto mipmap_offset = UtilCalcMipmapOffset(i, width, height);
112
113 regions[0].src_image = src_obj;
114 regions[0].src_level = 0;
115 regions[0].dst_level = 0;
116 regions[0].width = mip_width;
117 regions[0].height = mip_height;
118 regions[0].src_x = mipmap_offset.first;
119 regions[0].src_y = mipmap_offset.second;
120 regions[0].dst_x = 0;
121 regions[0].dst_y = 0;
122
123 if (buffer == nullptr)
124 {
125 UtilFillImage(ctx, regions, vk_obj, static_cast<uint64_t>(VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL));
126 } else
127 {

Callers 1

create2_funcFunction · 0.70

Calls 6

UtilCalcMipmapOffsetFunction · 0.85
UtilFillImageFunction · 0.85
UtilImageToImageFunction · 0.85
AtMethod · 0.80
IsEmptyMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected