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

Function update_func

source/emulator/src/Graphics/Objects/StorageTexture.cpp:127–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127static void update_func(GraphicContext* ctx, const uint64_t* params, void* obj, const uint64_t* vaddr, const uint64_t* size, int vaddr_num)
128{
129 KYTY_PROFILER_BLOCK("StorageTextureObject::update_func");
130
131 EXIT_IF(obj == nullptr);
132 EXIT_IF(ctx == nullptr);
133 EXIT_IF(params == nullptr);
134 EXIT_IF(vaddr == nullptr || size == nullptr || vaddr_num != 1);
135
136 auto* vk_obj = static_cast<StorageTextureVulkanImage*>(obj);
137
138 auto tile = params[StorageTextureObject::PARAM_TILE];
139 auto fmt = (params[StorageTextureObject::PARAM_FORMAT] >> 16u) & 0xffffu;
140 auto dfmt = (params[StorageTextureObject::PARAM_FORMAT] >> 8u) & 0xffu;
141 auto nfmt = (params[StorageTextureObject::PARAM_FORMAT]) & 0xffu;
142 auto width = params[StorageTextureObject::PARAM_WIDTH_HEIGHT] >> 32u;
143 auto height = params[StorageTextureObject::PARAM_WIDTH_HEIGHT] & 0xffffffffu;
144 // auto base_level = params[StorageTextureObject::PARAM_LEVELS] >> 32u;
145 auto levels = params[StorageTextureObject::PARAM_LEVELS] & 0xffffffffu;
146 auto pitch = params[StorageTextureObject::PARAM_PITCH];
147 bool neo = Config::IsNeo();
148
149 VkImageLayout vk_layout = VK_IMAGE_LAYOUT_GENERAL;
150
151 EXIT_NOT_IMPLEMENTED(levels >= 16);
152
153 EXIT_NOT_IMPLEMENTED(tile != 8 && tile != 13);
154
155 TileSizeOffset level_sizes[16];
156
157 if (fmt != 0)
158 {
159 TileGetTextureSize2(fmt, width, height, pitch, levels, tile, nullptr, level_sizes, nullptr);
160 } else
161 {
162 TileGetTextureSize(dfmt, nfmt, width, height, pitch, levels, tile, neo, nullptr, level_sizes, nullptr);
163 }
164
165 // dbg_test_mipmaps(ctx, VK_FORMAT_BC3_SRGB_BLOCK, 512, 512);
166
167 uint32_t mip_width = width;
168 uint32_t mip_height = height;
169 uint32_t mip_pitch = pitch;
170
171 Vector<BufferImageCopy> regions(levels);
172 for (uint32_t i = 0; i < levels; i++)
173 {
174 EXIT_NOT_IMPLEMENTED(level_sizes[i].size == 0);
175
176 auto mipmap_offset = UtilCalcMipmapOffset(i, width, height);
177
178 regions[i].offset = level_sizes[i].offset;
179 regions[i].width = mip_width;
180 regions[i].height = mip_height;
181 regions[i].pitch = mip_pitch;
182 regions[i].dst_level = 0;
183 regions[i].dst_x = mipmap_offset.first;
184 regions[i].dst_y = mipmap_offset.second;

Callers 1

create_funcFunction · 0.70

Calls 6

IsNeoFunction · 0.85
TileGetTextureSize2Function · 0.85
TileGetTextureSizeFunction · 0.85
UtilCalcMipmapOffsetFunction · 0.85
TileConvertTiledToLinearFunction · 0.85
UtilFillImageFunction · 0.85

Tested by

no test coverage detected